diff --git a/project/src/main/java/com/sdm/project/controller/SimulationLyricNodeController.java b/project/src/main/java/com/sdm/project/controller/SimulationLyricNodeController.java index 9ae73743..7c689b10 100644 --- a/project/src/main/java/com/sdm/project/controller/SimulationLyricNodeController.java +++ b/project/src/main/java/com/sdm/project/controller/SimulationLyricNodeController.java @@ -231,5 +231,11 @@ public class SimulationLyricNodeController { return lyricInternalService.manuallySupplementTodoReport(taskId); } + @GetMapping("/manuallySupplementTodoInfo") + @Operation(summary = "手动更新待办数据", description = "手动更新待办数据") + public SdmResponse manuallySupplementTodoInfo(@RequestParam(value = "startTime", required = false) String startTime, @RequestParam(value = "endTime", required = false) String endTime) { + return lyricInternalService.manuallySupplementTodoInfo(startTime, endTime); + } + } diff --git a/project/src/main/java/com/sdm/project/dao/SimulationDemandMapper.java b/project/src/main/java/com/sdm/project/dao/SimulationDemandMapper.java index 663a82a3..1e8e3ffb 100644 --- a/project/src/main/java/com/sdm/project/dao/SimulationDemandMapper.java +++ b/project/src/main/java/com/sdm/project/dao/SimulationDemandMapper.java @@ -49,4 +49,5 @@ public interface SimulationDemandMapper extends BaseMapper { List getDemandListByProjectId(@Param("nodeId") String nodeId); + List getListByTime(@Param("startTime") String startTime, @Param("endTime") String endTime,@Param("tenantId") Long tenantId); } diff --git a/project/src/main/java/com/sdm/project/service/ILyricInternalService.java b/project/src/main/java/com/sdm/project/service/ILyricInternalService.java index 88fbbea0..f681362e 100644 --- a/project/src/main/java/com/sdm/project/service/ILyricInternalService.java +++ b/project/src/main/java/com/sdm/project/service/ILyricInternalService.java @@ -65,4 +65,5 @@ public interface ILyricInternalService { SdmResponse manuallySupplementTodoReport(String taskId); + SdmResponse manuallySupplementTodoInfo(String startTime, String endTime); } diff --git a/project/src/main/java/com/sdm/project/service/impl/LyricInternalServiceImpl.java b/project/src/main/java/com/sdm/project/service/impl/LyricInternalServiceImpl.java index 6c524fc3..dad9a582 100644 --- a/project/src/main/java/com/sdm/project/service/impl/LyricInternalServiceImpl.java +++ b/project/src/main/java/com/sdm/project/service/impl/LyricInternalServiceImpl.java @@ -4405,6 +4405,80 @@ public class LyricInternalServiceImpl implements ILyricInternalService { return SdmResponse.success(); } + @Override + public SdmResponse manuallySupplementTodoInfo(String startTime, String endTime) { + Long tenantId = ThreadLocalContext.getTenantId(); + // 缓存校验 + SdmResponse cacheCheckResponse = checkSyncCache(); + if (cacheCheckResponse != null) { + return cacheCheckResponse; + } + if (StringUtils.isBlank(startTime) || StringUtils.isBlank(endTime)) { + String[] timeArray = calculateTimeRange(lyricTodoInterval); + startTime = timeArray[0]; + endTime = timeArray[1]; + } + // 查询原始待办数据 + List todoInfoList = lyricVTodoInfoService.lambdaQuery() + .eq(LyricVTodoEmulationInfoDM::getRelevanceTask, DemandTypeEnum.FINITE_ELEMENT_SIMULATION.getName()) + .ge(LyricVTodoEmulationInfoDM::getCreateTime, startTime) + .le(LyricVTodoEmulationInfoDM::getCreateTime, endTime) + .list(); + if (CollectionUtils.isEmpty(todoInfoList)) { + log.info("手动未查询到{}到{}的待同步的待办数据", startTime, endTime); + return SdmResponse.success(); + } + + // 根据todoId去重,保留首次出现的待办 + todoInfoList = todoInfoList.stream() + // 过滤掉todoId为null的数据 + .filter(dm -> dm.getSubject() != null) + .collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(LyricVTodoEmulationInfoDM::getSubject))), + ArrayList::new + )); + + Map todoMap = todoInfoList.stream().collect(Collectors.toMap(LyricVTodoEmulationInfoDM::getTodoId, Function.identity())); + + List demandVoList = demandMapper.getListByTime(startTime,endTime,tenantId); + if (CollectionUtils.isEmpty(demandVoList)) { + return SdmResponse.success(); + } + List needToUpdateDemandList = new ArrayList<>(); + for (SpdmDemandVo spdmDemandVo : demandVoList) { + String demandCode = spdmDemandVo.getDemandCode(); + if (!isConvertibleToLong(demandCode)) { + continue; + } + LyricVTodoEmulationInfoDM lyricVTodoEmulationInfoDM = todoMap.get(Long.valueOf(demandCode)); + if (ObjectUtils.isEmpty(lyricVTodoEmulationInfoDM)) { + continue; + } + // 对比是否待办信息有变化 + SimulationDemand simulationDemand = compareDemandInfo(spdmDemandVo,lyricVTodoEmulationInfoDM); + if (ObjectUtils.isNotEmpty(simulationDemand)) { + needToUpdateDemandList.add(simulationDemand); + } + } + if (CollectionUtils.isEmpty(needToUpdateDemandList)) { + log.info("needToUpdateDemandList为空"); + return SdmResponse.success(); + } + // 更新待办信息 + demandMapper.updateById(needToUpdateDemandList); + return SdmResponse.success(); + } + + private SimulationDemand compareDemandInfo(SpdmDemandVo spdmDemandVo, LyricVTodoEmulationInfoDM lyricVTodoEmulationInfoDM) { + if (StringUtils.isNotBlank(spdmDemandVo.getDescription()) && !spdmDemandVo.getDescription().equals(lyricVTodoEmulationInfoDM.getDescribes())) { + SimulationDemand simulationDemand = new SimulationDemand(); + BeanUtils.copyProperties(spdmDemandVo,simulationDemand); + return simulationDemand; + } + return null; + } + + /** * 项目的当前阶段包含:设计,就是:项目承接主体+结构,否则就是:项目承接主体+技术中心+结构,所对应的人 * diff --git a/project/src/main/resources/mapper/SimulationDemandMapper.xml b/project/src/main/resources/mapper/SimulationDemandMapper.xml index 44b75efb..6bf5c188 100644 --- a/project/src/main/resources/mapper/SimulationDemandMapper.xml +++ b/project/src/main/resources/mapper/SimulationDemandMapper.xml @@ -231,4 +231,18 @@ select * from simulation_demand where project_id = #{nodeId} + + \ No newline at end of file