Browse Source

update更新装运单

qiangxuan 2 months ago
parent
commit
c71bc0f16b

+ 48 - 66
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsend/service/impl/BilletHotsendBaseServiceImpl.java

@@ -170,32 +170,12 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 			x.setUpdateTime(new Date());
 		});
 		billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
-		List<Integer> sizeList = rollClubCommonList.stream().map(RollClubCommon::getLength).distinct().collect(Collectors.toList());
-		List<String> sizeLists = sizeList.stream().map(String::valueOf).collect(Collectors.toList());
-		String sizeString = String.join(",", sizeLists);
-		if (oConvertUtils.isEmpty(billetHotsendDetailsVo.getStorageBill()) || billetHotsendDetailsVo.getStorageBill() == null){
-			// 5号机棒一和6号机高线不产生,装运单和储运记录
-//			if ("roll_height".equals(billetHotsendDetailsVo.getBelongTable()) || "roll_club_one".equals(billetHotsendDetailsVo.getBelongTable())){
-//				List<String> heatNoList = rollClubCommonList.stream().map(RollClubCommon::getHeatNo).distinct().collect(Collectors.toList());
-//
-//				// 生成钢坯装运单记录
-//				StorageBill storageBillInfo = createStorageBill(billetHotsendDetailsVo, rollClubCommonList, sizeLists);
-//				String distinctAssemblyNumber = billetBasicInfoList.stream()
-//						.map(BilletBasicInfo::getAssemblyNumber)
-//						.filter(assemblyNumber -> assemblyNumber!= null)
-//						.distinct()
-//						.collect(Collectors.joining(","));
-//				storageBillInfo.setAssemblyNumber(distinctAssemblyNumber);
-//				storageBillInfo.setId(rollClubOneOrHeightStorageBillId);
-//				if ("roll_height".equals(billetHotsendDetailsVo.getBelongTable())){
-//					storageBillInfo.setBtype("0");
-//				}
-//				storageBillService.save(storageBillInfo);
-//				// 生成钢坯储运单记录
-//				StorageCarLog storageCarLog = createStorageCarLog(storageBillInfo, rollClubCommonList, heatNoList, sizeLists);
-//				storageCarLogService.save(storageCarLog);
-//				result.put("success", "6".equals(billetHotsendDetailsVo.getBilletHotsend().getCcmNo()) ? "保存高线成功!" : "保存棒一成功!");
-//			}
+
+		if ("roll_club_one".equals(billetHotsendDetailsVo.getBelongTable())){
+			result.put("success", "直轧棒一保存成功!");
+			return result;
+		}else if ("roll_height".equals(billetHotsendDetailsVo.getBelongTable())){
+			result.put("success", "热送高线保存成功!");
 			return result;
 		}
 		// 更新装运单 车次总序号、本车车次
@@ -203,33 +183,34 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		queryWrapperSB.eq(StorageBill::getId, billetHotsendDetailsVo.getStorageBill().getId());
 		StorageBill storageBillInfo = storageBillService.getOne(queryWrapperSB);
 		if (oConvertUtils.isEmpty(storageBillInfo)){
-			storageBill.setAmountTotal(rollClubCommonList.size());
-		}else {
-			storageBill.setAmountTotal(storageBillInfo.getAmountTotal() + rollClubCommonList.size());
+			result.put("fail", "钢坯装运单不存在,棒线保存操作失败!");
+			return result;
 		}
+		storageBillInfo.setAmountTotal(storageBillInfo.getAmountTotal() + rollClubCommonList.size());
 		// 取最新的第一条钢坯信息
 		RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
-		storageBill.setSteel(rollClubCommon.getGrade());//钢种
-		storageBill.setSpec(rollClubCommon.getSpec());//规格
-		storageBill.setTypeConfigId(billetHotsendDetailsVo.getBilletHotsendTypeConfigId()); // 钢坯配置类型ID
-		storageBill.setDestination(billetHotsendDetailsVo.getBelongTypeName());// 目的地
-		storageBill.setHeatNo(rollClubCommon.getHeatNo());// 炉号
-		storageBill.setSize(sizeString);// 定尺
-		String distinctAssemblyNumber = billetBasicInfoList.stream()
-				.map(BilletBasicInfo::getAssemblyNumber)
-				.filter(assemblyNumber -> assemblyNumber!= null)
-				.distinct()
-				.collect(Collectors.joining(","));
-		if (oConvertUtils.isNotEmpty(storageBill)){
-			String existingAssemblyNumber = storageBill.getAssemblyNumber();
-			String finalAssemblyNumber = Optional.ofNullable(existingAssemblyNumber)
+		if (rollClubCommon != null) {
+			storageBillInfo.setSteel(rollClubCommon.getGrade());//钢种
+			storageBillInfo.setSpec(rollClubCommon.getSpec());//规格
+			storageBillInfo.setHeatNo(rollClubCommon.getHeatNo());// 炉号
+		}
+		List<Integer> sizeList = rollClubCommonList.stream().map(RollClubCommon::getLength).distinct().collect(Collectors.toList());
+		List<String> sizeLists = sizeList.stream().map(String::valueOf).collect(Collectors.toList());
+		String sizeString = String.join(",", sizeLists);
+		storageBillInfo.setSize(sizeString);// 定尺
+		List<String> stringList = billetBasicInfoList.stream().map(BilletBasicInfo::getAssemblyNumber).filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber)).collect(Collectors.toList());
+		if(oConvertUtils.listIsNotEmpty(stringList)) {
+			String distinctAssemblyNumber = billetBasicInfoList.stream()
+					.map(BilletBasicInfo::getAssemblyNumber)
+					.filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
+					.distinct().collect(Collectors.joining(","));
+			String finalAssemblyNumber = Optional.ofNullable(storageBillInfo.getAssemblyNumber())
+					.filter(oConvertUtils::isNotEmpty)
 					.map(s -> s + "," + distinctAssemblyNumber)
 					.orElse(distinctAssemblyNumber);
-			storageBill.setAssemblyNumber(finalAssemblyNumber);
-		}else {
-			storageBill.setAssemblyNumber(distinctAssemblyNumber);
+			storageBillInfo.setAssemblyNumber(finalAssemblyNumber);
 		}
