修复普测调整带来的其他功能bug

This commit is contained in:
2024-06-04 14:49:57 +08:00
parent 2b0f149905
commit 06ec23710d
7 changed files with 164 additions and 4 deletions

View File

@@ -9,7 +9,9 @@ import com.njcn.common.pojo.enums.common.LogEnum;
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.SupervisionGeneralSurveyPlanParm;
import com.njcn.supervision.pojo.param.survey.SurveyTestParam;
import com.njcn.supervision.pojo.vo.survey.SupervisionGeneralSurveyPlanDetailVO;
import com.njcn.supervision.pojo.vo.survey.SurveyPlanVO;
import com.njcn.supervision.pojo.vo.survey.SurveyTestVO;
import com.njcn.supervision.service.survey.ISurveyTestService;
@@ -51,6 +53,16 @@ public class SurveyTestController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, out, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/pageProblemSurvey")
@ApiOperation("分页查询当前用户能看到的普测计划中存在超标问题")
@ApiImplicitParam(name = "surveyTestQueryParam", value = "参数", required = true)
public HttpResult<Page<SurveyTestVO>> pageProblemSurvey(@RequestBody @Validated SurveyTestParam.SurveyTestQueryParam surveyTestQueryParam ){
String methodDescribe = getMethodDescribe("pageProblemSurvey");
Page<SurveyTestVO> out = surveyTestService.pageProblemSurvey(surveyTestQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, out, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("新增普测测试")
@@ -100,5 +112,15 @@ public class SurveyTestController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, surveyTestVO, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/initiateWarningLeaflet")
@ApiOperation("针对有问题的现场测试发起告警单")
public HttpResult<Boolean> initiateWarningLeaflet(@RequestParam("id") String id){
String methodDescribe = getMethodDescribe("initiateWarningLeaflet");
surveyTestService.initiateWarningLeaflet(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, Boolean.TRUE, methodDescribe);
}
}

View File

@@ -25,8 +25,10 @@ import com.njcn.supervision.mapper.leaflet.WarningLeafletMapper;
import com.njcn.supervision.pojo.param.leaflet.WarningLeafletParam;
import com.njcn.supervision.pojo.po.leaflet.WarningLeaflet;
import com.njcn.supervision.pojo.po.survey.SupervisionGeneralSurveyPlanPO;
import com.njcn.supervision.pojo.po.survey.SurveyTest;
import com.njcn.supervision.pojo.vo.leaflet.WarningLeafletVO;
import com.njcn.supervision.service.leaflet.IWarningLeafletService;
import com.njcn.supervision.service.survey.ISurveyTestService;
import com.njcn.supervision.service.survey.SupervisionGeneralSurveyPlanPOService;
import com.njcn.supervision.utils.InstanceUtil;
import com.njcn.system.api.DicDataFeignClient;
@@ -65,6 +67,8 @@ public class WarningLeafletServiceImpl extends ServiceImpl<WarningLeafletMapper,
@Resource
private BpmProcessFeignClient bpmProcessFeignClient;
@Resource
private ISurveyTestService surveyTestService;
@Lazy
@Resource
@@ -171,8 +175,8 @@ public class WarningLeafletServiceImpl extends ServiceImpl<WarningLeafletMapper,
for (WarningLeafletVO record : records) {
if(record.getProblemType().equals(ProblemTypeEnum.SITE_TEST.getCode()) && StrUtil.isNotBlank(record.getProblemId())){
//查询到现场测试超标附件地址
SupervisionGeneralSurveyPlanPO generalSurveyPlanPO = supervisionGeneralSurveyPlanPOService.getById(record.getProblemId());
record.setProblemPath(generalSurveyPlanPO.getFilePath());
SurveyTest surveyTest = surveyTestService.getById(record.getProblemId());
record.setProblemPath(surveyTest.getTestReport());
}
}
}

View File

