From 6e7c27daee1d3ea051177bae04d64237e03e2e5a Mon Sep 17 00:00:00 2001
From: jiaosong <jiaosong6760@dingtalk.com>
Date: 星期五, 18 八月 2023 15:26:32 +0800
Subject: [PATCH] #产出计算

---
 server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java b/server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java
index d283106..8874489 100644
--- a/server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java
+++ b/server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java
@@ -661,6 +661,8 @@
         order.setUrgent(mp.getUrgent());
         order.setFactoryId(mp.getFactoryId());
         order.setBackorderId(mp.getBackorderId());
+        order.setUnqualifiedNum(param.getUnqualifiedNum());
+        order.setQualifiedNum(param.getQualifiedNum());
         order.setOriginId(systemDictDataBiz.queryByCode(Constants.WORKORDER_SOURCE,Constants.WORKORDER_SOURCE_PLAN).getId());
         //宸ュ崟缂栫爜
         order.setCode(workorderExtService.getNextCode(user.getCompany().getId()));
@@ -1585,6 +1587,12 @@
     @Transactional(rollbackFor = {BusinessException.class,Exception.class})
     @Override
     public void autoWorkReport(LoginUserInfo user, AutoWorkReportDTO autoWorkReportDTO){
+        if(Objects.isNull(autoWorkReportDTO)
+            || Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO())
+            || Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum())|| autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().compareTo(BigDecimal.ZERO) < Constants.ZERO
+            || Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum())|| autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().compareTo(BigDecimal.ZERO) < Constants.ZERO){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
         //鏌ヨ宸ュ伐搴忚鍒掔姸鎬�
         Plans plans = plansExtMapper.selectById(autoWorkReportDTO.getPlansId());
         if(Objects.isNull(plans)){
@@ -1597,7 +1605,7 @@
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"宸ュ簭璁″垝宸叉殏鍋滐紝鏃犳硶鎿嶄綔");
         }
         if(Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO())){
-            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍙傛暟閿欒锛氫骇鍑烘暟鎹�");
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鍙傛暟閿欒锛氫骇鍑烘暟鎹�");
         }
         //鏌ヨ宸ュ簭璁″垝宸插垎閰嶆暟閲�
         List<Workorder> workorderList = workorderMapper.selectList(new QueryWrapper<Workorder>().eq("PLAN_ID",plans.getId())
@@ -1611,7 +1619,7 @@
         Integer produceNum = workorderList.stream().map(s -> s.getPlanNum()).reduce(Constants.ZERO, Integer::sum);
         Integer surplusNum = plans.getNum() - produceNum;
         if(num.compareTo(BigDecimal.valueOf(surplusNum))>0){
-            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍙傛暟閿欒锛氳秴鍑哄伐鍗曞墿浣欏彲鍒嗛厤鏁伴噺");
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瓒呭嚭褰撳墠宸ュ簭璁″垝鍙姤宸ユ暟閲�");
         }
         Workorder param = new Workorder();
         param.setPlanId(autoWorkReportDTO.getPlansId());
@@ -1620,7 +1628,9 @@
         param.setProUserList(autoWorkReportDTO.getProUserList());
         param.setPlanNum(num.intValue());
         //鐢熸垚宸ュ崟淇℃伅
-        Workorder workorder = this.distributeDone(user,param,plans.getNum());
+        param.setUnqualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().intValue());
+        param.setQualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().intValue());
+        Workorder workorder = this.distributeDone(user,param,num.intValue());
         //宸ュ崟鎶曟枡璁板綍
         CreateMaterialDTO createMaterialDTO = new CreateMaterialDTO();
         if(!Objects.isNull(autoWorkReportDTO.getRecordList())&&autoWorkReportDTO.getRecordList().size()>Constants.ZERO){
@@ -1632,7 +1642,7 @@
         autoWorkReportDTO.getCreateWorkorderRecordDTO().setWorkorderId(workorder.getId());
         WorkorderRecord workorderRecord = workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user);
         //宸ュ崟鎶ュ伐
-        workorderRecordStandardService.comfirmDone(workorder);
+        workorderRecordStandardService.comfirmDone(workorder,false);
         //鏇存柊宸ュ崟鐘舵��
         if(num.compareTo(BigDecimal.valueOf(surplusNum))==Constants.ZERO){
             plans.setStatus(Constants.PLAN_STATUS.done);
@@ -1642,6 +1652,8 @@
             }
         }
         plansExtMapper.updateById(plans);
+        //鍙戦�佹秷鎭槦鍒楀鐞嗗垎浜搷浣�
+        workorderExtService.statisticNum(workorder);
         //瀛樺偍鎶ュ伐涓嶈壇椤规暟鎹�
         if(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().compareTo(BigDecimal.ZERO)<=Constants.ZERO){
             if(!Objects.isNull(autoWorkReportDTO.getCreateUnqualifiedDTOList())&&autoWorkReportDTO.getCreateUnqualifiedDTOList().size()>Constants.ZERO){

--
Gitblit v1.9.3