瀏覽代碼

update未知目的地

qiangxuan 4 月之前
父節點
當前提交
8eed76bab7

+ 22 - 22
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/service/impl/BilletHotsendChangeShiftServiceImpl.java

@@ -179,28 +179,28 @@ public class BilletHotsendChangeShiftServiceImpl extends ServiceImpl<BilletHotse
                 billetHotsendChangeShift.setUpdateTime(new Date());
                 baseMapper.updateById(billetHotsendChangeShift);
                 // 获取当前最新炉号
-                if (oConvertUtils.isNotEmpty(billetHotsendChangeShift.getHeatNo())) {
-                    // 根据当前炉号、铸机号、班组、班别查询总生产的钢坯数
-                    LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<BilletBasicInfo>()
-                            .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(ccmNo))
-                            .eq(BilletBasicInfo::getHeatNo, billetHotsendChangeShift.getHeatNo())
-                            .eq(BilletBasicInfo::getShift, billetHotsendChangeShift.getShift())
-                            .eq(BilletBasicInfo::getShiftGroup, billetHotsendChangeShift.getShiftGroup())
-                            .isNull(BilletBasicInfo::getBelongTable)
-                            .isNull(BilletBasicInfo::getBhtcId)
-                            .orderByAsc(BilletBasicInfo::getCreateTime);
-                    List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper);
-                    List<BilletBasicInfo> updateBilletBasicInfo = extractRemainderData(billetBasicInfoList);
-                    if (oConvertUtils.listIsNotEmpty(updateBilletBasicInfo)){
-                        updateBilletBasicInfo.forEach(x -> {
-                            x.setShift(billetHotsendChangeShiftVo.getShift());
-                            x.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
-                            x.setUpdateTime(new Date());
-                        });
-                        log.info("自动化交班判定该钢坯到新的班组:{}", JSON.toJSON(updateBilletBasicInfo) + "操作时间" + new Date());
-                        billetBasicInfoService.saveOrUpdateBatch(updateBilletBasicInfo);
-                    }
-                }
+//                if (oConvertUtils.isNotEmpty(billetHotsendChangeShift.getHeatNo())) {
+//                    // 根据当前炉号、铸机号、班组、班别查询总生产的钢坯数
+//                    LambdaQueryWrapper<BilletBasicInfo> queryWrapper = new LambdaQueryWrapper<BilletBasicInfo>()
+//                            .eq(BilletBasicInfo::getCcmNo, Integer.valueOf(ccmNo))
+//                            .eq(BilletBasicInfo::getHeatNo, billetHotsendChangeShift.getHeatNo())
+//                            .eq(BilletBasicInfo::getShift, billetHotsendChangeShift.getShift())
+//                            .eq(BilletBasicInfo::getShiftGroup, billetHotsendChangeShift.getShiftGroup())
+//                            .isNull(BilletBasicInfo::getBelongTable)
+//                            .isNull(BilletBasicInfo::getBhtcId)
+//                            .orderByAsc(BilletBasicInfo::getCreateTime);
+//                    List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(queryWrapper);
+//                    List<BilletBasicInfo> updateBilletBasicInfo = extractRemainderData(billetBasicInfoList);
+//                    if (oConvertUtils.listIsNotEmpty(updateBilletBasicInfo)){
+//                        updateBilletBasicInfo.forEach(x -> {
+//                            x.setShift(billetHotsendChangeShiftVo.getShift());
+//                            x.setShiftGroup(billetHotsendChangeShiftVo.getShiftGroup());
+//                            x.setUpdateTime(new Date());
+//                        });
+//                        log.info("自动化交班判定该钢坯到新的班组:{}", JSON.toJSON(updateBilletBasicInfo) + "操作时间" + new Date());
+//                        billetBasicInfoService.saveOrUpdateBatch(updateBilletBasicInfo);
+//                    }
+//                }
 
                 // 生成新的交班记录 初始化并保存入库
                 BilletHotsendChangeShift billetHotsendChangeShift1 = new BilletHotsendChangeShift();

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