-		storageBillService.updateById(storageBill);
+		storageBillService.updateById(storageBillInfo);
 		result.put("success", "棒线保存成功!");
 		return result;
 	}
@@ -337,39 +318,40 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		queryWrapperSB.eq(StorageBill::getId, billetHotsendDetailsVo.getStorageBill().getId());
 		StorageBill storageBillInfo = storageBillService.getOne(queryWrapperSB);
 		if (oConvertUtils.isEmpty(storageBillInfo)){
-			storageBill.setAmountTotal(rollClubCommonList.size());
-		}else {
-			storageBill.setAmountTotal(storageBillInfo.getAmountTotal() + rollClubCommonList.size());
+			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+			result.put("fail", "钢坯装运单不存在,棒线发车操作失败!");
+			return result;
 		}
+		storageBillInfo.setAmountTotal(storageBillInfo.getAmountTotal() + rollClubCommonList.size());
 		// 取最新的第一条钢坯信息
 		RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
-		storageBill.setSteel(rollClubCommon.getGrade());//钢种
-		storageBill.setSpec(rollClubCommon.getSpec());//规格
-		storageBill.setHeatNo(rollClubCommon.getHeatNo());//炉号
-		storageBill.setTypeConfigId(billetHotsendDetailsVo.getBilletHotsendTypeConfigId()); // 钢坯配置类型ID
-		storageBill.setDestination(billetHotsendDetailsVo.getBelongTypeName());// 目的地
-		storageBill.setSize(String.join(",", sizeList));
-		storageBill.setOutTime(new Date());
-		List<String> stringList = billetBasicInfoList.stream().map(BilletBasicInfo::getAssemblyNumber).filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber)).collect(Collectors.toList());
-		if(oConvertUtils.listIsNotEmpty(stringList)) {
+		storageBillInfo.setSteel(rollClubCommon.getGrade());//钢种
+		storageBillInfo.setSpec(rollClubCommon.getSpec());//规格
+		storageBillInfo.setHeatNo(rollClubCommon.getHeatNo());// 炉号
+		String sizeString = String.join(",", sizeList.stream().map(String::valueOf).collect(Collectors.toList()));
+		storageBillInfo.setSize(sizeString);// 定尺
+		List<String> assemblyNumberList = billetBasicInfoList.stream().map(BilletBasicInfo::getAssemblyNumber).filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber)).collect(Collectors.toList());
+		if(oConvertUtils.listIsNotEmpty(assemblyNumberList)) {
 			String distinctAssemblyNumber = billetBasicInfoList.stream()
 					.map(BilletBasicInfo::getAssemblyNumber)
 					.filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
 					.distinct().collect(Collectors.joining(","));
-			String finalAssemblyNumber = Optional.ofNullable(storageBill.getAssemblyNumber())
+			String finalAssemblyNumber = Optional.ofNullable(storageBillInfo.getAssemblyNumber())
 					.filter(oConvertUtils::isNotEmpty)
 					.map(s -> s + "," + distinctAssemblyNumber)
 					.orElse(distinctAssemblyNumber);
-			storageBill.setAssemblyNumber(finalAssemblyNumber);
+			storageBillInfo.setAssemblyNumber(finalAssemblyNumber);
 		}
