提交一次接线图实时调试
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package com.njcn.cssystem.controller.zutai;
|
||||
|
||||
|
||||
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.cssystem.pojo.vo.EleEpdTreeVO;
|
||||
import com.njcn.cssystem.service.IEleEpdPqdService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/csDictData")
|
||||
@Api(tags = "指标数据字典")
|
||||
@AllArgsConstructor
|
||||
public class EleEpdPqdController extends BaseController {
|
||||
|
||||
private final IEleEpdPqdService eleEpdPqdService;
|
||||
|
||||
/**
|
||||
* 获取电能质量指标模板树
|
||||
* @author cdf
|
||||
* @date 2022/8/16
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/eleEpdChooseTree")
|
||||
@ApiOperation("获取电能质量指标模板树")
|
||||
public HttpResult<List<EleEpdTreeVO>> eleEpdChooseTree(){
|
||||
String methodDescribe = getMethodDescribe("eleEpdChooseTree");
|
||||
List<EleEpdTreeVO> res = eleEpdPqdService.eleEpdChooseTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.cssystem.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.cssystem.pojo.po.EleEpdPqd;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-24
|
||||
*/
|
||||
public interface EleEpdPqdMapper extends BaseMapper<EleEpdPqd> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.cssystem.mapper.EleEpdPqdMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.cssystem.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.cssystem.pojo.po.EleEpdPqd;
|
||||
import com.njcn.cssystem.pojo.vo.EleEpdTreeVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-24
|
||||
*/
|
||||
public interface IEleEpdPqdService extends IService<EleEpdPqd> {
|
||||
|
||||
|
||||
List<EleEpdTreeVO> eleEpdChooseTree();
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.njcn.cssystem.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.cssystem.mapper.EleEpdPqdMapper;
|
||||
import com.njcn.cssystem.pojo.po.EleEpdPqd;
|
||||
import com.njcn.cssystem.pojo.vo.EleEpdTreeVO;
|
||||
import com.njcn.cssystem.service.IEleEpdPqdService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-24
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd> implements IEleEpdPqdService {
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final String STR_ONE = "#";
|
||||
|
||||
private final String STR_TWO = "$";
|
||||
|
||||
@Override
|
||||
public List<EleEpdTreeVO> eleEpdChooseTree() {
|
||||
DictData dic = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.CS_DATA_TYPE.getName(), DicDataEnum.EPD.getName()).getData();
|
||||
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(EleEpdPqd::getDataType, dic.getId()).orderByAsc(EleEpdPqd::getSort);
|
||||
List<EleEpdPqd> list = this.getBaseMapper().selectList(lambdaQueryWrapper);
|
||||
Map<String, List<EleEpdPqd>> map = list.stream().collect(Collectors.groupingBy(EleEpdPqd::getName, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
List<EleEpdTreeVO> tree = new ArrayList<>();
|
||||
map.forEach((key, value) -> {
|
||||
|
||||
EleEpdTreeVO reportTreeVO = new EleEpdTreeVO();
|
||||
reportTreeVO.setName(value.get(0).getOtherName());
|
||||
reportTreeVO.setShowName(value.get(0).getShowName());
|
||||
|
||||
//存在1-50次 2-50次情况
|
||||
if (Objects.nonNull(value.get(0).getHarmStart()) && Objects.nonNull(value.get(0).getHarmEnd())) {
|
||||
List<EleEpdTreeVO> reHarm = new ArrayList<>();
|
||||
for (int i = value.get(0).getHarmStart(); i <= value.get(0).getHarmEnd(); i++) {
|
||||
EleEpdTreeVO reportTreeCount = new EleEpdTreeVO();
|
||||
reportTreeCount.setName(value.get(0).getOtherName() + "_" + i);
|
||||
reportTreeCount.setShowName(i + "次" + value.get(0).getShowName());
|
||||
reportTreeVO.setFlag(1);
|
||||
assPhase(value, reportTreeCount, reportTreeCount.getName());
|
||||
reHarm.add(reportTreeCount);
|
||||
}
|
||||
reportTreeVO.setChildren(reHarm);
|
||||
} else {
|
||||
assPhase(value, reportTreeVO, value.get(0).getOtherName());
|
||||
}
|
||||
tree.add(reportTreeVO);
|
||||
});
|
||||
return tree;
|
||||
}
|
||||
|
||||
/*组装相别*/
|
||||
private void assPhase(List<EleEpdPqd> value, EleEpdTreeVO reportTreeItem, String key) {
|
||||
List<EleEpdTreeVO> phaseTree = new ArrayList<>();
|
||||
value.forEach(item -> {
|
||||
if (Objects.nonNull(item.getPhase()) && !"M".equals(item.getPhase())) {
|
||||
List<EleEpdTreeVO> statTree = new ArrayList<>();
|
||||
EleEpdTreeVO reportTreePhase = new EleEpdTreeVO();
|
||||
reportTreePhase.setName(item.getPhase());
|
||||
reportTreePhase.setShowName(item.getPhase());
|
||||
// reportTreePhase.setUnit(item.getUnit());
|
||||
assStatMethod(item, statTree, key, item.getPhase());
|
||||
reportTreePhase.setChildren(statTree);
|
||||
phaseTree.add(reportTreePhase);
|
||||
reportTreeItem.setChildren(phaseTree);
|
||||
|
||||
} else {
|
||||
List<EleEpdTreeVO> statTree = new ArrayList<>();
|
||||
assStatMethod(item, statTree, key, "T");
|
||||
reportTreeItem.setChildren(statTree);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void assStatMethod(EleEpdPqd item, List<EleEpdTreeVO> statTree, String oneKey, String twoKey) {
|
||||
//存在向别为M但是Stat_Method不为空
|
||||
if (StrUtil.isNotBlank(item.getStatMethod())) {
|
||||
String[] arr = item.getStatMethod().split(",");
|
||||
List<String> stat = Stream.of(arr).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(stat)) {
|
||||
stat.forEach(statItem -> {
|
||||
EleEpdTreeVO reportTreeStat = new EleEpdTreeVO();
|
||||
reportTreeStat.setUnit(item.getUnit());
|
||||
String tem = "";
|
||||
if (Objects.nonNull(item.getLimitName())) {
|
||||
tem = STR_ONE + item.getLimitName();
|
||||
} else {
|
||||
tem = "#NO";
|
||||
}
|
||||
if (StrUtil.isNotBlank(twoKey)) {
|
||||
reportTreeStat.setName(STR_TWO + oneKey + STR_ONE + twoKey + STR_ONE + statItem + STR_ONE + item.getClassId().trim() + tem.trim() + STR_TWO);
|
||||
} else {
|
||||
reportTreeStat.setName(STR_TWO + oneKey + STR_ONE + statItem + STR_ONE + item.getClassId().trim() + tem.trim() + STR_TWO);
|
||||
}
|
||||
|
||||
reportTreeStat.setShowName(statItem);
|
||||
statTree.add(reportTreeStat);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user