云前置改造

This commit is contained in:
xy
2025-09-23 16:34:24 +08:00
parent ee07f7a5e2
commit 9d2b4b97f9
15 changed files with 303 additions and 37 deletions

View File

@@ -1,10 +1,16 @@
package com.njcn.csdevice.api;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
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.api.fallback.CsLineClientFallbackFactory;
import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
@@ -44,5 +50,5 @@ public interface CsLineFeignClient {
HttpResult<CsLinePO> getById(@RequestParam("lineId") String lineId);
@PostMapping("/getLinesByDevList")
HttpResult<List<CsLinePO>> getLinesByDevList(@RequestParam("ids") List<String> ids);
HttpResult<List<CsLinePO>> getLinesByDevList(@RequestBody List<String> ids);
}

View File

@@ -54,4 +54,7 @@ public interface WlRecordFeignClient {
@PostMapping("/findDevBaseDataByLineId")
HttpResult<List<RecordVo>> findDevBaseDataByLineId(@RequestBody @Validated WlRecordParam.lineRecord param);
@GetMapping("/getTestRecordById")
HttpResult<RecordVo.RecordItemVo> getTestRecordById(@RequestParam("testRecordId") @Validated String testRecordId);
}

View File

@@ -70,6 +70,12 @@ public class WlRecordClientFallbackFactory implements FallbackFactory<WlRecordFe
log.error("{}异常,降级处理,异常为:{}","根据监测点id查询装置基础数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<RecordVo.RecordItemVo> getTestRecordById(String testRecordId) {
log.error("{}异常,降级处理,异常为:{}","根据测试项ID查询测试项信息",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -58,6 +58,8 @@ public interface DataParam {
String GOVERNANCE_SYSTEM = "治理系统";
String cldDev = "云前置设备";
String EvtParamPhase = "Evt_Param_Phase";
String EvtParamDepth = "Evt_Param_VVaDepth";

View File

@@ -7,7 +7,6 @@ import com.njcn.csdevice.pojo.param.CsLineParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.Valid;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
@@ -31,19 +30,15 @@ public class IcdLedgerParam implements Serializable {
@ApiModelProperty("设备和mac关系")
private Map<String,String> devMacMap;
@Valid
@ApiModelProperty("工程信息")
private CsEngineeringAddParm engineering;
@Valid
@ApiModelProperty("项目信息")
private AppProjectAddParm project;
@Valid
@ApiModelProperty("装置信息")
private List<CsEquipmentDeliveryAddParm> device;
@Valid
@ApiModelProperty("监测点信息")
private List<CsLineParam> line;
}

View File

@@ -23,6 +23,9 @@ public class CsLedgerVO implements Serializable {
@ApiModelProperty(name = "pid",value = "父id")
private String pid;
@ApiModelProperty(name = "pids",value = "父id集合")
private String pids;
@ApiModelProperty(name = "name",value = "名称")
private String name;

View File

@@ -6,7 +6,6 @@ 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.mapper.CsLinePOMapper;
import com.njcn.csdevice.mapper.OverlimitMapper;
import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO;
@@ -145,11 +144,21 @@ public class CslineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
// @PostMapping("/getLinesByDevList")
// @ApiOperation("根据装置id集合获取监测点id集合")
// @ApiImplicitParam(name = "ids", value = "装置id集合", required = true)
// public HttpResult<List<CsLinePO>> getLinesByDevList(@RequestParam("ids") List<String> ids) {
// String methodDescribe = getMethodDescribe("getLinesByDevList");
// List<CsLinePO> list = csLinePOService.getLinesByDevList(ids);
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
// }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getLinesByDevList")
@ApiOperation("根据装置id集合获取监测点id集合")
@ApiImplicitParam(name = "ids", value = "装置id集合", required = true)
public HttpResult<List<CsLinePO>> getLinesByDevList(@RequestParam("ids") List<String> ids) {
public HttpResult<List<CsLinePO>> getLinesByDevList(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("getLinesByDevList");
List<CsLinePO> list = csLinePOService.getLinesByDevList(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);

View File

@@ -64,7 +64,7 @@ public class WlRecordController extends BaseController {
@GetMapping("/getTestRecordById")
@ApiOperation("根据测试项ID查询测试项信息")
@ApiImplicitParam(name = "testRecordId", value = "测试项ID", required = true)
public HttpResult<RecordVo.RecordItemVo> getTestRecordById(@RequestParam @Validated String testRecordId) {
public HttpResult<RecordVo.RecordItemVo> getTestRecordById(@RequestParam("testRecordId") @Validated String testRecordId) {
String methodDescribe = getMethodDescribe("getTestRecordById");
LogUtil.njcnDebug(log, "{}测试项id为{}", methodDescribe, testRecordId);
RecordVo.RecordItemVo result = wlRecordService.getTestRecordById(testRecordId);

View File

@@ -32,7 +32,7 @@
</resultMap>
<select id="getAll" resultType="CsLedgerVO">
select
id,pid,name,level,sort
id,pid,pids,name,level,sort
from
cs_ledger
where

View File

@@ -76,4 +76,11 @@ public interface ICsLedgerService extends IService<CsLedger> {
DevDetailDTO queryDevDetail(String devId);
List<CsLedgerVO> getztProjectTree();
/**
* 根据设备集合获取项目和工程
* @param id
* @return
*/
List<CsLedgerVO> getProAndEngineer(List<String> id);
}

View File

@@ -1,6 +1,7 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.stream.CollectorUtil;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -356,10 +357,14 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
@Override
public List<AppProjectPO> getProjectByEngineering(List<String> list) {
List<AppProjectPO> result = new ArrayList<>();
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper();
csLedgerQueryWrapper.lambda().in(CsLedger::getPid, list).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(AppProjectPO::getId,collect).list();
if (CollectionUtil.isNotEmpty(csLedgers)) {
List<String> collect = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList());
result = this.lambdaQuery().in(AppProjectPO::getId,collect).list();
}
return result;
}
}

View File

@@ -7,9 +7,11 @@ import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.LineBaseEnum;
import com.njcn.csdevice.mapper.*;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.param.CsLedgerParam;
@@ -18,7 +20,10 @@ import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.service.*;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.Area;
import com.njcn.system.pojo.vo.DictTreeVO;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@@ -49,6 +54,8 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
private final CsDevModelRelationService csDevModelRelationService;
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final ICsDataSetService csDataSetService;
private final EquipmentFeignClient equipmentFeignClient;
private final DictTreeFeignClient dictTreeFeignClient;
@Override
public List<CsLedgerVO> getLedgerTree() {
@@ -72,6 +79,29 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
/*获取用户工程,设备信息过滤*/
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
List<String> device = roleEngineerDevService.getDevice();
//区分治理装置和云前置装置
List<String> zhiLianDevice = new ArrayList<>();
List<String> cldDevice = new ArrayList<>();
List<CsEquipmentDeliveryDTO> csEquipmentDeliveryPOS = equipmentFeignClient.queryDeviceById(device).getData();
if (CollectionUtil.isNotEmpty(csEquipmentDeliveryPOS)) {
DictTreeVO vo1 = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
Optional.ofNullable(vo1)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.forEach(cldDevice::add)
);
DictTreeVO vo2 = dictTreeFeignClient.queryByCode(DicDataEnum.CONNECT_DEV.getCode()).getData();
Optional.ofNullable(vo2)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.forEach(zhiLianDevice::add)
);
}
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
@@ -85,7 +115,20 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
));
List<CsLedgerVO> deviceList = allList.stream()
.filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.filter(item -> zhiLianDevice.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.peek(item -> {
CsEquipmentDeliveryPO po = poMap.get(item.getId());
item.setComFlag(po.getRunStatus());
item.setNDId(po.getNdid());
item.setType("device");
item.setProcess(po.getProcess());
})
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
List<CsLedgerVO> cldDeviceList = allList.stream()
.filter(item -> cldDevice.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.peek(item -> {
CsEquipmentDeliveryPO po = poMap.get(item.getId());
item.setComFlag(po.getRunStatus());
@@ -116,11 +159,35 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
}
)
.collect(Collectors.toList());
checkDevSetData(deviceList);
deviceList.forEach(dev -> dev.setChildren(getChildren(dev, finalLineList)));
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
engineeringList = engineeringList.stream().sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
List<CsLedgerVO> engineeringList1 = new ArrayList<>();
List<CsLedgerVO> projectList1 = new ArrayList<>();
List<String> dev = deviceList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsLedgerVO> ledger1 = getProAndEngineer(dev);
if (CollectionUtil.isNotEmpty(ledger1)) {
deviceList.forEach(dev1 -> dev1.setChildren(getChildren(dev1, finalLineList)));
engineeringList1 = ledger1.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList1 = ledger1.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList1.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
List<CsLedgerVO> finalProjectList = projectList1;
engineeringList1.forEach(eng -> eng.setChildren(getChildren(eng, finalProjectList)));
}
checkDevSetData(cldDeviceList);
List<CsLedgerVO> engineeringList2 = new ArrayList<>();
List<CsLedgerVO> projectList2 = new ArrayList<>();
List<String> dev2 = cldDeviceList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsLedgerVO> ledger2 = getProAndEngineer(dev2);
if (CollectionUtil.isNotEmpty(ledger2)) {
cldDeviceList.forEach(dev1 -> dev1.setChildren(getChildren(dev1, finalLineList)));
engineeringList2 = ledger2.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList2 = ledger2.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList2.forEach(pro -> pro.setChildren(getChildren(pro, cldDeviceList)));
List<CsLedgerVO> finalProjectList = projectList2;
engineeringList2.forEach(eng -> eng.setChildren(getChildren(eng, finalProjectList)));
}
//获取便携式设备树
CsLedgerVO portable = new CsLedgerVO();
portable.setLevel(0);
@@ -150,7 +217,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
.filter(c -> poMap2.get(c.getId()).getUsageStatus() == 1)
.collect(Collectors.toList());
portables = portables.stream().sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
portables.forEach(dev -> dev.setChildren(getChildren(dev, finalLineList)));
portables.forEach(dev3 -> dev3.setChildren(getChildren(dev3, finalLineList)));
checkDevSetData(portables);
portable.setChildren(portables);
@@ -159,7 +226,16 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
government.setName(DataParam.governmentDev);
government.setPid("0");
government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList);
government.setChildren(engineeringList1);
//获取云前置设备树
CsLedgerVO cld = new CsLedgerVO();
cld.setLevel(0);
cld.setName(DataParam.cldDev);
cld.setPid("0");
cld.setId(IdUtil.simpleUUID());
cld.setChildren(engineeringList2);
List<CsLedgerVO> tree = new ArrayList<>();
if (CollUtil.isNotEmpty(portables)) {
tree.add(portable);
@@ -167,6 +243,9 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government);
}
if (CollUtil.isNotEmpty(cldDeviceList)) {
tree.add(cld);
}
return tree;
}
//剔除未接入的设备(根据status判断不太稳,所有这里直接判断该设备有没有对应的模板指标)
@@ -205,6 +284,28 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
/*获取用户工程,设备信息过滤*/
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
List<String> device = roleEngineerDevService.getDevice();
List<String> zhiLianDevice = new ArrayList<>();
List<String> cldDevice = new ArrayList<>();
List<CsEquipmentDeliveryDTO> csEquipmentDeliveryPOS = equipmentFeignClient.queryDeviceById(device).getData();
if (CollectionUtil.isNotEmpty(csEquipmentDeliveryPOS)) {
DictTreeVO vo1 = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
Optional.ofNullable(vo1)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.forEach(cldDevice::add)
);
DictTreeVO vo2 = dictTreeFeignClient.queryByCode(DicDataEnum.CONNECT_DEV.getCode()).getData();
Optional.ofNullable(vo2)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.forEach(zhiLianDevice::add)
);
}
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
@@ -217,8 +318,9 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
csEquipmentDeliveryMapper::selectById
));
//获取治理设备
List<CsLedgerVO> deviceList = allList.stream()
.filter(item -> device.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.filter(item -> zhiLianDevice.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.peek(item -> {
CsEquipmentDeliveryPO po = poMap.get(item.getId());
item.setComFlag(po.getRunStatus());
@@ -230,9 +332,45 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
List<CsLedgerVO> engineeringList1 = new ArrayList<>();
List<CsLedgerVO> projectList1 = new ArrayList<>();
checkDevSetData(deviceList);
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
List<String> dev = deviceList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsLedgerVO> ledger1 = getProAndEngineer(dev);
if (CollectionUtil.isNotEmpty(ledger1)) {
engineeringList1 = ledger1.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList1 = ledger1.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList1.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
List<CsLedgerVO> finalProjectList = projectList1;
engineeringList1.forEach(eng -> eng.setChildren(getChildren(eng, finalProjectList)));
}
//获取云前置设备
List<CsLedgerVO> cldDevList = allList.stream()
.filter(item -> cldDevice.contains(item.getId()) && !Objects.equals(item.getPid(), "0"))
.peek(item -> {
CsEquipmentDeliveryPO po = poMap.get(item.getId());
item.setComFlag(po.getRunStatus());
item.setNDId(po.getNdid());
item.setType("device");
item.setProcess(po.getProcess());
})
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
.sorted(Comparator.comparing(CsLedgerVO::getSort))
.collect(Collectors.toList());
checkDevSetData(cldDevList);
List<CsLedgerVO> engineeringList2 = new ArrayList<>();
List<CsLedgerVO> projectList2 = new ArrayList<>();
List<String> dev2 = cldDevList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsLedgerVO> ledger2 = getProAndEngineer(dev2);
if (CollectionUtil.isNotEmpty(ledger2)) {
engineeringList2 = ledger2.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList2 = ledger2.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
projectList2.forEach(pro -> pro.setChildren(getChildren(pro, cldDevList)));
List<CsLedgerVO> finalProjectList = projectList2;
engineeringList2.forEach(eng -> eng.setChildren(getChildren(eng, finalProjectList)));
}
//获取便携式设备树
CsLedgerVO portable = new CsLedgerVO();
@@ -272,7 +410,16 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
government.setName(DataParam.governmentDev);
government.setPid("0");
government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList);
government.setChildren(engineeringList1);
//获取云前置设备树
CsLedgerVO cld = new CsLedgerVO();
cld.setLevel(0);
cld.setName(DataParam.cldDev);
cld.setPid("0");
cld.setId(IdUtil.simpleUUID());
cld.setChildren(engineeringList2);
List<CsLedgerVO> tree = new ArrayList<>();
if (CollUtil.isNotEmpty(portables)) {
tree.add(portable);
@@ -280,6 +427,9 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government);
}
if (CollUtil.isNotEmpty(cldDevList)) {
tree.add(cld);
}
return tree;
}
@@ -474,6 +624,32 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
return tree;
}
@Override
public List<CsLedgerVO> getProAndEngineer(List<String> id) {
List<CsLedgerVO> result = new ArrayList<>();
List<CsLedgerVO> allList = this.baseMapper.getAll();
Set<String> idSet = new HashSet<>(id);
if (CollectionUtil.isNotEmpty(id)) {
id.forEach(item->{
allList.forEach(item2->{
if (Objects.equals(item2.getId(),item)) {
idSet.addAll(Arrays.asList(item2.getPids().split( ",")));
}
});
});
}
if (CollectionUtil.isNotEmpty(idSet)) {
idSet.forEach(item->{
allList.forEach(item2->{
if (Objects.equals(item2.getId(),item)) {
result.add(item2);
}
});
});
}
return result;
}
/**
* 获取子节点
*/

