App稳态、暂态报告功能支持
This commit is contained in:
@@ -2,8 +2,14 @@ package com.njcn.advance.api;
|
||||
|
||||
import com.njcn.advance.api.fallback.EventWaveAnalysisFeignClientFallbackFactory;
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
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 io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -27,4 +33,7 @@ public interface EventWaveAnalysisFeignClient {
|
||||
*/
|
||||
@PostMapping("analysis")
|
||||
HttpResult<EntityAdvancedData> analysis(@RequestParam("eventIndex") String eventIndex);
|
||||
|
||||
@PostMapping("analysisWlEvent")
|
||||
HttpResult<EntityAdvancedData> analysisWlEvent(@RequestParam("eventIndex") String eventIndex);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ public class EventWaveAnalysisFeignClientFallbackFactory implements FallbackFact
|
||||
log.error("{}异常,降级处理,异常为:{}", "波形高级分析", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<EntityAdvancedData> analysisWlEvent(String eventIndex) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "物联测点波形高级分析异常", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +73,10 @@ public class EventAnalysisDTO {
|
||||
* 1 正常计算
|
||||
*/
|
||||
private Integer typeFlag = 1;
|
||||
|
||||
/**
|
||||
* 文件全路径
|
||||
* 适配物联的暂态事件解析 物联那边事件的路径是全路径,不需要拼接,这个参数可为空
|
||||
*/
|
||||
private String wlFilePath;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,13 @@ public class CauseStruct extends Structure {
|
||||
public static class ByValue extends CauseStruct implements Structure.ByValue {
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected List<String> getFieldOrder() { // 返回值填入的顺序
|
||||
// return Arrays.asList(new String[] { "cause", "no_cal" });
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() { // 返回值填入的顺序
|
||||
return Arrays.asList(new String[] { "cause", "no_cal" });
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList("smp_va", "smp_vb", "smp_vc", "smp_rate", "smp_len", "threshold", "cause", "no_cal");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,13 @@ public class Rect extends Structure {
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected List<String> getFieldOrder() {
|
||||
// return Arrays.asList(new String[] { "evt_num","evt_buf" });
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "evt_num","evt_buf" });
|
||||
return Arrays.asList("smp_va", "smp_vb", "smp_vc", "smp_rate", "smp_len", "evt_num", "evt_buf");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ public class EventWaveAnalysisController extends BaseController {
|
||||
|
||||
private final EventWaveAnalysisService eventWaveAnalysisService;
|
||||
|
||||
|
||||
@PostMapping("analysis")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("波形高级分析")
|
||||
@@ -43,6 +42,15 @@ public class EventWaveAnalysisController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("analysis");
|
||||
EntityAdvancedData entityAdvancedData = eventWaveAnalysisService.analysis(eventIndex);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, entityAdvancedData, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("analysisWlEvent")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("物联事件波形高级分析")
|
||||
@ApiImplicitParam(name = "eventIndex", value = "暂降事件id", required = true)
|
||||
public HttpResult<EntityAdvancedData> analysisWlEvent(@RequestParam("eventIndex") String eventIndex) {
|
||||
String methodDescribe = getMethodDescribe("analysisWlEvent");
|
||||
EntityAdvancedData entityAdvancedData = eventWaveAnalysisService.analysisWlEvent(eventIndex);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, entityAdvancedData, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,11 +48,12 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
||||
public EventAnalysisDTO analysisCauseAndType(EventAnalysisDTO eventAnalysis) {
|
||||
WaveDataDTO waveDataDTO;
|
||||
String waveName = eventAnalysis.getWaveName();
|
||||
String wlFilePath = eventAnalysis.getWlFilePath();
|
||||
String cfgPath, datPath, cfgPath2, datPath2;
|
||||
String ip = eventAnalysis.getIp();
|
||||
if (generalInfo.getBusinessWaveFileStorage() == GeneralConstant.LOCAL_DISK) {
|
||||
cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG;
|
||||
datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT;
|
||||
cfgPath = Objects.isNull(wlFilePath) ? generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG : wlFilePath + GeneralConstant.CFG;
|
||||
datPath = Objects.isNull(wlFilePath) ? generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT : wlFilePath + GeneralConstant.DAT;
|
||||
log.info("本地磁盘波形文件路径----" + cfgPath);
|
||||
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
|
||||
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
|
||||
@@ -61,11 +62,11 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
||||
}
|
||||
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 0);
|
||||
} else {
|
||||
cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
|
||||
datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT;
|
||||
cfgPath = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG : wlFilePath + GeneralConstant.CFG;
|
||||
datPath = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT : wlFilePath + GeneralConstant.DAT;
|
||||
//适配文件后缀小写
|
||||
cfgPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG.toLowerCase();
|
||||
datPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT.toLowerCase();
|
||||
cfgPath2 = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG.toLowerCase() : wlFilePath + GeneralConstant.CFG.toLowerCase();
|
||||
datPath2 = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT.toLowerCase() : wlFilePath + GeneralConstant.DAT.toLowerCase();
|
||||
log.info("文件服务器波形文件路径----" + cfgPath);
|
||||
try (
|
||||
InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath);
|
||||
@@ -127,9 +128,19 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
||||
}
|
||||
}
|
||||
String str = WriteData2File(typeDataStruct);
|
||||
String hdrPath = OssPath.WAVE_DIR + ip+StrUtil.SLASH ;
|
||||
String hdrName = waveName + GeneralConstant.HDR_LOWER;
|
||||
fileStorageUtil.uploadStreamSpecifyName(new ByteArrayInputStream(str.getBytes()),hdrPath,hdrName);
|
||||
if (Objects.isNull(wlFilePath)) {
|
||||
String hdrPath = OssPath.WAVE_DIR + ip+StrUtil.SLASH;
|
||||
String hdrName = waveName + GeneralConstant.HDR_LOWER;
|
||||
fileStorageUtil.uploadStreamSpecifyName(new ByteArrayInputStream(str.getBytes()),hdrPath,hdrName);
|
||||
} else {
|
||||
// comtrade/00:B7:8D:00:A8:7A/PQMonitor_PQM1_00100_20260204_162453_071_WAV.hdr
|
||||
String fullPath = wlFilePath + GeneralConstant.HDR_LOWER;
|
||||
int lastSlashIndex = fullPath.lastIndexOf('/');
|
||||
String hdrPath = fullPath.substring(0, lastSlashIndex + 1);
|
||||
String hdrName = fullPath.substring(lastSlashIndex + 1);
|
||||
fileStorageUtil.uploadStreamSpecifyName(new ByteArrayInputStream(str.getBytes()),hdrPath,hdrName);
|
||||
}
|
||||
|
||||
//上传HR
|
||||
eventAnalysis.setType(globalFaultType);
|
||||
} else {
|
||||
|
||||
@@ -11,4 +11,6 @@ import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
|
||||
public interface EventWaveAnalysisService {
|
||||
|
||||
EntityAdvancedData analysis(String eventIndex);
|
||||
|
||||
EntityAdvancedData analysisWlEvent(String eventIndex);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.advance.enums.EnumEvt;
|
||||
import com.njcn.advance.mapper.RmpEventAdvanceMapper;
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.*;
|
||||
|
||||
import com.njcn.advance.service.EventWaveAnalysisService;
|
||||
import com.njcn.advance.utils.*;
|
||||
import com.njcn.advance.utils.JnaCallBalance;
|
||||
import com.njcn.advance.utils.JnaCallDllOrSo;
|
||||
import com.njcn.advance.utils.Utils;
|
||||
import com.njcn.advance.utils.WaveUtils;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
@@ -26,7 +28,10 @@ import net.sf.json.JSONObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -170,17 +175,13 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
||||
causeStruct.smp_len = pitchList.size();
|
||||
causeStruct.smp_rate = (int) wavePitchData.getnOneWaveNum();
|
||||
|
||||
|
||||
String hdrStr = waveUtils.getFile(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.HDR);
|
||||
JSONObject jsonObject = JSONObject.fromObject(hdrStr);
|
||||
translateData(jsonObject, rmpEventDetailPO.getStartTime(), entityAdvancedData);
|
||||
|
||||
|
||||
if (rmpEventDetailPO.getDealFlag() != 1) {
|
||||
//如果存在三个文件但是没有调用dll/so计算
|
||||
|
||||
getDataFromDLL(rmpEventDetailPO, waveOriginalData, rect, entityAdvancedData, causeStruct);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -214,6 +215,159 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
||||
return entityAdvancedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityAdvancedData analysisWlEvent(String eventIndex) {
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
//调用方法获取暂降事件详情
|
||||
RmpEventDetailPO rmpEventDetailPO = rmpEventAdvanceMapper.selectById(eventIndex);
|
||||
EntityAdvancedData entityAdvancedData;
|
||||
|
||||
if (rmpEventDetailPO.getFileFlag() == 1) {
|
||||
//获取所有暂态原因
|
||||
List<DictData> dicDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData();
|
||||
Map<Integer, DictData> eventTypeMap = dicDataList.stream().collect(Collectors.toMap(DictData::getAlgoDescribe, Function.identity()));
|
||||
InputStream inputStreamCfg;
|
||||
InputStream inputStreamDat;
|
||||
try {
|
||||
inputStreamCfg = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath()+ GeneralConstant.CFG);
|
||||
inputStreamDat = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath() + GeneralConstant.DAT);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
inputStreamCfg = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath() + GeneralConstant.CFG.toLowerCase());
|
||||
inputStreamDat = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath() + GeneralConstant.DAT.toLowerCase());
|
||||
} catch (Exception e1) {
|
||||
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
//读取
|
||||
BufferedReader bufferedReader;
|
||||
InputStreamReader read = null;
|
||||
String strFileLine;
|
||||
byte[] array = {};
|
||||
List<String> temCfgList = new ArrayList<>();
|
||||
try {
|
||||
// 判断文件是否存在
|
||||
array = IoUtil.readBytes(inputStreamDat);
|
||||
// 考虑到编码格式
|
||||
read = new InputStreamReader(inputStreamCfg, StandardCharsets.UTF_8);
|
||||
bufferedReader = new BufferedReader(read);
|
||||
|
||||
while ((strFileLine = bufferedReader.readLine()) != null) {
|
||||
temCfgList.add(strFileLine);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (read != null) {
|
||||
read.close();
|
||||
}
|
||||
if (inputStreamDat != null) {
|
||||
inputStreamDat.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//原始波形
|
||||
WaveData waveOriginalData = getWavedata(rmpEventDetailPO, temCfgList, array, 3);
|
||||
List<List<Float>> originalList = waveOriginalData.getSunData();
|
||||
|
||||
entityAdvancedData = new EntityAdvancedData(originalList.size());
|
||||
|
||||
for (int i = 0; i < originalList.size(); i++) {
|
||||
//坐标轴
|
||||
entityAdvancedData.smp_x[i] = originalList.get(i).get(0);
|
||||
entityAdvancedData.smp_a[i] = originalList.get(i).get(1);
|
||||
entityAdvancedData.smp_b[i] = originalList.get(i).get(2);
|
||||
entityAdvancedData.smp_c[i] = originalList.get(i).get(3);
|
||||
}
|
||||
entityAdvancedData.smp_len = originalList.size();
|
||||
|
||||
//抽点方法计算波形
|
||||
WaveData wavePitchData = getWavedata(rmpEventDetailPO, temCfgList, array, 0);
|
||||
List<List<Float>> pitchList = wavePitchData.getSunData();
|
||||
|
||||
// 将获取到的数据填充到结构体内
|
||||
Rect rect = new Rect();
|
||||
CauseStruct causeStruct = new CauseStruct();
|
||||
|
||||
for (int i = 0; i < pitchList.size(); i++) {
|
||||
rect.smp_va[i] = pitchList.get(i).get(1);
|
||||
causeStruct.smp_va[i] = pitchList.get(i).get(1);
|
||||
|
||||
rect.smp_vb[i] = pitchList.get(i).get(2);
|
||||
causeStruct.smp_vb[i] = pitchList.get(i).get(2);
|
||||
|
||||
rect.smp_vc[i] = pitchList.get(i).get(3);
|
||||
causeStruct.smp_vc[i] = pitchList.get(i).get(3);
|
||||
}
|
||||
|
||||
rect.smp_len = pitchList.size();
|
||||
|
||||
//超过60s的波形直接抛异常给上面处理
|
||||
/*
|
||||
* 波形最大值计算
|
||||
*/
|
||||
int MAX_LENGTH = 128 * 3000;
|
||||
if (rect.smp_len >= MAX_LENGTH) {
|
||||
throw new BusinessException("波形超过60S");
|
||||
}
|
||||
|
||||
rect.smp_rate = (int) wavePitchData.getnOneWaveNum();
|
||||
causeStruct.smp_len = pitchList.size();
|
||||
causeStruct.smp_rate = (int) wavePitchData.getnOneWaveNum();
|
||||
|
||||
if (rmpEventDetailPO.getDealFlag() != 1) {
|
||||
//如果存在三个文件但是没有调用dll/so计算
|
||||
getDataFromDLL(rmpEventDetailPO, waveOriginalData, rect, entityAdvancedData, causeStruct);
|
||||
}
|
||||
|
||||
String hdrStr = null;
|
||||
try {
|
||||
hdrStr = waveUtils.getFile(rmpEventDetailPO.getWavePath() + GeneralConstant.HDR.toLowerCase());
|
||||
} catch (Exception e) {
|
||||
log.error("读取文件服务器波形数据异常:{}",e.getMessage());
|
||||
}
|
||||
if (hdrStr != null) {
|
||||
JSONObject jsonObject = JSONObject.fromObject(hdrStr);
|
||||
translateData(jsonObject, rmpEventDetailPO.getStartTime(), entityAdvancedData);
|
||||
}
|
||||
|
||||
// if (rmpEventDetailPO.getDealFlag() != 1) {
|
||||
// //如果存在三个文件但是没有调用dll/so计算
|
||||
// getDataFromDLL(rmpEventDetailPO, waveOriginalData, rect, entityAdvancedData, causeStruct);
|
||||
// }
|
||||
|
||||
/****************************************************************
|
||||
* 根据返回的结果计算,获取暂降类型描述
|
||||
****************************************************************/
|
||||
if (entityAdvancedData.backNumber > 0) {
|
||||
for (int i = 0; i < entityAdvancedData.backNumber; i++) {
|
||||
entityAdvancedData.sagType[i] = eventTypeMap.get(entityAdvancedData.evt_buf[i].qvvr_cata_type[0]).getName();
|
||||
switch (entityAdvancedData.evt_buf[i].qvvr_phasetype[0]) {
|
||||
case 1:
|
||||
entityAdvancedData.sagPhaseType[i] = "单相";
|
||||
break;
|
||||
case 2:
|
||||
entityAdvancedData.sagPhaseType[i] = "两相";
|
||||
break;
|
||||
case 3:
|
||||
entityAdvancedData.sagPhaseType[i] = "三相";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
|
||||
}
|
||||
log.info("高级算法波形计算" + timeInterval.interval());
|
||||
return entityAdvancedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件未进行高级算法处理:系统调用dll处理并保存结果
|
||||
@@ -358,7 +512,7 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
||||
if (StrUtil.isBlank(rmpEventDetailPOQuery.getAdvanceReason())) {
|
||||
|
||||
//暂降原因计算
|
||||
JnaCallDllOrSo jnaCallDllReason = new JnaCallBalance("qvvr_dll_cause");
|
||||
JnaCallDllOrSo jnaCallDllReason = new JnaCallBalance("qvvr_cause_dll");
|
||||
jnaCallDllReason.setPath();
|
||||
|
||||
JnaCallBalance.Balancelibrary CAUSE = JnaCallBalance.Balancelibrary.INSTANTCE;
|
||||
|
||||
@@ -169,4 +169,14 @@ public interface OssPath {
|
||||
*/
|
||||
String CONFIGURATIONNAME = "configuration.json";
|
||||
|
||||
/**
|
||||
* APP 稳态报告路径
|
||||
*/
|
||||
String APP_HARMONIC_REPORT = "app/report/harmonic/";
|
||||
|
||||
/**
|
||||
* APP 暂态报告路径
|
||||
*/
|
||||
String APP_EVENT_REPORT = "app/report/event/";
|
||||
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ public class Knife4jSwaggerConfig {
|
||||
"com.njcn.cswarn.controller",
|
||||
"com.njcn.csharmonic.controller",
|
||||
"com.njcn.cssystem.controller",
|
||||
"com.njcn.csreport.controller",
|
||||
"com.njcn.advance.controller",
|
||||
"com.njcn.stat.controller",
|
||||
"com.njcn.rt.controller",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
|
||||
import com.njcn.event.pojo.param.ExportParam;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
@@ -7,6 +8,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
@@ -24,4 +26,11 @@ public interface CommMonitorEventReportService {
|
||||
* @param index
|
||||
*/
|
||||
void createEventReport(List<String> index, HttpServletResponse response) throws IOException, InvalidFormatException;
|
||||
|
||||
/**
|
||||
* 暂态事件报告存储,返回文件路径
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
String saveStableEventReport(List<String> index, Map<String, AreaLineInfoVO> map);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,20 @@ public interface WaveService {
|
||||
*/
|
||||
WaveDataDTO getWavedata(RmpEventDetailPO eventDetail, AreaLineInfoVO line);
|
||||
|
||||
/**
|
||||
* 用于云平台设备获取波形数据
|
||||
* @param eventDetail
|
||||
* @param line
|
||||
* @return
|
||||
*/
|
||||
WaveDataDTO getWavedata2(RmpEventDetailPO eventDetail, AreaLineInfoVO line);
|
||||
|
||||
|
||||
List<EventEigDetail> eventDetailEigenvalue(String eventDetailIndex,Integer ptType);
|
||||
|
||||
/**
|
||||
* 用于云平台设备获取数据
|
||||
* @return
|
||||
*/
|
||||
List<EventEigDetail> eventDetailEigenvalue2(String eventDetailIndex,Integer ptType);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.advance.api.EventCauseFeignClient;
|
||||
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
@@ -14,12 +16,12 @@ import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import com.njcn.echarts.util.DrawPicUtil;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.pojo.dto.EventEigDetail;
|
||||
import com.njcn.event.common.pojo.dto.EventInfoDetailVO;
|
||||
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
|
||||
import com.njcn.event.common.service.CommMonitorEventReportService;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.event.common.service.EventReportService;
|
||||
import com.njcn.event.common.service.WaveService;
|
||||
import com.njcn.event.common.pojo.dto.EventInfoDetailVO;
|
||||
import com.njcn.event.common.utils.WordUtil;
|
||||
import com.njcn.event.common.utils.WordUtils;
|
||||
import com.njcn.event.file.component.WavePicComponent;
|
||||
@@ -31,6 +33,7 @@ import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
@@ -47,7 +50,9 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
@@ -80,6 +85,7 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
private final WavePicComponent wavePicComponent;
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final LineFeignClient lineFeignClient;
|
||||
private final EventCauseFeignClient eventCauseFeignClient;
|
||||
|
||||
|
||||
/**
|
||||
@@ -650,4 +656,63 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "导出暂降事件报告异常");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveStableEventReport(List<String> eventIndex, Map<String, AreaLineInfoVO> map) {
|
||||
WordUtil wordUtil = new WordUtil();
|
||||
for (String index : eventIndex) {
|
||||
RmpEventDetailPO detail = rmpEventDetailMapper.selectById(index);
|
||||
AreaLineInfoVO line = map.get(index);
|
||||
|
||||
//判断hdr文件是否存在,不存在先生成hdr文件
|
||||
String fullPath = detail.getWavePath();
|
||||
EventAnalysisDTO eventAnalysis = new EventAnalysisDTO();
|
||||
int lastSlashIndex = fullPath.lastIndexOf('/');
|
||||
eventAnalysis.setWaveName(fullPath.substring(lastSlashIndex + 1));
|
||||
eventAnalysis.setWlFilePath(fullPath);
|
||||
eventCauseFeignClient.analysisCauseAndType(eventAnalysis);
|
||||
|
||||
WaveDataDTO waveData = waveService.getWavedata2(detail, line);
|
||||
//数据筛选,如果是双路电压的话,会存在 2 个波形数据
|
||||
List<WaveDataDetail> waveDataDetails = WaveUtil.filterWaveData(waveData);
|
||||
if (ObjUtil.isNull(waveData)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "没有波形数据");
|
||||
} else {
|
||||
//获取瞬时波形
|
||||
String instantPath = wavePicComponent.generateImageShun(waveData, waveDataDetails);
|
||||
InputStream instantStream = fileStorageUtil.getFileStream(instantPath);
|
||||
String imageShun64 = cn.hutool.core.codec.Base64.encode(instantStream);
|
||||
|
||||
wordUtil.translateShun(index, imageShun64);
|
||||
//获取 rms 波形
|
||||
String rmsPath = wavePicComponent.generateImageRms(waveData, waveDataDetails);
|
||||
InputStream rmsStream = fileStorageUtil.getFileStream(rmsPath);
|
||||
String rmsShun64 = cn.hutool.core.codec.Base64.encode(rmsStream);
|
||||
wordUtil.translateRms(index, rmsShun64);
|
||||
|
||||
EventInfoDetailVO eventInfoList = new EventInfoDetailVO();
|
||||
eventInfoList.setLineName(line.getLineName());
|
||||
eventInfoList.setGdName(line.getGdName());
|
||||
eventInfoList.setBdzName(line.getSubName());
|
||||
eventInfoList.setDevName(line.getDeviceName());
|
||||
eventInfoList.setScale(line.getVoltageScale());
|
||||
eventInfoList.setIp(line.getIp());
|
||||
eventInfoList.setEventDetailIndex(detail.getEventId());
|
||||
eventInfoList.setTimeID(detail.getStartTime());
|
||||
eventInfoList.setPersistTime(detail.getDuration());
|
||||
eventInfoList.setMs(detail.getFirstMs());
|
||||
eventInfoList.setEventValue(detail.getFeatureAmplitude());
|
||||
wordUtil.setEventInfoList(index, eventInfoList);
|
||||
List<EventEigDetail> eventDetailEigenvalue = waveService.eventDetailEigenvalue2(index,line.getPtType());
|
||||
wordUtil.setEventDetailEigenvalue(index, eventDetailEigenvalue);
|
||||
}
|
||||
}
|
||||
try {
|
||||
InputStream inputStream = wordUtil.createReport2(eventIndex);
|
||||
String filePath = fileStorageUtil.uploadStream(inputStream, OssPath.APP_EVENT_REPORT, "暂降事件报告.docx");
|
||||
return filePath;
|
||||
} catch (IOException | InvalidFormatException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,43 @@ public class WaveServiceImpl implements WaveService {
|
||||
return waveDataDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaveDataDTO getWavedata2(RmpEventDetailPO eventDetail, AreaLineInfoVO line) {
|
||||
WaveDataDTO waveDataDTO = null;
|
||||
if (ObjectUtil.isNotEmpty(line)) {
|
||||
String waveName = eventDetail.getWavePath();
|
||||
if (StrUtil.isBlank(waveName)) {
|
||||
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
}
|
||||
try (
|
||||
InputStream cfgStream = fileStorageUtil.getFileStream(waveName + GeneralConstant.CFG);
|
||||
InputStream datStream = fileStorageUtil.getFileStream(waveName + GeneralConstant.DAT)
|
||||
) {
|
||||
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
}
|
||||
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
InputStream cfgStreamLower = fileStorageUtil.getFileStream(waveName + GeneralConstant.CFG_LOWER);
|
||||
InputStream datStreamLower = fileStorageUtil.getFileStream(waveName + GeneralConstant.DAT_LOWER);
|
||||
if (Objects.isNull(cfgStreamLower) || Objects.isNull(datStreamLower)) {
|
||||
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
}
|
||||
waveDataDTO = waveFileComponent.getComtrade(cfgStreamLower, datStreamLower, 1);
|
||||
} catch (Exception e1) {
|
||||
throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
|
||||
}
|
||||
}
|
||||
waveDataDTO = waveFileComponent.getValidData(waveDataDTO);
|
||||
waveDataDTO.setPtType(line.getPtType());
|
||||
waveDataDTO.setPt(line.getPt1() * 1.0 / line.getPt2());
|
||||
waveDataDTO.setCt(line.getCt1() * 1.0 / line.getCt2());
|
||||
waveDataDTO.setMonitorName(line.getLineName());
|
||||
}
|
||||
return waveDataDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventEigDetail> eventDetailEigenvalue(String eventDetailIndex,Integer ptType) {
|
||||
List<EventEigDetail> eventInfoDetails = new ArrayList<>();
|
||||
@@ -121,5 +158,42 @@ public class WaveServiceImpl implements WaveService {
|
||||
return eventInfoDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventEigDetail> eventDetailEigenvalue2(String eventDetailIndex,Integer ptType) {
|
||||
List<EventEigDetail> eventInfoDetails = new ArrayList<>();
|
||||
EntityAdvancedData entityAdvancedData = eventWaveAnalysisFeignClient.analysisWlEvent(eventDetailIndex).getData() ;
|
||||
if (entityAdvancedData.backNumber != -1) {
|
||||
for (int i = 0; i < entityAdvancedData.backNumber; i++) {
|
||||
EventEigDetail eventEigDetail = new EventEigDetail();
|
||||
eventEigDetail.setHold_time_dq(entityAdvancedData.evt_buf[i].hold_time_dq * 1000);
|
||||
eventEigDetail.setPow_a(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_a));
|
||||
eventEigDetail.setPow_b(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_b));
|
||||
eventEigDetail.setPow_c(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_c));
|
||||
|
||||
eventEigDetail.setVoltagechange_Va(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Va / 1000));
|
||||
eventEigDetail.setVoltagechange_Vb(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Vb / 1000));
|
||||
eventEigDetail.setVoltagechange_Vc(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Vc / 1000));
|
||||
|
||||
|
||||
eventEigDetail.setUa_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ua_min[0]));
|
||||
eventEigDetail.setUb_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ub_min[0]));
|
||||
eventEigDetail.setUc_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ua_min[0]));
|
||||
|
||||
eventEigDetail.setAngle_diff_ap(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_ap[0]));
|
||||
eventEigDetail.setAngle_diff_bp(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_bp[0]));
|
||||
eventEigDetail.setAngle_diff_cp(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_cp[0]));
|
||||
|
||||
eventEigDetail.setBph_max_value(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].bph_max_value[0]));
|
||||
eventEigDetail.setSagReason(entityAdvancedData.sagReason[0]);//暂降原因,暂降原因都一样
|
||||
eventEigDetail.setSagType(entityAdvancedData.sagType[i]);//暂降类型
|
||||
eventInfoDetails.add(eventEigDetail);
|
||||
eventEigDetail.setPttype(ptType);
|
||||
}
|
||||
} else {
|
||||
eventInfoDetails = null;
|
||||
}
|
||||
return eventInfoDetails;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||
import sun.misc.BASE64Decoder;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigInteger;
|
||||
@@ -152,6 +153,89 @@ public class WordUtil {
|
||||
System.out.println("11");
|
||||
}
|
||||
|
||||
public InputStream createReport2(List<String> eventIndex) throws IOException, InvalidFormatException {
|
||||
setHeadingStyle(this.document);
|
||||
|
||||
// 添加标题
|
||||
XWPFParagraph titleParagraph = getCenterParagraph(this.document);
|
||||
addLine(titleParagraph, 11);
|
||||
// 设置段落居中
|
||||
XWPFRun titleParagraphBigRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphBigRun, "宋体", 28, "000000", "暂降事件报告", true);
|
||||
addLine(titleParagraph, 17);
|
||||
XWPFRun titleParagraphDateRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphDateRun, "宋体", 16, "000000", "南京灿能电力自动化股份有限公司", false);
|
||||
addLine(titleParagraph, 1);
|
||||
titleParagraphDateRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphDateRun, "宋体", 14, "000000", "生成时间:" + getRightNow(), false);
|
||||
addLine(titleParagraph, 8);
|
||||
titleParagraph = getLeftParagraph(this.document);
|
||||
titleParagraphDateRun = titleParagraph.createRun();
|
||||
addParagraph(titleParagraphDateRun, "宋体", 10, "000000", "【申明】本公司保留对报告的修改权,恕不另行通知,敬请关注最新版本。", false);
|
||||
for (int m = 0; m < eventIndex.size(); m++) {
|
||||
String eventId = eventIndex.get(m);
|
||||
List<EventEigDetail> eventDetailEigenvaluetmp = this.eventDetailEigenvalue.get(eventId);
|
||||
String time = eventInfoList.get(eventId).getTimeID().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
createTitle(document, (m + 1) + ". " + time, "标题 1", 0, 20);
|
||||
createTitle(document, (m + 1) + "." + "1. 基本信息", "标题 2", 0, 15);
|
||||
XWPFParagraph introductionContentParagraph = getLeftParagraph(document);
|
||||
introductionContentParagraph.setIndentationFirstLine(200);
|
||||
XWPFRun introductionContentRun = introductionContentParagraph.createRun();
|
||||
addParagraph(introductionContentRun, "宋体", 11, "000000", eventInfoList.get(eventId).getGdName() + "," + eventInfoList.get(eventId).getBdzName() + ",网络参数:" + eventInfoList.get(eventId).getIp() + "," + eventInfoList.get(eventId).getLineName() + "于" + time + "发生暂降事件,特征幅值:" + (eventInfoList.get(eventId).getEventValue()) + "%,持续时间:" + eventInfoList.get(eventId).getPersistTime() + "s。", false);
|
||||
createTitle(document, (m + 1) + "." + "2. 波形图", "标题 2", 0, 15);
|
||||
createTitle(document, (m + 1) + "." + "2.1 瞬时波形图", "标题 3", 200, 11);
|
||||
for (int shun = 0; shun < listShunPic.get(eventId).size(); shun++) {
|
||||
createPic(document, "瞬时波形" + (shun), listShunPic.get(eventId).get(shun));
|
||||
}
|
||||
createTitle(document, (m + 1) + "." + "2.2 RMS 波形图", "标题 3", 200, 11);
|
||||
for (int rms = 0; rms < listRmsPic.get(eventId).size(); rms++) {
|
||||
createPic(document, "RMS 波形" + (eventId), listRmsPic.get(eventId).get(rms));
|
||||
}
|
||||
createTitle(document, (m + 1) + "." + "3. 多特征值", "标题 2", 0, 15);
|
||||
|
||||
XWPFParagraph value = getLeftParagraph(document);
|
||||
XWPFRun valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "事件总分段数:" + eventDetailEigenvaluetmp.size(), false);
|
||||
addLine(value, 1);
|
||||
|
||||
if (eventDetailEigenvaluetmp.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "暂降原因:" + eventDetailEigenvaluetmp.get(0).getSagReason(), false);
|
||||
addLine(value, 1);
|
||||
|
||||
for (int i = 0; i < eventDetailEigenvaluetmp.size(); i++) {
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "分段" + (i + 1) + "多特征值", true);
|
||||
addLine(value, 1);
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "波形起始点相位 (°):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相" + eventDetailEigenvaluetmp.get(i).getPow_a() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相" + eventDetailEigenvaluetmp.get(i).getPow_b() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相" + eventDetailEigenvaluetmp.get(i).getPow_c())), false);
|
||||
addLine(value, 1);
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "跳变段电压变化率 (V/ms):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Va() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Vb() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Vc())), false);
|
||||
addLine(value, 1);
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "相位跳变 (°):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相" + eventDetailEigenvaluetmp.get(i).getAngle_diff_ap() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相" + eventDetailEigenvaluetmp.get(i).getAngle_diff_bp() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相" + eventDetailEigenvaluetmp.get(i).getAngle_diff_cp())), false);
|
||||
addLine(value, 1);
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "不平衡度 (%):" + eventDetailEigenvaluetmp.get(i).getBph_max_value(), false);
|
||||
addLine(value, 1);
|
||||
valuex = value.createRun();
|
||||
addParagraph(valuex, "宋体", 11, "000000", "暂降类型:" + eventDetailEigenvaluetmp.get(i).getSagType(), false);
|
||||
addLine(value, 1);
|
||||
}
|
||||
addLine(value, 1);
|
||||
}
|
||||
|
||||
// 将文档写入 ByteArrayOutputStream
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
document.write(baos);
|
||||
document.close();
|
||||
// 创建 ByteArrayInputStream 并返回
|
||||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
}
|
||||
|
||||
public void createPic(XWPFDocument document, String name, byte[] base64Info) throws IOException, InvalidFormatException {
|
||||
XWPFParagraph picParagraph = getCenterParagraph(document);
|
||||
XWPFRun createRun = picParagraph.createRun();
|
||||
|
||||
@@ -190,6 +190,13 @@ spring:
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-report-boot
|
||||
uri: lb://cs-report-boot
|
||||
predicates:
|
||||
- Path=/cs-report-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
#河北国网总部调用省侧接口,路径总部统一规定
|
||||
- id: hb_pms_down
|
||||
uri: lb://harmonic-boot
|
||||
@@ -237,6 +244,7 @@ whitelist:
|
||||
- /harmonic-boot/comAccess/getComAccessData
|
||||
- /harmonic-boot/harmonic/getHistoryResult
|
||||
- /event-boot/transient/getTransientAnalyseWave
|
||||
# - /**
|
||||
#开始
|
||||
# - /advance-boot/**
|
||||
# - /device-boot/**
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.njcn.harmonic.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据公共工具类
|
||||
*
|
||||
@@ -7,6 +13,7 @@ package com.njcn.harmonic.utils;
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/10/14 - 10:07
|
||||
*/
|
||||
|
||||
public class PublicDataUtils {
|
||||
/**
|
||||
* 功能:下划线命名转驼峰命名
|
||||
@@ -27,4 +34,40 @@ public class PublicDataUtils {
|
||||
}
|
||||
return under;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算指定月份的第一天 (格式:yyyy-MM-dd)
|
||||
* @param monthStr 月份字符串,格式为 yyyy-MM
|
||||
* @return 月份第一天的日期字符串
|
||||
*/
|
||||
public static String calculateMonthStart(String monthStr) {
|
||||
if (StrUtil.isBlank(monthStr)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Date date = DateUtil.parse(monthStr, "yyyy-MM");
|
||||
Date firstDayOfMonth = DateUtil.beginOfMonth(date);
|
||||
return DateUtil.format(firstDayOfMonth, "yyyy-MM-dd");
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("时间格式不正确,请使用 yyyy-MM 格式");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算指定月份的最后一天 (格式:yyyy-MM-dd)
|
||||
* @param monthStr 月份字符串,格式为 yyyy-MM
|
||||
* @return 月份最后一天的日期字符串
|
||||
*/
|
||||
public static String calculateMonthEnd(String monthStr) {
|
||||
if (StrUtil.isBlank(monthStr)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Date date = DateUtil.parse(monthStr, "yyyy-MM");
|
||||
Date lastDayOfMonth = DateUtil.endOfMonth(date);
|
||||
return DateUtil.format(lastDayOfMonth, "yyyy-MM-dd");
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("时间格式不正确,请使用 yyyy-MM 格式");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.harmonic.common.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.harmonic.pojo.param.ReportSearchParam;
|
||||
@@ -19,6 +20,7 @@ import java.util.Map;
|
||||
* @author cdf
|
||||
* @date 2022/8/16
|
||||
*/
|
||||
@DS("sjzx")
|
||||
public interface ExcelRptTempMapper extends BaseMapper<ExcelRptTemp> {
|
||||
|
||||
Page<ReportTemplateVO> getReportTemplateListPage(Page<BaseParam> page, @Param("baseParam")BaseParam baseParam);
|
||||
|
||||
@@ -24,4 +24,10 @@ public interface CustomReportTableService {
|
||||
* @date 2022/10/18
|
||||
*/
|
||||
void getCustomReport(ReportSearchParam reportSearchParam, Map<String,String> newMap, DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 存储稳态事件报表,并返回存储路径
|
||||
*/
|
||||
String saveStableEventReport(ReportSearchParam reportSearchParam, Map<String, String> newMap, DeviceUnitCommDTO deviceUnitCommDTO);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
|
||||
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
|
||||
import com.njcn.harmonic.common.service.CustomReportTableService;
|
||||
@@ -29,6 +27,7 @@ import com.njcn.harmonic.pojo.param.ReportSearchParam;
|
||||
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
|
||||
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.enums.OssResponseEnum;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
@@ -40,13 +39,16 @@ import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
@@ -69,18 +71,9 @@ import java.util.stream.Collectors;
|
||||
public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
|
||||
private final ExcelRptTempMapper excelRptTempMapper;
|
||||
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
|
||||
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
|
||||
|
||||
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
|
||||
|
||||
private final String CELL_DATA = "celldata";
|
||||
@@ -113,8 +106,286 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveStableEventReport(ReportSearchParam reportSearchParam, Map<String, String> newMap, DeviceUnitCommDTO deviceUnitCommDTO) {
|
||||
String filePath = "";
|
||||
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(reportSearchParam.getTempId());
|
||||
if (Objects.isNull(excelRptTemp)) {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
|
||||
} else {
|
||||
if (Objects.isNull(reportSearchParam.getCustomType())) {
|
||||
filePath = this.analyzeReport2(reportSearchParam, excelRptTemp, newMap, deviceUnitCommDTO);
|
||||
}
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
/**
|
||||
private String analyzeReport2(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp,Map<String,String> newMap,DeviceUnitCommDTO deviceUnitCommDTO) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
//定义一个线程集合
|
||||
List<Future<?>> futures = new ArrayList<>();
|
||||
//指标
|
||||
List<ReportTemplateDTO> reportTemplateDTOList = new ArrayList<>();
|
||||
//限值
|
||||
List<ReportTemplateDTO> reportLimitList = new ArrayList<>();
|
||||
//台账
|
||||
List<ReportTemplateDTO> terminalList = new ArrayList<>();
|
||||
JSONArray jsonArray;
|
||||
try (InputStream fileStream = fileStorageUtil.getFileStream(excelRptTemp.getContent())) {
|
||||
jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
|
||||
parseTemplate(jsonArray, reportTemplateDTOList, reportLimitList, terminalList);
|
||||
} catch (Exception e) {
|
||||
if(e instanceof BusinessException){
|
||||
throw new BusinessException(e.getMessage());
|
||||
}else {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
|
||||
}
|
||||
}
|
||||
//查询不分相别的指标
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(), DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||
if(Objects.isNull(dictData)){
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"字典类型模板缺少!");
|
||||
}
|
||||
|
||||
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
|
||||
|
||||
Map<String, String> tMap = new HashMap<>();
|
||||
eleEpdPqdList.forEach(item->{
|
||||
String phase;
|
||||
if (Objects.isNull(PHASE_MAPPING.get(item.getPhase()))) {
|
||||
phase = item.getPhase();
|
||||
} else {
|
||||
phase = PHASE_MAPPING.get(item.getPhase());
|
||||
}
|
||||
if (ObjectUtils.isNotNull(item.getHarmStart()) && ObjectUtils.isNotNull(item.getHarmEnd())) {
|
||||
for (int i = item.getHarmStart(); i <= item.getHarmEnd() + 1; i++) {
|
||||
tMap.put((item.getOtherName() + "_" + i + phase + item.getResourcesId()).toUpperCase(), item.getPrimaryFormula());
|
||||
}
|
||||
} else {
|
||||
tMap.put((item.getOtherName() + phase + item.getResourcesId()).toUpperCase(), item.getPrimaryFormula());
|
||||
}
|
||||
});
|
||||
|
||||
eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());
|
||||
List<String> noPhaseList = eleEpdPqdList.stream().filter(it->StrUtil.isNotBlank(it.getOtherName())).map(it->it.getOtherName().toUpperCase()).collect(Collectors.toList());
|
||||
|
||||
//处理指标是否合格
|
||||
reportLimitList = new LinkedHashSet<>(reportLimitList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
|
||||
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam);
|
||||
//存放限值指标的map
|
||||
Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity()));
|
||||
|
||||
List<ReportTemplateDTO> endList = new CopyOnWriteArrayList<>();
|
||||
if (CollUtil.isNotEmpty(reportTemplateDTOList)) {
|
||||
//开始组织sql
|
||||
reportTemplateDTOList = new LinkedHashSet<>(reportTemplateDTOList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
|
||||
Map<String, List<ReportTemplateDTO>> classMap = reportTemplateDTOList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getResourceId));
|
||||
//定义存放越限指标的map
|
||||
Map<String, ReportTemplateDTO> assNoPassMap = new HashMap<>();
|
||||
classMap.forEach((classKey, templateValue) -> {
|
||||
Map<String, List<ReportTemplateDTO>> valueTypeMap = templateValue.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getStatMethod));
|
||||
//每张表开启一个独立线程查询
|
||||
futures.add(executorService.submit(() -> {
|
||||
DynamicDataSourceContextHolder.push("sjzx");
|
||||
//avg.max,min,cp95
|
||||
try {
|
||||
valueTypeMap.forEach((valueTypeKey, valueTypeVal) -> {
|
||||
//相别分组
|
||||
Map<String, List<ReportTemplateDTO>> phaseMap = valueTypeVal.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getPhase));
|
||||
phaseMap.forEach((phaseKey, phaseVal) -> {
|
||||
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
|
||||
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}finally {
|
||||
DynamicDataSourceContextHolder.poll();
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
// 等待所有任务完成
|
||||
for (Future<?> future : futures) {
|
||||
try {
|
||||
future.get(); // 这会阻塞直到任务完成或抛出异常
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
log.error("自定义报表多线程查询流程出错!错误信息{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//处理指标最终判定合格还是不合格
|
||||
dealTargetResult(assNoPassMap, limitTargetMapX, endList);
|
||||
}
|
||||
resultAssemble2(endList,reportSearchParam,newMap,deviceUnitCommDTO,jsonArray,dataMap);
|
||||
//存储自定义报表
|
||||
return saveReport(jsonArray,dataMap);
|
||||
}
|
||||
|
||||
public void resultAssemble2(List<ReportTemplateDTO> endList, ReportSearchParam reportSearchParam, Map<String, String> finalTerminalMap, DeviceUnitCommDTO deviceUnitCommDTO, JSONArray jsonArray,Map<String, Object> dataMap) {
|
||||
if (CollUtil.isNotEmpty(endList)) {
|
||||
Map<String, String> unit = this.unitMap(deviceUnitCommDTO);
|
||||
Map<String, List<ReportTemplateDTO>> assMap = (Map)endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
|
||||
jsonArray.forEach((item) -> {
|
||||
JSONObject jsonObject = (JSONObject)item;
|
||||
JSONArray itemArr = (JSONArray)jsonObject.get("celldata");
|
||||
itemArr.forEach((it) -> {
|
||||
if (Objects.nonNull(it) && !"null".equals(it.toString())) {
|
||||
JSONObject data = (JSONObject)it;
|
||||
JSONObject son = (JSONObject)data.get("v");
|
||||
if (son.containsKey("v")) {
|
||||
String v = son.getStr("v");
|
||||
String tem;
|
||||
List rDto;
|
||||
if (v.charAt(0) == '$' && v.contains("#")) {
|
||||
tem = "";
|
||||
rDto = (List)assMap.get(v.replace("$", "").toUpperCase());
|
||||
if (Objects.nonNull(rDto)) {
|
||||
tem = ((ReportTemplateDTO)rDto.get(0)).getValue();
|
||||
if (StringUtils.isBlank(tem)) {
|
||||
tem = "/";
|
||||
}
|
||||
|
||||
son.set("v", tem);
|
||||
dataMap.put(v, tem);
|
||||
if (Objects.nonNull(((ReportTemplateDTO)rDto.get(0)).getOverLimitFlag()) && ((ReportTemplateDTO)rDto.get(0)).getOverLimitFlag() == 1) {
|
||||
son.set("fc", "#990000");
|
||||
}
|
||||
}
|
||||
} else if (v.charAt(0) == '%' && v.contains("#")) {
|
||||
tem = "";
|
||||
rDto = (List)assMap.get(v.replace("%", "").toUpperCase());
|
||||
if (Objects.nonNull(rDto)) {
|
||||
tem = ((ReportTemplateDTO)rDto.get(0)).getValue();
|
||||
if (StringUtils.isBlank(tem)) {
|
||||
tem = "/";
|
||||
}
|
||||
|
||||
son.set("v", tem);
|
||||
dataMap.put(v, tem);
|
||||
if ("不合格".equals(tem)) {
|
||||
son.set("fc", "#990000");
|
||||
dataMap.put("fc", "#990000");
|
||||
}
|
||||
}
|
||||
} else if (v.charAt(0) == '&') {
|
||||
tem = v.replace("&", "").toUpperCase();
|
||||
if (finalTerminalMap.size() > 0) {
|
||||
if ("STATIS_TIME".equals(tem)) {
|
||||
String localTime = " 23:59:59";
|
||||
LocalDate localDate = LocalDateTimeUtil.parseDate(reportSearchParam.getEndTime(), "yyyy-MM-dd");
|
||||
LocalDate nowDate = LocalDate.now();
|
||||
if (nowDate.isAfter(localDate)) {
|
||||
son.set("v", reportSearchParam.getStartTime() + " 00:00:00" + "_" + reportSearchParam.getEndTime() + localTime);
|
||||
dataMap.put(v, reportSearchParam.getStartTime() + " 00:00:00" + "_" + reportSearchParam.getEndTime() + localTime);
|
||||
} else {
|
||||
localTime = " " + LocalTime.now().format(DatePattern.NORM_TIME_FORMATTER);
|
||||
son.set("v", reportSearchParam.getStartTime() + " 00:00:00" + "_" + nowDate + localTime);
|
||||
dataMap.put(v, reportSearchParam.getStartTime() + " 00:00:00" + "_" + nowDate + localTime);
|
||||
}
|
||||
} else {
|
||||
son.set("v", finalTerminalMap.getOrDefault(tem, "/"));
|
||||
dataMap.put(v, finalTerminalMap.getOrDefault(tem, "/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (v.charAt(0) == '@' && v.contains("#")) {
|
||||
tem = v.replace("@", "");
|
||||
son.set("v", unit.getOrDefault(tem, "/"));
|
||||
dataMap.put(v, unit.getOrDefault(tem, "/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private String saveReport(JSONArray jsonArray, Map<String, Object> dataMap) {
|
||||
String filePath = "";
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String sheetName = jsonObject.getStr("name");
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
|
||||
Sheet sheet = workbook.createSheet(sheetName);
|
||||
|
||||
if (data != null) {
|
||||
for (int j = 0; j < data.size(); j++) {
|
||||
Row row = sheet.createRow(j);
|
||||
JSONArray rowData = data.getJSONArray(j);
|
||||
|
||||
if (rowData != null) {
|
||||
for (int k = 0; k < rowData.size(); k++) {
|
||||
Cell cell = row.createCell(k);
|
||||
JSONObject cellObj = rowData.getJSONObject(k);
|
||||
|
||||
if (cellObj != null && !cellObj.isEmpty()) {
|
||||
Object v = cellObj.get("v");
|
||||
if (v != null) {
|
||||
Object vData = dataMap.get(v);
|
||||
if (vData != null) {
|
||||
if (vData instanceof String) {
|
||||
cell.setCellValue((String) vData);
|
||||
} else if (vData instanceof Number) {
|
||||
cell.setCellValue(((Number) vData).doubleValue());
|
||||
} else if (vData instanceof Boolean) {
|
||||
cell.setCellValue((Boolean) vData);
|
||||
} else {
|
||||
cell.setCellValue(vData.toString());
|
||||
}
|
||||
} else {
|
||||
if (v instanceof String) {
|
||||
cell.setCellValue((String) v);
|
||||
} else if (v instanceof Number) {
|
||||
cell.setCellValue(((Number) v).doubleValue());
|
||||
} else if (v instanceof Boolean) {
|
||||
cell.setCellValue((Boolean) v);
|
||||
} else {
|
||||
cell.setCellValue(v.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
workbook.write(baos);
|
||||
workbook.close();
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(OssResponseEnum.DOWNLOAD_FILE_STREAM_ERROR);
|
||||
}
|
||||
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
filePath = fileStorageUtil.uploadStream(bais, OssPath.APP_HARMONIC_REPORT, "稳态报表.xlsx");
|
||||
try {
|
||||
bais.close();
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理
|
||||
*
|
||||
* @author cdf
|
||||
|
||||
@@ -26,11 +26,11 @@ public class AppInfoSetParam {
|
||||
@ApiModelProperty(value = "设备告警")
|
||||
private Integer alarmInfo;
|
||||
|
||||
@ApiModelProperty("是否开启出厂调试0:false ;1:true")
|
||||
private Integer exFactoryBug;
|
||||
@ApiModelProperty("0:false ;1:true itic功能是否开启")
|
||||
private Integer iticFunction;
|
||||
|
||||
@ApiModelProperty("是否开启功能调试0:false ;1:true")
|
||||
private Integer functionBug;
|
||||
@ApiModelProperty("0:false ;1:true f47功能是否开启")
|
||||
private Integer f47Function;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
@@ -50,11 +50,11 @@ public class AppInfoSet {
|
||||
@ApiModelProperty("设备告警")
|
||||
private Integer alarmInfo;
|
||||
|
||||
@ApiModelProperty("是否开启出厂调试0:false ;1:true")
|
||||
private Integer exFactoryBug;
|
||||
@ApiModelProperty("0:false ;1:true itic功能是否开启")
|
||||
private Integer iticFunction;
|
||||
|
||||
@ApiModelProperty("是否开启功能调试0:false ;1:true")
|
||||
private Integer functionBug;
|
||||
@ApiModelProperty("0:false ;1:true f47功能是否开启")
|
||||
private Integer f47Function;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,11 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.pojo.po.Role;
|
||||
import com.njcn.user.pojo.po.UserRole;
|
||||
import com.njcn.user.pojo.po.app.AppInfoSet;
|
||||
import com.njcn.user.service.IAppInfoSetService;
|
||||
import com.njcn.user.service.IAppRoleService;
|
||||
import com.njcn.user.service.IRoleService;
|
||||
@@ -58,13 +56,13 @@ public class AppRoleServiceImpl implements IAppRoleService {
|
||||
LambdaUpdateWrapper<UserRole> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(UserRole::getUserId, userId).set(UserRole::getRoleId, roleByCode.getId());
|
||||
userRoleService.update(lambdaUpdateWrapper);
|
||||
if (Objects.equals(roleByCode.getCode(), AppRoleEnum.ENGINEERING_USER.getCode())) {
|
||||
iAppInfoSetService.lambdaUpdate().
|
||||
eq(AppInfoSet::getUserId, userId).
|
||||
set(AppInfoSet::getExFactoryBug, 1).
|
||||
set(AppInfoSet::getFunctionBug, 1).
|
||||
update();
|
||||
}
|
||||
// if (Objects.equals(roleByCode.getCode(), AppRoleEnum.ENGINEERING_USER.getCode())) {
|
||||
// iAppInfoSetService.lambdaUpdate().
|
||||
// eq(AppInfoSet::getUserId, userId).
|
||||
// set(AppInfoSet::getExFactoryBug, 1).
|
||||
// set(AppInfoSet::getFunctionBug, 1).
|
||||
// update();
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,10 +32,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
@@ -195,8 +192,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
||||
appInfoSet.setEventInfo(1);
|
||||
appInfoSet.setRunInfo(1);
|
||||
appInfoSet.setAlarmInfo(1);
|
||||
appInfoSet.setFunctionBug(0);
|
||||
appInfoSet.setExFactoryBug(0);
|
||||
appInfoSet.setIticFunction(0);
|
||||
appInfoSet.setF47Function(0);
|
||||
appInfoSetService.save(appInfoSet);
|
||||
//发送用户初始密码
|
||||
password = redisUtil.getStringByKey(newUser.getId());
|
||||
@@ -365,7 +362,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
||||
|
||||
@Override
|
||||
public List<User> getAdminInfo() {
|
||||
return this.lambdaQuery().eq(User::getType,1).eq(User::getState,1).list();
|
||||
return this.lambdaQuery().in(User::getType, Arrays.asList(0,1)).ne(User::getState,Arrays.asList(0,3)).list();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user