Browse Source

采购执行管理中,本单位超额项目交给上级处理,本单位不处理。(包括采购办首页待办事项)

buzhanyi 2 năm trước cách đây
mục cha
commit
a4cbafe06f

+ 99 - 30
purchase-system/src/main/java/com/ozs/pm/service/impl/PmDemandServiceImpl.java

@@ -124,6 +124,7 @@ import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -597,7 +598,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
             } else if (3 == reqType) {
                 if (!ObjectUtils.isEmpty(list)) {
                     //查出审核此项目的单位
-                    List<Long> longList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
+                    List<Long> longList = list.stream().map(PmAuditDeptRef::getDeptId).collect(Collectors.toList());
                     // 如果有上级单位存在,将本单位剔除
                     SysDept sysDept = deptMapper.selectDeptById(sysUser.getDeptId());
                     if (longList.contains(sysDept.getParentId())) {
@@ -4018,25 +4019,44 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public List<PmDemand> getListByStatusCGB(String projectStatus) {
         //登录用户的部门
         Long deptId = SecurityUtils.getDeptId();
+        SysDept sysDept = deptMapper.selectDeptById(deptId);
+
         LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
-        //需求待提交时不用查审核
         List<PmAuditDeptRef> list = new ArrayList<>();
         LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
         l.eq(PmAuditDeptRef::getDeptId, deptId);
         l.eq(PmAuditDeptRef::getRefType, "2");
         list = pmAuditDeptRefService.list(l);
-        if (!ObjectUtils.isEmpty(list) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
-            //查出审核此项目的单位
-            List<Long> longList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
-            // 如果有上级单位存在,将本单位剔除
-            SysDept sysDept = deptMapper.selectDeptById(deptId);
-            if (longList.contains(sysDept.getParentId())) {
-                longList.remove(deptId);
+        //本单位所有参与审核的项目id
+        List<Long> refList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
+        //替身,取交集用
+        List<Long> refListL = refList;
+
+        //上级参与审核的项目
+        List<Long> refListf = new ArrayList<>();
+        LambdaQueryWrapper<PmDemand> lwf = new LambdaQueryWrapper<PmDemand>();
+        List<PmAuditDeptRef> listf = new ArrayList<>();
+        if (sysDept.getParentId() != 0) {
+            LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
+            lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
+            lf.eq(PmAuditDeptRef::getRefType, "2");
+            listf = pmAuditDeptRefService.list(lf);
+            //上级参与审核的项目id
+            refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
+        }
+        //取集合交集,交集中的是上级处理,本单位不处理
+        if (!ObjectUtils.isEmpty(refListf)) {
+            refListL.retainAll(refListf);
+            Iterator<Long> it = refList.iterator();
+            while (it.hasNext()) {
+                //只留下本单位要处理的项目
+                if (refListL.contains(it.next())) {
+                    it.remove();
+                }
             }
-            lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
         }
+
         lw.in(PmDemand::getProjectStatus, projectStatus);
-        lw.eq(PmDemand::getPurchaseDeptId, deptId);
         lw.last(" order by project_status, plan_demand_sub_time");
         return this.baseMapper.selectList(lw);
     }
@@ -4076,24 +4096,49 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public List<PmDemand> getListByStatusTotalCGB(List<String> projectStatus) {
         //登录用户的部门
         Long deptId = SecurityUtils.getDeptId();
+        SysDept sysDept = deptMapper.selectDeptById(deptId);
+
         LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
         List<PmAuditDeptRef> list = new ArrayList<>();
         LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
         l.eq(PmAuditDeptRef::getDeptId, deptId);
         l.eq(PmAuditDeptRef::getRefType, "2");
         list = pmAuditDeptRefService.list(l);
-        if (!ObjectUtils.isEmpty(list) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
-            //查出审核此项目的单位
-            List<Long> longList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
-            // 如果有上级单位存在,将本单位剔除
-            SysDept sysDept = deptMapper.selectDeptById(deptId);
-            if (longList.contains(sysDept.getParentId())) {
-                longList.remove(deptId);
+        //本单位所有参与审核的项目id
+        List<Long> refList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
+        //替身,取交集用
+        List<Long> refListL = refList;
+
+        //上级参与审核的项目
+        List<Long> refListf = new ArrayList<>();
+        LambdaQueryWrapper<PmDemand> lwf = new LambdaQueryWrapper<PmDemand>();
+        List<PmAuditDeptRef> listf = new ArrayList<>();
+        if (sysDept.getParentId() != 0) {
+            LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
+            lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
+            lf.eq(PmAuditDeptRef::getRefType, "2");
+            listf = pmAuditDeptRefService.list(lf);
+            //上级参与审核的项目id
+            refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
+        }
+        //取集合交集,交集中的是上级处理,本单位不处理
+        if (!ObjectUtils.isEmpty(refListf)) {
+            refListL.retainAll(refListf);
+            Iterator<Long> it = refList.iterator();
+            while (it.hasNext()) {
+                //只留下本单位要处理的项目
+                if (refListL.contains(it.next())) {
+                    it.remove();
+                }
             }
-            lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
+        }
+        //为空就返回空
+        if (ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
+            lw.in(PmDemand::getDemandId, -1);
+        } else if (!ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
+            lw.in(PmDemand::getDemandId, refList);
         }
         lw.in(PmDemand::getProjectStatus, projectStatus);
-        lw.eq(PmDemand::getPurchaseDeptId, deptId);
         lw.last(" order by project_status, plan_demand_sub_time");
         return this.baseMapper.selectList(lw);
     }
@@ -4138,25 +4183,49 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public Integer getNumByStatusCGB(String projectStatus) {
         //登录用户的部门
         Long deptId = SecurityUtils.getDeptId();
+        SysDept sysDept = deptMapper.selectDeptById(deptId);
+
         LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
-        ///需求待提交时不用查审核
         List<PmAuditDeptRef> list = new ArrayList<>();
         LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
         l.eq(PmAuditDeptRef::getDeptId, deptId);
         l.eq(PmAuditDeptRef::getRefType, "2");
         list = pmAuditDeptRefService.list(l);
-        if (!ObjectUtils.isEmpty(list) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
-            //查出审核此项目的单位
-            List<Long> longList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
-            // 如果有上级单位存在,将本单位剔除
-            SysDept sysDept = deptMapper.selectDeptById(deptId);
-            if (longList.contains(sysDept.getParentId())) {
-                longList.remove(deptId);
+        //本单位所有参与审核的项目id
+        List<Long> refList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
+        //替身,取交集用
+        List<Long> refListL = refList;
+
+        //上级参与审核的项目
+        List<Long> refListf = new ArrayList<>();
+        LambdaQueryWrapper<PmDemand> lwf = new LambdaQueryWrapper<PmDemand>();
+        List<PmAuditDeptRef> listf = new ArrayList<>();
+        if (sysDept.getParentId() != 0) {
+            LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
+            lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
+            lf.eq(PmAuditDeptRef::getRefType, "2");
+            listf = pmAuditDeptRefService.list(lf);
+            //上级参与审核的项目id
+            refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
+        }
+        //取集合交集,交集中的是上级处理,本单位不处理
+        if (!ObjectUtils.isEmpty(refListf)) {
+            refListL.retainAll(refListf);
+            Iterator<Long> it = refList.iterator();
+            while (it.hasNext()) {
+                //只留下本单位要处理的项目
+                if (refListL.contains(it.next())) {
+                    it.remove();
+                }
             }
-            lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
+        }
+        //为空就返回空
+        if (ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
+            lw.in(PmDemand::getDemandId, -1);
+        } else if (!ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
+            lw.in(PmDemand::getDemandId, refList);
         }
         lw.eq(PmDemand::getProjectStatus, projectStatus);
-        lw.eq(PmDemand::getPurchaseDeptId, deptId);
         lw.last(" order by project_status, plan_demand_sub_time");
         Long count = this.baseMapper.selectCount(lw);
         return Math.toIntExact(count);