设备监控实时数据相关接口调整(格式与前端不兼容)
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
package com.njcn.csdevice.constant;
|
package com.njcn.csdevice.constant;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@@ -21,8 +23,18 @@ public interface DataParam {
|
|||||||
//统计类型配置-便携式设备-稳态指标的ID(用于某些业务判断)
|
//统计类型配置-便携式设备-稳态指标的ID(用于某些业务判断)
|
||||||
String portableDevStatisticalId = "bce2dfdfb46c4d96e92584def276d1c8";
|
String portableDevStatisticalId = "bce2dfdfb46c4d96e92584def276d1c8";
|
||||||
|
|
||||||
|
//统计类型配置-便携式设备-稳态指标-实时数据-指标的ID(用于某些业务判断)
|
||||||
|
String portableDevStatisticaTrendlId = "91f4cbe168f97b680192aa133c6e2e78";
|
||||||
|
|
||||||
|
//统计类型配置-便携式设备-稳态指标下的三个分组ID 对应国标限值字段
|
||||||
|
Map<String,String> overlimitsGroup = new HashMap<String,String>(){{
|
||||||
|
put("6d5470f509ca271d7108a86e83bb283f","uharm");
|
||||||
|
put("ae31115b83f02f03a0d3bd65cb017121","inuharm");
|
||||||
|
put("8dc260f16280184e2b57d26668dc00b1","iharm");
|
||||||
|
}};
|
||||||
|
|
||||||
//便携式设备默认统计方式
|
//便携式设备默认统计方式
|
||||||
String portableDevStatisticalMethods = "min";
|
String portableDevStatisticalMethods = "cp95";
|
||||||
|
|
||||||
//DecimalFormat格式化
|
//DecimalFormat格式化
|
||||||
String DecimalFormatStr = "#0.0000";
|
String DecimalFormatStr = "#0.0000";
|
||||||
@@ -53,4 +65,10 @@ public interface DataParam {
|
|||||||
|
|
||||||
String wlRecordUpload = "Offline_Data_Upload";
|
String wlRecordUpload = "Offline_Data_Upload";
|
||||||
|
|
||||||
|
String dataStr = "data";
|
||||||
|
|
||||||
|
String nameStr = "name";
|
||||||
|
|
||||||
|
String phaseStr = "phase";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
|||||||
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
||||||
import com.njcn.csdevice.service.ICsGroupService;
|
import com.njcn.csdevice.service.ICsGroupService;
|
||||||
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
|
||||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||||
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
|
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
|
||||||
@@ -95,11 +96,22 @@ public class CsGroupController extends BaseController {
|
|||||||
@ApiOperation("查询实时数据中实时趋势")
|
@ApiOperation("查询实时数据中实时趋势")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "devId", value = "设备ID", required = true),
|
@ApiImplicitParam(name = "devId", value = "设备ID", required = true),
|
||||||
@ApiImplicitParam(name = "lineId", value = "监测点id", required = true)
|
@ApiImplicitParam(name = "lineId", value = "监测点id", required = true),
|
||||||
|
@ApiImplicitParam(name = "groupId", value = "指标分组ID", required = false)
|
||||||
})
|
})
|
||||||
public HttpResult<List<ThdDataVO>> getDeviceTrendData(@RequestParam("devId") String devId, @RequestParam(value = "lineId")String lineId){
|
public HttpResult<List<ThdDataTdVO>> getDeviceTrendData(@RequestParam("devId") String devId, @RequestParam(value = "lineId")String lineId,
|
||||||
|
@RequestParam(value = "groupId",required = false)String groupId){
|
||||||
String methodDescribe = getMethodDescribe("getDeviceTrendData");
|
String methodDescribe = getMethodDescribe("getDeviceTrendData");
|
||||||
List<ThdDataVO> list = csGroupService.getDeviceTrendData(devId,lineId);
|
List<ThdDataTdVO> list = csGroupService.getDeviceTrendData(devId,lineId,groupId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/getDeviceTrendDataGroup")
|
||||||
|
@ApiOperation("查询实时数据中实时趋势中指标分组")
|
||||||
|
public HttpResult<List<ThdDataTdVO>> getDeviceTrendDataGroup(){
|
||||||
|
String methodDescribe = getMethodDescribe("getDeviceTrendDataGroup");
|
||||||
|
List<ThdDataTdVO> list = csGroupService.getDeviceTrendDataGroup();
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,9 +119,9 @@ public class CsGroupController extends BaseController {
|
|||||||
@PostMapping("/getDeviceHarmonicSpectrumData")
|
@PostMapping("/getDeviceHarmonicSpectrumData")
|
||||||
@ApiOperation("查询实时数据中谐波频谱")
|
@ApiOperation("查询实时数据中谐波频谱")
|
||||||
@ApiImplicitParam(name = "commonStatisticalQueryParam",required = true)
|
@ApiImplicitParam(name = "commonStatisticalQueryParam",required = true)
|
||||||
public HttpResult<List<ThdDataVO>> getDeviceHarmonicSpectrumData(@RequestBody CommonStatisticalQueryParam commonStatisticalQueryParam){
|
public HttpResult<List<ThdDataTdVO.ThdDataSpectrumVOData>> getDeviceHarmonicSpectrumData(@RequestBody CommonStatisticalQueryParam commonStatisticalQueryParam){
|
||||||
String methodDescribe = getMethodDescribe("getDeviceHarmonicSpectrumData");
|
String methodDescribe = getMethodDescribe("getDeviceHarmonicSpectrumData");
|
||||||
List<ThdDataVO> list = csGroupService.getDeviceHarmonicSpectrumData(commonStatisticalQueryParam);
|
List<ThdDataTdVO.ThdDataSpectrumVOData> list = csGroupService.getDeviceHarmonicSpectrumData(commonStatisticalQueryParam);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import com.njcn.system.api.DicDataFeignClient;
|
|||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import com.njcn.web.pojo.param.BaseParam;
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
@@ -27,8 +26,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -40,7 +37,7 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 便携式基础数据导入 前端控制器
|
* 离线数据导入 前端控制器
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author guofeihu
|
* @author guofeihu
|
||||||
@@ -48,7 +45,7 @@ import java.util.stream.Stream;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/portableOfflLog")
|
@RequestMapping("/portableOfflLog")
|
||||||
@Api(tags = " 出厂设备")
|
@Api(tags = " 离线数据导入")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PortableOfflLogController extends BaseController {
|
public class PortableOfflLogController extends BaseController {
|
||||||
|
|
||||||
@@ -74,14 +71,14 @@ public class PortableOfflLogController extends BaseController {
|
|||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/queryPage")
|
@PostMapping("/queryPage")
|
||||||
@ApiOperation("便携式设备解析列表")
|
@ApiOperation("便携式设备解析列表")
|
||||||
@ApiImplicitParam(name = "baseParam", value = "查询参数", required = true)
|
|
||||||
public HttpResult<Page<PortableOfflLog>> queryPage(@RequestBody BaseParam baseParam){
|
public HttpResult<Page<PortableOfflLog>> queryPage(@RequestBody BaseParam baseParam){
|
||||||
String methodDescribe = getMethodDescribe("queryPage");
|
String methodDescribe = getMethodDescribe("queryPage");
|
||||||
Page<PortableOfflLog> list = iPortableOfflLogService.queryPage(baseParam);
|
Page<PortableOfflLog> list = iPortableOfflLogService.queryPage(baseParam);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("批量导入便携式设备信息")
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@ApiOperation("离线数据导入")
|
||||||
@PostMapping(value = "importEquipment")
|
@PostMapping(value = "importEquipment")
|
||||||
public HttpResult<String> importEquipment(@RequestParam("devId") String devId
|
public HttpResult<String> importEquipment(@RequestParam("devId") String devId
|
||||||
, @RequestParam("lineId") String lineId, @RequestParam("paths") String paths,HttpServletRequest request) {
|
, @RequestParam("lineId") String lineId, @RequestParam("paths") String paths,HttpServletRequest request) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.njcn.csdevice.pojo.po.CsGroup;
|
|||||||
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||||
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
||||||
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
|
||||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||||
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
|
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
|
||||||
@@ -51,13 +52,19 @@ public interface ICsGroupService extends IService<CsGroup> {
|
|||||||
* 查询实时数据中实时趋势
|
* 查询实时数据中实时趋势
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ThdDataVO> getDeviceTrendData(String devId,String lineId);
|
List<ThdDataTdVO> getDeviceTrendData(String devId, String lineId,String groupId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询实时数据中实时趋势中指标分组
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ThdDataTdVO> getDeviceTrendDataGroup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询实时数据中实时趋势
|
* 查询实时数据中实时趋势
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ThdDataVO> getDeviceHarmonicSpectrumData(CommonStatisticalQueryParam commonStatisticalQueryParam);
|
List<ThdDataTdVO.ThdDataSpectrumVOData> getDeviceHarmonicSpectrumData(CommonStatisticalQueryParam commonStatisticalQueryParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询稳态指标并按照指标名称分组(A、B、...)
|
* 查询稳态指标并按照指标名称分组(A、B、...)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.njcn.web.pojo.param.BaseParam;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 便携式基础数据导入 服务类
|
* 离线数据导入 服务类
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author guofeihu
|
* @author guofeihu
|
||||||
|
|||||||
@@ -30,7 +30,10 @@ import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
|
|||||||
import com.njcn.csdevice.service.ICsDataArrayService;
|
import com.njcn.csdevice.service.ICsDataArrayService;
|
||||||
import com.njcn.csdevice.service.ICsGroupService;
|
import com.njcn.csdevice.service.ICsGroupService;
|
||||||
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
|
||||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||||
|
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||||
|
import com.njcn.device.pq.api.OverLimitClient;
|
||||||
import com.njcn.event.api.EventDetailFeignClient;
|
import com.njcn.event.api.EventDetailFeignClient;
|
||||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||||
import com.njcn.influx.pojo.bo.CommonQueryParam;
|
import com.njcn.influx.pojo.bo.CommonQueryParam;
|
||||||
@@ -53,6 +56,8 @@ import lombok.Data;
|
|||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
@@ -62,6 +67,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static com.njcn.csdevice.constant.DataParam.overlimitsGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 数据分组表 服务实现类
|
* 数据分组表 服务实现类
|
||||||
@@ -102,6 +109,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
|
|
||||||
private final EleEvtFeignClient eleEvtFeignClient;
|
private final EleEvtFeignClient eleEvtFeignClient;
|
||||||
|
|
||||||
|
private final OverLimitClient overLimitClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public List<CsGroupVO> getGroupData(String dataSet) {
|
public List<CsGroupVO> getGroupData(String dataSet) {
|
||||||
@@ -297,11 +306,16 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
eleEpdPqds.addAll(css.getEleEpdPqdVOS());
|
eleEpdPqds.addAll(css.getEleEpdPqdVOS());
|
||||||
});
|
});
|
||||||
eleEpdPqds.forEach(epdPqd->{
|
eleEpdPqds.forEach(epdPqd->{
|
||||||
|
String frequency = "";
|
||||||
|
if(epdPqd.getHarmStart() != null && epdPqd.getHarmEnd() != null){
|
||||||
|
frequency = "_" + epdPqd.getHarmStart().intValue();
|
||||||
|
}
|
||||||
|
String finalFrequency = frequency;
|
||||||
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
||||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||||
commonQueryParam.setLineId(temp.getLineId());
|
commonQueryParam.setLineId(temp.getLineId());
|
||||||
commonQueryParam.setTableName(getTableNameByClassId(epdPqd.getClassId()));
|
commonQueryParam.setTableName(getTableNameByClassId(epdPqd.getClassId()));
|
||||||
commonQueryParam.setColumnName(epdPqd.getName());
|
commonQueryParam.setColumnName(epdPqd.getName()+ finalFrequency);
|
||||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType() == null ? DataParam.portableDevStatisticalMethods:commonStatisticalQueryParam.getValueType());
|
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType() == null ? DataParam.portableDevStatisticalMethods:commonStatisticalQueryParam.getValueType());
|
||||||
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
||||||
@@ -355,7 +369,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), DataParam.EvtParamPhase)).
|
filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), DataParam.EvtParamPhase)).
|
||||||
collect(Collectors.toList());
|
collect(Collectors.toList());
|
||||||
if(CollectionUtil.isEmpty(evtParamPhase)){
|
if(CollectionUtil.isEmpty(evtParamPhase)){
|
||||||
temp.setPhaseType("-");
|
temp.setPhaseType(null);
|
||||||
}else {
|
}else {
|
||||||
temp.setPhaseType(evtParamPhase.get(0).getValue()+(Objects.isNull(evtParamPhase.get(0).getUnit())?"":evtParamPhase.get(0).getUnit()));
|
temp.setPhaseType(evtParamPhase.get(0).getValue()+(Objects.isNull(evtParamPhase.get(0).getUnit())?"":evtParamPhase.get(0).getUnit()));
|
||||||
}
|
}
|
||||||
@@ -391,102 +405,184 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ThdDataVO> getDeviceTrendData(String devId, String lineId) {
|
public List<ThdDataTdVO> getDeviceTrendData(String devId, String lineId,String groupId) {
|
||||||
List<ThdDataVO> result = new ArrayList();
|
List<ThdDataTdVO> data = new ArrayList();
|
||||||
|
List<Overlimit> overlimits = overLimitClient.getOverLimitByLineIds(Arrays.asList(lineId)).getData();
|
||||||
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(lineId)).getData();
|
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(lineId)).getData();
|
||||||
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(devId.toString()).collect(Collectors.toList())).getData();
|
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(devId).collect(Collectors.toList())).getData();
|
||||||
//便携式设备的稳态指标
|
//便携式设备-稳态指标-实时数据-指标
|
||||||
CsStatisticalSetVO csStatisticalSetVO = csStatisticalSetFeignClient.queryStatistical(DataParam.portableDevStatisticalId).getData();
|
CsStatisticalSetVO csStatisticalSetVO = csStatisticalSetFeignClient.queryStatistical(DataParam.portableDevStatisticaTrendlId).getData();
|
||||||
List<EleEpdPqd> eleEpdPqds = new ArrayList<>();
|
|
||||||
csStatisticalSetVO.getSelectedList().forEach(css->{
|
csStatisticalSetVO.getSelectedList().forEach(css->{
|
||||||
for(EleEpdPqd epdPqd : css.getEleEpdPqdVOS()){
|
if(groupId != null && !groupId.equals(css.getDataType())){
|
||||||
if(epdPqd.getHarmStart() != null && epdPqd.getHarmEnd() != null){
|
|
||||||
eleEpdPqds.add(epdPqd);
|
}else{
|
||||||
|
ThdDataTdVO thdDataTdVO = new ThdDataTdVO();
|
||||||
|
thdDataTdVO.setId(css.getDataType());
|
||||||
|
thdDataTdVO.setGroupName(css.getDataTypeName());
|
||||||
|
List<Map<String,Object>> thdDataVOS = new ArrayList<>();
|
||||||
|
List<ThdDataTdVO.ThdDataTdVOData> thdDataTdVODatas = new ArrayList<>();
|
||||||
|
for(EleEpdPqd epd : css.getEleEpdPqdVOS()){
|
||||||
|
if(epd.getHarmStart() != null && epd.getHarmEnd() != null){
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
List<ThdDataVO> result = new ArrayList();
|
||||||
|
List<EleEpdPqd> eleEpdPqds = new ArrayList<>();
|
||||||
|
eleEpdPqds.add(epd);
|
||||||
|
eleEpdPqds.forEach(epdPqd->{
|
||||||
|
for (int i = epdPqd.getHarmStart().intValue(); i < epdPqd.getHarmEnd().intValue(); i++) {
|
||||||
|
String index = i+"";
|
||||||
|
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
||||||
|
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||||
|
commonQueryParam.setLineId(temp.getLineId());
|
||||||
|
commonQueryParam.setTableName(getTableNameByClassId(epdPqd.getClassId()));
|
||||||
|
commonQueryParam.setColumnName(epdPqd.getName()+"_"+index);
|
||||||
|
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||||
|
commonQueryParam.setDataType(DataParam.portableDevStatisticalMethods);
|
||||||
|
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
||||||
|
commonQueryParam.setClDid(getClDidByLineId(temp.getLineId()));
|
||||||
|
return commonQueryParam;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(commonQueryParams);
|
||||||
|
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||||
|
ThdDataVO vo = new ThdDataVO();
|
||||||
|
vo.setLineId(temp.getLineId());
|
||||||
|
vo.setPhase(temp.getPhaseType());
|
||||||
|
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||||
|
vo.setPosition(position);
|
||||||
|
vo.setTime(temp.getTime());
|
||||||
|
vo.setStatMethod(temp.getValueType());
|
||||||
|
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||||
|
vo.setStatisticalIndex(epdPqd.getId());
|
||||||
|
vo.setUnit(epdPqd.getUnit());
|
||||||
|
vo.setStatisticalName(epdPqd.getName());
|
||||||
|
vo.setAnotherName(epdPqd.getShowName());
|
||||||
|
vo.setFrequency(index);
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
result.addAll(collect1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
map.put(DataParam.dataStr,result);
|
||||||
|
map.put(DataParam.nameStr,epd.getPhase()+epd.getShowName());
|
||||||
|
map.put(DataParam.phaseStr,epd.getPhase());
|
||||||
|
thdDataVOS.add(map);
|
||||||
|
|
||||||
|
for(ThdDataVO thdDataVO : result){
|
||||||
|
ThdDataTdVO.ThdDataTdVOData thdDataTdVOData = new ThdDataTdVO.ThdDataTdVOData();
|
||||||
|
BeanUtils.copyProperties(thdDataVO,thdDataTdVOData);
|
||||||
|
if(!overlimits.isEmpty()){
|
||||||
|
thdDataTdVOData.setInternationalValue(getOverlimitsByGroup(overlimits.get(0).getClass(),css.getDataType(),thdDataVO.getFrequency(),overlimits.get(0)));
|
||||||
|
}
|
||||||
|
thdDataTdVODatas.add(thdDataTdVOData);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
thdDataTdVO.setThdDataVOS(thdDataVOS);
|
||||||
|
thdDataTdVO.setThdDataTdVODatas(thdDataTdVODatas);
|
||||||
|
data.add(thdDataTdVO);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
eleEpdPqds.forEach(epdPqd->{
|
return data;
|
||||||
for (int i = epdPqd.getHarmStart().intValue(); i < epdPqd.getHarmEnd().intValue(); i++) {
|
}
|
||||||
String index = i+"";
|
|
||||||
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
//根据指标分组获取对应的国标幅值
|
||||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
private Object getOverlimitsByGroup(Class clazz,String groupId,String frequency,Overlimit overlimit){
|
||||||
commonQueryParam.setLineId(temp.getLineId());
|
try {
|
||||||
commonQueryParam.setTableName(getTableNameByClassId(epdPqd.getClassId()));
|
String name = DataParam.overlimitsGroup.get(groupId);
|
||||||
commonQueryParam.setColumnName(epdPqd.getName()+"_"+index);
|
if(name == null){
|
||||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
return null;
|
||||||
commonQueryParam.setDataType(DataParam.portableDevStatisticalMethods);
|
|
||||||
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
|
||||||
commonQueryParam.setClDid(getClDidByLineId(temp.getLineId()));
|
|
||||||
return commonQueryParam;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(commonQueryParams);
|
|
||||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
|
||||||
ThdDataVO vo = new ThdDataVO();
|
|
||||||
vo.setLineId(temp.getLineId());
|
|
||||||
vo.setPhase(temp.getPhaseType());
|
|
||||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
|
||||||
vo.setPosition(position);
|
|
||||||
vo.setTime(temp.getTime());
|
|
||||||
vo.setStatMethod(temp.getValueType());
|
|
||||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
|
||||||
vo.setStatisticalIndex(epdPqd.getId());
|
|
||||||
vo.setUnit(epdPqd.getUnit());
|
|
||||||
vo.setStatisticalName(epdPqd.getName());
|
|
||||||
vo.setAnotherName(epdPqd.getShowName());
|
|
||||||
vo.setFrequency(index);
|
|
||||||
return vo;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
result.addAll(collect1);
|
|
||||||
}
|
}
|
||||||
});
|
Field field = clazz.getDeclaredField(name+frequency);
|
||||||
return result;
|
field.setAccessible(true);
|
||||||
|
return field.get(overlimit);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ThdDataVO> getDeviceHarmonicSpectrumData(CommonStatisticalQueryParam commonStatisticalQueryParam) {
|
public List<ThdDataTdVO> getDeviceTrendDataGroup() {
|
||||||
|
List<ThdDataTdVO> data = new ArrayList();
|
||||||
|
//便携式设备-稳态指标-实时数据-指标
|
||||||
|
CsStatisticalSetVO csStatisticalSetVO = csStatisticalSetFeignClient.queryStatistical(DataParam.portableDevStatisticaTrendlId).getData();
|
||||||
|
csStatisticalSetVO.getSelectedList().forEach(css->{
|
||||||
|
ThdDataTdVO thdDataTdVO = new ThdDataTdVO();
|
||||||
|
thdDataTdVO.setId(css.getDataType());
|
||||||
|
thdDataTdVO.setGroupName(css.getDataTypeName());
|
||||||
|
data.add(thdDataTdVO);
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ThdDataTdVO.ThdDataSpectrumVOData> getDeviceHarmonicSpectrumData(CommonStatisticalQueryParam commonStatisticalQueryParam) {
|
||||||
formatQueryParamList(commonStatisticalQueryParam);
|
formatQueryParamList(commonStatisticalQueryParam);
|
||||||
List<ThdDataVO> result = new ArrayList();
|
List<ThdDataTdVO.ThdDataSpectrumVOData> thdDataSpectrumVODatas = new ArrayList<>();
|
||||||
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(commonStatisticalQueryParam.getDevId()).collect(Collectors.toList())).getData();
|
List<CsEquipmentDeliveryDTO> data1 = equipmentFeignClient.queryDeviceById(Stream.of(commonStatisticalQueryParam.getDevId()).collect(Collectors.toList())).getData();
|
||||||
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(commonStatisticalQueryParam.getLineId())).getData();
|
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(commonStatisticalQueryParam.getLineId())).getData();
|
||||||
if(commonStatisticalQueryParam.getList() != null && commonStatisticalQueryParam.getList().size() > 0){
|
if(commonStatisticalQueryParam.getList() != null && commonStatisticalQueryParam.getList().size() > 0){
|
||||||
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
|
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
|
||||||
if(param.getStatisticalId() == null){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
|
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
|
||||||
|
ThdDataTdVO.ThdDataSpectrumVOData thdDataSpectrumVOData = new ThdDataTdVO.ThdDataSpectrumVOData();
|
||||||
|
List<ThdDataVO> result = new ArrayList();
|
||||||
eleEpdPqds.forEach(epdPqd->{
|
eleEpdPqds.forEach(epdPqd->{
|
||||||
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
if(epdPqd.getHarmStart() != null && epdPqd.getHarmEnd() != null){
|
||||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
thdDataSpectrumVOData.setShowName(getShowName(param.getStatisticalId()));
|
||||||
commonQueryParam.setLineId(temp.getLineId());
|
for (int i = epdPqd.getHarmStart().intValue(); i < epdPqd.getHarmEnd().intValue(); i++) {
|
||||||
commonQueryParam.setTableName(getTableNameByClassId(epdPqd.getClassId()));
|
String index = i+"";
|
||||||
commonQueryParam.setColumnName(epdPqd.getName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
|
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
||||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
|
commonQueryParam.setLineId(temp.getLineId());
|
||||||
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
commonQueryParam.setTableName(getTableNameByClassId(epdPqd.getClassId()));
|
||||||
commonQueryParam.setClDid(getClDidByLineId(temp.getLineId()));
|
commonQueryParam.setColumnName(epdPqd.getName()+"_"+index);
|
||||||
return commonQueryParam;
|
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||||
}).collect(Collectors.toList());
|
commonQueryParam.setDataType(DataParam.portableDevStatisticalMethods);
|
||||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(commonQueryParams);
|
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
||||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
commonQueryParam.setClDid(getClDidByLineId(temp.getLineId()));
|
||||||
ThdDataVO vo = new ThdDataVO();
|
return commonQueryParam;
|
||||||
vo.setLineId(temp.getLineId());
|
}).collect(Collectors.toList());
|
||||||
vo.setPhase(temp.getPhaseType());
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(commonQueryParams);
|
||||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||||
vo.setPosition(position);
|
ThdDataVO vo = new ThdDataVO();
|
||||||
vo.setTime(temp.getTime());
|
vo.setLineId(temp.getLineId());
|
||||||
vo.setStatMethod(temp.getValueType());
|
vo.setPhase(temp.getPhaseType());
|
||||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||||
vo.setStatisticalIndex(epdPqd.getId());
|
vo.setPosition(position);
|
||||||
vo.setUnit(epdPqd.getUnit());
|
vo.setTime(temp.getTime());
|
||||||
vo.setStatisticalName(epdPqd.getName());
|
vo.setStatMethod(temp.getValueType());
|
||||||
vo.setAnotherName(epdPqd.getShowName());
|
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||||
return vo;
|
vo.setStatisticalIndex(epdPqd.getId());
|
||||||
}).collect(Collectors.toList());
|
vo.setUnit(epdPqd.getUnit());
|
||||||
result.addAll(collect1);
|
vo.setStatisticalName(epdPqd.getName());
|
||||||
|
vo.setAnotherName(epdPqd.getShowName());
|
||||||
|
vo.setFrequency(index);
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
result.addAll(collect1);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
thdDataSpectrumVOData.setThdDataVOS(result);
|
||||||
|
thdDataSpectrumVODatas.add(thdDataSpectrumVOData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return thdDataSpectrumVODatas;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getShowName(String statisticalId){
|
||||||
|
CsStatisticalSetVO csStatisticalSetVO = csStatisticalSetFeignClient.queryStatistical(DataParam.portableDevStatisticaTrendlId).getData();
|
||||||
|
for(EleEpdPqdListVO eleEpdPqdListVO : csStatisticalSetVO.getSelectedList()){
|
||||||
|
if(statisticalId.equals(eleEpdPqdListVO.getDataType())){
|
||||||
|
return eleEpdPqdListVO.getDataTypeName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
csStatisticalSetVO = csStatisticalSetFeignClient.queryStatistical(DataParam.portableDevStatisticalId).getData();
|
||||||
|
for(EleEpdPqdListVO eleEpdPqdListVO : csStatisticalSetVO.getSelectedList()){
|
||||||
|
if(statisticalId.equals(eleEpdPqdListVO.getDataType())){
|
||||||
|
return eleEpdPqdListVO.getDataTypeName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.njcn.csdevice.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.constant.DataParam;
|
import com.njcn.csdevice.constant.DataParam;
|
||||||
import com.njcn.csdevice.mapper.PortableOfflLogMapper;
|
import com.njcn.csdevice.mapper.PortableOfflLogMapper;
|
||||||
@@ -11,25 +10,28 @@ import com.njcn.csdevice.service.IPortableOfflLogService;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.csdevice.param.UploadDataParam;
|
import com.njcn.csdevice.param.UploadDataParam;
|
||||||
import com.njcn.csharmonic.api.OfflineDataUploadFeignClient;
|
import com.njcn.csharmonic.api.OfflineDataUploadFeignClient;
|
||||||
|
import com.njcn.csharmonic.offline.constant.OfflineConstant;
|
||||||
import com.njcn.csharmonic.offline.log.vo.NewTaglogbuffer;
|
import com.njcn.csharmonic.offline.log.vo.NewTaglogbuffer;
|
||||||
|
import com.njcn.csharmonic.offline.mincfg.tagComtradeCfg;
|
||||||
import com.njcn.csharmonic.offline.vo.Response;
|
import com.njcn.csharmonic.offline.vo.Response;
|
||||||
|
import com.njcn.influx.pojo.po.cs.PqdData;
|
||||||
import com.njcn.oss.utils.FileStorageUtil;
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import com.njcn.web.pojo.param.BaseParam;
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 便携式基础数据导入 服务实现类
|
* 离线数据导入 服务实现类
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author guofeihu
|
* @author guofeihu
|
||||||
@@ -48,38 +50,40 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
|||||||
@Override
|
@Override
|
||||||
public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
|
public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
|
||||||
Page<PortableOfflLog> returnpage = new Page<> (baseParam.getPageNum(), baseParam.getPageSize ());
|
Page<PortableOfflLog> returnpage = new Page<> (baseParam.getPageNum(), baseParam.getPageSize ());
|
||||||
if(baseParam.getSearchBeginTime()!=null) baseParam.setSearchBeginTime(baseParam.getSearchBeginTime()+" 00:00:00");
|
if(baseParam.getSearchBeginTime()!=null) baseParam.setSearchBeginTime(baseParam.getSearchBeginTime()+DataParam.startTime);
|
||||||
if(baseParam.getSearchEndTime()!=null) baseParam.setSearchEndTime(baseParam.getSearchEndTime()+" 23:59:59");
|
if(baseParam.getSearchEndTime()!=null) baseParam.setSearchEndTime(baseParam.getSearchEndTime()+DataParam.endTime);
|
||||||
returnpage = this.getBaseMapper().queryPage(returnpage,baseParam);
|
returnpage = this.getBaseMapper().queryPage(returnpage,baseParam);
|
||||||
return returnpage;
|
return returnpage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void importEquipment(UploadDataParam uploadDataParam) {
|
public void importEquipment(UploadDataParam uploadDataParam) {
|
||||||
//获取离线上传对应的字典规则
|
//获取离线上传对应的字典规则(字典用来控制上传的文件夹名称,其中字典的name代表名称,code代表该文件夹下对应的解析规则且code不能更改)
|
||||||
List<DictData> dictDatas = dicDataFeignClient.getDicDataByTypeCode(DataParam.wlRecordUpload).getData();
|
List<DictData> dictDatas = dicDataFeignClient.getDicDataByTypeCode(DataParam.wlRecordUpload).getData();
|
||||||
List<Response> responses = new ArrayList<>();
|
List<Response> responses = new ArrayList<>();
|
||||||
List<MultipartFile> files = uploadDataParam.getFiles();
|
//便利每个文件夹
|
||||||
List<String> paths = uploadDataParam.getPaths();
|
|
||||||
for(DictData dictData : dictDatas){
|
for(DictData dictData : dictDatas){
|
||||||
List<MultipartFile> fileList = new ArrayList<>();
|
List<MultipartFile> fileList = new ArrayList<>();
|
||||||
for (int i = 0; i < files.size(); i++) {
|
for(MultipartFile file : uploadDataParam.getFiles()){
|
||||||
if(paths.get(i).indexOf(dictData.getName())!=-1){
|
//获取每个文件夹下对应的文件信息
|
||||||
fileList.add(files.get(i));
|
if(checkPrevsFolder(file.getOriginalFilename(),dictData.getName())!=null) fileList.add(file);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(!fileList.isEmpty()){
|
if(!fileList.isEmpty()){
|
||||||
|
//将当前文件夹下的文件统一解析
|
||||||
byte[] resp = offlineDataUploadFeignClient.uploadAnalysis(fileList,dictData.getCode()).getData();
|
byte[] resp = offlineDataUploadFeignClient.uploadAnalysis(fileList,dictData.getCode()).getData();
|
||||||
|
//解析的返回的是复杂对象所以直接转成byte数组
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(resp);
|
ByteArrayInputStream bis = new ByteArrayInputStream(resp);
|
||||||
ObjectInputStream ois = null;
|
ObjectInputStream ois = null;
|
||||||
try {
|
try {
|
||||||
ois = new ObjectInputStream(bis);
|
ois = new ObjectInputStream(bis);
|
||||||
Object obj = ois.readObject();
|
Object obj = ois.readObject();
|
||||||
|
//实际返回的是List<Response> 也即:该文件夹下所有解析的文件对应的结果集
|
||||||
List<Response> response = (List<Response>) obj;
|
List<Response> response = (List<Response>) obj;
|
||||||
responses.addAll(response);
|
responses.addAll(response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new BusinessException("数据集对象转字节数组失败");
|
throw new BusinessException(OfflineConstant.BYTETODATA_FAIL);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
ois.close();
|
ois.close();
|
||||||
@@ -91,6 +95,8 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//min文件夹下的文件是否解析过
|
||||||
|
boolean minFlag = true;
|
||||||
//开始上传文件、记录上传日志、解析的文件结果入库
|
//开始上传文件、记录上传日志、解析的文件结果入库
|
||||||
//最外层便利所有文件确保所有文件都上传及记录上传日志
|
//最外层便利所有文件确保所有文件都上传及记录上传日志
|
||||||
for(MultipartFile file : uploadDataParam.getFiles()){
|
for(MultipartFile file : uploadDataParam.getFiles()){
|
||||||
@@ -98,34 +104,71 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
|||||||
PortableOfflLog portableOfflLog = new PortableOfflLog();
|
PortableOfflLog portableOfflLog = new PortableOfflLog();
|
||||||
portableOfflLog.setName(file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("/")+1));
|
portableOfflLog.setName(file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("/")+1));
|
||||||
portableOfflLog.setPath(file.getOriginalFilename());
|
portableOfflLog.setPath(file.getOriginalFilename());
|
||||||
portableOfflLog.setDataPath(fileStorageUtil.uploadMultipart(file, DataParam.wlRecordPath+uploadDataParam.getDevId()+"/"+uploadDataParam.getLineId()+"/"));
|
portableOfflLog.setDataPath(fileStorageUtil.uploadMultipart(file, DataParam.wlRecordPath+uploadDataParam.getDevId()+"/"+uploadDataParam.getLineId()+"/"+getFolderName()+"/"));
|
||||||
portableOfflLog.setLogsIndex(IdUtil.simpleUUID());
|
portableOfflLog.setLogsIndex(IdUtil.simpleUUID());
|
||||||
portableOfflLog.setState(1);
|
portableOfflLog.setState(0);
|
||||||
//默认总条数及入库数为0(防止解析的数据重复插入及上传的文件目录路径错误)
|
//默认总条数及入库数为0(防止解析的数据重复插入及上传的文件目录路径错误)
|
||||||
portableOfflLog.setAllCount(0);
|
portableOfflLog.setAllCount(0);
|
||||||
portableOfflLog.setRealCount(0);
|
portableOfflLog.setRealCount(0);
|
||||||
//开始匹配解析的文件结果入库
|
//开始匹配解析的文件结果入库
|
||||||
for(Response response : responses){
|
for(Response response : responses){
|
||||||
//当前文件匹配到解析结果
|
//min解析结果较为特殊所有的文件解析后只有一条结果
|
||||||
if(file.getOriginalFilename().indexOf(response.getFilename())!=-1){
|
if(OfflineConstant.MIN.equals(response.getFilename()) && checkPrevsFolder(file.getOriginalFilename(),OfflineConstant.MIN)!=null){
|
||||||
//设置当前文件总条数
|
List<PqdData> pqdData = (List<PqdData>) response.getObj();
|
||||||
//portableOfflLog.setAllCount(allCount);
|
if(response.getState() != null){
|
||||||
|
portableOfflLog.setState(response.getState());
|
||||||
|
}
|
||||||
|
if(pqdData != null && !pqdData.isEmpty()){
|
||||||
|
portableOfflLog.setState(1);
|
||||||
|
portableOfflLog.setAllCount(pqdData.size());
|
||||||
|
if(minFlag){
|
||||||
|
//min结果集解析入库后就不需要在解析了
|
||||||
|
minFlag = false;
|
||||||
|
portableOfflLog.setRealCount(pqdData.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if(file.getOriginalFilename().equals(response.getFilename())){
|
||||||
//判断当前解析的数据属于哪种结果(目前来说三种:comtrade、log、min)
|
//判断当前解析的数据属于哪种结果(目前来说三种:comtrade、log、min)
|
||||||
|
if(checkPrevsFolder(file.getOriginalFilename(),OfflineConstant.COMTRADE)!=null){
|
||||||
|
if(response.getState() != null){
|
||||||
|
portableOfflLog.setState(response.getState());
|
||||||
|
}
|
||||||
|
tagComtradeCfg tagComtradeCfg = (tagComtradeCfg) response.getObj();
|
||||||
|
if(tagComtradeCfg != null){
|
||||||
|
portableOfflLog.setState(1);
|
||||||
|
portableOfflLog.setAllCount(1);
|
||||||
|
portableOfflLog.setRealCount(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(checkPrevsFolder(file.getOriginalFilename(),OfflineConstant.LOG)!=null){
|
||||||
|
if(response.getState() != null){
|
||||||
|
portableOfflLog.setState(response.getState());
|
||||||
|
}
|
||||||
|
List<NewTaglogbuffer> newTaglogbuffers = (List<NewTaglogbuffer>) response.getObj();
|
||||||
|
if(newTaglogbuffers != null && !newTaglogbuffers.isEmpty()){
|
||||||
|
portableOfflLog.setState(1);
|
||||||
|
portableOfflLog.setAllCount(newTaglogbuffers.size());
|
||||||
|
portableOfflLog.setRealCount(newTaglogbuffers.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.baseMapper.insert(portableOfflLog);
|
this.baseMapper.insert(portableOfflLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T convertToObj(LinkedHashMap<String,Object> map,Class<T> clazz) throws Exception{
|
//根据文件全路径(包含文件夹)解析文件的分类
|
||||||
T obj = clazz.newInstance();
|
private String checkPrevsFolder(String filePath,String type){
|
||||||
for(Map.Entry<String,Object> entry : map.entrySet()){
|
List<String> paths = Arrays.asList(filePath.split("/"));
|
||||||
String fieldName = entry.getKey();
|
if(paths.contains(type)){
|
||||||
Object fieldValue = entry.getValue();
|
return type;
|
||||||
Field field = clazz.getDeclaredField(fieldName);
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(obj,fieldValue);
|
|
||||||
}
|
}
|
||||||
return obj;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getFolderName(){
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||||
|
return sdf.format(calendar.getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.csharmonic.offline.constant;
|
||||||
|
|
||||||
|
public interface OfflineConstant {
|
||||||
|
|
||||||
|
String COMTRADE = "comtrade";
|
||||||
|
|
||||||
|
String MIN = "min";
|
||||||
|
|
||||||
|
String LOG = "log";
|
||||||
|
|
||||||
|
String BYTETODATA_FAIL = "字节数组转结果集失败";
|
||||||
|
|
||||||
|
String DATATOBYTE_FAIL = "结果集转字节数组失败";
|
||||||
|
|
||||||
|
String BIN = ".bin";
|
||||||
|
|
||||||
|
String CFG = ".cfg";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -70,39 +70,39 @@ public class AnalyseComtradeCfg {
|
|||||||
List<PqdData> pqdData = new ArrayList<>();
|
List<PqdData> pqdData = new ArrayList<>();
|
||||||
|
|
||||||
HashMap hashMapA = new HashMap<>();
|
HashMap hashMapA = new HashMap<>();
|
||||||
hashMapA.put("phasic_type","A");
|
hashMapA.put("phaseType","A");
|
||||||
hashMapA.put("value_type",valueType);
|
hashMapA.put("valueType",valueType);
|
||||||
hashMapA.put("time",dateTime.toInstant());
|
hashMapA.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
HashMap hashMapB = new HashMap<>();
|
HashMap hashMapB = new HashMap<>();
|
||||||
hashMapB.put("phasic_type","B");
|
hashMapB.put("phaseType","B");
|
||||||
hashMapB.put("value_type",valueType);
|
hashMapB.put("valueType",valueType);
|
||||||
hashMapB.put("time",dateTime.toInstant());
|
hashMapB.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
HashMap hashMapC = new HashMap<>();
|
HashMap hashMapC = new HashMap<>();
|
||||||
hashMapC.put("phasic_type","C");
|
hashMapC.put("phaseType","C");
|
||||||
hashMapC.put("value_type",valueType);
|
hashMapC.put("valueType",valueType);
|
||||||
hashMapC.put("time",dateTime.toInstant());
|
hashMapC.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
HashMap hashMapM = new HashMap<>();
|
HashMap hashMapM = new HashMap<>();
|
||||||
hashMapM.put("phasic_type","M");
|
hashMapM.put("phaseType","M");
|
||||||
hashMapM.put("value_type",valueType);
|
hashMapM.put("valueType",valueType);
|
||||||
hashMapM.put("time",dateTime.toInstant());
|
hashMapM.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
|
|
||||||
HashMap hashMapAB = new HashMap<>();
|
HashMap hashMapAB = new HashMap<>();
|
||||||
hashMapAB.put("phasic_type","AB");
|
hashMapAB.put("phaseType","AB");
|
||||||
hashMapAB.put("value_type",valueType);
|
hashMapAB.put("valueType",valueType);
|
||||||
hashMapAB.put("time",dateTime.toInstant());
|
hashMapAB.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
HashMap hashMapBC = new HashMap<>();
|
HashMap hashMapBC = new HashMap<>();
|
||||||
hashMapBC.put("phasic_type","BC");
|
hashMapBC.put("phaseType","BC");
|
||||||
hashMapBC.put("value_type",valueType);
|
hashMapBC.put("valueType",valueType);
|
||||||
hashMapBC.put("time",dateTime.toInstant());
|
hashMapBC.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
HashMap hashMapCA = new HashMap<>();
|
HashMap hashMapCA = new HashMap<>();
|
||||||
hashMapCA.put("phasic_type","CA");
|
hashMapCA.put("phaseType","CA");
|
||||||
hashMapCA.put("value_type",valueType);
|
hashMapCA.put("valueType",valueType);
|
||||||
hashMapCA.put("time",dateTime.toInstant());
|
hashMapCA.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
|
|
||||||
@@ -297,17 +297,26 @@ public class AnalyseComtradeCfg {
|
|||||||
hashMapB.put("pq_Plt",ulFlicker[1]);
|
hashMapB.put("pq_Plt",ulFlicker[1]);
|
||||||
hashMapC.put("pq_Plt",ulFlicker[2]);
|
hashMapC.put("pq_Plt",ulFlicker[2]);
|
||||||
|
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.registerModule(new JavaTimeModule());
|
mapper.registerModule(new JavaTimeModule());
|
||||||
PqdData pqdDataA = mapper.convertValue(hashMapA, PqdData.class);
|
PqdData pqdDataA = mapper.convertValue(hashMapA, PqdData.class);
|
||||||
PqdData pqdDataB = mapper.convertValue(hashMapB, PqdData.class);
|
PqdData pqdDataB = mapper.convertValue(hashMapB, PqdData.class);
|
||||||
PqdData pqdDataC = mapper.convertValue(hashMapC, PqdData.class);
|
PqdData pqdDataC = mapper.convertValue(hashMapC, PqdData.class);
|
||||||
PqdData pqdDataM = mapper.convertValue(hashMapM, PqdData.class);
|
PqdData pqdDataM = mapper.convertValue(hashMapM, PqdData.class);
|
||||||
|
PqdData pqdDataAB = mapper.convertValue(hashMapAB, PqdData.class);
|
||||||
|
PqdData pqdDataBC = mapper.convertValue(hashMapBC, PqdData.class);
|
||||||
|
PqdData pqdDataCA = mapper.convertValue(hashMapCA, PqdData.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pqdData.add(pqdDataA);
|
pqdData.add(pqdDataA);
|
||||||
pqdData.add(pqdDataB);
|
pqdData.add(pqdDataB);
|
||||||
pqdData.add(pqdDataC);
|
pqdData.add(pqdDataC);
|
||||||
pqdData.add(pqdDataM);
|
pqdData.add(pqdDataM);
|
||||||
|
pqdData.add(pqdDataAB);
|
||||||
|
pqdData.add(pqdDataBC);
|
||||||
|
pqdData.add(pqdDataCA);
|
||||||
|
|
||||||
return pqdData;
|
return pqdData;
|
||||||
|
|
||||||
|
|||||||
@@ -82,39 +82,39 @@ public class AnalyseComtradeCfg1 {
|
|||||||
List<PqdData> pqdData = new ArrayList<>();
|
List<PqdData> pqdData = new ArrayList<>();
|
||||||
|
|
||||||
HashMap hashMapA = new HashMap<>();
|
HashMap hashMapA = new HashMap<>();
|
||||||
hashMapA.put("phasic_type","A");
|
hashMapA.put("phaseType","A");
|
||||||
hashMapA.put("value_type",valueType);
|
hashMapA.put("valueType",valueType);
|
||||||
hashMapA.put("time",dateTime.toInstant());
|
hashMapA.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
HashMap hashMapB = new HashMap<>();
|
HashMap hashMapB = new HashMap<>();
|
||||||
hashMapB.put("phasic_type","B");
|
hashMapB.put("phaseType","B");
|
||||||
hashMapB.put("value_type",valueType);
|
hashMapB.put("valueType",valueType);
|
||||||
hashMapB.put("time",dateTime.toInstant());
|
hashMapB.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
HashMap hashMapC = new HashMap<>();
|
HashMap hashMapC = new HashMap<>();
|
||||||
hashMapC.put("phasic_type","C");
|
hashMapC.put("phaseType","C");
|
||||||
hashMapC.put("value_type",valueType);
|
hashMapC.put("valueType",valueType);
|
||||||
hashMapC.put("time",dateTime.toInstant());
|
hashMapC.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
HashMap hashMapM = new HashMap<>();
|
HashMap hashMapM = new HashMap<>();
|
||||||
hashMapM.put("phasic_type","M");
|
hashMapM.put("phaseType","M");
|
||||||
hashMapM.put("value_type",valueType);
|
hashMapM.put("valueType",valueType);
|
||||||
hashMapM.put("time",dateTime.toInstant());
|
hashMapM.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
|
|
||||||
HashMap hashMapAB = new HashMap<>();
|
HashMap hashMapAB = new HashMap<>();
|
||||||
hashMapAB.put("phasic_type","AB");
|
hashMapAB.put("phaseType","AB");
|
||||||
hashMapAB.put("value_type",valueType);
|
hashMapAB.put("valueType",valueType);
|
||||||
hashMapAB.put("time",dateTime.toInstant());
|
hashMapAB.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
HashMap hashMapBC = new HashMap<>();
|
HashMap hashMapBC = new HashMap<>();
|
||||||
hashMapBC.put("phasic_type","BC");
|
hashMapBC.put("phaseType","BC");
|
||||||
hashMapBC.put("value_type",valueType);
|
hashMapBC.put("valueType",valueType);
|
||||||
hashMapBC.put("time",dateTime.toInstant());
|
hashMapBC.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
HashMap hashMapCA = new HashMap<>();
|
HashMap hashMapCA = new HashMap<>();
|
||||||
hashMapCA.put("phasic_type","CA");
|
hashMapCA.put("phaseType","CA");
|
||||||
hashMapCA.put("value_type",valueType);
|
hashMapCA.put("valueType",valueType);
|
||||||
hashMapCA.put("time",dateTime.toInstant());
|
hashMapCA.put("time",dateTime.toInstant());
|
||||||
|
|
||||||
|
|
||||||
@@ -315,11 +315,19 @@ public class AnalyseComtradeCfg1 {
|
|||||||
PqdData pqdDataB = mapper.convertValue(hashMapB, PqdData.class);
|
PqdData pqdDataB = mapper.convertValue(hashMapB, PqdData.class);
|
||||||
PqdData pqdDataC = mapper.convertValue(hashMapC, PqdData.class);
|
PqdData pqdDataC = mapper.convertValue(hashMapC, PqdData.class);
|
||||||
PqdData pqdDataM = mapper.convertValue(hashMapM, PqdData.class);
|
PqdData pqdDataM = mapper.convertValue(hashMapM, PqdData.class);
|
||||||
|
PqdData pqdDataAB = mapper.convertValue(hashMapAB, PqdData.class);
|
||||||
|
PqdData pqdDataBC = mapper.convertValue(hashMapBC, PqdData.class);
|
||||||
|
PqdData pqdDataCA = mapper.convertValue(hashMapCA, PqdData.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pqdData.add(pqdDataA);
|
pqdData.add(pqdDataA);
|
||||||
pqdData.add(pqdDataB);
|
pqdData.add(pqdDataB);
|
||||||
pqdData.add(pqdDataC);
|
pqdData.add(pqdDataC);
|
||||||
pqdData.add(pqdDataM);
|
pqdData.add(pqdDataM);
|
||||||
|
pqdData.add(pqdDataAB);
|
||||||
|
pqdData.add(pqdDataBC);
|
||||||
|
pqdData.add(pqdDataCA);
|
||||||
|
|
||||||
return pqdData;
|
return pqdData;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ public class Response implements Serializable {
|
|||||||
@ApiModelProperty("文件名")
|
@ApiModelProperty("文件名")
|
||||||
private String filename;
|
private String filename;
|
||||||
|
|
||||||
|
@ApiModelProperty("解析结果状态(0-未解析 1-解析成功 2-解析失败 3-文件不存在)")
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
@ApiModelProperty("解析后数据")
|
@ApiModelProperty("解析后数据")
|
||||||
private Object obj;
|
private Object obj;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.njcn.csharmonic.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 设备监控-实时数据
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author guofeihu
|
||||||
|
* @since 2024-07-26
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ThdDataTdVO{
|
||||||
|
|
||||||
|
@ApiModelProperty("id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty("指标分组名称")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@ApiModelProperty("该分组下的各个指标的谐坡次数对应值")
|
||||||
|
private List<Map<String,Object>> thdDataVOS;
|
||||||
|
|
||||||
|
@ApiModelProperty("该指标下的谐坡次数对应值")
|
||||||
|
private List<ThdDataTdVOData> thdDataTdVODatas;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ThdDataTdVOData extends ThdDataVO{
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "国标限值名称")
|
||||||
|
private String international = "国标限值";
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "国标限值")
|
||||||
|
private Object internationalValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ThdDataSpectrumVOData{
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "指标名称")
|
||||||
|
private String showName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "国标限值")
|
||||||
|
private List<ThdDataVO> thdDataVOS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.csharmonic.service.impl;
|
package com.njcn.csharmonic.service.impl;
|
||||||
|
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.csharmonic.offline.constant.OfflineConstant;
|
||||||
import com.njcn.csharmonic.offline.log.Log;
|
import com.njcn.csharmonic.offline.log.Log;
|
||||||
import com.njcn.csharmonic.offline.log.vo.NewTaglogbuffer;
|
import com.njcn.csharmonic.offline.log.vo.NewTaglogbuffer;
|
||||||
import com.njcn.csharmonic.offline.mincfg.AnalyseComtradeCfg;
|
import com.njcn.csharmonic.offline.mincfg.AnalyseComtradeCfg;
|
||||||
@@ -8,6 +9,7 @@ import com.njcn.csharmonic.offline.mincfg.tagComtradeCfg;
|
|||||||
import com.njcn.csharmonic.offline.vo.Response;
|
import com.njcn.csharmonic.offline.vo.Response;
|
||||||
import com.njcn.csharmonic.service.OfflineDataUploadService;
|
import com.njcn.csharmonic.service.OfflineDataUploadService;
|
||||||
import com.njcn.influx.pojo.po.cs.PqdData;
|
import com.njcn.influx.pojo.po.cs.PqdData;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@@ -23,6 +25,7 @@ import java.util.List;
|
|||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @createTime 2024/7/22 13:56
|
* @createTime 2024/7/22 13:56
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class OfflineDataUploadServiceImpl implements OfflineDataUploadService {
|
public class OfflineDataUploadServiceImpl implements OfflineDataUploadService {
|
||||||
|
|
||||||
@@ -34,21 +37,39 @@ public class OfflineDataUploadServiceImpl implements OfflineDataUploadService {
|
|||||||
|
|
||||||
List<Response> responses = new ArrayList<>();
|
List<Response> responses = new ArrayList<>();
|
||||||
//min解析较为特殊需要同时解析所有文件
|
//min解析较为特殊需要同时解析所有文件
|
||||||
if(!files.isEmpty() && "min".equals(type)){
|
if(!files.isEmpty() && OfflineConstant.MIN.equals(type)){
|
||||||
Response response = new Response();
|
Response response = new Response();
|
||||||
response.setFilename("min");
|
response.setFilename(OfflineConstant.MIN);
|
||||||
List<PqdData> pqdData = AnalyseComtradeCfg.processDirectory(files);
|
List<PqdData> pqdData = null;
|
||||||
|
try {
|
||||||
|
pqdData = AnalyseComtradeCfg.processDirectory(files);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("min文件夹下的数据文件解析失败");
|
||||||
|
response.setState(2);
|
||||||
|
}
|
||||||
response.setObj(pqdData);
|
response.setObj(pqdData);
|
||||||
responses.add(response);
|
responses.add(response);
|
||||||
}else{
|
}else{
|
||||||
for(MultipartFile file : files){
|
for(MultipartFile file : files){
|
||||||
Response response = new Response();
|
Response response = new Response();
|
||||||
response.setFilename(file.getOriginalFilename());
|
response.setFilename(file.getOriginalFilename());
|
||||||
if("comtrade".equals(type) && file.getOriginalFilename().indexOf(".cfg") != -1) {
|
if(OfflineConstant.COMTRADE.equals(type) && file.getOriginalFilename().indexOf(OfflineConstant.CFG) != -1) {
|
||||||
tagComtradeCfg tagComtradeCfg = AnalyseComtradeCfg.analyseComtradeCfg(file);
|
tagComtradeCfg tagComtradeCfg = null;
|
||||||
|
try {
|
||||||
|
tagComtradeCfg = AnalyseComtradeCfg.analyseComtradeCfg(file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("当前文件:{},解析失败",file.getOriginalFilename());
|
||||||
|
response.setState(2);
|
||||||
|
}
|
||||||
response.setObj(tagComtradeCfg);
|
response.setObj(tagComtradeCfg);
|
||||||
}else if("log".equals(type) && file.getOriginalFilename().indexOf(".bin") != -1){
|
}else if(OfflineConstant.LOG.equals(type) && file.getOriginalFilename().indexOf(OfflineConstant.BIN) != -1){
|
||||||
List<NewTaglogbuffer> newTaglogbuffers = Log.convertLog(file);
|
List<NewTaglogbuffer> newTaglogbuffers = null;
|
||||||
|
try {
|
||||||
|
newTaglogbuffers = Log.convertLog(file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("当前文件:{},解析失败",file.getOriginalFilename());
|
||||||
|
response.setState(2);
|
||||||
|
}
|
||||||
response.setObj(newTaglogbuffers);
|
response.setObj(newTaglogbuffers);
|
||||||
}
|
}
|
||||||
responses.add(response);
|
responses.add(response);
|
||||||
@@ -59,7 +80,7 @@ public class OfflineDataUploadServiceImpl implements OfflineDataUploadService {
|
|||||||
bytes = baos.toByteArray();
|
bytes = baos.toByteArray();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new BusinessException("数据集对象转字节数组失败");
|
throw new BusinessException(OfflineConstant.DATATOBYTE_FAIL);
|
||||||
} finally {
|
} finally {
|
||||||
oos.close();
|
oos.close();
|
||||||
baos.close();
|
baos.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user