1、便携式设备台账调整
2、事件入库参数优化
This commit is contained in:
@@ -5,7 +5,6 @@ import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -18,6 +17,11 @@ import java.util.List;
|
||||
@Data
|
||||
public class DevAccessParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("工程id")
|
||||
private String engineeringId;
|
||||
|
||||
@ApiModelProperty("项目id")
|
||||
@NotNull(message = "项目id不能为空")
|
||||
private String projectId;
|
||||
|
||||
@@ -120,4 +120,14 @@ public class CsDeviceController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/autoPortableLedger")
|
||||
@ApiOperation("调整便携式设备的台账信息")
|
||||
@ReturnMsg
|
||||
public HttpResult<String> autoPortableLedger(){
|
||||
String methodDescribe = getMethodDescribe("autoPortableLedger");
|
||||
csDeviceService.autoPortableLedger();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,4 +54,6 @@ public interface ICsDeviceService {
|
||||
* @param nDid 设备识别码
|
||||
*/
|
||||
void wlAccess(String nDid);
|
||||
|
||||
String autoPortableLedger();
|
||||
}
|
||||
|
||||
@@ -24,4 +24,6 @@ public interface ICsLedgerService extends IService<CsLedger> {
|
||||
*/
|
||||
CsLedger addLedgerTree(CsLedgerParam csLedgerParam);
|
||||
|
||||
void updatePortableLedger(String engineeringId, String projectId);
|
||||
|
||||
}
|
||||
|
||||
@@ -22,9 +22,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.*;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.pojo.param.CsDevModelRelationAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.param.*;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
@@ -33,6 +31,9 @@ import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -80,6 +81,10 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
private final ChannelObjectUtil channelObjectUtil;
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
private final DataSetFeignClient dataSetFeignClient;
|
||||
private final CsMarketDataFeignClient csMarketDataFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final EngineeringFeignClient engineeringFeignClient;
|
||||
private final AppProjectFeignClient appProjectFeignClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@@ -130,15 +135,16 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
|
||||
}
|
||||
//5.判断当前流程是否是合法的
|
||||
if (csEquipmentDeliveryVO.getProcess() > type){
|
||||
logDto.setResult(0);
|
||||
logDto.setFailReason(AccessResponseEnum.PROCESS_SAME_ERROR.getMessage());
|
||||
throw new BusinessException(AccessResponseEnum.PROCESS_SAME_ERROR);
|
||||
} else if (csEquipmentDeliveryVO.getProcess() < type){
|
||||
logDto.setResult(0);
|
||||
logDto.setFailReason(AccessResponseEnum.PROCESS_MISSING_ERROR.getMessage());
|
||||
throw new BusinessException(AccessResponseEnum.PROCESS_MISSING_ERROR);
|
||||
}
|
||||
//note(重要说明) 这边流程原先是三个阶段,在实际应用中嫌麻烦,简化为一个流程
|
||||
// if (csEquipmentDeliveryVO.getProcess() > type){
|
||||
// logDto.setResult(0);
|
||||
// logDto.setFailReason(AccessResponseEnum.PROCESS_SAME_ERROR.getMessage());
|
||||
// throw new BusinessException(AccessResponseEnum.PROCESS_SAME_ERROR);
|
||||
// } else if (csEquipmentDeliveryVO.getProcess() < type){
|
||||
// logDto.setResult(0);
|
||||
// logDto.setFailReason(AccessResponseEnum.PROCESS_MISSING_ERROR.getMessage());
|
||||
// throw new BusinessException(AccessResponseEnum.PROCESS_MISSING_ERROR);
|
||||
// }
|
||||
//6.询问设备支持的主题信息
|
||||
//将支持的主题入库
|
||||
askTopic(nDid);
|
||||
@@ -296,9 +302,9 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
//8.删除redis监测点模板信息
|
||||
redisUtil.delete(AppRedisKey.MODEL + devAccessParam.getNDid());
|
||||
redisUtil.delete(AppRedisKey.LINE + devAccessParam.getNDid());
|
||||
//存储日志
|
||||
//9.存储日志
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
//存储设备调试日志表
|
||||
//10.存储设备调试日志表
|
||||
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
|
||||
csEquipmentProcess.setDevId(devAccessParam.getNDid());
|
||||
csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
|
||||
@@ -309,6 +315,18 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
csEquipmentProcess.setStatus(1);
|
||||
}
|
||||
processFeignClient.add(csEquipmentProcess);
|
||||
//11.这里会出现工程用户接入设备时,如果当前工程用户并没有关注,接入之后应该将用户和工程关联起来
|
||||
List<UserVO> users = userFeignClient.getUserVOByIdList(Collections.singletonList(RequestUtil.getUserIndex())).getData();
|
||||
if (CollectionUtil.isNotEmpty(users)) {
|
||||
UserVO userVO = users.get(0);
|
||||
if (CollectionUtil.isNotEmpty(userVO.getRoleCode()) && userVO.getRoleCode().contains(AppRoleEnum.ENGINEERING_USER.getCode())) {
|
||||
csMarketDataFeignClient.insertData(userVO.getId(), devAccessParam.getEngineeringId());
|
||||
}
|
||||
}
|
||||
//12.如果设备接入,发现接入的工程项目和之前预设的工程项目不一致,则需要更新原来的预设,使用接入的工程项目
|
||||
if (!Objects.equals(vo.getAssociatedEngineering(),devAccessParam.getEngineeringId()) || !Objects.equals(vo.getAssociatedProject(),devAccessParam.getProjectId())) {
|
||||
equipmentFeignClient.updateLedger(devAccessParam.getNDid(), devAccessParam.getEngineeringId(), devAccessParam.getProjectId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logDto.setResult(0);
|
||||
logDto.setFailReason(e.getMessage());
|
||||
@@ -327,12 +345,13 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
param.setNDid(nDid);
|
||||
param.setStatus(1);
|
||||
param.setRunStatus(1);
|
||||
boolean isConnectDev = DicDataEnum.CONNECT_DEV.getCode().equals(dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData().getCode());
|
||||
if (isConnectDev) {
|
||||
param.setProcess(2);
|
||||
} else {
|
||||
param.setProcess(4);
|
||||
}
|
||||
// boolean isConnectDev = DicDataEnum.CONNECT_DEV.getCode().equals(dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData().getCode());
|
||||
// if (isConnectDev) {
|
||||
// param.setProcess(2);
|
||||
// } else {
|
||||
// param.setProcess(4);
|
||||
// }
|
||||
param.setProcess(4);
|
||||
csEquipmentDeliveryService.devResetFactory(param);
|
||||
//清除关系表
|
||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
|
||||
@@ -396,9 +415,13 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||
//1.录入装置台账信息
|
||||
//note 1、这边发现便携式设备注册时,如果没有工程 项目,后期特殊处理非常的麻烦,这边接入时,先查询工程 项目,如果没有则创建;如果存在则直接使用;
|
||||
//note 2、查询之前已经接入过的便携式设备,如果存在修改台账信息,添加工程、项目
|
||||
String projectId = this.autoPortableLedger();
|
||||
//新增便携式设备
|
||||
CsLedgerParam csLedgerParam = new CsLedgerParam();
|
||||
csLedgerParam.setId(vo.getId());
|
||||
csLedgerParam.setPid("0");
|
||||
csLedgerParam.setPid(projectId);
|
||||
csLedgerParam.setName(vo.getName());
|
||||
csLedgerParam.setLevel(2);
|
||||
csLedgerParam.setSort(0);
|
||||
@@ -445,7 +468,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
//5.发起自动接入请求
|
||||
Thread.sleep(2000);
|
||||
//先获取版本
|
||||
// String version = csTopicService.getVersion(nDid);
|
||||
//String version = csTopicService.getVersion(nDid);
|
||||
String version = "V1";
|
||||
devAccessAskTemplate(nDid,version,1);
|
||||
//6.修改流程,便携式设备接入成功即为实际环境
|
||||
@@ -481,6 +504,37 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
this.devAccessAskTemplate(nDid,version,1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String autoPortableLedger() {
|
||||
CsEngineeringPO csEngineeringPO = engineeringFeignClient.getEngineeringByName("便携式工程").getData();
|
||||
if (csEngineeringPO == null) {
|
||||
//新增便携式工程
|
||||
CsEngineeringAddParm param = new CsEngineeringAddParm();
|
||||
param.setName("便携式工程");
|
||||
param.setProvince("320000000000");
|
||||
param.setCity("320100000000");
|
||||
param.setDescription("便携式工程");
|
||||
param.setSort(Integer.MAX_VALUE);
|
||||
csEngineeringPO = engineeringFeignClient.addEngineering(param).getData();
|
||||
}
|
||||
|
||||
AppProjectPO csProjectPO = appProjectFeignClient.getProjectByName("便携式项目").getData();
|
||||
if (csProjectPO == null) {
|
||||
//新增便携式项目
|
||||
AppProjectAddParm param = new AppProjectAddParm();
|
||||
param.setEngineeringId(csEngineeringPO.getId());
|
||||
param.setName("便携式项目");
|
||||
param.setArea("园区");
|
||||
param.setDescription("便携式项目");
|
||||
param.setTopoIds(Collections.singletonList("99ed9b9c8cf9007cc4d2ac4c7127b7e4"));
|
||||
param.setSort(Integer.MAX_VALUE);
|
||||
csProjectPO = appProjectFeignClient.addAppProject(param).getData();
|
||||
}
|
||||
//修改已存在的便携式设备
|
||||
csLedgerService.updatePortableLedger(csEngineeringPO.getId(),csProjectPO.getId());
|
||||
return csProjectPO.getId();
|
||||
}
|
||||
|
||||
private void checkDeviceStatus(String nDid) {
|
||||
DeviceLogDTO logDto = createLogDto("当前设备"+nDid+"状态判断");
|
||||
CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentBynDid(nDid);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.njcn.access.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.mapper.CsLedgerMapper;
|
||||
import com.njcn.access.service.ICsLedgerService;
|
||||
@@ -8,8 +10,11 @@ import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -43,4 +48,35 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
return csLedger;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void updatePortableLedger(String engineeringId, String projectId) {
|
||||
//先查询有没有历史的便携式设备
|
||||
List<CsLedger> portableDevices = this.list(
|
||||
new LambdaQueryWrapper<CsLedger>()
|
||||
.eq(CsLedger::getPid, "0")
|
||||
.eq(CsLedger::getLevel, 2)
|
||||
.eq(CsLedger::getState, 1));
|
||||
if (CollectionUtil.isNotEmpty(portableDevices)) {
|
||||
portableDevices.forEach(item->{
|
||||
item.setPid(projectId);
|
||||
item.setPids("0," + engineeringId + "," + projectId);
|
||||
});
|
||||
this.updateBatchById(portableDevices);
|
||||
//获取监测点id
|
||||
List<String> devList = portableDevices.stream().map(CsLedger::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(CsLedger::getPid, devList).eq(CsLedger::getState,1).eq(CsLedger::getLevel,3);
|
||||
List<CsLedger> pointList = this.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(pointList)) {
|
||||
pointList.forEach(item->{
|
||||
String pidS = item.getPids();
|
||||
String devPid = pidS.split(",")[1];
|
||||
item.setPids("0," + engineeringId + "," + projectId + "," + devPid);
|
||||
});
|
||||
this.updateBatchById(pointList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -167,6 +167,9 @@ public class EventServiceImpl implements IEventService {
|
||||
if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_VVADEPTH)) {
|
||||
csEvent.setAmplitude(Double.parseDouble(param.getData().toString()));
|
||||
}
|
||||
if (Objects.equals(param.getName(),"Evt_Param_Phase")) {
|
||||
csEvent.setPhase(param.getData().toString());
|
||||
}
|
||||
fields.put(param.getName(),param.getData());
|
||||
}
|
||||
//只有治理型号的设备有监测位置
|
||||
@@ -221,6 +224,7 @@ public class EventServiceImpl implements IEventService {
|
||||
rmpEventDetailPo.setEventDescribe(getTag(item.getTag()));
|
||||
rmpEventDetailPo.setDealFlag(0);
|
||||
rmpEventDetailPo.setFileFlag(0);
|
||||
rmpEventDetailPo.setPhase(item.getPhase());
|
||||
wlRmpEventDetailMapper.insert(rmpEventDetailPo);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user