组态功能开发
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.njcn.harmonic.controller;
|
||||
|
||||
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.LineTargetVO;
|
||||
import com.njcn.harmonic.service.ILineTargetService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import pojo.vo.TargetDetailVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/6/1 10:03
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/lineTarget")
|
||||
@Api(tags = "组态指标绑定")
|
||||
@AllArgsConstructor
|
||||
public class LineTargetController extends BaseController {
|
||||
|
||||
private final ILineTargetService lineTargetService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/target")
|
||||
@ApiOperation("监测点指标")
|
||||
@ApiImplicitParam(name = "lineId", value = "监测点Id", required = true)
|
||||
public HttpResult<List<LineTargetVO>> getLineTarget(@RequestParam("lineId") String lineId) {
|
||||
String methodDescribe = getMethodDescribe("getLineTarget");
|
||||
List<LineTargetVO> list = lineTargetService.getLineTarget(lineId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/targetDetail")
|
||||
@ApiOperation("获取指标数据类型和相别")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pid", value = "数据集id", required = true),
|
||||
@ApiImplicitParam(name = "name", value = "名称", required = true)
|
||||
})
|
||||
public HttpResult<TargetDetailVO> getTargetDetail(@RequestParam("pid") String pid, @RequestParam("name") String name) {
|
||||
String methodDescribe = getMethodDescribe("getTargetDetail");
|
||||
TargetDetailVO list = lineTargetService.getTargetDetail(pid,name);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.harmonic.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
||||
import pojo.vo.TargetDetailVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xuyang
|
||||
*/
|
||||
public interface ILineTargetService {
|
||||
|
||||
/**
|
||||
* 根据监测点Id获取对应指标
|
||||
* @param lineId
|
||||
* @return
|
||||
*/
|
||||
List<LineTargetVO> getLineTarget(String lineId);
|
||||
|
||||
/**
|
||||
* 获取指标的数据类型和相别
|
||||
* @param pid
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
TargetDetailVO getTargetDetail(String pid, String name);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.njcn.harmonic.service.impl;
|
||||
|
||||
import com.njcn.csdevice.api.*;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelRelationPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
||||
import com.njcn.harmonic.service.ILineTargetService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pojo.vo.TargetDetailVO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/6/1 10:11
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class LineTargetServiceImpl implements ILineTargetService {
|
||||
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
|
||||
private final DevModelRelationFeignClient devModelRelationFeignClient;
|
||||
|
||||
private final DevModelFeignClient devModelFeignClient;
|
||||
|
||||
private final DataSetFeignClient dataSetFeignClient;
|
||||
|
||||
private final DataArrayFeignClient dataArrayFeignClient;
|
||||
|
||||
@Override
|
||||
public List<LineTargetVO> getLineTarget(String lineId) {
|
||||
List<LineTargetVO> list = new ArrayList<>();
|
||||
String devId = csLedgerFeignClient.findDevByLineId(lineId).getData();
|
||||
CsDevModelRelationPO po = devModelRelationFeignClient.getModelByDevId(devId).getData();
|
||||
if (!Objects.isNull(po)){
|
||||
CsDevModelPO csDevModelPo = devModelFeignClient.getModelById(po.getModelId()).getData();
|
||||
List<LineTargetVO> dataSetList = dataSetFeignClient.getDataSet(csDevModelPo.getId()).getData();
|
||||
List<String> setList = dataSetList.stream().map(LineTargetVO::getId).collect(Collectors.toList());
|
||||
List<LineTargetVO> dataArrayList = dataArrayFeignClient.getDataArray(setList).getData();
|
||||
dataSetList.forEach(dev -> dev.setChildren(getChildren(dev, dataArrayList)));
|
||||
list.addAll(dataSetList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetDetailVO getTargetDetail(String pid, String name) {
|
||||
TargetDetailVO vo = new TargetDetailVO();
|
||||
List<CsDataArray> dataArrayList = dataArrayFeignClient.getDataArrayById(pid,name).getData();
|
||||
List<String> dataType = dataArrayList.stream().map(CsDataArray::getStatMethod).distinct().collect(Collectors.toList());
|
||||
List<String> phasic = dataArrayList.stream().map(CsDataArray::getPhase).distinct().collect(Collectors.toList());
|
||||
vo.setDataTypeList(dataType);
|
||||
vo.setPhasicList(phasic);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子节点
|
||||
*/
|
||||
public List<LineTargetVO> getChildren(LineTargetVO item, List<LineTargetVO> all) {
|
||||
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user