Commit c276a15e authored by KeYong's avatar KeYong

优化Autosys服务及解决潜在bug

parent 5ed1e91d
package com.yeejoin.amos.fas.dao.dto;
import lombok.Data;
import java.util.List;
@Data
public class PlanStepJsonVO {
private String stepCode;
private String stepName;
private String stepStatus;
/**
* 是否并行,用于卡片展示;1:是,0:否
*/
private String isParallel;
private String roleCode;
private String buttonCode;
private String batchNo;
private String caseId;
private String buttonJson;
private String time = "";
/**
* 进度条标识
*/
private boolean showLine = false;
/**
* 1:是,0:否
*/
private String checkYesOrNo = "";
/**
* 进度索引
*/
private Integer index;
/**
* 节点物联设备指标之间关系
*/
private String inAndOr;
/**
* 节点物联设备之间关系
*/
private String outAndOr;
/**
* 是否自动执行;1自动,0非自动
*/
private Integer isAuto;
}
package com.yeejoin.amos.fas.dao.entity;
import com.yeejoin.amos.fas.dao.dto.PlanStepJsonVO;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class PlanStepTree extends BasicEntity {
private static final long serialVersionUID = 1L;
private String sequenceNbr;
//职责id
private Long obligationId;
//人员名称
private String name;
private String stepName;
//子级
private List<PlanStepJsonVO> children = new ArrayList<>();
//树节点展示标识
private String type;
private String code;
private Integer index;
}
\ No newline at end of file
......@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/contingencyPlan")
......@@ -283,7 +284,8 @@ public class ContingencyPlanController extends BaseController {
@RequestParam(value = "batchNo", required = false) String batchNo,
@RequestParam(value = "runState", required = false) String runState,
@RequestParam(value = "updateDate", required = false) String updateDate,
@RequestParam(value = "roleName", required = false) String roleName
@RequestParam(value = "roleName", required = false) String roleName,
@RequestParam(value = "stepCode", required = false) String stepCode
) {
if (current < 1 || size < 1) {
throw new YeeException("分页参数有误");
......@@ -293,7 +295,13 @@ public class ContingencyPlanController extends BaseController {
String[] ids = new String(roleName).split(",");
list = Arrays.asList(ids);
}
return CommonResponseUtil2.success(contingencyPlanService.selectTaskActionPage(current, size, batchNo, runState, updateDate, list));
List<String> steps = new ArrayList<>();
if (!StringUtils.isEmpty(stepCode)) {
String[] codes = new String(stepCode).split(",");
steps = Arrays.asList(codes);
steps = steps.stream().map(x -> String.valueOf(Integer.valueOf(x) - 1)).collect(Collectors.toList());
}
return CommonResponseUtil2.success(contingencyPlanService.selectTaskActionPage(current, size, batchNo, runState, updateDate, list, steps));
}
}
......@@ -62,12 +62,17 @@ public class EmergencyTaskController extends BaseController{
@ApiOperation(httpMethod = "GET",value = "岗位人员树", notes = "岗位人员树")
@RequestMapping(value = "/tree", method = RequestMethod.GET)
public CommonResponse tree(){
public CommonResponse tree(@RequestParam(value = "type", required = false) String type){
Dict dict = new Dict();
dict.setDictCode("YJZC");
//查询应急角色
// List<Dict> dictList = dictService.getDictList(dict);
List<EmergencyTaskRole> emergencyTaskRoles = emergencyTaskRoleMapper.selectList();
List<EmergencyTaskRole> emergencyTaskRoles = new ArrayList<>();
if (StringUtils.isNotEmpty(type)) {
emergencyTaskRoles = emergencyTaskRoleMapper.selectListFilterEmptyTask();
} else {
emergencyTaskRoles = emergencyTaskRoleMapper.selectList();
}
List<EmergencyRelationTree> list = new ArrayList<>();
List<EmergencyRelationTree> root = new ArrayList<>();
List<EmergencyRelationTree> treeNodes = iEmergencyTaskService.treeList();
......
......@@ -10,7 +10,9 @@ import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil2;
import com.yeejoin.amos.fas.core.util.ResponseModel;
import com.yeejoin.amos.fas.dao.dto.PlanStepJsonVO;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.PlanStepTree;
import com.yeejoin.amos.fas.dao.entity.TextPlan;
import com.yeejoin.amos.fas.exception.YeeException;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
......@@ -30,6 +32,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(value = "/api/visual")
......@@ -165,6 +168,30 @@ public class PlanVisual3dController extends BaseController {
}
@Permission
@ApiOperation(value = "根据批次号获取预案的步骤", notes = "根据批次号获取预案的步骤")
@GetMapping(value = "/plan/step/tree")
public ResponseModel getPlanStepTree(@RequestParam(value = "batchNo", required = false) String batchNo) {
if (StringUtils.isEmpty(batchNo)) {
batchNo = planVisual3dService.getNewestBatchNo();
}
List<PlanStepTree> root = new ArrayList<>();
List<PlanStepJsonVO> list = planVisual3dService.getPlanStepList(batchNo);
list.stream().map(x -> {x.setIndex(x.getIndex() + 1); return x;}).collect(Collectors.toList());
//增加根节点
PlanStepTree tree = new PlanStepTree();
tree.setId(0);
tree.setIndex(0);
tree.setSequenceNbr("0");
tree.setName("全部");
tree.setStepName("全部");
tree.setType("3");
tree.setCode("0");
tree.setChildren(list);
root.add(tree);
return CommonResponseUtil.successNew(root);
}
@Permission
@ApiOperation(value = "根据批次号更新预案的步骤", notes = "根据批次号更新预案的步骤")
@PostMapping(value = "/plan/updatePlanStep")
public ResponseModel updatePlanStep(@RequestBody PlanStepVo planStepVo) {
......
......@@ -38,8 +38,8 @@ public interface ContingencyInstanceInfoMapper extends BaseMapper<ContingencyIns
List<ContingencyPlanInstanceVO> getTaskActionList(@Param("type") String type, @Param("status") String status, @Param("batchNo") String batchNo);
int countTaskPage(@Param("type") String type, @Param("batchNo") String batchNo, @Param("list") List<String> roles);
int countTaskPage(@Param("type") String type, @Param("batchNo") String batchNo, @Param("list") List<String> roles, @Param("steps") List<String> steps);
List<ContingencyPlanInstanceVO> getTaskActionPage(@Param("current") int current, @Param("size") int size, @Param("batchNo") String batchNo, @Param("type") String type, @Param("runState") String runState, @Param("updateDate") String updateDate, @Param("list") List<String> roles);
List<ContingencyPlanInstanceVO> getTaskActionPage(@Param("current") int current, @Param("size") int size, @Param("batchNo") String batchNo, @Param("type") String type, @Param("runState") String runState, @Param("updateDate") String updateDate, @Param("list") List<String> roles, @Param("steps") List<String> steps);
}
......@@ -32,5 +32,7 @@ public interface EmergencyTaskRoleMapper extends BaseMapper<EmergencyTaskRole> {
List<EmergencyTaskRole> selectList();
List<EmergencyTaskRole> selectListFilterEmptyTask();
String getPlanStepInfoByType(@Param("planType") String planType);
}
......@@ -455,12 +455,19 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
@Override
public Optional<Equipment> clickButton(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String isExecute, String isAuto, String token, String product, String appKey,String startUserName) throws Exception {
if ("0".equals(stepCode)) {
String planType = null;
if (redisTemplate.hasKey("planType")) {
planType = redisTemplate.boundValueOps("planType").get(0, -1);
}
// 此处逻辑修改为所有任务执行完成才会点亮节点
List<EmergencyTaskContentVo> tasks = emergencyTaskService.getMustTaskList(stepCode, planType);
boolean flag = judgeIfConfirmed(tasks, batchNo);
if ("0".equals(stepCode) && flag) {
contingencyInstance.fire(batchNo, stepCode, buttonJson, contingencyPlanId,
"FIRE_CONFIRM", buttonState, stepStateOnbutton, "true", "false", token,
product, appKey, startUserName);
}
ContingencyPlanInstance instance = contingencyPlanInstanceMapper.getMessageById(contingencyPlanId);
instance.setId(null);
instance.setRecordType("REPLYMESSAGE");
......@@ -468,12 +475,6 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
instance.setContent(instance.getCategory());
ContingencyPlanInstance res = repository.save(instance);
if (!ObjectUtils.isEmpty(res)) {
String planType = null;
if (redisTemplate.hasKey("planType")) {
planType = redisTemplate.boundValueOps("planType").get(0, -1);
}
List<EmergencyTaskContentVo> mustTasks = emergencyTaskService.getMustTaskList(stepCode, planType);
boolean flag = judgeIfConfirmed(mustTasks, batchNo);
if (!"-1".equals(stepCode) && flag) {
PlanExecuteVo vo = new PlanExecuteVo();
vo.setConfirm(buttonState);
......@@ -536,17 +537,16 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
return Optional.empty();
}
private boolean judgeIfConfirmed(List<EmergencyTaskContentVo> mustTasks, String batchNo) {
if (0 == mustTasks.size()) {
return true;
private boolean judgeIfConfirmed(List<EmergencyTaskContentVo> tasks, String batchNo) {
boolean flag = Boolean.TRUE;
if (!CollectionUtils.isEmpty(tasks)) {
EmergencyTaskContentVo contentVo = tasks.get(0);
Integer count = contingencyPlanInstanceMapper.getPlanInstanceByRunState(contentVo.getStepCode(), batchNo);
if (0 != count) {
flag = Boolean.FALSE;
}
EmergencyTaskContentVo vo = mustTasks.get(0);
Integer count = contingencyPlanInstanceMapper.getPlanInstanceByRunState(vo.getStepCode(), batchNo);
if (0 == count) {
return true;
} else {
return false;
}
return flag;
}
@Autowired
......
......@@ -871,11 +871,11 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
}
@Override
public Page<ContingencyPlanInstanceVO> selectTaskActionPage(int current, int size, String batchNo, String runState, String updateDate, List<String> roleList) {
public Page<ContingencyPlanInstanceVO> selectTaskActionPage(int current, int size, String batchNo, String runState, String updateDate, List<String> roleList, List<String> steps) {
String type = "TASKOPERATE";
Page<ContingencyPlanInstanceVO> page = new Page<>(current, size);
int total = 0;
total = contingencyInstanceInfoMapper.countTaskPage(type, batchNo, roleList);
total = contingencyInstanceInfoMapper.countTaskPage(type, batchNo, roleList, steps);
long start = (page.getCurrent() - 1) * page.getSize();
if (total == 0) {
page.setCurrent(1);
......@@ -884,7 +884,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
page.setCurrent(1);
start = 0;
}
List<ContingencyPlanInstanceVO> list = contingencyInstanceInfoMapper.getTaskActionPage((int) start, size, batchNo, type, runState, updateDate, roleList);
List<ContingencyPlanInstanceVO> list = contingencyInstanceInfoMapper.getTaskActionPage((int) start, size, batchNo, type, runState, updateDate, roleList, steps);
list.stream().forEach(e->{
if(ObjectUtils.isEmpty(e.getCreateUser())) {
List<String> userName = planVisual3dService.getUserName(e.getRoleCode());
......
......@@ -170,7 +170,7 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService {
contingencyPlanInstance.setTaskSort(taskNum);
contingencyPlanInstance.setStepCode(stepCode);
contingencyPlanInstance.setContent(buttonJson);
contingencyPlanInstanceRepository.save(contingencyPlanInstance);
contingencyPlanInstanceRepository.saveAndFlush(contingencyPlanInstance);
if ("0".equals(stepCode)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
......
......@@ -25,6 +25,7 @@ import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.core.util.ResponseModel;
import com.yeejoin.amos.fas.dao.entity.*;
import com.yeejoin.amos.fas.dao.dto.PlanStepJsonVO;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
......@@ -277,6 +278,13 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
}
@Override
public List<PlanStepJsonVO> getPlanStepList(String batchNo) {
String json = planStepService.getPlanStep();
List<PlanStepJsonVO> res = JSONObject.parseArray(json, PlanStepJsonVO.class);
return res;
}
@Override
public ToipResponse getPlaneRecordByBatchNo(String batchNo) {
// 根据批次号获取预案记录
List<Map<String, Object>> instancesList = contingencyPlanInstanceRepository.queryRecord(batchNo, "MESSAGE");
......
......@@ -142,5 +142,5 @@ public interface IContingencyPlanService {
String getPlanBatchNo();
Page<ContingencyPlanInstanceVO> selectTaskActionPage(int current, int size, String batchNo, String runState, String updateDate, List<String> roleList);
Page<ContingencyPlanInstanceVO> selectTaskActionPage(int current, int size, String batchNo, String runState, String updateDate, List<String> roleList, List<String> steps);
}
......@@ -2,10 +2,8 @@ package com.yeejoin.amos.fas.business.service.intfc;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.business.vo.ContingencyPlanInstanceVO;
import com.yeejoin.amos.fas.business.vo.MessageVO;
import com.yeejoin.amos.fas.business.vo.PlanStepVo;
import com.yeejoin.amos.fas.business.vo.TreeSubjectVo;
import com.yeejoin.amos.fas.business.vo.*;
import com.yeejoin.amos.fas.dao.dto.PlanStepJsonVO;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.TextPlan;
......@@ -142,4 +140,6 @@ public interface IPlanVisual3dService {
* @return
*/
ContingencyPlanInstance updateStatusByIdWeb(ContingencyPlanInstance contingencyPlanInstance, Boolean runStatus);
List<PlanStepJsonVO> getPlanStepList(String batchNo);
}
......@@ -321,6 +321,11 @@
role_code like concat('%',#{role},'%')
</foreach>
</if>
<if test="steps != null and steps.size() >0">
<foreach collection="steps" item="code" index="index" open="and (" close=") " separator="or">
step_code = #{code}
</foreach>
</if>
</where>
UNION ALL
select count(1) AS tmpcount from contingency_plan_instance
......@@ -337,6 +342,11 @@
role_code like concat('%',#{role},'%')
</foreach>
</if>
<if test="steps != null and steps.size() >0">
<foreach collection="steps" item="code" index="index" open="and (" close=") " separator="or">
step_code = #{code}
</foreach>
</if>
</where>
) a
</select>
......@@ -363,6 +373,11 @@
cpi.role_code like concat('%',#{role},'%')
</foreach>
</if>
<if test="steps != null and steps.size() >0">
<foreach collection="steps" item="code" index="index" open="and (" close=") " separator="or">
step_code = #{code}
</foreach>
</if>
</where>
UNION ALL
select cpi.id, cpi.`record_type`, cpi.`category`, cpi.`content`, cpi.`icon`, cpi.`sort`, cpi.`sequence_num`
......@@ -385,6 +400,11 @@
cpi.role_code like concat('%',#{role},'%')
</foreach>
</if>
<if test="steps != null and steps.size() >0">
<foreach collection="steps" item="code" index="index" open="and (" close=") " separator="or">
step_code = #{code}
</foreach>
</if>
</where>
) tmp
<if test="updateDate != null and updateDate != '' and updateDate == 0">
......
......@@ -59,6 +59,20 @@
select * from c_emergency_task_role where is_delete = 0 order by sort desc
</select>
<select id="selectListFilterEmptyTask" resultType="com.yeejoin.amos.fas.dao.entity.EmergencyTaskRole">
SELECT
*
FROM
c_emergency_task_role cet
JOIN c_emergency_task_content cetc ON cetc.obligation_id = cet.id
WHERE
is_delete = 0
GROUP BY
cet.`code`
ORDER BY
cet.sort DESC
</select>
<select id="getPlanStepInfoByType" resultType="java.lang.String">
select `data` from c_plan_step_config
<where>
......
......@@ -148,9 +148,8 @@
FROM
c_emergency_task_content
<where>
is_must = true
<if test="stepCode != null and stepCode != ''">
and step_code = #{stepCode}
step_code = #{stepCode}
</if>
<if test="planType != null ">
AND plan_type = #{planType}
......
......@@ -15,7 +15,7 @@
"stepStatus": "0",
"buttonCode": "CALL_PHONE",
"isParallel": "1",
"roleCode": "Digital_Responsing_Plan_B",
"roleCode": "Digital_Responsing_Plan_A",
"index": 1,
"checkYesOrNo": ""
},
......@@ -27,7 +27,8 @@
"isParallel": "0",
"roleCode": "Digital_Responsing_Plan_A",
"index": 2,
"isAuto": 0
"isAuto": 0,
"checkYesOrNo": ""
},
{
"stepCode": "3",
......@@ -54,36 +55,49 @@
},
{
"stepCode": "4",
"stepName": "启动应急排油",
"stepName": "启动CAFS消防系统",
"stepStatus": "0",
"buttonCode": "FIRE_TRANSVERTER_TO_OVERHAUL",
"buttonCode": "OPEN_WATERSYSTEM",
"isParallel": "0",
"roleCode": "Digital_Responsing_Plan_B",
"roleCode": "Digital_Responsing_Plan_A",
"index": 4,
"checkYesOrNo": ""
"checkYesOrNo": "",
"condition": [
{
"equipName": "雨淋阀",
"equipCode": "92130300BH644",
"equipSpeName": "",
"equipSpeCode": "",
"equipSpeIndexKey": "WSS_DelugeValve_Start",
"standardValue": "true",
"inAndOr": "and"
}
],
"outAndOr": "and",
"isAuto": 0
},
{
"stepCode": "5",
"stepName": "CAFS喷淋系统已开启",
"stepName": "启动应急排油",
"stepStatus": "0",
"buttonCode": "VERIFY_EQUIP_STATUS",
"buttonCode": "DRAIN_OIL_CONFIRM",
"isParallel": "0",
"roleCode": "Digital_Responsing_Plan_A",
"index": 5,
"checkYesOrNo": "",
"condition": [
{
"equipName": "雨淋阀",
"equipCode": "92130300BH644",
"equipName": "排油阀",
"equipCode": "92100400VWE44",
"equipSpeName": "",
"equipSpeCode": "",
"equipSpeIndexKey": "WSS_DelugeValve_Start",
"equipSpeIndexKey": "ONL_DrainOilValve_Open",
"standardValue": "true",
"inAndOr": "and"
}
],
"outAndOr": "and",
"isAuto": 0
"isAuto": 0,
"checkYesOrNo": ""
},
{
"stepCode": "6",
......@@ -122,7 +136,7 @@
"stepStatus": "0",
"buttonCode": "FIRE_TRANSVERTER_TO_OVERHAUL",
"isParallel": "0",
"roleCode": "Digital_Responsing_Plan_A",
"roleCode": "Digital_Responsing_Plan_B",
"index": 9,
"checkYesOrNo": ""
},
......
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