@@ -18,6 +18,7 @@ import com.njcn.supervision.pojo.vo.survey.SurveyTestVO;
public interface ISurveyTestService extends IService<SurveyTest> {
Page<SurveyTestVO> surveyTestPage(SurveyTestParam.SurveyTestQueryParam surveyTestQueryParam);
Page<SurveyTestVO> pageProblemSurvey(SurveyTestParam.SurveyTestQueryParam surveyTestQueryParam);
String addSurveyTest(SurveyTestParam surveyTestParam);
@@ -28,4 +29,6 @@ public interface ISurveyTestService extends IService<SurveyTest> {
void updateSurveyTestStatus(String businessKey, Integer status);
SurveyTestVO getVOById(String id);
void initiateWarningLeaflet(String id);
}

View File

@@ -202,6 +202,7 @@ public class SurveyPlanServiceImpl extends ServiceImpl<SurveyPlanMapper, SurveyP
SurveyTest surveyTest = new SurveyTest();
surveyTest.setPlanId(surveyPlan.getId());
surveyTest.setDeptId(surveyPlan.getDeptId());
surveyTest.setInitiateWarningFlag(0);
surveyTest.setSubstation(subId);
surveyTest.setCustomSubstationFlag(0);
surveyTest.setStatus(FlowStatusEnum.UN_TEST.getCode());
@@ -212,6 +213,7 @@ public class SurveyPlanServiceImpl extends ServiceImpl<SurveyPlanMapper, SurveyP
surveyTest.setPlanId(surveyPlan.getId());
surveyTest.setDeptId(surveyPlan.getDeptId());
surveyTest.setSubstation(surveyPlan.getSubstation());
surveyTest.setInitiateWarningFlag(0);
surveyTest.setCustomSubstationFlag(1);
surveyTest.setStatus(FlowStatusEnum.UN_TEST.getCode());
surveyTestService.save(surveyTest);

View File

@@ -1,10 +1,14 @@
package com.njcn.supervision.service.survey.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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;
@@ -15,12 +19,18 @@ import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam;
import com.njcn.common.pojo.enums.common.DataStateEnum;
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.LeafletTypeEnum;
import com.njcn.supervision.enums.ProblemTypeEnum;
import com.njcn.supervision.mapper.survey.SurveyTestMapper;
import com.njcn.supervision.pojo.param.survey.SurveyTestParam;
import com.njcn.supervision.pojo.po.survey.SupervisionGeneralSurveyPlanDetailPO;
import com.njcn.supervision.pojo.po.survey.SupervisionGeneralSurveyPlanPO;
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.SurveyTestVO;
import com.njcn.supervision.service.leaflet.IWarningLeafletService;
import com.njcn.supervision.service.survey.ISurveyPlanService;
import com.njcn.supervision.service.survey.ISurveyTestService;
import com.njcn.supervision.utils.InstanceUtil;
@@ -38,6 +48,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* <p>
@@ -64,6 +75,8 @@ public class SurveyTestServiceImpl extends ServiceImpl<SurveyTestMapper, SurveyT
@Resource
private ISurveyPlanService surveyPlanService;
@Resource
private IWarningLeafletService warningLeafletService;
/**
* 预告警单的反馈单对应的流程定义 KEY
@@ -76,12 +89,22 @@ public class SurveyTestServiceImpl extends ServiceImpl<SurveyTestMapper, SurveyT
QueryWrapper<SurveyTestVO> surveyTestVOQueryWrapper = new QueryWrapper<>();
if (Objects.nonNull(surveyTestQueryParam)) {
//添加上时间范围
surveyTestVOQueryWrapper.between("supervision_survey_test.Create_Time",
surveyTestVOQueryWrapper.between("supervision_survey_test.create_time",
DateUtil.beginOfDay(DateUtil.parse(surveyTestQueryParam.getSearchBeginTime())),
DateUtil.endOfDay(DateUtil.parse(surveyTestQueryParam.getSearchEndTime())));
//根据工程名称模糊搜索
if (StrUtil.isNotBlank(surveyTestQueryParam.getSearchValue())) {
surveyTestVOQueryWrapper.like("supervision_survey_test.plan_name", surveyTestQueryParam.getSearchValue());
LambdaQueryWrapper<SurveyPlan> surveyPlanLambdaQueryWrapper = new LambdaQueryWrapper<>();
surveyPlanLambdaQueryWrapper.eq(SurveyPlan::getState, DataStateEnum.ENABLE.getCode())
.like(SurveyPlan::getPlanName, surveyTestQueryParam.getSearchValue());
List<SurveyPlan> surveyPlans = surveyPlanService.getBaseMapper().selectList(surveyPlanLambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(surveyPlans)) {
List<String> planIds = surveyPlans.stream().map(SurveyPlan::getId).collect(Collectors.toList());
surveyTestVOQueryWrapper.in("supervision_survey_test.plan_id", planIds);
}
} else {
//没有匹配的。直接返回
return new Page<>();
}
}
//获取当前用户部门所有同事的id查看该部门下所有的数据
@@ -108,6 +131,55 @@ public class SurveyTestServiceImpl extends ServiceImpl<SurveyTestMapper, SurveyT
return surveyTestVOPage;
}
@Override
public Page<SurveyTestVO> pageProblemSurvey(SurveyTestParam.SurveyTestQueryParam surveyTestQueryParam) {
QueryWrapper<SurveyTestVO> surveyTestVOQueryWrapper = new QueryWrapper<>();
if (Objects.nonNull(surveyTestQueryParam)) {
//添加上时间范围
surveyTestVOQueryWrapper.between("supervision_survey_test.create_time",
DateUtil.beginOfDay(DateUtil.parse(surveyTestQueryParam.getSearchBeginTime())),
DateUtil.endOfDay(DateUtil.parse(surveyTestQueryParam.getSearchEndTime())));
//根据工程名称模糊搜索
if (StrUtil.isNotBlank(surveyTestQueryParam.getSearchValue())) {
LambdaQueryWrapper<SurveyPlan> surveyPlanLambdaQueryWrapper = new LambdaQueryWrapper<>();
surveyPlanLambdaQueryWrapper.eq(SurveyPlan::getState, DataStateEnum.ENABLE.getCode())
.like(SurveyPlan::getPlanName, surveyTestQueryParam.getSearchValue());
List<SurveyPlan> surveyPlans = surveyPlanService.getBaseMapper().selectList(surveyPlanLambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(surveyPlans)) {
List<String> planIds = surveyPlans.stream().map(SurveyPlan::getId).collect(Collectors.toList());
surveyTestVOQueryWrapper.in("supervision_survey_test.plan_id", planIds);
} else {
//没有匹配的。直接返回
return new Page<>();
}
}
}
//获取当前用户部门所有同事的id查看该部门下所有的数据
List<String> colleaguesIds = userFeignClient.getColleaguesIdByUserId(RequestUtil.getUserIndex()).getData();
surveyTestVOQueryWrapper.in("supervision_survey_test.Create_By", colleaguesIds)
.eq("supervision_survey_test.problem_flag", 1)
.eq("supervision_survey_test.status", FlowStatusEnum.APPROVE.getCode())
.eq("supervision_survey_test.state", DataStateEnum.ENABLE.getCode())
.orderByDesc("supervision_survey_test.Update_Time");
Page<SurveyTestVO> surveyTestVOPage = this.baseMapper.surveyTestPage(new Page<>(PageFactory.getPageNum(surveyTestQueryParam), PageFactory.getPageSize(surveyTestQueryParam)), surveyTestVOQueryWrapper);
List<SurveyTestVO> records = surveyTestVOPage.getRecords();
if (CollectionUtil.isNotEmpty(records)) {
for (SurveyTestVO record : records) {
//回显部门名称
record.setDeptName(deptFeignClient.getDeptById(record.getDeptId()).getData().getName());
//回显变电站名称
if (record.getCustomSubstationFlag() == 0) {
//关联台账内的变电站名称
String substation = record.getSubstation();
record.setSubstationName(lineFeignClient.getSubstationInfo(substation).getData().getName());
} else {
record.setSubstationName(record.getSubstation());
}
}
}
return surveyTestVOPage;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String addSurveyTest(SurveyTestParam surveyTestParam) {
@@ -211,4 +283,46 @@ public class SurveyTestServiceImpl extends ServiceImpl<SurveyTestMapper, SurveyT
}
return surveyTestVO;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void initiateWarningLeaflet(String id) {
SurveyTestVO surveyTestVO = this.getVOById(id);
/*
* 1、预告警单名称此处暂时用普测计划名称+变电站名称组成预告警单名
* 2、预告警编号暂时随机by yxb
* 3、问题类型1技术监督管理2在线监测超标问题3用户投诉4现场测试超标此处是现场测试超标
* 4、对应问题源id用于查询详细数据
* 5、单子类型1预警单2告警单
* 6、问题详细描述
* */
warningLeafletService.createLeaflet(
surveyTestVO.getPlanName().concat(StrPool.UNDERLINE).concat(surveyTestVO.getSubstationName()),
IdWorker.get32UUID(),
id,
ProblemTypeEnum.SITE_TEST.getCode(),
LeafletTypeEnum.ALARM.getCode(),
assembleIssueDetail(surveyTestVO)
);
//将当前的测试数据改为已告警
this.lambdaUpdate().eq(SurveyTest::getId,id).set(SurveyTest::getInitiateWarningFlag,1).update();
}
/**
* 组装谐波普测的问题
* 格式planCreateTime发起的planName普测计划由负责人leader测试后于planComplateTime完成其中subName在本次普测计划测试中存在电能质量问题详细请查看附件
*/
private String assembleIssueDetail(SurveyTestVO surveyTestVO) {
return "变电站:".concat(surveyTestVO.getSubstationName())
.concat("")
.concat(LocalDateTimeUtil.format(surveyTestVO.getCreateTime(), DatePattern.CHINESE_DATE_PATTERN))
.concat("发起的")
.concat(surveyTestVO.getPlanName())
.concat("普测计划,由负责人")
.concat(surveyTestVO.getCompleteBy())
.concat("测试后,于")
.concat(LocalDateTimeUtil.format(surveyTestVO.getCompleteTime(), DatePattern.CHINESE_DATE_PATTERN))
.concat("完成变电站电能质量测试,")
.concat("在本次普测计划测试中存在电能质量问题,详细请查看问题附件");
}
}