refactor(device): 更新设备监测点信息接口调用方式

- 引入 LineInfoParam 参数对象统一接口参数传递
- 移除 DictData 依赖减少不必要的导入
- 修改 getLineInfo 方法调用适配新的参数结构
- 在多个服务类中实现统一的参数封装逻辑
- 优化 Redis 缓存中监测点信息的处理流程
- 提升代码可读性和维护性
This commit is contained in:
xy
2026-05-26 10:53:14 +08:00
parent 71107fe36d
commit 200004913e
4 changed files with 37 additions and 25 deletions

View File

@@ -56,7 +56,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
@@ -487,29 +486,34 @@ public class MqttMessageHandler {
heartbeatService.receiveHeartbeat(nDid);
//有心跳,则将装置改成在线
//csEquipmentDeliveryService.updateRunStatusBynDid(nDid,AccessEnum.ONLINE.getCode());
//处理心跳
ReqAndResDto.Res reqAndResParam = new ReqAndResDto.Res();
reqAndResParam.setMid(res.getMid());
reqAndResParam.setDid(0);
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_29.getCode()));
reqAndResParam.setCode(200);
//fixme 前置处理的时间应该是UTC时间所以需要加8小时。
String json = "{Time:"+(System.currentTimeMillis()/1000+8*3600)+"}";
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(json);
reqAndResParam.setMsg(jsonObject);
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,gson.toJson(reqAndResParam),1,false);
//处理业务逻辑
Object object = res.getMsg();
if (!Objects.isNull(object)){
List<String> abnormalList = new ArrayList<>();
if (object instanceof ArrayList<?>){
abnormalList.addAll((List<String>) object);
//处理心跳 判断设备是否接入,如果设备已经接入则响应,不然忽略
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
if (Objects.nonNull(po)) {
if (po.getUsageStatus() == 1 && po.getRunStatus() == 2 && po.getStatus() == 3) {
ReqAndResDto.Res reqAndResParam = new ReqAndResDto.Res();
reqAndResParam.setMid(res.getMid());
reqAndResParam.setDid(0);
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_29.getCode()));
reqAndResParam.setCode(200);
//fixme 前置处理的时间应该是UTC时间所以需要加8小时。
String json = "{Time:"+(System.currentTimeMillis()/1000+8*3600)+"}";
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(json);
reqAndResParam.setMsg(jsonObject);
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,gson.toJson(reqAndResParam),1,false);
//处理业务逻辑
Object object = res.getMsg();
if (!Objects.isNull(object)){
List<String> abnormalList = new ArrayList<>();
if (object instanceof ArrayList<?>){
abnormalList.addAll((List<String>) object);
}
//todo APF设备不存在逻辑设备掉线的情况网关下的设备会存在
abnormalList.forEach(item->{
System.out.println("异常设备ID"+item);
});
}
}
//todo APF设备不存在逻辑设备掉线的情况网关下的设备会存在
abnormalList.forEach(item->{
System.out.println("异常设备ID"+item);
});
}
break;
case 4866:

View File

@@ -28,5 +28,5 @@ public interface ICsTopicService extends IService<CsTopic> {
*/
String getVersion(String nDid);
void deleteByNDid(String nDid);
}

View File

@@ -388,6 +388,8 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
appLineTopologyDiagramPOQueryWrapper.in("line_id",collect);
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
}
//删除topic表
csTopicService.deleteByNDid(nDid);
//清空缓存
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION+nDid);
}

View File

@@ -7,7 +7,6 @@ import com.njcn.access.mapper.CsTopicMapper;
import com.njcn.access.pojo.po.CsTopic;
import com.njcn.access.service.ICsTopicService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
@@ -42,4 +41,11 @@ public class CsTopicServiceImpl extends ServiceImpl<CsTopicMapper, CsTopic> impl
}
return version;
}
@Override
public void deleteByNDid(String nDid) {
LambdaQueryWrapper<CsTopic> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsTopic::getNDid,nDid);
this.remove(lambdaQueryWrapper);
}
}