From 2f6529a3efdd6812e13dbc37ce09974e3a024055 Mon Sep 17 00:00:00 2001
From: jiaosong <jiaosong6760@dingtalk.com>
Date: 星期三, 16 八月 2023 16:52:41 +0800
Subject: [PATCH] # 工资表配置表 导出模板索字段添加

---
 server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java |  122 ++++++++++++++++++++++++++++++++++------
 1 files changed, 102 insertions(+), 20 deletions(-)

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 8ec0cff..17b1c9d 100644
--- a/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java
+++ b/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java
@@ -83,6 +83,10 @@
     private MaterialExtMapper materialExtMapper;
     @Autowired
     private SalaryParamMapper salaryParamMapper;
+    @Autowired
+    private PlansExtMapper plansExtMapper;
+    @Autowired
+    private DeviceExtMapper deviceExtMapper;
 
     @Transactional(rollbackFor = {BusinessException.class,Exception.class})
     @Override
@@ -188,6 +192,14 @@
         return mp;
     }
 
+    private void getPlansAndValid(LoginUserInfo user, Plans mp)  throws  BusinessException{
+        if(mp== null){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝璇ヨ褰曚笉瀛樺湪锛�");
+        }
+        if(Constants.equalsInteger(mp.getPaused(),Constants.ONE)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝宸ュ崟宸叉殏鍋滐紒");
+        }
+    }
 
     private QueryBomDetailExtDTO initBomParam(LoginUserInfo user, Workorder mp)  throws BusinessException{
         QueryBomExtDTO bb = new QueryBomExtDTO();
@@ -207,6 +219,27 @@
         bom.setBomId(versionBom.getBomVersionId());
 //        bom.setProcedureId(mp.getProcedureId());
         bom.setWorkorderId(mp.getId());
+        return bom;
+    }
+
+    private QueryBomDetailExtDTO initBomParamForPlans(LoginUserInfo user, Plans plans)  throws BusinessException{
+        QueryBomExtDTO bb = new QueryBomExtDTO();
+        bb.setDepartId(plans.getDepartId());
+        bb.setDeleted(Constants.ZERO);
+        bb.setRootDepartId(user.getRootDepartment().getId());
+        bb.setMaterialId(plans.getMaterialId());
+        bb.setProcedureId(plans.getProcedureId());
+        BomExtListVO versionBom = bomExtMapper.selectByModel( bb);
+        if(versionBom == null || StringUtils.isBlank(versionBom.getVersion()) || versionBom.getBomVersionId() == null){
+            return  null;
+            // throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝璇ュ伐鍗曠墿鏂橞OM淇℃伅閰嶇疆鏈夎锛岃鑱旂郴绠$悊鍛橈紒");
+        }
+        plans.setBomModel(versionBom);
+        QueryBomDetailExtDTO  bom = new QueryBomDetailExtDTO();
+        bom.setDeleted(Constants.ZERO);
+        bom.setBomId(versionBom.getBomVersionId());
+//        bom.setProcedureId(mp.getProcedureId());
+        bom.setPlansId(plans.getId());
         return bom;
     }
 
