新增云前置相关功能
This commit is contained in:
@@ -7,6 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.param.IcdLedgerParam;
|
||||
import com.njcn.csdevice.param.IcdParam;
|
||||
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceInfo;
|
||||
import com.njcn.csdevice.service.IcdService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -16,10 +17,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -56,4 +54,14 @@ public class IcdController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getLedgerById")
|
||||
@ApiOperation("根据Id获取台账信息")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true)
|
||||
public HttpResult<CldLedgerVo> getLedgerById(@RequestParam String id){
|
||||
String methodDescribe = getMethodDescribe("getLedgerById");
|
||||
CldLedgerVo vo = icdService.getLedgerById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -171,8 +171,9 @@ public class CslineController extends BaseController {
|
||||
@PostMapping("/updateCldLine")
|
||||
@ApiOperation("修改云前置监测点")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true)
|
||||
public HttpResult<List<CsLinePO>> updateCldLine(@RequestParam("id") String id) {
|
||||
public HttpResult<List<CsLinePO>> updateCldLine(@RequestBody CsLineParam param) {
|
||||
String methodDescribe = getMethodDescribe("updateCldLine");
|
||||
csLinePOService.updateCldLine(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -182,6 +183,7 @@ public class CslineController extends BaseController {
|
||||
@ApiImplicitParam(name = "id", value = "监测点id", required = true)
|
||||
public HttpResult<List<CsLinePO>> delCldLine(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("delCldLine");
|
||||
csLinePOService.deleteCldLine(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,8 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class EngineeringController extends BaseController {
|
||||
|
||||
|
||||
private final CsEngineeringService csEngineeringService;
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/addEngineering")
|
||||
@ApiOperation("新增工程")
|
||||
|
||||
@@ -178,4 +178,9 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
|
||||
*/
|
||||
void flipCldDevStatus(String devId, Integer status);
|
||||
|
||||
/**
|
||||
* 根据项目id获取设备列表
|
||||
*/
|
||||
List<CsEquipmentDeliveryPO> getDevListByProjectId(String projectId);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.param.IcdLedgerParam;
|
||||
import com.njcn.csdevice.param.IcdParam;
|
||||
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceInfo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -12,4 +13,6 @@ public interface IcdService {
|
||||
|
||||
void addLedgerInfo(IcdLedgerParam param);
|
||||
|
||||
CldLedgerVo getLedgerById(String id);
|
||||
|
||||
}
|
||||
|
||||
@@ -927,6 +927,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsEquipmentDeliveryPO> getDevListByProjectId(String projectId) {
|
||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper();
|
||||
csLedgerQueryWrapper.lambda().eq(CsLedger::getPid, projectId).eq(CsLedger::getState,1);
|
||||
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
|
||||
List<String> collect = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList());
|
||||
return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId,collect).list();
|
||||
}
|
||||
|
||||
//根据前置机id获取装置数量
|
||||
public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) {
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
@@ -169,8 +169,10 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteCldLine(String id) {
|
||||
|
||||
this.removeById(id);
|
||||
csLedgerMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.access.utils.ChannelObjectUtil;
|
||||
@@ -12,6 +13,7 @@ import com.njcn.csdevice.pojo.param.AppProjectAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceInfo;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
@@ -19,6 +21,7 @@ import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -27,6 +30,7 @@ import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class IcdServiceImpl implements IcdService {
|
||||
@@ -38,6 +42,7 @@ class IcdServiceImpl implements IcdService {
|
||||
private final AppProjectService appProjectService;
|
||||
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final ICsLedgerService csLedgerService;
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
@Override
|
||||
@@ -119,12 +124,126 @@ class IcdServiceImpl implements IcdService {
|
||||
// 第四种:从设备创建
|
||||
else if (CollectionUtil.isNotEmpty(param.getDevice())) {
|
||||
handleFromDeviceCreation(param);
|
||||
//新增完监测点后,需要通知前置修改台账信息
|
||||
|
||||
//todo 新增完监测点后,需要通知前置修改台账信息
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CldLedgerVo getLedgerById(String id) {
|
||||
CldLedgerVo vo = new CldLedgerVo();
|
||||
CsLedger csLedger = csLedgerService.findDataById(id);
|
||||
if (ObjectUtil.isNull(csLedger)) {
|
||||
return vo;
|
||||
}
|
||||
Integer level = csLedger.getLevel();
|
||||
String[] pids = csLedger.getPids().split(StrUtil.COMMA);
|
||||
// 设置工程信息(所有级别都需要)
|
||||
setEngineeringInfo(vo, level, pids, id);
|
||||
// 根据级别设置不同的业务数据
|
||||
switch (level) {
|
||||
case 0:
|
||||
handleLevel0(vo, id);
|
||||
break;
|
||||
case 1:
|
||||
handleLevel1(vo, id, pids);
|
||||
break;
|
||||
case 2:
|
||||
handleLevel2(vo, id, pids);
|
||||
break;
|
||||
case 3:
|
||||
handleLevel3(vo, id, pids);
|
||||
break;
|
||||
default:
|
||||
log.warn("Unknown ledger level: {}", level);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置工程信息
|
||||
*/
|
||||
private void setEngineeringInfo(CldLedgerVo vo, Integer level, String[] pids, String id) {
|
||||
String engineeringId;
|
||||
|
||||
if (level == 0) {
|
||||
// 0级本身就是工程
|
||||
engineeringId = id;
|
||||
} else if (level >= 1 && pids.length > 1) {
|
||||
// 1-3级的工程ID在pids[1]位置
|
||||
engineeringId = pids[1];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
CsEngineeringPO po = csEngineeringService.queryEngineeringById(engineeringId);
|
||||
if (po != null) {
|
||||
vo.setEngineeringId(po.getId());
|
||||
vo.setEngineeringName(po.getName());
|
||||
vo.setProvince(po.getProvince());
|
||||
vo.setCity(po.getCity());
|
||||
vo.setEngineeringDescription(po.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理0级数据(工程级别)
|
||||
*/
|
||||
private void handleLevel0(CldLedgerVo vo, String id) {
|
||||
List<AppProjectPO> projectInfoList = appProjectService.getProjectByEngineering(Collections.singletonList(id));
|
||||
vo.setProjectInfoList(projectInfoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理1级数据(项目级别)
|
||||
*/
|
||||
private void handleLevel1(CldLedgerVo vo, String id, String[] pids) {
|
||||
// 设置项目信息
|
||||
List<AppProjectPO> appProjectPOS = appProjectService.listByIds(Collections.singletonList(id));
|
||||
vo.setProjectInfoList(appProjectPOS);
|
||||
// 设置设备信息
|
||||
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryService.getDevListByProjectId(id);
|
||||
vo.setDeviceInfoList(devList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理2级数据(设备级别)
|
||||
*/
|
||||
private void handleLevel2(CldLedgerVo vo, String id, String[] pids) {
|
||||
// 设置项目信息(项目ID在pids[2]位置)
|
||||
if (pids.length > 2) {
|
||||
String projectId = pids[2];
|
||||
List<AppProjectPO> project = appProjectService.listByIds(Collections.singletonList(projectId));
|
||||
vo.setProjectInfoList(project);
|
||||
}
|
||||
// 设置设备信息
|
||||
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(Collections.singletonList(id));
|
||||
vo.setDeviceInfoList(csEquipmentDeliveryPOS);
|
||||
// 设置线路信息
|
||||
List<CsLinePO> list = csLinePOService.queryByDevId(id);
|
||||
vo.setLineInfoList(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理3级数据(线路级别)
|
||||
*/
|
||||
private void handleLevel3(CldLedgerVo vo, String id, String[] pids) {
|
||||
// 设置项目信息(项目ID在pids[2]位置)
|
||||
if (pids.length > 2) {
|
||||
String projectId = pids[2];
|
||||
List<AppProjectPO> appProjectPOS = appProjectService.listByIds(Collections.singletonList(projectId));
|
||||
vo.setProjectInfoList(appProjectPOS);
|
||||
}
|
||||
// 设置设备信息(设备ID在pids[3]位置)
|
||||
if (pids.length > 3) {
|
||||
String deviceId = pids[3];
|
||||
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(Collections.singletonList(deviceId));
|
||||
vo.setDeviceInfoList(csEquipmentDeliveryPOS);
|
||||
}
|
||||
// 设置线路信息
|
||||
List<CsLinePO> line = csLinePOService.listByIds(Collections.singletonList(id));
|
||||
vo.setLineInfoList(line);
|
||||
}
|
||||
|
||||
public void sendFrontLedger() {
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -23,10 +24,9 @@ import java.util.stream.Stream;
|
||||
public class InfluxDbParamUtil {
|
||||
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
/*表名换成了id本方法做转换*/
|
||||
public String getTableNameByClassId(String classId){
|
||||
@@ -50,6 +50,11 @@ public class InfluxDbParamUtil {
|
||||
if(DataParam.portableDevType.equals(csEquipmentDeliveryDTOList.get(0).getDevType())){
|
||||
return finalCsLinePOList.get(0).getClDid()+"";
|
||||
}
|
||||
//如果是云前置设备,直接返回clDid
|
||||
boolean isCLdDevice = DicDataEnum.DEV_CLD.getCode().equals(dictTreeFeignClient.queryById(csEquipmentDeliveryDTOList.get(0).getDevType()).getData().getCode());
|
||||
if(isCLdDevice){
|
||||
return String.valueOf(finalCsLinePOList.get(0).getLineNo());
|
||||
}
|
||||
//之后的逻辑还是按照原来的不变
|
||||
String position = csLineFeignClient.getPositionById(lineId).getData();
|
||||
if (Objects.isNull(position)){
|
||||
|
||||
Reference in New Issue
Block a user