新增预警/告警事务首页以及技术监督管理接口
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.njcn.process.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
||||
import com.njcn.prepare.harmonic.pojo.po.ThsOverRunLog;
|
||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 告警/预警监测点列表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lxp
|
||||
* @since 2023-03-16
|
||||
*/
|
||||
public interface ThsOverRunLogService extends IService<ThsOverRunLog> {
|
||||
|
||||
/**
|
||||
* 保存技术监督监测点
|
||||
*
|
||||
* @param superviseParam
|
||||
* @return
|
||||
*/
|
||||
void saveOverRunLog(SuperviseParam superviseParam);
|
||||
|
||||
/**
|
||||
* 查询技术监督监测点集合
|
||||
*
|
||||
* @param supIndex
|
||||
* @return
|
||||
*/
|
||||
SuperviceRunLogVo superviseDetail(String supIndex);
|
||||
|
||||
/**
|
||||
* 更新技术监督
|
||||
*
|
||||
* @param superviseParam
|
||||
*/
|
||||
HttpResult updateSupervise(SuperviseParam superviseParam);
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.njcn.process.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import com.njcn.harmonic.pojo.vo.SourceSteadyIndicator;
|
||||
import com.njcn.harmonic.pojo.vo.ThsStrategyVo;
|
||||
import com.njcn.prepare.harmonic.pojo.dto.SuperviseDto;
|
||||
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
||||
import com.njcn.prepare.harmonic.pojo.po.ThsOverRunLog;
|
||||
import com.njcn.prepare.harmonic.pojo.po.ThsSupervise;
|
||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviseVo;
|
||||
import com.njcn.prepare.harmonic.pojo.vo.ThsSuperviseVo;
|
||||
import com.njcn.process.enums.TypeEnum;
|
||||
import com.njcn.process.pojo.po.LimitRate;
|
||||
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lxp
|
||||
* @since 2023-03-16
|
||||
*/
|
||||
public interface ThsSuperviseService extends IService<ThsSupervise> {
|
||||
/**
|
||||
* 初始化技术监督
|
||||
*/
|
||||
HttpResult<SuperviceRunLogVo> initSupervise(SuperviseParam superviseParam);
|
||||
|
||||
/**
|
||||
* 查新策略集合
|
||||
*
|
||||
* @param superviseParam
|
||||
* @return
|
||||
*/
|
||||
List<ThsStrategyVo> selectStrategyList(SuperviseParam superviseParam);
|
||||
|
||||
/**
|
||||
* 查询LimitTarget数据
|
||||
*
|
||||
* @param monitorId
|
||||
*/
|
||||
LimitRate queryLimitTargetData(String monitorId);
|
||||
|
||||
/**
|
||||
* 生成监督数据
|
||||
*
|
||||
* @param limitBoolMap
|
||||
*/
|
||||
void buildData(SourceSteadyIndicator steady, Map<String, Object> limitBoolMap, Monitor monitor, LimitRate limitRate, Integer initType, ThsSupervise thsSupervise, List<ThsOverRunLog> thsOverRunLogs);
|
||||
|
||||
/**
|
||||
* 查询策略绑定的干扰源列表或指标参数列表
|
||||
*
|
||||
* @param id
|
||||
* @param typeEnum
|
||||
* @return
|
||||
*/
|
||||
List<ThsWarnStrategyAss> queryWarnStrategyAss(String id, TypeEnum typeEnum);
|
||||
|
||||
/**
|
||||
* 生成监督数据
|
||||
*
|
||||
* @param steady
|
||||
* @param monitor
|
||||
* @return
|
||||
*/
|
||||
void buildSuperviseData(SourceSteadyIndicator steady, Monitor monitor, LimitRate limitRate, Map<String, Object> limitBoolMap, Integer initType, ThsSupervise thsSupervise, List<ThsOverRunLog> thsOverRunLogs);
|
||||
|
||||
/**
|
||||
* 生成 告警/预警监测点列表 数据
|
||||
*
|
||||
* @param steady
|
||||
* @param thsSupervise
|
||||
* @param monitor
|
||||
*/
|
||||
void buildOverRunLog(SourceSteadyIndicator steady, ThsSupervise thsSupervise, Monitor monitor, LimitRate limitRate, Map<String, Object> limitBoolMap, Integer initType, List<ThsOverRunLog> thsOverRunLogs);
|
||||
|
||||
|
||||
void deleteTodayData(String depId, Integer initType);
|
||||
|
||||
/**
|
||||
* 生成技术监督数据
|
||||
*
|
||||
* @param thsSupervise
|
||||
* @param overRunLogList
|
||||
*/
|
||||
void creatData(Dept dept, ThsSupervise thsSupervise, List<ThsOverRunLog> overRunLogList);
|
||||
|
||||
/**
|
||||
* 保存技术监督数据
|
||||
*
|
||||
* @param superviceRunLogVo
|
||||
*/
|
||||
void saveOverRunLog(SuperviceRunLogVo superviceRunLogVo);
|
||||
|
||||
/**
|
||||
* 查询技术监督列表
|
||||
*
|
||||
* @param superviseDto
|
||||
*/
|
||||
Page<SuperviseVo> querySuperviseList(SuperviseDto superviseDto);
|
||||
|
||||
/**
|
||||
* 删除技术监督
|
||||
*
|
||||
* @param superviseDto
|
||||
* @return
|
||||
*/
|
||||
HttpResult deleteSupervise(SuperviseDto superviseDto);
|
||||
|
||||
/**
|
||||
* 上传技术监督单据
|
||||
*
|
||||
* @param id
|
||||
* @param ticketType
|
||||
* @param files
|
||||
* @param response
|
||||
*/
|
||||
void uploadSuperviseTicket(String id, String supIndex, String ticketType, MultipartFile[] files, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 查询流程状态枚举列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Map<Integer, String>> queryProgressValues();
|
||||
|
||||
/**
|
||||
* 上传单据模板
|
||||
*
|
||||
* @param type
|
||||
* @param formworkType
|
||||
* @param file
|
||||
* @param response
|
||||
*/
|
||||
void uploadAlarmFormwork(Integer type, Integer formworkType, MultipartFile file, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 下载单据模板
|
||||
*
|
||||
* @param type
|
||||
* @param formworkType
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
String dowloadAlarmFormwork(Integer type, Integer formworkType, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 技术监督首页
|
||||
*
|
||||
* @param superviseDto
|
||||
* @return
|
||||
*/
|
||||
Page<ThsSuperviseVo> superviseIndex(SuperviseDto superviseDto);
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.njcn.process.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
||||
import com.njcn.prepare.harmonic.pojo.po.ThsOverRunLog;
|
||||
import com.njcn.prepare.harmonic.pojo.po.ThsSupervise;
|
||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
||||
import com.njcn.process.mapper.ThsOverRunLogMapper;
|
||||
import com.njcn.process.mapper.ThsSuperviseMapper;
|
||||
import com.njcn.process.service.ThsOverRunLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 告警/预警监测点列表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lxp
|
||||
* @since 2023-03-16
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@DS("process")
|
||||
public class ThsOverRunLogServiceImpl extends ServiceImpl<ThsOverRunLogMapper, ThsOverRunLog> implements ThsOverRunLogService {
|
||||
@Autowired
|
||||
private ThsOverRunLogMapper thsOverRunLogMapper;
|
||||
@Autowired
|
||||
private ThsSuperviseMapper thsSuperviseMapper;
|
||||
@Autowired
|
||||
private FileStorageUtil fileStorageUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveOverRunLog(SuperviseParam superviseParam) {
|
||||
this.saveBatch(superviseParam.getOverRunLog());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuperviceRunLogVo superviseDetail(String supIndex) {
|
||||
ThsSupervise thsSupervise = thsSuperviseMapper.selectOne(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, supIndex));
|
||||
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, supIndex));
|
||||
if (CollectionUtil.isNotEmpty(thsOverRunLogs)) {
|
||||
thsOverRunLogs.forEach(item -> {
|
||||
if (StringUtils.isNotBlank(item.getAlarmTicket())) {
|
||||
item.setAlarmTicket(fileStorageUtil.getFileUrl(item.getAlarmTicket()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(item.getFeedback())) {
|
||||
item.setFeedback(fileStorageUtil.getFileUrl(item.getFeedback()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(item.getTestReport())) {
|
||||
item.setTestReport(fileStorageUtil.getFileUrl(item.getTestReport()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(item.getReviseNotice())) {
|
||||
item.setReviseNotice(fileStorageUtil.getFileUrl(item.getReviseNotice()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(item.getReviseFeedback())) {
|
||||
item.setReviseFeedback(fileStorageUtil.getFileUrl(item.getReviseFeedback()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
return SuperviceRunLogVo.builder().overRunLog(thsOverRunLogs).thsSupervise(thsSupervise).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult updateSupervise(SuperviseParam superviseParam) {
|
||||
List<ThsOverRunLog> overRunLog = superviseParam.getOverRunLog();
|
||||
if (CollectionUtil.isEmpty(overRunLog)) {
|
||||
HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "监测点不能为空", null);
|
||||
}
|
||||
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, superviseParam.getSupIndex()));
|
||||
List<String> saveIds = superviseParam.getOverRunLog().stream().map(ThsOverRunLog::getId).collect(Collectors.toList());
|
||||
List<String> allIds = thsOverRunLogs.stream().map(ThsOverRunLog::getId).collect(Collectors.toList());
|
||||
allIds.removeAll(saveIds);
|
||||
thsOverRunLogMapper.delete(new LambdaQueryWrapper<ThsOverRunLog>().in(ThsOverRunLog::getId, allIds));
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,739 @@
|
||||
package com.njcn.process.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import com.njcn.harmonic.pojo.vo.SourceSteadyIndicator;
|
||||
import com.njcn.harmonic.pojo.vo.ThsStrategyVo;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.prepare.harmonic.pojo.dto.SuperviseDto;
|
||||
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
|
||||
import com.njcn.prepare.harmonic.pojo.po.ThsOverRunLog;
|
||||
import com.njcn.prepare.harmonic.pojo.po.ThsSupervise;
|
||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviceRunLogVo;
|
||||
import com.njcn.prepare.harmonic.pojo.vo.SuperviseVo;
|
||||
import com.njcn.prepare.harmonic.pojo.vo.ThsSuperviseVo;
|
||||
import com.njcn.process.annotaion.HarCurrent;
|
||||
import com.njcn.process.annotaion.HarVoltage;
|
||||
import com.njcn.process.annotaion.InterharVoltage;
|
||||
import com.njcn.process.enums.*;
|
||||
import com.njcn.process.mapper.*;
|
||||
import com.njcn.process.pojo.po.LimitRate;
|
||||
import com.njcn.process.pojo.po.ThsAlarmFormwork;
|
||||
import com.njcn.process.pojo.po.ThsWarnStrategyAss;
|
||||
import com.njcn.process.service.ThsSuperviseService;
|
||||
import com.njcn.process.utils.ReadPatientExcelUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.map.HashedMap;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lxp
|
||||
* @since 2023-03-16
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, ThsSupervise> implements ThsSuperviseService {
|
||||
|
||||
@Autowired
|
||||
private PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
|
||||
|
||||
@Autowired
|
||||
private ThsWarnStrategyMapper thsWarnStrategyMapper;
|
||||
@Autowired
|
||||
private ThsWarnStrategyAssMapper thsWarnStrategyAssMapper;
|
||||
@Autowired
|
||||
private PmsMonitorMapper pmsMonitorMapper;
|
||||
@Autowired
|
||||
private LimitRateMapper limitRateMapper;
|
||||
@Autowired
|
||||
private DicDataFeignClient dicDataFeignClient;
|
||||
@Autowired
|
||||
private ThsSuperviseMapper thsSuperviseMapper;
|
||||
@Autowired
|
||||
private ThsOverRunLogMapper thsOverRunLogMapper;
|
||||
@Autowired
|
||||
private DeptFeignClient deptFeignClient;
|
||||
@Autowired
|
||||
private FileStorageUtil fileStorageUtil;
|
||||
@Autowired
|
||||
private ThsAlarmFormworkMapper thsAlarmFormworkMapper;
|
||||
private static final String DESCRIPTION = "description";
|
||||
|
||||
@Override
|
||||
public HttpResult<SuperviceRunLogVo> initSupervise(SuperviseParam superviseParam) {
|
||||
SuperviceRunLogVo superviceRunLogVo = new SuperviceRunLogVo();
|
||||
List<ThsOverRunLog> overRunLogList = new ArrayList<>();
|
||||
if (InitTypeEnum.MANUAL.getCode().equals(superviseParam.getInitType()) && StringUtils.isBlank(superviseParam.getDeptId())) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.INVALID_PARAMETER, null, "");
|
||||
}
|
||||
List<ThsStrategyVo> thsStrategyList = this.selectStrategyList(superviseParam);
|
||||
//按部门进行分组
|
||||
if (CollectionUtil.isNotEmpty(thsStrategyList)) {
|
||||
Map<String, List<ThsStrategyVo>> deptMap = thsStrategyList.stream().collect(Collectors.groupingBy(ThsStrategyVo::getDeptId));
|
||||
for (Map.Entry<String, List<ThsStrategyVo>> entry : deptMap.entrySet()) {
|
||||
String depId = entry.getKey();
|
||||
ThsSupervise thsSupervise = new ThsSupervise();
|
||||
List<ThsStrategyVo> deptList = entry.getValue();
|
||||
List<ThsStrategyVo> oneLevel = deptList.stream().filter(r -> !GradeEnum.THREE_LEVEL.getCode().equals(r.getGrade())).collect(Collectors.toList());//一级或二级策略集合
|
||||
List<SourceSteadyIndicator> oneSourceSteadyIndicatorList = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(oneLevel)) {
|
||||
for (ThsStrategyVo oneStrategyVo : oneLevel) {
|
||||
List<ThsWarnStrategyAss> oneInterferenceSourceAsses = this.queryWarnStrategyAss(oneStrategyVo.getId(), TypeEnum.SOURCE_TYPE);//干扰源列表
|
||||
List<ThsWarnStrategyAss> oneSteadyIndicatorAsses = this.queryWarnStrategyAss(oneStrategyVo.getId(), TypeEnum.INTERFERENCE_TYPE);//干扰源列表
|
||||
List<String> oneSteadyIndicatorAssesIds = oneSteadyIndicatorAsses.stream().map(ThsWarnStrategyAss::getAssId).collect(Collectors.toList());
|
||||
//封装每一种干扰源和对应的指标
|
||||
for (ThsWarnStrategyAss oneWarnStrategyAss : oneInterferenceSourceAsses) {
|
||||
SourceSteadyIndicator build = SourceSteadyIndicator.builder().id(oneStrategyVo.getId()).operation(oneStrategyVo.getOperation())
|
||||
.interferenceSource(oneWarnStrategyAss.getAssId())
|
||||
.steadyIndicator(oneSteadyIndicatorAssesIds)
|
||||
.deptId(oneStrategyVo.getDeptId())
|
||||
.type(oneStrategyVo.getType())
|
||||
.monitorId(oneStrategyVo.getMonitorId())
|
||||
.build();
|
||||
oneSourceSteadyIndicatorList.add(build);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<ThsStrategyVo> threeLevel = deptList.stream().filter(r -> GradeEnum.THREE_LEVEL.getCode().equals(r.getGrade())).collect(Collectors.toList());//三级策略集合
|
||||
if (CollectionUtil.isNotEmpty(threeLevel)) {
|
||||
for (ThsStrategyVo threeStrategyVo : threeLevel) {
|
||||
Iterator<SourceSteadyIndicator> iterator = oneSourceSteadyIndicatorList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
SourceSteadyIndicator sourceSteady = iterator.next();
|
||||
if (sourceSteady.getType().equals(threeStrategyVo.getType())) {
|
||||
if (StringUtils.equals(threeStrategyVo.getMonitorId(), sourceSteady.getMonitorId())) {
|
||||
List<ThsWarnStrategyAss> interferenceSourceAsses = this.queryWarnStrategyAss(threeStrategyVo.getId(), TypeEnum.SOURCE_TYPE);
|
||||
//干扰源类型id
|
||||
List<String> threeInterferenceSourceIds = interferenceSourceAsses.stream().map(ThsWarnStrategyAss::getAssId).collect(Collectors.toList());
|
||||
List<ThsWarnStrategyAss> threeSteadyIndicatorAsses = this.queryWarnStrategyAss(threeStrategyVo.getId(), TypeEnum.INTERFERENCE_TYPE);
|
||||
//指标类型id
|
||||
List<String> steadyIndicatorIds = threeSteadyIndicatorAsses.stream().map(ThsWarnStrategyAss::getAssId).collect(Collectors.toList());
|
||||
for (String threeInterferenceSourceId : threeInterferenceSourceIds) {
|
||||
if (OperationEnum.AND.getCode().equals(threeStrategyVo.getOperation())) {//处理三级策略的与
|
||||
if (OperationEnum.AND.getCode().equals(sourceSteady.getOperation())) {
|
||||
if (StringUtils.equals(threeInterferenceSourceId, sourceSteady.getInterferenceSource()) &&
|
||||
steadyIndicatorIds.containsAll(sourceSteady.getSteadyIndicator())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
} else {//处理三级策略的或
|
||||
if (StringUtils.equals(threeInterferenceSourceId, sourceSteady.getInterferenceSource())) {
|
||||
if (steadyIndicatorIds.containsAll(sourceSteady.getSteadyIndicator())) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
List<String> steadyIndicator = sourceSteady.getSteadyIndicator();
|
||||
steadyIndicator.removeAll(steadyIndicatorIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(oneSourceSteadyIndicatorList)) {
|
||||
oneSourceSteadyIndicatorList.forEach(steady -> {
|
||||
Monitor monitor = pmsMonitorMapper.selectById(steady.getMonitorId());
|
||||
if (monitor != null) {
|
||||
if (StringUtils.equals(monitor.getMonitorTag(), steady.getInterferenceSource())) {//匹配该监测点属于的干扰源类型
|
||||
//查询该监测点的检测数据
|
||||
LimitRate limitRate = this.queryLimitTargetData(monitor.getId());
|
||||
//判断指标是否超标
|
||||
Map<String, Object> limitBoolMap = this.verifyLimit(limitRate, steady);
|
||||
//构建监督数据
|
||||
this.buildData(steady, limitBoolMap, monitor, limitRate, superviseParam.getInitType(), thsSupervise, overRunLogList);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
//生成技术监督数据
|
||||
HttpResult<Dept> deptById = deptFeignClient.getDeptById(depId);
|
||||
Dept dept = deptById.getData();
|
||||
if (InitTypeEnum.AUTO.getCode().equals(superviseParam.getInitType())) {
|
||||
this.creatData(dept, thsSupervise, overRunLogList);
|
||||
} else {
|
||||
this.buildSuperviseName(thsSupervise, overRunLogList, dept);
|
||||
superviceRunLogVo.setOverRunLog(overRunLogList);
|
||||
superviceRunLogVo.setThsSupervise(thsSupervise);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, superviceRunLogVo, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建技术监督名称
|
||||
*
|
||||
* @param thsSupervise
|
||||
* @param overRunLogList
|
||||
* @param dept
|
||||
*/
|
||||
private void buildSuperviseName(ThsSupervise thsSupervise, List<ThsOverRunLog> overRunLogList, Dept dept) {
|
||||
if (CollectionUtil.isNotEmpty(overRunLogList)) {
|
||||
thsSupervise.setDescription(overRunLogList.get(0).getDescription());
|
||||
String str = Arrays.asList(overRunLogList.get(0).getDescription().split(",")).get(0);
|
||||
String overItem = str.substring(0, str.indexOf("次") - 1);
|
||||
thsSupervise.setName(DateUtil.today() + dept.getName() + overRunLogList.get(0).getName() + "等" + overRunLogList.size() + "个监测点" + overItem);
|
||||
}
|
||||
}
|
||||
|
||||
//生成技术监督数据
|
||||
@DS("process")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void creatData(Dept dept, ThsSupervise thsSupervise, List<ThsOverRunLog> overRunLogList) {
|
||||
if (CollectionUtil.isNotEmpty(overRunLogList)) {
|
||||
thsSupervise.setDescription(overRunLogList.get(0).getDescription());
|
||||
String str = Arrays.asList(overRunLogList.get(0).getDescription().split(",")).get(0);
|
||||
String overItem = str.substring(0, str.indexOf("次") - 1);
|
||||
thsSupervise.setName(DateUtil.today() + dept.getName() + overRunLogList.get(0).getName() + "等" + overRunLogList.size() + "个监测点" + overItem);
|
||||
thsSuperviseMapper.insert(thsSupervise);
|
||||
for (ThsOverRunLog thsOverRunLog : overRunLogList) {
|
||||
thsOverRunLogMapper.insert(thsOverRunLog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("process")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveOverRunLog(SuperviceRunLogVo superviceRunLogVo) {
|
||||
if (CollectionUtil.isNotEmpty(superviceRunLogVo.getOverRunLog())) {
|
||||
ThsSupervise thsSupervise = superviceRunLogVo.getThsSupervise();
|
||||
HttpResult<Dept> deptById = deptFeignClient.getDeptById(thsSupervise.getDeptId());
|
||||
Dept dept = deptById.getData();
|
||||
Date date = new Date();
|
||||
thsSupervise.setCreateTime(date);
|
||||
thsSupervise.setCreateUser(RequestUtil.getUsername());
|
||||
thsSupervise.setModifyUser(RequestUtil.getUsername());
|
||||
thsSupervise.setModifyTime(date);
|
||||
thsSupervise.setSupIndex(IdUtil.simpleUUID());
|
||||
this.buildSuperviseName(thsSupervise, superviceRunLogVo.getOverRunLog(), dept);
|
||||
this.thsSuperviseMapper.insert(thsSupervise);
|
||||
for (ThsOverRunLog thsOverRunLog : superviceRunLogVo.getOverRunLog()) {
|
||||
thsOverRunLog.setCreateTime(date);
|
||||
thsOverRunLog.setSupIndex(thsSupervise.getSupIndex());
|
||||
this.thsOverRunLogMapper.insert(thsOverRunLog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SuperviseVo> querySuperviseList(SuperviseDto superviseDto) {
|
||||
Integer pageNum = PageFactory.getPageNum(superviseDto);
|
||||
Integer pageSize = PageFactory.getPageSize(superviseDto);
|
||||
Page<SuperviseVo> superviseVoPage = new Page<>(pageNum, pageSize);
|
||||
Page<SuperviseVo> page = thsSuperviseMapper.querySuperviseList(superviseVoPage, superviseDto);
|
||||
List<SuperviseVo> pageRecords = page.getRecords();
|
||||
if (CollectionUtil.isNotEmpty(pageRecords)) {
|
||||
for (SuperviseVo superviseVo : pageRecords) {
|
||||
superviseVo.setCompanyName(deptFeignClient.getDeptById(superviseVo.getDeptId()).getData().getName());
|
||||
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, superviseVo.getSupIndex()));
|
||||
if (CollectionUtil.isNotEmpty(thsOverRunLogs)) {
|
||||
List<String> alarmTickets = thsOverRunLogs.stream().map(ThsOverRunLog::getAlarmTicket).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(alarmTickets)) {
|
||||
superviseVo.setHaveAlarmticket(true);
|
||||
}
|
||||
List<String> feedbacks = thsOverRunLogs.stream().map(ThsOverRunLog::getFeedback).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(feedbacks)) {
|
||||
superviseVo.setHaveFeedback(true);
|
||||
}
|
||||
List<String> testReports = thsOverRunLogs.stream().map(ThsOverRunLog::getTestReport).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(testReports)) {
|
||||
superviseVo.setHaveTestReport(true);
|
||||
}
|
||||
List<String> reviseNotices = thsOverRunLogs.stream().map(ThsOverRunLog::getReviseNotice).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(reviseNotices)) {
|
||||
superviseVo.setHaveReviseNotice(true);
|
||||
}
|
||||
List<String> reviseFeedbacks = thsOverRunLogs.stream().map(ThsOverRunLog::getReviseFeedback).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(reviseFeedbacks)) {
|
||||
superviseVo.setHaveReviseFeedback(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setRecords(pageRecords);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult deleteSupervise(SuperviseDto superviseDto) {
|
||||
if (CollectionUtil.isNotEmpty(superviseDto.getDeleteIds())) {
|
||||
superviseDto.getDeleteIds().forEach(id -> {
|
||||
thsOverRunLogMapper.delete(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, id));
|
||||
thsSuperviseMapper.deleteById(id);
|
||||
});
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSuperviseTicket(String id, String supIndex, String ticketType, MultipartFile[] files, HttpServletResponse response) {
|
||||
ThsSupervise thsSupervise = thsSuperviseMapper.selectOne(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, supIndex).last("limit 1"));
|
||||
ThsOverRunLog thsOverRunLog = thsOverRunLogMapper.selectById(id);
|
||||
thsSupervise.setSupIndex(thsOverRunLog.getSupIndex());
|
||||
thsOverRunLog.setId(id);
|
||||
if (files != null && files.length == 1) {
|
||||
String path = fileStorageUtil.uploadMultipart(files[0], OssPath.ELECTRICITY_QUALITY);
|
||||
this.updateSuperviesData(path, thsOverRunLog, ticketType);
|
||||
} else {
|
||||
List<ThsOverRunLog> thsOverRunLogs = thsOverRunLogMapper.selectList(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, supIndex));
|
||||
this.batchUploadFile(thsSupervise, thsOverRunLogs, files, ticketType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传文件
|
||||
*
|
||||
* @param thsSupervise
|
||||
* @param thsOverRunLogs
|
||||
* @param files
|
||||
* @param ticketType
|
||||
*/
|
||||
private void batchUploadFile(ThsSupervise thsSupervise, List<ThsOverRunLog> thsOverRunLogs, MultipartFile[] files, String ticketType) {
|
||||
if (files != null && files.length > 1) {
|
||||
List<ThsOverRunLog> excelData = new ArrayList<>();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
String originalFilename = files[i].getOriginalFilename();
|
||||
String fileType = originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||
if (".xls".equalsIgnoreCase(fileType) || ".xlsx".equalsIgnoreCase(fileType)) {
|
||||
excelData = ReadPatientExcelUtil.getExcelInfo(files[i]);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isEmpty(excelData)) {
|
||||
throw new BusinessException("没有Excel文件,或Excel文件无数据!");
|
||||
}
|
||||
for (ThsOverRunLog thsOverRunLogDto : excelData) {
|
||||
for (ThsOverRunLog thsOverRunLog : thsOverRunLogs) {
|
||||
if (StringUtils.equals(thsOverRunLog.getLineIndexName(), thsOverRunLogDto.getLineIndexName()) &&
|
||||
StringUtils.equals(thsOverRunLog.getName(), thsOverRunLogDto.getName())) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
String originalFilename = files[i].getOriginalFilename();
|
||||
String filename = originalFilename.substring(0, originalFilename.lastIndexOf("."));
|
||||
if (StringUtils.equals(filename, thsOverRunLogDto.getLineIndexName())) {
|
||||
this.uploadFile(files[i], ticketType, thsOverRunLog);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void uploadFile(MultipartFile file, String ticketType, ThsOverRunLog thsOverRunLog) {
|
||||
String path = fileStorageUtil.uploadMultipart(file, OssPath.ELECTRICITY_QUALITY);
|
||||
this.updateSuperviesData(path, thsOverRunLog, ticketType);
|
||||
}
|
||||
|
||||
private void updateSuperviesData(String path, ThsOverRunLog thsOverRunLog, String ticketType) {
|
||||
TicketTypeEnum ticketTypeEnum = TicketTypeEnum.getTicketTypeEnumByCode(ticketType);
|
||||
if (ticketTypeEnum == null) {
|
||||
throw new BusinessException("上传单据参数类型错误!");
|
||||
}
|
||||
switch (ticketTypeEnum) {
|
||||
case ALARM_TICKET:
|
||||
thsOverRunLog.setAlarmTicket(path);
|
||||
break;
|
||||
case FEEDBACK:
|
||||
thsOverRunLog.setFeedback(path);
|
||||
break;
|
||||
case TEST_REPORT:
|
||||
thsOverRunLog.setTestReport(path);
|
||||
break;
|
||||
case REVISE_NOTICE:
|
||||
thsOverRunLog.setTestReport(path);
|
||||
break;
|
||||
case REVISE_FEEDBACK:
|
||||
thsOverRunLog.setReviseFeedback(path);
|
||||
break;
|
||||
}
|
||||
thsOverRunLogMapper.updateById(thsOverRunLog);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Map<Integer, String>> queryProgressValues() {
|
||||
List<Map<Integer, String>> list = new ArrayList<>();
|
||||
Arrays.asList(ProgressEnum.values()).forEach(value -> {
|
||||
Map<Integer, String> progress = new HashMap<>();
|
||||
progress.put(value.getCode(), value.getMessage());
|
||||
list.add(progress);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadAlarmFormwork(Integer type, Integer formworkType, MultipartFile file, HttpServletResponse response) {
|
||||
thsAlarmFormworkMapper.delete(new LambdaQueryWrapper<ThsAlarmFormwork>().eq(ThsAlarmFormwork::getFormworkType, formworkType)
|
||||
.eq(ThsAlarmFormwork::getType, type));
|
||||
String path = fileStorageUtil.uploadMultipart(file, OssPath.ELECTRICITY_QUALITY);
|
||||
ThsAlarmFormwork alarmFormwork = new ThsAlarmFormwork();
|
||||
alarmFormwork.setId(IdUtil.simpleUUID());
|
||||
alarmFormwork.setType(type);
|
||||
alarmFormwork.setFormworkType(formworkType);
|
||||
alarmFormwork.setPath(path);
|
||||
thsAlarmFormworkMapper.insert(alarmFormwork);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String dowloadAlarmFormwork(Integer type, Integer formworkType, HttpServletResponse response) {
|
||||
ThsAlarmFormwork thsAlarmFormwork = thsAlarmFormworkMapper.selectOne(new LambdaQueryWrapper<ThsAlarmFormwork>().eq(ThsAlarmFormwork::getFormworkType, formworkType)
|
||||
.eq(ThsAlarmFormwork::getType, type).last("limit 1"));
|
||||
return fileStorageUtil.getFileUrl(thsAlarmFormwork.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ThsSuperviseVo> superviseIndex(SuperviseDto superviseDto) {
|
||||
Integer pageNum = PageFactory.getPageNum(superviseDto);
|
||||
Integer pageSize = PageFactory.getPageSize(superviseDto);
|
||||
Page<SuperviseVo> superviseVoPage = new Page<>(pageNum, pageSize);
|
||||
Page<SuperviseVo> page = thsSuperviseMapper.querySuperviseList(superviseVoPage, superviseDto);
|
||||
List<SuperviseVo> pageRecords = page.getRecords();
|
||||
Page<ThsSuperviseVo> thsSuperviseVoPage = new Page<>(pageNum, pageSize);
|
||||
thsSuperviseVoPage.setTotal(superviseVoPage.getTotal());
|
||||
ThsSuperviseVo thsSuperviseVo = new ThsSuperviseVo();
|
||||
if (CollectionUtil.isNotEmpty(pageRecords)) {
|
||||
for (SuperviseVo superviseVo : pageRecords) {
|
||||
superviseVo.setCompanyName(deptFeignClient.getDeptById(superviseVo.getDeptId()).getData().getName());
|
||||
//处理预警类型
|
||||
Date modifyTime = superviseVo.getModifyTime();
|
||||
Long progressTime = DateUtil.between(modifyTime, new Date(), DateUnit.DAY);
|
||||
superviseVo.setProgressTime(progressTime.intValue());
|
||||
switch (ProgressEnum.getProgressEnumByCode(superviseVo.getProgress())) {
|
||||
case START:
|
||||
case ALARM_TICKET_ISSUE:
|
||||
if (progressTime >= 1) {
|
||||
superviseVo.setAlertType(AlertTypeEnum.RED.getCode());
|
||||
} else {
|
||||
superviseVo.setAlertType(AlertTypeEnum.BLACK.getCode());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (progressTime >= 10) {
|
||||
superviseVo.setAlertType(AlertTypeEnum.RED.getCode());
|
||||
} else if (progressTime >= 8) {
|
||||
superviseVo.setAlertType(AlertTypeEnum.ORANGE.getCode());
|
||||
} else if (progressTime >= 5) {
|
||||
superviseVo.setAlertType(AlertTypeEnum.YELLOW.getCode());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
thsSuperviseVo.setSuperviseVoList(pageRecords);
|
||||
//分组处理每种流程状态的数量
|
||||
Map<Integer, List<SuperviseVo>> map = pageRecords.stream().collect(Collectors.groupingBy(SuperviseVo::getProgress));
|
||||
for (Map.Entry<Integer, List<SuperviseVo>> entry : map.entrySet()) {
|
||||
Integer code = entry.getKey();
|
||||
switch (ProgressEnum.getProgressEnumByCode(code)) {
|
||||
case START:
|
||||
thsSuperviseVo.setStartNum(entry.getValue().size());
|
||||
break;
|
||||
case ALARM_TICKET_ISSUE:
|
||||
thsSuperviseVo.setAlarmTicketIssueNum(entry.getValue().size());
|
||||
break;
|
||||
case FEEDBACK_UPLOAD:
|
||||
thsSuperviseVo.setFeedbackUploadNum(entry.getValue().size());
|
||||
break;
|
||||
case TEST_REPORT:
|
||||
thsSuperviseVo.setTestReportNum(entry.getValue().size());
|
||||
break;
|
||||
case REVISE_NOTICE_ISSUE:
|
||||
thsSuperviseVo.setReviseFeedbackNum(entry.getValue().size());
|
||||
break;
|
||||
case REVISE_FEEDBACK:
|
||||
thsSuperviseVo.setReviseFeedbackNum(entry.getValue().size());
|
||||
break;
|
||||
case END:
|
||||
thsSuperviseVo.setEndNum(entry.getValue().size());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
thsSuperviseVoPage.setRecords(Collections.singletonList(thsSuperviseVo));
|
||||
return thsSuperviseVoPage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询策略列表
|
||||
*
|
||||
* @param superviseParam
|
||||
* @return
|
||||
*/
|
||||
@DS("process")
|
||||
@Override
|
||||
public List<ThsStrategyVo> selectStrategyList(SuperviseParam superviseParam) {
|
||||
return thsWarnStrategyMapper.selectStrategyList(superviseParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询策略绑定的干扰源列表或指标参数列表
|
||||
*
|
||||
* @param warnId
|
||||
* @param typeEnum
|
||||
* @return
|
||||
*/
|
||||
@DS("process")
|
||||
@Override
|
||||
public List<ThsWarnStrategyAss> queryWarnStrategyAss(String warnId, TypeEnum typeEnum) {
|
||||
return thsWarnStrategyAssMapper.selectList(new LambdaQueryWrapper<ThsWarnStrategyAss>()
|
||||
.eq(ThsWarnStrategyAss::getWarnId, warnId)
|
||||
.eq(ThsWarnStrategyAss::getType, typeEnum.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成监督数据
|
||||
*
|
||||
* @param limitBoolMap
|
||||
*/
|
||||
@Override
|
||||
public void buildData(SourceSteadyIndicator steady, Map<String, Object> limitBoolMap, Monitor monitor, LimitRate limitRate, Integer initType, ThsSupervise thsSupervise, List<ThsOverRunLog> thsOverRunLogs) {
|
||||
if (CollectionUtil.isNotEmpty(limitBoolMap)) {
|
||||
if (OperationEnum.AND.getCode().equals(steady.getOperation())) {
|
||||
for (Map.Entry<String, Object> entry : limitBoolMap.entrySet()) {
|
||||
if (entry.getValue() instanceof Boolean && !(boolean) entry.getValue()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
//构建监督数据
|
||||
this.buildSuperviseData(steady, monitor, limitRate, limitBoolMap, initType, thsSupervise, thsOverRunLogs);
|
||||
//构建告警/预警监测点列表数据
|
||||
this.buildOverRunLog(steady, thsSupervise, monitor, limitRate, limitBoolMap, initType, thsOverRunLogs);
|
||||
return;
|
||||
}
|
||||
if (OperationEnum.OR.getCode().equals(steady.getOperation())) {
|
||||
for (Map.Entry<String, Object> entry : limitBoolMap.entrySet()) {
|
||||
if (entry.getValue() instanceof Boolean && (boolean) entry.getValue()) {
|
||||
//生成监督数据
|
||||
this.buildSuperviseData(steady, monitor, limitRate, limitBoolMap, initType, thsSupervise, thsOverRunLogs);
|
||||
//生成告警/预警监测点数据
|
||||
this.buildOverRunLog(steady, thsSupervise, monitor, limitRate, limitBoolMap, initType, thsOverRunLogs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void buildSuperviseData(SourceSteadyIndicator steady, Monitor monitor, LimitRate limitRate, Map<String, Object> limitBoolMap, Integer initType, ThsSupervise thsSupervise, List<ThsOverRunLog> thsOverRunLogs) {
|
||||
if (thsSupervise != null && StringUtils.isBlank(thsSupervise.getSupIndex())) {
|
||||
thsSupervise.setSupIndex(IdUtil.simpleUUID());
|
||||
thsSupervise.setDeptId(steady.getDeptId());
|
||||
thsSupervise.setCreateTime(new Date());
|
||||
thsSupervise.setType(steady.getType());
|
||||
thsSupervise.setCreateUser(RequestUtil.getUsername());
|
||||
thsSupervise.setProgress(ProgressEnum.START.getCode());
|
||||
thsSupervise.setCreateType(initType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void buildOverRunLog(SourceSteadyIndicator steady, ThsSupervise thsSupervise, Monitor monitor, LimitRate limitRate, Map<String, Object> limitBoolMap, Integer initType, List<ThsOverRunLog> thsOverRunLogs) {
|
||||
ThsOverRunLog thsOverRunLog = new ThsOverRunLog();
|
||||
thsOverRunLog.setId(IdUtil.simpleUUID());
|
||||
thsOverRunLog.setSupIndex(thsSupervise.getSupIndex());
|
||||
thsOverRunLog.setLineIndex(monitor.getId());
|
||||
thsOverRunLog.setName(monitor.getPowerrName());
|
||||
thsOverRunLog.setUpdateTime(limitRate.getCreatTime());
|
||||
thsOverRunLog.setCreateTime(new Date());
|
||||
thsOverRunLog.setCompanyName(monitor.getOrgName());
|
||||
thsOverRunLog.setLineIndexName(monitor.getName());
|
||||
List<String> descriptionList = (List) limitBoolMap.get(DESCRIPTION);
|
||||
thsOverRunLog.setDescription(StringUtils.join(descriptionList, ","));
|
||||
|
||||
thsOverRunLogs.add(thsOverRunLog);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@DS("pms")
|
||||
public LimitRate queryLimitTargetData(String monitorId) {
|
||||
LimitRate limitRate = limitRateMapper.selectOne(new LambdaQueryWrapper<LimitRate>().eq(LimitRate::getLineId, monitorId)
|
||||
.between(LimitRate::getCreatTime,
|
||||
DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1)),
|
||||
DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1))).last("limit 1"));
|
||||
return limitRate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重复执行删除旧数据
|
||||
*
|
||||
* @param depId
|
||||
*/
|
||||
@Override
|
||||
@DS("process")
|
||||
public void deleteTodayData(String depId, Integer initType) {
|
||||
ThsSupervise thsSupervise = thsSuperviseMapper.selectOne(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getDeptId, depId)
|
||||
.eq(ThsSupervise::getCreateType, initType)
|
||||
.between(ThsSupervise::getCreateTime,
|
||||
DateUtil.beginOfDay(new Date()),
|
||||
DateUtil.endOfDay(new Date())).last("limit 1"));
|
||||
if (thsSupervise != null) {
|
||||
thsOverRunLogMapper.delete(new LambdaQueryWrapper<ThsOverRunLog>().eq(ThsOverRunLog::getSupIndex, thsSupervise.getSupIndex()));
|
||||
thsSuperviseMapper.delete(new LambdaQueryWrapper<ThsSupervise>().eq(ThsSupervise::getSupIndex, thsSupervise.getSupIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断监测数据是否超标
|
||||
*
|
||||
* @param limitRate
|
||||
* @param steady
|
||||
*/
|
||||
private Map<String, Object> verifyLimit(LimitRate limitRate, SourceSteadyIndicator steady) {
|
||||
if (limitRate != null) {
|
||||
List<String> steadyIndicator = steady.getSteadyIndicator();
|
||||
Map<String, Object> limitBoolMap = new HashedMap();
|
||||
List<String> descriptionList = new ArrayList<>();
|
||||
steadyIndicator.forEach(id -> {
|
||||
HttpResult<DictData> dicDataById = dicDataFeignClient.getDicDataById(id);
|
||||
if (CommonResponseEnum.SUCCESS.getCode().equals(dicDataById.getCode()) && dicDataById.getData() != null) {
|
||||
SteadyIndicatorEnum steadyIndicatorEnum = SteadyIndicatorEnum.getSteadyIndicatorEnumByCode(dicDataById.getData().getCode());
|
||||
if (null != steadyIndicatorEnum) {
|
||||
switch (steadyIndicatorEnum) {
|
||||
case Negative_Voltage://负序电压不平衡度
|
||||
if (limitRate.getUbalanceOvertime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Negative_Voltage.getCode(), true);
|
||||
descriptionList.add(SteadyIndicatorEnum.Negative_Voltage.getMessage().concat(limitRate.getUbalanceOvertime() + "次"));
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Negative_Voltage.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Interhar_Voltage://间谐波电压
|
||||
Integer interharVoltageOvertime = this.maxOverTime(limitRate, InterharVoltage.class);
|
||||
if (interharVoltageOvertime > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Interhar_Voltage.getCode(), true);
|
||||
descriptionList.add(SteadyIndicatorEnum.Interhar_Voltage.getMessage().concat(interharVoltageOvertime + "次"));
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Interhar_Voltage.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Neg_Current://负序电流
|
||||
if (limitRate.getINegOvertime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Neg_Current.getCode(), true);
|
||||
descriptionList.add(SteadyIndicatorEnum.Neg_Current.getMessage().concat(limitRate.getINegOvertime() + "次"));
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Neg_Current.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Fre_Deviation://频率偏差
|
||||
if (limitRate.getFreqDevOvertime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Fre_Deviation.getCode(), true);
|
||||
descriptionList.add(SteadyIndicatorEnum.Fre_Deviation.getMessage().concat(limitRate.getFreqDevOvertime() + "次"));
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Fre_Deviation.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Voltage_Dev://电压偏差
|
||||
if (limitRate.getVoltageDevOvertime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Voltage_Dev.getCode(), true);
|
||||
descriptionList.add(SteadyIndicatorEnum.Voltage_Dev.getMessage().concat(limitRate.getVoltageDevOvertime() + "次"));
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Voltage_Dev.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Har_Current://谐波电流
|
||||
Integer harCurrentOvertime = this.maxOverTime(limitRate, HarCurrent.class);
|
||||
if (harCurrentOvertime > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Har_Current.getCode(), true);
|
||||
descriptionList.add(SteadyIndicatorEnum.Har_Current.getMessage().concat(harCurrentOvertime + "次"));
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Har_Current.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Voltage_Fluc://电压波动与闪变
|
||||
if (limitRate.getFlickerOvertime() > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Voltage_Fluc.getCode(), true);
|
||||
descriptionList.add(SteadyIndicatorEnum.Voltage_Fluc.getMessage().concat(limitRate.getFlickerOvertime() + "次"));
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Voltage_Fluc.getCode(), false);
|
||||
}
|
||||
break;
|
||||
case Har_Voltage://谐波电压
|
||||
Integer harVoltageOvertime = this.maxOverTime(limitRate, HarVoltage.class);
|
||||
if (harVoltageOvertime > 0) {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Har_Voltage.getCode(), true);
|
||||
descriptionList.add(SteadyIndicatorEnum.Har_Voltage.getMessage().concat(harVoltageOvertime + "次"));
|
||||
} else {
|
||||
limitBoolMap.put(SteadyIndicatorEnum.Har_Voltage.getCode(), false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
limitBoolMap.put(DESCRIPTION, descriptionList);
|
||||
return limitBoolMap;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取越限最大值
|
||||
* @param object
|
||||
* @param annotation
|
||||
* @return
|
||||
*/
|
||||
private Integer maxOverTime(Object object, Class annotation) {
|
||||
Integer maxValue = 0;
|
||||
try {
|
||||
Class objClass = object.getClass();
|
||||
Field[] fields = objClass.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
boolean isAnon = field.isAnnotationPresent(annotation);
|
||||
if (isAnon) {
|
||||
Object objValue = field.get(object);
|
||||
if (objValue instanceof Integer) {
|
||||
if ((Integer) objValue > maxValue) {
|
||||
maxValue = (Integer) objValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取越限最大值异常:{}", e.toString());
|
||||
}
|
||||
return maxValue;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user