@@ -281,7 +314,6 @@
     }
 
     private void updateOrderInfo(LoginUserInfo user, Workorder mp,int status) {
-
         List<WorkorderHistory> whList = new ArrayList<>();
         //宸ュ崟鍘嗗彶鏁版嵁
         Workorder order = new Workorder();
@@ -299,7 +331,7 @@
             order.setStatus(Constants.WORKORDER_STATUS.material);
         }else if(status ==Constants.WORKORDER_HISTORY_STATUS.done){
             order.setStatus(Constants.WORKORDER_STATUS.done);
-        }else if(status ==Constants.WORKORDER_HISTORY_STATUS.material){
+        }else if(status ==Constants.WORKORDER_HISTORY_STATUS.material ||status ==Constants.WORKORDER_HISTORY_STATUS.produce){
             //鎶曟枡鎿嶄綔
             if(Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create)
                     ||Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material)){
@@ -637,13 +669,13 @@
             if (bomDetailList == null || bomDetailList.size() == 0) {
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝璇ョ敓浜х墿鏂欑殑bom閰嶇疆鏈夎锛岃鑱旂郴绠$悊鍛橈紒");
             }
-            for (BomDetailExtListVO i :bomDetailList) {
-                //鏌ヨ鏄惁鎶曟枡
-                if(workorderRecordExtMapper.selectCount(new QueryWrapper<WorkorderRecord>()
-                        .eq("DELETED",Constants.ZERO).eq("MATERIAL_ID",i.getMaterialId()).eq("TYPE",Constants.ZERO))<=0){
-                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀛樺湪鏈姇鏂橞OM鐗╂枡锛屾棤娉曡繘琛屾姤宸�");
-                }
-            }
+//            for (BomDetailExtListVO i :bomDetailList) {
+//                //鏌ヨ鏄惁鎶曟枡
+//                if(workorderRecordExtMapper.selectCount(new QueryWrapper<WorkorderRecord>()
+//                        .eq("DELETED",Constants.ZERO).eq("MATERIAL_ID",i.getMaterialId()).eq("TYPE",Constants.ZERO))<=0){
+//                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀛樺湪鏈姇鏂橞OM鐗╂枡锛屾棤娉曡繘琛屾姤宸�");
+//                }
+//            }
         }
 
         WOutbound outbound = new WOutbound();
@@ -801,16 +833,16 @@
                 }
                 //濡傛灉鏄骇鍑�
                 mp.setHasProduceNum(Constants.formatBigdecimal(tModel.getNum()).intValue()+Constants.formatIntegerNum(mp.getHasProduceNum()));
-                if(tModel.getDoneType() == null){
-                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝宸ヨ鍣ㄥ叿銆�"+tModel.getAmodel().getCode()+"銆戜骇鍑鸿川閲忓睘鎬т负绌猴紝鏃犳硶鎶ュ伐锛�");
-                }
-                if(!Constants.equalsInteger(tModel.getDoneType(),Constants.ZERO)){
-                    //濡傛灉涓嶈壇锛岀疮璁″伐鍗曠殑涓嶈壇浜у嚭
-                    mp.setUnqualifiedNum(Constants.formatIntegerNum(mp.getUnqualifiedNum())+(Constants.formatBigdecimal(tModel.getNum()).intValue()));
-                }else{
-                    //濡傛灉鏄悎鏍硷紝绱宸ュ崟鐨勫悎鏍兼暟閲�
-                    mp.setQualifiedNum(Constants.formatIntegerNum(mp.getQualifiedNum())+(Constants.formatBigdecimal(tModel.getNum()).intValue()));
-                }
+//                if(tModel.getDoneType() == null){
+//                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝宸ヨ鍣ㄥ叿銆�"+tModel.getAmodel().getCode()+"銆戜骇鍑鸿川閲忓睘鎬т负绌猴紝鏃犳硶鎶ュ伐锛�");
+//                }
+//                if(!Constants.equalsInteger(tModel.getDoneType(),Constants.ZERO)){
+//                    //濡傛灉涓嶈壇锛岀疮璁″伐鍗曠殑涓嶈壇浜у嚭
+//                    mp.setUnqualifiedNum(Constants.formatIntegerNum(mp.getUnqualifiedNum())+(Constants.formatBigdecimal(tModel.getNum()).intValue()));
+//                }else{
+//                    //濡傛灉鏄悎鏍硷紝绱宸ュ崟鐨勫悎鏍兼暟閲�
+//                    mp.setQualifiedNum(Constants.formatIntegerNum(mp.getQualifiedNum())+(Constants.formatBigdecimal(tModel.getNum()).intValue()));
+//                }
 
                 //鐗╂枡+鎵规+宸ュ簭+璐ㄩ噺灞炴�у幓閲�
                 WOutboundDetail detail =getWoutbondDetailByList(tModel,detailList);
@@ -1111,7 +1143,52 @@
         return PageData.from(new PageInfo<>(result));
     }
 
