From 6365ab0a976afdd247742c9b3dca15deb3a7a7a1 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 17 八月 2023 17:21:40 +0800
Subject: [PATCH] 初始化1.0.1

---
 server/src/main/java/doumeemes/service/business/impl/SalaryParamServiceImpl.java |  211 ++++++++++++++++------------------------------------
 1 files changed, 64 insertions(+), 147 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 95da0cb..c36de3a 100644
--- a/server/src/main/java/doumeemes/service/business/impl/SalaryParamServiceImpl.java
+++ b/server/src/main/java/doumeemes/service/business/impl/SalaryParamServiceImpl.java
@@ -1,38 +1,20 @@
 package doumeemes.service.business.impl;
 
-import doumeemes.core.constants.ResponseStatus;
-import doumeemes.core.exception.BusinessException;
-import doumeemes.core.model.LoginUserInfo;
 import doumeemes.core.model.PageData;
 import doumeemes.core.model.PageWrap;
-import doumeemes.core.utils.Constants;
 import doumeemes.core.utils.Utils;
-import doumeemes.core.utils.excel.EasyExcelUtil;
-import doumeemes.dao.business.DepartmentMapper;
-import doumeemes.dao.business.MaterialMapper;
-import doumeemes.dao.business.ProceduresMapper;
 import doumeemes.dao.business.SalaryParamMapper;
-import doumeemes.dao.business.model.*;
-import doumeemes.dao.business.vo.SalaryParamVO;
-import doumeemes.dao.ext.dto.SalaryParamDTO;
-import doumeemes.dao.ext.dto.SalaryParamImportDTO;
-import doumeemes.service.business.DepartmentService;
+import doumeemes.dao.business.model.SalaryParam;
 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 org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
-import org.springframework.web.multipart.MultipartFile;
 
