diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java index 9fed8989..4083298a 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java @@ -771,140 +771,157 @@ public class TmTaskServiceImpl implements TmTaskService { List tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record); for (TmTask tmTask : tmTaskList) { - if (tmTask == null) { - continue; - } - List collect = tmTaskMapper.getAuditManageListByLeaseInfo(tmTask); - if (collect.isEmpty()) { - continue; - } - int deptId1 = tmTaskMapper.getDeptId(collect.get(0).getCreateBy()); - handleTaskByRoleAndDept(tmTask, collect, roles, deptId, deptId1); - } - return tmTaskList.stream().filter(t -> t.getLeaseApplyInfoList() != null).collect(Collectors.toList()); - } + int count = 0; + if (tmTask != null) { + // 去查询任务分单表 + List collect = tmTaskMapper.getAuditManageListByLeaseInfo(tmTask); + if (collect.size() > 0) { + int deptId1 = tmTaskMapper.getDeptId(collect.get(0).getCreateBy()); + if (roles.contains("admin") || deptId == 100) { + // 对领料任务集合查询具体详情 + for (LeaseApplyInfo leaseApplyInfo : collect) { + if (leaseApplyInfo != null) { + // 去查询领料任务详情表 + List leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo); + if (leaseApplyDetails.size() > 0) { + for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) { + if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) { + // 统计预领数量 + count += leaseApplyDetail.getPreNum(); + } + } + // 塞入领料任务详情的集合中 + leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails); + // 存入领料任务实体集合 + tmTask.setLeaseApplyInfoList(collect); + tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1))); + tmTask.setRemark(collect.get(0).getRemark()); + } + } + } + } else if (deptId == 101) { //机具经理、书记、副经理查看数据 + List auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 101).collect(Collectors.toList()); + if (deptId1 == 101) { + List applyInfoList = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 102).collect(Collectors.toList()); + auditListByLeaseInfo.addAll(applyInfoList); + } - /** - * 处理角色和部门逻辑 - * @param tmTask - * @param collect - * @param roles - * @param deptId - * @param deptId1 - */ - private void handleTaskByRoleAndDept(TmTask tmTask, List collect, Set roles, Long deptId, int deptId1) { - List filteredList; - if (roles.contains("admin") || deptId == 100) { - filteredList = collect; - } else if (deptId == 101) { - filteredList = handleDept101(collect, deptId1); - } else if (deptId == 102) { - filteredList = handleDept102(collect, deptId1); - } else if (deptId == deptId1) { - filteredList = collect; - } else if (roles.contains("sgb")) { - filteredList = handleRoleSgb(collect, deptId1); - } else { - return; - } - processLeaseApplyInfoList(tmTask, filteredList, collect, deptId1); - } + if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) { + // 对领料任务集合查询具体详情 + for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) { + if (leaseApplyInfo != null) { + // 去查询领料任务详情表 + List leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo); + if (leaseApplyDetails.size() > 0) { + for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) { + if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) { + // 统计预领数量 + count += leaseApplyDetail.getPreNum(); + } + } + // 塞入领料任务详情的集合中 + leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails); + // 存入领料任务实体集合 + tmTask.setLeaseApplyInfoList(auditListByLeaseInfo); + tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1))); + tmTask.setRemark(collect.get(0).getRemark()); + } + } + } + } + } else if (deptId == 102) { // 调试公司可以看到的数据权限 + List auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 102).collect(Collectors.toList()); + if (deptId1 == 102) { + List list2 = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 101).collect(Collectors.toList()); + auditListByLeaseInfo.addAll(list2); + } - /** - * 处理部门101 - * @param collect - * @param deptId1 - * @return - */ - private List handleDept101(List collect, int deptId1) { - List auditListByLeaseInfo = collect.stream() - .filter(t -> t.getCompanyId() != null) - .filter(t -> t.getCompanyId() == 101) - .collect(Collectors.toList()); - if (deptId1 == 101) { - List applyInfoList = collect.stream() - .filter(t -> t.getCompanyId() != null) - .filter(t -> t.getCompanyId() == 102) - .collect(Collectors.toList()); - auditListByLeaseInfo.addAll(applyInfoList); - } - return auditListByLeaseInfo; - } + if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) { + // 对领料任务集合查询具体详情 + for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) { + if (leaseApplyInfo != null) { + // 去查询领料任务详情表 + List leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo); + if (leaseApplyDetails.size() > 0) { + for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) { + if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) { + // 统计预领数量 + count += leaseApplyDetail.getPreNum(); + } + } + // 塞入领料任务详情的集合中 + leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails); + // 存入领料任务实体集合 + tmTask.setLeaseApplyInfoList(auditListByLeaseInfo); + tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1))); + tmTask.setRemark(collect.get(0).getRemark()); + } + } + } + } + } else if (deptId == deptId1) { //其他各分公司可以看到的自己部门的数据 + // 对领料任务集合查询具体详情 + for (LeaseApplyInfo leaseApplyInfo : collect) { + if (leaseApplyInfo != null) { + // 去查询领料任务详情表 + List leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo); + if (leaseApplyDetails.size() > 0) { + for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) { + if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) { + // 统计预领数量 + count += leaseApplyDetail.getPreNum(); + } + } + // 塞入领料任务详情的集合中 + leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails); + // 存入领料任务实体集合 + tmTask.setLeaseApplyInfoList(collect); + tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1))); + tmTask.setRemark(collect.get(0).getRemark()); + } + } + } + } else if (roles.contains("sgb")) { + // 对领料任务集合查询具体详情 + List auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 101).collect(Collectors.toList()); + if (deptId1 == 210) { + List list1 = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 102).collect(Collectors.toList()); + auditListByLeaseInfo.addAll(list1); + } + if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) { + // 对领料任务集合查询具体详情 + for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) { + if (leaseApplyInfo != null) { + // 去查询领料任务详情表 + List leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo); + if (leaseApplyDetails.size() > 0) { + for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) { + if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) { + // 统计预领数量 + count += leaseApplyDetail.getPreNum(); + } + } + // 塞入领料任务详情的集合中 + leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails); + // 存入领料任务实体集合 + tmTask.setLeaseApplyInfoList(auditListByLeaseInfo); + tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1))); + tmTask.setRemark(collect.get(0).getRemark()); + } + } + } + } + } - /** - * 处理部门102 - * @param collect - * @param deptId1 - * @return - */ - private List handleDept102(List collect, int deptId1) { - List auditListByLeaseInfo = collect.stream() - .filter(t -> t.getCompanyId() != null) - .filter(t -> t.getCompanyId() == 102) - .collect(Collectors.toList()); - if (deptId1 == 102) { - List list2 = collect.stream() - .filter(t -> t.getCompanyId() != null) - .filter(t -> t.getCompanyId() == 101) - .collect(Collectors.toList()); - auditListByLeaseInfo.addAll(list2); - } - return auditListByLeaseInfo; - } - - /** - * 处理角色为sgb - * @param collect - * @param deptId1 - * @return - */ - private List handleRoleSgb(List collect, int deptId1) { - List auditListByLeaseInfo = collect.stream() - .filter(t -> t.getCompanyId() != null) - .filter(t -> t.getCompanyId() == 101) - .collect(Collectors.toList()); - if (deptId1 == 210) { - List list1 = collect.stream() - .filter(t -> t.getCompanyId() != null) - .filter(t -> t.getCompanyId() == 102) - .collect(Collectors.toList()); - auditListByLeaseInfo.addAll(list1); - } - return auditListByLeaseInfo; - } - - /** - * 处理部门101、102、sgb角色的逻辑 - * @param tmTask - * @param filteredList - * @param collect - * @param deptId1 - */ - private void processLeaseApplyInfoList(TmTask tmTask, List filteredList, List collect, int deptId1) { - if (filteredList.isEmpty()) { - return; - } - int count = 0; - for (LeaseApplyInfo leaseApplyInfo : filteredList) { - if (leaseApplyInfo == null) { - continue; - } - List leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo); - if (leaseApplyDetails.isEmpty()) { - continue; - } - for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) { - if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) { - count += leaseApplyDetail.getPreNum(); } } - leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails); + tmTask.setPreCountNum(count); } - tmTask.setLeaseApplyInfoList(filteredList); - tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1))); - tmTask.setRemark(collect.get(0).getRemark()); - tmTask.setPreCountNum(count); + List tmTasks = tmTaskList.stream().filter(t -> t.getLeaseApplyInfoList() != null).collect(Collectors.toList()); + return tmTasks; } + + /** * 获取审核列表 - App端 */