Quellcode durchsuchen

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

buzhanyi vor 2 Jahren
Ursprung
Commit
52c54970b5

+ 33 - 3
purchase-system/src/main/java/com/ozs/pm/service/impl/PmDemandServiceImpl.java

@@ -601,10 +601,40 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
                     List<Long> longList = list.stream().map(PmAuditDeptRef::getDeptId).collect(Collectors.toList());
                     // 如果有上级单位存在,将本单位剔除
                     SysDept sysDept = deptMapper.selectDeptById(sysUser.getDeptId());
-                    if (longList.contains(sysDept.getParentId())) {
-                        longList.remove(sysUser.getDeptId());
+                    //本单位所有参与审核的项目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();
+                            }
+                        }
+                    }
+                    //为空就返回空
+                    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::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
                 }
             } else {
                 lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());