From 6c2d51a68d4dc59415d92fb8f60a16726d62951f Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 18 八月 2023 21:59:21 +0800
Subject: [PATCH] 修复bug

---
 server/src/main/java/doumeemes/service/business/impl/SalaryParamServiceImpl.java |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/server/src/main/java/doumeemes/service/business/impl/SalaryParamServiceImpl.java b/server/src/main/java/doumeemes/service/business/impl/SalaryParamServiceImpl.java
index b165cd9..2c66aea 100644
--- a/server/src/main/java/doumeemes/service/business/impl/SalaryParamServiceImpl.java
+++ b/server/src/main/java/doumeemes/service/business/impl/SalaryParamServiceImpl.java
@@ -11,16 +11,21 @@
 import doumeemes.dao.business.*;
 import doumeemes.dao.business.model.*;
 import doumeemes.dao.business.vo.SalaryParamVO;
+import doumeemes.dao.ext.MaterialExtMapper;
 import doumeemes.dao.ext.dto.SalaryParamDTO;
 import doumeemes.dao.ext.dto.SalaryParamImportDTO;
+import doumeemes.dao.ext.vo.DepartmentExtListVO;
 import doumeemes.service.business.DepartmentService;
 import doumeemes.service.business.SalaryParamService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import doumeemes.service.ext.DepartmentExtService;
 import org.apache.shiro.SecurityUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -42,6 +47,9 @@
 
     @Autowired
     private DepartmentMapper departmentMapper;
+    @Lazy
+    @Autowired
+    private DepartmentExtService departmentExtService;
 
     @Autowired
     private MaterialMapper materialMapper;
@@ -63,6 +71,7 @@
         insert.setProcedureId(salaryParam.getProcedureId());
         insert.setMaterialId(salaryParam.getMaterialId());
         insert.setDeleted((byte) Constants.ZERO);
+        insert.setType(salaryParam.getType());
         if(findOne(insert) != null){
             throw  new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"鍚屼竴涓墿鏂欏湪鐩稿悓宸ュ簭涓嶈兘閲嶅閰嶇疆鍝︼紒");
         }
@@ -198,17 +207,24 @@
 
         for (int i = 0; i < plansList.size(); i++) {
             SalaryParamImportDTO salaryParamImportDTO = plansList.get(i);
-
-            QueryWrapper<Department> wrapper = new QueryWrapper<>();
-            wrapper.lambda()
-                    .eq(Department::getName,salaryParamImportDTO.getDepartName())
-                    .eq(Department::getType,Constants.DEPART_TYPE.factory)
-                    .eq(Department::getDeleted,Constants.ZERO)
-                    .last("limit 1");
-            Department department = departmentMapper.selectOne(wrapper);
-            if (Objects.isNull(department)){
+//
+//            QueryWrapper<Department> wrapper = new QueryWrapper<>();
+//            wrapper.lambda()
+//                    .eq(Department::getName,salaryParamImportDTO.getDepartName())
+//                    .eq(Department::getType,Constants.DEPART_TYPE.factory)
+//                    .eq(Department::getDeleted,Constants.ZERO)
+//                    .last("limit 1");
+            Department dparam = new Department();
+            dparam.setName(salaryParamImportDTO.getDepartName());
+            dparam.setDeleted(Constants.ZERO);
+            dparam.setType(Constants.DEPART_TYPE.factory);
+            dparam = departmentExtService.findOne(dparam);
+            if (Objects.isNull(dparam)){
                 throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵煎叆鏁版嵁鍐呭銆愬叕鍙稿悕绉般�戞湁璇紒");
             }
+            DepartmentExtListVO department = new DepartmentExtListVO();
+            BeanUtils.copyProperties(dparam, department);
+            Integer comDepartId = departmentExtService.getComDepartId(department);
 
             QueryWrapper<Material> materialWrapper = new QueryWrapper<>();
             materialWrapper.lambda()
@@ -228,6 +244,7 @@
             materialDistributeQueryWrapper.lambda()
                     .eq(MaterialDistribute::getMaterialId,material.getId())
                     .eq(MaterialDistribute::getRootDepartId,department.getRootId())
+                    .eq(MaterialDistribute::getDepartId, comDepartId)
                     .eq(MaterialDistribute::getDeleted,Constants.ZERO)
                     .last("limit 1");
             MaterialDistribute materialDistribute = materialDistributeMapper.selectOne(materialDistributeQueryWrapper);
@@ -248,7 +265,7 @@
             salaryParam.setRootDepartId(department.getRootId());
             salaryParam.setDepartId(department.getId());
             salaryParam.setProcedureId(procedures.getId());
-            salaryParam.setMaterialId(materialDistribute.getId());
+            salaryParam.setMaterialId(materialDistribute1.getId());
             salaryParam.setSalary(salaryParamImportDTO.getSalary());
             salaryParam.setNum(new BigDecimal(salaryParamImportDTO.getNum()));
             salaryParam.setTimes(getIntegerTimes(salaryParamImportDTO.getTimesName()));

--
Gitblit v1.9.3