parent
8adbe9febc
commit
8991bad2e4
|
|
@ -771,140 +771,157 @@ public class TmTaskServiceImpl implements TmTaskService {
|
|||
List<TmTask> tmTaskList = tmTaskMapper.getAuditManageListByLeaseTmTask(record);
|
||||
|
||||
for (TmTask tmTask : tmTaskList) {
|
||||
if (tmTask == null) {
|
||||
continue;
|
||||
}
|
||||
List<LeaseApplyInfo> 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理角色和部门逻辑
|
||||
* @param tmTask
|
||||
* @param collect
|
||||
* @param roles
|
||||
* @param deptId
|
||||
* @param deptId1
|
||||
*/
|
||||
private void handleTaskByRoleAndDept(TmTask tmTask, List<LeaseApplyInfo> collect, Set<String> roles, Long deptId, int deptId1) {
|
||||
List<LeaseApplyInfo> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理部门101
|
||||
* @param collect
|
||||
* @param deptId1
|
||||
* @return
|
||||
*/
|
||||
private List<LeaseApplyInfo> handleDept101(List<LeaseApplyInfo> collect, int deptId1) {
|
||||
List<LeaseApplyInfo> auditListByLeaseInfo = collect.stream()
|
||||
.filter(t -> t.getCompanyId() != null)
|
||||
.filter(t -> t.getCompanyId() == 101)
|
||||
.collect(Collectors.toList());
|
||||
if (deptId1 == 101) {
|
||||
List<LeaseApplyInfo> applyInfoList = collect.stream()
|
||||
.filter(t -> t.getCompanyId() != null)
|
||||
.filter(t -> t.getCompanyId() == 102)
|
||||
.collect(Collectors.toList());
|
||||
auditListByLeaseInfo.addAll(applyInfoList);
|
||||
}
|
||||
return auditListByLeaseInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理部门102
|
||||
* @param collect
|
||||
* @param deptId1
|
||||
* @return
|
||||
*/
|
||||
private List<LeaseApplyInfo> handleDept102(List<LeaseApplyInfo> collect, int deptId1) {
|
||||
List<LeaseApplyInfo> auditListByLeaseInfo = collect.stream()
|
||||
.filter(t -> t.getCompanyId() != null)
|
||||
.filter(t -> t.getCompanyId() == 102)
|
||||
.collect(Collectors.toList());
|
||||
if (deptId1 == 102) {
|
||||
List<LeaseApplyInfo> 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<LeaseApplyInfo> handleRoleSgb(List<LeaseApplyInfo> collect, int deptId1) {
|
||||
List<LeaseApplyInfo> auditListByLeaseInfo = collect.stream()
|
||||
.filter(t -> t.getCompanyId() != null)
|
||||
.filter(t -> t.getCompanyId() == 101)
|
||||
.collect(Collectors.toList());
|
||||
if (deptId1 == 210) {
|
||||
List<LeaseApplyInfo> 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<LeaseApplyInfo> filteredList, List<LeaseApplyInfo> collect, int deptId1) {
|
||||
if (filteredList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int count = 0;
|
||||
for (LeaseApplyInfo leaseApplyInfo : filteredList) {
|
||||
if (leaseApplyInfo == null) {
|
||||
continue;
|
||||
}
|
||||
if (tmTask != null) {
|
||||
// 去查询任务分单表
|
||||
List<LeaseApplyInfo> 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> leaseApplyDetails = tmTaskMapper.getLeaseApplyManageDetails(leaseApplyInfo);
|
||||
if (leaseApplyDetails.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (leaseApplyDetails.size() > 0) {
|
||||
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
|
||||
if (leaseApplyDetail != null && leaseApplyDetail.getPreNum() != null) {
|
||||
// 统计预领数量
|
||||
count += leaseApplyDetail.getPreNum();
|
||||
}
|
||||
}
|
||||
// 塞入领料任务详情的集合中
|
||||
leaseApplyInfo.setLeaseApplyDetails(leaseApplyDetails);
|
||||
}
|
||||
tmTask.setLeaseApplyInfoList(filteredList);
|
||||
// 存入领料任务实体集合
|
||||
tmTask.setLeaseApplyInfoList(collect);
|
||||
tmTask.setDeptId(Long.parseLong(String.valueOf(deptId1)));
|
||||
tmTask.setRemark(collect.get(0).getRemark());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (deptId == 101) { //机具经理、书记、副经理查看数据
|
||||
List<LeaseApplyInfo> auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 101).collect(Collectors.toList());
|
||||
if (deptId1 == 101) {
|
||||
List<LeaseApplyInfo> applyInfoList = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 102).collect(Collectors.toList());
|
||||
auditListByLeaseInfo.addAll(applyInfoList);
|
||||
}
|
||||
|
||||
if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) {
|
||||
// 对领料任务集合查询具体详情
|
||||
for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) {
|
||||
if (leaseApplyInfo != null) {
|
||||
// 去查询领料任务详情表
|
||||
List<LeaseApplyDetails> 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<LeaseApplyInfo> auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 102).collect(Collectors.toList());
|
||||
if (deptId1 == 102) {
|
||||
List<LeaseApplyInfo> list2 = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 101).collect(Collectors.toList());
|
||||
auditListByLeaseInfo.addAll(list2);
|
||||
}
|
||||
|
||||
if (auditListByLeaseInfo != null && !auditListByLeaseInfo.isEmpty()) {
|
||||
// 对领料任务集合查询具体详情
|
||||
for (LeaseApplyInfo leaseApplyInfo : auditListByLeaseInfo) {
|
||||
if (leaseApplyInfo != null) {
|
||||
// 去查询领料任务详情表
|
||||
List<LeaseApplyDetails> 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> 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<LeaseApplyInfo> auditListByLeaseInfo = collect.stream().filter(t -> t.getCompanyId() != null).filter(t -> t.getCompanyId() == 101).collect(Collectors.toList());
|
||||
if (deptId1 == 210) {
|
||||
List<LeaseApplyInfo> 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> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
tmTask.setPreCountNum(count);
|
||||
}
|
||||
List<TmTask> tmTasks = tmTaskList.stream().filter(t -> t.getLeaseApplyInfoList() != null).collect(Collectors.toList());
|
||||
return tmTasks;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取审核列表 - App端
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue