代码调整-兼容便携式设备
This commit is contained in:
@@ -103,7 +103,7 @@ public class CsEquipmentDeliveryPO extends BaseEntity {
|
||||
private String qrPath;
|
||||
|
||||
/**
|
||||
* 设备当前流程(1:设备登记,2:功能调试,3:出厂调试),4:设备投运)
|
||||
* 设备当前流程(1:设备登记,2:功能调试,3:出厂调试,4:设备投运)
|
||||
*/
|
||||
@TableField(value = "process")
|
||||
private Integer process;
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -15,6 +16,7 @@ import lombok.Data;
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName(value = "cs_line")
|
||||
public class CsLinePO extends BaseEntity {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.njcn.csdevice.controller.ledger;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.csdevice.service.IWlLedgerService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2024/4/9 14:42
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wlLedger")
|
||||
@Slf4j
|
||||
@Api(tags = "便携式终端台账")
|
||||
@AllArgsConstructor
|
||||
public class WlLedgerController extends BaseController {
|
||||
|
||||
private final IWlLedgerService wlLedgerService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/wlDevice")
|
||||
@ApiOperation("设备列表")
|
||||
public HttpResult<List<CsLedgerVO>> getWlDevice(){
|
||||
String methodDescribe = getMethodDescribe("getWlDevice");
|
||||
List<CsLedgerVO> list = wlLedgerService.getWlDevice();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/wlDeviceTree")
|
||||
@ApiOperation("二层设备树(设备-监测点)")
|
||||
public HttpResult<List<CsLedgerVO>> getWlDeviceTree(){
|
||||
String methodDescribe = getMethodDescribe("getWlDeviceTree");
|
||||
List<CsLedgerVO> list = wlLedgerService.getWlDeviceTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2024/4/9 14:45
|
||||
*/
|
||||
|
||||
public interface IWlLedgerService {
|
||||
|
||||
/**
|
||||
* 便携式设备列表
|
||||
* @return
|
||||
*/
|
||||
List<CsLedgerVO> getWlDevice();
|
||||
|
||||
/**
|
||||
* 便携式设备两层树(装置-监测点)
|
||||
* @return
|
||||
*/
|
||||
List<CsLedgerVO> getWlDeviceTree();
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -36,6 +37,7 @@ import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicTreeEnum;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
@@ -274,38 +276,25 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceManagerVO getDeviceData(String deviceId,String type,String lineId) {
|
||||
public DeviceManagerVO getDeviceData(String deviceId, String type, String lineId) {
|
||||
DeviceManagerVO deviceManagerVo = new DeviceManagerVO();
|
||||
List<DeviceManagerVO.DataSetVO> dataSetList = new ArrayList<>();
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPo = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId,deviceId).one();
|
||||
if (Objects.isNull(lineId) || StringUtils.isBlank(lineId)){
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPo = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one();
|
||||
if (lineId == null || lineId.isEmpty()) {
|
||||
List<CsDataSet> dataSet = new ArrayList<>();
|
||||
List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId);
|
||||
modelId.forEach(item->{
|
||||
if (CollUtil.isNotEmpty(modelId)){
|
||||
for (CsDevModelRelationPO item : modelId) {
|
||||
dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId()));
|
||||
});
|
||||
BeanUtils.copyProperties(csEquipmentDeliveryPo,deviceManagerVo);
|
||||
dataSet.forEach(item->{
|
||||
DeviceManagerVO.DataSetVO dataSetVO = new DeviceManagerVO.DataSetVO();
|
||||
dataSetVO.setId(item.getId());
|
||||
dataSetVO.setName(item.getAnotherName());
|
||||
dataSetVO.setType("rt");
|
||||
dataSetList.add(dataSetVO);
|
||||
if (Objects.equals(type,"history")){
|
||||
DeviceManagerVO.DataSetVO dataSetVo2 = new DeviceManagerVO.DataSetVO();
|
||||
dataSetVo2.setId(item.getId());
|
||||
dataSetVo2.setName("历史"+item.getAnotherName());
|
||||
dataSetVo2.setType("history");
|
||||
dataSetList.add(dataSetVo2);
|
||||
}
|
||||
});
|
||||
deviceManagerVo.setDataSetList(dataSetList);
|
||||
CsLedger csLedger = csLedgerService.findDataById(deviceId);
|
||||
deviceManagerVo.setTime(csLedger.getCreateTime());
|
||||
}
|
||||
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
|
||||
} else {
|
||||
CsLinePO line = csLinePOService.listByIds(Collections.singletonList(lineId)).get(0);
|
||||
String devTypeCode = dictTreeFeignClient.queryById(csEquipmentDeliveryPo.getDevType()).getData().getCode();
|
||||
if (Objects.equals(devTypeCode, DicDataEnum.CONNECT_DEV.getCode())) {
|
||||
CsLinePO line = csLinePOService.getById(lineId);
|
||||
String code = dicDataFeignClient.getDicDataById(line.getPosition()).getData().getCode();
|
||||
String modelId = null;
|
||||
String modelId = "";
|
||||
List<CsDataSet> dataSet = new ArrayList<>();
|
||||
//治理监测点
|
||||
if (Objects.equals(code, DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||
@@ -322,26 +311,32 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
modelId = csDevModelRelationService.getModelByType(deviceId,1);
|
||||
dataSet = csDataSetService.findDataSetByModelId(modelId,2);
|
||||
}
|
||||
BeanUtils.copyProperties(csEquipmentDeliveryPo,deviceManagerVo);
|
||||
dataSet.forEach(item->{
|
||||
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
|
||||
}
|
||||
}
|
||||
return deviceManagerVo;
|
||||
}
|
||||
|
||||
private void setDataSetValues(CsEquipmentDeliveryPO csEquipmentDeliveryPo, List<CsDataSet> dataSet, List<DeviceManagerVO.DataSetVO> dataSetList, String type, DeviceManagerVO deviceManagerVo) {
|
||||
BeanUtils.copyProperties(csEquipmentDeliveryPo, deviceManagerVo);
|
||||
if (CollUtil.isNotEmpty(dataSet)) {
|
||||
for (CsDataSet item : dataSet) {
|
||||
DeviceManagerVO.DataSetVO dataSetVO = new DeviceManagerVO.DataSetVO();
|
||||
dataSetVO.setId(item.getId());
|
||||
dataSetVO.setName(item.getAnotherName());
|
||||
dataSetVO.setType("rt");
|
||||
dataSetList.add(dataSetVO);
|
||||
if (Objects.equals(type,"history")){
|
||||
if (Objects.equals(type, "history")) {
|
||||
DeviceManagerVO.DataSetVO dataSetVo2 = new DeviceManagerVO.DataSetVO();
|
||||
dataSetVo2.setId(item.getId());
|
||||
dataSetVo2.setName("历史"+item.getAnotherName());
|
||||
dataSetVo2.setName("历史" + item.getAnotherName());
|
||||
dataSetVo2.setType("history");
|
||||
dataSetList.add(dataSetVo2);
|
||||
}
|
||||
});
|
||||
deviceManagerVo.setDataSetList(dataSetList);
|
||||
CsLedger csLedger = csLedgerService.findDataById(deviceId);
|
||||
deviceManagerVo.setTime(csLedger.getCreateTime());
|
||||
}
|
||||
return deviceManagerVo;
|
||||
deviceManagerVo.setDataSetList(dataSetList);
|
||||
deviceManagerVo.setTime(csLinePOService.findByNdid(csEquipmentDeliveryPo.getNdid()).get(0).getCreateTime());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
|
||||
import com.njcn.csdevice.mapper.CsLinePOMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.csdevice.service.IWlLedgerService;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2024/4/9 14:45
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class IWlLedgerServiceImpl implements IWlLedgerService {
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
|
||||
private final CsLinePOMapper csLinePOMapper;
|
||||
|
||||
@Override
|
||||
public List<CsLedgerVO> getWlDevice() {
|
||||
List<CsLedgerVO> result = new ArrayList<>();
|
||||
// 获取便携式设备字典
|
||||
DictTreeVO vo = Optional.ofNullable(dictTreeFeignClient.queryByCode(DicDataEnum.PORTABLE.getCode()).getData()).orElse(null);
|
||||
if (vo == null) {
|
||||
return result;
|
||||
}
|
||||
// 获取便携设备列表
|
||||
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryMapper.selectList(
|
||||
new LambdaQueryWrapper<CsEquipmentDeliveryPO>()
|
||||
.eq(CsEquipmentDeliveryPO::getDevType, vo.getId())
|
||||
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
|
||||
);
|
||||
if (CollUtil.isEmpty(devList)) {
|
||||
return result;
|
||||
}
|
||||
// 组装结果返回
|
||||
result = devList.stream().map(dev -> {
|
||||
CsLedgerVO csLedgerVO = new CsLedgerVO();
|
||||
csLedgerVO.setId(dev.getId());
|
||||
csLedgerVO.setName(dev.getName());
|
||||
csLedgerVO.setLevel(0);
|
||||
csLedgerVO.setComFlag(dev.getRunStatus());
|
||||
return csLedgerVO;
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsLedgerVO> getWlDeviceTree() {
|
||||
List<CsLedgerVO> result = new ArrayList<>();
|
||||
// 获取便携式设备字典
|
||||
DictTreeVO vo = Optional.ofNullable(dictTreeFeignClient.queryByCode(DicDataEnum.PORTABLE.getCode()).getData()).orElse(null);
|
||||
if (vo == null) {
|
||||
return result;
|
||||
}
|
||||
// 获取便携设备列表
|
||||
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryMapper.selectList(
|
||||
new LambdaQueryWrapper<CsEquipmentDeliveryPO>()
|
||||
.eq(CsEquipmentDeliveryPO::getDevType, vo.getId())
|
||||
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
|
||||
);
|
||||
if (CollUtil.isEmpty(devList)) {
|
||||
return result;
|
||||
}
|
||||
// 获取监测点列表
|
||||
List<String> devIds = devList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
|
||||
List<CsLinePO> lineList = csLinePOMapper.selectList(
|
||||
new LambdaQueryWrapper<CsLinePO>()
|
||||
.in(CsLinePO::getDeviceId, devIds)
|
||||
);
|
||||
// 组装结果返回
|
||||
result = devList.stream().map(dev -> {
|
||||
CsLedgerVO csLedgerVO = new CsLedgerVO();
|
||||
csLedgerVO.setId(dev.getId());
|
||||
csLedgerVO.setName(dev.getName());
|
||||
csLedgerVO.setLevel(0);
|
||||
csLedgerVO.setComFlag(dev.getRunStatus());
|
||||
List<CsLedgerVO> children = lineList.stream()
|
||||
.filter(line -> Objects.equals(dev.getId(), line.getDeviceId()))
|
||||
.map(line -> {
|
||||
CsLedgerVO vo2 = new CsLedgerVO();
|
||||
vo2.setId(line.getLineId());
|
||||
vo2.setPid(dev.getId());
|
||||
vo2.setName(line.getName());
|
||||
vo2.setLevel(1);
|
||||
return vo2;
|
||||
}).collect(Collectors.toList());
|
||||
csLedgerVO.setChildren(children);
|
||||
return csLedgerVO;
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user