View File

@@ -2,6 +2,7 @@ package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.csdevice.api.CsLineFeignClient;
@@ -74,9 +75,15 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
if (item.getClDid() == 0) {
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"apf_data","Apf_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
}
//电能质量监测点
else {
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"pqd_data","Pq_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
//云前置监测点
if (ObjectUtil.isNotNull(item.getLineNo())) {
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"data_v","Pq_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
}
//治理、无线监测点
else {
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"pqd_data","Pq_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
}
}
data.setTimeId(LocalDate.parse(time, DatePattern.NORM_DATE_FORMATTER));
data.setLineIndex(item.getLineId());

View File

@@ -1,6 +1,7 @@
package com.njcn.csharmonic.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -377,6 +378,11 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
if(!CollectionUtils.isEmpty(governmentDevTree)){
governmentDevTree = governmentDevTree.get(0).getChildren();
}
List<CsLedgerVO> cldDevTree = data.stream().filter(temp -> Objects.equals(temp.getName(), DataParam.cldDev)).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(cldDevTree)){
cldDevTree = cldDevTree.get(0).getChildren();
}
//便携式就1层下边就是设备
List<String> portableDevIds = portableDevTree.stream().filter(
temp -> StringUtils.isEmpty(csEventUserQueryPage.getDeviceId()) ||
@@ -394,8 +400,23 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
).
map(CsLedgerVO::getId).
collect(Collectors.toList());
List<String> cldDevIds = cldDevTree.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())||
Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid()))
.map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getProjectId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getProjectId())
).
map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId())
).
map(CsLedgerVO::getId).
collect(Collectors.toList());
devIds.addAll(portableDevIds);
devIds.addAll(governmentDevIds);
devIds.addAll(cldDevIds);
if (CollectionUtils.isEmpty(devIds)){
return returnpage;
}
@@ -408,10 +429,17 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
temp.setEngineeringid(devDetail.getEngineeringid());
temp.setEngineeringName(devDetail.getEngineeringName());
EleEpdPqd ele = epdFeignClient.findByName(temp.getTag()).getData();
temp.setShowName(ele.getShowName());
temp.setCode(ele.getDefaultValue());
if (temp.getLineId().endsWith("0")) {
temp.setModuleNo("模块" + temp.getClDid());
if (Objects.isNull(ele)) {
temp.setShowName(temp.getTag());
temp.setCode(temp.getCode());
} else {
temp.setShowName(ele.getShowName());
temp.setCode(ele.getDefaultValue());
}
if (ObjectUtil.isNotNull(temp.getLineId())) {
if (temp.getLineId().endsWith("0")) {
temp.setModuleNo("模块" + temp.getClDid());
}
}
if(Objects.equals(csEventUserQueryPage.getType(),"0")){
List<EleEvtParm> data1 = eleEvtFeignClient.queryByPid(ele.getId()).getData();

View File

@@ -8,17 +8,22 @@ import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.api.DataSetFeignClient;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.pojo.po.CsDataSet;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csharmonic.service.RealDataService;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
@@ -35,23 +40,37 @@ public class RealDataServiceImpl implements RealDataService {
private final EquipmentFeignClient equipmentFeignClient;
private final RedisUtil redisUtil;
private final MqttUtil mqttUtil;
private final DictTreeFeignClient dictTreeFeignClient;
@Override
public boolean getBaseRealData(String lineId) {
boolean result = true;
try {
String nDid = lineId.substring(0, lineId.length() - 1);
String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
if (!mqttClient) {
throw new BusinessException("装置离线");
}
//判断设备类型 治理无线设备需要判断mqtt、云前置设备直接判断设备运行状态
CsEquipmentDeliveryPO dev = equipmentFeignClient.getDevByLineId(lineId).getData();
String devModelCode = dictTreeFeignClient.queryById(dev.getDevType()).getData().getCode();
// if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
// if (dev.getRunStatus() == 1) {
// throw new BusinessException("装置离线");
// }
// } else {
// String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
// boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
// if (!mqttClient) {
// throw new BusinessException("装置离线");
// }
// }
Integer clDid = Integer.parseInt(lineId.substring(lineId.length() - 1));
//获取装置所用模板
CsLinePO po = csLineFeignClient.getById(lineId).getData();
String modelId = po.getDataModelId();
CsDataSet csDataSet = dataSetFeignClient.getBaseDataSet(modelId,clDid).getData();
askDeviceDataFeignClient.askRealData(nDid,csDataSet.getIdx(),clDid);
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
askDeviceDataFeignClient.askCldRealData(dev.getId(),lineId,dev.getNodeId());
} else {
askDeviceDataFeignClient.askRealData(nDid,csDataSet.getIdx(),clDid);
}
//等待装置响应,获取询问结果
Thread.sleep(2000);
Object object = redisUtil.getObjectByKey("devResponse");