浏览代码

审核关联表

suntianwu 2 年之前
父节点
当前提交
f9c2368393

+ 6 - 5
purchase-admin/src/main/java/com/ozs/web/controller/pm/PmPurchaseExecutionController.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ozs.base.domain.BaseAgency;
 import com.ozs.base.domain.BaseExpert;
 import com.ozs.base.domain.BaseProfessional;
+import com.ozs.base.domain.BaseUnitInformation;
 import com.ozs.base.domain.vo.BaseExpertVo;
 import com.ozs.base.domain.vo.BaseProfessionalVo;
 import com.ozs.base.service.BaseAgencyService;
@@ -302,13 +303,13 @@ public class PmPurchaseExecutionController extends BaseController {
     @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:getExpertUnitList')")
     @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
     public AjaxResult getExpertUnitList() {
-        List<BaseExpert> baseExperts = baseExpertService.list();
-        if(ObjectUtils.isEmpty(baseExperts)){
-            return error("专家列表是空的");
+        List<BaseUnitInformation> baseUnitInformationList = baseExpertService.getBaseUnitInformationList();
+        if(ObjectUtils.isEmpty(baseUnitInformationList)){
+            return error("专家单位列表是空的");
         }
         Set<String> set = new HashSet<>();
-        for(BaseExpert baseExpert : baseExperts) {
-            set.add(baseExpert.getUnitInformation());
+        for(BaseUnitInformation baseUnitInformation : baseUnitInformationList) {
+            set.add(baseUnitInformation.getUnitName());
         }
         return success(set);
     }

+ 5 - 0
purchase-system/src/main/java/com/ozs/base/service/BaseExpertService.java

@@ -3,9 +3,12 @@ package com.ozs.base.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ozs.base.domain.BaseAgency;
 import com.ozs.base.domain.BaseExpert;
+import com.ozs.base.domain.BaseUnitInformation;
 import com.ozs.base.domain.vo.BaseExpertVo;
 import com.ozs.common.core.domain.AjaxResult;
 
+import java.util.List;
+
 public interface BaseExpertService  extends IService<BaseExpert> {
     int insertExpert(BaseExpertVo baseExpertVo);
 
@@ -14,4 +17,6 @@ public interface BaseExpertService  extends IService<BaseExpert> {
     AjaxResult selectReviewProject(BaseExpertVo baseExpertVo);
 
     AjaxResult selectExtractionExpert(BaseExpertVo baseExpertVo);
+
+    List<BaseUnitInformation> getBaseUnitInformationList();
 }

+ 6 - 0
purchase-system/src/main/java/com/ozs/base/service/impl/BaseExpertServiceImpl.java

@@ -112,6 +112,12 @@ public class BaseExpertServiceImpl extends ServiceImpl<BaseExpertMapper, BaseExp
         return AjaxResult.success(pageInfo);
     }
 
+    @Override
+    public List<BaseUnitInformation> getBaseUnitInformationList(){
+        List<BaseUnitInformation> baseUnitInformationList = baseExpertMapper.selectByUnitInformation(null);
+        return baseUnitInformationList;
+    }
+
     private List<PmDemandResVo> changTo(List<PmDemand> pmDemandList) {
         List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
         if (pmDemandList != null && pmDemandList.size() > 0) {

+ 159 - 18
purchase-system/src/main/java/com/ozs/pm/service/impl/PmDemandServiceImpl.java

@@ -14,12 +14,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ozs.base.domain.*;
 import com.ozs.base.domain.vo.BaseExpertVo;
+import com.ozs.base.mapper.BaseExpertMapper;
 import com.ozs.base.service.*;
 import com.ozs.common.core.domain.AjaxResult;
-import com.ozs.common.core.domain.entity.SysDept;
-import com.ozs.common.core.domain.entity.SysDictData;
-import com.ozs.common.core.domain.entity.SysRole;
-import com.ozs.common.core.domain.entity.SysUser;
+import com.ozs.common.core.domain.entity.*;
 import com.ozs.common.enums.*;
 import com.ozs.common.utils.DateUtils;
 import com.ozs.common.utils.RandomUtil;
@@ -123,6 +121,13 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
     @Autowired
     private SysDeptMapper deptMapper;
+    @Autowired
+    private BaseExpertMapper baseExpertMapper;
+
+    @Autowired
+    private SysProcurementStandardService sysProcurementStandardService;
+    @Autowired
+    private PmAuditDeptRefService pmAuditDeptRefService;
 
     /**
      * 查询采购需求
@@ -710,13 +715,70 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean commit(PmDemandReqVo pmDemandReqVo) {
-        PmDemand pmDemand = new PmDemand();
-        pmDemand.setDemandId(pmDemandReqVo.getDemandId());
-        pmDemand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
-        pmDemand.setRealDemandCommitTime(DateUtils.getNowDate());
-        pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
-        pmDemand.setUpdateTime(DateUtils.getNowDate());
-        return this.updateById(pmDemand);
+        PmDemand pmDemand = this.getById(pmDemandReqVo.getDemandId());
+
+        SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
+        Long deptId = sysUser.getDeptId();
+        SysDept sysDept = deptMapper.selectDeptById(deptId);
+        String[] ancestors = sysDept.getAncestors().split(",");
+        String deptLevel = null;
+        if(ancestors.length == 2){ //C级
+            deptLevel = "C";
+        } else if(ancestors.length == 3){ //B级
+            deptLevel = "B";
+        } else if(ancestors.length == 4){ //A级
+            deptLevel = "A";
+        }
+        LambdaQueryWrapper<SysProcurementStandard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(SysProcurementStandard::getDeptId,deptId)
+                .eq(SysProcurementStandard::getCategory,pmDemand.getProjectType())
+                .eq(SysProcurementStandard::getState,1);//0不限1限额
+        SysProcurementStandard sysProcurementStandard = sysProcurementStandardService.getOne(lambdaQueryWrapper);
+
+        PmAuditDeptRef pmAuditDeptRef = new PmAuditDeptRef();
+        pmAuditDeptRef.setRefId(pmDemand.getDemandId());
+        pmAuditDeptRef.setRefType("2");
+        pmAuditDeptRef.setStatus(0);
+        pmAuditDeptRef.setCreated(pmDemandReqVo.getUpdateBy());
+        pmAuditDeptRef.setCreateTime(DateUtils.getNowDate());
+        pmAuditDeptRef.setUpdated(pmDemandReqVo.getUpdateBy());
+        pmAuditDeptRef.setUpdateTime(pmAuditDeptRef.getCreateTime());
+
+        if(!ObjectUtils.isEmpty(sysProcurementStandard)){ //限额
+            BigDecimal maximum = sysProcurementStandard.getMaximum();
+            if(maximum.doubleValue() < pmDemand.getEvaluation()) { //需求超额了,提交给上级部门
+                String parentDeptLevel = null;
+                Long parentDeptId = null;
+                if("A".endsWith(deptLevel)){
+                    parentDeptLevel = "B";
+                    parentDeptId = sysDept.getParentId();
+                } else if("B".endsWith(deptLevel)) {
+                    parentDeptLevel = "C";
+                    parentDeptId = sysDept.getParentId();
+                } else { //C级提交同级
+                    parentDeptLevel = "C";
+                    parentDeptId = deptId;
+                }
+
+                pmAuditDeptRef.setDeptId(parentDeptId);
+                pmAuditDeptRef.setDeptLevel(parentDeptLevel);
+            } else { //没超额,提交给同级
+                pmAuditDeptRef.setDeptId(deptId);
+                pmAuditDeptRef.setDeptLevel(deptLevel);
+            }
+        } else { //不限额,提交给同级
+            pmAuditDeptRef.setDeptId(deptId);
+            pmAuditDeptRef.setDeptLevel(deptLevel);
+        }
+        pmAuditDeptRefService.save(pmAuditDeptRef);
+
+        PmDemand pmDemandUpdate = new PmDemand();
+        pmDemandUpdate.setDemandId(pmDemand.getDemandId());
+        pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
+        pmDemandUpdate.setRealDemandCommitTime(DateUtils.getNowDate());
+        pmDemandUpdate.setUpdateBy(pmDemandReqVo.getUpdateBy());
+        pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
+        return this.updateById(pmDemandUpdate);
     }
 
     /**
@@ -728,16 +790,83 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean reviewTo(PmDemandReqVo pmDemandReqVo) {
-        PmDemand pmDemand = new PmDemand();
-        pmDemand.setDemandId(pmDemandReqVo.getDemandId());
-        pmDemand.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
+       PmDemand pmDemand = this.getById(pmDemandReqVo.getDemandId());
+
+        PmDemand pmDemandUpdate = new PmDemand();
+        pmDemandUpdate.setDemandId(pmDemand.getDemandId());
+
+        SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
+        Long deptId = sysUser.getDeptId();
+        SysDept sysDept = deptMapper.selectDeptById(deptId);
+        String[] ancestors = sysDept.getAncestors().split(",");
+        String deptLevel = null;
+        if(ancestors.length == 2){ //C级
+            deptLevel = "C";
+        } else if(ancestors.length == 3){ //B级
+            deptLevel = "B";
+        } else if(ancestors.length == 4){ //A级
+            deptLevel = "A";
+        }
+        LambdaQueryWrapper<SysProcurementStandard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(SysProcurementStandard::getDeptId,deptId)
+                .eq(SysProcurementStandard::getCategory,pmDemand.getProjectType())
+                .eq(SysProcurementStandard::getState,1);//0不限1限额
+        SysProcurementStandard sysProcurementStandard = sysProcurementStandardService.getOne(lambdaQueryWrapper);
+
+        PmAuditDeptRef pmAuditDeptRef = new PmAuditDeptRef();
+        pmAuditDeptRef.setRefId(pmDemand.getDemandId());
+        pmAuditDeptRef.setRefType("2");
+        pmAuditDeptRef.setCreated(pmDemandReqVo.getUpdateBy());
+        pmAuditDeptRef.setCreateTime(DateUtils.getNowDate());
+        pmAuditDeptRef.setUpdated(pmDemandReqVo.getUpdateBy());
+        pmAuditDeptRef.setUpdateTime(pmAuditDeptRef.getCreateTime());
+
+        if(!ObjectUtils.isEmpty(sysProcurementStandard)){ //限额
+            BigDecimal maximum = sysProcurementStandard.getMaximum();
+            if(maximum.doubleValue() < pmDemand.getEvaluation()) { //需求超额了,提交给上级部门
+                String parentDeptLevel = null;
+                Long parentDeptId = null;
+                if("A".endsWith(deptLevel)){
+                    parentDeptLevel = "B";
+                    parentDeptId = sysDept.getParentId();
+                    pmAuditDeptRef.setStatus(0);
+                    pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
+                } else if("B".endsWith(deptLevel)) {
+                    parentDeptLevel = "C";
+                    parentDeptId = sysDept.getParentId();
+                    pmAuditDeptRef.setStatus(0);
+                    pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
+                } else { //C级 审核通过
+                    parentDeptLevel = "C";
+                    parentDeptId = deptId;
+                    pmAuditDeptRef.setStatus(1);
+                    pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
+                }
+
+                pmAuditDeptRef.setDeptId(parentDeptId);
+                pmAuditDeptRef.setDeptLevel(parentDeptLevel);
+
+            } else { //没超额,审核通过
+                pmAuditDeptRef.setDeptId(deptId);
+                pmAuditDeptRef.setDeptLevel(deptLevel);
+                pmAuditDeptRef.setStatus(1);
+                pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
+            }
+        } else { //不限额,审核通过
+            pmAuditDeptRef.setDeptId(deptId);
+            pmAuditDeptRef.setDeptLevel(deptLevel);
+            pmAuditDeptRef.setStatus(1);
+            pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
+        }
+        pmAuditDeptRefService.save(pmAuditDeptRef);
+
         List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
         uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
 
-        pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
-        pmDemand.setUpdateTime(DateUtils.getNowDate());
-        pmDemand.setAuditTime(DateUtils.getNowDate());
-        return this.updateById(pmDemand);
+        pmDemandUpdate.setUpdateBy(pmDemandReqVo.getUpdateBy());
+        pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
+        pmDemandUpdate.setAuditTime(DateUtils.getNowDate());
+        return this.updateById(pmDemandUpdate);
     }
 
     /**
@@ -916,6 +1045,18 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
                 pmDemandExpertRef.setUpdateBy(pmBaseExpertFillReqVo.getCreateBy());
                 pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
                 pmDemandExpertRefService.saveOrUpdate(pmDemandExpertRef);
+
+                //专家单位
+                if (StringUtils.isNotNull(baseExpert.getUnitInformation())) {
+                    List<BaseUnitInformation> baseUnitInformationList = baseExpertMapper.selectByUnitInformation(baseExpert.getUnitInformation());
+                    if (baseUnitInformationList.size() <= 0) {
+                        BaseUnitInformation baseUnitInformation = new BaseUnitInformation();
+                        baseUnitInformation.setUnitName(baseExpert.getUnitInformation());
+                        baseUnitInformation.setCreated(baseExpert.getExpertName());
+                        baseUnitInformation.setCreateTime(new Date());
+                        Integer i = baseExpertMapper.insertBaseUnitInformation(baseUnitInformation);
+                    }
+                }
             }
 
         }