From 44c381b12687bbe966721cb53fafa5e5a113d484 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期五, 18 八月 2023 20:32:13 +0800
Subject: [PATCH] 111

---
 server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java |    8 ++++----
 server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java                |    8 ++++++--
 server/src/main/resources/mappers/PlansExtMapper.xml                                    |    2 +-
 3 files changed, 11 insertions(+), 7 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 ac7265f..26a9562 100644
--- a/server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java
+++ b/server/src/main/java/doumeemes/service/ext/impl/PlansExtServiceImpl.java
@@ -92,6 +92,8 @@
     private WorkorderRecordStandardService workorderRecordStandardService;
     @Autowired
     private UnqualifiedRecordMapper unqualifiedRecordMapper;
+    @Autowired
+    private CompanyUserExtMapper companyUserExtMapper;
 
     @Override
     public  PlansExtListVO findById(Integer id){
@@ -639,7 +641,7 @@
         List<WorkorderHistory> whList = new ArrayList<>();
         Workorder order = new Workorder();
         order.setCreateTime(DateUtil.getCurrentDate());
-        order.setCreateUser(user.getId());
+        order.setCreateUser(param.getCreateUser());
         order.setDeleted(Constants.ZERO);
         order.setStatus(Constants.WORKORDER_STATUS.create);
         order.setPlanId(mp.getId());
@@ -1642,7 +1644,7 @@
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍙傛暟閿欒锛氫骇鍑烘暟鎹�");
         }
         //宸ュ崟宸插垎閰嶆暟閲�
-        Integer produceNum = workorderList.stream().map(s -> s.getPlanNum()).reduce(Constants.ZERO, Integer::sum);
+        Integer produceNum = workorderList.stream().map(s -> s.getUnqualifiedNum() + s.getQualifiedNum()).reduce(Constants.ZERO, Integer::sum);
         Integer surplusNum = plans.getNum() - produceNum;
         if(num.compareTo(BigDecimal.valueOf(surplusNum))>0){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瓒呭嚭褰撳墠宸ュ簭璁″垝鍙姤宸ユ暟閲�");
@@ -1650,6 +1652,8 @@
         Workorder param = new Workorder();
         param.setPlanId(autoWorkReportDTO.getPlansId());
         param.setPlanDate(new Date());
+        CompanyUser companyUser= companyUserExtMapper.selectById(autoWorkReportDTO.getProUserList().get(Constants.ZERO));
+        param.setCreateUser(companyUser.getUserId());
         param.setProGroupId(autoWorkReportDTO.getProGroupId());
         param.setProUserList(autoWorkReportDTO.getProUserList());
         param.setPlanNum(num.intValue());
diff --git a/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java b/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java
index f408243..d8abd47 100644
--- a/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java
+++ b/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java
@@ -298,11 +298,11 @@
         wrModel.setMaterialId(wStock.getMaterialId());
         wrModel.setDepartId(mp.getDepartId());
         wrModel.setCreateTime(DateUtil.getCurrentDate());
-        wrModel.setCreateUser(user.getId());
+        wrModel.setCreateUser(mp.getCreateUser());
         wrModel.setMaterialBatch(mp.getBatch());
         wrModel.setType(Constants.WORKORDER_RECORD_TYPE.materail);
         wrModel.setFactoryId(mp.getFactoryId());
-        wrModel.setProcedureId(mp.getProcedureId());
+        wrModel.setProcedureId(wStock.getProcedureId());
         wrModel.setBatch(wStock.getBatch());
         wrModel.setUnitId(mp.getUnitId());
         wrModel.setPlanId(mp.getPlanId());
@@ -1532,8 +1532,8 @@
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌鐢熶骇浜哄憳瀵瑰簲浼佷笟鐢ㄦ埛淇℃伅锛�");
             }
             workorderRecord.setCreateUser(companyUser.getUserId());
-            workorderRecord.setRootDepartId(companyUser.getRootDepartId());
-            workorderRecord.setDepartId(companyUser.getComDepartId());
+            workorderRecord.setRootDepartId(loginUserInfo.getRootDepartment().getId());
+            workorderRecord.setDepartId(loginUserInfo.getCurComDepartment().getId());
         }else{
             workorderRecord.setCreateUser(loginUserInfo.getId());
             workorderRecord.setRootDepartId(loginUserInfo.getRootDepartment().getId());
diff --git a/server/src/main/resources/mappers/PlansExtMapper.xml b/server/src/main/resources/mappers/PlansExtMapper.xml
index f2dd8e4..6f43afc 100644
--- a/server/src/main/resources/mappers/PlansExtMapper.xml
+++ b/server/src/main/resources/mappers/PlansExtMapper.xml
@@ -123,7 +123,7 @@
   <select id="selectByModel" parameterType="doumeemes.dao.ext.dto.QueryPlansExtDTO" resultMap="PlansExtListVO">
   SELECT
   `a`.*
-    ,ifnull((  SELECT sum( b.PLAN_NUM ) FROM  workorder b  WHERE b.deleted = 0 AND b.PLAN_ID = a.id and b.status = 4 ),0) AS workorderDistributNum
+    , ifnull((  SELECT sum(  b.UNQUALIFIED_NUM + QUALIFIED_NUM ) FROM  workorder b  WHERE b.deleted = 0  AND b.PLAN_ID = a.id  and b.status  = 4 ),0) AS workorderDistributNum
     from plans a
     <where>
     <if test="id != null">

--
Gitblit v1.9.3