Explorar el Código

1.产品产品选择新增对可能出现的产品选择后又退回流程新增了评估对象的null情况处理

GouGengquan hace 1 mes
padre
commit
713ee4d646

+ 1 - 1
biz-base/src/main/java/com/dayou/controller/AssetsProductionController.java

@@ -71,7 +71,7 @@ public class AssetsProductionController extends BaseController {
     }
 
     /**
-     * 资产产品表新增
+     * 资产新增产品选择记录
      */
     @FinishTask
     @PostMapping("/save")

+ 21 - 4
service/src/main/java/com/dayou/service/impl/AssetsProductionServiceImpl.java

@@ -141,6 +141,11 @@ public class AssetsProductionServiceImpl extends ServiceImpl<AssetsProductionMap
         return this.updateById(assetsProduction);
     }
 
+    /**
+     * 更新产品选择类型
+     * @param assetsProduction prod
+     * @return Boolean
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean updateChoice(AssetsProduction assetsProduction) {
@@ -153,12 +158,24 @@ public class AssetsProductionServiceImpl extends ServiceImpl<AssetsProductionMap
                     .eq(BusinessProductionChoiceLog::getTargetId, targetId)
                     .eq(BaseEntity::getDeleted, 0)
                     .eq(BusinessProductionChoiceLog::getTakeNoStatus, 0));
-            choiceLog.setProductionId(assetsProduction.getId());
-            choiceLog.setProductionType(assetsProduction.getProductionType());
-            choiceLog.setPrintCount(assetsProduction.getPrintCount());
+            // 判断产品选择记录是否为空
+            if (ObjectUtil.isNotNull(choiceLog)) { // 不为空直接在原有信息更新
+                choiceLog.setProductionId(assetsProduction.getId());
+                choiceLog.setProductionType(assetsProduction.getProductionType());
+                choiceLog.setPrintCount(assetsProduction.getPrintCount());
+            } else { // 为空说明该评估对象没有产品选择记录, 需要新增一条(退回节点后新增了评估对象等情况可能会导致有没有产品选择记录的评估对象)
+                choiceLog = new BusinessProductionChoiceLog();
+                choiceLog.setBusinessType("ASSET_BUSINESS");
+                choiceLog.setProductionType(assetsProduction.getProductionType());
+                choiceLog.setBusinessId(assetsProduction.getBusinessId());
+                choiceLog.setTargetId(targetId);
+                choiceLog.setPrintCount(assetsProduction.getPrintCount());
+                choiceLog.setProductionId(assetsProduction.getId());
+            }
             choiceLogList.add(choiceLog);
         }
-        choiceLogService.updateBatchById(choiceLogList);
+        // 保存或新增产品选择记录
+        choiceLogService.saveOrUpdateBatch(choiceLogList);
         return this.updateById(assetsProduction);
     }