|
|
|
|
@ -18,6 +18,7 @@ import org.springblade.modules.business.service.*; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.ZoneId; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
@ -179,6 +180,9 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl<MaintenancePlanM |
|
|
|
|
// 按计划分组
|
|
|
|
|
Map<Long, List<MaintenancePlanDetail>> listMap = planDetails.stream().collect(Collectors.groupingBy(MaintenancePlanDetail::getPlanId)); |
|
|
|
|
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
|
|
|
|
String todayStr = format.format(new Date()); |
|
|
|
|
int count = 1; |
|
|
|
|
for (Map.Entry<Long, List<MaintenancePlanDetail>> longListEntry : listMap.entrySet()) { |
|
|
|
|
Long planId = longListEntry.getKey(); |
|
|
|
|
List<MaintenancePlanDetail> details = longListEntry.getValue(); |
|
|
|
|
@ -207,10 +211,13 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl<MaintenancePlanM |
|
|
|
|
} |
|
|
|
|
if (!newDetails.isEmpty()) { |
|
|
|
|
try { |
|
|
|
|
// 巡查单号
|
|
|
|
|
String code = "XC-" + todayStr + "-" + (count < 9 ? "0" + count : count + ""); |
|
|
|
|
// 保存巡查任务
|
|
|
|
|
saveTask(plans, planId, newDetails); |
|
|
|
|
saveTask(plans, planId, newDetails, code); |
|
|
|
|
// 修改计划详情
|
|
|
|
|
planDetailService.updateBatchById(newDetails); |
|
|
|
|
count++; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error(e.toString()); |
|
|
|
|
} |
|
|
|
|
@ -220,7 +227,7 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl<MaintenancePlanM |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void saveTask(List<MaintenancePlan> plans, Long planId, List<MaintenancePlanDetail> newDetails) { |
|
|
|
|
private void saveTask(List<MaintenancePlan> plans, Long planId, List<MaintenancePlanDetail> newDetails, String code) { |
|
|
|
|
// 获取计划详情
|
|
|
|
|
List<MaintenancePlan> planList = plans.stream().filter(plan -> plan.getId().equals(planId)).toList(); |
|
|
|
|
MaintenancePlan maintenancePlan = planList.get(0); |
|
|
|
|
@ -229,7 +236,7 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl<MaintenancePlanM |
|
|
|
|
// 巡检任务赋值保存
|
|
|
|
|
MaintenanceTask maintenanceTask = new MaintenanceTask(); |
|
|
|
|
maintenanceTask.setPlanId(maintenancePlan.getId()); |
|
|
|
|
maintenanceTask.setTaskCode(maintenancePlan.getPlanCode()); |
|
|
|
|
maintenanceTask.setTaskCode(code); |
|
|
|
|
maintenanceTask.setDeptId(maintenancePlan.getDeptId()); |
|
|
|
|
maintenanceTask.setTaskName(maintenancePlan.getPlanName()); |
|
|
|
|
maintenanceTask.setAddress(maintenancePlan.getAddress()); |
|
|
|
|
|