Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

buzhanyi vor 2 Jahren
Ursprung
Commit
a3808b42b4

+ 3 - 1
purchase-admin/src/main/java/com/ozs/web/controller/pm/PmDemandController.java

@@ -161,7 +161,9 @@ public class PmDemandController extends BaseController {
     @PreAuthorize("@ss.hasPermi('pm:examine:list')")
     @Log(title = ModularConstans.demandExamine, businessType = BusinessType.QUERY)
     public AjaxResult examineList(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        IPage<PmDemandResVo> page  = pmDemandService.selectPmDemandList(pmDemandReqVo,1);
+        pmDemandReqVo.setDeptId(getDeptId());
+        pmDemandReqVo.setUserId(getUserId());
+        IPage<PmDemandResVo> page = pmDemandService.selectPmDemandList(pmDemandReqVo, 1);
         return success(page);
     }
 

+ 4 - 0
purchase-system/src/main/java/com/ozs/pm/doman/vo/requestVo/PmDemandReqVo.java

@@ -89,4 +89,8 @@ public class PmDemandReqVo extends PageVo
 
     @ApiModelProperty("项目类型列表")
     private List<String> projectStatusList;
+
+    private Long deptId;
+
+    private Long userId;
 }

+ 2 - 0
purchase-system/src/main/java/com/ozs/pm/doman/vo/responseVo/PmDemandResVo.java

@@ -263,4 +263,6 @@ public class PmDemandResVo extends BaseEntity
      * 抽取时间
      */
     private Date accessTime;
+
+    private Boolean flay;
 }

+ 64 - 137
purchase-system/src/main/java/com/ozs/pm/service/impl/PmDemandServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ozs.pm.service.impl;
 
+import java.lang.invoke.LambdaConversionException;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
 import java.text.ParseException;
@@ -383,42 +384,14 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public IPage<PmDemandResVo> selectPmDemandList(PmDemandReqVo pmDemandReqVo, int reqType) {
         LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
 
-        /*******************权限代码***********************/
-        SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
-        Long deptId = sysUser.getDeptId();
-
-        //获取登录用户的角色
-        List<SysRole> sysRoles = sysRoleMapper.selectRolePermissionByUserId(SecurityUtils.getUserId());
-        //获取属于求单位管理员的列表
-        List<SysRole> sysRoleList2 = sysRoles.stream().filter(tdto -> tdto.getRoleKey().equals(SysRoleKey.DEMAND_UNIT.getCode())).collect(Collectors.toList());
-        if (!ObjectUtils.isEmpty(sysRoleList2)) { //属于需求单位管理员
-            lw.apply("(purchase_dept_id = " + deptId + ")");
-        } else {
-            //获取属于采购管理部门管理员 或 采购办管理员的列表
-            List<SysRole> sysRoleList = sysRoles.stream().filter(tdto -> (tdto.getRoleKey().equals(SysRoleKey.PURCHASING_MANAGEMENT.getCode())
-                    || tdto.getRoleKey().equals(SysRoleKey.PROCUREMENT_OFFICE.getCode()))).collect(Collectors.toList());
-            if (!ObjectUtils.isEmpty(sysRoleList)) { //属于采购管理部门管理员 或 采购办管理员
-                //获取子部门列表
-                List<SysDept> sysDeptSubs = deptMapper.selectChildrenDeptById(sysUser.getDeptId());
-                String sysDeptSubStr = null;
-                if (!ObjectUtils.isEmpty(sysDeptSubs)) {
-                    List<String> sysDeptSubIds = sysDeptSubs.stream().map(SysDept::getDeptId).collect(Collectors.toList())
-                            .stream().map(x -> x + "").collect(Collectors.toList());
-                    sysDeptSubStr = String.join(",", sysDeptSubIds);
-                }
-
-                String condtionSql = null;
-                if (ObjectUtils.isEmpty(sysDeptSubStr)) {
-                    condtionSql = "(purchase_dept_id = " + deptId + " AND is_excess = 0) ";
-                } else {
-                    condtionSql = "((purchase_dept_id = " + deptId + " AND is_excess = 0) " +
-                            " OR (purchase_dept_id IN (" + sysDeptSubStr + ")  AND is_excess = 1))";
-                }
-
-                lw.apply(condtionSql);
-            }
+        LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
+        l.eq(PmAuditDeptRef::getDeptId, pmDemandReqVo.getDeptId());
+        l.eq(PmAuditDeptRef::getRefType, "2");
+        List<PmAuditDeptRef> list = pmAuditDeptRefService.list(l);
+        if (!ObjectUtils.isEmpty(list)) {
+            lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
         }
-        /*******************权限代码end***********************/
+
 
         if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) {
             lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%");
@@ -460,6 +433,32 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         IPage<PmDemandResVo> results = new Page<>(pageRes.getCurrent(), pageRes.getSize(), pageRes.getTotal());
         if (pageRes.getRecords() != null && pageRes.getRecords().size() > 0) {
             List<PmDemandResVo> pmDemandResVos = demandChangeTo(pageRes.getRecords());
+
+            for (PmDemandResVo vo : pmDemandResVos) {
+                // 根据项目id 和 部门id 和 参数类型 获取 部门级别
+                List<PmAuditDeptRef> collect = list.stream()
+                        .filter(o -> o.getRefId().equals(vo.getDemandId()))
+                        .collect(Collectors.toList());
+                if (!ObjectUtils.isEmpty(collect)) {
+                    String deptLevel = collect.get(0).getDeptLevel();
+
+                    // 根据项目id  和 参数类型 获取 所有审核数据
+                    LambdaQueryWrapper<PmAuditDeptRef> ll = new LambdaQueryWrapper<>();
+                    ll.eq(PmAuditDeptRef::getRefId, vo.getDemandId());
+                    ll.eq(PmAuditDeptRef::getRefType, "2");
+                    List<PmAuditDeptRef> listl = pmAuditDeptRefService.list(l);
+
+                    // 判断当前用户是否有审核权限
+                    boolean flay = true;
+                    for (PmAuditDeptRef pmAuditDeptRef : listl) {
+                        if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
+                                && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
+                            flay = false;
+                        }
+                    }
+                    vo.setFlay(flay);
+                }
+            }
             results.setRecords(pmDemandResVos);
         }
 
@@ -720,57 +719,12 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         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);
+        pmAuditDeptRefService.insertPmAuditDeptRefs(pmDemandReqVo.getDemandId()
+                , "2"
+                , deptId
+                , BigDecimal.valueOf(pmDemand.getEvaluation())
+                , sysUser.getUserId()
+                , pmDemand.getProjectType());
 
         PmDemand pmDemandUpdate = new PmDemand();
         pmDemandUpdate.setDemandId(pmDemand.getDemandId());
