refactor(device): 更新设备监测点信息接口调用方式
- 引入 LineInfoParam 参数对象统一接口参数传递 - 移除 DictData 依赖减少不必要的导入 - 修改 getLineInfo 方法调用适配新的参数结构 - 在多个服务类中实现统一的参数封装逻辑 - 优化 Redis 缓存中监测点信息的处理流程 - 提升代码可读性和维护性
This commit is contained in:
@@ -56,7 +56,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import javax.validation.ConstraintViolation;
|
import javax.validation.ConstraintViolation;
|
||||||
import javax.validation.Validator;
|
import javax.validation.Validator;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.DateTimeFormatterBuilder;
|
import java.time.format.DateTimeFormatterBuilder;
|
||||||
@@ -487,29 +486,34 @@ public class MqttMessageHandler {
|
|||||||
heartbeatService.receiveHeartbeat(nDid);
|
heartbeatService.receiveHeartbeat(nDid);
|
||||||
//有心跳,则将装置改成在线
|
//有心跳,则将装置改成在线
|
||||||
//csEquipmentDeliveryService.updateRunStatusBynDid(nDid,AccessEnum.ONLINE.getCode());
|
//csEquipmentDeliveryService.updateRunStatusBynDid(nDid,AccessEnum.ONLINE.getCode());
|
||||||
//处理心跳
|
//处理心跳 判断设备是否接入,如果设备已经接入则响应,不然忽略
|
||||||
ReqAndResDto.Res reqAndResParam = new ReqAndResDto.Res();
|
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
||||||
reqAndResParam.setMid(res.getMid());
|
if (Objects.nonNull(po)) {
|
||||||
reqAndResParam.setDid(0);
|
if (po.getUsageStatus() == 1 && po.getRunStatus() == 2 && po.getStatus() == 3) {
|
||||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
ReqAndResDto.Res reqAndResParam = new ReqAndResDto.Res();
|
||||||
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_29.getCode()));
|
reqAndResParam.setMid(res.getMid());
|
||||||
reqAndResParam.setCode(200);
|
reqAndResParam.setDid(0);
|
||||||
//fixme 前置处理的时间应该是UTC时间,所以需要加8小时。
|
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||||
String json = "{Time:"+(System.currentTimeMillis()/1000+8*3600)+"}";
|
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_29.getCode()));
|
||||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(json);
|
reqAndResParam.setCode(200);
|
||||||
reqAndResParam.setMsg(jsonObject);
|
//fixme 前置处理的时间应该是UTC时间,所以需要加8小时。
|
||||||
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,gson.toJson(reqAndResParam),1,false);
|
String json = "{Time:"+(System.currentTimeMillis()/1000+8*3600)+"}";
|
||||||
//处理业务逻辑
|
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(json);
|
||||||
Object object = res.getMsg();
|
reqAndResParam.setMsg(jsonObject);
|
||||||
if (!Objects.isNull(object)){
|
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,gson.toJson(reqAndResParam),1,false);
|
||||||
List<String> abnormalList = new ArrayList<>();
|
//处理业务逻辑
|
||||||
if (object instanceof ArrayList<?>){
|
Object object = res.getMsg();
|
||||||
abnormalList.addAll((List<String>) object);
|
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;
|
break;
|
||||||
case 4866:
|
case 4866:
|
||||||
|
|||||||
@@ -28,5 +28,5 @@ public interface ICsTopicService extends IService<CsTopic> {
|
|||||||
*/
|
*/
|
||||||
String getVersion(String nDid);
|
String getVersion(String nDid);
|
||||||
|
|
||||||
|
void deleteByNDid(String nDid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -388,6 +388,8 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
appLineTopologyDiagramPOQueryWrapper.in("line_id",collect);
|
appLineTopologyDiagramPOQueryWrapper.in("line_id",collect);
|
||||||
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
|
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
|
||||||
}
|
}
|
||||||
|
//删除topic表
|
||||||
|
csTopicService.deleteByNDid(nDid);
|
||||||
//清空缓存
|
//清空缓存
|
||||||
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION+nDid);
|
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION+nDid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.njcn.access.mapper.CsTopicMapper;
|
|||||||
import com.njcn.access.pojo.po.CsTopic;
|
import com.njcn.access.pojo.po.CsTopic;
|
||||||
import com.njcn.access.service.ICsTopicService;
|
import com.njcn.access.service.ICsTopicService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -42,4 +41,11 @@ public class CsTopicServiceImpl extends ServiceImpl<CsTopicMapper, CsTopic> impl
|
|||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByNDid(String nDid) {
|
||||||
|
LambdaQueryWrapper<CsTopic> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(CsTopic::getNDid,nDid);
|
||||||
|
this.remove(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user