治理设备新增功能
This commit is contained in:
@@ -5,7 +5,11 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.mq.message.AppAutoDataMessage;
|
||||
import com.njcn.rt.api.fallback.RtClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
@@ -15,4 +19,7 @@ public interface RtFeignClient {
|
||||
|
||||
@PostMapping("/rtAnalysis")
|
||||
HttpResult<String> analysis(AppAutoDataMessage appAutoDataMessage);
|
||||
|
||||
@PostMapping("/apfRtAnalysis")
|
||||
HttpResult<Map<String,Float>> apfRtAnalysis(@RequestBody @Validated AppAutoDataMessage appAutoDataMessage);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@@ -27,7 +29,13 @@ public class RtClientFallbackFactory implements FallbackFactory<RtFeignClient> {
|
||||
|
||||
@Override
|
||||
public HttpResult<String> analysis(AppAutoDataMessage appAutoDataMessage) {
|
||||
log.error("{}异常,降级处理,异常为:{}","实时数据解析",cause.toString());
|
||||
log.error("{}异常,降级处理,异常为:{}","便携式实时数据解析",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Map<String,Float>> apfRtAnalysis(AppAutoDataMessage appAutoDataMessage) {
|
||||
log.error("{}异常,降级处理,异常为:{}","APF实时数据解析",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
@@ -45,5 +47,14 @@ public class RtController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/apfRtAnalysis")
|
||||
@ApiOperation("APF实时数据解析")
|
||||
@ApiImplicitParam(name = "appAutoDataMessage", value = "数据实体", required = true)
|
||||
public HttpResult<String> apfRtAnalysis(@RequestBody @Validated AppAutoDataMessage appAutoDataMessage){
|
||||
String methodDescribe = getMethodDescribe("apfRtAnalysis");
|
||||
rtService.apfRtAnalysis(appAutoDataMessage);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,4 +8,10 @@ import com.njcn.mq.message.AppAutoDataMessage;
|
||||
public interface IRtService {
|
||||
|
||||
void analysis(AppAutoDataMessage appAutoDataMessage);
|
||||
|
||||
/**
|
||||
* APF数据解析
|
||||
* @param appAutoDataMessage
|
||||
*/
|
||||
void apfRtAnalysis(AppAutoDataMessage appAutoDataMessage);
|
||||
}
|
||||
|
||||
@@ -97,6 +97,36 @@ public class RtServiceImpl implements IRtService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apfRtAnalysis(AppAutoDataMessage appAutoDataMessage) {
|
||||
List<CsDataArray> dataArrayList;
|
||||
String lineId;
|
||||
//监测点id
|
||||
if (appAutoDataMessage.getDid() == 1){
|
||||
lineId = appAutoDataMessage.getId() + "0";
|
||||
} else {
|
||||
lineId = appAutoDataMessage.getId() + appAutoDataMessage.getMsg().getClDid();
|
||||
}
|
||||
//获取监测点基础信息
|
||||
CsLinePO po = csLineFeignClient.getById(lineId).getData();
|
||||
//获取数据集 dataSet
|
||||
Integer idx = appAutoDataMessage.getMsg().getDsNameIdx();
|
||||
CsDataSet dataSet = dataSetFeignClient.getDataSetByIdx(po.getDataModelId(),idx).getData();
|
||||
|
||||
String key = "BaseRealData:" + lineId + idx;
|
||||
Object object = redisUtil.getObjectByKey(key);
|
||||
if (Objects.isNull(object)){
|
||||
dataArrayList = saveBaseRealDataSet(key,dataSet.getId());
|
||||
} else {
|
||||
dataArrayList = channelObjectUtil.objectToList(object,CsDataArray.class);
|
||||
}
|
||||
//根据dataArray解析数据
|
||||
AppAutoDataMessage.DataArray item = appAutoDataMessage.getMsg().getDataArray().get(0);
|
||||
Map<String,Float> map = getData(dataArrayList,item);
|
||||
int data = Math.round(map.get("Apf_ModWorkingSts" + "M"));
|
||||
redisUtil.saveByKeyWithExpire("ApfRtData:" + appAutoDataMessage.getMid(),data,10L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间处理
|
||||
*/
|
||||
|
||||
@@ -3,8 +3,11 @@ package com.njcn.zlevent.service.impl;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.pojo.po.CsDeviceOnlineLogs;
|
||||
import com.njcn.access.utils.ChannelObjectUtil;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
@@ -33,6 +36,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.njcn.csdevice.enums.AlgorithmResponseEnum.DATA_ERROR;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 告警事件表 服务实现类
|
||||
@@ -63,7 +68,7 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
||||
//获取装置id
|
||||
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(appEventMessage.getId()).getData();
|
||||
List<SysDicTreePO> dictTreeList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.DICT_TREE),SysDicTreePO.class);
|
||||
String code = dictTreeList.stream().filter(item->Objects.equals(item.getId(),po.getDevType())).findFirst().orElse(null).getCode();
|
||||
String code = dictTreeList.stream().filter(item->Objects.equals(item.getId(),po.getDevType())).findFirst().orElse(null).getCode();
|
||||
|
||||
try {
|
||||
//便携式设备
|
||||
@@ -82,6 +87,17 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
||||
List<AppEventMessage.DataArray> dataArray = appEventMessage.getMsg().getDataArray();
|
||||
for (AppEventMessage.DataArray item : dataArray) {
|
||||
eventTime = eventService.timeFormat(item.getDataTimeSec(),item.getDataTimeUSec());
|
||||
tag = item.getName();
|
||||
//判断各模块事件,如果上次模块事件和这次一致,则不记录
|
||||
CsEventPO csEventPO = this.lambdaQuery().eq(CsEventPO::getLineId,lineId)
|
||||
.eq(CsEventPO::getClDid,appEventMessage.getMsg().getClDid())
|
||||
.eq(CsEventPO::getProcess,po.getProcess())
|
||||
.orderByDesc(CsEventPO::getStartTime).last("LIMIT 1").one();
|
||||
if (csEventPO != null) {
|
||||
if (Objects.equals(csEventPO.getTag(),tag)) {
|
||||
throw new BusinessException(DATA_ERROR);
|
||||
}
|
||||
}
|
||||
//事件入库
|
||||
CsEventPO csEvent = new CsEventPO();
|
||||
csEvent.setLineId(lineId);
|
||||
@@ -90,7 +106,6 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
||||
csEvent.setProcess(po.getProcess());
|
||||
csEvent.setCode(item.getCode());
|
||||
csEvent.setStartTime(eventTime);
|
||||
tag = item.getName();
|
||||
csEvent.setTag(tag);
|
||||
csEvent.setType(3);
|
||||
csEvent.setClDid(appEventMessage.getMsg().getClDid());
|
||||
|
||||
Reference in New Issue
Block a user