@@ -1222,24 +1222,22 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
     @ApiOperation(value="钢坯装运单-编辑(不带Token)", notes="钢坯装运单-编辑(不带Token)")
     @RequestMapping(value = "/editNoToken", method = {RequestMethod.PUT})
     public Result<String> editNoToken(@RequestBody StorageBill storageBill) {
-		if(oConvertUtils.isNotEmpty(storageBill.getId())) {
-			StorageBill bill = storageBillService.getById(storageBill.getId());
-			if(oConvertUtils.isNotEmpty(storageBill.getLicensePlateStatus())){
-				bill.setLicensePlateStatus(storageBill.getLicensePlateStatus());
-				storageBillService.updateById(bill);
-				Result.OK("确认车牌编辑成功!");
-			}
-			if(oConvertUtils.isNotEmpty(storageBill.getDestination())){
-				bill.setDestination(storageBill.getDestination());
-				bill.setTypeConfigId(storageBill.getTypeConfigId());
-				JSONObject jsonObject = storageBillService.billetAutoTmpDataSyn(storageBill);
-
-
-				storageBillService.updateById(bill);
-
-			}
-
+		if(oConvertUtils.isEmpty(storageBill.getId())) {
+			return Result.error("参数异常!");
+		}
+		StorageBill bill = storageBillService.getById(storageBill.getId());
+		if(oConvertUtils.isNotEmpty(storageBill.getLicensePlateStatus())){
+			bill.setLicensePlateStatus(storageBill.getLicensePlateStatus());
+			storageBillService.updateById(bill);
+			return Result.OK("确认车牌编辑成功!");
+		}
+		if(oConvertUtils.isNotEmpty(storageBill.getDestination())){
+			bill.setDestination(storageBill.getDestination());
+			bill.setTypeConfigId(storageBill.getTypeConfigId());
+			JSONObject jsonObject = storageBillService.billetAutoTmpDataSyn(bill);
+			log.info("{}{}", "轧钢外运未知目的地数据同步结果:", jsonObject);
+			return Result.OK("轧钢外运未知目的地数据同步成功!");
 		}
-        return Result.OK("编辑成功!");
+        return Result.error("系统异常!");
     }
 }

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

@@ -2684,17 +2684,17 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     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)){
-                result.put("fail", "钢坯运未知目的地明细不存在!");
+                result.put("fail", "钢坯轧钢外运未知目的地明细不存在!");
                 return result;
             }
             billetAutoTmpList.forEach(x ->{
@@ -2759,42 +2759,42 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 x.setUpdateTime(new Date());
             });
             billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
-
-//            // 维护支数、组坯号、
-//            storageBill.setAmountTotal();
-//            storageBill.setAssemblyNumber(storageBill.getAssemblyNumber());
-//            // 更新装运单目的地、发车时间
-//            storageBill.setUpdateTime(new Date());
-//            baseMapper.updateById(storageBill);
-
-//            // 发车后,新增储运记录 storage_car_log
-//            StorageCarLog storageCarLog = new StorageCarLog();
-//            BeanUtils.copyProperties(storageBill, storageCarLog);
-//            storageCarLog.setCarNm(storageBill.getLicensePlate());// 车牌号
-//            storageCarLog.setTypeConfigId(storageBill.getTypeConfigId()); // 钢坯配置类型ID
-//
-//            List<String> sizeList = rollClubCommonList.stream().map(RollClubCommon::getSize).distinct().collect(Collectors.toList());
-//            List<String> heatNoList = rollClubCommonList.stream().map(RollClubCommon::getHeatNo).distinct().collect(Collectors.toList());
-//            long count = rollClubCommonList.stream().count();
-//
-//            storageCarLog.setHeatNo(String.join(",", heatNoList));
-//            storageCarLog.setSize(String.join(",", sizeList));// 定尺
-//            storageCarLog.setAmount(Integer.valueOf((int) count));// 支数
-//
-//            storageCarLog.setDataTime(new Date());
-//            storageCarLog.setCreateTime(new Date());
-//            storageCarLogService.save(storageCarLog);
-//            log.info("{}{}", "B端钢坯车位发车成功!", storageBill.getLicensePlate());
-
+            // 维护总支数
+            storageBill.setAmountTotal(storageBill.getAmountTotal() + rollClubCommonList.size());
+            // 取最新的第一条钢坯信息
+            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端钢坯车位发车成功!");
+            result.put("success", "B端钢坯轧钢外运未知目的地明细同步成功!");
             return result;
         }catch (Exception e){
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             // 记录异常日志
-            log.error("钢坯车位发车发生异常", e.getMessage());
+            log.error("B端钢坯轧钢外运未知目的地明细同步发生异常", e.getMessage());
             result.put("fail", "系统错误,请稍后再试!");
             return result;
         }