高级算法特征值,暂降事件范围分析代码提交
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
package com.njcn.advance.service;
|
||||
|
||||
|
||||
import com.njcn.advance.pojo.dto.BalanceInfo;
|
||||
import com.njcn.advance.pojo.param.AdvanceBaseParam;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.advance.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.advance.mapper.RmpEventAdvanceMapper;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.AdvanceEventDetailVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/6/30
|
||||
*/
|
||||
public interface EventRelevantAnalysisService extends IService<RmpEventDetailPO> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/6/30
|
||||
*/
|
||||
void processEvents(LocalDateTime startTime,LocalDateTime endTime);
|
||||
|
||||
|
||||
Page<AdvanceEventDetailVO> querySagEventsPage(BaseParam baseParam);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.njcn.advance.service;
|
||||
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/8/1
|
||||
*/
|
||||
public interface EventWaveAnalysisService {
|
||||
|
||||
EntityAdvancedData analysis(String eventIndex);
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.njcn.advance.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.njcn.advance.mapper.BalanceMapper;
|
||||
import com.njcn.advance.pojo.dto.AdvanceBaseDTO;
|
||||
import com.njcn.advance.pojo.dto.BalanceInfo;
|
||||
import com.njcn.advance.pojo.dto.QtIdx;
|
||||
import com.njcn.advance.pojo.dto.relevent.QtIdx;
|
||||
import com.njcn.advance.pojo.param.AdvanceBaseParam;
|
||||
import com.njcn.advance.service.BalanceService;
|
||||
import com.njcn.advance.utils.GetBalanceUtils;
|
||||
@@ -16,7 +14,6 @@ import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.system.pojo.enums.StatisticsEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
@@ -25,7 +22,6 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -99,7 +95,9 @@ public class BalanceServiceImpl implements BalanceService {
|
||||
balanceInfoList.add(balanceInfo);
|
||||
}
|
||||
// 打包数据传入dll/so计算结果
|
||||
|
||||
getBalanceUtils.translateData(balanceInfoList);
|
||||
|
||||
return balanceInfoList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,475 @@
|
||||
package com.njcn.advance.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||
import com.njcn.advance.mapper.RelevantMapper;
|
||||
import com.njcn.advance.mapper.RmpEventAdvanceMapper;
|
||||
import com.njcn.advance.mapper.RmpEventDetailAssMapper;
|
||||
import com.njcn.advance.pojo.dto.SagEvent;
|
||||
import com.njcn.advance.pojo.dto.relevent.*;
|
||||
import com.njcn.advance.pojo.po.PqsRelevanceLog;
|
||||
import com.njcn.advance.service.EventRelevantAnalysisService;
|
||||
|
||||
import com.njcn.advance.utils.UtilNormalization;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.event.api.RmpEventDetailFeignClient;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.AdvanceEventDetailVO;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.enums.SystemResponseEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/6/30
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanceMapper, RmpEventDetailPO> implements EventRelevantAnalysisService {
|
||||
|
||||
private final RmpEventDetailFeignClient rmpEventDetailFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final RelevantMapper relevantMapper;
|
||||
|
||||
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
||||
|
||||
private final RmpEventAdvanceMapper eventAdvanceMapper;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final RmpEventDetailAssMapper rmpEventDetailAssMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void processEvents(LocalDateTime startTime,LocalDateTime endTime) {
|
||||
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
|
||||
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.EVENT_REASON.getName(), DicDataEnum.SHORT_TROUBLE.getName()).getData();
|
||||
if (Objects.isNull(dictData)) {
|
||||
throw new BusinessException(SystemResponseEnum.ADVANCE_REASON);
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime date = LocalDateTime.now();
|
||||
HandleEvent handleEvent = new HandleEvent();
|
||||
// 分析的事件进行处理
|
||||
List<EntityGroupEvtData> baseList = handleEvent.getData(generalDeviceInfoClient,startTime,endTime);
|
||||
|
||||
// 传入的处理事件根据物理隔绝进行分组
|
||||
|
||||
List<EntityLogic> strategyList = relevantMapper.getLogic();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(strategyList)) {
|
||||
List<SagEvent> listSagEvent = new ArrayList<>();
|
||||
List<EventAssObj> listEventAssObj = new ArrayList<>();
|
||||
|
||||
Map<String, List<String>> strategyToBusBarMap = new HashMap<>();
|
||||
|
||||
Map<String, EntityMtrans> mapRedis = new HashMap<>();
|
||||
|
||||
Map<String, List<EntityLogic>> strategyMap = strategyList.stream().collect(Collectors.groupingBy(EntityLogic::getTPIndex));
|
||||
strategyMap.forEach((key, list) -> {
|
||||
List<String> before = list.stream().map(EntityLogic::getNodeBefore).distinct().collect(Collectors.toList());
|
||||
List<String> after = list.stream().map(EntityLogic::getNodeNext).distinct().collect(Collectors.toList());
|
||||
before.addAll(after);
|
||||
before = before.stream().distinct().collect(Collectors.toList());
|
||||
strategyToBusBarMap.put(key, before);
|
||||
|
||||
FinalData.NODE_NUM = before.size();
|
||||
EntityMtrans entityMtrans = new EntityMtrans();
|
||||
handleEvent.create_matrixcata(list, entityMtrans);
|
||||
|
||||
mapRedis.put(key, entityMtrans);
|
||||
});
|
||||
//TODO 是否要处理排序
|
||||
|
||||
strategyToBusBarMap.forEach((lastKey, lastVal) -> {
|
||||
int index = 1;
|
||||
List<EntityGroupEvtData> list = new ArrayList<EntityGroupEvtData>();
|
||||
for (EntityGroupEvtData entityGroupEvtData : baseList) {
|
||||
if (lastVal.contains(entityGroupEvtData.getNodePhysics()) && dictData.getId().equals(entityGroupEvtData.getSagReason())) {
|
||||
entityGroupEvtData.setNode(index++);
|
||||
list.add(entityGroupEvtData);
|
||||
}
|
||||
}
|
||||
|
||||
baseList.removeIf(entityGroupEvtData -> lastVal.contains(entityGroupEvtData.getNodePhysics()) && dictData.getId().equals(entityGroupEvtData.getSagReason()));
|
||||
|
||||
|
||||
EntityGroupEvtData[] entityGroupEvtData = new EntityGroupEvtData[list.size()];
|
||||
Collections.sort(list);
|
||||
list.toArray(entityGroupEvtData);
|
||||
|
||||
mapRedis.forEach((mKey, mVal) -> {
|
||||
if (mKey.equals(lastKey)) {
|
||||
/********************************************************************
|
||||
* 算法最多处理1000条数据,超过限制需分批处理 先将数据根据某种方式进行升序/降序排序,然后分段处理 加入循环处理
|
||||
*********************************************************************/
|
||||
int circulation = entityGroupEvtData.length % FinalData.MAX_EVT_NUM == 0
|
||||
? entityGroupEvtData.length / FinalData.MAX_EVT_NUM
|
||||
: entityGroupEvtData.length / FinalData.MAX_EVT_NUM + 1;
|
||||
|
||||
for (int i = 0; i < circulation; i++) {
|
||||
int to = 0;
|
||||
|
||||
if (i == circulation - 1) {
|
||||
to = entityGroupEvtData.length % FinalData.MAX_EVT_NUM > 0
|
||||
? entityGroupEvtData.length
|
||||
: (i + 1) * FinalData.MAX_EVT_NUM - 1;
|
||||
} else {
|
||||
to = (i + 1) * FinalData.MAX_EVT_NUM - 1;
|
||||
}
|
||||
|
||||
EntityGroupEvtData[] arrayObj = Arrays.copyOfRange(entityGroupEvtData,
|
||||
i * FinalData.MAX_EVT_NUM, to);
|
||||
EntityGroupData entityGroupData = handleEvent.translate(arrayObj, mVal);
|
||||
// 处理分析结果
|
||||
handleEvent.show_group_info(entityGroupData, listSagEvent, listEventAssObj, date);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* 事件ID不在矩阵中,结果集为基础以时标为标准进行归集处理 注意:三相与(单相/两相)互斥
|
||||
*****************************************************************************/
|
||||
disposeNonStandardData(handleEvent, baseList, listEventAssObj, listSagEvent, date);
|
||||
|
||||
|
||||
int listSize = listEventAssObj.size();
|
||||
int toIndex = 1000;
|
||||
for (int i = 0; i < listSize; i += 1000) {
|
||||
//作用为toIndex最后没有toIndex条数据则剩余几条newList中就装几条
|
||||
if (i + 1000 > listSize) {
|
||||
toIndex = listSize - i;
|
||||
}
|
||||
//分割lst
|
||||
List<EventAssObj> newList = listEventAssObj.subList(i, i + toIndex);
|
||||
//写入添加方法,需要写你的新增方法,把newList分切后的数据新增进入数据库。
|
||||
rmpEventDetailAssMapper.insertEventAssData(newList);
|
||||
}
|
||||
|
||||
List<RmpEventDetailPO> eventUpdateList = new ArrayList<>();
|
||||
for (int i = 0; i < listSagEvent.size(); i++) {
|
||||
RmpEventDetailPO rmp = new RmpEventDetailPO();
|
||||
rmp.setEventId(listSagEvent.get(i).getIndexEventDetail());
|
||||
rmp.setEventassIndex(listSagEvent.get(i).getIndexEventAss());
|
||||
rmp.setDealTime(listSagEvent.get(i).getDealTime());
|
||||
eventUpdateList.add(rmp);
|
||||
if ((i + 1) % 1000 == 0) {
|
||||
this.updateBatchById(eventUpdateList);
|
||||
eventUpdateList.clear();
|
||||
} else if (i == listSagEvent.size() - 1) {
|
||||
this.updateBatchById(eventUpdateList);
|
||||
}
|
||||
}
|
||||
|
||||
// 增加策略记录
|
||||
String describe = "用户" + RequestUtil.getUserNickname() + "进行了关联分析";
|
||||
PqsRelevanceLog entityPqsRelevance = new PqsRelevanceLog();
|
||||
entityPqsRelevance.setContentDes(describe);
|
||||
entityPqsRelevance.setState(DataStateEnum.ENABLE.getCode());
|
||||
entityPqsRelevance.setTimeId(date);
|
||||
relevantMapper.insert(entityPqsRelevance);
|
||||
|
||||
}
|
||||
|
||||
log.info("事件关联分析用时:" + timeInterval.interval() / 1000 + "秒");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<AdvanceEventDetailVO> querySagEventsPage(BaseParam baseParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* 归集结果与非矩阵事件进行比对
|
||||
**********************************************************************/
|
||||
public void disposeNonStandardData(HandleEvent handleEvent, List<EntityGroupEvtData> noDealList, List<EventAssObj> list, List<SagEvent> list2, LocalDateTime date) {
|
||||
// 如果还有未归集的数据则单独拎为单一事件处理
|
||||
for (EntityGroupEvtData entityGroupEvtData : noDealList) {
|
||||
String strUUID = IdUtil.simpleUUID();
|
||||
entityGroupEvtData.getSagEvent().setIndexEventAss(strUUID);
|
||||
entityGroupEvtData.getSagEvent().setDealTime(date);
|
||||
|
||||
List<SagEvent> dealList = new ArrayList<>();
|
||||
dealList.add(entityGroupEvtData.getSagEvent());
|
||||
handleEvent.processing(dealList, list, date);
|
||||
list2.add(entityGroupEvtData.getSagEvent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class HandleEvent {
|
||||
public EntityGroupData translate(EntityGroupEvtData entityGroupEvtData[], EntityMtrans entityMtrans) {
|
||||
// 获取测试数据的数组长度
|
||||
int test_log_num = entityGroupEvtData.length;
|
||||
|
||||
// 实例化EntityGroupData,给其中的数组分配空间
|
||||
EntityGroupData group_buf = new EntityGroupData();
|
||||
|
||||
// 填入日志
|
||||
setMatrixcata(group_buf, entityMtrans);
|
||||
create_evt_buf(entityGroupEvtData, group_buf, test_log_num);
|
||||
|
||||
UtilNormalization.sort_Tstart(group_buf); // 根据时标进行划分
|
||||
// 根据暂降类型进行划分
|
||||
for (int i = 0; i < group_buf.getGrp_all_num(); i++) {
|
||||
UtilNormalization.sort_cata(group_buf, i);
|
||||
}
|
||||
|
||||
return group_buf;
|
||||
}
|
||||
|
||||
public List<EntityGroupEvtData> getData(GeneralDeviceInfoClient generalDeviceInfoClient,LocalDateTime startTime,LocalDateTime endTime) {
|
||||
List<EntityGroupEvtData> entityGroupEvtDataList = new ArrayList<>();
|
||||
|
||||
List<DictData> advanceType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData();
|
||||
Map<String, DictData> advanceMap = advanceType.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
|
||||
List<AdvanceEventDetailVO> advanceEventDetailVOLsit = querySagEventsAll(startTime,endTime);
|
||||
|
||||
|
||||
for (int i = 0; i < advanceEventDetailVOLsit.size(); i++) { // 获取监测点线路序号
|
||||
//母线id
|
||||
String nodePhysics = advanceEventDetailVOLsit.get(i).getVoltageId();
|
||||
|
||||
// 根据暂降类型获取高级算法对应的编号
|
||||
int cata = 0;
|
||||
long ll = 0L;
|
||||
int start_time = 0;
|
||||
|
||||
if (Objects.isNull(advanceEventDetailVOLsit.get(i).getFirstType())) {
|
||||
cata = advanceMap.get(advanceEventDetailVOLsit.get(i).getAdvanceType()).getAlgoDescribe();
|
||||
ll = (long) (Timestamp.valueOf(advanceEventDetailVOLsit.get(i).getStartTime()).getTime()
|
||||
+ (advanceEventDetailVOLsit.get(i).getDuration() * 1000));
|
||||
start_time = (int) (ll / 1000);
|
||||
} else {
|
||||
cata = advanceMap.get(advanceEventDetailVOLsit.get(i).getAdvanceType()).getAlgoDescribe(); // 获取类型
|
||||
ll = (long) (Timestamp.valueOf(advanceEventDetailVOLsit.get(i).getFirstTime()).getTime()
|
||||
+ (advanceEventDetailVOLsit.get(i).getFirstMs()));
|
||||
start_time = (int) (ll / 1000);
|
||||
}
|
||||
|
||||
// 填充SagEvent对象数据
|
||||
SagEvent sagEvent = new SagEvent();
|
||||
|
||||
sagEvent.setIndexEventDetail(advanceEventDetailVOLsit.get(i).getEventId());
|
||||
sagEvent.setSagTime(advanceEventDetailVOLsit.get(i).getStartTime());
|
||||
sagEvent.setFirstTime(PubUtils.ms2Date(ll));// 必须增加,否则序列化出错
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
/*String tem = advanceEventDetailVOLsit.get(i).getFirstTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
sagEvent.setStrTime(tem + "."
|
||||
+ advanceEventDetailVOLsit.get(i).getFirstMs());*/
|
||||
sagEvent.setTime(Timestamp.valueOf(advanceEventDetailVOLsit.get(i).getStartTime()).getTime());
|
||||
sagEvent.setFirstTimeMills(ll);
|
||||
sagEvent.setMsec(advanceEventDetailVOLsit.get(i).getDuration().intValue());
|
||||
//sagEvent.setSagTime(PubUtils.ms2Date(Timestamp.valueOf(advanceEventDetailVOLsit.get(i).getFirstTime()).getTime()));
|
||||
PlantInfo plantInfo = new PlantInfo();
|
||||
plantInfo.setNameBD(advanceEventDetailVOLsit.get(i).getSubName());
|
||||
plantInfo.setNameGD(advanceEventDetailVOLsit.get(i).getGdName());
|
||||
plantInfo.setNamePoint(advanceEventDetailVOLsit.get(i).getLineId());
|
||||
sagEvent.setPlantInfo(plantInfo);
|
||||
sagEvent.setIndexPoint(advanceEventDetailVOLsit.get(i).getLineId());
|
||||
sagEvent.setCata(cata);
|
||||
|
||||
|
||||
EntityGroupEvtData entityGroupEvtData = new EntityGroupEvtData(nodePhysics, start_time, cata, -1, sagEvent, advanceEventDetailVOLsit.get(i).getAdvanceReason());
|
||||
entityGroupEvtDataList.add(entityGroupEvtData);
|
||||
}
|
||||
|
||||
return entityGroupEvtDataList;
|
||||
}
|
||||
|
||||
public void create_evt_buf(EntityGroupEvtData[] arr, EntityGroupData obj, int len) {
|
||||
System.arraycopy(arr, 0, obj.getIn_buf(), 0, arr.length);
|
||||
obj.setEvt_in_num(len);
|
||||
}
|
||||
|
||||
public void create_matrixcata(List<EntityLogic> list, EntityMtrans entityMtrans) {
|
||||
EntityLogic[] node_data = new EntityLogic[list.size()];
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
node_data[i] = list.get(i);
|
||||
}
|
||||
|
||||
int len = node_data.length;
|
||||
|
||||
UtilNormalization.matrixcata_pro(node_data, entityMtrans, len);
|
||||
}
|
||||
|
||||
public void setMatrixcata(EntityGroupData obj, EntityMtrans entityMtrans) {
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < (FinalData.MAX_CATA_NUM - 1); i++) {
|
||||
for (j = 0; j < FinalData.NODE_NUM; j++) {
|
||||
obj.getMatrixcata()[i][j] = entityMtrans.getMatrixcata1()[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void show_group_info(EntityGroupData obj, List<SagEvent> list, List<EventAssObj> assEvent, LocalDateTime date) {
|
||||
int i, j, k;
|
||||
for (i = 0; i < obj.getGrp_all_num(); i++) {
|
||||
String strUUID = IdUtil.simpleUUID();
|
||||
List<SagEvent> listTem = new ArrayList<SagEvent>();
|
||||
|
||||
for (j = 0; j < FinalData.MAX_CATA_NUM + 2; j++) {
|
||||
if (obj.getGrp_cata_num()[i][j] != 0) {
|
||||
for (k = 0; k < obj.getGrp_cata_num()[i][j]; k++) {
|
||||
obj.getGrp_cata_buf()[i][j][k].getSagEvent().setIndexEventAss(strUUID);
|
||||
obj.getGrp_cata_buf()[i][j][k].getSagEvent().setDealTime(date);
|
||||
listTem.add(obj.getGrp_cata_buf()[i][j][k].getSagEvent());
|
||||
list.add(obj.getGrp_cata_buf()[i][j][k].getSagEvent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (listTem.size() > 0) {
|
||||
processing(listTem, assEvent, date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void processing(List<SagEvent> list, List<EventAssObj> lists, LocalDateTime date) {
|
||||
// 根据暂降事件发生时间进行排序
|
||||
Collections.sort(list);
|
||||
EventAssObj eventAssObj = new EventAssObj();
|
||||
String strUUID = list.get(0).getIndexEventAss();
|
||||
|
||||
// 归一化处理数据填充
|
||||
eventAssObj.setIndexEventAss(strUUID);
|
||||
|
||||
// 事件发生时间
|
||||
eventAssObj.setTime(list.get(0).getSagTime());
|
||||
|
||||
|
||||
// 获取当前用户GUID
|
||||
eventAssObj.setIndexUser(RequestUtil.getUserIndex());
|
||||
|
||||
// 是否进行范围分析 默认未分析
|
||||
eventAssObj.setbRange(1);
|
||||
|
||||
// 更新时间
|
||||
eventAssObj.setUpdateTime(date);
|
||||
|
||||
|
||||
// 暂降事件描述
|
||||
String codeName = LocalDateTimeUtil.format(eventAssObj.getTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
String describe = "事件关联分析编号" + codeName + "共包含" + list.size() + "个事件";
|
||||
eventAssObj.setDescribe(describe);
|
||||
|
||||
eventAssObj.setList(list);
|
||||
lists.add(eventAssObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************************
|
||||
* 获取变压器信息并生成矩阵
|
||||
*************************************************************************************/
|
||||
public void getNodeInfo(HandleEvent handleEvent) {
|
||||
List<EntityLogic> list = relevantMapper.getLogic();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
Map<String, List<EntityLogic>> tfMap = list.stream().collect(Collectors.groupingBy(EntityLogic::getTPIndex));
|
||||
Map<String, List<String>> tfBusBarMap = new HashMap<>();
|
||||
|
||||
Map<String, EntityMtrans> entityMtranMap = new HashMap<>();
|
||||
|
||||
tfMap.forEach((key, val) -> {
|
||||
List<String> tem = new ArrayList<>();
|
||||
val.forEach(it -> {
|
||||
tem.add(it.getNodeBefore());
|
||||
tem.add(it.getNodeNext());
|
||||
});
|
||||
tfBusBarMap.put(key, tem);
|
||||
|
||||
EntityMtrans entityMtrans = new EntityMtrans();
|
||||
handleEvent.create_matrixcata(val, entityMtrans);
|
||||
entityMtranMap.put(key, entityMtrans);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<AdvanceEventDetailVO> querySagEventsAll(LocalDateTime startTime,LocalDateTime endTime) {
|
||||
List<String> lineIds = generalDeviceInfoClient.deptGetRunLineEvent(RequestUtil.getDeptIndex()).getData();
|
||||
if (CollUtil.isNotEmpty(lineIds)) {
|
||||
|
||||
LambdaQueryWrapper<RmpEventDetailPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.and(i -> i.isNull(RmpEventDetailPO::getEventassIndex).or().eq(RmpEventDetailPO::getEventassIndex, ""))
|
||||
.between(RmpEventDetailPO::getStartTime, startTime, endTime);
|
||||
|
||||
|
||||
List<RmpEventDetailPO> rmpEventDetailPOList = eventAdvanceMapper.selectList(lambdaQueryWrapper);
|
||||
if (CollectionUtil.isEmpty(rmpEventDetailPOList)) {
|
||||
throw new BusinessException(AdvanceResponseEnum.EVENT_EMPTY);
|
||||
}
|
||||
List<String> tempLineIds = rmpEventDetailPOList.stream().map(RmpEventDetailPO::getLineId).distinct().collect(Collectors.toList());
|
||||
|
||||
List<AreaLineInfoVO> temLine = lineFeignClient.getBaseLineAreaInfo(tempLineIds).getData();
|
||||
Map<String, AreaLineInfoVO> map = temLine.stream().collect(Collectors.toMap(AreaLineInfoVO::getLineId, Function.identity()));
|
||||
|
||||
List<AdvanceEventDetailVO> advanceEventDetailVOList = BeanUtil.copyToList(rmpEventDetailPOList, AdvanceEventDetailVO.class);
|
||||
advanceEventDetailVOList = advanceEventDetailVOList.stream().peek(item -> {
|
||||
if (map.containsKey(item.getLineId())) {
|
||||
AreaLineInfoVO areaLineInfoVO = map.get(item.getLineId());
|
||||
item.setGdName(areaLineInfoVO.getGdName());
|
||||
item.setSubName(areaLineInfoVO.getSubName());
|
||||
item.setNum(areaLineInfoVO.getNum());
|
||||
item.setVoltageId(areaLineInfoVO.getVoltageId());
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return advanceEventDetailVOList;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,828 @@
|
||||
package com.njcn.advance.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
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.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.FileUtil;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.api.RmpEventDetailFeignClient;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.oss.constant.GeneralConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/7/28
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
||||
|
||||
private final int MAXLENGTH = 128 * 3000; //波形最大值计算
|
||||
|
||||
private final RmpEventDetailFeignClient rmpEventDetailFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final GeneralInfo generalInfo;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
private final WaveUtils waveUtils;
|
||||
|
||||
private final RmpEventAdvanceMapper rmpEventAdvanceMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public EntityAdvancedData analysis(String eventIndex) {
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
//调用方法获取暂降事件详情
|
||||
RmpEventDetailPO rmpEventDetailPO = rmpEventAdvanceMapper.selectById(eventIndex);
|
||||
EntityAdvancedData entityAdvancedData = null;
|
||||
|
||||
//获取PT变比
|
||||
LineDetailDataVO lineDetailDataVO = lineFeignClient.getLineDetailData(rmpEventDetailPO.getLineId()).getData();
|
||||
|
||||
|
||||
|
||||
if (rmpEventDetailPO.getFileFlag() == 1) {
|
||||
//获取所有暂态原因
|
||||
List<DictData> dicDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_REASON.getCode()).getData();
|
||||
Map<Integer, DictData> eventReasonMap = dicDataList.stream().collect(Collectors.toMap(DictData::getAlgoDescribe, Function.identity()));
|
||||
|
||||
InputStream inputStreamCfg = null;
|
||||
InputStream inputStreamDat = null;
|
||||
try {
|
||||
inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG);
|
||||
inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
|
||||
}
|
||||
|
||||
//读取
|
||||
BufferedReader bufferedReader = null;
|
||||
InputStreamReader read = null;
|
||||
String strFileLine = null;
|
||||
byte[] array = {};
|
||||
List<String> temCfgList = new ArrayList<>();
|
||||
try {
|
||||
// 判断文件是否存在
|
||||
array = IoUtil.readBytes(inputStreamDat);
|
||||
|
||||
read = new InputStreamReader(inputStreamCfg, CharsetUtil.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).floatValue();//坐标轴
|
||||
entityAdvancedData.smp_a[i] = originalList.get(i).get(1).floatValue();
|
||||
entityAdvancedData.smp_b[i] = originalList.get(i).get(2).floatValue();
|
||||
entityAdvancedData.smp_c[i] = originalList.get(i).get(3).floatValue();
|
||||
}
|
||||
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).floatValue();
|
||||
causeStruct.smp_va[i] = pitchList.get(i).get(1).floatValue();
|
||||
|
||||
rect.smp_vb[i] = pitchList.get(i).get(2).floatValue();
|
||||
causeStruct.smp_vb[i] = pitchList.get(i).get(2).floatValue();
|
||||
|
||||
rect.smp_vc[i] = pitchList.get(i).get(3).floatValue();
|
||||
causeStruct.smp_vc[i] = pitchList.get(i).get(3).floatValue();
|
||||
}
|
||||
|
||||
rect.smp_len = pitchList.size();
|
||||
|
||||
if (rect.smp_len >= MAXLENGTH) { //超过60s的波形直接抛异常给上面处理
|
||||
throw new BusinessException("波形超过60S");
|
||||
}
|
||||
|
||||
rect.smp_rate = (int) wavePitchData.getnOneWaveNum();
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* 根据返回的结果计算,获取暂降类型描述
|
||||
****************************************************************/
|
||||
if (entityAdvancedData.backNumber > 0) {
|
||||
for (int i = 0; i < entityAdvancedData.backNumber; i++) {
|
||||
entityAdvancedData.sagType[i] = eventReasonMap.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:
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
|
||||
}
|
||||
|
||||
log.info("高级算法波形计算" + timeInterval.interval());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// 1-值调用暂降类型dll 2-两个dll都调用
|
||||
private void judgeEvt(int type, String eventIndex, WaveData waveData, Rect rect, EntityAdvancedData entityAdvancedData) {
|
||||
try {
|
||||
//getDataFromDLL(type, eventIndex, waveData, rect, entityAdvancedData);
|
||||
} catch (Exception e) {
|
||||
//eventDetailMapper.updateDealFlag(3, eventIndex); //计算失败
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @事件未进行高级算法处理:系统调用dll处理并保存结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void getDataFromDLL(RmpEventDetailPO rmpEventDetailPOQuery,WaveData waveData, Rect rect, EntityAdvancedData entityAdvancedData, CauseStruct causeStruct) {
|
||||
|
||||
if(StrUtil.isBlank(rmpEventDetailPOQuery.getAdvanceType())){
|
||||
JnaCallDllOrSo jnaCallDllOrSo = new JnaCallBalance("qvvr_dll");
|
||||
jnaCallDllOrSo.setPath();
|
||||
// 计算暂降类
|
||||
JnaCallBalance.Eventlibrary INSTANTCE = JnaCallBalance.Eventlibrary.INSTANTCE;
|
||||
INSTANTCE.qvvr_fun(rect);
|
||||
|
||||
initBackData(rect.evt_num, entityAdvancedData);
|
||||
|
||||
/**
|
||||
* @判断是否调用成功
|
||||
* @成功执行更新pqs_eventdetail操作:更新dq持续时间、暂降类型、暂降原因、总分段数目
|
||||
*/
|
||||
if (rect.evt_num > 0) {
|
||||
RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO();
|
||||
rmpEventDetailPO.setEventId(rmpEventDetailPOQuery.getEventId());
|
||||
rmpEventDetailPO.setNum(rect.evt_num);
|
||||
rmpEventDetailPO.setDqTime((double) rect.evt_buf[0].hold_time_dq);
|
||||
rmpEventDetailPO.setFirstType((Integer.toString(rect.evt_buf[0].qvvr_cata_type[0])));
|
||||
rmpEventDetailPO.setFirstTime(waveData.getFirstTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||
rmpEventDetailPO.setFirstMs((double)waveData.getFirstMs());
|
||||
|
||||
|
||||
// 排序并获取多段中最小的数据
|
||||
float[] f = new float[rect.evt_num];
|
||||
|
||||
for (int i = 0; i < rect.evt_num; i++) {
|
||||
Arrays.parallelSort(rect.evt_buf[i].u3_min, 0, Math.max(rect.evt_buf[i].u_min_num - 1, 0));
|
||||
f[i] = rect.evt_buf[i].u3_min[0];
|
||||
}
|
||||
|
||||
float min = f[0];
|
||||
int index = 0;
|
||||
|
||||
for (int len = 1; len < f.length; len++) {
|
||||
if (min - f[len] > 0) {
|
||||
index = len;
|
||||
min = f[len];
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* add by sw 返回的分段位置需根据采样率进行恢复
|
||||
********************************************************************/
|
||||
List<AnalyWaveModel.tagOneRate> list = waveData.getRatesCfg().OneRate;
|
||||
int rate = (int) waveData.getnOneWaveNum();
|
||||
int k = 0;
|
||||
int l = 0;
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (i == 0) {
|
||||
for (int j = 0; j < rect.evt_buf[0].SEG_T_num; j++) {
|
||||
if (list.get(i).nOneSample >= rate && rect.evt_buf[0].SEG_T_idx[j] < list.get(i).nSampleNum
|
||||
/ (list.get(i).nOneSample / rate)) {
|
||||
rect.evt_buf[0].SEG_T_idx[j] = (int) (rect.evt_buf[0].SEG_T_idx[j]
|
||||
* (list.get(i).nOneSample / rate));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < rect.evt_buf[0].u_min_num; j++) {
|
||||
if (list.get(i).nOneSample >= rate && rect.evt_buf[0].order_min_idx[j] < list.get(i).nSampleNum
|
||||
/ (list.get(i).nOneSample / rate)) {
|
||||
rect.evt_buf[0].order_min_idx[j] = (int) (rect.evt_buf[0].order_min_idx[j]
|
||||
* (list.get(i).nOneSample / rate));
|
||||
l++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int j = k; j < rect.evt_buf[0].SEG_T_num; j++) {
|
||||
int posb = 0;
|
||||
int pose = 0;
|
||||
int pos = 0;
|
||||
|
||||
for (int kk = 0; kk <= i; kk++) {
|
||||
pose += list.get(kk).nSampleNum / list.get(kk).nOneSample * rate;
|
||||
|
||||
if (kk < i) {
|
||||
posb += list.get(kk).nSampleNum / list.get(kk).nOneSample * rate;
|
||||
pos += list.get(kk).nSampleNum;
|
||||
}
|
||||
}
|
||||
|
||||
if (list.get(i).nOneSample >= rate
|
||||
&& rect.evt_buf[0].SEG_T_idx[j] > posb
|
||||
&& rect.evt_buf[0].SEG_T_idx[j] < pose) {
|
||||
rect.evt_buf[0].SEG_T_idx[j] = (int) ((rect.evt_buf[0].SEG_T_idx[j] - posb) * list.get(i).nOneSample / rate) + pos;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = l; j < rect.evt_buf[0].u_min_num; j++) {
|
||||
int posb = 0;
|
||||
int pose = 0;
|
||||
int pos = 0;
|
||||
|
||||
for (int kk = 0; kk <= i; kk++) {
|
||||
pose += list.get(kk).nSampleNum / list.get(kk).nOneSample * rate;
|
||||
|
||||
if (kk < i) {
|
||||
posb += list.get(kk).nSampleNum / list.get(kk).nOneSample * rate;
|
||||
pos += list.get(kk).nSampleNum;
|
||||
}
|
||||
}
|
||||
|
||||
if (list.get(i).nOneSample >= rate
|
||||
&& rect.evt_buf[0].order_min_idx[j] > posb
|
||||
&& rect.evt_buf[0].order_min_idx[j] < pose) {
|
||||
rect.evt_buf[0].order_min_idx[j] = (int) ((rect.evt_buf[0].order_min_idx[j] - posb) * list.get(i).nSampleNum / rate) + pos;
|
||||
l++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<DictData> dicDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData();
|
||||
Map<Integer, DictData> eventTypeMap = dicDataList.stream().collect(Collectors.toMap(DictData::getAlgoDescribe, Function.identity()));
|
||||
|
||||
Integer tem = rect.evt_buf[index].qvvr_cata_type[0];
|
||||
if(eventTypeMap.containsKey(tem)) {
|
||||
rmpEventDetailPO.setAdvanceType(eventTypeMap.get(tem).getId());
|
||||
}
|
||||
rmpEventDetailPO.setDealFlag(1);
|
||||
rmpEventAdvanceMapper.updateById(rmpEventDetailPO);
|
||||
//setEntityAdvanceData();
|
||||
//WriteData2File();
|
||||
//eventDetailMapper.updateDealFlag(1, eventIndex); //计算有结果
|
||||
} else if (rect.evt_num == 0) {
|
||||
//eventDetailMapper.updateDealFlag(2, eventIndex);//已计算无结果
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (StrUtil.isBlank(rmpEventDetailPOQuery.getAdvanceReason())) {
|
||||
|
||||
//暂降原因计算
|
||||
JnaCallDllOrSo jnaCallDllReason = new JnaCallBalance("qvvr_dll_cause");
|
||||
jnaCallDllReason.setPath();
|
||||
|
||||
JnaCallBalance.Balancelibrary CAUSE = JnaCallBalance.Balancelibrary.INSTANTCE;
|
||||
CAUSE.qvvr_fun_cause(causeStruct);
|
||||
|
||||
if (causeStruct.no_cal == 1) {
|
||||
causeStruct.cause = 0;
|
||||
}
|
||||
|
||||
//获取所有暂态原因
|
||||
List<DictData> dicDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_REASON.getCode()).getData();
|
||||
Map<Integer, DictData> eventReasonMap = dicDataList.stream().collect(Collectors.toMap(DictData::getAlgoDescribe, Function.identity()));
|
||||
|
||||
// 暂降原因的结果更新到数据库
|
||||
if(eventReasonMap.containsKey(causeStruct.cause)) {
|
||||
RmpEventDetailPO updateRmpEventDetailPO = new RmpEventDetailPO();
|
||||
updateRmpEventDetailPO.setEventId(rmpEventDetailPOQuery.getEventId());
|
||||
updateRmpEventDetailPO.setAdvanceReason(eventReasonMap.get(causeStruct.cause).getId());
|
||||
rmpEventAdvanceMapper.updateById(updateRmpEventDetailPO);
|
||||
entityAdvancedData.sagReason[0] = eventReasonMap.get(causeStruct.cause).getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void initBackData(int len, EntityAdvancedData entityAdvancedData) {
|
||||
len = (len == 0 ? 1 : len);
|
||||
|
||||
entityAdvancedData.evt_buf = new BackData[len];
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
entityAdvancedData.evt_buf[i] = new BackData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据暂降事件索引获取波形数据
|
||||
* 注:当前只考虑本地的波形文件
|
||||
*
|
||||
* @param rmpEventDetailPO 暂态事件
|
||||
* @param flag 抽点方式 3.全部数据 1.抽点数据
|
||||
*/
|
||||
|
||||
public WaveData getWavedata(RmpEventDetailPO rmpEventDetailPO, List<String> temCfgList, byte[] array, int flag) {
|
||||
WaveData waveData = new WaveData();
|
||||
|
||||
waveData.setEventValue(PubUtils.floatRound(2, rmpEventDetailPO.getFeatureAmplitude().floatValue() * 100));
|
||||
waveData.setPersistTime(PubUtils.floatRound(3, rmpEventDetailPO.getDuration().floatValue() / 1000));
|
||||
waveData.setTrigeTime(AnalyWave.getTimeWave());
|
||||
|
||||
|
||||
// 判断文件是否存在
|
||||
if (StrUtil.isNotBlank(rmpEventDetailPO.getWavePath())) {
|
||||
log.info(OssPath.WAVE_DIR + rmpEventDetailPO.getWavePath() + "路径下,文件找到了");
|
||||
//CFG文件路径 pathTemp
|
||||
//获取波形的瞬时值、RMS值数据
|
||||
AnalyWave analyWave = new AnalyWave();
|
||||
AnalyWaveModel.tagDataValue tagDataValue = analyWave.readComtrade(temCfgList, array, flag);
|
||||
List<List<Float>> shunWave = tagDataValue.getListWaveData();//获取瞬时波形值
|
||||
List<List<Float>> rmsWave = analyWave.showValidData(shunWave);//RMS值波形
|
||||
waveData.setnOneWaveNum(analyWave.getnOneWaveNum());
|
||||
waveData.setSunData(shunWave);
|
||||
waveData.setTmpWaveTitle(tagDataValue.getTmpWaveTitle());
|
||||
waveData.setFirstMs(analyWave.getFirstMs());
|
||||
waveData.setFirstTime(analyWave.getFirstTime());
|
||||
waveData.setRmsData(rmsWave);
|
||||
waveData.setRatesCfg(analyWave.getRatesCfg());
|
||||
/*********** Modify by yexibao ---Start **************/
|
||||
waveData.setiPhasic(tagDataValue.getiPhasic());
|
||||
/*********** Modify by yexibao ---End **************/
|
||||
List<String> tmpWaveTitle = tagDataValue.getTmpWaveTitle();
|
||||
/*********** Modify by yexibao ---Start **************/
|
||||
for (int i = 0; i < tagDataValue.getiPhasic(); i++) {
|
||||
if (tmpWaveTitle.get(i + 1).substring(1).indexOf("A") > -1) {
|
||||
waveData.setA(tmpWaveTitle.get(i + 1).substring(1));
|
||||
}
|
||||
if (tmpWaveTitle.get(i + 1).substring(1).indexOf("B") > -1) {
|
||||
waveData.setB(tmpWaveTitle.get(i + 1).substring(1));
|
||||
}
|
||||
if (tmpWaveTitle.get(i + 1).substring(1).indexOf("C") > -1) {
|
||||
waveData.setC(tmpWaveTitle.get(i + 1).substring(1));
|
||||
}
|
||||
}
|
||||
/*********** Modify by yexibao ---End **************/
|
||||
|
||||
} else {
|
||||
log.error(OssPath.WAVE_DIR + rmpEventDetailPO.getWavePath() + "路径下,文件找不到了");
|
||||
}
|
||||
|
||||
return waveData;
|
||||
}
|
||||
|
||||
|
||||
public void translateData(JSONObject jsonObject, LocalDateTime trigeTime, EntityAdvancedData entityAdvancedData) {
|
||||
int len = Utils.getIntValue(jsonObject.get(EnumEvt.EVT_NUM.getProperty()).toString(), 0);
|
||||
|
||||
entityAdvancedData.backNumber = len;
|
||||
//初始化EntityAdvancedData的BackData数据
|
||||
len = (len == 0 ? 1 : len);
|
||||
entityAdvancedData.evt_buf = new BackData[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
entityAdvancedData.evt_buf[i] = new BackData();
|
||||
}
|
||||
|
||||
for (int offset = 0; offset < len; offset++) {
|
||||
BackData backData = new BackData();
|
||||
/**
|
||||
* @波形起始点(3相)
|
||||
*/
|
||||
backData.POW_a = Utils.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).get(EnumEvt.POW_A.getProperty()).toString(), 0.0f);
|
||||
backData.POW_b = Utils.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).get(EnumEvt.POW_B.getProperty()).toString(), 0.0f);
|
||||
backData.POW_c = Utils.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).get(EnumEvt.POW_C.getProperty()).toString(), 0.0f);
|
||||
|
||||
/**
|
||||
* @跳变段电压变化
|
||||
*/
|
||||
backData.Voltagechange_Va = Utils.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).get(EnumEvt.VOLTAGECHANGE_VA.getProperty()).toString(), 0.0f);
|
||||
backData.Voltagechange_Vb = Utils.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).get(EnumEvt.VOLTAGECHANGE_VB.getProperty()).toString(), 0.0f);
|
||||
backData.Voltagechange_Vc = Utils.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).get(EnumEvt.VOLTAGECHANGE_VC.getProperty()).toString(), 0.0f);
|
||||
|
||||
/**
|
||||
* @持续时间
|
||||
*/
|
||||
backData.hold_time_rms = Utils.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).get(EnumEvt.HOLD_TIME_RMS.getProperty()).toString(), 0.0f);
|
||||
backData.hold_time_dq = Utils.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).get(EnumEvt.HOLD_TIME_DQ.getProperty()).toString(), 0.0f);
|
||||
|
||||
/**
|
||||
* @分段信息
|
||||
*/
|
||||
backData.SEG_T_num = Utils.getIntValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).get(EnumEvt.SEG_T_NUM.getProperty()).toString(), 0);
|
||||
|
||||
for (int i = 0; i < backData.SEG_T_num; i++) {
|
||||
backData.SEG_T_idx[i] = Utils.getIntValue(
|
||||
jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.SEG_T_IDX.getProperty()).get(Integer.toString(i)).toString(),
|
||||
-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @特征幅值
|
||||
*/
|
||||
backData.u_min_num = Utils.getIntValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).get(EnumEvt.U_MIN_NUM.getProperty()).toString(), 0);
|
||||
|
||||
for (int j = 0; j < backData.u_min_num; j++) {
|
||||
backData.ua_min[j] = Utils
|
||||
.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.UA_MIN.getProperty()).get(Integer.toString(j)).toString(), 0.0f);
|
||||
backData.ub_min[j] = Utils
|
||||
.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.UB_MIN.getProperty()).get(Integer.toString(j)).toString(), 0.0f);
|
||||
backData.uc_min[j] = Utils
|
||||
.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.UC_MIN.getProperty()).get(Integer.toString(j)).toString(), 0.0f);
|
||||
backData.u3_min[j] = Utils
|
||||
.getFloatValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.U3_MIN.getProperty()).get(Integer.toString(j)).toString(), 0.0f);
|
||||
|
||||
/**
|
||||
* @相位跳变
|
||||
*/
|
||||
backData.angle_diff_an[j] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.ANGLE_DIFF_AN.getProperty()).get(Integer.toString(j)).toString(),
|
||||
0.0f);
|
||||
backData.angle_diff_bn[j] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.ANGLE_DIFF_BN.getProperty()).get(Integer.toString(j)).toString(),
|
||||
0.0f);
|
||||
backData.angle_diff_cn[j] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.ANGLE_DIFF_CN.getProperty()).get(Integer.toString(j)).toString(),
|
||||
0.0f);
|
||||
backData.angle_diff_ap[j] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.ANGLE_DIFF_AP.getProperty()).get(Integer.toString(j)).toString(),
|
||||
0.0f);
|
||||
backData.angle_diff_bp[j] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.ANGLE_DIFF_BP.getProperty()).get(Integer.toString(j)).toString(),
|
||||
0.0f);
|
||||
backData.angle_diff_cp[j] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.ANGLE_DIFF_CP.getProperty()).get(Integer.toString(j)).toString(),
|
||||
0.0f);
|
||||
|
||||
/**
|
||||
* @不平衡度
|
||||
*/
|
||||
backData.bph_max_value[j] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty()).getJSONObject(offset)
|
||||
.getJSONObject(EnumEvt.BPH_MAX_VALUE.getProperty()).get(Integer.toString(j)).toString(),
|
||||
0.0f);
|
||||
|
||||
/**
|
||||
* @暂降原因
|
||||
*/
|
||||
backData.qvvr_cata_cause[j] = Utils.getIntValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).getJSONObject(EnumEvt.QVVR_CATA_CAUSE.getProperty())
|
||||
.get(Integer.toString(j)).toString(), -1);
|
||||
|
||||
/**
|
||||
* @暂降类型
|
||||
*/
|
||||
backData.qvvr_cata_type[j] = Utils.getIntValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).getJSONObject(EnumEvt.QVVR_CATA_TYPE.getProperty())
|
||||
.get(Integer.toString(j)).toString(), -1);
|
||||
|
||||
/**
|
||||
* @暂降相别
|
||||
*/
|
||||
backData.qvvr_phasetype[j] = Utils.getIntValue(jsonObject.getJSONArray(EnumEvt.EVT_BUF.getProperty())
|
||||
.getJSONObject(offset).getJSONObject(EnumEvt.QVVR_PHASETYPE.getProperty())
|
||||
.get(Integer.toString(j)).toString(), -1);
|
||||
}
|
||||
|
||||
entityAdvancedData.evt_buf[offset] = backData;
|
||||
}
|
||||
|
||||
if (jsonObject.containsKey(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty())) {
|
||||
if (!jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).isEmpty()) {
|
||||
entityAdvancedData.power_after_buf = new PowerData[1];
|
||||
PowerData power = new PowerData();
|
||||
float fundP[] = new float[5];
|
||||
fundP[0] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_P.getProperty()).get("A").toString(), 0.0f);
|
||||
fundP[1] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_P.getProperty()).get("B").toString(), 0.0f);
|
||||
fundP[2] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_P.getProperty()).get("C").toString(), 0.0f);
|
||||
fundP[3] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_P.getProperty()).get("total").toString(), 0.0f);
|
||||
fundP[4] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_P.getProperty()).get("zero").toString(), 0.0f);
|
||||
power.setFundP(fundP);
|
||||
|
||||
float fundQ[] = new float[5];
|
||||
fundQ[0] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_Q.getProperty()).get("A").toString(), 0.0f);
|
||||
fundQ[1] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_Q.getProperty()).get("B").toString(), 0.0f);
|
||||
fundQ[2] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_Q.getProperty()).get("C").toString(), 0.0f);
|
||||
fundQ[3] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_Q.getProperty()).get("total").toString(), 0.0f);
|
||||
fundQ[4] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_Q.getProperty()).get("zero").toString(), 0.0f);
|
||||
power.setFundQ(fundQ);
|
||||
|
||||
float fundS[] = new float[5];
|
||||
fundS[0] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_S.getProperty()).get("A").toString(), 0.0f);
|
||||
fundS[1] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_S.getProperty()).get("B").toString(), 0.0f);
|
||||
fundS[2] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_S.getProperty()).get("C").toString(), 0.0f);
|
||||
fundS[3] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_S.getProperty()).get("total").toString(), 0.0f);
|
||||
fundS[4] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.POWER_QVVR_AFTER_BUF.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.FUND_S.getProperty()).get("zero").toString(), 0.0f);
|
||||
power.setFundS(fundS);
|
||||
entityAdvancedData.power_after_buf[0] = power;
|
||||
}
|
||||
}
|
||||
if (jsonObject.containsKey(EnumEvt.QVVR_DIRECTION_INFO.getProperty())) {
|
||||
if (!jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).isEmpty()) {
|
||||
entityAdvancedData.qvvr_direction_info = new DirectionData[1];
|
||||
DirectionData direction = new DirectionData();
|
||||
int trigTime[] = new int[7];
|
||||
trigTime[0] = Utils.getIntValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("year").toString(), 0);
|
||||
trigTime[1] = Utils.getIntValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("month").toString(), 0);
|
||||
trigTime[2] = Utils.getIntValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("date").toString(), 0);
|
||||
trigTime[3] = Utils.getIntValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("hour").toString(), 0);
|
||||
trigTime[4] = Utils.getIntValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("minute").toString(), 0);
|
||||
trigTime[5] = Utils.getIntValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("second").toString(), 0);
|
||||
trigTime[6] = Utils.getIntValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("millisecond").toString(), 0);
|
||||
direction.setTrigTime(trigTime);
|
||||
|
||||
float qvvrBeforeRms[] = new float[6];
|
||||
qvvrBeforeRms[0] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_RMS.getProperty()).get("Fund_Ua").toString(), 0.0f);
|
||||
qvvrBeforeRms[1] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_RMS.getProperty()).get("Fund_Ub").toString(), 0.0f);
|
||||
qvvrBeforeRms[2] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_RMS.getProperty()).get("Fund_Uc").toString(), 0.0f);
|
||||
qvvrBeforeRms[3] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_RMS.getProperty()).get("Fund_Ia").toString(), 0.0f);
|
||||
qvvrBeforeRms[4] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_RMS.getProperty()).get("Fund_Ib").toString(), 0.0f);
|
||||
qvvrBeforeRms[5] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_RMS.getProperty()).get("Fund_Ic").toString(), 0.0f);
|
||||
direction.setQvvrBeforeRms(qvvrBeforeRms);
|
||||
|
||||
float qvvrBeforeZk[] = new float[6];
|
||||
qvvrBeforeZk[0] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_ZK.getProperty()).get("Za").toString(), 0.0f);
|
||||
qvvrBeforeZk[1] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_ZK.getProperty()).get("Zb").toString(), 0.0f);
|
||||
qvvrBeforeZk[2] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_ZK.getProperty()).get("Zc").toString(), 0.0f);
|
||||
qvvrBeforeZk[3] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_ZK.getProperty()).get("Zab").toString(), 0.0f);
|
||||
qvvrBeforeZk[4] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_ZK.getProperty()).get("Zbc").toString(), 0.0f);
|
||||
qvvrBeforeZk[5] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_BEFORE_ZK.getProperty()).get("Zca").toString(), 0.0f);
|
||||
direction.setQvvrBeforeZk(qvvrBeforeZk);
|
||||
|
||||
float qvvrOccurRms[] = new float[6];
|
||||
qvvrOccurRms[0] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_RMS.getProperty()).get("Fund_Ua").toString(), 0.0f);
|
||||
qvvrOccurRms[1] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_RMS.getProperty()).get("Fund_Ub").toString(), 0.0f);
|
||||
qvvrOccurRms[2] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_RMS.getProperty()).get("Fund_Uc").toString(), 0.0f);
|
||||
qvvrOccurRms[3] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_RMS.getProperty()).get("Fund_Ia").toString(), 0.0f);
|
||||
qvvrOccurRms[4] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_RMS.getProperty()).get("Fund_Ib").toString(), 0.0f);
|
||||
qvvrOccurRms[5] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_RMS.getProperty()).get("Fund_Ic").toString(), 0.0f);
|
||||
direction.setQvvrOccurRms(qvvrOccurRms);
|
||||
|
||||
float qvvrOccurZk[] = new float[6];
|
||||
qvvrOccurZk[0] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_ZK.getProperty()).get("Za").toString(), 0.0f);
|
||||
qvvrOccurZk[1] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_ZK.getProperty()).get("Zb").toString(), 0.0f);
|
||||
qvvrOccurZk[2] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_ZK.getProperty()).get("Zc").toString(), 0.0f);
|
||||
qvvrOccurZk[3] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_ZK.getProperty()).get("Zab").toString(), 0.0f);
|
||||
qvvrOccurZk[4] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_ZK.getProperty()).get("Zbc").toString(), 0.0f);
|
||||
qvvrOccurZk[5] = Utils.getFloatValue(
|
||||
jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_OCCUR_ZK.getProperty()).get("Zca").toString(), 0.0f);
|
||||
direction.setQvvrOccurZk(qvvrOccurZk);
|
||||
|
||||
String qvvrPosInfo[] = new String[1];
|
||||
qvvrPosInfo[0] = jsonObject.getJSONArray(EnumEvt.QVVR_DIRECTION_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.QVVR_POS_INFO.getProperty()).get("direction").toString();
|
||||
direction.setQvvrPosInfo(qvvrPosInfo);
|
||||
|
||||
entityAdvancedData.qvvr_direction_info[0] = direction;
|
||||
}
|
||||
}
|
||||
if (jsonObject.containsKey(EnumEvt.QVVR_UTBL_INFO.getProperty())) {
|
||||
if (!jsonObject.getJSONArray(EnumEvt.QVVR_UTBL_INFO.getProperty()).isEmpty()) {
|
||||
entityAdvancedData.qvvr_utbl_info = new UtblData[1];
|
||||
UtblData direction = new UtblData();
|
||||
long trigTime[] = new long[1];
|
||||
String year = jsonObject.getJSONArray(EnumEvt.QVVR_UTBL_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("year").toString();
|
||||
String month = jsonObject.getJSONArray(EnumEvt.QVVR_UTBL_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("month").toString();
|
||||
String day = jsonObject.getJSONArray(EnumEvt.QVVR_UTBL_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("date").toString();
|
||||
String hour = jsonObject.getJSONArray(EnumEvt.QVVR_UTBL_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("hour").toString();
|
||||
String min = jsonObject.getJSONArray(EnumEvt.QVVR_UTBL_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("minute").toString();
|
||||
String sec = jsonObject.getJSONArray(EnumEvt.QVVR_UTBL_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("second").toString();
|
||||
String mil = jsonObject.getJSONArray(EnumEvt.QVVR_UTBL_INFO.getProperty()).getJSONObject(0)
|
||||
.getJSONObject(EnumEvt.TRIG_TIME.getProperty()).get("millisecond").toString();
|
||||
SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
Date utbl = null;
|
||||
try {
|
||||
utbl = dfs.parse(year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec + "." + mil);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long between = utbl.getTime() - trigeTime.toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
|
||||
trigTime[0] = between;
|
||||
direction.setTrigTime(trigTime);
|
||||
entityAdvancedData.qvvr_utbl_info[0] = direction;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user