1、根据军令状时间判断任务逾期相关的逻辑进行调整
This commit is contained in:
@@ -10,7 +10,8 @@ public enum MessageTemplateEnum {
|
|||||||
DATA_ALERT_MANAGER("数据通知", "%s的数据存储空间已达阈值"),
|
DATA_ALERT_MANAGER("数据通知", "%s的数据存储空间已达阈值"),
|
||||||
APPROVE_ALERT("审批通知", "收到一条%s消息"),
|
APPROVE_ALERT("审批通知", "收到一条%s消息"),
|
||||||
HPC_START("作业通知", "HPC任务作业:%s,已发起%s"),
|
HPC_START("作业通知", "HPC任务作业:%s,已发起%s"),
|
||||||
HPC_END("作业通知", "HPC任务作业:%s,已结束,执行结果:%s")
|
HPC_END("作业通知", "HPC任务作业:%s,已结束,执行结果:%s"),
|
||||||
|
TASK_OVERDUE("任务逾期通知", "任务:%s,已逾期")
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String title;
|
private final String title;
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.sdm.common.service;
|
||||||
|
|
||||||
|
import com.sdm.common.common.SdmResponse;
|
||||||
|
import com.sdm.common.entity.bo.DataDictionary;
|
||||||
|
import com.sdm.common.entity.constants.TagConstant;
|
||||||
|
import com.sdm.common.feign.impl.system.SysConfigFeignClientImpl;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static java.util.Collections.emptyMap;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class TaskProgressService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysConfigFeignClientImpl sysConfigFeignClient;
|
||||||
|
|
||||||
|
private static final String TASK_PROGRESS_STATUS = "TASK_PROGRESS_STATUS";
|
||||||
|
|
||||||
|
public Map<String, String> getMapName() {
|
||||||
|
SdmResponse<List<DataDictionary>> taskProgressStatusList = sysConfigFeignClient.getDictionaryData(TASK_PROGRESS_STATUS);
|
||||||
|
if (!taskProgressStatusList.isSuccess() || ObjectUtils.isEmpty(taskProgressStatusList.getData())) {
|
||||||
|
log.error("字典信息查询失败");
|
||||||
|
return emptyMap();
|
||||||
|
}
|
||||||
|
return taskProgressStatusList.getData().stream().collect(Collectors.toMap(DataDictionary::getDictName, DataDictionary::getDictValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
//package com.sdm.project.schedule.lyric;
|
|
||||||
//
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
|
||||||
//@Component
|
|
||||||
//@Slf4j
|
|
||||||
//public class CommitmentDeadlineStatusSchedule {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private CommitmentDeadlineStatusScheduleExecutor commitmentDeadlineStatusScheduleExecutor;
|
|
||||||
//
|
|
||||||
// // fixedDelayString 读取配置,值为【毫秒】,所以拼接000
|
|
||||||
// @Scheduled(fixedDelayString = "${commitmentDeadlineStatusTask.schedule.interval:1800}000")
|
|
||||||
// public void doCommitmentDeadlineStatusTask() {
|
|
||||||
// try {
|
|
||||||
// commitmentDeadlineStatusScheduleExecutor.run();
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// log.error("【承诺截止状态更新任务】执行异常,原因:{}", e.getMessage(), e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,166 +1,330 @@
|
|||||||
//package com.sdm.project.schedule.lyric;
|
package com.sdm.project.schedule.lyric;
|
||||||
//
|
|
||||||
//import com.sdm.common.entity.enums.NodeTypeEnum;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
//import com.sdm.project.common.TaskExeStatusEnum;
|
import com.sdm.common.common.ThreadLocalContext;
|
||||||
//import com.sdm.project.model.entity.SimulationNode;
|
import com.sdm.common.entity.enums.MessageTemplateEnum;
|
||||||
//import com.sdm.project.model.entity.SimulationTask;
|
import com.sdm.common.entity.enums.NodeTypeEnum;
|
||||||
//import com.sdm.project.service.INodeService;
|
import com.sdm.common.entity.req.system.SendMsgReq;
|
||||||
//import com.sdm.project.service.ISimulationTaskService;
|
import com.sdm.common.entity.resp.system.CIDStaffResp;
|
||||||
//import com.xxl.job.core.handler.annotation.XxlJob;
|
import com.sdm.common.feign.impl.system.MessageFeignClientImpl;
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
import com.sdm.common.service.TagMapService;
|
||||||
//import org.apache.commons.collections4.CollectionUtils;
|
import com.sdm.common.service.TaskProgressService;
|
||||||
//import org.apache.commons.lang3.StringUtils;
|
import com.sdm.outbridge.entity.LyricVProjectToDM;
|
||||||
//import org.springframework.beans.factory.annotation.Value;
|
import com.sdm.project.common.MemberTypeEnum;
|
||||||
//import org.springframework.stereotype.Component;
|
import com.sdm.project.common.TaskExeStatusEnum;
|
||||||
//import org.springframework.stereotype.Service;
|
import com.sdm.project.dao.SimulationNodeMapper;
|
||||||
//
|
import com.sdm.project.model.bo.TaskNodeTag;
|
||||||
//import javax.annotation.Resource;
|
import com.sdm.project.model.entity.SimulationNode;
|
||||||
//import java.time.LocalDateTime;
|
import com.sdm.project.model.entity.SimulationTask;
|
||||||
//import java.time.format.DateTimeFormatter;
|
import com.sdm.project.model.entity.SimulationTaskExtra;
|
||||||
//import java.time.temporal.ChronoUnit;
|
import com.sdm.project.model.entity.SimulationTaskMember;
|
||||||
//import java.util.*;
|
import com.sdm.project.model.vo.SpdmNodeExtraVo;
|
||||||
//import java.util.stream.Collectors;
|
import com.sdm.project.service.INodeService;
|
||||||
//
|
import com.sdm.project.service.ISimulationTaskExtraService;
|
||||||
//import static com.sdm.project.service.impl.NodeServiceImpl.SYNC_PROJECT_SOURCE;
|
import com.sdm.project.service.ISimulationTaskMemberService;
|
||||||
//
|
import com.sdm.project.service.ISimulationTaskService;
|
||||||
//@Slf4j
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
//@Component
|
import lombok.extern.slf4j.Slf4j;
|
||||||
//public class CommitmentDeadlineStatusScheduleExecutor{
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
//
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
// // 时间格式化器:全局常量,线程安全,可复用(yyyy-MM-dd HH:mm:ss 固定格式)
|
import org.apache.commons.lang3.StringUtils;
|
||||||
// private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
//
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
// @Value("${commitmentDeadlineStatusTask.schedule.calculationInterval:5}")
|
import org.springframework.stereotype.Component;
|
||||||
// private int calculationInterval;
|
import org.springframework.stereotype.Service;
|
||||||
//
|
|
||||||
// @Resource
|
import javax.annotation.Resource;
|
||||||
// private INodeService nodeService;
|
import java.time.LocalDateTime;
|
||||||
//
|
import java.time.format.DateTimeFormatter;
|
||||||
// @Resource
|
import java.time.temporal.ChronoUnit;
|
||||||
// private ISimulationTaskService taskService;
|
import java.util.*;
|
||||||
//
|
import java.util.stream.Collectors;
|
||||||
// @XxlJob("commitmentDeadlineStatusHandler")
|
|
||||||
// public void commitmentDeadlineStatusHandler() {
|
import static com.sdm.project.model.entity.SimulationTaskExtra.PROPERTY_NAME_ACTUAL_PROGRESS;
|
||||||
// log.info("定时任务执行");
|
import static com.sdm.project.service.impl.NodeServiceImpl.SYNC_PROJECT_SOURCE;
|
||||||
// try {
|
|
||||||
// // 1. 获取所有节点(工位)
|
@Slf4j
|
||||||
// List<SimulationNode> nodeList = nodeService.lambdaQuery().eq(SimulationNode::getNodeType, NodeTypeEnum.WORKSPACE)
|
@Component
|
||||||
// .eq(SimulationNode::getProjectSource, SYNC_PROJECT_SOURCE).isNotNull(SimulationNode::getCommitmentDeadline)
|
public class CommitmentDeadlineStatusScheduleExecutor{
|
||||||
// .list();
|
|
||||||
// Map<String, String> nodeMap = new HashMap<>();
|
// 时间格式化器:全局常量,线程安全,可复用(yyyy-MM-dd HH:mm:ss 固定格式)
|
||||||
// if (CollectionUtils.isNotEmpty(nodeList)) {
|
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
@Value("${commitmentDeadlineStatusTask.schedule.calculationInterval:5}")
|
||||||
|
private int calculationInterval;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private INodeService nodeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SimulationNodeMapper nodeMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ISimulationTaskService taskService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ISimulationTaskMemberService taskMemberService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ISimulationTaskExtraService taskExtraService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TaskProgressService taskProgressService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageFeignClientImpl messageFeignClient;
|
||||||
|
|
||||||
|
public static final String LIST_RELEASE_TIME = "listReleaseTime";
|
||||||
|
|
||||||
|
public static final String THREE_D_DESIGN = "3D设计";
|
||||||
|
|
||||||
|
@XxlJob("commitmentDeadlineStatusHandler")
|
||||||
|
public void commitmentDeadlineStatusHandler() {
|
||||||
|
log.info("项目是否延期的定时任务执行中");
|
||||||
|
try {
|
||||||
|
// 1. 获取所有节点(工位)
|
||||||
|
List<SimulationNode> nodeList = nodeService.lambdaQuery().eq(SimulationNode::getNodeType, NodeTypeEnum.WORKSPACE)
|
||||||
|
.eq(SimulationNode::getProjectSource, SYNC_PROJECT_SOURCE).isNotNull(SimulationNode::getCommitmentDeadline)
|
||||||
|
.list();
|
||||||
|
Map<String, String> nodeMap = new HashMap<>();
|
||||||
|
if (CollectionUtils.isNotEmpty(nodeList)) {
|
||||||
// nodeMap = nodeList.stream().filter(node -> StringUtils.isNotBlank(node.getCommitmentDeadline()))
|
// nodeMap = nodeList.stream().filter(node -> StringUtils.isNotBlank(node.getCommitmentDeadline()))
|
||||||
// .collect(Collectors.toMap(SimulationNode::getUuid,SimulationNode::getCommitmentDeadline));
|
// .collect(Collectors.toMap(SimulationNode::getUuid,SimulationNode::getCommitmentDeadline));
|
||||||
// }
|
List<String> nodeIdList = nodeList.stream().map(SimulationNode::getUuid).toList();
|
||||||
// // 2. 获取所有任务
|
List<SpdmNodeExtraVo> nodeExtraList = nodeMapper.getNodeExtraListByNodeIdList(nodeIdList);
|
||||||
// List<SimulationTask> taskList = taskService.lambdaQuery()
|
if (CollectionUtils.isEmpty(nodeExtraList)) {
|
||||||
// .in(SimulationTask::getExeStatus, Arrays.asList(TaskExeStatusEnum.NO_CONFIRM.getCode()
|
log.info("项目是否延期的定时任务中未查询到工位的拓展属性");
|
||||||
// , TaskExeStatusEnum.NO_STARTED.getCode(), TaskExeStatusEnum.IN_PROGRESS.getCode()))
|
return;
|
||||||
// .list();
|
}
|
||||||
// // 3. 计算间隔时间(单位:天)
|
List<SpdmNodeExtraVo> listReleaseTimeExtraList = nodeExtraList.stream().filter(nodeExtra -> LIST_RELEASE_TIME.equals(nodeExtra.getPropertyName())).toList();
|
||||||
//// if (CollectionUtils.isNotEmpty(nodeList)) {
|
if (CollectionUtils.isEmpty(listReleaseTimeExtraList)) {
|
||||||
//// List<SimulationNode> updateNodeList = handleNodeCommitmentDeadlineStatus(nodeList);
|
log.info("项目是否延期的定时任务中未查询到工位的军令状时间");
|
||||||
//// if (CollectionUtils.isNotEmpty(updateNodeList)) {
|
return;
|
||||||
//// log.info("共有:{}个节点已延期", updateNodeList.size());
|
}
|
||||||
//// nodeService.updateBatchById(updateNodeList);
|
nodeMap = listReleaseTimeExtraList.stream()
|
||||||
//// } else {
|
.collect(Collectors.toMap(
|
||||||
//// log.info("无节点延期");
|
SpdmNodeExtraVo::getNodeId,
|
||||||
//// }
|
SpdmNodeExtraVo::getPropertyValue,
|
||||||
//// } else {
|
(existing, replacement) -> existing
|
||||||
//// log.info("无节点延期");
|
));
|
||||||
//// }
|
for (SimulationNode simulationNode : nodeList) {
|
||||||
//
|
simulationNode.setCommitmentDeadline(nodeMap.get(simulationNode.getUuid()));
|
||||||
// if (CollectionUtils.isNotEmpty(taskList)) {
|
}
|
||||||
// for (SimulationTask simulationTask : taskList) {
|
}
|
||||||
// // 取工位的军令状时间
|
// 2. 获取所有任务
|
||||||
// String workspaceNodeId = simulationTask.getTag5();
|
List<SimulationTask> taskList = taskService.lambdaQuery()
|
||||||
// if (StringUtils.isBlank(workspaceNodeId)) {
|
.in(SimulationTask::getExeStatus, Arrays.asList(TaskExeStatusEnum.NO_CONFIRM.getCode()
|
||||||
// continue;
|
, TaskExeStatusEnum.NO_STARTED.getCode(), TaskExeStatusEnum.IN_PROGRESS.getCode()))
|
||||||
// }
|
.list();
|
||||||
// simulationTask.setCommitmentDeadline(nodeMap.get(workspaceNodeId));
|
// 3. 计算间隔时间(单位:天)
|
||||||
// }
|
if (CollectionUtils.isNotEmpty(nodeList)) {
|
||||||
// taskList = taskList.stream().filter(task -> StringUtils.isNotBlank(task.getCommitmentDeadline())).toList();
|
List<SimulationNode> updateNodeList = handleNodeCommitmentDeadlineStatus(nodeList);
|
||||||
// List<SimulationTask> updateTaskList = new ArrayList<>();
|
if (CollectionUtils.isNotEmpty(updateNodeList)) {
|
||||||
// if (CollectionUtils.isNotEmpty(taskList)) {
|
log.info("共有:{}个节点已延期", updateNodeList.size());
|
||||||
// updateTaskList = handleTaskCommitmentDeadlineStatus(taskList);
|
nodeService.updateBatchById(updateNodeList);
|
||||||
// }
|
} else {
|
||||||
// if (CollectionUtils.isNotEmpty(updateTaskList)) {
|
log.info("无节点延期");
|
||||||
// log.info("共有:{}个任务已延期,延期的任务id为:{}", updateTaskList.size(),updateTaskList.stream().map(SimulationTask::getId).toList());
|
}
|
||||||
// taskService.updateBatchById(updateTaskList);
|
} else {
|
||||||
// } else {
|
log.info("无节点延期");
|
||||||
// log.info("无任务延期");
|
}
|
||||||
// }
|
|
||||||
// } else {
|
// 查询任务进度状态的字典
|
||||||
// log.info("无任务延期");
|
Map<String, String> taskProgressMap = taskProgressService.getMapName();
|
||||||
// }
|
// 若实际达成进度超过 3D设计,则不发消息给提出人
|
||||||
// } catch (Exception ex) {
|
int taskProgressValue = 0;
|
||||||
// log.error("定时任务执行异常", ex);
|
if (isConvertibleToInt(taskProgressMap.get(THREE_D_DESIGN))) {
|
||||||
// }
|
taskProgressValue = Integer.parseInt(taskProgressMap.get(THREE_D_DESIGN));
|
||||||
//
|
}else {
|
||||||
// }
|
log.error("未查询到3D设计的字典值,或字典值不为数字。{}",taskProgressMap.get(THREE_D_DESIGN));
|
||||||
//
|
taskProgressValue = -1;
|
||||||
// /**
|
}
|
||||||
// * 核心方法:根据截止时间和间隔天数,判断并更新SimulationNode的exeStatus
|
log.info("taskProgressValue为:{}",taskProgressValue);
|
||||||
// *
|
|
||||||
// * @param node 待处理的实体对象
|
if (CollectionUtils.isNotEmpty(taskList)) {
|
||||||
// * @param calculationInterval 间隔天数(int,单位:天)
|
|
||||||
// */
|
|
||||||
// public static void updateNodeStatus(SimulationNode node, int calculationInterval) {
|
for (SimulationTask simulationTask : taskList) {
|
||||||
// // 1. 判空
|
// 取工位的军令状时间
|
||||||
// if (node.getCommitmentDeadline().trim().isEmpty()) {
|
String workspaceNodeId = simulationTask.getTag5();
|
||||||
// return;
|
if (StringUtils.isBlank(workspaceNodeId)) {
|
||||||
// }
|
continue;
|
||||||
// // 2. 字符串转日期对象
|
}
|
||||||
// LocalDateTime deadlineTime = LocalDateTime.parse(node.getCommitmentDeadline().trim(), DATE_TIME_FORMATTER);
|
simulationTask.setCommitmentDeadline(nodeMap.get(workspaceNodeId));
|
||||||
// LocalDateTime currentTime = LocalDateTime.now();
|
}
|
||||||
// // 3. 先计算两个时间的毫秒差值
|
taskList = taskList.stream().filter(task -> StringUtils.isNotBlank(task.getCommitmentDeadline())).toList();
|
||||||
// long diffMillis = ChronoUnit.MILLIS.between(currentTime, deadlineTime);
|
List<SimulationTask> updateTaskList = new ArrayList<>();
|
||||||
// // 1天 = 24*60*60*1000 毫秒 = 86400000L 毫秒,换算成带小数的天数
|
if (CollectionUtils.isNotEmpty(taskList)) {
|
||||||
// double daysBetween = diffMillis / 86400000.0D;
|
updateTaskList = handleTaskCommitmentDeadlineStatus(taskList);
|
||||||
// // 4. 业务判断:精准天数 > 配置间隔天数 → 更新状态为:已延期
|
}
|
||||||
// if (daysBetween < calculationInterval) {
|
if (CollectionUtils.isNotEmpty(updateTaskList)) {
|
||||||
// node.setExeStatus(TaskExeStatusEnum.POSTPONED.getCode());
|
log.info("共有:{}个任务已延期,延期的任务id为:{}", updateTaskList.size(),updateTaskList.stream().map(SimulationTask::getId).toList());
|
||||||
// }
|
taskService.updateBatchById(updateTaskList);
|
||||||
// }
|
// 查询任务的执行人
|
||||||
//
|
List<SimulationTaskMember> executorUserList = taskMemberService.lambdaQuery().in(SimulationTaskMember::getTaskId, updateTaskList.stream().map(SimulationTask::getUuid).toList())
|
||||||
// private List<SimulationNode> handleNodeCommitmentDeadlineStatus(List<SimulationNode> nodeList) {
|
.eq(SimulationTaskMember::getType, MemberTypeEnum.EXECUTOR).list();
|
||||||
// List<SimulationNode> updateNodeList = new ArrayList<>();
|
Map<String, List<SimulationTaskMember>> taskMemberMap = new HashMap<>();
|
||||||
// for (SimulationNode simulationNode : nodeList) {
|
if (CollectionUtils.isNotEmpty(executorUserList)) {
|
||||||
// updateNodeStatus(simulationNode, calculationInterval);
|
taskMemberMap = executorUserList.stream().collect(Collectors.groupingBy(SimulationTaskMember::getTaskId));
|
||||||
// if (TaskExeStatusEnum.POSTPONED.getCode().equals(simulationNode.getExeStatus())) {
|
}
|
||||||
// updateNodeList.add(simulationNode);
|
// 查询任务的拓展属性(实际达成进度)
|
||||||
// }
|
List<SimulationTaskExtra> actualProgressList = taskExtraService.lambdaQuery().in(SimulationTaskExtra::getTaskId, updateTaskList.stream().map(SimulationTask::getUuid).toList())
|
||||||
// }
|
.eq(SimulationTaskExtra::getPropertyName, PROPERTY_NAME_ACTUAL_PROGRESS).list();
|
||||||
// return updateNodeList;
|
Map<String, String> actualProgressMap = new HashMap<>();
|
||||||
// }
|
if (CollectionUtils.isNotEmpty(actualProgressList)) {
|
||||||
//
|
actualProgressMap = actualProgressList.stream()
|
||||||
// public static void updateTaskStatus(SimulationTask task, int calculationInterval) {
|
.collect(Collectors.toMap(
|
||||||
// // 1. 判空
|
SimulationTaskExtra::getTaskId,
|
||||||
// if (task.getCommitmentDeadline().trim().isEmpty()) {
|
SimulationTaskExtra::getPropertyValue,
|
||||||
// return;
|
(oldValue, newValue) -> oldValue
|
||||||
// }
|
));
|
||||||
// // 2. 字符串转日期对象
|
}
|
||||||
// LocalDateTime deadlineTime = LocalDateTime.parse(task.getCommitmentDeadline().trim(), DATE_TIME_FORMATTER);
|
List<SimulationTaskMember> currentTaskMemberList;
|
||||||
// LocalDateTime currentTime = LocalDateTime.now();
|
for (SimulationTask simulationTask : updateTaskList) {
|
||||||
// // 3. 先计算两个时间的毫秒差值
|
// 若实际达成进度不超过 3D设计,则发消息给提出人
|
||||||
// long diffMillis = ChronoUnit.MILLIS.between(currentTime, deadlineTime);
|
String actualProgress = actualProgressMap.get(simulationTask.getUuid());
|
||||||
// // 1天 = 24*60*60*1000 毫秒 = 86400000L 毫秒,换算成带小数的天数
|
log.info("actualProgress为:{}",actualProgress);
|
||||||
// double daysBetween = diffMillis / 86400000.0D;
|
if (StringUtils.isNotBlank(actualProgress)) {
|
||||||
// // 4. 业务判断:精准天数 > 配置间隔天数 → 更新状态为:已延期
|
String actualProgressValueStr = taskProgressMap.get(actualProgress);
|
||||||
// if (daysBetween < calculationInterval) {
|
log.info("actualProgressValueStr为:{}",actualProgressValueStr);
|
||||||
// task.setExeStatus(TaskExeStatusEnum.POSTPONED.getCode());
|
if (StringUtils.isNotBlank(actualProgressValueStr) && isConvertibleToInt(actualProgressValueStr)) {
|
||||||
// }
|
int actualProgressValue = Integer.parseInt(actualProgressValueStr);
|
||||||
// }
|
if ((taskProgressValue == -1 || actualProgressValue <= taskProgressValue)
|
||||||
//
|
&& ObjectUtils.isNotEmpty(simulationTask.getCreator())) {
|
||||||
// private List<SimulationTask> handleTaskCommitmentDeadlineStatus(List<SimulationTask> taskList) {
|
sendMessage(MessageTemplateEnum.TASK_OVERDUE, simulationTask.getTaskName(), String.valueOf(simulationTask.getCreator()), simulationTask.getUuid());
|
||||||
// List<SimulationTask> updateTaskList = new ArrayList<>();
|
}
|
||||||
// for (SimulationTask simulationTask : taskList) {
|
}
|
||||||
// updateTaskStatus(simulationTask, calculationInterval);
|
}
|
||||||
// if (TaskExeStatusEnum.POSTPONED.getCode().equals(simulationTask.getExeStatus())) {
|
// 发消息给执行人
|
||||||
// updateTaskList.add(simulationTask);
|
currentTaskMemberList = taskMemberMap.get(simulationTask.getUuid());
|
||||||
// }
|
if (CollectionUtils.isEmpty(currentTaskMemberList)) {
|
||||||
// }
|
log.info("未查询到任务:{}的执行人,无法发送消息",simulationTask.getUuid());
|
||||||
// return updateTaskList;
|
continue;
|
||||||
// }
|
}
|
||||||
//
|
for (SimulationTaskMember simulationTaskMember : currentTaskMemberList) {
|
||||||
//}
|
sendMessage(MessageTemplateEnum.TASK_OVERDUE, simulationTask.getTaskName(), String.valueOf(simulationTaskMember.getUserId()), simulationTask.getUuid());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log.info("无任务延期");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.info("无任务延期");
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("定时任务执行异常", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核心方法:根据截止时间和间隔天数,判断并更新SimulationNode的exeStatus
|
||||||
|
*
|
||||||
|
* @param node 待处理的实体对象
|
||||||
|
* @param calculationInterval 间隔天数(int,单位:天)
|
||||||
|
*/
|
||||||
|
public static void updateNodeStatus(SimulationNode node, int calculationInterval) {
|
||||||
|
// 1. 判空
|
||||||
|
if (node.getCommitmentDeadline().trim().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 2. 字符串转日期对象
|
||||||
|
LocalDateTime deadlineTime = LocalDateTime.parse(node.getCommitmentDeadline().trim(), DATE_TIME_FORMATTER);
|
||||||
|
LocalDateTime currentTime = LocalDateTime.now();
|
||||||
|
// 3. 先计算两个时间的毫秒差值
|
||||||
|
long diffMillis = ChronoUnit.MILLIS.between(currentTime, deadlineTime);
|
||||||
|
// 1天 = 24*60*60*1000 毫秒 = 86400000L 毫秒,换算成带小数的天数
|
||||||
|
double daysBetween = diffMillis / 86400000.0D;
|
||||||
|
// 4. 业务判断:精准天数 > 配置间隔天数 → 更新状态为:已延期
|
||||||
|
if (daysBetween < calculationInterval) {
|
||||||
|
node.setExeStatus(TaskExeStatusEnum.POSTPONED.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SimulationNode> handleNodeCommitmentDeadlineStatus(List<SimulationNode> nodeList) {
|
||||||
|
List<SimulationNode> updateNodeList = new ArrayList<>();
|
||||||
|
for (SimulationNode simulationNode : nodeList) {
|
||||||
|
updateNodeStatus(simulationNode, calculationInterval);
|
||||||
|
if (TaskExeStatusEnum.POSTPONED.getCode().equals(simulationNode.getExeStatus())) {
|
||||||
|
updateNodeList.add(simulationNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return updateNodeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updateTaskStatus(SimulationTask task, int calculationInterval) {
|
||||||
|
// 1. 判空
|
||||||
|
if (task.getCommitmentDeadline().trim().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 2. 字符串转日期对象
|
||||||
|
LocalDateTime deadlineTime = LocalDateTime.parse(task.getCommitmentDeadline().trim(), DATE_TIME_FORMATTER);
|
||||||
|
LocalDateTime currentTime = LocalDateTime.now();
|
||||||
|
// 3. 先计算两个时间的毫秒差值
|
||||||
|
long diffMillis = ChronoUnit.MILLIS.between(currentTime, deadlineTime);
|
||||||
|
// 1天 = 24*60*60*1000 毫秒 = 86400000L 毫秒,换算成带小数的天数
|
||||||
|
double daysBetween = diffMillis / 86400000.0D;
|
||||||
|
// 4. 业务判断:精准天数 > 配置间隔天数 → 更新状态为:已延期
|
||||||
|
if (daysBetween < calculationInterval) {
|
||||||
|
task.setExeStatus(TaskExeStatusEnum.POSTPONED.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SimulationTask> handleTaskCommitmentDeadlineStatus(List<SimulationTask> taskList) {
|
||||||
|
List<SimulationTask> updateTaskList = new ArrayList<>();
|
||||||
|
for (SimulationTask simulationTask : taskList) {
|
||||||
|
updateTaskStatus(simulationTask, calculationInterval);
|
||||||
|
if (TaskExeStatusEnum.POSTPONED.getCode().equals(simulationTask.getExeStatus())) {
|
||||||
|
updateTaskList.add(simulationTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return updateTaskList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMessage(MessageTemplateEnum templateEnum, String taskName, String userId, String uuid) {
|
||||||
|
SendMsgReq req = new SendMsgReq();
|
||||||
|
req.setTitle(templateEnum.getTitle());
|
||||||
|
req.setContent(templateEnum.getContent(taskName));
|
||||||
|
req.setTenantId(ThreadLocalContext.getTenantId().toString());
|
||||||
|
req.setUserId(userId);
|
||||||
|
JSONObject params = new JSONObject();
|
||||||
|
params.put("taskId", uuid);
|
||||||
|
req.setParams(JSONObject.toJSONString(params));
|
||||||
|
messageFeignClient.sendMessage(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断字符串是否可以安全转换为int类型
|
||||||
|
*
|
||||||
|
* @param str 待判断的字符串
|
||||||
|
* @return true-可以安全转换,false-不可以
|
||||||
|
*/
|
||||||
|
public static boolean isConvertibleToInt(String str) {
|
||||||
|
// 1. 处理null或空字符串
|
||||||
|
if (str == null || str.trim().isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去除首尾空格
|
||||||
|
String trimmedStr = str.trim();
|
||||||
|
|
||||||
|
// 2. 正则校验:匹配整数格式(可选的正负号 + 至少1位数字)
|
||||||
|
// 正则说明:^[-+]? 匹配开头的正负号(可选);\\d+ 匹配至少1位数字;$ 匹配字符串结尾
|
||||||
|
if (!trimmedStr.matches("^[-+]?\\d+$")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 3. 先尝试转换为long(避免int范围溢出),再判断是否在int范围内
|
||||||
|
long num = Long.parseLong(trimmedStr);
|
||||||
|
return num >= Integer.MIN_VALUE && num <= Integer.MAX_VALUE;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 理论上正则校验通过后不会走到这里,做兜底处理
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
|||||||
SdmResponse<PageDataResp<List<CIDUserResp>>> pageDataRespSdmResponse = sysUserFeignClient.listUser(userListReq);
|
SdmResponse<PageDataResp<List<CIDUserResp>>> pageDataRespSdmResponse = sysUserFeignClient.listUser(userListReq);
|
||||||
if (pageDataRespSdmResponse.isSuccess() && pageDataRespSdmResponse.getData().getData() != null) {
|
if (pageDataRespSdmResponse.isSuccess() && pageDataRespSdmResponse.getData().getData() != null) {
|
||||||
List<CIDUserResp> userList = pageDataRespSdmResponse.getData().getData();
|
List<CIDUserResp> userList = pageDataRespSdmResponse.getData().getData();
|
||||||
usernameToUserIdMap = userList.stream().collect(Collectors.toMap(CIDUserResp::getUsername, CIDUserResp::getUserId));
|
usernameToUserIdMap = userList.stream().collect(Collectors.toMap(CIDUserResp::getJobNumber, CIDUserResp::getUserId));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SimulationNode projectNode : projectNodeList) {
|
for (SimulationNode projectNode : projectNodeList) {
|
||||||
|
|||||||
@@ -3426,7 +3426,7 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
|
|||||||
SdmResponse<PageDataResp<List<CIDUserResp>>> pageDataRespSdmResponse = sysUserFeignClient.listUser(userListReq);
|
SdmResponse<PageDataResp<List<CIDUserResp>>> pageDataRespSdmResponse = sysUserFeignClient.listUser(userListReq);
|
||||||
if (pageDataRespSdmResponse.isSuccess() && pageDataRespSdmResponse.getData().getData() != null) {
|
if (pageDataRespSdmResponse.isSuccess() && pageDataRespSdmResponse.getData().getData() != null) {
|
||||||
List<CIDUserResp> userList = pageDataRespSdmResponse.getData().getData();
|
List<CIDUserResp> userList = pageDataRespSdmResponse.getData().getData();
|
||||||
usernameToUserIdMap = userList.stream().collect(Collectors.toMap(CIDUserResp::getUsername, CIDUserResp::getUserId));
|
usernameToUserIdMap = userList.stream().collect(Collectors.toMap(CIDUserResp::getJobNumber, CIDUserResp::getUserId));
|
||||||
}
|
}
|
||||||
// 筛选出所有工位节点
|
// 筛选出所有工位节点
|
||||||
for (LyricVTodoEmulationInfoDM todoItem : todoInfoList) {
|
for (LyricVTodoEmulationInfoDM todoItem : todoInfoList) {
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ public class SimulationTaskServiceImpl extends ServiceImpl<SimulationTaskMapper,
|
|||||||
task.setDescription(demand.getDescription());
|
task.setDescription(demand.getDescription());
|
||||||
task.setBeginTime(demand.getBeginTime());
|
task.setBeginTime(demand.getBeginTime());
|
||||||
task.setEndTime(demand.getEndTime());
|
task.setEndTime(demand.getEndTime());
|
||||||
task.setCreator(ThreadLocalContext.getUserId());
|
task.setCreator(demand.getCreator());
|
||||||
task.setCreateTime(demand.getCreateTime());
|
task.setCreateTime(demand.getCreateTime());
|
||||||
task.setTenantId(ThreadLocalContext.getTenantId());
|
task.setTenantId(ThreadLocalContext.getTenantId());
|
||||||
|
|
||||||
|
|||||||
@@ -1062,7 +1062,7 @@ public class TaskServiceImpl implements ITaskService {
|
|||||||
SdmResponse<PageDataResp<List<CIDUserResp>>> pageDataRespSdmResponse = sysUserFeignClient.listUser(userListReq);
|
SdmResponse<PageDataResp<List<CIDUserResp>>> pageDataRespSdmResponse = sysUserFeignClient.listUser(userListReq);
|
||||||
if (pageDataRespSdmResponse.isSuccess() && pageDataRespSdmResponse.getData().getData() != null) {
|
if (pageDataRespSdmResponse.isSuccess() && pageDataRespSdmResponse.getData().getData() != null) {
|
||||||
List<CIDUserResp> userList = pageDataRespSdmResponse.getData().getData();
|
List<CIDUserResp> userList = pageDataRespSdmResponse.getData().getData();
|
||||||
usernameToUserIdMap = userList.stream().collect(Collectors.toMap(CIDUserResp::getUsername, CIDUserResp::getUserId));
|
usernameToUserIdMap = userList.stream().collect(Collectors.toMap(CIDUserResp::getJobNumber, CIDUserResp::getUserId));
|
||||||
}
|
}
|
||||||
List<SpdmNewTaskVo> newTaskList = convertToNewVoBatch(pageTaskList, batchData,usernameToUserIdMap);
|
List<SpdmNewTaskVo> newTaskList = convertToNewVoBatch(pageTaskList, batchData,usernameToUserIdMap);
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user