@@ -800,65 +754,35 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         SysDept sysDept = deptMapper.selectDeptById(deptId);
         String[] ancestors = sysDept.getAncestors().split(",");
         String deptLevel = null;
-        if(ancestors.length == 2){ //C级
+        if (ancestors.length == 2) { //C级
             deptLevel = "C";
-        } else if(ancestors.length == 3){ //B级
+        } else if (ancestors.length == 3) { //B级
             deptLevel = "B";
-        } else if(ancestors.length == 4){ //A级
+        } 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;
+        LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
+        lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
+        lw.eq(PmAuditDeptRef::getRefType, "2");
+        List<PmAuditDeptRef> list = pmAuditDeptRefService.list(lw);
+        boolean flay = true;
+        if (!ObjectUtils.isEmpty(list)) {
+            for (PmAuditDeptRef pmAuditDeptRef : list) {
+                // 判断 deptLevel 是否还有更高的 且是 待审核的数据
+                if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
+                        && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
+                    flay = false;
+                }
+                // 更新当前  deptLevel 级别的审核状态
+                if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0) {
                     pmAuditDeptRef.setStatus(1);
-                    pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
+                    pmAuditDeptRefService.updateById(pmAuditDeptRef);
                 }
-
-                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);
+        }
+        if (flay) {
             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());
@@ -886,7 +810,10 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
                 .set(PmDemand::getUpdateBy, pmDemandReqVo.getUpdateBy())
                 .set(PmDemand::getUpdateTime, DateUtils.getNowDate())
                 .set(PmDemand::getAuditTime, DateUtils.getNowDate());
-
+        LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
+        lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
+        lw.eq(PmAuditDeptRef::getRefType, "2");
+        pmAuditDeptRefService.remove(lw);
         return this.update(updateWrapper);
     }