Commit aeb84cb2 authored by KeYong's avatar KeYong

优化任务功能

parent e18f4f78
......@@ -131,6 +131,9 @@ public class ContingencyAction implements CustomerAction {
@Autowired
private IPlanStepService planStepService;
@Autowired
private IEmergencyTaskService emergencyTaskService;
@Value("${rocket-plan-topic}")
private String rocketTopic;
......@@ -994,58 +997,7 @@ public class ContingencyAction implements CustomerAction {
if (!StringUtils.isEmpty(instanceId)) {
return;
}
ContingencyPlanInstance contingencyPlanInstance = new ContingencyPlanInstance();
contingencyPlanInstance.setBatchNo(batchNo);
contingencyPlanInstance.setRecordType("TASKOPERATE");
contingencyPlanInstance.setRoleCode(roleCode);
contingencyPlanInstance.setCategory(taskName);
contingencyPlanInstance.setCreateDate(new Date());
contingencyPlanInstance.setTaskSort(taskNum);
contingencyPlanInstance.setStepCode(stepCode);
contingencyPlanInstance.setContent(buttonJson);
contingencyPlanInstanceRepository.save(contingencyPlanInstance);
if("0".equals(stepCode)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
String planStep = "";
if (redisTemplate.hasKey("planStep")) {
planStep = Objects.requireNonNull(redisTemplate.opsForValue().get("planStep")).toString();
} else {
planStep = planStepService.getPlanStep();
}
JSONArray objects = JSON.parseArray(planStep);
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan");
Map<String, Object> result = new HashMap<>();
result.put("contingency", new ContingencyRo());
result.put("msgContext", Collections.EMPTY_MAP);
result.put("msgType", "getStepList");
result.put("planStep", objects);
String planTask = "";
if (redisTemplate.hasKey("planTask")) {
planTask = Objects.requireNonNull(redisTemplate.opsForValue().get("planTask")).toString();
} else {
List<ContingencyPlanInstanceVO> lists = planVisual3dService.getTaskActionList(batchNo, 1);
planTask = JSON.toJSONString(lists);
}
JSONArray taskObjects = JSON.parseArray(planTask);
result.put("planTask", taskObjects);
webMqttComponent.publish(topic, JSON.toJSONString(result));
}
});
}
MessageVO messageVO = new MessageVO();
messageVO.setTitle("应急处置事项提醒");
messageVO.setBody("【" + taskName + "】" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
messageVO.setMsgType("emergencyPlan");
messageVO.setCategory(1);
messageVO.setIsSendApp(true);
messageVO.setIsSendWeb(true);
messageVO.setRelationId(batchNo);
planVisual3dService.sendMessage(roleCode, messageVO);
emergencyTaskService.saveTask("-2", batchNo);
}
}
}
......@@ -259,7 +259,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Override
public void afterCommit() {
equipmentHandlerService.executeDynamicPlan(batchNo, deviceData, equipment, equipmentSpecific, toke, operationRecord.getId());
emergencyTaskService.saveTask("-2", batchNo);
emergencyTaskService.saveTask("0", batchNo);
}
});
......
......@@ -35,6 +35,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils;
......@@ -121,6 +122,7 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService {
}
@Async
@Transactional
@Override
public void saveTask(String stepCode, String batchId) {
List<EmergencyTaskContentVo> list = emergencyTaskMapper.getContentList(stepCode);
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sun.media.jfxmedia.logging.Logger;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
......@@ -19,6 +20,7 @@ import com.yeejoin.amos.fas.business.service.intfc.IEmergencyTaskService;
import com.yeejoin.amos.fas.business.service.intfc.IPlanStepService;
import com.yeejoin.amos.fas.business.service.intfc.IPlanVisual3dService;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.business.util.DateUtils;
import com.yeejoin.amos.fas.business.util.JSONUtil;
import com.yeejoin.amos.fas.business.util.StringUtil;
import com.yeejoin.amos.fas.business.vo.*;
......@@ -43,6 +45,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -702,6 +705,7 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override
public boolean updateTaskStatusById(String id, Boolean runStatus, String userName, String userId, String roleNames) {
long start = System.currentTimeMillis();
boolean bool = false;
ResponseModel responseModel = null;
try {
......@@ -709,6 +713,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
} catch (Exception e) {
e.printStackTrace();
}
long end = System.currentTimeMillis();
System.out.println(end - start + ".......................");
String img = "";
if (responseModel != null && "SUCCESS".equals(responseModel.getDevMessage())) {
String resStr = JSON.toJSONString(responseModel.getResult()).replace("\"","");
......@@ -723,8 +729,6 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
bool = contingencyPlanInstanceMapper.updateTaskStatusById(id, null, runStatus, userName, userId, img, PlanReplyMessageEnum.TEXT.getCode(), roleNames);
}
if (bool) {
if (redisTemplate.hasKey("planTask")) {
redisTemplate.delete("planTask");
......
......@@ -460,7 +460,7 @@
FROM
contingency_plan_instance
<where>
runstate = false AND record_type = 'TASKOPERATE'
runstate IS NULL AND record_type = 'TASKOPERATE'
<if test="stepCode != null and stepCode != ''">
AND step_code = #{stepCode}
</if>
......
......@@ -109,11 +109,11 @@
FROM
c_emergency_task_content
<where>
<if test="stepCode != null and stepCode != ''">
<if test="stepCode != null and stepCode != '' and stepCode != '-2'">
step_code = #{stepCode}
</if>
<if test="stepCode != null and stepCode != '' and stepCode == '-2'">
step_code = -1 OR step_code = 0
step_code = -1
</if>
</where>
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment