Jelajahi Sumber

清单导入校验,保证单价和数量必须同时存在或不存在

qianxb 8 bulan lalu
induk
melakukan
41dcc860ec

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/MeterTreeController.java

@@ -650,7 +650,7 @@ public class MeterTreeController extends BladeController {
                 transactionManager.commit(status);
             }catch (Exception e){
                 transactionManager.rollback(status);
-                return R.fail(e.getMessage());
+                return R.fail("b1,b2错误:"+e.getMessage());
             }
             if (b1 && b2) {
                 return R.success("操作成功");

+ 7 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractInventoryFormServiceImpl.java

@@ -84,11 +84,17 @@ public class ContractInventoryFormServiceImpl extends BaseServiceImpl<ContractIn
             if (excels == null || excels.size() == 0){
                 throw new ServiceException("未检测到excel中清单数据,请检查格式后后重新导入");
             }
-            //校验必填字段是否为空
+            //校验必填字段是否为空,校验填写数量就必须填写金额
             excels.stream().forEach(l->{
                 if (StringUtils.isBlank(l.getImportNumber()) || StringUtils.isBlank(l.getFormNumber() ) || StringUtils.isBlank(l.getFormName())){
                     throw new ServiceException("excel中有必填项未填写,请检查(导入编号,清单编号,清单名称)后重新导入");
                 }
+                if (l.getBidPrice() == null && l.getContractTotal() != null){
+                    throw new ServiceException("excel中有清单单价未填写,填写数量则必须填写单价");
+                }
+                if (l.getBidPrice() != null && l.getContractTotal() == null){
+                    throw new ServiceException("excel中有清单数量未填写,填写单价则必须填写数量");
+                }
             });
             allTotal = excels.size();
             List<Integer> firstNode = new ArrayList<>();

+ 2 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MiddleMeterApplyServiceImpl.java

@@ -130,7 +130,8 @@ public class MiddleMeterApplyServiceImpl extends BaseServiceImpl<MiddleMeterAppl
         //获取清单和分解信息
         List<Long> longs = Func.toLongList(ids);
         vos = baseMapper.getResolveFormInfo(contractId,nodeId,longs);
-        vos = vos.stream().filter(l-> !l.getAllMeterTotal().equals(l.getChangeTotal())).collect(Collectors.toList());
+        vos = vos.stream().filter(l-> !l.getAllMeterTotal().equals(l.getChangeTotal()) && l.getChangeTotal().compareTo(BigDecimal.ZERO) != 0)
+                            .collect(Collectors.toList());
         for (MeterInventoryVO vo : vos) {
             //默认分解清单的比例为0
             vo.setPayRatio(new BigDecimal(0));