-		storageBillService.updateById(storageBill);
+		storageBillInfo.setOutTime(new Date());
+		storageBillService.updateById(storageBillInfo);
+
 		// 生成储运单
 		StorageCarLog storageCarLog = new StorageCarLog();
-		BeanUtils.copyProperties(storageBill, storageCarLog);
-		storageCarLog.setDestination(billetHotsendTypeConfig.getTypeName());// 目的地
-		storageCarLog.setCarNm(storageBill.getLicensePlate());// 车牌号
+		BeanUtils.copyProperties(storageBillInfo, storageCarLog);
+		storageCarLog.setDestination(storageBillInfo.getDestination());// 目的地
+		storageCarLog.setCarNm(storageBillInfo.getLicensePlate());// 车牌号
 //			storageCarLog.setFixedWeight();// 定重
-		storageCarLog.setTypeConfigId(billetHotsendDetailsVo.getBilletHotsendTypeConfigId()); // 钢坯配置类型ID
+		storageCarLog.setTypeConfigId(storageBillInfo.getTypeConfigId()); // 钢坯配置类型ID
 		storageCarLog.setHeatNo(String.join(",", heatNoList));
 		storageCarLog.setSize(String.join(",", sizeList));// 定尺
 		storageCarLog.setAmount(Integer.valueOf((int) count));// 支数

+ 41 - 55
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/stackingAndLoadingVehicles/service/impl/StackingAndLoadingVehiclesServiceImpl.java

@@ -194,14 +194,14 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             x.setUpdateTime(new Date());
         });
         billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
-        // 取最新的第一条钢坯信息
-        RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
         // 根据装运单ID查询装运单信息
         StorageBill storageBillInfo = storageBillService.getById(storageBill.getId());
         if (oConvertUtils.isEmpty(storageBillInfo)){
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             result.put("fail", "钢坯装运单信息为空,堆垛保存操作失败!");
             return result;
         }
+        RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
         storageBillInfo.setSteel(rollClubCommon.getGrade());//钢种
         storageBillInfo.setSpec(rollClubCommon.getSpec());//规格
         storageBillInfo.setAmountTotal((oConvertUtils.isNotEmpty(storageBillInfo.getAmountTotal()) ? storageBillInfo.getAmountTotal() : 0) + stackingAndLoadingVehiclesList.size() * 4);
