台账算法支持
This commit is contained in:
@@ -1,34 +1,23 @@
|
||||
package com.njcn.device.pq.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import com.njcn.common.pojo.enums.common.ServerEnum;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.EnumUtils;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.biz.pojo.dto.DeptGetChildrenDTO;
|
||||
import com.njcn.device.biz.pojo.dto.*;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import com.njcn.device.pq.service.DeptLineService;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.device.pq.service.CommTerminalService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
@@ -43,9 +32,7 @@ import java.util.stream.Stream;
|
||||
@Api(tags = "通用台账-所有子孙部门以及监测点")
|
||||
public class CommTerminalController extends BaseController {
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final DeptLineService deptLineService;
|
||||
private final CommTerminalService commTerminalService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,65 +42,133 @@ public class CommTerminalController extends BaseController {
|
||||
* @date 2023/4/24
|
||||
*/
|
||||
@PostMapping("deptGetLineIds")
|
||||
@ApiOperation("通过部门获取所有子集部门所拥有的监测点")
|
||||
@ApiImplicitParam(name = "deptGetLineParam", value = "请求体", required = true)
|
||||
public HttpResult<List<DeptGetChildrenDTO>> deptGetLineList(@RequestBody @Validated DeptGetLineParam deptGetLineParam) {
|
||||
TimeInterval timer = new TimeInterval();
|
||||
String methodDescribe = getMethodDescribe("deptGetLineList");
|
||||
List<DeptGetChildrenDTO> all = new ArrayList<>();
|
||||
List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(deptGetLineParam.getDeptId(), Stream.of(0, 1).collect(Collectors.toList())).getData();
|
||||
getAllChildren(deptGetLineParam.getDeptId(), deptDTOList, all);
|
||||
Map<String, List<String>> map = deptLineService.getLineByDeptRelation(filterDataType(deptGetLineParam.getServerName()));
|
||||
all.forEach(item -> {
|
||||
List<String> itemDeptChildren = item.getDeptChildren();
|
||||
if (CollectionUtil.isNotEmpty(itemDeptChildren)) {
|
||||
List<String> lineIds = new ArrayList<>();
|
||||
itemDeptChildren.forEach(i -> {
|
||||
if (map.containsKey(i)) {
|
||||
lineIds.addAll(map.get(i));
|
||||
}
|
||||
});
|
||||
item.setLineIds(lineIds);
|
||||
}
|
||||
});
|
||||
List<DeptGetChildrenDTO> result = commTerminalService.deptGetLineList(deptGetLineParam);
|
||||
log.info("运行时长" + timer.intervalRestart());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, all, methodDescribe);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定部门所有子孙部门id
|
||||
*
|
||||
* 根据单位获取所有子单位信息
|
||||
* @author cdf
|
||||
* @date 2023/4/24
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
private void getAllChildren(String deptId, List<DeptDTO> deptAllList, List<DeptGetChildrenDTO> res) {
|
||||
deptAllList.stream().filter(item -> item.getPid().equals(deptId)).forEach(it -> {
|
||||
List<String> deptChildren = deptAllList.stream().filter(deptDTO -> deptDTO.getPids().contains(it.getId())).map(DeptDTO::getId).collect(Collectors.toList());
|
||||
deptChildren.add(it.getId());
|
||||
DeptGetChildrenDTO generalDeviceDTO = new DeptGetChildrenDTO();
|
||||
generalDeviceDTO.setDeptId(it.getId());
|
||||
generalDeviceDTO.setDeptName(it.getName());
|
||||
generalDeviceDTO.setDeptChildren(deptChildren);
|
||||
res.add(generalDeviceDTO);
|
||||
getAllChildren(it.getId(), deptAllList, res);
|
||||
});
|
||||
@PostMapping("getDeptChildrenByParent")
|
||||
@ApiImplicitParam(name = "deptGetLineParam", value = "请求体", required = true)
|
||||
public HttpResult<List<DeptGetBase>> getDeptChildrenByParent(@RequestBody @Validated DeptGetLineParam deptGetLineParam) {
|
||||
TimeInterval timer = new TimeInterval();
|
||||
String methodDescribe = getMethodDescribe("getDeptChildrenByParent");
|
||||
List<DeptGetBase> result = commTerminalService.getDeptChildrenByParent(deptGetLineParam);
|
||||
log.info("运行时长" + timer.intervalRestart());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据单位获取监测点信息
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
@PostMapping("deptGetLine")
|
||||
@ApiOperation("根据单位获取监测点信息")
|
||||
@ApiImplicitParam(name = "deptGetLineParam", value = "请求体", required = true)
|
||||
public HttpResult<List<DeptGetChildrenMoreDTO>> deptGetLine(@RequestBody @Validated DeptGetLineParam deptGetLineParam) {
|
||||
TimeInterval timer = new TimeInterval();
|
||||
String methodDescribe = getMethodDescribe("deptGetLine");
|
||||
List<DeptGetChildrenMoreDTO> result = commTerminalService.deptGetLine(deptGetLineParam);
|
||||
log.info("运行时长" + timer.intervalRestart());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据单位获取所有变电站
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
@PostMapping("deptGetSubStation")
|
||||
@ApiOperation("根据单位获取所有变电站")
|
||||
@ApiImplicitParam(name = "deptGetLineParam", value = "请求体", required = true)
|
||||
public HttpResult<List<DeptGetSubStationDTO>> deptSubStation(@RequestBody @Validated DeptGetLineParam deptGetLineParam) {
|
||||
TimeInterval timer = new TimeInterval();
|
||||
String methodDescribe = getMethodDescribe("deptSubStation");
|
||||
List<DeptGetSubStationDTO> result = commTerminalService.deptSubStation(deptGetLineParam);
|
||||
log.info("运行时长" + timer.intervalRestart());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据单位获取所有变电站
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
@PostMapping("deptGetBusBar")
|
||||
@ApiOperation("根据单位获取所有母线")
|
||||
@ApiImplicitParam(name = "deptGetLineParam", value = "请求体", required = true)
|
||||
public HttpResult<List<DeptGetBusBarDTO>> deptBusBar(@RequestBody @Validated DeptGetLineParam deptGetLineParam) {
|
||||
TimeInterval timer = new TimeInterval();
|
||||
String methodDescribe = getMethodDescribe("deptBusBar");
|
||||
List<DeptGetBusBarDTO> result = commTerminalService.deptBusBar(deptGetLineParam);
|
||||
log.info("运行时长" + timer.intervalRestart());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据单位获取所有装置
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
@PostMapping("deptGetDevice")
|
||||
@ApiOperation("根据单位获取所有装置")
|
||||
@ApiImplicitParam(name = "deptGetLineParam", value = "请求体", required = true)
|
||||
public HttpResult<List<DeptGetDeviceDTO>> deptGetDevice(@RequestBody @Validated DeptGetLineParam deptGetLineParam) {
|
||||
TimeInterval timer = new TimeInterval();
|
||||
String methodDescribe = getMethodDescribe("deptGetDevice");
|
||||
List<DeptGetDeviceDTO> result = commTerminalService.deptGetDevice(deptGetLineParam);
|
||||
log.info("运行时长" + timer.intervalRestart());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 筛选数据类型
|
||||
* 根据单站id获取监测点信息
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
private Integer filterDataType(String serverName) {
|
||||
ServerEnum serverEnum = EnumUtils.getServerEnumByName(serverName);
|
||||
switch (serverEnum) {
|
||||
case EVENT:
|
||||
return 0;
|
||||
case HARMONIC:
|
||||
return 1;
|
||||
default:
|
||||
throw new BusinessException(CommonResponseEnum.INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
@PostMapping("substationGetLine")
|
||||
@ApiOperation("根据电站获取所有监测点")
|
||||
@ApiImplicitParam(name = "substationId", value = "请求体", required = true)
|
||||
public HttpResult<List<LineDevGetDTO>> substationGetLine(@RequestParam("substationId")String substationId) {
|
||||
TimeInterval timer = new TimeInterval();
|
||||
String methodDescribe = getMethodDescribe("substationGetLine");
|
||||
List<LineDevGetDTO> result = commTerminalService.substationGetLine(substationId);
|
||||
log.info("运行时长" + timer.intervalRestart());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据母线id获取监测点信息
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
@PostMapping("busBarGetLine")
|
||||
@ApiOperation("根据母线id获取监测点信息")
|
||||
@ApiImplicitParam(name = "busBarId", value = "请求体", required = true)
|
||||
public HttpResult<List<LineDevGetDTO>> busBarGetLine(@RequestParam("busBarId")String busBarId) {
|
||||
TimeInterval timer = new TimeInterval();
|
||||
String methodDescribe = getMethodDescribe("busBarGetLine");
|
||||
List<LineDevGetDTO> result = commTerminalService.busBarGetLine(busBarId);
|
||||
log.info("运行时长" + timer.intervalRestart());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ package com.njcn.device.pq.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||
import com.njcn.device.biz.pojo.dto.TerminalGetBase;
|
||||
import com.njcn.device.pq.pojo.po.DeptLine;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -67,4 +68,9 @@ public interface DeptLineMapper extends BaseMapper<DeptLine> {
|
||||
"\t\tAND pq_line.Id = pq_dept_line.Line_Id and (pq_device.Dev_Data_Type= 2 or pq_device.Dev_Data_Type = #{devDataType})\n" +
|
||||
"\t)")
|
||||
List<DeptLine> getLineByDeptRelation(@Param("devDataType")Integer devDataType);
|
||||
|
||||
|
||||
List<LineDevGetDTO> lineDevGet(@Param("list")List<Integer> devType,@Param("type")Integer type);
|
||||
|
||||
List<TerminalGetBase> orgSubStationGet(@Param("list")List<Integer> devType);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.dto.SimpleDTO;
|
||||
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||
import com.njcn.device.pq.pojo.bo.BaseLineInfo;
|
||||
import com.njcn.device.pq.pojo.bo.DeviceType;
|
||||
import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel;
|
||||
@@ -419,4 +420,12 @@ public interface LineMapper extends BaseMapper<Line> {
|
||||
|
||||
Page<LineFlowMealDetailVO> getNewDeviceRunStatistics (Page<LineFlowMealDetailVO> page,@Param("devs") List<String> list, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
|
||||
Page<LineFlowMealDetailVO> getNewDeviceFlowStatistics (Page<LineFlowMealDetailVO> page,@Param("devs") List<String> list, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 通过电站id获取监测点信息
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
List<LineDevGetDTO> getLineBySubStation(@Param("subId")String subId);
|
||||
}
|
||||
|
||||
@@ -17,4 +17,70 @@
|
||||
<select id="getMyselfBindLine" resultType="String">
|
||||
select line_id from pq_dept_line where Id =#{deptId}
|
||||
</select>
|
||||
|
||||
<select id="lineDevGet" resultType="com.njcn.device.biz.pojo.dto.LineDevGetDTO">
|
||||
select
|
||||
<!--监测点-->
|
||||
<if test="type == 1">
|
||||
pq_dept_line.id unitId,
|
||||
point.id pointId,
|
||||
lineDetail.Time_Interval as `interval`,
|
||||
dic.value voltageLevel,
|
||||
dev.id devId,
|
||||
device.com_flag comFlag
|
||||
</if>
|
||||
<!--母线-->
|
||||
<if test="type == 2">
|
||||
DISTINCT
|
||||
pq_dept_line.id unitId,
|
||||
dic.value voltageLevel,
|
||||
voltage.id pointId
|
||||
|
||||
</if>
|
||||
<!--装置-->
|
||||
<if test="type == 3">
|
||||
DISTINCT
|
||||
pq_dept_line.id unitId,
|
||||
dev.id devId,
|
||||
dic.value voltageLevel,
|
||||
1 as type ,
|
||||
device.update_time
|
||||
</if>
|
||||
from pq_dept_line pq_dept_line
|
||||
inner join pq_line point on pq_dept_line.line_id = point.id
|
||||
inner join pq_line_detail lineDetail on point.id = lineDetail.id
|
||||
inner join pq_line voltage on point.pid = voltage.id
|
||||
inner join pq_voltage pq_voltage on voltage.id = pq_voltage.id
|
||||
inner join sys_dict_data dic on pq_voltage.Scale= dic.id
|
||||
inner join pq_line dev on voltage.pid = dev.id
|
||||
inner join pq_device device on dev.id = device.id
|
||||
where device.Dev_Model = 1
|
||||
and point.state = 1
|
||||
and device.Dev_Data_Type in
|
||||
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<select id="orgSubStationGet" resultType="com.njcn.device.biz.pojo.dto.TerminalGetBase">
|
||||
select
|
||||
DISTINCT
|
||||
pq_dept_line.id unitId,
|
||||
substation.id ledgerId
|
||||
from pq_dept_line pq_dept_line
|
||||
inner join pq_line point on pq_dept_line.line_id = point.id
|
||||
inner join pq_line_detail lineDetail on point.id = lineDetail.id
|
||||
inner join pq_line voltage on point.pid = voltage.id
|
||||
inner join pq_line dev on voltage.pid = dev.id
|
||||
inner join pq_device device on dev.id = device.id
|
||||
inner join pq_line substation on dev.pid = substation.id
|
||||
where device.Dev_Model = 1
|
||||
and point.state = 1
|
||||
and device.Dev_Data_Type in
|
||||
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1065,4 +1065,28 @@
|
||||
and a.state = 1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getLineBySubStation" resultType="com.njcn.device.biz.pojo.dto.LineDevGetDTO">
|
||||
SELECT
|
||||
pq_line.id pointId,
|
||||
lineDetail.Time_Interval `interval`,
|
||||
dev.id devId,
|
||||
device.com_flag
|
||||
FROM
|
||||
pq_line pq_line
|
||||
INNER JOIN pq_line_detail lineDetail ON pq_line.id = lineDetail.id
|
||||
INNER JOIN pq_line busBar ON pq_line.pid = busBar.id
|
||||
INNER JOIN pq_line dev ON busBar.pid = dev.id
|
||||
INNER JOIN pq_device device ON dev.id = device.id
|
||||
WHERE
|
||||
(pq_line.LEVEL = 6
|
||||
AND pq_line.state = 1
|
||||
AND device.Dev_Model = 1
|
||||
AND device.Run_Flag = 0
|
||||
)
|
||||
and FIND_IN_SET(#{subId}, pq_line.pids );
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.njcn.device.pq.service;
|
||||
|
||||
import com.njcn.device.biz.pojo.dto.*;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
|
||||
public interface CommTerminalService {
|
||||
|
||||
|
||||
/**
|
||||
*通过部门获取所有子集部门所拥有的监测点
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
List<DeptGetChildrenDTO> deptGetLineList(DeptGetLineParam deptGetLineParam);
|
||||
|
||||
/**
|
||||
* 根据单位获取所有子单位信息
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
List<DeptGetBase> getDeptChildrenByParent(DeptGetLineParam deptGetLineParam);
|
||||
|
||||
/**
|
||||
* 根据单位获取单位监测点
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
List<DeptGetChildrenMoreDTO> deptGetLine(DeptGetLineParam deptGetLineParam);
|
||||
|
||||
/**
|
||||
* 根据单位获取所有变电站
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
List<DeptGetSubStationDTO> deptSubStation(DeptGetLineParam deptGetLineParam);
|
||||
|
||||
|
||||
/**
|
||||
* 根据单位获取所有变电站
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
List<DeptGetBusBarDTO> deptBusBar(DeptGetLineParam deptGetLineParam);
|
||||
|
||||
|
||||
/**
|
||||
* 根据单位获取所有装置
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
List<DeptGetDeviceDTO> deptGetDevice(DeptGetLineParam deptGetLineParam);
|
||||
|
||||
/**
|
||||
* 根据单位获取所有装置
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
List<LineDevGetDTO> substationGetLine(String substationId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据母线获取监测点信息
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
List<LineDevGetDTO> busBarGetLine(String busBarId);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.device.pq.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||
import com.njcn.device.pq.pojo.po.DeptLine;
|
||||
import com.njcn.web.pojo.param.DeptLineParam;
|
||||
|
||||
@@ -64,4 +65,23 @@ public interface DeptLineService extends IService<DeptLine> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取根据单位分组的监测点集合信息
|
||||
* param devType 装置类型 0暂态 1稳态 2 双类型
|
||||
* param type 装置类型 1监测点 2母线 3 装置
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
Map<String, List<LineDevGetDTO>> lineDevGet(List<Integer> devType,Integer type);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取根据单位分组的变电站集合信息
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
Map<String, List<String>> orgSubStationGet(List<Integer> devType);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
package com.njcn.device.pq.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.enums.common.ServerEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.EnumUtils;
|
||||
import com.njcn.device.biz.pojo.dto.*;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import com.njcn.device.pq.mapper.LineMapper;
|
||||
import com.njcn.device.pq.service.CommTerminalService;
|
||||
import com.njcn.device.pq.service.DeptLineService;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class CommTerminalServiceImpl implements CommTerminalService {
|
||||
|
||||
private final String commTerminal = "commTerminal#";
|
||||
|
||||
private final DeptLineService deptLineService;
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final LineMapper lineMapper;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 基础获取单位信息
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
@Override
|
||||
public List<DeptGetBase> getDeptChildrenByParent(DeptGetLineParam deptGetLineParam) {
|
||||
/*List<DeptGetBase> redisResult = (List<DeptGetBase>) redisUtil.getObjectByKey(commTerminal + deptGetLineParam.getDeptId());
|
||||
if (CollectionUtil.isNotEmpty(redisResult)) {
|
||||
return redisResult;
|
||||
}*/
|
||||
List<DeptGetBase> result = new ArrayList<>();
|
||||
List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(deptGetLineParam.getDeptId(), Stream.of(0, 1).collect(Collectors.toList())).getData();
|
||||
deptDTOList.forEach(it -> {
|
||||
DeptGetBase deptGetBase = new DeptGetBase();
|
||||
deptGetBase.setUnitId(it.getId());
|
||||
deptGetBase.setUnitName(it.getName());
|
||||
List<String> deptChildren = deptDTOList.stream().filter(deptDTO -> deptDTO.getPids().contains(it.getId())).map(DeptDTO::getId).collect(Collectors.toList());
|
||||
deptChildren.add(it.getId());
|
||||
deptGetBase.setUnitChildrenList(deptChildren);
|
||||
result.add(deptGetBase);
|
||||
});
|
||||
redisUtil.saveByKey(commTerminal + deptGetLineParam.getDeptId(),result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DeptGetChildrenMoreDTO> deptGetLine(DeptGetLineParam deptGetLineParam) {
|
||||
List<DeptGetChildrenMoreDTO> result = new ArrayList<>();
|
||||
List<DeptGetBase> temDept = getDeptChildrenByParent(deptGetLineParam);
|
||||
Map<String, List<LineDevGetDTO>> map = deptLineService.lineDevGet(filterDataTypeNew(deptGetLineParam.getServerName()),1);
|
||||
temDept.forEach(item -> {
|
||||
DeptGetChildrenMoreDTO deptGetChildrenMoreDTO = new DeptGetChildrenMoreDTO();
|
||||
deptGetChildrenMoreDTO.setUnitId(item.getUnitId());
|
||||
deptGetChildrenMoreDTO.setUnitName(item.getUnitName());
|
||||
deptGetChildrenMoreDTO.setUnitChildrenList(item.getUnitChildrenList());
|
||||
List<String> deptIds = item.getUnitChildrenList();
|
||||
if (CollectionUtil.isNotEmpty(deptIds)) {
|
||||
List<LineDevGetDTO> lineList = new ArrayList<>();
|
||||
deptIds.forEach(i -> {
|
||||
if (map.containsKey(i)) {
|
||||
lineList.addAll(map.get(i));
|
||||
}
|
||||
});
|
||||
deptGetChildrenMoreDTO.setLineBaseList(lineList);
|
||||
}
|
||||
result.add(deptGetChildrenMoreDTO);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DeptGetSubStationDTO> deptSubStation(DeptGetLineParam deptGetLineParam) {
|
||||
List<DeptGetSubStationDTO> result = new ArrayList<>();
|
||||
List<DeptGetBase> temDept = getDeptChildrenByParent(deptGetLineParam);
|
||||
Map<String, List<String>> map = deptLineService.orgSubStationGet(filterDataTypeNew(deptGetLineParam.getServerName()));
|
||||
temDept.forEach(item -> {
|
||||
DeptGetSubStationDTO deptGetSubStationDTO = new DeptGetSubStationDTO();
|
||||
deptGetSubStationDTO.setUnitId(item.getUnitId());
|
||||
deptGetSubStationDTO.setUnitName(item.getUnitName());
|
||||
deptGetSubStationDTO.setUnitChildrenList(item.getUnitChildrenList());
|
||||
List<String> deptIds = item.getUnitChildrenList();
|
||||
if (CollectionUtil.isNotEmpty(deptIds)) {
|
||||
List<String> lineList = new ArrayList<>();
|
||||
deptIds.forEach(i -> {
|
||||
if (map.containsKey(i)) {
|
||||
lineList.addAll(map.get(i));
|
||||
}
|
||||
});
|
||||
deptGetSubStationDTO.setStationIds(lineList);
|
||||
}
|
||||
result.add(deptGetSubStationDTO);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptGetBusBarDTO> deptBusBar(DeptGetLineParam deptGetLineParam) {
|
||||
List<DeptGetBusBarDTO> result = new ArrayList<>();
|
||||
List<DeptGetBase> temDept = getDeptChildrenByParent(deptGetLineParam);
|
||||
Map<String, List<LineDevGetDTO>> map = deptLineService.lineDevGet(filterDataTypeNew(deptGetLineParam.getServerName()),2);
|
||||
temDept.forEach(item -> {
|
||||
DeptGetBusBarDTO deptGetBusBarDTO = new DeptGetBusBarDTO();
|
||||
deptGetBusBarDTO.setUnitId(item.getUnitId());
|
||||
deptGetBusBarDTO.setUnitName(item.getUnitName());
|
||||
deptGetBusBarDTO.setUnitChildrenList(item.getUnitChildrenList());
|
||||
List<String> deptIds = item.getUnitChildrenList();
|
||||
if (CollectionUtil.isNotEmpty(deptIds)) {
|
||||
List<String> lineList = new ArrayList<>();
|
||||
deptIds.forEach(i -> {
|
||||
if (map.containsKey(i)) {
|
||||
lineList.addAll(map.get(i).stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()));
|
||||
}
|
||||
});
|
||||
deptGetBusBarDTO.setBusBarIds(lineList);
|
||||
}
|
||||
result.add(deptGetBusBarDTO);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptGetDeviceDTO> deptGetDevice(DeptGetLineParam deptGetLineParam) {
|
||||
List<DeptGetDeviceDTO> result = new ArrayList<>();
|
||||
List<DeptGetBase> temDept = getDeptChildrenByParent(deptGetLineParam);
|
||||
Map<String, List<LineDevGetDTO>> map = deptLineService.lineDevGet(filterDataTypeNew(deptGetLineParam.getServerName()),3);
|
||||
temDept.forEach(item -> {
|
||||
DeptGetDeviceDTO deptGetDeviceDTO = new DeptGetDeviceDTO();
|
||||
deptGetDeviceDTO.setUnitId(item.getUnitId());
|
||||
deptGetDeviceDTO.setUnitName(item.getUnitName());
|
||||
deptGetDeviceDTO.setUnitChildrenList(item.getUnitChildrenList());
|
||||
List<String> deptIds = item.getUnitChildrenList();
|
||||
if (CollectionUtil.isNotEmpty(deptIds)) {
|
||||
List<LineDevGetDTO> devGetDTOList = new ArrayList<>();
|
||||
deptIds.forEach(i -> {
|
||||
if (map.containsKey(i)) {
|
||||
devGetDTOList.addAll(map.get(i));
|
||||
}
|
||||
});
|
||||
deptGetDeviceDTO.setDeviceList(devGetDTOList);
|
||||
}
|
||||
result.add(deptGetDeviceDTO);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LineDevGetDTO> substationGetLine(String substationId) {
|
||||
return lineMapper.getLineBySubStation(substationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LineDevGetDTO> busBarGetLine(String busBarId) {
|
||||
return lineMapper.getLineBySubStation(busBarId);
|
||||
}
|
||||
|
||||
|
||||
private void getChildrenByParent(List<DeptDTO> deptAllList, List<DeptGetChildrenMoreDTO> res) {
|
||||
deptAllList.forEach(it -> {
|
||||
DeptGetChildrenMoreDTO deptGetChildrenMoreDTO = new DeptGetChildrenMoreDTO();
|
||||
deptGetChildrenMoreDTO.setUnitId(it.getId());
|
||||
deptGetChildrenMoreDTO.setUnitName(it.getName());
|
||||
List<String> deptChildren = deptAllList.stream().filter(deptDTO -> deptDTO.getPids().contains(it.getId())).map(DeptDTO::getId).collect(Collectors.toList());
|
||||
deptChildren.add(it.getId());
|
||||
deptGetChildrenMoreDTO.setUnitChildrenList(deptChildren);
|
||||
res.add(deptGetChildrenMoreDTO);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private List<Integer> filterDataTypeNew(String serverName) {
|
||||
List<Integer> devType = new ArrayList<>();
|
||||
devType.add(2);
|
||||
ServerEnum serverEnum = EnumUtils.getServerEnumByName(serverName);
|
||||
switch (serverEnum) {
|
||||
case EVENT:
|
||||
devType.add(0);
|
||||
break;
|
||||
case HARMONIC:
|
||||
devType.add(1);
|
||||
break;
|
||||
default:
|
||||
devType.add(0);
|
||||
devType.add(1);
|
||||
break;
|
||||
}
|
||||
return devType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @author cdf
|
||||
* @date 2023/5/10
|
||||
*/
|
||||
@Override
|
||||
public List<DeptGetChildrenDTO> deptGetLineList(DeptGetLineParam deptGetLineParam) {
|
||||
List<DeptGetChildrenDTO> all = new ArrayList<>();
|
||||
List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(deptGetLineParam.getDeptId(), Stream.of(0, 1).collect(Collectors.toList())).getData();
|
||||
getAllChildren(deptGetLineParam.getDeptId(), deptDTOList, all);
|
||||
Map<String, List<String>> map = deptLineService.getLineByDeptRelation(filterDataType(deptGetLineParam.getServerName()));
|
||||
all.forEach(item -> {
|
||||
List<String> itemDeptChildren = item.getDeptChildren();
|
||||
if (CollectionUtil.isNotEmpty(itemDeptChildren)) {
|
||||
List<String> lineIds = new ArrayList<>();
|
||||
itemDeptChildren.forEach(i -> {
|
||||
if (map.containsKey(i)) {
|
||||
lineIds.addAll(map.get(i));
|
||||
}
|
||||
});
|
||||
item.setLineIds(lineIds);
|
||||
}
|
||||
});
|
||||
return all;
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选数据类型
|
||||
*/
|
||||
private Integer filterDataType(String serverName) {
|
||||
ServerEnum serverEnum = EnumUtils.getServerEnumByName(serverName);
|
||||
switch (serverEnum) {
|
||||
case EVENT:
|
||||
return 0;
|
||||
case HARMONIC:
|
||||
return 1;
|
||||
default:
|
||||
throw new BusinessException(CommonResponseEnum.INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定部门所有子孙部门id
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/4/24
|
||||
*/
|
||||
private void getAllChildren(String deptId, List<DeptDTO> deptAllList, List<DeptGetChildrenDTO> res) {
|
||||
deptAllList.stream().filter(item -> item.getPid().equals(deptId)).forEach(it -> {
|
||||
List<String> deptChildren = deptAllList.stream().filter(deptDTO -> deptDTO.getPids().contains(it.getId())).map(DeptDTO::getId).collect(Collectors.toList());
|
||||
deptChildren.add(it.getId());
|
||||
DeptGetChildrenDTO generalDeviceDTO = new DeptGetChildrenDTO();
|
||||
generalDeviceDTO.setDeptId(it.getId());
|
||||
generalDeviceDTO.setDeptName(it.getName());
|
||||
generalDeviceDTO.setDeptChildren(deptChildren);
|
||||
res.add(generalDeviceDTO);
|
||||
getAllChildren(it.getId(), deptAllList, res);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package com.njcn.device.pq.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.device.biz.pojo.dto.TerminalGetBase;
|
||||
import com.njcn.device.pq.mapper.DeptLineMapper;
|
||||
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||
import com.njcn.device.pq.pojo.po.DeptLine;
|
||||
import com.njcn.device.pq.service.DeptLineService;
|
||||
import com.njcn.web.pojo.param.DeptLineParam;
|
||||
@@ -11,7 +13,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -85,5 +86,18 @@ public class DeptLineServiceImpl extends ServiceImpl<DeptLineMapper, DeptLine> i
|
||||
return deptLines.stream ( ).collect (Collectors.groupingBy (DeptLine::getId, Collectors.mapping (DeptLine::getLineId,Collectors.toList ())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<LineDevGetDTO>> lineDevGet(List<Integer> devDataType,Integer type) {
|
||||
List<LineDevGetDTO> deptLines = deptLineMapper.lineDevGet(devDataType,type);
|
||||
return deptLines.stream ().collect (Collectors.groupingBy (LineDevGetDTO::getUnitId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> orgSubStationGet(List<Integer> devDataType) {
|
||||
List<TerminalGetBase> deptLines = deptLineMapper.orgSubStationGet(devDataType);
|
||||
return deptLines.stream ().collect (Collectors.groupingBy (TerminalGetBase::getUnitId, Collectors.mapping (TerminalGetBase::getLedgerId,Collectors.toList ())));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user