From 1beaa4992ff843c54deb11b552fe354e187a5b79 Mon Sep 17 00:00:00 2001 From: xuyang <748613696@qq.com> Date: Tue, 12 Sep 2023 15:50:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A8=A1=E6=9D=BF=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/njcn/access/enums/TypeEnum.java | 7 ++ .../njcn/access/pojo/dto/devModel/ApfDto.java | 8 ++ .../access/pojo/dto/devModel/ClDevDto.java | 4 + .../CsDeviceOnlineLogsController.java | 54 ----------- .../controller/CsGatewayController.java | 2 + .../access/handler/MqttMessageHandler.java | 2 - .../runner/AccessApplicationRunner.java | 94 +++++++++---------- .../service/impl/CsDevModelServiceImpl.java | 33 ++++--- .../service/impl/CsDeviceServiceImpl.java | 12 ++- .../service/impl/CsLedgerServiceImpl.java | 2 +- .../stat/service/impl/StatServiceImpl.java | 8 +- .../service/impl/CsWaveServiceImpl.java | 4 +- .../service/impl/EventServiceImpl.java | 5 +- 13 files changed, 104 insertions(+), 131 deletions(-) delete mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceOnlineLogsController.java diff --git a/iot-access/access-api/src/main/java/com/njcn/access/enums/TypeEnum.java b/iot-access/access-api/src/main/java/com/njcn/access/enums/TypeEnum.java index 26969b6..08ca8fe 100644 --- a/iot-access/access-api/src/main/java/com/njcn/access/enums/TypeEnum.java +++ b/iot-access/access-api/src/main/java/com/njcn/access/enums/TypeEnum.java @@ -80,6 +80,13 @@ public enum TypeEnum { INSET("InSet","内部定值"), CTRL("Ctrl","控制"), + /** + * 监测点位置信息 + */ + GUID("guid","电网侧"), + LOAD("load","负载侧"), + + ; private final String code; diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ApfDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ApfDto.java index 4763a86..49d1b76 100644 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ApfDto.java +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ApfDto.java @@ -46,4 +46,12 @@ public class ApfDto implements Serializable { @ApiModelProperty("数据统计方法(max,min,avg,cp95)") private List statMethod; + @SerializedName("HarmStart") + @ApiModelProperty("开始次数") + private Integer harmStart; + + @SerializedName("HarmEnd") + @ApiModelProperty("结束次数") + private Integer harmEnd; + } diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ClDevDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ClDevDto.java index 83d0dd5..41eb8aa 100644 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ClDevDto.java +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ClDevDto.java @@ -26,6 +26,10 @@ public class ClDevDto implements Serializable { @ApiModelProperty(value = "逻辑子设备型号") private String devType; + @SerializedName("Location") + @ApiModelProperty(value = "安装位置") + private String location; + @SerializedName("DataList") @NotEmpty(message = "数据模型列表,不可为空") private List dataList; diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceOnlineLogsController.java b/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceOnlineLogsController.java deleted file mode 100644 index 1dc2041..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceOnlineLogsController.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.njcn.access.controller; - - -import com.njcn.access.pojo.po.CsDeviceOnlineLogs; -import com.njcn.access.service.ICsDevModelService; -import com.njcn.access.service.ICsDeviceOnlineLogsService; -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.annotation.ReturnMsg; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import com.njcn.web.controller.BaseController; -import org.springframework.web.multipart.MultipartFile; - -/** - *

- * 设备状态日志表,记录设备掉线上线的情况 前端控制器 - *

- * - * @author xuyang - * @since 2023-09-08 - */ -@Slf4j -@RestController -@RequestMapping("/csDeviceOnlineLogs") -@Api(tags = "设备上线日志表") -@AllArgsConstructor -public class CsDeviceOnlineLogsController extends BaseController { - - private final ICsDeviceOnlineLogsService csDeviceOnlineLogsService; - - @OperateInfo(info = LogEnum.BUSINESS_COMMON) - @PostMapping("/find") - @ApiOperation("find") - @ApiImplicitParam(name = "nDid", value = "设备识别码", required = true) - public HttpResult devRegister(@RequestParam String nDid){ - CsDeviceOnlineLogs vo = csDeviceOnlineLogsService.findLastData(nDid); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, "123"); - } - - - -} - diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsGatewayController.java b/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsGatewayController.java index 265b984..1416dfb 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsGatewayController.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsGatewayController.java @@ -18,6 +18,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.List; @@ -35,6 +36,7 @@ import java.util.List; @Api(tags = "治理网关信息") @AllArgsConstructor @Validated +@ApiIgnore public class CsGatewayController extends BaseController { private final ICsGatewayService csGatewayService; diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java b/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java index 4401e19..02719a5 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java @@ -30,7 +30,6 @@ import com.njcn.csdevice.api.DataSetFeignClient; import com.njcn.csdevice.api.DevModelFeignClient; import com.njcn.csdevice.pojo.po.CsDataSet; import com.njcn.csdevice.pojo.po.CsDevModelPO; -import com.njcn.mq.constant.BusinessTopic; import com.njcn.mq.message.AppAutoDataMessage; import com.njcn.mq.message.AppEventMessage; import com.njcn.mq.message.AppFileMessage; @@ -348,7 +347,6 @@ public class MqttMessageHandler { break; case 2: List ldevInfo = JSON.parseArray(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.LdevInfo.class); - //fixme 默认第一个监测点是负载侧,第二个是电网测,后期数据错误可以在移动端调整 redisUtil.saveByKeyWithExpire(AppRedisKey.LINE_DATA+nDid,ldevInfo,600L); break; default: diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/runner/AccessApplicationRunner.java b/iot-access/access-boot/src/main/java/com/njcn/access/runner/AccessApplicationRunner.java index 716417d..fc726b4 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/runner/AccessApplicationRunner.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/runner/AccessApplicationRunner.java @@ -1,47 +1,47 @@ -//package com.njcn.access.runner; -// -//import com.njcn.access.service.ICsEquipmentDeliveryService; -//import com.njcn.access.service.ICsTopicService; -//import com.njcn.access.service.impl.CsDeviceServiceImpl; -//import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.boot.ApplicationArguments; -//import org.springframework.boot.ApplicationRunner; -//import org.springframework.stereotype.Component; -// -//import javax.annotation.Resource; -//import java.util.List; -//import java.util.Objects; -// -///** -// * 类的介绍:用来重新发起设备的接入,存在程序意外停止了,缓存失效导致无法更新装置的状态,所以需要在程序启动时发起设备的接入 -// * -// * @author xuyang -// * @version 1.0.0 -// * @createTime 2023/8/28 13:57 -// */ -//@Component -//@Slf4j -//public class AccessApplicationRunner implements ApplicationRunner { -// -// @Resource -// private CsDeviceServiceImpl csDeviceService; -// -// @Resource -// private ICsTopicService csTopicService; -// -// @Resource -// private ICsEquipmentDeliveryService csEquipmentDeliveryService; -// -// @Override -// public void run(ApplicationArguments args){ -// List list = csEquipmentDeliveryService.getAll(); -// list.forEach(item->{ -// String version = csTopicService.getVersion(item.getNdid()); -// if (!Objects.isNull(version)){ -// csDeviceService.devAccess(item.getNdid(),version); -// } -// }); -// } -// -//} +package com.njcn.access.runner; + +import com.njcn.access.service.ICsEquipmentDeliveryService; +import com.njcn.access.service.ICsTopicService; +import com.njcn.access.service.impl.CsDeviceServiceImpl; +import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Objects; + +/** + * 类的介绍:用来重新发起设备的接入,存在程序意外停止了,缓存失效导致无法更新装置的状态,所以需要在程序启动时发起设备的接入 + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/8/28 13:57 + */ +@Component +@Slf4j +public class AccessApplicationRunner implements ApplicationRunner { + + @Resource + private CsDeviceServiceImpl csDeviceService; + + @Resource + private ICsTopicService csTopicService; + + @Resource + private ICsEquipmentDeliveryService csEquipmentDeliveryService; + + @Override + public void run(ApplicationArguments args){ + List list = csEquipmentDeliveryService.getAll(); + list.forEach(item->{ + String version = csTopicService.getVersion(item.getNdid()); + if (!Objects.isNull(version)){ + csDeviceService.devAccess(item.getNdid(),version); + } + }); + } + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDevModelServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDevModelServiceImpl.java index f85152d..6a18ac7 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDevModelServiceImpl.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDevModelServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil; import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.njcn.access.enums.AccessResponseEnum; import com.njcn.access.enums.DataModel; +import com.njcn.access.enums.TypeEnum; import com.njcn.access.mapper.CsDevModelMapper; import com.njcn.access.pojo.dto.data.*; import com.njcn.access.pojo.dto.devModel.*; @@ -34,7 +35,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; import java.sql.Date; import java.util.*; import java.util.concurrent.atomic.AtomicReference; @@ -105,7 +105,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService { logDto.setResult(0); logDto.setFailReason(AccessResponseEnum.MODEL_ANALYSIS_ERROR.getMessage()); csLogsFeignClient.addUserLog(logDto); - throw new BusinessException(AccessResponseEnum.MODEL_ANALYSIS_ERROR); + throw new BusinessException(e.getMessage()); } } @@ -208,6 +208,13 @@ public class CsDevModelServiceImpl implements ICsDevModelService { eleEpdPqdParam.setPhase(apf.getPhase()); } eleEpdPqdParam.setClassId(classId); + if (Objects.equals(apf.getHarmStart(),0.5) && Objects.equals(apf.getHarmEnd(),49.5)){ + eleEpdPqdParam.setHarmStart((int)(apf.getHarmStart()+0.5)); + eleEpdPqdParam.setHarmEnd((int)(apf.getHarmEnd()+49.5)); + } else { + eleEpdPqdParam.setHarmStart((int)(apf.getHarmStart()*1.0)); + eleEpdPqdParam.setHarmEnd((int)(apf.getHarmEnd()*1.0)); + } result.add(eleEpdPqdParam); } }); @@ -432,10 +439,10 @@ public class CsDevModelServiceImpl implements ICsDevModelService { eleEpdPqdParam.setUnit(epd.getUnit()); if (Objects.equals(epd.getHarmStart(),0.5) && Objects.equals(epd.getHarmEnd(),49.5)){ eleEpdPqdParam.setHarmStart((int)(epd.getHarmStart()+0.5)); - eleEpdPqdParam.setHarmEnd((int)(epd.getHarmStart()+49.5)); + eleEpdPqdParam.setHarmEnd((int)(epd.getHarmEnd()+49.5)); } else { eleEpdPqdParam.setHarmStart((int)(epd.getHarmStart()*1.0)); - eleEpdPqdParam.setHarmEnd((int)(epd.getHarmStart()*1.0)); + eleEpdPqdParam.setHarmEnd((int)(epd.getHarmEnd()*1.0)); } eleEpdPqdParam.setStatMethod(epd.getStatMethod()); eleEpdPqdParam.setDataType(id); @@ -449,7 +456,6 @@ public class CsDevModelServiceImpl implements ICsDevModelService { List pqdDto = templateDto.getPqdDto(); pqdDto.forEach(pqd->{ String id = dicDataFeignClient.getDicDataByCode(item).getData().getId(); - String classId = dicDataFeignClient.getDicDataByCode(DataModel.PQD_DATA).getData().getId(); List list = epdFeignClient.judgeExist(pqd.getName(),id).getData(); if (CollectionUtil.isEmpty(list)){ @@ -467,10 +473,10 @@ public class CsDevModelServiceImpl implements ICsDevModelService { eleEpdPqdParam.setUnit(pqd.getUnit()); if (Objects.equals(pqd.getHarmStart(),0.5) && Objects.equals(pqd.getHarmEnd(),49.5)){ eleEpdPqdParam.setHarmStart((int)(pqd.getHarmStart()+0.5)); - eleEpdPqdParam.setHarmEnd((int)(pqd.getHarmStart()+49.5)); + eleEpdPqdParam.setHarmEnd((int)(pqd.getHarmEnd()+49.5)); } else { eleEpdPqdParam.setHarmStart((int)(pqd.getHarmStart()*1.0)); - eleEpdPqdParam.setHarmEnd((int)(pqd.getHarmStart()*1.0)); + eleEpdPqdParam.setHarmEnd((int)(pqd.getHarmEnd()*1.0)); } eleEpdPqdParam.setDataType(id); eleEpdPqdParam.setClassId(classId); @@ -981,13 +987,12 @@ public class CsDevModelServiceImpl implements ICsDevModelService { CsLineModel csLineModel = new CsLineModel(); csLineModel.setLineId(IdUtil.fastSimpleUUID()); csLineModel.setPid(pId); - //fixme 默认第一个监测点是负载侧,第二个是电网测,后期数据错误可以在移动端调整 - if (Objects.equals(item.getClDid(),1)){ - csLineModel.setName("负载侧监测点"); - csLineModel.setPosition(dicDataFeignClient.getDicDataByCode(DicDataEnum.LOAD_SIDE.getCode()).getData().getId()); - } else if (Objects.equals(item.getClDid(),2)){ + if (Objects.equals(item.getClDid(),1) || Objects.equals(item.getLocation(), TypeEnum.GUID.getCode())){ csLineModel.setName("电网侧监测点"); csLineModel.setPosition(dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData().getId()); + } else if (Objects.equals(item.getClDid(),2) || Objects.equals(item.getLocation(), TypeEnum.LOAD.getCode())){ + csLineModel.setName("负载侧监测点"); + csLineModel.setPosition(dicDataFeignClient.getDicDataByCode(DicDataEnum.LOAD_SIDE.getCode()).getData().getId()); } result.add(csLineModel); }); @@ -1019,10 +1024,10 @@ public class CsDevModelServiceImpl implements ICsDevModelService { showName = "模块4数据"; break; case "Ds$Pqd$Stat$01": - showName = "负载侧数据"; + showName = "电网侧数据"; break; case "Ds$Pqd$Stat$02": - showName = "电网侧数据"; + showName = "负载侧数据"; break; default: break; diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java index 2663aa1..e3d98a4 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java @@ -249,7 +249,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { po.setName(item.getName()); po.setPosition(item.getPosition()); po.setClDid(0); - if (Objects.equals(DicDataEnum.LOAD_SIDE.getCode(),location)){ + if (Objects.equals(DicDataEnum.GRID_SIDE.getCode(),location)){ RspDataDto.LdevInfo po1 = list.stream().filter(s -> Objects.equals(s.getClDid(),1)).findFirst().orElse(null); po.setLineId(devAccessParam.getNDid() + "1"); param.setId(devAccessParam.getNDid() + "1"); @@ -259,7 +259,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { po.setCtRatio(po1.getCtRatio()); po.setConType(po1.getConType()); po.setClDid(1); - } else if (Objects.equals(DicDataEnum.GRID_SIDE.getCode(),location)){ + } else if (Objects.equals(DicDataEnum.LOAD_SIDE.getCode(),location)){ RspDataDto.LdevInfo po1 = list.stream().filter(s -> Objects.equals(s.getClDid(),2)).findFirst().orElse(null); po.setLineId(devAccessParam.getNDid() + "2"); param.setId(devAccessParam.getNDid() + "2"); @@ -337,7 +337,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { csLogsFeignClient.addUserLog(logDto); } catch (Exception e) { logDto.setResult(0); - logDto.setFailReason(CommonResponseEnum.FAIL.getMessage()); + logDto.setFailReason(e.getMessage()); csLogsFeignClient.addUserLog(logDto); throw new BusinessException(CommonResponseEnum.FAIL); } @@ -363,6 +363,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode()); reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_1.getCode())); reqAndResParam.setExpire(-1); + logger.info("询问主题报文为:" + new Gson().toJson(reqAndResParam)); publisher.send("/Pfm/DevTopic/"+nDid, new Gson().toJson(reqAndResParam),1,false); } @@ -382,6 +383,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { accessDto.setNdid(nDid); accessDto.setDevType(devType); reqAndResParam.setMsg(accessDto); + logger.info("注册报文为:" + new Gson().toJson(reqAndResParam)); publisher.send("/Pfm/DevReg/"+nDid, new Gson().toJson(reqAndResParam),1,false); } @@ -425,7 +427,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { askDataDto.setEndTime(-1); if (Objects.equals(dataType,AccessEnum.SOFT_INFO.getCode())){ askDataDto.setCldid(0); - reqAndResParam.setDid(2); + reqAndResParam.setDid(0); askDataDto.setDataType(1); } else if (Objects.equals(dataType,AccessEnum.L_DEV_INFO.getCode())){ askDataDto.setCldid(-1); @@ -433,7 +435,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { askDataDto.setDataType(2); } reqAndResParam.setMsg(askDataDto); - System.out.println("111==:"+new Gson().toJson(reqAndResParam)); + logger.info("询问设备软件信息(监测点信息):" + new Gson().toJson(reqAndResParam)); publisher.send("/Pfm/DevCmd/"+version+"/"+nDid, new Gson().toJson(reqAndResParam),1,false); } diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLedgerServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLedgerServiceImpl.java index 7ac84f3..7afa1df 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLedgerServiceImpl.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLedgerServiceImpl.java @@ -25,7 +25,7 @@ public class CsLedgerServiceImpl extends ServiceImpl i @Override public CsLedger addLedgerTree(CsLedgerParam csLedgerParam) { - CsLedger fatherCsLedger = this.lambdaQuery().eq(CsLedger::getId,csLedgerParam.getPid()).one(); + CsLedger fatherCsLedger = this.lambdaQuery().eq(CsLedger::getId,csLedgerParam.getPid()).eq(CsLedger::getState,1).one(); CsLedger csLedger = new CsLedger(); BeanUtils.copyProperties(csLedgerParam,csLedger); csLedger.setState(1); diff --git a/iot-analysis/analysis-stat/stat-boot/src/main/java/com/njcn/stat/service/impl/StatServiceImpl.java b/iot-analysis/analysis-stat/stat-boot/src/main/java/com/njcn/stat/service/impl/StatServiceImpl.java index ef2a74a..37c3e2c 100644 --- a/iot-analysis/analysis-stat/stat-boot/src/main/java/com/njcn/stat/service/impl/StatServiceImpl.java +++ b/iot-analysis/analysis-stat/stat-boot/src/main/java/com/njcn/stat/service/impl/StatServiceImpl.java @@ -63,7 +63,7 @@ public class StatServiceImpl implements IStatService { //1.根据设备网络识别码获取设备id,查询到所用的模板,用来判断模板的类型(治理模板还是电能质量模板) //2.解析appAutoDataMessage的Did,来判断当前数据是治理数据还是电能质量数据 //3-1.治理数据则获取治理的dataArray,并且查询治理的监测点 - //3-2.电能质量数据则还需要判断Cldid的值,在dataSet里面筛选正确的数据集,查询dataArray(默认Cldid=1为负载侧监测点、Cldid=2为电网侧监测点) + //3-2.电能质量数据则还需要判断Cldid的值,在dataSet里面筛选正确的数据集,查询dataArray //4.查询dataArray数据,查询对应的字典数据,然后将数据组装,录入influxDB DataArrayParam dataArrayParam = new DataArrayParam(); dataArrayParam.setId(appAutoDataMessage.getId()); @@ -142,9 +142,9 @@ public class StatServiceImpl implements IStatService { } if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){ map.put(0,item.getLineId()); - } else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){ - map.put(1,item.getLineId()); } else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){ + map.put(1,item.getLineId()); + } else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){ map.put(2,item.getLineId()); } } @@ -210,7 +210,7 @@ public class StatServiceImpl implements IStatService { fields.put(dataArrayList.get(i).getName(),floats.get(i)); fields.put(InfluxDBTableConstant.IS_ABNORMAL,item.getDataTag()); //fixme 这边前置传递的应该是UTC时间,但是前置说是传递的北京时间,讨论了一下没太理解。这边暂时先这样处理,influx入库处理成北京时间,减去8小时。 - Point point = influxDbUtils.pointBuilder(tableName, item.getDataTimeSec()-8*3600, TimeUnit.SECONDS, tags, fields); + Point point = influxDbUtils.pointBuilder(tableName, item.getDataTimeSec(), TimeUnit.SECONDS, tags, fields); BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build(); batchPoints.point(point); records.add(batchPoints.lineProtocol()); diff --git a/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/CsWaveServiceImpl.java b/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/CsWaveServiceImpl.java index 278fd0d..4822639 100644 --- a/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/CsWaveServiceImpl.java +++ b/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/CsWaveServiceImpl.java @@ -148,9 +148,9 @@ public class CsWaveServiceImpl implements ICsWaveService { } if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){ map.put(0,item.getLineId()); - } else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){ - map.put(1,item.getLineId()); } else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){ + map.put(1,item.getLineId()); + } else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){ map.put(2,item.getLineId()); } } diff --git a/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/EventServiceImpl.java b/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/EventServiceImpl.java index 7ecb5be..99e71b4 100644 --- a/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/EventServiceImpl.java +++ b/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/EventServiceImpl.java @@ -105,6 +105,7 @@ public class EventServiceImpl implements IEventService { csEvent.setStartTime(timeFormat(item.getDataTimeSec(),item.getDataTimeUSec())); csEvent.setTag(item.getName()); csEvent.setType(0); + csEvent.setClDid(appEventMessage.getMsg().getClDid()); list1.add(csEvent); //参数入库 Map map = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.ELE_EPD_PQD)), Map.class); @@ -156,9 +157,9 @@ public class EventServiceImpl implements IEventService { } if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){ map.put(0,item.getLineId()); - } else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){ - map.put(1,item.getLineId()); } else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){ + map.put(1,item.getLineId()); + } else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){ map.put(2,item.getLineId()); } }