普测计划
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.njcn.bpm.listener.business;
|
||||
|
||||
import com.njcn.bpm.listener.BpmProcessInstanceStatusEvent;
|
||||
import com.njcn.bpm.listener.BpmProcessInstanceStatusEventListener;
|
||||
import com.njcn.supervision.api.DeVReportManageFeignClient;
|
||||
import com.njcn.supervision.api.SurveyPlanFeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
@Component
|
||||
public class BpmSurveyPlanStatusListener extends BpmProcessInstanceStatusEventListener {
|
||||
|
||||
@Resource
|
||||
private SurveyPlanFeignClient surveyPlanFeignClient;
|
||||
|
||||
@Override
|
||||
protected String getProcessDefinitionKey() {
|
||||
return "survey_plan";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
||||
surveyPlanFeignClient.updateStatus(event.getBusinessKey(), event.getStatus());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.supervision.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.supervision.api.fallback.SurveyPlanFeignClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
|
||||
/**
|
||||
* 流程实例 Api 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.SUPERVISION, path = "/surveyPlan", fallbackFactory = SurveyPlanFeignClientFallbackFactory.class)
|
||||
public interface SurveyPlanFeignClient {
|
||||
|
||||
@GetMapping("/updateSurveyPlanStatus")
|
||||
HttpResult<Object> updateStatus(@RequestParam("businessKey") String businessKey, @RequestParam("status")Integer status);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.supervision.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.supervision.api.SurveyPlanFeignClient;
|
||||
import com.njcn.supervision.utils.SupervisionEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022/3/16
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SurveyPlanFeignClientFallbackFactory implements FallbackFactory<SurveyPlanFeignClient> {
|
||||
@Override
|
||||
public SurveyPlanFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = SupervisionEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new SurveyPlanFeignClient() {
|
||||
@Override
|
||||
public HttpResult<Object> updateStatus(String businessKey, Integer status) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "更新普测计划流程状态", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public enum SupervisionResponseEnum {
|
||||
*/
|
||||
SUPERVISION_COMMON_ERROR("A00550","监督管理模块异常"),
|
||||
IMPORT_SENSITIVE_USER_ERROR("A00550","导入敏感及重要用户失败"),
|
||||
DATA_NOT_EXISTS("A00550","数据不存在"),
|
||||
NO_POWER("A00550","不能操作非自己创建的任务!")
|
||||
;
|
||||
|
||||
|
||||
@@ -39,6 +39,18 @@ public class SurveyTest extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private String deptId;
|
||||
|
||||
|
||||
/**
|
||||
* 0 关联系统内变电站;1 用户手动输入变电站
|
||||
*/
|
||||
private Integer customSubstationFlag;
|
||||
|
||||
/**
|
||||
* 变电站台账ID或者用户手动输入的变电站名称
|
||||
*/
|
||||
private String substation;
|
||||
|
||||
|
||||
/**
|
||||
* 计划完成时间
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -84,5 +85,10 @@ public class SurveyPlanVO extends BaseEntity implements Serializable {
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 变电站详情
|
||||
*/
|
||||
private List<SurveySubstation> surveySubstationList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.supervision.pojo.vo.survey;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SurveySubstation implements Serializable {
|
||||
|
||||
/**
|
||||
* 变电站名
|
||||
*/
|
||||
private String substationName;
|
||||
|
||||
/**
|
||||
* 电压等级
|
||||
*/
|
||||
private String voltageLevel;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
* 0:系统内
|
||||
* 1:用户自定义
|
||||
*/
|
||||
private Integer dataSource = 0;
|
||||
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.supervision.pojo.param.survey.SurveyPlanParam;
|
||||
import com.njcn.supervision.pojo.vo.device.QuitRunningDeviceVO;
|
||||
import com.njcn.supervision.pojo.vo.survey.SurveyPlanVO;
|
||||
import com.njcn.supervision.service.survey.ISurveyPlanService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -89,7 +90,14 @@ public class SurveyPlanController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getById")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@Operation(summary = "根据id获取普测计划的详细数据")
|
||||
public HttpResult<SurveyPlanVO> getById(String id) {
|
||||
String methodDescribe = getMethodDescribe("getById");
|
||||
SurveyPlanVO surveyPlanVO = surveyPlanService.getVOById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, surveyPlanVO, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,4 +26,6 @@ public interface ISurveyPlanService extends IService<SurveyPlan> {
|
||||
String cancelSurveyPlan(BpmProcessInstanceCancelParam cancelReqVO);
|
||||
|
||||
void updateSurveyPlanStatus(String businessKey, Integer status);
|
||||
|
||||
SurveyPlanVO getVOById(String id);
|
||||
}
|
||||
|
||||
@@ -13,12 +13,19 @@ import com.njcn.bpm.enums.BpmTaskStatusEnum;
|
||||
import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
|
||||
import com.njcn.supervision.enums.FlowStatusEnum;
|
||||
import com.njcn.supervision.enums.SupervisionResponseEnum;
|
||||
import com.njcn.supervision.mapper.survey.SurveyPlanMapper;
|
||||
import com.njcn.supervision.pojo.param.survey.SurveyPlanParam;
|
||||
import com.njcn.supervision.pojo.po.survey.SurveyPlan;
|
||||
import com.njcn.supervision.pojo.po.survey.SurveyTest;
|
||||
import com.njcn.supervision.pojo.vo.survey.SurveyPlanVO;
|
||||
import com.njcn.supervision.pojo.vo.survey.SurveySubstation;
|
||||
import com.njcn.supervision.service.survey.ISurveyPlanService;
|
||||
import com.njcn.supervision.service.survey.ISurveyTestService;
|
||||
import com.njcn.supervision.utils.InstanceUtil;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
@@ -29,10 +36,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -54,6 +58,8 @@ public class SurveyPlanServiceImpl extends ServiceImpl<SurveyPlanMapper, SurveyP
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final ISurveyTestService surveyTestService;
|
||||
|
||||
/**
|
||||
* 预告警单的反馈单对应的流程定义 KEY
|
||||
*/
|
||||
@@ -178,9 +184,65 @@ public class SurveyPlanServiceImpl extends ServiceImpl<SurveyPlanMapper, SurveyP
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateSurveyPlanStatus(String businessKey, Integer status) {
|
||||
SurveyPlan surveyPlan = this.baseMapper.selectById(businessKey);
|
||||
surveyPlan.setStatus(status);
|
||||
this.updateById(surveyPlan);
|
||||
if(Objects.equals(status, FlowStatusEnum.APPROVE.getCode())){
|
||||
//计划审核成功后,需要将计划拆成一个个待测试的
|
||||
if(surveyPlan.getCustomSubstationFlag() == 0){
|
||||
String substation = surveyPlan.getSubstation();
|
||||
String[] subIds = substation.split(StrPool.COMMA);
|
||||
for (String subId : subIds) {
|
||||
SurveyTest surveyTest = new SurveyTest();
|
||||
surveyTest.setPlanId(surveyPlan.getId());
|
||||
surveyTest.setDeptId(surveyPlan.getDeptId());
|
||||
surveyTest.setSubstation(subId);
|
||||
surveyTest.setCustomSubstationFlag(0);
|
||||
surveyTestService.save(surveyTest);
|
||||
}
|
||||
}else{
|
||||
SurveyTest surveyTest = new SurveyTest();
|
||||
surveyTest.setPlanId(surveyPlan.getId());
|
||||
surveyTest.setDeptId(surveyPlan.getDeptId());
|
||||
surveyTest.setSubstation(surveyPlan.getSubstation());
|
||||
surveyTest.setCustomSubstationFlag(1);
|
||||
surveyTestService.save(surveyTest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SurveyPlanVO getVOById(String id) {
|
||||
SurveyPlan surveyPlan = this.baseMapper.selectById(id);
|
||||
if (Objects.isNull(surveyPlan)) {
|
||||
throw new BusinessException(SupervisionResponseEnum.DATA_NOT_EXISTS);
|
||||
}
|
||||
SurveyPlanVO surveyPlanVO = new SurveyPlanVO();
|
||||
BeanUtils.copyProperties(surveyPlan, surveyPlanVO);
|
||||
surveyPlanVO.setDeptName(deptFeignClient.getDeptById(surveyPlanVO.getDeptId()).getData().getName());
|
||||
List<SurveySubstation> surveySubstationList = new ArrayList<>();
|
||||
if (surveyPlanVO.getCustomSubstationFlag() == 0) {
|
||||
//系统内变电站信息
|
||||
String substation = surveyPlanVO.getSubstation();
|
||||
String[] subIds = substation.split(StrPool.COMMA);
|
||||
for (String subId : subIds) {
|
||||
PollutionSubstationDTO data = lineFeignClient.getSubstationInfo(subId).getData();
|
||||
SurveySubstation surveySubstation = new SurveySubstation();
|
||||
surveySubstation.setDataSource(0);
|
||||
surveySubstation.setSubstationName(data.getName());
|
||||
surveySubstation.setVoltageLevel(data.getVoltageLevel());
|
||||
surveySubstationList.add(surveySubstation);
|
||||
}
|
||||
} else {
|
||||
SurveySubstation surveySubstation = new SurveySubstation();
|
||||
surveySubstation.setDataSource(1);
|
||||
surveySubstation.setSubstationName(surveyPlanVO.getSubstation());
|
||||
surveySubstation.setVoltageLevel(StrPool.SLASH);
|
||||
surveySubstationList.add(surveySubstation);
|
||||
}
|
||||
surveyPlanVO.setSurveySubstationList(surveySubstationList);
|
||||
return surveyPlanVO;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user