物解析功能

This commit is contained in:
2023-08-16 19:47:54 +08:00
parent 93fb513166
commit 4740f2b4d0
8 changed files with 108 additions and 47 deletions

View File

@@ -33,7 +33,7 @@ public interface ICsEquipmentDeliveryService extends IService<CsEquipmentDeliver
* 根据网关id修改软件信息
* @param nDid 网关id
*/
void updateSoftInfoBynDid(String nDid,String id);
void updateSoftInfoBynDid(String nDid,String id,Integer moduleNumber);
/**
* 根据网关id修改设备运行状态

View File

@@ -27,6 +27,7 @@ import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient;
@@ -128,7 +129,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
Object model = null;
try {
Thread.sleep(1500);
String key = "LINE" + nDid;
String key = AppRedisKey.LINE + nDid;
model = redisUtil.getObjectByKey(key);
if (Objects.isNull(model)){
throw new BusinessException(AccessResponseEnum.MODEL_MISS);
@@ -155,8 +156,8 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
csLedgerParam.setLevel(2);
csLedgerParam.setSort(0);
csLedgerService.addLedgerTree(csLedgerParam);
List<CsModelDto> modelId = objectToList(redisUtil.getObjectByKey("MODEL" + devAccessParam.getNDid()));
Integer clDid = null;
List<CsModelDto> modelId = objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + devAccessParam.getNDid()));
Integer clDid = null, moduleNumber = null;
//2.新增装置-模板关系、获取电能质量的逻辑设备id
for (CsModelDto item : modelId) {
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
@@ -167,15 +168,21 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
if (Objects.equals(item.getType(),1)){
clDid = item.getDid();
}
if (Objects.equals(item.getType(),0)){
moduleNumber = item.getModuleNumber();
}
}
if (Objects.isNull(clDid)){
throw new BusinessException(AccessResponseEnum.CLDID_IS_NULL);
}
if (Objects.isNull(moduleNumber)){
throw new BusinessException(AccessResponseEnum.MODULE_NUMBER_IS_NULL);
}
askDevData(devAccessParam.getNDid(),AccessEnum.L_DEV_INFO.getCode(),version,clDid);
List<RspDataDto.LdevInfo> list = new ArrayList<>();
//等待mqtt数据
Thread.sleep(500);
String key = "LINEDATA" + devAccessParam.getNDid();
String key = AppRedisKey.LINE_DATA + devAccessParam.getNDid();
list = objectToList2(redisUtil.getObjectByKey(key));
if (CollectionUtils.isEmpty(list)){
throw new BusinessException(AccessResponseEnum.LDEVINFO_IS_NULL);
@@ -188,18 +195,21 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
po.setLineId(id);
po.setName(item.getName());
po.setPosition(item.getPosition());
po.setClDid(0);
if (Objects.equals(DicDataEnum.LOAD_SIDE.getCode(),location)){
RspDataDto.LdevInfo po1 = list.stream().filter(s -> Objects.equals(s.getClDid(),1)).findFirst().orElse(null);
po.setVolGrade(po1.getVolGrade());
po.setPtRatio(po1.getPtRatio());
po.setCtRatio(po1.getCtRatio());
po.setConType(po1.getConType());
po.setClDid(1);
} else if (Objects.equals(DicDataEnum.GRID_SIDE.getCode(),location)){
RspDataDto.LdevInfo po1 = list.stream().filter(s -> Objects.equals(s.getClDid(),2)).findFirst().orElse(null);
po.setVolGrade(po1.getVolGrade());
po.setPtRatio(po1.getPtRatio());
po.setCtRatio(po1.getCtRatio());
po.setConType(po1.getConType());
po.setClDid(2);
}
po.setStatus(1);
csLinePoList.add(po);
@@ -232,7 +242,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
askDevData(devAccessParam.getNDid(),AccessEnum.SOFT_INFO.getCode(),version,0);
//等待mqtt数据
Thread.sleep(500);
String key2 = "SOFTINFO" + devAccessParam.getNDid();
String key2 = AppRedisKey.SOFTINFO + devAccessParam.getNDid();
RspDataDto.SoftInfo softInfo = JSON.parseObject(JSON.toJSONString(redisUtil.getObjectByKey(key2)), RspDataDto.SoftInfo.class);
if (Objects.isNull(softInfo)){
throw new BusinessException(AccessResponseEnum.SOFTINFO_IS_NULL);
@@ -243,16 +253,16 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
csSoftInfoPo.setAppDate(new SimpleDateFormat("yyyy-MM-dd").parse(softInfo.getAppDate()));
csSoftInfoService.save(csSoftInfoPo);
//更新设备表软件信息
csEquipmentDeliveryService.updateSoftInfoBynDid(devAccessParam.getNDid(),csSoftInfoPo.getId());
csEquipmentDeliveryService.updateSoftInfoBynDid(devAccessParam.getNDid(),csSoftInfoPo.getId(),moduleNumber);
//修改装置状态
csEquipmentDeliveryService.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.REGISTERED.getCode());
//7.发起自动接入请求
devAccess(devAccessParam.getNDid(),version);
//8.删除redis监测点模板信息
redisUtil.delete("MODEL" + devAccessParam.getNDid());
redisUtil.delete("LINE" + devAccessParam.getNDid());
redisUtil.delete("LINEDATA" + devAccessParam.getNDid());
redisUtil.delete("SOFTINFO" + devAccessParam.getNDid());
redisUtil.delete(AppRedisKey.MODEL + devAccessParam.getNDid());
redisUtil.delete(AppRedisKey.LINE + devAccessParam.getNDid());
redisUtil.delete(AppRedisKey.LINE_DATA + devAccessParam.getNDid());
redisUtil.delete(AppRedisKey.SOFTINFO + devAccessParam.getNDid());
} catch (Exception e) {
throw new BusinessException(CommonResponseEnum.FAIL);
}

View File

@@ -34,9 +34,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
}
@Override
public void updateSoftInfoBynDid(String nDid, String id) {
public void updateSoftInfoBynDid(String nDid, String id, Integer moduleNumber) {
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getSoftinfoId,id).eq(CsEquipmentDeliveryPO::getNdid,nDid);
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getSoftinfoId,id).set(CsEquipmentDeliveryPO::getModuleNumber,moduleNumber).eq(CsEquipmentDeliveryPO::getNdid,nDid);
this.update(lambdaUpdateWrapper);
}