|
@@ -91,12 +91,6 @@ public class StockDetailServiceImpl extends ServiceImpl<StockDetailMapper, Stock
|
|
|
BigDecimal availableArea = BigDecimalUtil.init(availableQuantity).multiply(materialWidth).divide(100, 1).getValue();
|
|
|
item.put("availableArea", availableArea);
|
|
|
|
|
|
-
|
|
|
- Map<String, Object> recommendMaterial = baseMapper.selectRecommendMaterial(materialCode, availableQuantity);
|
|
|
- if (recommendMaterial != null) {
|
|
|
- item.putAll(recommendMaterial);
|
|
|
- }
|
|
|
-
|
|
|
Map<String, BigDecimal> materialCodeQuantityMap = map.get(materialCode);
|
|
|
if (materialCodeQuantityMap == null) {
|
|
|
item.put("totalArea", BigDecimal.ZERO);
|
|
@@ -124,6 +118,20 @@ public class StockDetailServiceImpl extends ServiceImpl<StockDetailMapper, Stock
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ Map<String, List<Map<String, Object>>> listMapByMaterialCode = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(item -> item.get("materialCode").toString()));
|
|
|
+
|
|
|
+ listMapByMaterialCode.forEach((k, v) -> {
|
|
|
+ List<Map<String, Object>> itemList = baseMapper.selectRecommendMaterial(k, (BigDecimal) v.get(0).get("availableQuantity"));
|
|
|
+
|
|
|
+ int size = Math.min(v.size(), itemList.size());
|
|
|
+
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ v.get(i).putAll(itemList.get(i));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
return list;
|
|
|
}
|
|
|
|
|
@@ -131,12 +139,27 @@ public class StockDetailServiceImpl extends ServiceImpl<StockDetailMapper, Stock
|
|
|
@Override
|
|
|
public void submitRestrictedPicking(Map<String, Object> condition) {
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
List<Map<String, Object>> appointInfoList = (List<Map<String, Object>>) condition.get("appointInfo");
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> actualList = (List<Map<String, Object>>) condition.get("actual");
|
|
|
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(appointInfoList) || ObjectUtil.isEmpty(actualList)) return;
|
|
|
+
|
|
|
+
|
|
|
+ Map<Object, List<Map<String, Object>>> appointInfoByCodeMap = appointInfoList.stream()
|
|
|
+ .collect(Collectors.groupingBy(item -> item.get("materialCode")));
|
|
|
+
|
|
|
+
|
|
|
+ Map<Object, List<Map<String, Object>>> actualByCodeMap = actualList.stream()
|
|
|
+ .collect(Collectors.groupingBy(item -> item.get("materialCode")));
|
|
|
+
|
|
|
|
|
|
String jobNo = condition.get("jobNo").toString();
|
|
|
|
|
@@ -146,85 +169,193 @@ public class StockDetailServiceImpl extends ServiceImpl<StockDetailMapper, Stock
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
-
|
|
|
- HashSet<String> materialCodeList = new HashSet<>();
|
|
|
+
|
|
|
+ List<Scheduling> schedulingList = new ArrayList<>();
|
|
|
|
|
|
-
|
|
|
+
|
|
|
List<SchedulingActual> schedulingActualList = new ArrayList<>();
|
|
|
|
|
|
- List<Scheduling> schedulingList = appointInfoList.stream().map(item -> {
|
|
|
|
|
|
- Scheduling scheduling = new Scheduling();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- scheduling.setId(item.get("id").toString());
|
|
|
- String type = item.get("type").toString();
|
|
|
+ appointInfoByCodeMap.forEach((k, v) -> {
|
|
|
|
|
|
- String materialCode = item.get("materialCode").toString();
|
|
|
- materialCodeList.add(materialCode);
|
|
|
-
|
|
|
- Object rfidCode = item.get("rfidCode");
|
|
|
- if (ObjectUtil.isNotEmpty(rfidCode)) {
|
|
|
- SchedulingActual schedulingActual = new SchedulingActual();
|
|
|
- schedulingActual.setMaterialCode(materialCode);
|
|
|
- schedulingActual.setMaterialRfid(rfidCode.toString());
|
|
|
- schedulingActual.setQuantity(BigDecimalUtil.objToBigDecimal(item.get("quantity")));
|
|
|
- schedulingActual.setType(2);
|
|
|
- schedulingActual.setJobNo(jobNo);
|
|
|
- schedulingActual.setFlag(flag);
|
|
|
- schedulingActual.setCreateTime(date);
|
|
|
- schedulingActualList.add(schedulingActual);
|
|
|
- }
|
|
|
+
|
|
|
+ 实际领料信息封装为map格式
|
|
|
+ key:rfid
|
|
|
+ value:详细详细
|
|
|
+ */
|
|
|
+ Map<String, Map<String, Object>> actualByRfidMap = actualByCodeMap.get(k).stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ item -> item.get("materialRfid").toString(),
|
|
|
+ item -> item
|
|
|
+ ));
|
|
|
|
|
|
- if (type.equals("1")) {
|
|
|
- scheduling.setMaterialStatus(1);
|
|
|
- scheduling.setMaterialFlag(flag);
|
|
|
- } else {
|
|
|
- scheduling.setPaperStatus(1);
|
|
|
- scheduling.setPaperFlag(flag);
|
|
|
- }
|
|
|
+
|
|
|
+ 推荐领料信息rfid去匹配实际领料rfid
|
|
|
+ 如果匹配到,则为推荐领料出库
|
|
|
+ */
|
|
|
+ for (int i = 0; i < v.size(); i++) {
|
|
|
+ Map<String, Object> itemV = v.get(i);
|
|
|
|
|
|
- return scheduling;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ String rfidCode = itemV.get("rfidCode").toString();
|
|
|
|
|
|
- schedulingService.updateBatchById(schedulingList);
|
|
|
+
|
|
|
+ Map<String, Object> map = actualByRfidMap.get(rfidCode);
|
|
|
|
|
|
- for (Map<String, Object> map : actualList) {
|
|
|
- String materialCode = map.get("materialCode").toString();
|
|
|
- String materialRfid = map.get("materialRfid").toString();
|
|
|
- BigDecimal quantity = BigDecimalUtil.objToBigDecimal(map.get("quantity"));
|
|
|
+
|
|
|
+ if (map != null) {
|
|
|
|
|
|
- if (!materialCodeList.contains(materialCode)) continue;
|
|
|
+ Scheduling scheduling = createScheduling(itemV, flag);
|
|
|
+ schedulingList.add(scheduling);
|
|
|
+ v.remove(itemV);
|
|
|
+ i--;
|
|
|
|
|
|
-
|
|
|
- boolean isRecommendFlag = false;
|
|
|
+ SchedulingActual schedulingActual = createSchedulingActual(1, map, flag, jobNo, date);
|
|
|
+ schedulingActualList.add(schedulingActual);
|
|
|
+ actualByRfidMap.remove("rfidCode");
|
|
|
|
|
|
-
|
|
|
- for (SchedulingActual schedulingActual : schedulingActualList) {
|
|
|
- if (schedulingActual.getMaterialRfid().equals(materialRfid)) {
|
|
|
- schedulingActual.setType(1);
|
|
|
- isRecommendFlag = true;
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!isRecommendFlag) {
|
|
|
- SchedulingActual schedulingActual = new SchedulingActual();
|
|
|
- schedulingActual.setMaterialCode(materialCode);
|
|
|
- schedulingActual.setMaterialRfid(materialRfid);
|
|
|
- schedulingActual.setQuantity(quantity);
|
|
|
- schedulingActual.setType(3);
|
|
|
- schedulingActual.setJobNo(jobNo);
|
|
|
- schedulingActual.setFlag(flag);
|
|
|
- schedulingActual.setCreateTime(date);
|
|
|
+
|
|
|
+ List<Map<String, Object>> actual = new ArrayList<>(actualByRfidMap.values());
|
|
|
+
|
|
|
+ int size = Math.min(actual.size(), v.size());
|
|
|
+
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ Map<String, Object> map = v.get(i);
|
|
|
+
|
|
|
+ Scheduling scheduling = createScheduling(map, flag);
|
|
|
+ schedulingList.add(scheduling);
|
|
|
+
|
|
|
+ map.put("materialRfid", map.get("rfidCode"));
|
|
|
+ SchedulingActual schedulingActual = createSchedulingActual(2, map, flag, jobNo, date);
|
|
|
schedulingActualList.add(schedulingActual);
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ for (Map<String, Object> item : actual) {
|
|
|
+ SchedulingActual schedulingActual = createSchedulingActual(3, item, flag, jobNo, date);
|
|
|
+ schedulingActualList.add(schedulingActual);
|
|
|
+ }
|
|
|
|
|
|
+ });
|
|
|
+
|
|
|
+ schedulingService.updateBatchById(schedulingList);
|
|
|
schedulingActualService.saveBatch(schedulingActualList);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 生成推荐领料信息对象
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Scheduling createScheduling(Map<String, Object> map, Long flag) {
|
|
|
+ Scheduling scheduling = new Scheduling();
|
|
|
+
|
|
|
+ scheduling.setId(map.get("id").toString());
|
|
|
+ String type = map.get("type").toString();
|
|
|
+
|
|
|
+ if (type.equals("1")) {
|
|
|
+ scheduling.setMaterialStatus(1);
|
|
|
+ scheduling.setMaterialFlag(flag);
|
|
|
+ } else {
|
|
|
+ scheduling.setPaperStatus(1);
|
|
|
+ scheduling.setPaperFlag(flag);
|
|
|
+ }
|
|
|
+
|
|
|
+ return scheduling;
|
|
|
+ }
|
|
|
+
|
|
|
+ private SchedulingActual createSchedulingActual(Integer type, Map<String, Object> map, Long flag, String jobNo, Date date) {
|
|
|
+ SchedulingActual schedulingActual = new SchedulingActual();
|
|
|
+ schedulingActual.setMaterialCode(map.get("materialCode").toString());
|
|
|
+ schedulingActual.setMaterialRfid(map.get("materialRfid").toString());
|
|
|
+ schedulingActual.setQuantity(BigDecimalUtil.objToBigDecimal(map.get("quantity")));
|
|
|
+ schedulingActual.setType(type);
|
|
|
+ schedulingActual.setJobNo(jobNo);
|
|
|
+ schedulingActual.setFlag(flag);
|
|
|
+ schedulingActual.setCreateTime(date);
|
|
|
+ return schedulingActual;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public List<HashMap<String, Object>> pickingTrackingUserStatistics(Map<String, String> condition) {
|
|
|
|
|
@@ -388,10 +519,10 @@ public class StockDetailServiceImpl extends ServiceImpl<StockDetailMapper, Stock
|
|
|
*/
|
|
|
private void setRatio(PickingTrackingNumStatisticsResult result) {
|
|
|
|
|
|
- result.setAppointOutputRatio(BigDecimalUtil.init(result.getAppointArea()).divideTry(result.getPlanArea(), 4).getValue());
|
|
|
+ result.setAppointOutputRatio(BigDecimalUtil.init(result.getPlanArea()).divideTry(result.getAppointArea(), 4).getValue());
|
|
|
|
|
|
|
|
|
- result.setActualOutputRatio(BigDecimalUtil.init(result.getActualArea()).divideTry(result.getPlanArea(), 4).getValue());
|
|
|
+ result.setActualOutputRatio(BigDecimalUtil.init(result.getPlanArea()).divideTry(result.getActualArea(), 4).getValue());
|
|
|
|
|
|
|
|
|
result.setOutputRatioDifference(result.getAppointOutputRatio().subtract(result.getActualOutputRatio()));
|