Merge pull request '优化' (#1) from wireless into master
Reviewed-on: system-Backend/iot#1
This commit is contained in:
@@ -17,6 +17,7 @@ import com.njcn.access.pojo.dto.CsModelDto;
|
||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||
import com.njcn.access.pojo.param.DeviceStatusParam;
|
||||
import com.njcn.access.service.*;
|
||||
import com.njcn.access.utils.ChannelObjectUtil;
|
||||
import com.njcn.access.utils.MqttUtil;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
@@ -77,6 +78,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final CsDeviceUserPOService csDeviceUserPOService;
|
||||
private final ICsDataSetService csDataSetService;
|
||||
private final ChannelObjectUtil channelObjectUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@@ -202,7 +204,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
csLedgerParam.setLevel(2);
|
||||
csLedgerParam.setSort(0);
|
||||
csLedgerService.addLedgerTree(csLedgerParam);
|
||||
List<CsModelDto> modelId = objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + devAccessParam.getNDid()));
|
||||
List<CsModelDto> modelId = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + devAccessParam.getNDid()),CsModelDto.class);
|
||||
//2.新增装置-模板关系、获取电能质量的逻辑设备id
|
||||
for (CsModelDto item : modelId) {
|
||||
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
||||
@@ -365,14 +367,14 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
logDto.setOperate("设备"+nDid+"注册");
|
||||
logDto.setResult(1);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(2000);
|
||||
//获取版本
|
||||
String version = csTopicService.getVersion(nDid);
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||
//1.根据模板获取监测点个数,插入监测点表
|
||||
Thread.sleep(1000);
|
||||
List<CsModelDto> modelList = objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid));
|
||||
Thread.sleep(2000);
|
||||
List<CsModelDto> modelList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid),CsModelDto.class);
|
||||
if (CollUtil.isEmpty(modelList)){
|
||||
try {
|
||||
throwExceptionAndLog(AccessResponseEnum.MODEL_ERROR, logDto);
|
||||
@@ -513,7 +515,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid,new Gson().toJson(reqAndResParam),1,false);
|
||||
//接收到模板,判断模板是否存在,替换模板,发起接入
|
||||
Thread.sleep(2000);
|
||||
List<CsModelDto> modelId = objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid));
|
||||
List<CsModelDto> modelId = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid),CsModelDto.class);
|
||||
if (CollUtil.isNotEmpty(modelId)) {
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
//重新录入装置和模板关系信息
|
||||
@@ -571,16 +573,4 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
logger.info("注册报文为:{}", new Gson().toJson(reqAndResParam));
|
||||
publisher.send("/Pfm/DevReg/"+nDid, new Gson().toJson(reqAndResParam),1,false);
|
||||
}
|
||||
|
||||
public List<CsModelDto> objectToList(Object object) {
|
||||
List<CsModelDto> urlList = new ArrayList<>();
|
||||
if (object != null) {
|
||||
if (object instanceof ArrayList<?>) {
|
||||
for (Object o : (List<?>) object) {
|
||||
urlList.add((CsModelDto) o);
|
||||
}
|
||||
}
|
||||
}
|
||||
return urlList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user