qiangxuan 2 mesiacov pred
rodič
commit
984dc496b7

+ 1 - 1
zgztBus/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -157,7 +157,7 @@ public class ShiroConfig {
         //车位模块排除
         filterChainDefinitionMap.put("/storageBill/listNoToken", "anon");
         filterChainDefinitionMap.put("/storageBill/editNoToken", "anon");
-
+        filterChainDefinitionMap.put("/storageBill/editSynData", "anon");
         // update-begin--author:liusq Date:20230522 for:[issues/4829]访问不存在的url时会提示Token失效,请重新登录呢
         //错误路径排除
         filterChainDefinitionMap.put("/error", "anon");

+ 22 - 16
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/controller/StorageBillController.java

@@ -457,16 +457,12 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 		StorageBill old = storageBillService.getById(storageBill.getId());
 		if("1024".equals(old.getTypeConfigId()) && oConvertUtils.isNotEmpty(storageBill.getDestination())){
 			// 合并更新字段
-			StorageBill mergedSB = new StorageBill();
-			BeanUtils.copyProperties(old, mergedSB);
-			mergedSB.setTypeConfigId(storageBill.getTypeConfigId());
-			mergedSB.setDestination(storageBill.getDestination());
-
-			log.info("钢坯装运单编辑,未知目的地数据开始同步:{}", mergedSB.getLicensePlate());
-			JSONObject jsonObject = storageBillService.billetAutoTmpDataSyn(mergedSB);
-			if (jsonObject.containsKey("fail")) {
-				storageBillService.updateById(mergedSB);
-			}
+			BeanUtils.copyProperties(storageBill, old);
+
+			log.info("钢坯装运单编辑,未知目的地数据开始同步:{}", old.getAmountTotal());
+
+			JSONObject jsonObject = storageBillService.billetAutoTmpDataSyn(old);
+
 			log.info("钢坯装运单编辑,未知目的地数据同步结果:{}", jsonObject);
 		} else {
 			if (!old.getLicensePlate().equals(storageBill.getLicensePlate())){
@@ -1360,16 +1356,26 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 			storageBillService.updateById(bill);
 			return Result.OK("确认车牌编辑成功!");
 		}
+        return Result.error("系统异常!");
+    }
+
+	@ApiOperation(value="钢坯装运单-看板确认目的地", notes="钢坯装运单-看板确认目的地")
+	@RequestMapping(value = "/editSynData", method = {RequestMethod.PUT})
+	public Result<String> editSynData(@RequestBody StorageBill storageBill) {
+		if(oConvertUtils.isEmpty(storageBill.getId())) {
+			return Result.error("参数异常!");
+		}
+		StorageBill bill = storageBillService.getById(storageBill.getId());
 		// 原始装运单目的地ID是1024,才走数据同步
-		if("1024".equals(bill.getTypeConfigId())){
-			bill.setDestination(storageBill.getDestination());
-			bill.setTypeConfigId(storageBill.getTypeConfigId());
-			JSONObject jsonObject = storageBillService.billetAutoTmpDataSyn(bill);
+		if("1024".equals(bill.getTypeConfigId()) && !"1024".equals(storageBill.getTypeConfigId())){
+			JSONObject jsonObject = storageBillService.billetAutoTmpDataSynConfirm(storageBill);
 			log.info("{}{}", "看板确认目的地数据同步结果:", jsonObject);
 			return Result.OK("确认目的地成功!");
+		}else {
+			log.info("{}{}", "看板确认目的地参数有误:", JSON.toJSON(storageBill));
+			return Result.OK("确认目的地失败!");
 		}
-        return Result.error("系统异常!");
-    }
+	}
 
 	@ApiOperation(value="当班所有装运信息-车辆运行看板", notes="当班所有装运信息-车辆运行看板")
 	@GetMapping(value = "/queryOnDutyAllStorageBillBoard")

+ 1 - 0
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/service/IStorageBillService.java

@@ -78,4 +78,5 @@ public interface IStorageBillService extends IService<StorageBill> {
 
     OnDutySteelVo queryOnDutySteel(String ccmNo,String changeShiftId);
 
+    JSONObject billetAutoTmpDataSynConfirm(StorageBill bill);
 }

+ 135 - 8
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/service/impl/StorageBillServiceImpl.java

@@ -2747,14 +2747,14 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
     public JSONObject billetAutoTmpDataSyn(StorageBill storageBill) {
         JSONObject result = new JSONObject();
         try {
-            log.info("{}{}", "钢坯轧钢外运未知目的地数据同步装运单信息:", JSON.toJSON(storageBill));
+            log.info("{}{}", "编辑装运单未知目的地数据同步装运单信息:", JSON.toJSON(storageBill));
             List<RollClubCommon> rollClubCommonList = new ArrayList<>();
             // 根据装运单ID查询钢坯临时表
             List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(new LambdaQueryWrapper<BilletAutoTmp>()
                     .eq(BilletAutoTmp::getStorageBillId, storageBill.getId()));
             if (oConvertUtils.listIsEmpty(billetAutoTmpList)){
                 baseMapper.updateById(storageBill);
-                result.put("fail", "钢坯轧钢外运未知目的地明细不存在,更新目的地成功!");
+                result.put("fail", "编辑装运单未知目的地明细不存在,更新目的地成功!");
                 return result;
             }
             billetAutoTmpList.forEach(x ->{
@@ -2766,7 +2766,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 rollClubCommonList.add(rollClubCommon);
             });
 
-            log.info("{}{}", "未知目的地数据同步临时表总条数:", rollClubCommonList.size());
+            log.info("{}{}", "编辑装运单未知目的地数据同步临时表总条数:", rollClubCommonList.size());
 
             // 根据ID获取钢坯配置信息
             BilletHotsend billetHotsend = new BilletHotsend();
@@ -2799,8 +2799,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 JSONObject jsonObject = commonBilletHotsenAndDetailsHandle(billetHotsend, billetHotsendDetailsVo, billetHotsendTypeConfig, storageBill, groupRollClubCommonList, null);
                 if (jsonObject.containsKey("fail")) {
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                    log.info("{}{}", "B端钢坯装运单未知目的地数据同步操作失败,事务回滚!", jsonObject);
-                    result.put("fail", "B端钢坯装运单未知目的地数据同步操作失败!");
+                    log.info("{}{}", "编辑装运单未知目的地数据同步操作失败,事务回滚!", jsonObject);
+                    result.put("fail", "编辑装运单未知目的地数据同步操作失败!");
                     return result;
                 }
             }
@@ -2822,11 +2822,138 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 x.setUpdateTime(new Date());
             });
             billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
