qiangxuan před 2 měsíci
rodič
revize
b9384eb5fe

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

@@ -52,6 +52,7 @@ import org.jeecg.modules.billet.storageCarLog.service.IStorageCarLogService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
 
@@ -453,13 +454,24 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 	@AutoLog(value = "钢坯装运单-编辑")
 	@ApiOperation(value="钢坯装运单-编辑", notes="钢坯装运单-编辑")
 	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+	@Transactional(rollbackFor = Exception.class)
 	public Result<String> edit(@RequestBody StorageBill storageBill) {
 		StorageBill old = storageBillService.getById(storageBill.getId());
-		storageBillService.updateById(storageBill);
 		if("1024".equals(old.getTypeConfigId()) && oConvertUtils.isNotEmpty(storageBill.getDestination())){
-			log.info("{}{}", "钢坯装运单编辑,未知目的地数据开始同步:", storageBill.getLicensePlate());
-			JSONObject jsonObject = storageBillService.billetAutoTmpDataSyn(storageBill);
-			log.info("{}{}", "钢坯装运单编辑,未知目的地数据同步结果:", jsonObject);
+			// 合并更新字段
+			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);
+			}
+			log.info("钢坯装运单编辑,未知目的地数据同步结果:{}", jsonObject);
+		} else {
+			storageBillService.updateById(storageBill);
 		}
 		operateLogService.add(old,storageBill,StorageBill.class);
 		return Result.OK("编辑成功!");

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

@@ -2738,13 +2738,12 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
     public JSONObject billetAutoTmpDataSyn(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)){
+            if (oConvertUtils.listIsEmpty(billetAutoTmpList) || "1024".equals(storageBill.getTypeConfigId())){
                 result.put("fail", "钢坯轧钢外运未知目的地明细不存在!");
                 return result;
             }
@@ -2757,6 +2756,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 rollClubCommonList.add(rollClubCommon);
             });
 
+            log.info("{}{}", "未知目的地数据同步临时表总条数:", rollClubCommonList.size());
+
             // 根据ID获取钢坯配置信息
             BilletHotsend billetHotsend = new BilletHotsend();
             billetHotsend.setCcmNo(storageBill.getCcmNo());
@@ -2789,7 +2790,8 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 if (jsonObject.containsKey("fail")) {
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                     log.info("{}{}", "B端钢坯装运单未知目的地数据同步操作失败,事务回滚!", jsonObject);
-                    return jsonObject;
+                    result.put("fail", "B端钢坯装运单未知目的地数据同步操作失败!");
+                    return result;
                 }
             }
             List<String> billetNos = rollClubCommonList.stream().map(RollClubCommon::getBilletNo).collect(Collectors.toList());
@@ -2810,8 +2812,11 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
                 x.setUpdateTime(new Date());
             });
             billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
+            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) {