@@ -478,9 +478,9 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                     RollHeight rollHeight = new RollHeight();
                     if (oConvertUtils.isEmpty(rollHeight1)) {
 
-                        String distinctAssemblyNumber = rollClubCommonList.stream()
-                                .map(RollClubCommon::getAssemblyNumber)
-                                .filter(assemblyNumber -> assemblyNumber != null)
+                        String distinctAssemblyNumber = billetBasicInfoList.stream()
+                                .map(BilletBasicInfo::getAssemblyNumber)
+                                .filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
                                 .distinct()
                                 .collect(Collectors.joining(","));
                         // 堆垛保存发车时 目的地为高线时 保存上若信息
@@ -502,29 +502,6 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                         // 堆垛发车时 目的地为高线 更新高线信息
                         rollHeight1.setAmountTotal(rollHeight1.getAmountTotal() + 1);// 总支数
                         rollHeight1.setBlankOutput(rollHeight1.getBlankOutput() + y.getBilletWeight());
-                        rollHeight1.setUpdateTime(new Date());
-
-                        String assemblyNumber = "";
-                        if (oConvertUtils.isNotEmpty(rollHeight1.getAssemblyNumber())) {
-                            assemblyNumber = rollHeight1.getAssemblyNumber() + "," + rollClubCommonList.stream()
-                                    .map(RollClubCommon::getAssemblyNumber)
-                                    .filter(t -> oConvertUtils.isNotEmpty(t))
-                                    .distinct()
-                                    .collect(Collectors.joining(","));
-                            // 对 assemblyNumber 进行二次去重
-                            String finalAssemblyNumber = Arrays.stream(assemblyNumber.split(","))
-                                    .filter(s -> oConvertUtils.isNotEmpty(s))
-                                    .distinct()
-                                    .collect(Collectors.joining(","));
-                            rollHeight1.setAssemblyNumber(finalAssemblyNumber);
-                        } else {
-                            assemblyNumber = rollClubCommonList.stream()
-                                    .map(RollClubCommon::getAssemblyNumber)
-                                    .filter(n -> oConvertUtils.isNotEmpty(n))
-                                    .distinct()
-                                    .collect(Collectors.joining(","));
-                            rollHeight1.setAssemblyNumber(assemblyNumber);
-                        }
                         rollHeightService.updateById(rollHeight1);
                     }
                 });
@@ -543,6 +520,12 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
                 rollHeightDetails.setCreateTime(new Date());
                 rollHeightDetails.setUpdateTime(new Date());
                 rollHeightDetails.setBlankOutput(billetWeightTotal);//出坯量
+                String distinctAssemblyNumber = billetBasicInfoList.stream()
+                        .map(BilletBasicInfo::getAssemblyNumber)
+                        .filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
+                        .distinct()
+                        .collect(Collectors.joining(","));
+                rollHeightDetails.setAssemblyNumber(distinctAssemblyNumber);
                 rollHeightDetailsList.add(rollHeightDetails);
             }
         });
@@ -684,36 +667,39 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
 
         }
         // 6 更新装运单 storage_bill 取最新的第一条钢坯信息更新钢种和规格
-        RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
-        storageBill.setSteel(rollClubCommon.getGrade());//钢种
-        storageBill.setSpec(rollClubCommon.getSpec());//规格
-        storageBill.setHeatNo(rollClubCommon.getHeatNo());//炉号
-        storageBill.setSize(String.join(",", sizeList));
-        storageBill.setTypeConfigId(loadingParams.getDestinationId()); // 钢坯配置类型ID
-        storageBill.setDestination(loadingParams.getDestination());// 目的地
-        storageBill.setAmountTotal(storageBill.getAmountTotal() + stackingAndLoadingVehiclesList.size() * 4);
-        storageBill.setOutTime(new Date());
 
