设备监控实时数据相关接口调整(格式与前端不兼容)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.njcn.csharmonic.offline.constant;
|
||||
|
||||
public interface OfflineConstant {
|
||||
|
||||
String COMTRADE = "comtrade";
|
||||
|
||||
String MIN = "min";
|
||||
|
||||
String LOG = "log";
|
||||
|
||||
String BYTETODATA_FAIL = "字节数组转结果集失败";
|
||||
|
||||
String DATATOBYTE_FAIL = "结果集转字节数组失败";
|
||||
|
||||
String BIN = ".bin";
|
||||
|
||||
String CFG = ".cfg";
|
||||
|
||||
}
|
||||
@@ -70,39 +70,39 @@ public class AnalyseComtradeCfg {
|
||||
List<PqdData> pqdData = new ArrayList<>();
|
||||
|
||||
HashMap hashMapA = new HashMap<>();
|
||||
hashMapA.put("phasic_type","A");
|
||||
hashMapA.put("value_type",valueType);
|
||||
hashMapA.put("phaseType","A");
|
||||
hashMapA.put("valueType",valueType);
|
||||
hashMapA.put("time",dateTime.toInstant());
|
||||
|
||||
HashMap hashMapB = new HashMap<>();
|
||||
hashMapB.put("phasic_type","B");
|
||||
hashMapB.put("value_type",valueType);
|
||||
hashMapB.put("phaseType","B");
|
||||
hashMapB.put("valueType",valueType);
|
||||
hashMapB.put("time",dateTime.toInstant());
|
||||
|
||||
HashMap hashMapC = new HashMap<>();
|
||||
hashMapC.put("phasic_type","C");
|
||||
hashMapC.put("value_type",valueType);
|
||||
hashMapC.put("phaseType","C");
|
||||
hashMapC.put("valueType",valueType);
|
||||
hashMapC.put("time",dateTime.toInstant());
|
||||
|
||||
HashMap hashMapM = new HashMap<>();
|
||||
hashMapM.put("phasic_type","M");
|
||||
hashMapM.put("value_type",valueType);
|
||||
hashMapM.put("phaseType","M");
|
||||
hashMapM.put("valueType",valueType);
|
||||
hashMapM.put("time",dateTime.toInstant());
|
||||
|
||||
|
||||
HashMap hashMapAB = new HashMap<>();
|
||||
hashMapAB.put("phasic_type","AB");
|
||||
hashMapAB.put("value_type",valueType);
|
||||
hashMapAB.put("phaseType","AB");
|
||||
hashMapAB.put("valueType",valueType);
|
||||
hashMapAB.put("time",dateTime.toInstant());
|
||||
|
||||
HashMap hashMapBC = new HashMap<>();
|
||||
hashMapBC.put("phasic_type","BC");
|
||||
hashMapBC.put("value_type",valueType);
|
||||
hashMapBC.put("phaseType","BC");
|
||||
hashMapBC.put("valueType",valueType);
|
||||
hashMapBC.put("time",dateTime.toInstant());
|
||||
|
||||
HashMap hashMapCA = new HashMap<>();
|
||||
hashMapCA.put("phasic_type","CA");
|
||||
hashMapCA.put("value_type",valueType);
|
||||
hashMapCA.put("phaseType","CA");
|
||||
hashMapCA.put("valueType",valueType);
|
||||
hashMapCA.put("time",dateTime.toInstant());
|
||||
|
||||
|
||||
@@ -297,17 +297,26 @@ public class AnalyseComtradeCfg {
|
||||
hashMapB.put("pq_Plt",ulFlicker[1]);
|
||||
hashMapC.put("pq_Plt",ulFlicker[2]);
|
||||
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
PqdData pqdDataA = mapper.convertValue(hashMapA, PqdData.class);
|
||||
PqdData pqdDataB = mapper.convertValue(hashMapB, PqdData.class);
|
||||
PqdData pqdDataC = mapper.convertValue(hashMapC, PqdData.class);
|
||||
PqdData pqdDataM = mapper.convertValue(hashMapM, PqdData.class);
|
||||
PqdData pqdDataAB = mapper.convertValue(hashMapAB, PqdData.class);
|
||||
PqdData pqdDataBC = mapper.convertValue(hashMapBC, PqdData.class);
|
||||
PqdData pqdDataCA = mapper.convertValue(hashMapCA, PqdData.class);
|
||||
|
||||
|
||||
|
||||
pqdData.add(pqdDataA);
|
||||
pqdData.add(pqdDataB);
|
||||
pqdData.add(pqdDataC);
|
||||
pqdData.add(pqdDataM);
|
||||
pqdData.add(pqdDataAB);
|
||||
pqdData.add(pqdDataBC);
|
||||
pqdData.add(pqdDataCA);
|
||||
|
||||
return pqdData;
|
||||
|
||||
|
||||
@@ -82,39 +82,39 @@ public class AnalyseComtradeCfg1 {
|
||||
List<PqdData> pqdData = new ArrayList<>();
|
||||
|
||||
HashMap hashMapA = new HashMap<>();
|
||||
hashMapA.put("phasic_type","A");
|
||||
hashMapA.put("value_type",valueType);
|
||||
hashMapA.put("phaseType","A");
|
||||
hashMapA.put("valueType",valueType);
|
||||
hashMapA.put("time",dateTime.toInstant());
|
||||
|
||||
HashMap hashMapB = new HashMap<>();
|
||||
hashMapB.put("phasic_type","B");
|
||||
hashMapB.put("value_type",valueType);
|
||||
hashMapB.put("phaseType","B");
|
||||
hashMapB.put("valueType",valueType);
|
||||
hashMapB.put("time",dateTime.toInstant());
|
||||
|
||||
HashMap hashMapC = new HashMap<>();
|
||||
hashMapC.put("phasic_type","C");
|
||||
hashMapC.put("value_type",valueType);
|
||||
hashMapC.put("phaseType","C");
|
||||
hashMapC.put("valueType",valueType);
|
||||
hashMapC.put("time",dateTime.toInstant());
|
||||
|
||||
HashMap hashMapM = new HashMap<>();
|
||||
hashMapM.put("phasic_type","M");
|
||||
hashMapM.put("value_type",valueType);
|
||||
hashMapM.put("phaseType","M");
|
||||
hashMapM.put("valueType",valueType);
|
||||
hashMapM.put("time",dateTime.toInstant());
|
||||
|
||||
|
||||
HashMap hashMapAB = new HashMap<>();
|
||||
hashMapAB.put("phasic_type","AB");
|
||||
hashMapAB.put("value_type",valueType);
|
||||
hashMapAB.put("phaseType","AB");
|
||||
hashMapAB.put("valueType",valueType);
|
||||
hashMapAB.put("time",dateTime.toInstant());
|
||||
|
||||
HashMap hashMapBC = new HashMap<>();
|
||||
hashMapBC.put("phasic_type","BC");
|
||||
hashMapBC.put("value_type",valueType);
|
||||
hashMapBC.put("phaseType","BC");
|
||||
hashMapBC.put("valueType",valueType);
|
||||
hashMapBC.put("time",dateTime.toInstant());
|
||||
|
||||
HashMap hashMapCA = new HashMap<>();
|
||||
hashMapCA.put("phasic_type","CA");
|
||||
hashMapCA.put("value_type",valueType);
|
||||
hashMapCA.put("phaseType","CA");
|
||||
hashMapCA.put("valueType",valueType);
|
||||
hashMapCA.put("time",dateTime.toInstant());
|
||||
|
||||
|
||||
@@ -315,11 +315,19 @@ public class AnalyseComtradeCfg1 {
|
||||
PqdData pqdDataB = mapper.convertValue(hashMapB, PqdData.class);
|
||||
PqdData pqdDataC = mapper.convertValue(hashMapC, PqdData.class);
|
||||
PqdData pqdDataM = mapper.convertValue(hashMapM, PqdData.class);
|
||||
PqdData pqdDataAB = mapper.convertValue(hashMapAB, PqdData.class);
|
||||
PqdData pqdDataBC = mapper.convertValue(hashMapBC, PqdData.class);
|
||||
PqdData pqdDataCA = mapper.convertValue(hashMapCA, PqdData.class);
|
||||
|
||||
|
||||
|
||||
pqdData.add(pqdDataA);
|
||||
pqdData.add(pqdDataB);
|
||||
pqdData.add(pqdDataC);
|
||||
pqdData.add(pqdDataM);
|
||||
pqdData.add(pqdDataAB);
|
||||
pqdData.add(pqdDataBC);
|
||||
pqdData.add(pqdDataCA);
|
||||
|
||||
return pqdData;
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ public class Response implements Serializable {
|
||||
@ApiModelProperty("文件名")
|
||||
private String filename;
|
||||
|
||||
@ApiModelProperty("解析结果状态(0-未解析 1-解析成功 2-解析失败 3-文件不存在)")
|
||||
private Integer state;
|
||||
|
||||
@ApiModelProperty("解析后数据")
|
||||
private Object obj;
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.csharmonic.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备监控-实时数据
|
||||
* </p>
|
||||
*
|
||||
* @author guofeihu
|
||||
* @since 2024-07-26
|
||||
*/
|
||||
@Data
|
||||
public class ThdDataTdVO{
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("指标分组名称")
|
||||
private String groupName;
|
||||
|
||||
@ApiModelProperty("该分组下的各个指标的谐坡次数对应值")
|
||||
private List<Map<String,Object>> thdDataVOS;
|
||||
|
||||
@ApiModelProperty("该指标下的谐坡次数对应值")
|
||||
private List<ThdDataTdVOData> thdDataTdVODatas;
|
||||
|
||||
@Data
|
||||
public static class ThdDataTdVOData extends ThdDataVO{
|
||||
|
||||
@ApiModelProperty(value = "国标限值名称")
|
||||
private String international = "国标限值";
|
||||
|
||||
@ApiModelProperty(value = "国标限值")
|
||||
private Object internationalValue;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ThdDataSpectrumVOData{
|
||||
|
||||
@ApiModelProperty(value = "指标名称")
|
||||
private String showName;
|
||||
|
||||
@ApiModelProperty(value = "国标限值")
|
||||
private List<ThdDataVO> thdDataVOS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csharmonic.service.impl;
|
||||
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csharmonic.offline.constant.OfflineConstant;
|
||||
import com.njcn.csharmonic.offline.log.Log;
|
||||
import com.njcn.csharmonic.offline.log.vo.NewTaglogbuffer;
|
||||
import com.njcn.csharmonic.offline.mincfg.AnalyseComtradeCfg;
|
||||
@@ -8,6 +9,7 @@ import com.njcn.csharmonic.offline.mincfg.tagComtradeCfg;
|
||||
import com.njcn.csharmonic.offline.vo.Response;
|
||||
import com.njcn.csharmonic.service.OfflineDataUploadService;
|
||||
import com.njcn.influx.pojo.po.cs.PqdData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -23,6 +25,7 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @createTime 2024/7/22 13:56
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OfflineDataUploadServiceImpl implements OfflineDataUploadService {
|
||||
|
||||
@@ -34,21 +37,39 @@ public class OfflineDataUploadServiceImpl implements OfflineDataUploadService {
|
||||
|
||||
List<Response> responses = new ArrayList<>();
|
||||
//min解析较为特殊需要同时解析所有文件
|
||||
if(!files.isEmpty() && "min".equals(type)){
|
||||
if(!files.isEmpty() && OfflineConstant.MIN.equals(type)){
|
||||
Response response = new Response();
|
||||
response.setFilename("min");
|
||||
List<PqdData> pqdData = AnalyseComtradeCfg.processDirectory(files);
|
||||
response.setFilename(OfflineConstant.MIN);
|
||||
List<PqdData> pqdData = null;
|
||||
try {
|
||||
pqdData = AnalyseComtradeCfg.processDirectory(files);
|
||||
} catch (Exception e) {
|
||||
log.error("min文件夹下的数据文件解析失败");
|
||||
response.setState(2);
|
||||
}
|
||||
response.setObj(pqdData);
|
||||
responses.add(response);
|
||||
}else{
|
||||
for(MultipartFile file : files){
|
||||
Response response = new Response();
|
||||
response.setFilename(file.getOriginalFilename());
|
||||
if("comtrade".equals(type) && file.getOriginalFilename().indexOf(".cfg") != -1) {
|
||||
tagComtradeCfg tagComtradeCfg = AnalyseComtradeCfg.analyseComtradeCfg(file);
|
||||
if(OfflineConstant.COMTRADE.equals(type) && file.getOriginalFilename().indexOf(OfflineConstant.CFG) != -1) {
|
||||
tagComtradeCfg tagComtradeCfg = null;
|
||||
try {
|
||||
tagComtradeCfg = AnalyseComtradeCfg.analyseComtradeCfg(file);
|
||||
} catch (Exception e) {
|
||||
log.error("当前文件:{},解析失败",file.getOriginalFilename());
|
||||
response.setState(2);
|
||||
}
|
||||
response.setObj(tagComtradeCfg);
|
||||
}else if("log".equals(type) && file.getOriginalFilename().indexOf(".bin") != -1){
|
||||
List<NewTaglogbuffer> newTaglogbuffers = Log.convertLog(file);
|
||||
}else if(OfflineConstant.LOG.equals(type) && file.getOriginalFilename().indexOf(OfflineConstant.BIN) != -1){
|
||||
List<NewTaglogbuffer> newTaglogbuffers = null;
|
||||
try {
|
||||
newTaglogbuffers = Log.convertLog(file);
|
||||
} catch (Exception e) {
|
||||
log.error("当前文件:{},解析失败",file.getOriginalFilename());
|
||||
response.setState(2);
|
||||
}
|
||||
response.setObj(newTaglogbuffers);
|
||||
}
|
||||
responses.add(response);
|
||||
@@ -59,7 +80,7 @@ public class OfflineDataUploadServiceImpl implements OfflineDataUploadService {
|
||||
bytes = baos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new BusinessException("数据集对象转字节数组失败");
|
||||
throw new BusinessException(OfflineConstant.DATATOBYTE_FAIL);
|
||||
} finally {
|
||||
oos.close();
|
||||
baos.close();
|
||||
|
||||
Reference in New Issue
Block a user