diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java index 73a04675..90018955 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/TmTaskMapper.java @@ -142,4 +142,6 @@ public interface TmTaskMapper { int updateLeaseApplyInfoRejectInfoCq(@Param("record") LeaseApplyInfo leaseApplyInfo); int updateLeaseApplyInfoAuditInfoCq(@Param("record") LeaseApplyInfo leaseApplyInfo); + + int getDeptId(String createBy); } \ No newline at end of file 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 1d88ab8a..b4578bde 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 @@ -615,37 +615,16 @@ public class TmTaskServiceImpl implements TmTaskService { public List getLeaseAuditManageList(TmTask record) { Set roles = SecurityUtils.getLoginUser().getRoles(); Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - List tmTaskList = new ArrayList<>(); + List collect; + int count = 0; + List leaseApplyInfoList = new ArrayList<>(); + List tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record); if (roles.contains("admin")) { - tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record); - } else if (roles.contains("em01") || roles.contains("em02")) { //机具经理、机具副经理 - record.setDeptId(101L); - tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record); - } else if (roles.contains("sgb")) { //施管部经理 - record.setDeptId(210L); - tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record); - } else if (roles.contains("dm01") || roles.contains("dm04")) { //调试经理、调试安全专责 - record.setDeptId(102L); - tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record); - } else if (roles.contains("dm02")) { //调试审核员 - record.setCompanyId(102); - tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record); - } else if (roles.contains("fgs")) { //各分公司经理 - record.setDeptId(deptId); - tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record); - } else { //其他角色只能看到自己部门下的数据 - record.setDeptId(deptId); - tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record); - } - - for (TmTask tmTask : tmTaskList) { - int count = 0; - if (tmTask != null) { - tmTask.setDeptId(deptId); - // 去查询任务分单表 - List collect = tmTaskMapper.getAuditManageListByLeaseInfo(tmTask); - //管理员可以看到所有数据 - if (roles.contains("admin")) { + for (TmTask tmTask : tmTaskList) { + if (tmTask != null) { + // 去查询任务分单表 + collect = tmTaskMapper.getAuditManageListByLeaseInfo(tmTask); + record.setDeptId(null); // 对领料任务集合查询具体详情 for (LeaseApplyInfo leaseApplyInfo : collect) { if (leaseApplyInfo != null) { @@ -666,76 +645,50 @@ public class TmTaskServiceImpl implements TmTaskService { } } } - } else if (roles.contains("em01") || roles.contains("em02") || roles.contains("sgb")) { - List auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 101).collect(Collectors.toList()); - 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.setRemark(collect.get(0).getRemark()); - } - } - } + } + // 塞入预领的合计数量 + tmTask.setPreCountNum(count); + } + + } else { + for (TmTask tmTask : tmTaskList) { + collect = tmTaskMapper.getAuditManageListByLeaseInfo(tmTask); + for (LeaseApplyInfo leaseApplyInfo : collect) { + String createBy = leaseApplyInfo.getCreateBy(); + // 查询当前领料人所属部门 + int deptId1 = tmTaskMapper.getDeptId(createBy); + if ((deptId == 101 && leaseApplyInfo.getCompanyId() == 101) || (deptId1 == deptId && deptId1 == 101)) { + leaseApplyInfoList.add(leaseApplyInfo); } - } else if (roles.contains("dm01") || roles.contains("dm04") || roles.contains("dm02")) { - List auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 102).collect(Collectors.toList()); - 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) { - // 统计预领数量 - count += leaseApplyDetail.getPreNum(); - } - } - // 塞入领料任务详情的集合中 - leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails); - // 存入领料任务实体集合 - tmTask.setLeaseApplyInfoList(auditListByLeaseInfo); - tmTask.setRemark(collect.get(0).getRemark()); - } - } - } + if ((deptId == 102 && leaseApplyInfo.getCompanyId() == 102) || (deptId1 == deptId && deptId1 == 102)) { + leaseApplyInfoList.add(leaseApplyInfo); } - } else { - //其他部门人只能看到自己部门下的数据 - List auditListByLeaseInfo = collect.stream().filter(t -> t.getCreateBy().equals(deptId.toString())).collect(Collectors.toList()); - 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) { - // 统计预领数量 - count += leaseApplyDetail.getPreNum(); - } + if ((roles.contains("sgb") && leaseApplyInfo.getCompanyId() == 101) || (deptId1 == 210)) { + leaseApplyInfoList.add(leaseApplyInfo); + } + if (roles.contains("fgs") && (deptId == deptId1)) { + leaseApplyInfoList.add(leaseApplyInfo); + } + } + + if (leaseApplyInfoList != null && !leaseApplyInfoList.isEmpty()) { + // 对领料任务集合查询具体详情 + for (LeaseApplyInfo leaseApplyInfo : leaseApplyInfoList) { + 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.setRemark(collect.get(0).getRemark()); } + // 塞入领料任务详情的集合中 + leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails); + // 存入领料任务实体集合 + tmTask.setLeaseApplyInfoList(leaseApplyInfoList); + tmTask.setRemark(leaseApplyInfoList.get(0).getRemark()); } } } diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml index 30212702..66b39181 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml @@ -1152,4 +1152,7 @@ AND task_type = #{taskType} ORDER BY create_time DESC LIMIT 1 +