-            log.info("{}{}", "B端钢坯装运单未知目的地数据同步时,装运单总支数!", storageBill.getAmountTotal());
+
+            log.info("{}{}", "B端编辑装运单未知目的地数据同步时,装运单总支数:", storageBill.getAmountTotal());
+            // 维护总支数
+            storageBill.setAmountTotal(storageBill.getAmountTotal() + rollClubCommonList.size());
+
+            log.info("{}{}", "B端编辑装运单未知目的地数据同步后,累加临时表后的装运单总支数:", storageBill.getAmountTotal());
+            // 取最新的第一条钢坯信息
+            RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
+            if (rollClubCommon != null) {
+                storageBill.setSteel(rollClubCommon.getGrade());//钢种
+                storageBill.setSpec(rollClubCommon.getSpec());//规格
+                storageBill.setHeatNo(rollClubCommon.getHeatNo());// 炉号
+            }
+            List<Integer> sizeList = rollClubCommonList.stream().map(RollClubCommon::getLength).distinct().collect(Collectors.toList());
+            String sizeString = String.join(",", sizeList.stream().map(String::valueOf).collect(Collectors.toList()));
+            storageBill.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())
+                        .filter(oConvertUtils::isNotEmpty)
+                        .map(s -> s + "," + distinctAssemblyNumber)
+                        .orElse(distinctAssemblyNumber);
+                storageBill.setAssemblyNumber(finalAssemblyNumber);
+            }
+            storageBill.setUpdateTime(new Date());
+            baseMapper.updateById(storageBill);
+
+            // 物理删除钢坯临时表记录
+            billetAutoTmpService.removeBatchByIds(billetAutoTmpList.stream().map(BilletAutoTmp::getId).collect(Collectors.toList()));
+            result.put("success", "B端编辑装运单未知目的地明细同步成功!");
+            return result;
+        }catch (Exception e){
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            // 记录异常日志
+            log.error("B端编辑装运单未知目的地明细同步发生异常", e.getMessage());
+            result.put("fail", "系统错误,请稍后再试!");
+            return result;
+        }
+    }
+
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public JSONObject billetAutoTmpDataSynConfirm(StorageBill storageBill) {
+        JSONObject result = new JSONObject();
+        try {
+            log.info("{}{}", "看板确认目的地数据同步装运单信息:", JSON.toJSON(storageBill));
+            List<RollClubCommon> rollClubCommonList = new ArrayList<>();
+            // 根据装运单ID查询钢坯临时表
+            List<BilletAutoTmp> billetAutoTmpList = billetAutoTmpService.list(new LambdaQueryWrapper<BilletAutoTmp>()
+                    .eq(BilletAutoTmp::getStorageBillId, storageBill.getId()));
+            if (oConvertUtils.listIsEmpty(billetAutoTmpList)){
+                baseMapper.updateById(storageBill);
+                result.put("fail", "钢坯轧钢外运未知目的地明细不存在,看板确认目的地更新成功!");
+                return result;
+            }
+            billetAutoTmpList.forEach(x ->{
+                RollClubCommon rollClubCommon = new RollClubCommon();
+                BeanUtils.copyProperties(x, rollClubCommon);
+                rollClubCommon.setGrade(x.getSteel());
+                rollClubCommon.setLength(Integer.valueOf(x.getSize()));
+                rollClubCommon.setBilletWeight(x.getBlankOutput());
+                rollClubCommonList.add(rollClubCommon);
+            });
+
+            log.info("{}{}", "看板确认目的地同步临时表总条数:", rollClubCommonList.size());
+
+            // 根据ID获取钢坯配置信息
+            BilletHotsend billetHotsend = new BilletHotsend();
+            billetHotsend.setCcmNo(storageBill.getCcmNo());
+            BilletHotsendTypeConfig billetHotsendTypeConfig = billetHotsendTypeConfigService.getById(storageBill.getTypeConfigId());
+
+            BilletHotsendDetailsVo billetHotsendDetailsVo = new BilletHotsendDetailsVo();
+            billetHotsendDetailsVo.setBelongTable(billetHotsendTypeConfig.getBelongTable());
+            billetHotsendDetailsVo.setBelongTypeName(billetHotsendTypeConfig.getTypeName());
+
+            billetHotsendDetailsVo.setDestination(billetHotsendTypeConfig.getTypeName());
+            billetHotsendDetailsVo.setDestinationId(billetHotsendTypeConfig.getId());
+            billetHotsendDetailsVo.setBilletHotsendTypeConfigId(billetHotsendTypeConfig.getId());
+
+            billetHotsendDetailsVo.setStorageBill(storageBill);
+            billetHotsendDetailsVo.setBilletHotsend(billetHotsend);
+            billetHotsendDetailsVo.setRollClubCommonList(rollClubCommonList);
+
+            Map<String, List<RollClubCommon>> rollClubCommonLists = groupByShiftAttributes(rollClubCommonList);
+            /**
+             * 维护热送单炉信息 保存棒二或或棒三明细 更新钢坯基础信息
+             * 在这里可以添加更多针对每个分组(键和对应列表)的业务逻辑操作,比如遍历列表中的元素等
+             */
+            for (Map.Entry<String, List<RollClubCommon>> entry : rollClubCommonLists.entrySet()) {
+                String[] parts = entry.getKey().split(",");
+                billetHotsend.setHeatNo(parts[0]);// 炉号
+                billetHotsend.setShiftGroup(parts[1]);// 班组
+                billetHotsend.setShift(parts[2]);// 班别
+                List<RollClubCommon> groupRollClubCommonList = entry.getValue();
+                JSONObject jsonObject = commonBilletHotsenAndDetailsHandle(billetHotsend, billetHotsendDetailsVo, billetHotsendTypeConfig, storageBill, groupRollClubCommonList, null);
+                if (jsonObject.containsKey("fail")) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    log.info("{}{}", "B端钢坯装运单未知目的地数据同步操作失败,看板确认目的地事务回滚!", jsonObject);
+                    result.put("fail", "B端钢坯装运单看板确认目的地同步操作失败!");
+                    return result;
+                }
+            }
+            List<String> billetNos = rollClubCommonList.stream().map(RollClubCommon::getBilletNo).collect(Collectors.toList());
+            //查询并批量更新钢坯基础信息 belongTable
+            LambdaQueryWrapper<BilletBasicInfo> queryWrapperls = new LambdaQueryWrapper<BilletBasicInfo>()
+                    .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(billetHotsend.getCcmNo()))
+                    .in(BilletBasicInfo::getBilletNo, billetNos);
+            List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapperls);
+            billetBasicInfoList.forEach(x ->{
+                if ("roll_club_two".equals(billetHotsendDetailsVo.getBelongTable())){
+                    x.setBelongTable("roll_club_two");
+                }else if ("roll_club_three".equals(billetHotsendDetailsVo.getBelongTable())){
+                    x.setBelongTable("roll_club_three");
+                }else if ("roll_out_shipp".equals(billetHotsendDetailsVo.getBelongTable())){
+                    x.setBelongTable("roll_out_shipp");
+                }
+                x.setBhtcId(billetHotsendDetailsVo.getBilletHotsendTypeConfigId());
+                x.setUpdateTime(new Date());
+            });
+            billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
+            log.info("{}{}", "B端看板确认目的地数据同步时,装运单总支数:", storageBill.getAmountTotal());
             // 维护总支数
             storageBill.setAmountTotal(storageBill.getAmountTotal() + rollClubCommonList.size());
 
-            log.info("{}{}", "B端钢坯装运单未知目的地数据同步时,累加临时表后的,装运单总支数!", storageBill.getAmountTotal());
+            log.info("{}{}", "B端看板确认目的地数据同步后,累加临时表后的装运单总支数:", storageBill.getAmountTotal());
             // 取最新的第一条钢坯信息
             RollClubCommon rollClubCommon = rollClubCommonList.stream().findFirst().orElse(null);
             if (rollClubCommon != null) {
@@ -2855,7 +2982,7 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
 
             // 物理删除钢坯临时表记录
             billetAutoTmpService.removeBatchByIds(billetAutoTmpList.stream().map(BilletAutoTmp::getId).collect(Collectors.toList()));
-            result.put("success", "B端钢坯轧钢外运未知目的地明细同步成功!");
+            result.put("success", "B端看板确认目的地明细同步成功!");
             return result;
         }catch (Exception e){
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();