高级算法特征值,暂降事件范围分析代码提交
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package com.njcn.advance.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.netflix.ribbon.proxy.annotation.Http;
|
||||
import com.njcn.advance.pojo.dto.BalanceInfo;
|
||||
import com.njcn.advance.pojo.param.AdvanceBaseParam;
|
||||
import com.njcn.advance.service.EventRelevantAnalysisService;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.event.pojo.vo.AdvanceEventDetailVO;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.DataInputStream;
|
||||
import java.net.URLDecoder;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
* 事件关联分析
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/6/30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("process")
|
||||
@Api(tags = "暂降事件关联分析")
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class EventRelevantAnalysisController extends BaseController {
|
||||
|
||||
private final EventRelevantAnalysisService eventRelevantAnalysisService;
|
||||
|
||||
@GetMapping("processEvents")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("启动关联分析")
|
||||
public HttpResult<Object> processEvents(@RequestParam("startTime") String startTime, @RequestParam("endTime")String endTime) {
|
||||
String methodDescribe = getMethodDescribe("processEvents");
|
||||
List<LocalDateTime> timeVal = PubUtils.checkLocalDateTime(startTime,endTime);
|
||||
eventRelevantAnalysisService.processEvents(timeVal.get(0),timeVal.get(1));
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 高级算法-暂降事件关联分析主列表
|
||||
* @author cdf
|
||||
* @date 2023/7/20
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/querySagEventsPage")
|
||||
@ApiOperation("高级算法-暂降事件关联分析主列表")
|
||||
public HttpResult<Page<AdvanceEventDetailVO>> querySagEventsPage(BaseParam baseParam){
|
||||
String methodDescribe = getMethodDescribe("querySagEventsPage");
|
||||
Page<AdvanceEventDetailVO> list = eventRelevantAnalysisService.querySagEventsPage(baseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.njcn.advance.controller;
|
||||
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
|
||||
import com.njcn.advance.service.EventWaveAnalysisService;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
* 波形高级分析
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/7/28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("waveAnalysis")
|
||||
@Api(tags = "波形高级分析")
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class EventWaveAnalysisController extends BaseController {
|
||||
|
||||
private final EventWaveAnalysisService eventWaveAnalysisService;
|
||||
|
||||
|
||||
@PostMapping("analysis")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("波形高级分析")
|
||||
@ApiImplicitParam(name = "eventIndex", value = "暂降事件id", required = true)
|
||||
public HttpResult<EntityAdvancedData> analysis(@RequestParam("eventIndex") String eventIndex) {
|
||||
String methodDescribe = getMethodDescribe("analysis");
|
||||
EntityAdvancedData entityAdvancedData = eventWaveAnalysisService.analysis(eventIndex);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, entityAdvancedData, methodDescribe);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.advance.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.advance.pojo.dto.relevent.EntityLogic;
|
||||
import com.njcn.advance.pojo.po.PqsRelevanceLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/6/19
|
||||
*/
|
||||
public interface RelevantMapper extends BaseMapper<PqsRelevanceLog> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取母线物理隔绝信息
|
||||
* @author cdf
|
||||
* @date 2023/7/21
|
||||
*/
|
||||
List<EntityLogic> getLogic();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.advance.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.advance.pojo.dto.SagEvent;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/6/19
|
||||
*/
|
||||
public interface RmpEventAdvanceMapper extends BaseMapper<RmpEventDetailPO> {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.advance.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.advance.pojo.dto.SagEvent;
|
||||
import com.njcn.advance.pojo.dto.relevent.EventAssObj;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailAssPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/8/9
|
||||
*/
|
||||
public interface RmpEventDetailAssMapper extends BaseMapper<RmpEventDetailAssPO> {
|
||||
|
||||
|
||||
int insertEventAssData(@Param("list") List<EventAssObj> list);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.advance.mapper.RelevantMapper">
|
||||
|
||||
<select id="updateCause" resultType="EntityLogic">
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.advance.mapper.RelevantMapper">
|
||||
|
||||
<select id="getLogic" resultType="EntityLogic">
|
||||
SELECT
|
||||
a.tp_index tPIndex,
|
||||
b.logic_before nodeBefore,
|
||||
b.logic_next nodeNext,
|
||||
d.Algo_Describe type
|
||||
FROM
|
||||
pqs_tflgployass a,
|
||||
pqs_tflgass b,
|
||||
pqs_transformer c,
|
||||
sys_dict_data d
|
||||
WHERE
|
||||
a.tf_index = b.tf_index
|
||||
AND b.tf_index = c.tf_index
|
||||
and c.Wiring = d.id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.advance.mapper.RmpEventDetailAssMapper">
|
||||
|
||||
<!-- pqs_eventass批量插入数据 -->
|
||||
<insert id="insertEventAssData" parameterType="java.util.List">
|
||||
insert into r_mp_event_detail_ass values
|
||||
<foreach collection="list" item="eventAssData" index="index"
|
||||
separator=",">
|
||||
(
|
||||
#{eventAssData.indexEventAss},#{eventAssData.time},#{eventAssData.describe},
|
||||
#{eventAssData.bRange},#{eventAssData.indexUser},#{eventAssData.indexUser},#{eventAssData.updateTime},#{eventAssData.updateTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,15 +4,11 @@ import cn.hutool.core.date.TimeInterval;
|
||||
import com.njcn.advance.pojo.bo.QtIdxArray;
|
||||
import com.njcn.advance.pojo.bo.QvvrDataStruct;
|
||||
import com.njcn.advance.pojo.dto.BalanceInfo;
|
||||
import com.njcn.advance.pojo.dto.QtIdx;
|
||||
import com.njcn.advance.pojo.dto.relevent.QtIdx;
|
||||
import lombok.Data;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.njcn.advance.utils;
|
||||
|
||||
import com.njcn.advance.pojo.bo.QvvrDataStruct;
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.CauseStruct;
|
||||
import com.njcn.advance.pojo.dto.waveAnalysis.Rect;
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
|
||||
@@ -33,5 +35,23 @@ public class JnaCallBalance extends JnaCallDllOrSo{
|
||||
|
||||
// 定义方法--->与C方法相对应
|
||||
void qvvr_fun_cause(QvvrDataStruct data);
|
||||
|
||||
// 定义方法--->与C方法相对应
|
||||
void qvvr_fun_cause(CauseStruct data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public interface Eventlibrary extends Library {
|
||||
// 加载Lib库
|
||||
|
||||
|
||||
Eventlibrary INSTANTCE = (Eventlibrary) Native.loadLibrary(JnaCallBalance.strpath, Eventlibrary.class);
|
||||
|
||||
|
||||
// 计算暂降类
|
||||
void qvvr_fun(Rect data);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.net.URLDecoder;
|
||||
@Slf4j
|
||||
public class JnaCallDllOrSo {
|
||||
private String path = "";
|
||||
private String pathDll = "";
|
||||
private String nameDll;
|
||||
|
||||
public static String jarPath = "";
|
||||
|
||||
@@ -0,0 +1,382 @@
|
||||
package com.njcn.advance.utils;
|
||||
|
||||
|
||||
import com.njcn.advance.pojo.dto.relevent.*;
|
||||
|
||||
public class UtilNormalization {
|
||||
public static void matrixcata_pro(EntityLogic[] transformer, EntityMtrans entityMtrans, int len) {
|
||||
int i, j, k, con;
|
||||
String node1, node2;
|
||||
int src_node[] = new int[] { 0 };
|
||||
|
||||
// 连接方式转化为矩阵形式,行、列表示所有节点
|
||||
// inf表示两个节点不相连,0表示与自身相连,其他数值表示变压器连接类型
|
||||
// 将初始矩阵的元素设为inf,对角线元素设为0
|
||||
for (i = 0; i < FinalData.NODE_NUM; i++) {
|
||||
for (j = 0; j < FinalData.NODE_NUM; j++) {
|
||||
entityMtrans.getMtrans()[i][j] = FinalData.DATA_INF;
|
||||
}
|
||||
entityMtrans.getMtrans()[i][i] = 0;
|
||||
}
|
||||
// 根据transformer设置元素
|
||||
for (i = 0; i < len; i++) {
|
||||
node1 = transformer[i].getNode_h();
|
||||
node2 = transformer[i].getNode_l();
|
||||
con = transformer[i].getType();
|
||||
//TODO
|
||||
//entityMtrans.getMtrans()[node1 - 1][node2 - 1] = con;
|
||||
//entityMtrans.getMtrans()[node2 - 1][node1 - 1] = con;
|
||||
}
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (i = 0; i < FinalData.NODE_NUM; i++) {
|
||||
for (j = 0; j < FinalData.NODE_NUM; j++) {
|
||||
str.append(entityMtrans.getMtrans()[i][j]).append(" ");
|
||||
if (j == (FinalData.NODE_NUM - 1)) {
|
||||
str.append("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 类型匹配矩阵Matrixcata
|
||||
// Matrixcata模式匹配矩阵,列为节点数,行为总类别数,元素为第一个节点分别是1-6类别情况下其他节点类别情况。
|
||||
// 元素1,2,3,4,5,6 分别对应 Dc,Cb,Da,Cc,Db,Ca
|
||||
// 设置矩阵第一行元素
|
||||
for (i = 0; i < FinalData.NODE_NUM; i++) {
|
||||
entityMtrans.getMatrixcata0()[0][i] = 0;
|
||||
}
|
||||
for (i = 1; i < FinalData.NODE_NUM; i++) {
|
||||
// 路径缓存清空
|
||||
for (j = 0; j < FinalData.MAX_PATH_NUM; j++) {
|
||||
for (k = 0; k < (FinalData.NODE_NUM + 1); k++) {
|
||||
entityMtrans.getPossiable_path()[j][k] = 0;
|
||||
}
|
||||
}
|
||||
entityMtrans.setPath_num(0);
|
||||
// 寻找路径
|
||||
src_node[0] = 0;
|
||||
findPath(entityMtrans, src_node, i, 0, 1, FinalData.NODE_NUM);
|
||||
if (entityMtrans.getPath_num() != 0) {
|
||||
entityMtrans.getMatrixcata0()[0][i] = entityMtrans.getPossiable_path()[0][FinalData.NODE_NUM]; // 采用第一条路径
|
||||
} else {
|
||||
entityMtrans.getMatrixcata0()[0][i] = FinalData.DATA_INF; // 找不到路径填大值表示不通
|
||||
}
|
||||
}
|
||||
// 构造矩阵其他行元素
|
||||
for (i = 1; i < FinalData.EVT_TYPE_NUM; i++) {
|
||||
for (j = 0; j < FinalData.NODE_NUM; j++)
|
||||
// EntityGroupData.Matrixcata0[i][j] =
|
||||
// EntityGroupData.Matrixcata0[0][j] + i;
|
||||
{
|
||||
if (entityMtrans.getMatrixcata0()[0][j] == FinalData.DATA_INF) {
|
||||
entityMtrans.getMatrixcata0()[i][j] = FinalData.DATA_INF;
|
||||
} else {
|
||||
entityMtrans.getMatrixcata0()[i][j] = entityMtrans.getMatrixcata0()[0][j] + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 将数据归类到0-5
|
||||
for (i = 0; i < FinalData.EVT_TYPE_NUM; i++) {
|
||||
for (j = 0; j < FinalData.NODE_NUM; j++) {
|
||||
entityMtrans.getMatrixcata1()[i][j] = entityMtrans.getMatrixcata0()[i][j] % 6;
|
||||
}
|
||||
}
|
||||
// 0换成6,将数据归类到1-6
|
||||
for (i = 0; i < FinalData.EVT_TYPE_NUM; i++) {
|
||||
for (j = 0; j < FinalData.NODE_NUM; j++) {
|
||||
if (entityMtrans.getMatrixcata1()[i][j] == 0) {
|
||||
entityMtrans.getMatrixcata1()[i][j] = 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
str.delete(0, str.length());
|
||||
for (i = 0; i < FinalData.EVT_TYPE_NUM; i++) {
|
||||
for (j = 0; j < FinalData.NODE_NUM; j++) {
|
||||
str.append(entityMtrans.getMatrixcata1()[i][j]).append(" ");
|
||||
if (j == (FinalData.NODE_NUM - 1)) {
|
||||
str.append("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int findPath(EntityMtrans entityMtrans, int[] OriginalNode, int destination, int Weight, int src_num, int node_num) // 深度优先搜索
|
||||
{
|
||||
int i, j;
|
||||
int last_node;
|
||||
int nextNodes[] = new int[FinalData.NODE_NUM];
|
||||
int nextNode_num = 0;
|
||||
int nextNodes0[] = new int[FinalData.NODE_NUM];
|
||||
int nextNode_num0 = 0;
|
||||
int tmpPath[] = new int[FinalData.NODE_NUM + 1];
|
||||
int tmpPath_num;
|
||||
if (src_num < 1) // 源节点个数不对
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
last_node = OriginalNode[src_num - 1];
|
||||
if (last_node > node_num) // 判断最后一个节点号是否在范围内
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < node_num; i++) {
|
||||
// if((Mtrans[last_node][i]>0)&&(Mtrans[last_node][i]<DATA_INF))
|
||||
// //寻找相同的节点
|
||||
if (entityMtrans.getMtrans()[last_node][i] > 0) // 寻找相同的节点
|
||||
{
|
||||
nextNodes[nextNode_num] = i;
|
||||
nextNode_num++;
|
||||
}
|
||||
}
|
||||
// 如果一条路的最后一个节点就是目标节点,说明此路径是所有路径中的一条,可以直接return
|
||||
if (last_node == destination) {
|
||||
if (entityMtrans.getPath_num() >= FinalData.MAX_PATH_NUM) {
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < src_num; i++) {
|
||||
entityMtrans.getPossiable_path()[entityMtrans.getPath_num()][i] = OriginalNode[i];
|
||||
}
|
||||
entityMtrans.getPossiable_path()[entityMtrans.getPath_num()][FinalData.NODE_NUM] = Weight; // 最后一个节点填入变压器连接
|
||||
entityMtrans.setPath_num(entityMtrans.getPath_num() + 1);
|
||||
} else {
|
||||
for (i = 0; i < src_num; i++) {
|
||||
if (destination == OriginalNode[i]) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 判断下一个节点有没有目的节点
|
||||
for (i = 0; i < nextNode_num; i++) {
|
||||
if (nextNodes[i] == destination) {
|
||||
// 先清零;
|
||||
for (j = 0; j < (FinalData.NODE_NUM + 1); j++) {
|
||||
tmpPath[j] = 0;
|
||||
}
|
||||
// 填入源节点
|
||||
for (j = 0; j < src_num; j++) {
|
||||
tmpPath[j] = OriginalNode[j];
|
||||
}
|
||||
tmpPath[src_num] = destination; // 目的节点加在后面
|
||||
tmpPath[FinalData.NODE_NUM] = Weight + entityMtrans.getMtrans()[last_node][destination]; // 最后一个点填入变压器累计
|
||||
tmpPath_num = src_num + 1;
|
||||
if (entityMtrans.getPath_num() >= FinalData.MAX_PATH_NUM) {
|
||||
return 1;
|
||||
}
|
||||
for (j = 0; j < (FinalData.NODE_NUM + 1); j++) {
|
||||
entityMtrans.getPossiable_path()[entityMtrans.getPath_num()][j] = tmpPath[j]; // tmpPath为路径的路阻
|
||||
}
|
||||
entityMtrans.setPath_num(entityMtrans.getPath_num() + 1);
|
||||
nextNodes[i] = 0;
|
||||
if (nextNode_num != 0) // if(nextNode_num)
|
||||
{
|
||||
nextNode_num--;
|
||||
}
|
||||
} else {
|
||||
// 判断如果源节点中有下一个节点,不再寻找处理
|
||||
for (j = 0; j < src_num; j++) {
|
||||
if (nextNodes[i] == OriginalNode[j]) {
|
||||
nextNodes[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 不是目的节点的下一节点继续寻找
|
||||
for (i = 0; i < nextNode_num; i++) {
|
||||
if (nextNodes[i] != 0) {
|
||||
nextNodes0[nextNode_num0] = nextNodes[i];
|
||||
nextNode_num0++;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < nextNode_num0; i++) {
|
||||
// 填入源节点
|
||||
for (j = 0; j < src_num; j++) {
|
||||
tmpPath[j] = OriginalNode[j];
|
||||
}
|
||||
tmpPath[src_num] = nextNodes0[i]; // 下一个节点加在后面
|
||||
tmpPath_num = src_num + 1;
|
||||
findPath(entityMtrans, tmpPath, destination, (Weight + entityMtrans.getMtrans()[last_node][nextNodes0[i]]), tmpPath_num,
|
||||
node_num);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int sort_Tstart(EntityGroupData buf) {
|
||||
int res_num, out_num;
|
||||
int idx = 0;
|
||||
if ((buf == null) || (buf.getEvt_in_num() == 0)) {
|
||||
return 0;
|
||||
}
|
||||
res_num = buf.getEvt_in_num();
|
||||
while (res_num > 0) { // while(res_num)
|
||||
out_num = sort_Tstart_single(buf);
|
||||
// 输出缓冲填入归集缓冲
|
||||
// buf.getGrp_buf()[idx] = buf.getOut_buf();
|
||||
System.arraycopy(buf.getOut_buf(), 0, buf.getGrp_buf()[idx], 0, buf.getOut_buf().length);
|
||||
buf.getGrp_num()[idx] = out_num;
|
||||
// 未归集填入输入缓冲
|
||||
// buf.setIn_buf(buf.getRes_buf());
|
||||
System.arraycopy(buf.getRes_buf(), 0, buf.getIn_buf(), 0, buf.getRes_buf().length);
|
||||
buf.setEvt_in_num(buf.getEvt_res_num());
|
||||
idx++;
|
||||
if (idx >= FinalData.MAX_GROUP_NUM) // 分组超限
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (out_num <= res_num) {
|
||||
res_num = res_num - out_num;
|
||||
} else {
|
||||
break; // 分组数目超限
|
||||
}
|
||||
}
|
||||
buf.setGrp_all_num(idx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int sort_Tstart_single(EntityGroupData buf) {
|
||||
int i;
|
||||
int start_time;
|
||||
int thd_time1, thd_time2;
|
||||
if ((buf == null) || (buf.getEvt_in_num() == 0)) {
|
||||
return 0;
|
||||
}
|
||||
buf.setEvt_out_num(0);
|
||||
buf.setEvt_res_num(0);
|
||||
// 如果只有一个事件直接赋值返回
|
||||
if (buf.getEvt_in_num() == 1) {
|
||||
buf.setEvt_out_num(1);
|
||||
// buf.getOut_buf()[0] = buf.getIn_buf()[0];
|
||||
// System.arraycopy(buf.getIn_buf()[0], 0, buf.getOut_buf()[0], 0,
|
||||
// 1);
|
||||
buf.getOut_buf()[0] = (EntityGroupEvtData) buf.getIn_buf()[0].objClone();
|
||||
return buf.getEvt_out_num();
|
||||
}
|
||||
start_time = buf.getIn_buf()[0].getStart_time();
|
||||
thd_time1 = start_time - FinalData.TIME_THRESHOLD;
|
||||
thd_time2 = start_time + FinalData.TIME_THRESHOLD;
|
||||
// 判断时标阀值门槛归集
|
||||
for (i = 0; i < buf.getEvt_in_num(); i++) {
|
||||
start_time = buf.getIn_buf()[i].getStart_time();
|
||||
// 在阈值范围内
|
||||
if ((start_time >= thd_time1) && (start_time <= thd_time2)) {
|
||||
// buf.getOut_buf()[buf.getEvt_out_num()] = buf.getIn_buf()[i];
|
||||
// System.arraycopy(buf.getIn_buf()[i], 0,
|
||||
// buf.getOut_buf()[buf.getEvt_out_num()], 0, 1);
|
||||
buf.getOut_buf()[buf.getEvt_out_num()] = (EntityGroupEvtData) buf.getIn_buf()[i].objClone();
|
||||
buf.setEvt_out_num(buf.getEvt_out_num() + 1);
|
||||
} else {
|
||||
// buf.getRes_buf()[buf.getEvt_res_num()] = buf.getIn_buf()[i];
|
||||
// System.arraycopy(buf.getIn_buf()[i], 0,
|
||||
// buf.getRes_buf()[buf.getEvt_res_num()], 0, 1);
|
||||
buf.getRes_buf()[buf.getEvt_res_num()] = (EntityGroupEvtData) buf.getIn_buf()[i].objClone();
|
||||
buf.setEvt_res_num(buf.getEvt_res_num() + 1);
|
||||
}
|
||||
}
|
||||
return buf.getEvt_out_num();
|
||||
}
|
||||
|
||||
public static int sort_cata(EntityGroupData buf, int idx) {
|
||||
int i, j;
|
||||
int cata, node;
|
||||
int odrer[] = new int[FinalData.MAX_CATA_NUM + 2];
|
||||
// 针对类别是1-6的数据进行模式匹配,并标注属于哪一个模式
|
||||
|
||||
for (i = 0; i < (FinalData.MAX_CATA_NUM + 2); i++) {
|
||||
odrer[i] = 0;
|
||||
}
|
||||
// 暂降类型转换
|
||||
// 将类型7,8,9转换为6,2,4
|
||||
// 其中7,8,9分别对应BC两相接地,AC两相接地,AB两相接地,1,2,3,4,5,6分别对应Dc,Cb,Da,Cc,Db,Ca
|
||||
/*
|
||||
* for (i = 0; i < buf.getGrp_num()[idx]; i++) { if
|
||||
* (buf.getGrp_buf()[idx][i].getCata() == 7)
|
||||
* buf.getGrp_buf()[idx][i].setCata(6); if
|
||||
* (buf.getGrp_buf()[idx][i].getCata() == 8)
|
||||
* buf.getGrp_buf()[idx][i].setCata(2); if
|
||||
* (buf.getGrp_buf()[idx][i].getCata() == 9)
|
||||
* buf.getGrp_buf()[idx][i].setCata(4); }
|
||||
*/
|
||||
for (i = 0; i < buf.getGrp_num()[idx]; i++) {
|
||||
/*
|
||||
* if (buf.getGrp_buf()[idx][i].getCata() == 10) //事件类型未知
|
||||
* buf.getGrp_buf()[idx][i].setCata(11); if
|
||||
* (buf.getGrp_buf()[idx][i].getCata() == 9) //三相
|
||||
* buf.getGrp_buf()[idx][i].setCata(10);
|
||||
*/
|
||||
|
||||
if (buf.getGrp_buf()[idx][i].getCata() == 0) {
|
||||
buf.getGrp_buf()[idx][i].setCata(6);
|
||||
}
|
||||
|
||||
if (buf.getGrp_buf()[idx][i].getCata() == 6) {
|
||||
buf.getGrp_buf()[idx][i].setCata(6);
|
||||
}
|
||||
if (buf.getGrp_buf()[idx][i].getCata() == 7) {
|
||||
buf.getGrp_buf()[idx][i].setCata(2);
|
||||
}
|
||||
if (buf.getGrp_buf()[idx][i].getCata() == 8) {
|
||||
buf.getGrp_buf()[idx][i].setCata(4);
|
||||
}
|
||||
}
|
||||
|
||||
// 将数据进行模式匹配,并标注属于哪一个模式
|
||||
for (i = 0; i < buf.getGrp_num()[idx]; i++) {
|
||||
cata = buf.getGrp_buf()[idx][i].getCata();
|
||||
node = buf.getGrp_buf()[idx][i].getNode();
|
||||
|
||||
if ((node > FinalData.NODE_NUM) || (buf.getMatrixcata()[0][node - 1] == FinalData.DATA_INF)) {
|
||||
buf.getGrp_buf()[idx][i].setCata2(FinalData.QVVR_TYPE_OUTOFRANGE);
|
||||
// buf.getGrp_cata_buf()[idx][FinalData.MAX_CATA_NUM +
|
||||
// 1][odrer[FinalData.MAX_CATA_NUM + 1]] =
|
||||
// buf.getGrp_buf()[idx][i];
|
||||
// System.arraycopy(buf.getGrp_buf()[idx][i], 0,
|
||||
// buf.getGrp_cata_buf()[idx][FinalData.MAX_CATA_NUM +
|
||||
// 1][odrer[FinalData.MAX_CATA_NUM + 1]], 0, 1);
|
||||
buf.getGrp_cata_buf()[idx][FinalData.MAX_CATA_NUM + 1][odrer[FinalData.MAX_CATA_NUM
|
||||
+ 1]] = (EntityGroupEvtData) buf.getGrp_buf()[idx][i].objClone();
|
||||
odrer[FinalData.MAX_CATA_NUM + 1]++;
|
||||
} else if (cata == FinalData.QVVR_TYPE_UNKNOWN) {
|
||||
buf.getGrp_buf()[idx][i].setCata2(FinalData.QVVR_TYPE_UNKNOWN);
|
||||
// buf.getGrp_cata_buf()[idx][FinalData.MAX_CATA_NUM][odrer[FinalData.MAX_CATA_NUM]]
|
||||
// = buf.getGrp_buf()[idx][i];
|
||||
// System.arraycopy(buf.getGrp_buf()[idx][i], 0,
|
||||
// buf.getGrp_cata_buf()[idx][FinalData.MAX_CATA_NUM][odrer[FinalData.MAX_CATA_NUM]],
|
||||
// 0, 1);
|
||||
buf.getGrp_cata_buf()[idx][FinalData.MAX_CATA_NUM][odrer[FinalData.MAX_CATA_NUM]] = (EntityGroupEvtData) buf
|
||||
.getGrp_buf()[idx][i].objClone();
|
||||
odrer[FinalData.MAX_CATA_NUM]++;
|
||||
} else if (cata == FinalData.QVVR_TYPE_THREE) // ÈıÏàÔݽµ¹éÀà
|
||||
{
|
||||
buf.getGrp_buf()[idx][i].setCata2(FinalData.QVVR_TYPE_THREE);
|
||||
// buf.getGrp_cata_buf()[idx][FinalData.MAX_CATA_NUM -
|
||||
// 1][odrer[FinalData.MAX_CATA_NUM - 1]] =
|
||||
// buf.getGrp_buf()[idx][i];
|
||||
// System.arraycopy(buf.getGrp_buf()[idx][i], 0,
|
||||
// buf.getGrp_cata_buf()[idx][FinalData.MAX_CATA_NUM -
|
||||
// 1][odrer[FinalData.MAX_CATA_NUM - 1]], 0, 1);
|
||||
buf.getGrp_cata_buf()[idx][FinalData.MAX_CATA_NUM - 1][odrer[FinalData.MAX_CATA_NUM
|
||||
- 1]] = (EntityGroupEvtData) buf.getGrp_buf()[idx][i].objClone();
|
||||
odrer[FinalData.MAX_CATA_NUM - 1]++;
|
||||
} else // 1-6类暂降归类
|
||||
{
|
||||
for (j = 0; j < FinalData.MAX_CATA_NUM; j++) {
|
||||
if (cata == buf.getMatrixcata()[j][node - 1])// 判断数据类别属于第几行
|
||||
{
|
||||
buf.getGrp_buf()[idx][i].setCata2(j + 1);
|
||||
// 进行归类
|
||||
// buf.getGrp_cata_buf()[idx][j][odrer[j]] =
|
||||
// buf.getGrp_buf()[idx][i];
|
||||
// System.arraycopy(buf.getGrp_buf()[idx][i], 0,
|
||||
// buf.getGrp_cata_buf()[idx][j][odrer[j]], 0, 1);
|
||||
buf.getGrp_cata_buf()[idx][j][odrer[j]] = (EntityGroupEvtData) buf.getGrp_buf()[idx][i]
|
||||
.objClone();
|
||||
odrer[j]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < FinalData.MAX_CATA_NUM + 2; i++) {
|
||||
buf.getGrp_cata_num()[idx][i] = odrer[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.njcn.advance.utils;
|
||||
|
||||
/**
|
||||
* @Author: Sunwei 【sunW2016@163.com】
|
||||
* @Description:
|
||||
* @Date: Create in 22:28 2018/3/5
|
||||
* @Modified By:
|
||||
* @author njcn
|
||||
*/
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*****************************************************************
|
||||
* 字符串转基础类型,可能转换不成功,封装该方法
|
||||
* 第一个参数为需要转换的字符串
|
||||
* 第二个参数为null时,直接抛出异常,为数值则传入一个默认值
|
||||
*****************************************************************/
|
||||
public class Utils {
|
||||
public static int getIntValue(String s,Integer integer) {
|
||||
try {
|
||||
integer = Integer.parseInt(s);
|
||||
} catch (Exception e) {
|
||||
if (null == integer) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
return integer.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* String对象转float
|
||||
*
|
||||
* @param f
|
||||
* @return
|
||||
*/
|
||||
public static float getFloatValue(String s,Float f) {
|
||||
try {
|
||||
f = Float.parseFloat(s);
|
||||
} catch (Exception e) {
|
||||
if (null == f) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
return f.floatValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* String对象转double
|
||||
*
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
public static double getDoubleValue(String s,Double d) {
|
||||
try {
|
||||
d = Double.parseDouble(s);
|
||||
} catch (Exception e) {
|
||||
if (null == d) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
return d.doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* int转String对象
|
||||
*/
|
||||
public static String int2String(int iValue) {
|
||||
return Integer.toString(iValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* float转String
|
||||
*/
|
||||
public static String float2String(float fValue) {
|
||||
return Float.toString(fValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按指定大小,分隔集合,将集合按规定个数分为n个部分
|
||||
* @author cdf
|
||||
* @date 2021/10/26
|
||||
*/
|
||||
public static List<List<Integer>> splitList(List<Integer> list, int len){
|
||||
if(CollectionUtil.isEmpty(list) || len<1){
|
||||
return null;
|
||||
}
|
||||
List<List<Integer>> result = new ArrayList<>();
|
||||
int size = list.size();
|
||||
int count = (size+len-1)/1000;
|
||||
for(int i=0;i<count;i++){
|
||||
List<Integer> subList= list.subList(i*len,((i+1)*len>size?size:len*(i+1)));
|
||||
result.add(subList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user