diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceController.java b/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceController.java index e9fffc5..506f9b9 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceController.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceController.java @@ -96,7 +96,7 @@ public class CsDeviceController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/wlRegister") - @ApiOperation("便携式设备注册") + @ApiOperation("便携式设备接入") @ApiImplicitParams({ @ApiImplicitParam(name = "nDid", value = "设备识别码", required = true) }) @@ -109,7 +109,7 @@ public class CsDeviceController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/wlAccess") - @ApiOperation("便携式设备接入") + @ApiOperation("便携式设备手动接入") @ApiImplicitParams({ @ApiImplicitParam(name = "nDid", value = "设备识别码", required = true) }) diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java index 8d386e7..7a6675b 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java @@ -2,7 +2,6 @@ package com.njcn.access.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.IdUtil; import com.alibaba.nacos.client.naming.utils.CollectionUtils; import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -11,7 +10,6 @@ import com.njcn.access.enums.AccessEnum; import com.njcn.access.enums.AccessResponseEnum; import com.njcn.access.enums.TypeEnum; import com.njcn.access.param.DevAccessParam; -import com.njcn.access.pojo.RspDataDto; import com.njcn.access.pojo.dto.AccessDto; import com.njcn.access.pojo.dto.CsModelDto; import com.njcn.access.pojo.dto.ReqAndResDto; @@ -37,7 +35,6 @@ import com.njcn.system.enums.DicDataEnum; import com.njcn.system.pojo.po.SysDicTreePO; import com.njcn.web.utils.RequestUtil; import lombok.AllArgsConstructor; -import net.sf.cglib.core.Local; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -364,7 +361,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { DeviceLogDTO logDto = new DeviceLogDTO(); logDto.setUserName(RequestUtil.getUserNickname()); logDto.setLoginName(RequestUtil.getUsername()); - logDto.setOperate("设备"+nDid+"注册"); + logDto.setOperate("便携式设备"+nDid+"注册、接入"); logDto.setResult(1); try { Thread.sleep(2000); @@ -372,7 +369,15 @@ public class CsDeviceServiceImpl implements ICsDeviceService { String version = csTopicService.getVersion(nDid); CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData(); List csLinePoList = new ArrayList<>(); - //1.根据模板获取监测点个数,插入监测点表 + //1.录入装置台账信息 + CsLedgerParam csLedgerParam = new CsLedgerParam(); + csLedgerParam.setId(vo.getId()); + csLedgerParam.setPid("0"); + csLedgerParam.setName(vo.getName()); + csLedgerParam.setLevel(2); + csLedgerParam.setSort(0); + csLedgerService.addLedgerTree(csLedgerParam); + //2.根据模板获取监测点个数,插入监测点表 Thread.sleep(2000); List modelList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid),CsModelDto.class); if (CollUtil.isEmpty(modelList)){ @@ -391,26 +396,32 @@ public class CsDeviceServiceImpl implements ICsDeviceService { po.setClDid(item.getClDev()); po.setDeviceId(vo.getId()); //防止主键重复 - QueryWrapper qw = new QueryWrapper(); + QueryWrapper qw = new QueryWrapper<>(); qw.eq("line_id",po.getLineId()); if(csLineService.getBaseMapper().selectList(qw).isEmpty()){ csLinePoList.add(po); } + //3.生成台账树监测点数据 + CsLedgerParam param = new CsLedgerParam(); + param.setId(nDid + item.getClDev().toString()); + param.setPid(vo.getId()); + param.setName(item.getClDev().toString() + "#监测点"); + param.setLevel(3); + param.setSort(0); + csLedgerService.addLedgerTree(param); }); csLineService.saveBatch(csLinePoList); - //2.生成装置和模板的关系表 + //4.生成装置和模板的关系表 CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm(); csDevModelRelationAddParm.setDevId(vo.getId()); csDevModelRelationAddParm.setModelId(modelList.get(0).getModelId()); csDevModelRelationAddParm.setDid(modelList.get(0).getDid()); csDevModelRelationService.addDevModelRelation(csDevModelRelationAddParm); - //3.修改装置状态为注册状态 - csEquipmentDeliveryService.updateStatusBynDid(nDid, AccessEnum.REGISTERED.getCode()); - //4.发起自动接入请求 + //5.发起自动接入请求 devAccessAskTemplate(nDid,version,1); - //5.存储日志 + //6.存储日志 csLogsFeignClient.addUserLog(logDto); - //6.存储设备调试日志表 + //7.存储设备调试日志表 CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO(); csEquipmentProcess.setDevId(nDid); csEquipmentProcess.setOperator(RequestUtil.getUserIndex()); @@ -419,7 +430,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { csEquipmentProcess.setProcess(4); csEquipmentProcess.setStatus(1); processFeignClient.add(csEquipmentProcess); - //7.删除redis监测点模板信息 + //8.删除redis监测点模板信息 redisUtil.delete(AppRedisKey.MODEL + nDid); redisUtil.delete(AppRedisKey.LINE + nDid); } catch (Exception e) { diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLedgerServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLedgerServiceImpl.java index 7afa1df..9eefc11 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLedgerServiceImpl.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLedgerServiceImpl.java @@ -33,7 +33,11 @@ public class CsLedgerServiceImpl extends ServiceImpl i csLedger.setPid("0"); csLedger.setPids("0"); } else { - csLedger.setPids(fatherCsLedger.getPids() + "," + csLedgerParam.getPid()); + if (Objects.isNull(fatherCsLedger)) { + csLedger.setPids("0"); + } else { + csLedger.setPids(fatherCsLedger.getPids() + "," + csLedgerParam.getPid()); + } } this.save(csLedger); return csLedger;