|
|
@ -437,101 +437,101 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat |
|
|
|
|
|
|
|
|
Page<EnforcementRegistrationListVo> page = pageQuery.build(); |
|
|
Page<EnforcementRegistrationListVo> page = pageQuery.build(); |
|
|
IPage<EnforcementRegistrationListVo> result = baseMapper.selectEnforcementRegistrationPage(page, bo); |
|
|
IPage<EnforcementRegistrationListVo> result = baseMapper.selectEnforcementRegistrationPage(page, bo); |
|
|
List<EnforcementRegistrationListVo> records = result.getRecords(); |
|
|
// List<EnforcementRegistrationListVo> records = result.getRecords();
|
|
|
|
|
|
//
|
|
|
// ===== 1. 批量查询执法人员信息 =====
|
|
|
// // ===== 1. 批量查询执法人员信息 =====
|
|
|
// 收集所有用户ID(执法人员1 + 执法人员2)
|
|
|
// // 收集所有用户ID(执法人员1 + 执法人员2)
|
|
|
Set<Long> allUserIds = new HashSet<>(); |
|
|
// Set<Long> allUserIds = new HashSet<>();
|
|
|
for (EnforcementRegistrationListVo vo : records) { |
|
|
// for (EnforcementRegistrationListVo vo : records) {
|
|
|
if (StringUtils.isNotBlank(vo.getLawEnforcerId())) { |
|
|
// if (StringUtils.isNotBlank(vo.getLawEnforcerId())) {
|
|
|
try { allUserIds.add(Convert.toLong(vo.getLawEnforcerId())); } catch (Exception ignored) {} |
|
|
// try { allUserIds.add(Convert.toLong(vo.getLawEnforcerId())); } catch (Exception ignored) {}
|
|
|
} |
|
|
// }
|
|
|
if (StringUtils.isNotBlank(vo.getLawEnforcerIdTwo())) { |
|
|
// if (StringUtils.isNotBlank(vo.getLawEnforcerIdTwo())) {
|
|
|
for (String idStr : vo.getLawEnforcerIdTwo().split(",")) { |
|
|
// for (String idStr : vo.getLawEnforcerIdTwo().split(",")) {
|
|
|
try { allUserIds.add(Convert.toLong(idStr.trim())); } catch (Exception ignored) {} |
|
|
// try { allUserIds.add(Convert.toLong(idStr.trim())); } catch (Exception ignored) {}
|
|
|
} |
|
|
// }
|
|
|
} |
|
|
// }
|
|
|
// 判断超时多少天
|
|
|
// // 判断超时多少天
|
|
|
Instant instant = vo.getEnforcementTime().toInstant(); |
|
|
// Instant instant = vo.getEnforcementTime().toInstant();
|
|
|
ZoneId zoneId = ZoneId.systemDefault(); |
|
|
// ZoneId zoneId = ZoneId.systemDefault();
|
|
|
LocalDate startDate = instant.atZone(zoneId).toLocalDate(); |
|
|
// LocalDate startDate = instant.atZone(zoneId).toLocalDate();
|
|
|
// 今天距离执法时间所差天数
|
|
|
// // 今天距离执法时间所差天数
|
|
|
long daysBetween = ChronoUnit.DAYS.between(startDate, LocalDate.now()); |
|
|
// long daysBetween = ChronoUnit.DAYS.between(startDate, LocalDate.now());
|
|
|
vo.setOutTimeDayNum(daysBetween); |
|
|
// vo.setOutTimeDayNum(daysBetween);
|
|
|
|
|
|
//
|
|
|
} |
|
|
// }
|
|
|
// 一次批量查询所有用户
|
|
|
// // 一次批量查询所有用户
|
|
|
Map<Long, SysUser> userMap = new HashMap<>(); |
|
|
// Map<Long, SysUser> userMap = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(allUserIds)) { |
|
|
// if (CollUtil.isNotEmpty(allUserIds)) {
|
|
|
List<SysUser> users = sysUserMapper.selectList( |
|
|
// List<SysUser> users = sysUserMapper.selectList(
|
|
|
new LambdaQueryWrapper<SysUser>() |
|
|
// new LambdaQueryWrapper<SysUser>()
|
|
|
.select(SysUser::getUserId, SysUser::getUserName, SysUser::getLawCertificateNum, SysUser::getPhonenumber) |
|
|
// .select(SysUser::getUserId, SysUser::getUserName, SysUser::getLawCertificateNum, SysUser::getPhonenumber)
|
|
|
.in(SysUser::getUserId, allUserIds) |
|
|
// .in(SysUser::getUserId, allUserIds)
|
|
|
); |
|
|
// );
|
|
|
userMap = users.stream().collect(Collectors.toMap(SysUser::getUserId, u -> u, (a, b) -> a)); |
|
|
// userMap = users.stream().collect(Collectors.toMap(SysUser::getUserId, u -> u, (a, b) -> a));
|
|
|
} |
|
|
// }
|
|
|
|
|
|
//
|
|
|
// ===== 2. 批量查询评价信息(仅当 hasEvaluate=1 时) =====
|
|
|
// // ===== 2. 批量查询评价信息(仅当 hasEvaluate=1 时) =====
|
|
|
Map<String, Date> evaluateTimeMap = new HashMap<>(); |
|
|
// Map<String, Date> evaluateTimeMap = new HashMap<>();
|
|
|
|
|
|
//
|
|
|
// 判断是否需要查询评价时间:只有当前端传入 hasEvaluate=1 时才查询
|
|
|
// // 判断是否需要查询评价时间:只有当前端传入 hasEvaluate=1 时才查询
|
|
|
if (bo.getHasEvaluate() != null && bo.getHasEvaluate() == 1) { |
|
|
// if (bo.getHasEvaluate() != null && bo.getHasEvaluate() == 1) {
|
|
|
// 收集所有已评价的记录ID
|
|
|
// // 收集所有已评价的记录ID
|
|
|
List<String> evaluatedIds = records.stream() |
|
|
// List<String> evaluatedIds = records.stream()
|
|
|
.map(EnforcementRegistrationListVo::getId) |
|
|
// .map(EnforcementRegistrationListVo::getId)
|
|
|
.collect(Collectors.toList()); |
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
//
|
|
|
// 批量查询评价记录,获取 enforcementId 和 create_time
|
|
|
// // 批量查询评价记录,获取 enforcementId 和 create_time
|
|
|
if (CollUtil.isNotEmpty(evaluatedIds)) { |
|
|
// if (CollUtil.isNotEmpty(evaluatedIds)) {
|
|
|
List<EnterpriseEvaluate> evaluates = evaluateMapper.selectList( |
|
|
// List<EnterpriseEvaluate> evaluates = evaluateMapper.selectList(
|
|
|
new LambdaQueryWrapper<EnterpriseEvaluate>() |
|
|
// new LambdaQueryWrapper<EnterpriseEvaluate>()
|
|
|
.select(EnterpriseEvaluate::getEnforcementId, EnterpriseEvaluate::getCreateTime) |
|
|
// .select(EnterpriseEvaluate::getEnforcementId, EnterpriseEvaluate::getCreateTime)
|
|
|
.in(EnterpriseEvaluate::getEnforcementId, evaluatedIds) |
|
|
// .in(EnterpriseEvaluate::getEnforcementId, evaluatedIds)
|
|
|
); |
|
|
// );
|
|
|
evaluateTimeMap = evaluates.stream() |
|
|
// evaluateTimeMap = evaluates.stream()
|
|
|
.collect(Collectors.toMap( |
|
|
// .collect(Collectors.toMap(
|
|
|
EnterpriseEvaluate::getEnforcementId, |
|
|
// EnterpriseEvaluate::getEnforcementId,
|
|
|
EnterpriseEvaluate::getCreateTime, |
|
|
// EnterpriseEvaluate::getCreateTime,
|
|
|
(a, b) -> a // 如果有重复,取第一个
|
|
|
// (a, b) -> a // 如果有重复,取第一个
|
|
|
)); |
|
|
// ));
|
|
|
} |
|
|
// }
|
|
|
} |
|
|
// }
|
|
|
|
|
|
//
|
|
|
// ===== 3. 循环组装显示字段(无嵌套查询) =====
|
|
|
// // ===== 3. 循环组装显示字段(无嵌套查询) =====
|
|
|
for (EnforcementRegistrationListVo vo : records) { |
|
|
// for (EnforcementRegistrationListVo vo : records) {
|
|
|
// 3.1 执法人员1格式化展示
|
|
|
// // 3.1 执法人员1格式化展示
|
|
|
if (StringUtils.isNotBlank(vo.getLawEnforcerId())) { |
|
|
// if (StringUtils.isNotBlank(vo.getLawEnforcerId())) {
|
|
|
try { |
|
|
// try {
|
|
|
SysUser user = userMap.get(Convert.toLong(vo.getLawEnforcerId())); |
|
|
// SysUser user = userMap.get(Convert.toLong(vo.getLawEnforcerId()));
|
|
|
if (user != null) { |
|
|
// if (user != null) {
|
|
|
vo.setLawEnforcer(formatEnforcerDisplay(user)); |
|
|
// vo.setLawEnforcer(formatEnforcerDisplay(user));
|
|
|
} |
|
|
// }
|
|
|
} catch (Exception ignored) {} |
|
|
// } catch (Exception ignored) {}
|
|
|
} |
|
|
// }
|
|
|
|
|
|
//
|
|
|
// 3.2 执法人员2列表格式化展示
|
|
|
// // 3.2 执法人员2列表格式化展示
|
|
|
if (StringUtils.isNotBlank(vo.getLawEnforcerIdTwo())) { |
|
|
// if (StringUtils.isNotBlank(vo.getLawEnforcerIdTwo())) {
|
|
|
List<String> lawTwoList = new ArrayList<>(); |
|
|
// List<String> lawTwoList = new ArrayList<>();
|
|
|
for (String idStr : vo.getLawEnforcerIdTwo().split(",")) { |
|
|
// for (String idStr : vo.getLawEnforcerIdTwo().split(",")) {
|
|
|
try { |
|
|
// try {
|
|
|
SysUser user = userMap.get(Convert.toLong(idStr.trim())); |
|
|
// SysUser user = userMap.get(Convert.toLong(idStr.trim()));
|
|
|
if (user != null) { |
|
|
// if (user != null) {
|
|
|
lawTwoList.add(formatEnforcerDisplay(user)); |
|
|
// lawTwoList.add(formatEnforcerDisplay(user));
|
|
|
} |
|
|
// }
|
|
|
} catch (Exception ignored) {} |
|
|
// } catch (Exception ignored) {}
|
|
|
} |
|
|
// }
|
|
|
vo.setLawEnforcer2List(lawTwoList); |
|
|
// vo.setLawEnforcer2List(lawTwoList);
|
|
|
} |
|
|
// }
|
|
|
|
|
|
//
|
|
|
// 3.3 设置评价时间(仅当 hasEvaluate=1 且评价时间存在时)
|
|
|
// // 3.3 设置评价时间(仅当 hasEvaluate=1 且评价时间存在时)
|
|
|
if (bo.getHasEvaluate() != null && bo.getHasEvaluate() == 1) { |
|
|
// if (bo.getHasEvaluate() != null && bo.getHasEvaluate() == 1) {
|
|
|
Date evaluateTime = evaluateTimeMap.get(vo.getId()); |
|
|
// Date evaluateTime = evaluateTimeMap.get(vo.getId());
|
|
|
if (evaluateTime != null) { |
|
|
// if (evaluateTime != null) {
|
|
|
vo.setEvaluateTime(evaluateTime); |
|
|
// vo.setEvaluateTime(evaluateTime);
|
|
|
} |
|
|
// }
|
|
|
} |
|
|
// }
|
|
|
} |
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TableDataInfo.build(result); |
|
|
return TableDataInfo.build(result); |
|
|
|