Commit c47c8202 authored by 高建强's avatar 高建强

item:新增根据批次号更新预案步骤按钮的状态接口

parent 0c437db9
...@@ -162,6 +162,13 @@ public class PlanVisual3dController extends BaseController { ...@@ -162,6 +162,13 @@ public class PlanVisual3dController extends BaseController {
} }
@Permission @Permission
@ApiOperation(value = "根据批次号更新预案步骤按钮的状态", notes = "根据批次号更新预案步骤按钮的状态")
@GetMapping(value = "/plan/updatePlanStepStatus")
public ResponseModel updatePlanStepStatus(@RequestParam("batchNo") String batchNo, @RequestParam("buttonCode") String buttonCode, @RequestParam("status") String status) {
return CommonResponseUtil.successNew(planVisual3dService.updatePlanStepStatus(batchNo, buttonCode, status));
}
@Permission
@ApiOperation(value = "根据批次号获取预案的记录", notes = "根据R批次号获取预案的记录") @ApiOperation(value = "根据批次号获取预案的记录", notes = "根据R批次号获取预案的记录")
@GetMapping(value = "/plan/getPlaneRecord") @GetMapping(value = "/plan/getPlaneRecord")
public ResponseModel getPlaneRecord(@RequestParam("batchNo") String batchNo) { public ResponseModel getPlaneRecord(@RequestParam("batchNo") String batchNo) {
......
package com.yeejoin.amos.fas.business.dao.mapper; package com.yeejoin.amos.fas.business.dao.mapper;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.yeejoin.amos.fas.dao.entity.PlanRule;
import com.yeejoin.amos.fas.datasync.bo.PlanOperationRecordSyncBo; import com.yeejoin.amos.fas.datasync.bo.PlanOperationRecordSyncBo;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -34,4 +35,6 @@ public interface PlanOperationRecordMapper { ...@@ -34,4 +35,6 @@ public interface PlanOperationRecordMapper {
* @return * @return
*/ */
String getNewestBatchNo(); String getNewestBatchNo();
PlanRule getPlanRuleByBatchNo(String batchNo);
} }
...@@ -2,7 +2,6 @@ package com.yeejoin.amos.fas.business.service.impl; ...@@ -2,7 +2,6 @@ package com.yeejoin.amos.fas.business.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.yeejoin.amos.fas.business.constants.FasConstant; import com.yeejoin.amos.fas.business.constants.FasConstant;
import com.yeejoin.amos.fas.business.dao.mapper.DictMapper; import com.yeejoin.amos.fas.business.dao.mapper.DictMapper;
...@@ -10,6 +9,7 @@ import com.yeejoin.amos.fas.business.dao.mapper.PlanOperationRecordMapper; ...@@ -10,6 +9,7 @@ import com.yeejoin.amos.fas.business.dao.mapper.PlanOperationRecordMapper;
import com.yeejoin.amos.fas.business.dao.mapper.PlanVisual3dMapper; import com.yeejoin.amos.fas.business.dao.mapper.PlanVisual3dMapper;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao; import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyPlanInstanceRepository; import com.yeejoin.amos.fas.business.dao.repository.IContingencyPlanInstanceRepository;
import com.yeejoin.amos.fas.business.dao.repository.IPlanRuleDao;
import com.yeejoin.amos.fas.business.dao.repository.ITextPlanDao; import com.yeejoin.amos.fas.business.dao.repository.ITextPlanDao;
import com.yeejoin.amos.fas.business.feign.IMaasVisualServer; import com.yeejoin.amos.fas.business.feign.IMaasVisualServer;
import com.yeejoin.amos.fas.business.service.intfc.IDictService; import com.yeejoin.amos.fas.business.service.intfc.IDictService;
...@@ -17,15 +17,18 @@ import com.yeejoin.amos.fas.business.service.intfc.IPlanVisual3dService; ...@@ -17,15 +17,18 @@ import com.yeejoin.amos.fas.business.service.intfc.IPlanVisual3dService;
import com.yeejoin.amos.fas.business.service.model.ToipResponse; import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.business.util.JSONUtil; import com.yeejoin.amos.fas.business.util.JSONUtil;
import com.yeejoin.amos.fas.business.util.StringUtil; import com.yeejoin.amos.fas.business.util.StringUtil;
import com.yeejoin.amos.fas.business.vo.PlanStepVo;
import com.yeejoin.amos.fas.business.vo.TreeSubjectVo; import com.yeejoin.amos.fas.business.vo.TreeSubjectVo;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil; import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData; import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Dict; import com.yeejoin.amos.fas.dao.entity.Dict;
import com.yeejoin.amos.fas.dao.entity.PlanRule;
import com.yeejoin.amos.fas.dao.entity.TextPlan; import com.yeejoin.amos.fas.dao.entity.TextPlan;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -59,6 +62,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -59,6 +62,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Autowired @Autowired
private IContingencyPlanInstanceRepository contingencyPlanInstanceRepository; private IContingencyPlanInstanceRepository contingencyPlanInstanceRepository;
@Autowired
private IPlanRuleDao planRuleDao;
@Override @Override
public List<TreeSubjectVo> getPlanTree() { public List<TreeSubjectVo> getPlanTree() {
...@@ -88,11 +94,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -88,11 +94,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override @Override
public TextPlan getTextPlanInfoById(Long id) { public TextPlan getTextPlanInfoById(Long id) {
Optional<TextPlan> textPlan =iTextPlanDao.findById(id); Optional<TextPlan> textPlan = iTextPlanDao.findById(id);
if(textPlan.isPresent()){ if (textPlan.isPresent()) {
return textPlan.get(); return textPlan.get();
} }
return null; return null;
} }
private List<TreeSubjectVo> listToTree(List<Object> list) { private List<TreeSubjectVo> listToTree(List<Object> list) {
...@@ -117,11 +123,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -117,11 +123,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
List<TreeSubjectVo> childrenVos = Lists.newArrayList(); List<TreeSubjectVo> childrenVos = Lists.newArrayList();
List<Object> res = (List<Object>) response.getDataList(); List<Object> res = (List<Object>) response.getDataList();
res.forEach(r -> { res.forEach(r -> {
LinkedHashMap<String, Object> map1 = (LinkedHashMap<String, Object>) r; LinkedHashMap<String, Object> map1 = (LinkedHashMap<String, Object>) r;
Integer state = (Integer) map1.get("publishState"); Integer state = (Integer) map1.get("publishState");
if(state == 0) {//过滤 未发布状态 if (state == 0) {//过滤 未发布状态
return; return;
} }
TreeSubjectVo subjectVo = new TreeSubjectVo(); TreeSubjectVo subjectVo = new TreeSubjectVo();
subjectVo.setType("listNode"); subjectVo.setType("listNode");
subjectVo.setParentId((String) map.get("id")); subjectVo.setParentId((String) map.get("id"));
...@@ -187,8 +193,7 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -187,8 +193,7 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
Dict dict = new Dict(); Dict dict = new Dict();
dict.setDictCode(type); dict.setDictCode(type);
List<Dict> dictList = dictService.getDictList(dict); List<Dict> dictList = dictService.getDictList(dict);
Map<String, String> dicts = dictList.stream().collect( Map<String, String> dicts = dictList.stream().collect(Collectors.toMap(Dict::getDictValue, Dict::getDictName, (key1, key2) -> key2));
Collectors.toMap(Dict::getDictValue, Dict::getDictName, (key1, key2) -> key2));
//2.1换key为中文 //2.1换key为中文
Map<String, Object> tempMap = new HashMap<String, Object>(); Map<String, Object> tempMap = new HashMap<String, Object>();
...@@ -215,22 +220,22 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -215,22 +220,22 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
dict.setDictCode(FasConstant.PLAN_SOURCE_TYPE); dict.setDictCode(FasConstant.PLAN_SOURCE_TYPE);
List<Dict> dictList = dictMapper.getDictList(dict); List<Dict> dictList = dictMapper.getDictList(dict);
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
list = dictList.stream().map(e->{ list = dictList.stream().map(e -> {
Map<String, Object> newMap = new HashMap<String, Object>(); Map<String, Object> newMap = new HashMap<String, Object>();
newMap.put("key",e.getDictValue()); newMap.put("key", e.getDictValue());
newMap.put("value",e.getDictValue());//前端级联Cascader使用 newMap.put("value", e.getDictValue());//前端级联Cascader使用
newMap.put("isLeaf",false);////前端级联Cascader使用 newMap.put("isLeaf", false);////前端级联Cascader使用
newMap.put("dataType","type"); newMap.put("dataType", "type");
newMap.put("label",e.getDictName()); newMap.put("label", e.getDictName());
return newMap; return newMap;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return list; return list;
} }
@Override @Override
public List<TreeSubjectVo> getTextPlanBySubjectId(String appId) { public List<TreeSubjectVo> getTextPlanBySubjectId(String appId) {
//关联文字预案 //关联文字预案
List<TreeSubjectVo> subjectVos = new ArrayList<>(); List<TreeSubjectVo> subjectVos = new ArrayList<>();
List<TextPlan> textPlans = iTextPlanDao.findByAppId(appId); List<TextPlan> textPlans = iTextPlanDao.findByAppId(appId);
textPlans.forEach(t -> { textPlans.forEach(t -> {
TreeSubjectVo textTreeSubjectVo = new TreeSubjectVo(); TreeSubjectVo textTreeSubjectVo = new TreeSubjectVo();
...@@ -240,13 +245,13 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -240,13 +245,13 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
textTreeSubjectVo.setType("textNode"); textTreeSubjectVo.setType("textNode");
subjectVos.add(textTreeSubjectVo); subjectVos.add(textTreeSubjectVo);
}); });
return subjectVos; return subjectVos;
} }
@Override @Override
public void deleteTextPlanFile(Long id) { public void deleteTextPlanFile(Long id) {
iTextPlanDao.deleteById(id); iTextPlanDao.deleteById(id);
} }
@Override @Override
public String getNewestBatchNo() { public String getNewestBatchNo() {
...@@ -263,9 +268,13 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -263,9 +268,13 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
// 查询当前步骤 // 查询当前步骤
ContingencyOriginalData contingencyOriginalData = contingencyOriginalDataDao.findByBatchNo(batchNo); ContingencyOriginalData contingencyOriginalData = contingencyOriginalDataDao.findByBatchNo(batchNo);
String step = contingencyOriginalData.getStep(); String step = contingencyOriginalData.getStep();
String confirm = contingencyOriginalData.getConfirm();
Map<String, Object> msgContext = new HashMap<>(2); Map<String, Object> msgContext = new HashMap<>(2);
msgContext.put("step", objects); msgContext.put("step", objects);
msgContext.put("currentStep", step); msgContext.put("currentStep", contingencyOriginalData.getStep());
msgContext.put("confirm", contingencyOriginalData.getConfirm());
msgContext.put("createDate", contingencyOriginalData.getCreateDate());
msgContext.put("batchNo", contingencyOriginalData.getBatchNo());
toipResponse.setMsgType("steparea"); toipResponse.setMsgType("steparea");
toipResponse.setMsgContext(msgContext); toipResponse.setMsgContext(msgContext);
toipResponse.setContingency(contingencyOriginalData); toipResponse.setContingency(contingencyOriginalData);
...@@ -303,4 +312,24 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -303,4 +312,24 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
} }
return toipResponse; return toipResponse;
} }
@Override
@Transactional
public ToipResponse updatePlanStepStatus(String batchNo, String buttonCode, String status) {
ToipResponse toipResponse = new ToipResponse();
// 根据批次号查询预案步骤
PlanRule planRule = planOperationRecordMapper.getPlanRuleByBatchNo(batchNo);
String planStep = planRule.getPlanStep();
if (StringUtil.isNotEmpty(planStep)) {
List<PlanStepVo> list = JSON.parseArray(planStep, PlanStepVo.class);
List<PlanStepVo> collect = list.stream().peek(x -> {
if (StringUtils.isNotBlank(buttonCode) && buttonCode.equalsIgnoreCase(x.getButtonCode())) {
x.setStepStatus(status);
}
}).collect(Collectors.toList());
planRule.setPlanStep(JSON.toJSONString(collect));
planRuleDao.save(planRule);
}
return toipResponse;
}
} }
...@@ -68,4 +68,13 @@ public interface IPlanVisual3dService { ...@@ -68,4 +68,13 @@ public interface IPlanVisual3dService {
* @return 预案记录 * @return 预案记录
*/ */
ToipResponse getPlaneRecordOneByBatchNo(String batchNo); ToipResponse getPlaneRecordOneByBatchNo(String batchNo);
/**
* 根据批次号更新预案步骤按钮的状态
* @param batchNo 批次号
* @param buttonCode 按钮编码
* @param status 按钮状态:0-点击,1-已执行,2-点击未执行
* @return ToipResponse
*/
ToipResponse updatePlanStepStatus(String batchNo, String buttonCode, String status);
} }
package com.yeejoin.amos.fas.business.vo;
import lombok.Data;
@Data
public class PlanStepVo {
private String stepCode;
private String stepName;
private String stepStatus;
private String buttonCode;
}
...@@ -115,6 +115,15 @@ ...@@ -115,6 +115,15 @@
WHERE WHERE
cpor.batch_no = #{batchNo} cpor.batch_no = #{batchNo}
</select> </select>
<select id="getPlanRuleByBatchNo" resultType="com.yeejoin.amos.fas.dao.entity.PlanRule">
SELECT
cpr.*
FROM
c_plan_rule cpr
LEFT JOIN c_plan_operation_record cpor ON cpor.plan_id = cpr.plan_id
WHERE
cpor.batch_no = #{batchNo}
</select>
<select id="getNewestBatchNo" resultType="java.lang.String"> <select id="getNewestBatchNo" resultType="java.lang.String">
select batch_no as batchNo from c_plan_operation_record where status = 0 and is_delete = 0 order by create_date desc limit 1 select batch_no as batchNo from c_plan_operation_record where status = 0 and is_delete = 0 order by create_date desc limit 1
......
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