|
|
@@ -1364,4 +1364,123 @@ public class EquipPipeSchedulingServiceImpl extends ServiceImpl<EquipPipeSchedul
|
|
|
return taskDetailsVO;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<PipeShiftScheduleExportRespVO> convert(List<PipeShiftScheduleRespVO> list) {
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return List.of();
|
|
|
+ }
|
|
|
+ return list.stream().map(source -> {
|
|
|
+ PipeShiftScheduleExportRespVO target = new PipeShiftScheduleExportRespVO();
|
|
|
+
|
|
|
+ // 日期
|
|
|
+ target.setDate(source.getDate());
|
|
|
+
|
|
|
+ // 星期
|
|
|
+ target.setWeek(calculateWeek(source.getDate()));
|
|
|
+
|
|
|
+ // 检验员(将检验员ID列表转换为字符串)
|
|
|
+ if (source.getCheckers() != null && !source.getCheckers().isEmpty()) {
|
|
|
+ List<AdminUserRespDTO> checkedData = adminUserApi.getUserList(source.getCheckers()).getCheckedData();
|
|
|
+ target.setCheckers(String.join(",", checkedData.stream().map(AdminUserRespDTO::getNickname).toList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取第一个任务项
|
|
|
+ PipeShiftScheduleRespVO.PipeShiftScheduleItemRespVO taskItem =
|
|
|
+ source.getTaskItems() != null && !source.getTaskItems().isEmpty()
|
|
|
+ ? source.getTaskItems().get(0)
|
|
|
+ : null;
|
|
|
+
|
|
|
+ if (taskItem != null) {
|
|
|
+ // 检验类型
|
|
|
+ target.setCheckType("100".equals(taskItem.getCheckType()) ? "定期检验" : "年度检查");
|
|
|
+
|
|
|
+ // 使用单位
|
|
|
+ target.setUnitName(taskItem.getUnitName());
|
|
|
+
|
|
|
+ // 管道使用地址
|
|
|
+ target.setPipeAddress(taskItem.getPipeAddress());
|
|
|
+
|
|
|
+ // 联系人(去重后用/拼接)
|
|
|
+ List<String> contacts = source.getTaskItems().stream()
|
|
|
+ .map(PipeShiftScheduleRespVO.PipeShiftScheduleItemRespVO::getContact)
|
|
|
+ .filter(contact -> contact != null && !contact.isEmpty())
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ target.setContact(String.join("/", contacts));
|
|
|
+
|
|
|
+ // 电话(去重后用/拼接)
|
|
|
+ List<String> contactPhones = source.getTaskItems().stream()
|
|
|
+ .map(PipeShiftScheduleRespVO.PipeShiftScheduleItemRespVO::getContactPhone)
|
|
|
+ .filter(phone -> phone != null && !phone.isEmpty())
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ target.setContactPhone(String.join("/", contactPhones));
|
|
|
+
|
|
|
+ // 管线长度(累加)
|
|
|
+ double totalLength = source.getTaskItems().stream()
|
|
|
+ .mapToDouble(item -> {
|
|
|
+ try {
|
|
|
+ return item.getPipeLengthTotal() != null
|
|
|
+ ? Double.parseDouble(item.getPipeLengthTotal())
|
|
|
+ : 0;
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .sum();
|
|
|
+ target.setPipeLengthTotal(totalLength);
|
|
|
+
|
|
|
+ // 上次报告编号(根据检验类型选择)
|
|
|
+ if ("100".equals(taskItem.getCheckType())) {
|
|
|
+ target.setLastReportNo(taskItem.getLastLegalPeriodicalInspectionReportNo());
|
|
|
+ } else {
|
|
|
+ target.setLastReportNo(taskItem.getLastYearReportNo());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 监督报告编号
|
|
|
+ target.setLastMaintenanceReportNo(taskItem.getLastMaintenanceReportNo());
|
|
|
+
|
|
|
+ // 区域街道
|
|
|
+ String district = taskItem.getEquipDistrictName() != null ? taskItem.getEquipDistrictName() : "";
|
|
|
+ String street = taskItem.getEquipStreetName() != null ? taskItem.getEquipStreetName() : "";
|
|
|
+ target.setStreet(district + street);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 管道介质(去重后用、拼接)
|
|
|
+ if (source.getPipeMedium() != null && !source.getPipeMedium().isEmpty()) {
|
|
|
+ List<String> distinctMediums = source.getPipeMedium().stream()
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ target.setMedium(String.join("、", distinctMediums));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 状态
|
|
|
+ target.setStatus(getStatusText(source.getStatus()));
|
|
|
+
|
|
|
+ return target;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String calculateWeek(LocalDate date) {
|
|
|
+ if (date == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ String[] weekDays = {"日", "一", "二", "三", "四", "五", "六"};
|
|
|
+ int week = date.getDayOfWeek().getValue() % 7;
|
|
|
+ return weekDays[week];
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String getStatusText(Integer status) {
|
|
|
+ if (status == null) {
|
|
|
+ return "未知";
|
|
|
+ }
|
|
|
+ return switch (status) {
|
|
|
+ case 100 -> "已排期";
|
|
|
+ case 200 -> "待约检";
|
|
|
+ case 300 -> "已受理";
|
|
|
+ case 400 -> "检测中";
|
|
|
+ default -> "未知";
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
}
|