新增云协议相关内容

This commit is contained in:
xy
2025-09-16 18:31:55 +08:00
parent 1a3e443be1
commit 0fda2354eb
17 changed files with 1027 additions and 105 deletions

View File

@@ -128,11 +128,12 @@ public class AskDeviceDataController extends BaseController {
@ApiOperation("询问云前置实时数据")
@ApiImplicitParams({
@ApiImplicitParam(name = "devId", value = "装置id"),
@ApiImplicitParam(name = "lineId", value = "监测点id")
@ApiImplicitParam(name = "lineId", value = "监测点id"),
@ApiImplicitParam(name = "nodeId", value = "前置id")
})
public HttpResult<String> askCldRealData(@RequestParam("devId") String devId, @RequestParam("lineId") String lineId){
public HttpResult<String> askCldRealData(@RequestParam("devId") String devId, @RequestParam("lineId") String lineId, @RequestParam("nodeId") String nodeId){
String methodDescribe = getMethodDescribe("askCldRealData");
askDeviceDataService.askCldRealData(devId,lineId);
askDeviceDataService.askCldRealData(devId,lineId,nodeId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}

View File

@@ -19,6 +19,7 @@ import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.pojo.enums.RedisKeyEnum;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.rt.pojo.dto.BaseRealDataSet;
import com.njcn.user.api.AppUserFeignClient;
@@ -120,6 +121,13 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
});
}
}
//云前置设备心跳丢失处理
if(expiredKey.startsWith(RedisKeyEnum.CLD_HEART_BEAT_KEY.getKey())){
String node = expiredKey.split(":")[1];
String nodeId = node.substring(0, node.length() - 1);
int processNo = Integer.parseInt(node.substring(node.length() - 1));
equipmentFeignClient.updateCldDevStatus(nodeId,processNo);
}
}
//主任务

View File

@@ -22,5 +22,5 @@ public interface AskDeviceDataService {
*/
void askRealData(String nDid, Integer idx, Integer size);
void askCldRealData(String devId, String lineId);
void askCldRealData(String devId, String lineId, String nodeId);
}

View File

@@ -213,14 +213,15 @@ public class AskDeviceDataServiceImpl implements AskDeviceDataService {
}
@Override
public void askCldRealData(String devId, String lineId) {
public void askCldRealData(String devId, String lineId, String nodeId) {
RealDataMessage realDataMessage = new RealDataMessage();
realDataMessage.setDevSeries(devId);
realDataMessage.setLine(lineId);
int lastDigit = Character.getNumericValue(lineId.charAt(lineId.length() - 1));
realDataMessage.setLine(lastDigit);
realDataMessage.setRealData(true);
realDataMessage.setSoeData(true);
realDataMessage.setLimit(20);
realDataMessageTemplate.sendMember(realDataMessage);
realDataMessageTemplate.sendMember(realDataMessage,nodeId);
}
public Object getDeviceMid(String nDid) {

View File

@@ -849,12 +849,18 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
* 解析数据集、详细数据
*/
private void analysisDataSet(TemplateDto templateDto,String pId){
String code;
List<CsDataSet> setList = new ArrayList<>();
List<CsDataArray> arrayList = new ArrayList<>();
List<DataSetDto> dataSetList = templateDto.getDataSet();
String devType = templateDto.getDevType();
DictTreeVO dictTreeVO = dictTreeFeignClient.queryByCode(devType).getData();
String code = dictTreeFeignClient.queryById(dictTreeVO.getPid()).getData().getCode();
if (!DicDataEnum.DEV_CLD.getCode().equals(devType)){
DictTreeVO dictTreeVO = dictTreeFeignClient.queryByCode(devType).getData();
code = dictTreeFeignClient.queryById(dictTreeVO.getPid()).getData().getCode();
} else {
code = null;
}
//逻辑设备录入
if (CollectionUtil.isNotEmpty(dataSetList)){
dataSetList.forEach(item1->{

View File

@@ -371,7 +371,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
}
@Override
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public String wlDevRegister(String nDid) {
String result = "fail";
// 设备状态判断
@@ -404,7 +404,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
Thread.sleep(2000);
List<CsModelDto> modelList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid),CsModelDto.class);
if (CollUtil.isEmpty(modelList)) {
throwExceptionAndLog(AccessResponseEnum.MODEL_ERROR, logDto);
throwExceptionAndLog(nDid,AccessResponseEnum.MODEL_ERROR, logDto);
}
List<CsDataSet> list = csDataSetService.getDataSetData(modelList.get(0).getModelId());
list.forEach(item->{
@@ -459,6 +459,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
logDto.setResult(0);
logDto.setFailReason(e.getMessage());
csLogsFeignClient.addUserLog(logDto);
resetFactory(nDid);
throw new BusinessException(AccessResponseEnum.ACCESS_ERROR);
}
return result;
@@ -478,18 +479,18 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
DeviceLogDTO logDto = createLogDto("当前设备"+nDid+"状态判断");
CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentBynDid(nDid);
if (Objects.isNull(csEquipmentDeliveryVO.getNdid())) {
throwExceptionAndLog(AccessResponseEnum.NDID_NO_FIND, logDto);
throwExceptionAndLog(nDid,AccessResponseEnum.NDID_NO_FIND, logDto);
}
SysDicTreePO sysDicTreePo = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData();
if (Objects.isNull(sysDicTreePo)) {
throwExceptionAndLog(AccessResponseEnum.DEV_NOT_FIND, logDto);
throwExceptionAndLog(nDid,AccessResponseEnum.DEV_NOT_FIND, logDto);
}
String code = sysDicTreePo.getCode();
if (!Objects.equals(code, DicDataEnum.PORTABLE.getCode())) {
throwExceptionAndLog(AccessResponseEnum.DEV_IS_NOT_PORTABLE, logDto);
throwExceptionAndLog(nDid,AccessResponseEnum.DEV_IS_NOT_PORTABLE, logDto);
}
if (!mqttUtil.judgeClientOnline("NJCN-" + nDid.substring(nDid.length() - 6))) {
throwExceptionAndLog(AccessResponseEnum.MISSING_CLIENT, logDto);
throwExceptionAndLog(nDid,AccessResponseEnum.MISSING_CLIENT, logDto);
}
}
@@ -503,7 +504,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentBynDid(nDid);
SysDicTreePO dictData = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevModel()).getData();
if (Objects.isNull(dictData)) {
throwExceptionAndLog(AccessResponseEnum.DEV_MODEL_NOT_FIND, logDto);
throwExceptionAndLog(nDid,AccessResponseEnum.DEV_MODEL_NOT_FIND, logDto);
}
String devModel = dictData.getCode();
zhiLianRegister(nDid,devModel);
@@ -518,10 +519,11 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
return logDto;
}
private void throwExceptionAndLog(AccessResponseEnum responseEnum, DeviceLogDTO logDto) {
private void throwExceptionAndLog(String nDid,AccessResponseEnum responseEnum, DeviceLogDTO logDto) {
logDto.setResult(0);
logDto.setFailReason(responseEnum.getMessage());
csLogsFeignClient.addUserLog(logDto);
resetFactory(nDid);
throw new BusinessException(responseEnum);
}