-        String distinctAssemblyNumber = billetBasicInfoList.stream()
-                .map(BilletBasicInfo::getAssemblyNumber)
-                .filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
-                .distinct()
-                .collect(Collectors.joining(","));
-
-        if (oConvertUtils.isNotEmpty(storageBill)) {
-            String existingAssemblyNumber = storageBill.getAssemblyNumber();
-            String finalAssemblyNumber = Optional.ofNullable(existingAssemblyNumber)
+        // 根据装运单ID查询装运单信息
+        StorageBill storageBillInfo = storageBillService.getById(storageBill.getId());
+        if (oConvertUtils.isEmpty(storageBillInfo)){
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            result.put("fail", "钢坯装运单信息为空,堆垛发车操作失败!");
+            return result;
+        }
+        RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
+        if (rollClubCommon != null){
+            storageBillInfo.setSteel(rollClubCommon.getGrade());//钢种
+            storageBillInfo.setSpec(rollClubCommon.getSpec());//规格
+            storageBillInfo.setHeatNo(rollClubCommon.getHeatNo());//炉号
+        }
+        storageBillInfo.setSize(String.join(",", sizeList));
+        storageBillInfo.setAmountTotal((oConvertUtils.isNotEmpty(storageBillInfo.getAmountTotal()) ? storageBillInfo.getAmountTotal() : 0) + stackingAndLoadingVehiclesList.size() * 4);
+        List<String> assemblyNumberList = billetBasicInfoList.stream().map(BilletBasicInfo::getAssemblyNumber).filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber)).collect(Collectors.toList());
+        if(oConvertUtils.listIsNotEmpty(assemblyNumberList)) {
+            String distinctAssemblyNumber = billetBasicInfoList.stream()
+                    .map(BilletBasicInfo::getAssemblyNumber)
+                    .filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
+                    .distinct().collect(Collectors.joining(","));
+            String finalAssemblyNumber = Optional.ofNullable(storageBillInfo.getAssemblyNumber())
+                    .filter(oConvertUtils::isNotEmpty)
                     .map(s -> s + "," + distinctAssemblyNumber)
                     .orElse(distinctAssemblyNumber);
-            storageBill.setAssemblyNumber(finalAssemblyNumber);
-        } else {
-            storageBill.setAssemblyNumber(distinctAssemblyNumber);
+            storageBillInfo.setAssemblyNumber(finalAssemblyNumber);
         }
-
-        storageBillService.updateById(storageBill);
+        storageBillInfo.setOutTime(new Date());
+        storageBillService.updateById(storageBillInfo);
         // 7 发车后,新增钢坯堆垛储运信息,生成储运单 storage_car_log
         StorageCarLog storageCarLog = new StorageCarLog();
-        BeanUtils.copyProperties(storageBill, storageCarLog);
+        BeanUtils.copyProperties(storageBillInfo, storageCarLog);
 
         LambdaQueryWrapper<StackingDownLog> queryWrappersd = new LambdaQueryWrapper();
         queryWrappersd.eq(StackingDownLog::getCcmNo, storageBill.getCcmNo()).eq(StackingDownLog::getStorageBillId, storageBill.getId());
@@ -721,9 +707,9 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
 
         Integer bx = Integer.valueOf((int) count);
         Integer dd = stackingDownLogs.size() * 4 + bx;
-        storageCarLog.setDestination(loadingParams.getDestination());// 目的地
-        storageCarLog.setCarNm(storageBill.getLicensePlate());// 车牌号
-        storageCarLog.setTypeConfigId(billetHotsendTypeConfig.getId()); // 钢坯配置类型ID
+        storageCarLog.setDestination(storageBillInfo.getDestination());// 目的地
+        storageCarLog.setCarNm(storageBillInfo.getLicensePlate());// 车牌号
+        storageCarLog.setTypeConfigId(storageBillInfo.getTypeConfigId()); // 钢坯配置类型ID
         storageCarLog.setHeatNo(String.join(",", heatNoList));
         storageCarLog.setSize(String.join(",", sizeList));// 定尺
         storageCarLog.setAmount(dd);// 支数