-
+    @Override
+    public PageData<WStockExtListVO> choiceStockPageForPlans(PageWrap<QueryWStockDto> pageWrap,LoginUserInfo userInfo) {
+        Plans plans =plansExtMapper.selectById(pageWrap.getModel().getPlansId());
+        if(Objects.isNull(plans)){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌宸ュ簭璁″垝淇℃伅锛�");
+        }
+        Device device = deviceExtMapper.selectById(pageWrap.getModel().getDeviceId());
+        if(Objects.isNull(plans)){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌璁惧淇℃伅锛�");
+        }
+        //鏌ヨ骞堕獙璇佸伐鍗曚俊鎭�
+        this.getPlansAndValid(userInfo,plans);
+        //鏌ヨ鍏ㄩ儴bom缁勬垚鏁版嵁锛屽鏋滄湁BOM閰嶇疆锛屾寜鐓OM缁勬垚杩涜鎶曟枡锛屽鏋滄病鏈塀OM閰嶇疆锛屽垯鎶曟枡鐗╂枡涓哄緟鐢熶骇搴撲綅鐨勭墿鏂欐湰韬�
+        QueryBomDetailExtDTO bdparam = initBomParamForPlans(userInfo,plans);
+        List<BomDetailExtListVO> bomDetailList = null;
+        if(bdparam!=null){
+            bomDetailList = bomDetailExtMapper.selectList(bdparam);
+            List<Integer> materialDistributeId = bomDetailList.stream().map(BomDetailExtListVO::getMaterialId).collect(Collectors.toList());
+            pageWrap.getModel().setMaterialDistributeId(materialDistributeId);
+        }else{
+            //鏌ヨ鐗╂枡BOM淇℃伅
+            Bom bom = bomExtMapper.selectOne(new QueryWrapper<Bom>().eq("MATERIAL_ID",plans.getMaterialId()).eq("DELETED",Constants.ZERO).last(" limit 1 "));
+            if(Objects.isNull(bom)){
+                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌BOM淇℃伅锛�");
+            }
+            RouteProcedure currentRouteProcedure   = routeProcedureExtMapper.selectOne(new QueryWrapper<RouteProcedure>()
+                    .eq("ROUTE_ID",bom.getRouteId())
+                    .eq("PROCEDURE_ID",plans.getProcedureId())
+                    .last(" limit 1 ")
+            );
+            if(currentRouteProcedure!=null){
+                RouteProcedure routeProcedure   = routeProcedureExtMapper.selectOne(new QueryWrapper<RouteProcedure>()
+                        .eq("ROUTE_ID",currentRouteProcedure.getRouteId()).apply(" SORTNUM <  " + currentRouteProcedure.getSortnum() ).eq("STATUS",Constants.ONE).orderByDesc(" SORTNUM ").last(" limit 1  ")
+                );
+                if(Objects.isNull(routeProcedure)){
+                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌鐢熶骇鐗╂枡涓婁竴姝ュ伐搴忎俊鎭紒");
+                }
+                pageWrap.getModel().setProcedureId(routeProcedure.getProcedureId());
+                pageWrap.getModel().setMaterialId(plans.getMaterialId());
+            }
+        }
+        pageWrap.getModel().setLocationId(device.getProduceWarehouseLocationId());
+        PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity());
+        List<WStockExtListVO> result = wStockExtMapper.choiceStockList(pageWrap.getModel());
+        return PageData.from(new PageInfo<>(result));
+    }
 
     @Override
     @Transactional(rollbackFor = {BusinessException.class,Exception.class})
@@ -1180,8 +1257,13 @@
             workorderRecord.setSalary(BigDecimal.valueOf(createWorkorderRecordDTO.getDuration()).multiply(salaryParam.getSalary()).divide(new BigDecimal(3600)));
         }
 
+        //鎻掑叆宸ュ崟鎿嶄綔璁板綍锛屽苟涓斿垽鏂槸鍚︽洿鏀逛负宸ュ崟鐨勭姸鎬併�愮敓浜т腑銆�
+        updateOrderInfo(loginUserInfo,workorder,Constants.WORKORDER_HISTORY_STATUS.produce);
         workorderRecordExtMapper.insert(workorderRecord);
         return workorderRecord;
     }
+    
+    
+    
 
 }

--
Gitblit v1.9.3