This commit is contained in:
guosongrui
2024-05-24 16:22:31 +08:00
18 changed files with 183 additions and 31 deletions

View File

@@ -83,5 +83,13 @@ public class SupervisionPlanController extends BaseController {
supervisionPlanPOService.updateStatus(businessKey,status);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/initiateWarningLeaflet")
@ApiOperation("针对技术监督问题发起告警单")
public HttpResult<Boolean> initiateWarningLeaflet(@RequestParam("id") String id){
String methodDescribe = getMethodDescribe("initiateWarningLeaflet");
supervisionPlanPOService.initiateWarningLeaflet(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, Boolean.TRUE, methodDescribe);
}
}

View File

@@ -26,4 +26,6 @@ public interface SupervisionPlanPOService extends IService<SupervisionPlanPO>{
SupervisionPlanVO getDetailPlan(String id);
void updateStatus(String businessKey, Integer status);
void initiateWarningLeaflet(String id);
}

View File

@@ -9,6 +9,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.bpm.api.BpmProcessFeignClient;
@@ -17,11 +18,14 @@ import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
import com.njcn.supervision.enums.LeafletTypeEnum;
import com.njcn.supervision.enums.ProblemTypeEnum;
import com.njcn.supervision.mapper.plan.SupervisionPlanPOMapper;
import com.njcn.supervision.pojo.param.plan.SupervisionPlanParam;
import com.njcn.supervision.pojo.po.plan.SupervisionPlanPO;
import com.njcn.supervision.pojo.po.plan.SupervisionProblemPO;
import com.njcn.supervision.pojo.vo.plan.SupervisionPlanVO;
import com.njcn.supervision.service.leaflet.IWarningLeafletService;
import com.njcn.supervision.service.plan.SupervisionPlanPOService;
import com.njcn.supervision.service.plan.SupervisionProblemPOService;
import com.njcn.user.api.DeptFeignClient;
@@ -58,6 +62,8 @@ public class SupervisionPlanPOServiceImpl extends ServiceImpl<SupervisionPlanPOM
private final BpmProcessFeignClient bpmProcessFeignClient;
public static final String PROCESS_KEY = "sup_plan_add";
private final SupervisionProblemPOService supervisionProblemPOService;
private final IWarningLeafletService warningLeafletService;
@Override
@Transactional(rollbackFor = Exception.class)
public String addPlan(SupervisionPlanParam supvPlanParam) {
@@ -102,6 +108,7 @@ public class SupervisionPlanPOServiceImpl extends ServiceImpl<SupervisionPlanPOM
}
}
supvPlan.setState(DataStateEnum.ENABLE.getCode());
supvPlan.setIsUploadHead(0);
supvPlan.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
this.save(supvPlan);
return supvPlan.getPlanId();
@@ -288,6 +295,54 @@ public class SupervisionPlanPOServiceImpl extends ServiceImpl<SupervisionPlanPOM
this.lambdaUpdate().set(SupervisionPlanPO::getStatus,status).eq(SupervisionPlanPO::getPlanId,businessKey).update();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void initiateWarningLeaflet(String id) {
//获取数据源用于组装数据
List<SupervisionProblemPO> list = supervisionProblemPOService.lambdaQuery().eq(SupervisionProblemPO::getPlanId, id).list();
SupervisionPlanPO byId = this.getById(id);
/*
* 1、预告警单名称此处暂时用计算监督计划名称
* 2、预告警编号暂时随机by yxb
* 3、问题类型1技术监督管理2在线监测超标问题3用户投诉4现场测试超标此处是现场测试超标
* 4、对应问题源id用于查询详细数据
* 5、单子类型1预警单2告警单
* 6、问题详细描述
* */
warningLeafletService.createLeaflet(
byId.getWorkPlanName(),
IdWorker.get32UUID(),
id,
ProblemTypeEnum.PLAN.getCode(),
LeafletTypeEnum.ALARM.getCode(),
assembleIssueDetail(list,byId)
);
//将当前的问题记录是否告警修改为已告警
this.lambdaUpdate().eq(SupervisionPlanPO::getPlanId,id).set(SupervisionPlanPO::getIsUploadHead,1).update();
}
/**
* 组装谐波普测的问题
* 格式planCreateTime发起的planName普测计划由负责人leader测试后于planComplateTime完成其中subName在本次普测计划测试中存在电能质量问题详细请查看附件
*/
private String assembleIssueDetail(List<SupervisionProblemPO> supervisionProblemPOList, SupervisionPlanPO supervisionPlanPO) {
String join = String.join(",", supervisionProblemPOList.stream().map(SupervisionProblemPO::getRemark).collect(Collectors.toList()));
String issueDetail = ""
.concat(LocalDateTimeUtil.format(supervisionPlanPO.getCreateTime(), DatePattern.CHINESE_DATE_PATTERN))
.concat("发起的")
.concat(supervisionPlanPO.getWorkPlanName())
.concat("技术监督计划,由负责人")
.concat(supervisionPlanPO.getEffectUserName())
.concat("实施,于")
.concat(LocalDateTimeUtil.format(supervisionPlanPO.getEffectEndTime(), DatePattern.CHINESE_DATE_PATTERN))
.concat("完成,其中存在问题")
.concat(join)
.concat("在本次技术监督计划测试中存在电能质量问题,详细请查看问题附件");
return issueDetail;
}
private void checkParam(SupervisionPlanParam supvPlanParam, Boolean updateFlag) {