1.手持式设备注册、接入测试联调;

2.手持式设备树功能重写;
This commit is contained in:
xy
2024-09-24 13:20:29 +08:00
parent ab59d870d8
commit dfd035b908
3 changed files with 31 additions and 16 deletions

View File

@@ -96,7 +96,7 @@ public class CsDeviceController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/wlRegister") @PostMapping("/wlRegister")
@ApiOperation("便携式设备注册") @ApiOperation("便携式设备接入")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true) @ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
}) })
@@ -109,7 +109,7 @@ public class CsDeviceController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/wlAccess") @PostMapping("/wlAccess")
@ApiOperation("便携式设备接入") @ApiOperation("便携式设备手动接入")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true) @ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
}) })

View File

@@ -2,7 +2,6 @@ package com.njcn.access.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.nacos.client.naming.utils.CollectionUtils; import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.AccessResponseEnum;
import com.njcn.access.enums.TypeEnum; import com.njcn.access.enums.TypeEnum;
import com.njcn.access.param.DevAccessParam; 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.AccessDto;
import com.njcn.access.pojo.dto.CsModelDto; import com.njcn.access.pojo.dto.CsModelDto;
import com.njcn.access.pojo.dto.ReqAndResDto; 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.system.pojo.po.SysDicTreePO;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import net.sf.cglib.core.Local;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -364,7 +361,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
DeviceLogDTO logDto = new DeviceLogDTO(); DeviceLogDTO logDto = new DeviceLogDTO();
logDto.setUserName(RequestUtil.getUserNickname()); logDto.setUserName(RequestUtil.getUserNickname());
logDto.setLoginName(RequestUtil.getUsername()); logDto.setLoginName(RequestUtil.getUsername());
logDto.setOperate("设备"+nDid+"注册"); logDto.setOperate("便携式设备"+nDid+"注册、接入");
logDto.setResult(1); logDto.setResult(1);
try { try {
Thread.sleep(2000); Thread.sleep(2000);
@@ -372,7 +369,15 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
String version = csTopicService.getVersion(nDid); String version = csTopicService.getVersion(nDid);
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData(); CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
List<CsLinePO> csLinePoList = new ArrayList<>(); List<CsLinePO> 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); Thread.sleep(2000);
List<CsModelDto> modelList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid),CsModelDto.class); List<CsModelDto> modelList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid),CsModelDto.class);
if (CollUtil.isEmpty(modelList)){ if (CollUtil.isEmpty(modelList)){
@@ -391,26 +396,32 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
po.setClDid(item.getClDev()); po.setClDid(item.getClDev());
po.setDeviceId(vo.getId()); po.setDeviceId(vo.getId());
//防止主键重复 //防止主键重复
QueryWrapper<CsLinePO> qw = new QueryWrapper(); QueryWrapper<CsLinePO> qw = new QueryWrapper<>();
qw.eq("line_id",po.getLineId()); qw.eq("line_id",po.getLineId());
if(csLineService.getBaseMapper().selectList(qw).isEmpty()){ if(csLineService.getBaseMapper().selectList(qw).isEmpty()){
csLinePoList.add(po); 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); csLineService.saveBatch(csLinePoList);
//2.生成装置和模板的关系表 //4.生成装置和模板的关系表
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm(); CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
csDevModelRelationAddParm.setDevId(vo.getId()); csDevModelRelationAddParm.setDevId(vo.getId());
csDevModelRelationAddParm.setModelId(modelList.get(0).getModelId()); csDevModelRelationAddParm.setModelId(modelList.get(0).getModelId());
csDevModelRelationAddParm.setDid(modelList.get(0).getDid()); csDevModelRelationAddParm.setDid(modelList.get(0).getDid());
csDevModelRelationService.addDevModelRelation(csDevModelRelationAddParm); csDevModelRelationService.addDevModelRelation(csDevModelRelationAddParm);
//3.修改装置状态为注册状态 //5.发起自动接入请求
csEquipmentDeliveryService.updateStatusBynDid(nDid, AccessEnum.REGISTERED.getCode());
//4.发起自动接入请求
devAccessAskTemplate(nDid,version,1); devAccessAskTemplate(nDid,version,1);
//5.存储日志 //6.存储日志
csLogsFeignClient.addUserLog(logDto); csLogsFeignClient.addUserLog(logDto);
//6.存储设备调试日志表 //7.存储设备调试日志表
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO(); CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
csEquipmentProcess.setDevId(nDid); csEquipmentProcess.setDevId(nDid);
csEquipmentProcess.setOperator(RequestUtil.getUserIndex()); csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
@@ -419,7 +430,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
csEquipmentProcess.setProcess(4); csEquipmentProcess.setProcess(4);
csEquipmentProcess.setStatus(1); csEquipmentProcess.setStatus(1);
processFeignClient.add(csEquipmentProcess); processFeignClient.add(csEquipmentProcess);
//7.删除redis监测点模板信息 //8.删除redis监测点模板信息
redisUtil.delete(AppRedisKey.MODEL + nDid); redisUtil.delete(AppRedisKey.MODEL + nDid);
redisUtil.delete(AppRedisKey.LINE + nDid); redisUtil.delete(AppRedisKey.LINE + nDid);
} catch (Exception e) { } catch (Exception e) {

View File

@@ -33,7 +33,11 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
csLedger.setPid("0"); csLedger.setPid("0");
csLedger.setPids("0"); csLedger.setPids("0");
} else { } else {
csLedger.setPids(fatherCsLedger.getPids() + "," + csLedgerParam.getPid()); if (Objects.isNull(fatherCsLedger)) {
csLedger.setPids("0");
} else {
csLedger.setPids(fatherCsLedger.getPids() + "," + csLedgerParam.getPid());
}
} }
this.save(csLedger); this.save(csLedger);
return csLedger; return csLedger;