-import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
-import java.util.Objects;
 
 /**
  * 璁剧疆绫�-缁╂晥宸ヨ祫閰嶇疆琛⊿ervice瀹炵幇
@@ -45,36 +27,9 @@
     @Autowired
     private SalaryParamMapper salaryParamMapper;
 
-    @Autowired
-    private DepartmentMapper departmentMapper;
-
-    @Autowired
-    private MaterialMapper materialMapper;
-
-    @Autowired
-    private ProceduresMapper proceduresMapper;
-
     @Override
     public Integer create(SalaryParam salaryParam) {
-        LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
-
-        SalaryParam insert = new SalaryParam();
-        insert.setDeleted((byte) Constants.ZERO);
-        insert.setCreateUser(principal.getId());
-        insert.setCreateTime(new Date());
-        insert.setUpdateUser(principal.getId());
-        insert.setUpdateTime(new Date());
-        insert.setRemark(salaryParam.getRemark());
-        insert.setRootDepartId(salaryParam.getRootDepartId());
-        insert.setDepartId(salaryParam.getDepartId());
-        insert.setProcedureId(salaryParam.getProcedureId());
-        insert.setMaterialId(salaryParam.getMaterialId());
-        insert.setSalary(salaryParam.getSalary());
-        insert.setNum(salaryParam.getNum());
-        insert.setTimes(salaryParam.getTimes());
-        insert.setUnqualified(salaryParam.getUnqualified());
-        insert.setType(salaryParam.getType());
-        salaryParamMapper.insert(insert);
+        salaryParamMapper.insert(salaryParam);
         return salaryParam.getId();
     }
 
@@ -103,25 +58,6 @@
     }
 
     @Override
-    public void update(SalaryParam salaryParam) {
-        LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
-        UpdateWrapper<SalaryParam> wrapper = new UpdateWrapper<>();
-        wrapper.lambda()
-                .eq(SalaryParam::getId,salaryParam.getId())
-                .set(SalaryParam::getUpdateTime,new Date())
-                .set(SalaryParam::getUpdateUser,principal.getId())
-                .set(SalaryParam::getType,salaryParam.getType())
-                .set(SalaryParam::getDepartId,salaryParam.getDepartId())
-                .set(SalaryParam::getMaterialId,salaryParam.getMaterialId())
-                .set(SalaryParam::getProcedureId,salaryParam.getProcedureId())
-                .set(SalaryParam::getSalary,salaryParam.getSalary())
-                .set(SalaryParam::getNum,salaryParam.getNum())
-                .set(SalaryParam::getTimes,salaryParam.getTimes())
-                .set(SalaryParam::getUnqualified,salaryParam.getUnqualified());
-        salaryParamMapper.update(null,wrapper);
-    }
-
-    @Override
     public void updateByIdInBatch(List<SalaryParam> salaryParams) {
         if (CollectionUtils.isEmpty(salaryParams)) {
             return;
@@ -147,94 +83,75 @@
         QueryWrapper<SalaryParam> wrapper = new QueryWrapper<>(salaryParam);
         return salaryParamMapper.selectList(wrapper);
     }
-
+  
     @Override
-    public PageData<SalaryParamVO> findPage(PageWrap<SalaryParamDTO> pageWrap) {
+    public PageData<SalaryParam> findPage(PageWrap<SalaryParam> pageWrap) {
         IPage<SalaryParam> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
-        SalaryParamDTO model = pageWrap.getModel();
-        return PageData.from(salaryParamMapper.selectPage(page, model));
+        QueryWrapper<SalaryParam> queryWrapper = new QueryWrapper<>();
+        Utils.MP.blankToNull(pageWrap.getModel());
+        if (pageWrap.getModel().getId() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getId, pageWrap.getModel().getId());
+        }
+        if (pageWrap.getModel().getDeleted() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getDeleted, pageWrap.getModel().getDeleted());
+        }
+        if (pageWrap.getModel().getCreateUser() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getCreateUser, pageWrap.getModel().getCreateUser());
+        }
+        if (pageWrap.getModel().getCreateTime() != null) {
+            queryWrapper.lambda().ge(SalaryParam::getCreateTime, Utils.Date.getStart(pageWrap.getModel().getCreateTime()));
+            queryWrapper.lambda().le(SalaryParam::getCreateTime, Utils.Date.getEnd(pageWrap.getModel().getCreateTime()));
+        }
+        if (pageWrap.getModel().getUpdateUser() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getUpdateUser, pageWrap.getModel().getUpdateUser());
+        }
+        if (pageWrap.getModel().getUpdateTime() != null) {
+            queryWrapper.lambda().ge(SalaryParam::getUpdateTime, Utils.Date.getStart(pageWrap.getModel().getUpdateTime()));
+            queryWrapper.lambda().le(SalaryParam::getUpdateTime, Utils.Date.getEnd(pageWrap.getModel().getUpdateTime()));
+        }
+        if (pageWrap.getModel().getRemark() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getRemark, pageWrap.getModel().getRemark());
+        }
+        if (pageWrap.getModel().getRootDepartId() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getRootDepartId, pageWrap.getModel().getRootDepartId());
+        }
+        if (pageWrap.getModel().getDepartId() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getDepartId, pageWrap.getModel().getDepartId());
+        }
+        if (pageWrap.getModel().getProcedureId() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getProcedureId, pageWrap.getModel().getProcedureId());
+        }
+        if (pageWrap.getModel().getBomId() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getBomId, pageWrap.getModel().getBomId());
+        }
+        if (pageWrap.getModel().getSalary() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getSalary, pageWrap.getModel().getSalary());
+        }
+        if (pageWrap.getModel().getNum() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getNum, pageWrap.getModel().getNum());
+        }
+        if (pageWrap.getModel().getTimes() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getTimes, pageWrap.getModel().getTimes());
+        }
+        if (pageWrap.getModel().getUnqualified() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getUnqualified, pageWrap.getModel().getUnqualified());
+        }
+        if (pageWrap.getModel().getType() != null) {
+            queryWrapper.lambda().eq(SalaryParam::getType, pageWrap.getModel().getType());
+        }
+        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
+            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
+                queryWrapper.orderByDesc(sortData.getProperty());
+            } else {
+                queryWrapper.orderByAsc(sortData.getProperty());
+            }
+        }
+        return PageData.from(salaryParamMapper.selectPage(page, queryWrapper));
     }
 
     @Override
     public long count(SalaryParam salaryParam) {
         QueryWrapper<SalaryParam> wrapper = new QueryWrapper<>(salaryParam);
         return salaryParamMapper.selectCount(wrapper);
-    }
-
-    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
-    @Override
-    public void importPlans(MultipartFile file) {
-
-        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
-        if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){
-            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝鎮ㄦ棤鏉冮檺杩涜璇ユ搷浣滐紒");
-        }
-        //瑙f瀽excel
-        List<SalaryParamImportDTO> plansList = EasyExcelUtil.importExcel(file, 1, 1, SalaryParamImportDTO.class);
-        if(plansList == null || plansList.size()==0){
-            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵煎叆鏁版嵁鍐呭鏈夎锛�");
-        }
-
-        plansList.forEach(s->{
-            if (Objects.isNull(s.getType())
-                || Objects.isNull(s.getDepartName())
-                || Objects.isNull(s.getMaterialCode())
-                || Objects.isNull(s.getProcedureName())
-                || Objects.isNull(s.getNUM())){
-                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵煎叆鏁版嵁鍐呭鏈夎锛�");
-            }
-        });
-
-
-        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)
-                    .last("limit 1");
-            Department department = departmentMapper.selectOne(wrapper);
-            if (Objects.isNull(department)){
-                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵煎叆鏁版嵁鍐呭銆愬叕鍙稿悕绉般�戞湁璇紒");
-            }
-
-            QueryWrapper<Material> materialWrapper = new QueryWrapper<>();
-            materialWrapper.lambda()
-                    .eq(Material::getCode,salaryParamImportDTO.getMaterialCode())
-                    .eq(Material::getRootDepartId,department.getRootId())
-                    .last("limit 1");
-            Material material = materialMapper.selectOne(materialWrapper);
-
-            if (Objects.isNull(material)){
-                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵煎叆鏁版嵁鍐呭銆愪骇鍝佺紪鐮併�戞湁璇紒");
-            }
-            if (Objects.nonNull(material) && Objects.equals(material.getName(),salaryParamImportDTO.getMaterialName())){
-                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵煎叆鏁版嵁鍐呭銆愪骇鍝佸悕绉般�戞湁璇紒");
-            }
-            QueryWrapper<Procedures> proceduresWrapper = new QueryWrapper<>();
-            proceduresWrapper.lambda()
-                    .eq(Procedures::getName,salaryParamImportDTO.getProcedureName())
-                    .eq(Procedures::getRootDepartId,department.getRootId())
-                    .eq(Procedures::getDepartId,department.getId())
-                    .last("limit 1");
-            Procedures procedures = proceduresMapper.selectOne(proceduresWrapper);
-            if (Objects.isNull(procedures)){
-                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵煎叆鏁版嵁鍐呭銆愬伐搴忓悕绉般�戞湁璇紒");
-            }
-            SalaryParam salaryParam = new SalaryParam();
-            salaryParam.setRootDepartId(department.getRootId());
-            salaryParam.setDepartId(department.getId());
-            salaryParam.setProcedureId(procedures.getId());
-            salaryParam.setMaterialId(material.getId());
-            salaryParam.setSalary(salaryParamImportDTO.getSalary());
-            salaryParam.setNum(salaryParamImportDTO.getNUM());
-            //todo
-//            salaryParam.setTimes();
-//            salaryParam.setUnqualified(salaryParamImportDTO.getUnqualified() );
-//            salaryParam.setType(salaryParamImportDTO.getType());
-            create(salaryParam);
-        }
-
     }
 }

--
Gitblit v1.9.3