1.污区图
2.过程监督-终端 代码提交
This commit is contained in:
@@ -18,4 +18,6 @@ public class HarmonicPublicParam extends DeviceInfoParam.BusinessParam{
|
|||||||
@ApiModelProperty(name = "id", value = "id")
|
@ApiModelProperty(name = "id", value = "id")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "type", value = "区分(0:pq 1:pms)")
|
||||||
|
private Integer type=0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.njcn.harmonic.pojo.vo;
|
||||||
|
|
||||||
|
import com.njcn.device.pms.pojo.po.Monitor;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <功能描述>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @createTime: 2023-03-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PollMonitorVO extends Monitor {
|
||||||
|
|
||||||
|
@ApiModelProperty("数据")
|
||||||
|
private Double data = -1.0;
|
||||||
|
}
|
||||||
@@ -93,4 +93,14 @@ public class PollutionSubstationController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/getLineRank")
|
||||||
|
@ApiOperation("污区图-获取前十监测点排名")
|
||||||
|
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||||
|
public HttpResult<List<PollutionLineDTO>> getLineRank(@RequestBody HarmonicPublicParam param) {
|
||||||
|
String methodDescribe = getMethodDescribe("getLineRank");
|
||||||
|
LogUtil.njcnDebug(log, "{},实体参数:{}", methodDescribe, param);
|
||||||
|
List<PollutionLineDTO> list = pollutionSubstationService.getLineRank(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,4 +55,14 @@ public interface PollutionSubstationService extends IService<RStatPollutionSubst
|
|||||||
* @Date: 2022/11/3
|
* @Date: 2022/11/3
|
||||||
*/
|
*/
|
||||||
List<PollutionLineDTO> getLineInfoById(HarmonicPublicParam param);
|
List<PollutionLineDTO> getLineInfoById(HarmonicPublicParam param);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 获取前十监测点排名
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-03-03 16:21
|
||||||
|
* @param param
|
||||||
|
* @return List<PollutionLineDTO>
|
||||||
|
*/
|
||||||
|
List<PollutionLineDTO> getLineRank(HarmonicPublicParam param);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
package com.njcn.harmonic.service.impl;
|
package com.njcn.harmonic.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.njcn.common.config.GeneralInfo;
|
import com.njcn.common.config.GeneralInfo;
|
||||||
|
import com.njcn.common.pojo.dto.SimpleDTO;
|
||||||
|
import com.njcn.device.pms.api.MonitorClient;
|
||||||
|
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
|
||||||
|
import com.njcn.device.pms.api.PmsGeneratrixClient;
|
||||||
|
import com.njcn.device.pms.api.StatationStatClient;
|
||||||
|
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
|
||||||
|
import com.njcn.device.pms.pojo.dto.PmsStatationStatInfoDTO;
|
||||||
|
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
|
||||||
|
import com.njcn.device.pms.pojo.param.PmsStatationStatInfoParam;
|
||||||
|
import com.njcn.device.pms.pojo.po.Monitor;
|
||||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||||
import com.njcn.device.pq.api.LineFeignClient;
|
import com.njcn.device.pq.api.LineFeignClient;
|
||||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||||
@@ -10,6 +22,7 @@ import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
|
|||||||
import com.njcn.harmonic.constant.Param;
|
import com.njcn.harmonic.constant.Param;
|
||||||
import com.njcn.harmonic.pojo.dto.PublicDTO;
|
import com.njcn.harmonic.pojo.dto.PublicDTO;
|
||||||
import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
|
import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
|
||||||
|
import com.njcn.harmonic.pojo.vo.PollMonitorVO;
|
||||||
import com.njcn.harmonic.pojo.vo.PollutionVO;
|
import com.njcn.harmonic.pojo.vo.PollutionVO;
|
||||||
import com.njcn.harmonic.service.IPollutionService;
|
import com.njcn.harmonic.service.IPollutionService;
|
||||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||||
@@ -38,7 +51,13 @@ public class PollutionServiceImpl implements IPollutionService {
|
|||||||
|
|
||||||
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
||||||
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
|
||||||
|
|
||||||
|
private final StatationStatClient statationStatClient;
|
||||||
|
|
||||||
|
private final MonitorClient monitorClient;
|
||||||
|
|
||||||
|
private final InfluxDbUtils influxDbUtils = new InfluxDbUtils("admin", "njcnpqs", "http://192.168.1.18:8086", "pqsbase", ""); ;
|
||||||
|
|
||||||
private final GeneralInfo generalInfo;
|
private final GeneralInfo generalInfo;
|
||||||
|
|
||||||
@@ -46,11 +65,12 @@ public class PollutionServiceImpl implements IPollutionService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PollutionVO> getDeptSubstationRelations(HarmonicPublicParam harmonicPublicParam) {
|
public List<PollutionVO> getDeptSubstationRelations(HarmonicPublicParam harmonicPublicParam) {
|
||||||
harmonicPublicParam.setServerName(generalInfo.getMicroServiceName());
|
//用于区分是pms 还是 pq
|
||||||
List<PollutionVO> list = new ArrayList<>();
|
List<PollutionVO> list = new ArrayList<>();
|
||||||
List<String> lineList = new ArrayList<>();
|
List<String> lineList = new ArrayList<>();
|
||||||
List<PollutionLineDTO> lineInfo = new ArrayList<>();
|
List<PollutionLineDTO> lineInfo = new ArrayList<>();
|
||||||
PollutionParamDTO paramDTO = new PollutionParamDTO();
|
PollutionParamDTO paramDTO = new PollutionParamDTO();
|
||||||
|
harmonicPublicParam.setServerName(generalInfo.getMicroServiceName());
|
||||||
if (StringUtils.isBlank(RequestUtil.getDeptIndex())) {
|
if (StringUtils.isBlank(RequestUtil.getDeptIndex())) {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -58,10 +78,13 @@ public class PollutionServiceImpl implements IPollutionService {
|
|||||||
deviceList.forEach(dept -> {
|
deviceList.forEach(dept -> {
|
||||||
lineList.addAll(dept.getLineIndexes());
|
lineList.addAll(dept.getLineIndexes());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(lineList)) {
|
if (!CollectionUtils.isEmpty(lineList)) {
|
||||||
paramDTO.setLineList(lineList);
|
paramDTO.setLineList(lineList);
|
||||||
lineInfo = lineFeignClient.getLineInfo(paramDTO).getData();
|
lineInfo = lineFeignClient.getLineInfo(paramDTO).getData();
|
||||||
|
|
||||||
List<PublicDTO> lineData = getLineDate(lineList, harmonicPublicParam.getSearchBeginTime(), harmonicPublicParam.getSearchEndTime(), harmonicPublicParam.getStatisticalType().getCode());
|
List<PublicDTO> lineData = getLineDate(lineList, harmonicPublicParam.getSearchBeginTime(), harmonicPublicParam.getSearchEndTime(), harmonicPublicParam.getStatisticalType().getCode());
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(lineData)) {
|
if (!CollectionUtils.isEmpty(lineData)) {
|
||||||
lineInfo.stream().map(list1 -> lineData.stream().filter(list2 -> Objects.equals(list1.getId(), list2.getId())).findAny().map(m -> {
|
lineInfo.stream().map(list1 -> lineData.stream().filter(list2 -> Objects.equals(list1.getId(), list2.getId())).findAny().map(m -> {
|
||||||
list1.setData(m.getData());
|
list1.setData(m.getData());
|
||||||
@@ -100,8 +123,8 @@ public class PollutionServiceImpl implements IPollutionService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PollutionSubstationDTO> getSubstationInfoById(HarmonicPublicParam deptParam) {
|
public List<PollutionSubstationDTO> getSubstationInfoById(HarmonicPublicParam deptParam) {
|
||||||
deptParam.setServerName(generalInfo.getMicroServiceName());
|
|
||||||
List<PollutionSubstationDTO> list = new ArrayList<>();
|
List<PollutionSubstationDTO> list = new ArrayList<>();
|
||||||
|
deptParam.setServerName(generalInfo.getMicroServiceName());
|
||||||
List<GeneralDeviceDTO> sub = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(deptParam).getData();
|
List<GeneralDeviceDTO> sub = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(deptParam).getData();
|
||||||
sub.forEach(item -> {
|
sub.forEach(item -> {
|
||||||
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient.getSubstationInfo(item.getIndex()).getData();
|
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient.getSubstationInfo(item.getIndex()).getData();
|
||||||
@@ -188,6 +211,7 @@ public class PollutionServiceImpl implements IPollutionService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能描述:根据监测点id查询influxDB污染指数
|
* 功能描述:根据监测点id查询influxDB污染指数
|
||||||
|
*
|
||||||
* @param line 监测点集合
|
* @param line 监测点集合
|
||||||
* startTime 开始时间
|
* startTime 开始时间
|
||||||
* endTime 结束时间
|
* endTime 结束时间
|
||||||
|
|||||||
@@ -1,15 +1,26 @@
|
|||||||
package com.njcn.harmonic.service.impl;
|
package com.njcn.harmonic.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.common.config.GeneralInfo;
|
import com.njcn.common.config.GeneralInfo;
|
||||||
import com.njcn.common.pojo.constant.BizParamConstant;
|
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||||
|
import com.njcn.common.pojo.dto.SimpleDTO;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.device.pms.api.MonitorClient;
|
||||||
|
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
|
||||||
|
import com.njcn.device.pms.api.StatationStatClient;
|
||||||
|
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
|
||||||
|
import com.njcn.device.pms.pojo.dto.PmsStatationStatInfoDTO;
|
||||||
|
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
|
||||||
|
import com.njcn.device.pms.pojo.param.PmsStatationStatInfoParam;
|
||||||
|
import com.njcn.device.pms.pojo.po.Monitor;
|
||||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||||
import com.njcn.device.pq.api.LineFeignClient;
|
import com.njcn.device.pq.api.LineFeignClient;
|
||||||
import com.njcn.device.pq.api.SubstationFeignClient;
|
import com.njcn.device.pq.api.SubstationFeignClient;
|
||||||
import com.njcn.device.pq.pojo.dto.*;
|
import com.njcn.device.pq.pojo.dto.*;
|
||||||
|
import com.njcn.harmonic.constant.Param;
|
||||||
import com.njcn.harmonic.mapper.*;
|
import com.njcn.harmonic.mapper.*;
|
||||||
import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
|
import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
|
||||||
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
|
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
|
||||||
@@ -45,7 +56,9 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
|||||||
|
|
||||||
private final SubstationFeignClient substationFeignClient;
|
private final SubstationFeignClient substationFeignClient;
|
||||||
|
|
||||||
|
private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
|
||||||
|
private final StatationStatClient statationStatClient;
|
||||||
|
private final MonitorClient monitorClient;
|
||||||
|
|
||||||
private final RStatPollutionSubstationMMapper pollutionSubstationMMapper;
|
private final RStatPollutionSubstationMMapper pollutionSubstationMMapper;
|
||||||
private final RStatPollutionSubstationYPOMapper pollutionSubstationYPOMapper;
|
private final RStatPollutionSubstationYPOMapper pollutionSubstationYPOMapper;
|
||||||
@@ -150,18 +163,59 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<PollutionVO> getDeptSubstationRelations(HarmonicPublicParam harmonicPublicParam) {
|
public List<PollutionVO> getDeptSubstationRelations(HarmonicPublicParam harmonicPublicParam) {
|
||||||
harmonicPublicParam.setServerName(generalInfo.getMicroServiceName());
|
|
||||||
List<PollutionVO> list = new ArrayList<>();
|
List<PollutionVO> list = new ArrayList<>();
|
||||||
List<String> lineList = new ArrayList<>();
|
|
||||||
List<PollutionLineDTO> lineInfo = new ArrayList<>();
|
|
||||||
PollutionParamDTO paramDTO = new PollutionParamDTO();
|
|
||||||
|
|
||||||
String pollutionType = harmonicPublicParam.getStatisticalType ( ).getId ();
|
String pollutionType = harmonicPublicParam.getStatisticalType ( ).getId ();
|
||||||
|
|
||||||
String searchBeginTime = harmonicPublicParam.getSearchBeginTime ( ).substring (0,10);
|
String searchBeginTime = harmonicPublicParam.getSearchBeginTime ( ).substring (0,10);
|
||||||
if (StringUtils.isBlank(RequestUtil.getDeptIndex())){
|
if (StringUtils.isBlank(RequestUtil.getDeptIndex())){
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (harmonicPublicParam.getType() == 0) {
|
||||||
|
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam();
|
||||||
|
pmsDeviceInfoParam.setDeptIndex(harmonicPublicParam.getDeptIndex());
|
||||||
|
//获取统计类型
|
||||||
|
pmsDeviceInfoParam.setStatisticalType(harmonicPublicParam.getStatisticalType());
|
||||||
|
//获取主网台账信息
|
||||||
|
List<PmsGeneralDeviceDTO> deviceList = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam).getData();
|
||||||
|
deviceList.forEach(temp->{
|
||||||
|
PollutionVO pollutionVO = new PollutionVO ();
|
||||||
|
String detpid = temp.getIndex ();
|
||||||
|
String name =temp.getName ();
|
||||||
|
List<String> powers = temp.getPowerrIdList ( );
|
||||||
|
pollutionVO.setId (detpid);
|
||||||
|
pollutionVO.setName (name);
|
||||||
|
pollutionVO.setData (-1.0);
|
||||||
|
setData(harmonicPublicParam, pollutionType, searchBeginTime, pollutionVO, detpid);
|
||||||
|
|
||||||
|
//子集变电站
|
||||||
|
List<PollutionVO> powersVO = new ArrayList<>();
|
||||||
|
PmsStatationStatInfoParam param=new PmsStatationStatInfoParam();
|
||||||
|
param.setPowerIds(powers);
|
||||||
|
List<PmsStatationStatInfoDTO> data = statationStatClient.getStatationStatInfo(param).getData();
|
||||||
|
//去重解决重复数据
|
||||||
|
ArrayList<PmsStatationStatInfoDTO> dsData = data.stream().collect(Collectors.collectingAndThen
|
||||||
|
(Collectors.toCollection(() ->
|
||||||
|
new TreeSet<>(Comparator.comparing(o -> o.getPowerId()))), ArrayList::new));
|
||||||
|
Map<String, Double> stringDoubleMap = setPmsSubData(harmonicPublicParam, pollutionType, searchBeginTime, powers);
|
||||||
|
if(CollectionUtil.isNotEmpty(data)){
|
||||||
|
dsData.forEach(power->{
|
||||||
|
PollutionVO pollutionsubVO = new PollutionVO ();
|
||||||
|
pollutionsubVO.setId (power.getPowerId());
|
||||||
|
pollutionsubVO.setName ( power.getPowerName ());
|
||||||
|
pollutionsubVO.setPid (temp.getIndex ());
|
||||||
|
if(stringDoubleMap.containsKey(power.getPowerId())){
|
||||||
|
pollutionsubVO.setData(stringDoubleMap.get(power.getPowerId()));
|
||||||
|
}
|
||||||
|
powersVO.add (pollutionsubVO) ;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pollutionVO.setChildren (powersVO);
|
||||||
|
list.add (pollutionVO);
|
||||||
|
});
|
||||||
|
|
||||||
|
}else{
|
||||||
|
harmonicPublicParam.setServerName(generalInfo.getMicroServiceName());
|
||||||
|
|
||||||
List<GeneralDeviceDTO> sub = generalDeviceInfoClient.getPracticalRunDeviceInfo(harmonicPublicParam).getData();
|
List<GeneralDeviceDTO> sub = generalDeviceInfoClient.getPracticalRunDeviceInfo(harmonicPublicParam).getData();
|
||||||
sub.forEach (temp ->{
|
sub.forEach (temp ->{
|
||||||
PollutionVO pollutionVO = new PollutionVO ();
|
PollutionVO pollutionVO = new PollutionVO ();
|
||||||
@@ -171,6 +225,107 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
|||||||
pollutionVO.setId (detpid);
|
pollutionVO.setId (detpid);
|
||||||
pollutionVO.setName (name);
|
pollutionVO.setName (name);
|
||||||
pollutionVO.setData (-1.0);
|
pollutionVO.setData (-1.0);
|
||||||
|
setData(harmonicPublicParam, pollutionType, searchBeginTime, pollutionVO, detpid);
|
||||||
|
|
||||||
|
|
||||||
|
List<PollutionVO> subPollutionVO = new ArrayList<>();
|
||||||
|
subIndexes.forEach (subIndex->{
|
||||||
|
PollutionVO pollutionsubVO = new PollutionVO ();
|
||||||
|
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient.getSubstationInfo(subIndex).getData();
|
||||||
|
String id = pollutionSubstationDTO.getId ( );
|
||||||
|
pollutionsubVO.setId (id);
|
||||||
|
pollutionsubVO.setName ( pollutionSubstationDTO.getName ());
|
||||||
|
pollutionsubVO.setPid (temp.getIndex ());
|
||||||
|
pollutionsubVO.setData (-1.0);
|
||||||
|
|
||||||
|
setSubData(harmonicPublicParam, pollutionType, searchBeginTime, pollutionsubVO, id);
|
||||||
|
|
||||||
|
subPollutionVO.add (pollutionsubVO) ;
|
||||||
|
});
|
||||||
|
pollutionVO.setChildren (subPollutionVO);
|
||||||
|
|
||||||
|
list.add (pollutionVO);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(list)){
|
||||||
|
return list.stream().sorted(Comparator.comparing(PollutionVO::getData).reversed().thenComparing(PollutionVO::getName)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String,Double> setPmsSubData(HarmonicPublicParam harmonicPublicParam, String pollutionType, String searchBeginTime, List<String> id) {
|
||||||
|
if(Objects.equals (harmonicPublicParam.getReportFlag (), BizParamConstant.STAT_BIZ_YEAR) ){
|
||||||
|
QueryWrapper<RStatPollutionSubstationYPO> wrapper = new QueryWrapper<> ();
|
||||||
|
wrapper.in ("substation_id",id).
|
||||||
|
eq ("pollution_type", pollutionType).
|
||||||
|
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
||||||
|
List<RStatPollutionSubstationYPO> s = pollutionSubstationYPOMapper.selectList(wrapper);
|
||||||
|
return s.stream().collect(Collectors.toMap(RStatPollutionSubstationYPO::getSubstationId, RStatPollutionSubstationYPO::getValue));
|
||||||
|
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_QUARTER)){
|
||||||
|
QueryWrapper<RStatPollutionSubstationQPO> wrapper = new QueryWrapper<> ();
|
||||||
|
wrapper.in ("substation_id",id).
|
||||||
|
eq ("pollution_type", pollutionType).
|
||||||
|
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
||||||
|
List<RStatPollutionSubstationQPO> s = pollutionSubstationQPOMapper.selectList(wrapper);
|
||||||
|
return s.stream().collect(Collectors.toMap(RStatPollutionSubstationQPO::getSubstationId, RStatPollutionSubstationQPO::getValue));
|
||||||
|
|
||||||
|
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_MONTH)){
|
||||||
|
QueryWrapper<RStatPollutionSubstationM> wrapper = new QueryWrapper<> ();
|
||||||
|
wrapper.in ("substation_id",id).
|
||||||
|
eq ("pollution_type", pollutionType).
|
||||||
|
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
||||||
|
List<RStatPollutionSubstationM> s = pollutionSubstationMMapper.selectList(wrapper);
|
||||||
|
return s.stream().collect(Collectors.toMap(RStatPollutionSubstationM::getSubstationId, RStatPollutionSubstationM::getValue));
|
||||||
|
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_DAY)){
|
||||||
|
QueryWrapper<RStatPollutionSubstationDPO> wrapper = new QueryWrapper<> ();
|
||||||
|
wrapper.in ("substation_id",id).
|
||||||
|
eq ("pollution_type", pollutionType).
|
||||||
|
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
||||||
|
List<RStatPollutionSubstationDPO> s = pollutionSubstationDPOMapper.selectList(wrapper);
|
||||||
|
return s.stream().collect(Collectors.toMap(RStatPollutionSubstationDPO::getSubstationId, RStatPollutionSubstationDPO::getValue));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSubData(HarmonicPublicParam harmonicPublicParam, String pollutionType, String searchBeginTime, PollutionVO pollutionsubVO, String id) {
|
||||||
|
if(Objects.equals (harmonicPublicParam.getReportFlag (), BizParamConstant.STAT_BIZ_YEAR) ){
|
||||||
|
QueryWrapper<RStatPollutionSubstationYPO> wrapper = new QueryWrapper<> ();
|
||||||
|
wrapper.eq ("substation_id",id).
|
||||||
|
eq ("pollution_type", pollutionType).
|
||||||
|
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
||||||
|
RStatPollutionSubstationYPO rStatPollutionSubstationYPO = pollutionSubstationYPOMapper.selectOne (wrapper);
|
||||||
|
|
||||||
|
Optional.ofNullable (rStatPollutionSubstationYPO).ifPresent (t->pollutionsubVO.setData (t.getValue ()));
|
||||||
|
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_QUARTER)){
|
||||||
|
QueryWrapper<RStatPollutionSubstationQPO> wrapper = new QueryWrapper<> ();
|
||||||
|
wrapper.eq ("substation_id",id).
|
||||||
|
eq ("pollution_type", pollutionType).
|
||||||
|
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
||||||
|
RStatPollutionSubstationQPO rStatPollutionSubstationQPO = pollutionSubstationQPOMapper.selectOne (wrapper);
|
||||||
|
|
||||||
|
Optional.ofNullable (rStatPollutionSubstationQPO).ifPresent (t->pollutionsubVO.setData (t.getValue ()));
|
||||||
|
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_MONTH)){
|
||||||
|
QueryWrapper<RStatPollutionSubstationM> wrapper = new QueryWrapper<> ();
|
||||||
|
wrapper.eq ("substation_id",id).
|
||||||
|
eq ("pollution_type", pollutionType).
|
||||||
|
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
||||||
|
RStatPollutionSubstationM rStatPollutionSubstationM = pollutionSubstationMMapper.selectOne (wrapper);
|
||||||
|
|
||||||
|
Optional.ofNullable (rStatPollutionSubstationM).ifPresent (t->pollutionsubVO.setData (t.getValue ()));
|
||||||
|
|
||||||
|
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_DAY)){
|
||||||
|
QueryWrapper<RStatPollutionSubstationDPO> wrapper = new QueryWrapper<> ();
|
||||||
|
wrapper.eq ("substation_id",id).
|
||||||
|
eq ("pollution_type", pollutionType).
|
||||||
|
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
||||||
|
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper.selectOne (wrapper);
|
||||||
|
|
||||||
|
Optional.ofNullable (rStatPollutionSubstationDPO).ifPresent (t->pollutionsubVO.setData (t.getValue ()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setData(HarmonicPublicParam harmonicPublicParam, String pollutionType, String searchBeginTime, PollutionVO pollutionVO, String detpid) {
|
||||||
if(Objects.equals (harmonicPublicParam.getReportFlag (), BizParamConstant.STAT_BIZ_YEAR) ){
|
if(Objects.equals (harmonicPublicParam.getReportFlag (), BizParamConstant.STAT_BIZ_YEAR) ){
|
||||||
QueryWrapper<RStatPollutionOrgYPO> rStatPollutionOrgYPOQueryWrapper = new QueryWrapper<> ();
|
QueryWrapper<RStatPollutionOrgYPO> rStatPollutionOrgYPOQueryWrapper = new QueryWrapper<> ();
|
||||||
rStatPollutionOrgYPOQueryWrapper.eq ("org_id", detpid).
|
rStatPollutionOrgYPOQueryWrapper.eq ("org_id", detpid).
|
||||||
@@ -207,66 +362,8 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
|||||||
;
|
;
|
||||||
Optional.ofNullable (rStatPollutionOrgDPO).ifPresent (a->pollutionVO.setData (a.getValue ()));
|
Optional.ofNullable (rStatPollutionOrgDPO).ifPresent (a->pollutionVO.setData (a.getValue ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<PollutionVO> subPollutionVO = new ArrayList<>();
|
|
||||||
subIndexes.forEach (subIndex->{
|
|
||||||
PollutionVO pollutionsubVO = new PollutionVO ();
|
|
||||||
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient.getSubstationInfo(subIndex).getData();
|
|
||||||
String id = pollutionSubstationDTO.getId ( );
|
|
||||||
pollutionsubVO.setId (id);
|
|
||||||
pollutionsubVO.setName ( pollutionSubstationDTO.getName ());
|
|
||||||
pollutionsubVO.setPid (temp.getIndex ());
|
|
||||||
pollutionsubVO.setData (-1.0);
|
|
||||||
|
|
||||||
if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_YEAR) ){
|
|
||||||
QueryWrapper<RStatPollutionSubstationYPO> wrapper = new QueryWrapper<> ();
|
|
||||||
wrapper.eq ("substation_id",id).
|
|
||||||
eq ("pollution_type", pollutionType).
|
|
||||||
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
|
||||||
RStatPollutionSubstationYPO rStatPollutionSubstationYPO = pollutionSubstationYPOMapper.selectOne (wrapper);
|
|
||||||
|
|
||||||
Optional.ofNullable (rStatPollutionSubstationYPO).ifPresent (t->pollutionsubVO.setData (t.getValue ()));
|
|
||||||
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_QUARTER)){
|
|
||||||
QueryWrapper<RStatPollutionSubstationQPO> wrapper = new QueryWrapper<> ();
|
|
||||||
wrapper.eq ("substation_id",id).
|
|
||||||
eq ("pollution_type", pollutionType).
|
|
||||||
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
|
||||||
RStatPollutionSubstationQPO rStatPollutionSubstationQPO = pollutionSubstationQPOMapper.selectOne (wrapper);
|
|
||||||
|
|
||||||
Optional.ofNullable (rStatPollutionSubstationQPO).ifPresent (t->pollutionsubVO.setData (t.getValue ()));
|
|
||||||
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_MONTH)){
|
|
||||||
QueryWrapper<RStatPollutionSubstationM> wrapper = new QueryWrapper<> ();
|
|
||||||
wrapper.eq ("substation_id",id).
|
|
||||||
eq ("pollution_type", pollutionType).
|
|
||||||
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
|
||||||
RStatPollutionSubstationM rStatPollutionSubstationM = pollutionSubstationMMapper.selectOne (wrapper);
|
|
||||||
|
|
||||||
Optional.ofNullable (rStatPollutionSubstationM).ifPresent (t->pollutionsubVO.setData (t.getValue ()));
|
|
||||||
|
|
||||||
}else if(Objects.equals (harmonicPublicParam.getReportFlag (),BizParamConstant.STAT_BIZ_DAY)){
|
|
||||||
QueryWrapper<RStatPollutionSubstationDPO> wrapper = new QueryWrapper<> ();
|
|
||||||
wrapper.eq ("substation_id",id).
|
|
||||||
eq ("pollution_type", pollutionType).
|
|
||||||
eq("DATE_FORMAT( data_date ,'%Y-%m-%d')",searchBeginTime);
|
|
||||||
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper.selectOne (wrapper);
|
|
||||||
|
|
||||||
Optional.ofNullable (rStatPollutionSubstationDPO).ifPresent (t->pollutionsubVO.setData (t.getValue ()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subPollutionVO.add (pollutionsubVO) ;
|
|
||||||
});
|
|
||||||
pollutionVO.setChildren (subPollutionVO);
|
|
||||||
|
|
||||||
list.add (pollutionVO);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(list)){
|
|
||||||
return list.stream().sorted(Comparator.comparing(PollutionVO::getData).reversed().thenComparing(PollutionVO::getName)).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: getSubstationInfoById
|
* @Description: getSubstationInfoById
|
||||||
@@ -277,12 +374,43 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<PollutionSubstationDTO> getSubstationInfoById(HarmonicPublicParam deptParam) {
|
public List<PollutionSubstationDTO> getSubstationInfoById(HarmonicPublicParam deptParam) {
|
||||||
deptParam.setServerName(generalInfo.getMicroServiceName());
|
|
||||||
List<PollutionSubstationDTO> list = new ArrayList<>();
|
|
||||||
List<GeneralDeviceDTO> sub = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(deptParam).getData();
|
|
||||||
|
|
||||||
String pollutionType = deptParam.getStatisticalType ( ).getId ();
|
String pollutionType = deptParam.getStatisticalType ( ).getId ();
|
||||||
String searchBeginTime = deptParam.getSearchBeginTime ( ).substring (0,10);
|
String searchBeginTime = deptParam.getSearchBeginTime ( ).substring (0,10);
|
||||||
|
List<PollutionSubstationDTO> list = new ArrayList<>();
|
||||||
|
|
||||||
|
if (deptParam.getType() == 0) {
|
||||||
|
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam();
|
||||||
|
pmsDeviceInfoParam.setDeptIndex(deptParam.getDeptIndex());
|
||||||
|
//获取统计类型
|
||||||
|
pmsDeviceInfoParam.setStatisticalType(deptParam.getStatisticalType());
|
||||||
|
//获取主网台账信息
|
||||||
|
List<PmsGeneralDeviceDTO> deviceList = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam).getData();
|
||||||
|
deviceList.forEach(temp->{
|
||||||
|
List<String> powers = temp.getPowerrIdList ( );
|
||||||
|
PmsStatationStatInfoParam param=new PmsStatationStatInfoParam();
|
||||||
|
param.setPowerIds(powers);
|
||||||
|
List<PmsStatationStatInfoDTO> data = statationStatClient.getStatationStatInfo(param).getData();
|
||||||
|
//去重解决重复数据
|
||||||
|
ArrayList<PmsStatationStatInfoDTO> dsData = data.stream().collect(Collectors.collectingAndThen
|
||||||
|
(Collectors.toCollection(() ->
|
||||||
|
new TreeSet<>(Comparator.comparing(o -> o.getPowerId()))), ArrayList::new));
|
||||||
|
Map<String, Double> stringDoubleMap = setPmsSubData(deptParam, pollutionType, searchBeginTime, powers);
|
||||||
|
if(CollectionUtil.isNotEmpty(data)){
|
||||||
|
dsData.forEach(power->{
|
||||||
|
PollutionSubstationDTO dto=new PollutionSubstationDTO();
|
||||||
|
dto.setId(power.getPowerId());
|
||||||
|
dto.setName(power.getPowerName());
|
||||||
|
dto.setVoltageLevel(power.getPowerVoltageLevel());
|
||||||
|
if(stringDoubleMap.containsKey(power.getPowerId())){
|
||||||
|
dto.setData(stringDoubleMap.get(power.getPowerId()));
|
||||||
|
}
|
||||||
|
list.add (dto) ;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
deptParam.setServerName(generalInfo.getMicroServiceName());
|
||||||
|
List<GeneralDeviceDTO> sub = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(deptParam).getData();
|
||||||
sub.forEach(item->{
|
sub.forEach(item->{
|
||||||
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient.getSubstationInfo(item.getIndex()).getData();
|
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient.getSubstationInfo(item.getIndex()).getData();
|
||||||
String id = pollutionSubstationDTO.getId ();
|
String id = pollutionSubstationDTO.getId ();
|
||||||
@@ -323,6 +451,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
|||||||
|
|
||||||
list.add(pollutionSubstationDTO);
|
list.add(pollutionSubstationDTO);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
if (!CollectionUtils.isEmpty(list)){
|
if (!CollectionUtils.isEmpty(list)){
|
||||||
return list.stream().sorted(Comparator.comparing(PollutionSubstationDTO::getData).reversed().thenComparing(PollutionSubstationDTO::getName)).collect(Collectors.toList());
|
return list.stream().sorted(Comparator.comparing(PollutionSubstationDTO::getData).reversed().thenComparing(PollutionSubstationDTO::getName)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@@ -340,8 +469,6 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
|||||||
public List<PollutionLineDTO> getLineInfoById(HarmonicPublicParam harmonicPublicParam) {
|
public List<PollutionLineDTO> getLineInfoById(HarmonicPublicParam harmonicPublicParam) {
|
||||||
harmonicPublicParam.setServerName(generalInfo.getMicroServiceName());
|
harmonicPublicParam.setServerName(generalInfo.getMicroServiceName());
|
||||||
List<PollutionLineDTO> list = new ArrayList<>();
|
List<PollutionLineDTO> list = new ArrayList<>();
|
||||||
List<String> line = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
String pollutionType = harmonicPublicParam.getStatisticalType ( ).getId ();
|
String pollutionType = harmonicPublicParam.getStatisticalType ( ).getId ();
|
||||||
String code = harmonicPublicParam.getStatisticalType ( ).getCode ();
|
String code = harmonicPublicParam.getStatisticalType ( ).getCode ();
|
||||||
@@ -360,6 +487,31 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
|||||||
if (StringUtils.isBlank(RequestUtil.getDeptIndex())){
|
if (StringUtils.isBlank(RequestUtil.getDeptIndex())){
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
if (harmonicPublicParam.getType() == 0) {
|
||||||
|
PmsStatationStatInfoParam param=new PmsStatationStatInfoParam();
|
||||||
|
param.setPowerIds(Arrays.asList(harmonicPublicParam.getId()));
|
||||||
|
List<PmsStatationStatInfoDTO> data = statationStatClient.getStatationStatInfo(param).getData();
|
||||||
|
if(CollectionUtil.isNotEmpty(data)){
|
||||||
|
List<String> monitorId = data.stream().map(PmsStatationStatInfoDTO::getMonitorId).collect(Collectors.toList());
|
||||||
|
List<RMpPollutionDPO> lineData = rMpPollutionDPOMapper.selectMaxList ( monitorId,pollutionType,searchBeginTime);
|
||||||
|
Map<String, Double> lineMap = lineData.stream().collect(Collectors.toMap(RMpPollutionDPO::getLineId, RMpPollutionDPO::getValue));
|
||||||
|
PollutionLineDTO dto;
|
||||||
|
for (PmsStatationStatInfoDTO power : data) {
|
||||||
|
dto=new PollutionLineDTO();
|
||||||
|
dto.setId(power.getMonitorId());
|
||||||
|
dto.setName(power.getMonitorName());
|
||||||
|
dto.setPowerCompany(power.getOrgName());
|
||||||
|
dto.setSubstation(power.getPowerName());
|
||||||
|
dto.setSubstationId(power.getPowerId());
|
||||||
|
dto.setBusBar(power.getGeneratrixName());
|
||||||
|
if(lineMap.containsKey(power.getMonitorId())){
|
||||||
|
dto.setData(lineMap.get(power.getMonitorId()));
|
||||||
|
}
|
||||||
|
list.add (dto) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
List<String> line = new ArrayList<>();
|
||||||
List<GeneralDeviceDTO> sub = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(harmonicPublicParam).getData();
|
List<GeneralDeviceDTO> sub = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(harmonicPublicParam).getData();
|
||||||
sub.forEach(item->{
|
sub.forEach(item->{
|
||||||
if (Objects.equals(harmonicPublicParam.getId(),item.getIndex())){
|
if (Objects.equals(harmonicPublicParam.getId(),item.getIndex())){
|
||||||
@@ -381,8 +533,54 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
|
|||||||
} else {
|
} else {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return list.stream().sorted(Comparator.comparing(PollutionLineDTO::getData).reversed().thenComparing(PollutionLineDTO::getName)).collect(Collectors.toList());
|
return list.stream().sorted(Comparator.comparing(PollutionLineDTO::getData).reversed().thenComparing(PollutionLineDTO::getName)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PollutionLineDTO> getLineRank(HarmonicPublicParam param) {
|
||||||
|
String pollutionType = param.getStatisticalType ( ).getId ();
|
||||||
|
String searchBeginTime = "";
|
||||||
|
if(Objects.equals (param.getReportFlag (),BizParamConstant.STAT_BIZ_YEAR) ){
|
||||||
|
searchBeginTime = param.getSearchBeginTime ( ).substring (0, 4)+"%";
|
||||||
|
|
||||||
|
}else if(Objects.equals (param.getReportFlag (),BizParamConstant.STAT_BIZ_MONTH)){
|
||||||
|
searchBeginTime = param.getSearchBeginTime ( ).substring (0, 7)+"%";
|
||||||
|
|
||||||
|
|
||||||
|
}else if(Objects.equals (param.getReportFlag (),BizParamConstant.STAT_BIZ_DAY)) {
|
||||||
|
searchBeginTime = param.getSearchBeginTime ( ).substring (0, 10)+"%";
|
||||||
|
}
|
||||||
|
|
||||||
|
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam();
|
||||||
|
pmsDeviceInfoParam.setDeptIndex(param.getDeptIndex());
|
||||||
|
//获取统计类型
|
||||||
|
pmsDeviceInfoParam.setStatisticalType(param.getStatisticalType());
|
||||||
|
//获取主网台账信息
|
||||||
|
List<PmsGeneralDeviceDTO> deviceList = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam).getData();
|
||||||
|
List<String> monitorIdList=new ArrayList<>();
|
||||||
|
deviceList.forEach(dept -> {
|
||||||
|
monitorIdList.addAll(dept.getMonitorIdList());
|
||||||
|
});
|
||||||
|
|
||||||
|
if(CollectionUtil.isNotEmpty(monitorIdList)){
|
||||||
|
List<RMpPollutionDPO> lineData = rMpPollutionDPOMapper.selectMaxList ( monitorIdList,pollutionType,searchBeginTime);
|
||||||
|
lineData.sort((item1, item2) -> item2.getValue().compareTo(item1.getValue()));
|
||||||
|
if (lineData.size() > Param.UP_LIMIT) {
|
||||||
|
lineData = lineData.subList(Param.DOWN_LIMIT, Param.UP_LIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Monitor> data = monitorClient.getMonitorList(monitorIdList).getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
deviceList.forEach(temp->{
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.njcn.process.pojo.dto.excel;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
|
import com.njcn.device.pq.pojo.constant.DeviceValidMessage;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <功能描述>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @createTime: 2023-02-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TerminalExcel implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
@Excel(name = "终端编号",width = 15)
|
||||||
|
@NotBlank(message = "终端编号不为空")
|
||||||
|
@Pattern(regexp = "^[A-Za-z0-9]{1,32}$", message = "终端编号违规长度不能超过32位(数字 、 字母)")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Excel(name = "终端名称",width = 15)
|
||||||
|
@NotBlank(message = "终端名称不为空")
|
||||||
|
@Pattern(regexp = PatternRegex.DEPT_NAME_REGEX, message = DeviceValidMessage.PROJECT_NAME_RULE)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Excel(name = "组织机构名称",width = 15)
|
||||||
|
@NotBlank(message = "组织机构名称不为空")
|
||||||
|
private String orgName;
|
||||||
|
|
||||||
|
@Excel(name = "生产厂家",width = 15)
|
||||||
|
@NotBlank(message = "生产厂家不为空")
|
||||||
|
private String manufacture;
|
||||||
|
|
||||||
|
@Excel(name = "安装位置")
|
||||||
|
@NotBlank(message = "安装位置不为空")
|
||||||
|
private String installPlace;
|
||||||
|
|
||||||
|
@Excel(name = "送检单位")
|
||||||
|
@NotBlank(message = "送检单位不为空")
|
||||||
|
private String inspectionName;
|
||||||
|
|
||||||
|
@Excel(name = "检测时间",format = "yyyy-MM-dd", width = 15)
|
||||||
|
@NotNull(message = "检测时间不为空")
|
||||||
|
private LocalDate inspectionTime;
|
||||||
|
|
||||||
|
// @Excel(name = "检测结果")
|
||||||
|
// @NotBlank(message = "检测结果不为空")
|
||||||
|
// private String testResults;
|
||||||
|
//
|
||||||
|
// @Excel(name = "下次检测时间",format = "yyyy-MM-dd", width = 15)
|
||||||
|
// @NotNull(message = "下次检测时间不为空")
|
||||||
|
// private LocalDate nextInspectionTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class TerminalExcelMsg extends TerminalExcel implements Serializable {
|
||||||
|
@Excel(name = "错误信息描述", width = 30)
|
||||||
|
private String msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package com.njcn.process.pojo.param;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <功能描述>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @createTime: 2023-02-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TerminalParam {
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("开始时间")
|
||||||
|
@Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误")
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("结束时间")
|
||||||
|
@Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误")
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("单位id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class TerminalPageParam extends TerminalParam{
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "页码")
|
||||||
|
private Integer PageNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "条数")
|
||||||
|
private Integer PageSize;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否周期检测列表")
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class TerminalCycleParam {
|
||||||
|
|
||||||
|
@ApiModelProperty("单位id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "检测结果")
|
||||||
|
private String testResults;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class TerminalUpdateParam {
|
||||||
|
@ApiModelProperty(value = "终端编号")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "终端名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组织机构名称")
|
||||||
|
private String orgName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组织机构ID(外键)")
|
||||||
|
private String orgId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "生产厂家")
|
||||||
|
private String manufacture;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "安装位置")
|
||||||
|
private String installPlace;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "送检单位")
|
||||||
|
private String inspectionName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "检测结果")
|
||||||
|
private String testResults;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "检测时间")
|
||||||
|
private LocalDate inspectionTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "下次检测时间")
|
||||||
|
private LocalDate nextInspectionTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "检测报告")
|
||||||
|
private String inspectionReport;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "原始数据报告")
|
||||||
|
private String originalReport;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package com.njcn.process.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-02-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("pms_terminal_detection")
|
||||||
|
@ApiModel(value="PmsTerminalDetection对象", description="")
|
||||||
|
public class PmsTerminalDetection implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "终端编号")
|
||||||
|
@TableId(value = "Id", type = IdType.ASSIGN_ID)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "终端名称")
|
||||||
|
@TableField("Name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组织机构名称")
|
||||||
|
@TableField("Org_Name")
|
||||||
|
private String orgName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组织机构ID(外键)")
|
||||||
|
@TableField("Org_No")
|
||||||
|
private String orgNo;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "生产厂家(字典)")
|
||||||
|
@TableField("Manufacture")
|
||||||
|
private String manufacture;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "安装位置")
|
||||||
|
private String installPlace;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "送检单位")
|
||||||
|
@TableField("inspection_Name")
|
||||||
|
private String inspectionName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "检测结果(0:未开展 1:已开展)")
|
||||||
|
private Integer testResults;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "检测时间")
|
||||||
|
@TableField("inspection_Time")
|
||||||
|
private LocalDate inspectionTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "下次检测时间")
|
||||||
|
@TableField("next_inspection_Time")
|
||||||
|
private LocalDate nextInspectionTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "检测报告")
|
||||||
|
@TableField("inspection_Report")
|
||||||
|
private String inspectionReport;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "原始数据报告")
|
||||||
|
@TableField("original_Report")
|
||||||
|
private String originalReport;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "数据状态:0-删除;1-正常; ")
|
||||||
|
@TableField("Status")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建用户")
|
||||||
|
@TableField("Create_By")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新用户")
|
||||||
|
@TableField("Update_By")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package com.njcn.process.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <功能描述>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @createTime: 2023-02-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TerminalVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "终端编号")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "终端名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组织机构名称")
|
||||||
|
private String orgName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "组织机构编号")
|
||||||
|
private String orgNO;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "生产厂家")
|
||||||
|
private String manufacture;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "安装位置")
|
||||||
|
private String installPlace;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "送检单位")
|
||||||
|
private String inspectionName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "检测结果")
|
||||||
|
private String testResults;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "检测时间")
|
||||||
|
private LocalDate inspectionTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "下次检测时间")
|
||||||
|
private LocalDate nextInspectionTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "检测报告")
|
||||||
|
private String inspectionReport;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "原始数据报告")
|
||||||
|
private String originalReport;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class TerminalStatistics implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "单位id")
|
||||||
|
private String orgNo;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "单位名称")
|
||||||
|
private String orgName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "统计数量")
|
||||||
|
private Integer count;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
package com.njcn.process.utils;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||||
|
import cn.afterturn.easypoi.excel.entity.params.ExcelForEachParams;
|
||||||
|
import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler;
|
||||||
|
import org.apache.poi.hssf.util.HSSFColor;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pqs
|
||||||
|
*
|
||||||
|
* @author cdf
|
||||||
|
* @date 2022/7/4
|
||||||
|
*/
|
||||||
|
public class ExcelStyleUtil implements IExcelExportStyler {
|
||||||
|
// 数据行类型
|
||||||
|
private static final String DATA_STYLES = "dataStyles";
|
||||||
|
// 标题类型
|
||||||
|
private static final String TITLE_STYLES = "titleStyles";
|
||||||
|
//头样式
|
||||||
|
private static final String HEADER_STYLES = "headerStyles";
|
||||||
|
|
||||||
|
//数据行样式
|
||||||
|
private CellStyle styles;
|
||||||
|
// 标题样式
|
||||||
|
private CellStyle titleStyle;
|
||||||
|
|
||||||
|
// 标题样式
|
||||||
|
private CellStyle headerStyle;
|
||||||
|
|
||||||
|
public ExcelStyleUtil(Workbook workbook) {
|
||||||
|
this.init(workbook);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(Workbook workbook) {
|
||||||
|
this.styles = initStyles(workbook);
|
||||||
|
this.titleStyle = initTitleStyle(workbook);
|
||||||
|
this.headerStyle = initTitleStyle(workbook);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CellStyle getHeaderStyle(short headerColor) {
|
||||||
|
return headerStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题样式
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CellStyle getTitleStyle(short i) {
|
||||||
|
return titleStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CellStyle getStyles(boolean parity, ExcelExportEntity entity) {
|
||||||
|
return styles;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取样式方法
|
||||||
|
*
|
||||||
|
* @param dataRow 数据行
|
||||||
|
* @param obj 对象
|
||||||
|
* @param data 数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CellStyle getStyles(Cell cell, int dataRow, ExcelExportEntity entity, Object obj, Object data) {
|
||||||
|
return getStyles(true, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CellStyle getTemplateStyles(boolean isSingle, ExcelForEachParams excelForEachParams) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化--标题行样式
|
||||||
|
* @param workbook
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private CellStyle initTitleStyle(Workbook workbook) {
|
||||||
|
return buildCellStyle(workbook,TITLE_STYLES);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头样式
|
||||||
|
* @author cdf
|
||||||
|
* @date 2022/7/4
|
||||||
|
*/
|
||||||
|
private CellStyle initHeaderStyle(Workbook workbook) {
|
||||||
|
return buildCellStyle(workbook,HEADER_STYLES);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化--数据行样式
|
||||||
|
* @param workbook
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private CellStyle initStyles(Workbook workbook) {
|
||||||
|
return buildCellStyle(workbook,DATA_STYLES);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置单元格样式
|
||||||
|
* @param workbook
|
||||||
|
* @param type 类型 用来区分是数据行样式还是标题样式
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private CellStyle buildCellStyle(Workbook workbook,String type) {
|
||||||
|
CellStyle style = workbook.createCellStyle();
|
||||||
|
// 字体样式
|
||||||
|
Font font = workbook.createFont();
|
||||||
|
if(TITLE_STYLES.equals(type)){
|
||||||
|
font.setFontHeightInPoints((short)12);
|
||||||
|
font.setBold(true);
|
||||||
|
// 设置水平对齐的样式为居中对齐;
|
||||||
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
}
|
||||||
|
if(HEADER_STYLES.equals(type)){
|
||||||
|
font.setFontHeightInPoints((short)12);
|
||||||
|
font.setBold(true);
|
||||||
|
// 设置水平对齐的样式为居中对齐;
|
||||||
|
style.setAlignment(HorizontalAlignment.LEFT);
|
||||||
|
}
|
||||||
|
if(DATA_STYLES.equals(type)){
|
||||||
|
font.setFontHeightInPoints((short)10);
|
||||||
|
// 设置水平对齐的样式为居中对齐;
|
||||||
|
style.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
}
|
||||||
|
font.setFontName("Courier New");
|
||||||
|
style.setFont(font);
|
||||||
|
// 设置底边框
|
||||||
|
style.setBorderBottom(BorderStyle.THIN);
|
||||||
|
// 设置左边框
|
||||||
|
style.setBorderLeft(BorderStyle.THIN);
|
||||||
|
// 设置右边框;
|
||||||
|
style.setBorderRight(BorderStyle.THIN);
|
||||||
|
// 设置顶边框;
|
||||||
|
style.setBorderTop(BorderStyle.THIN);
|
||||||
|
// 设置底边颜色
|
||||||
|
style.setBottomBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||||
|
// 设置左边框颜色;
|
||||||
|
style.setLeftBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||||
|
// 设置右边框颜色;
|
||||||
|
style.setRightBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||||
|
// 设置顶边框颜色;
|
||||||
|
style.setTopBorderColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex());
|
||||||
|
// 设置自动换行;
|
||||||
|
style.setWrapText(false);
|
||||||
|
|
||||||
|
|
||||||
|
// 设置垂直对齐的样式为居中对齐;
|
||||||
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package com.njcn.process.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
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.process.pojo.param.TerminalParam;
|
||||||
|
import com.njcn.process.pojo.vo.TerminalVO;
|
||||||
|
import com.njcn.process.service.PmsTerminalDetectionService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 终端检测监督
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-02-27
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/process/pmsTerminalDetection")
|
||||||
|
@Api(tags = "终端检测监督管理")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PmsTerminalDetectionController extends BaseController {
|
||||||
|
private final PmsTerminalDetectionService pmsTerminalDetectionService;
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/getTerminalPage")
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@ApiOperation("终端检测监督管理分页查询")
|
||||||
|
public HttpResult<Page<TerminalVO>> getPage(@RequestBody TerminalParam.TerminalPageParam param) {
|
||||||
|
String methodDescribe = getMethodDescribe("getTerminalPage");
|
||||||
|
Page<TerminalVO> page = pmsTerminalDetectionService.terminalPage(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "导出终端入网检测录入模板")
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/export")
|
||||||
|
public void export(HttpServletResponse response) {
|
||||||
|
pmsTerminalDetectionService.exportTemplate(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/importTerminal")
|
||||||
|
@ApiOperation("excel批量导入终端入网检测录入")
|
||||||
|
@ResponseBody
|
||||||
|
public HttpResult<String> importTerminalBase(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
|
||||||
|
String methodDescribe = getMethodDescribe("importTerminal");
|
||||||
|
pmsTerminalDetectionService.batchTerminal(file, response);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@ApiOperation("批量导入检测报告")
|
||||||
|
@PostMapping(value = "/importReport")
|
||||||
|
public HttpResult<String> importReport(@ApiParam(value = "文件", required = true) @RequestPart("files") MultipartFile[] files, HttpServletResponse response) {
|
||||||
|
String methodDescribe = getMethodDescribe("importReport");
|
||||||
|
pmsTerminalDetectionService.importReport(files, response);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getStatistics")
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@ApiOperation("终端入网检测台账统计")
|
||||||
|
public HttpResult<List<TerminalVO.TerminalStatistics>> getStatistics(@RequestBody TerminalParam param) {
|
||||||
|
String methodDescribe = getMethodDescribe("getStatistics");
|
||||||
|
List<TerminalVO.TerminalStatistics> list = pmsTerminalDetectionService.getStatistics(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getCycleStatistics")
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@ApiOperation("周期检测统计")
|
||||||
|
public HttpResult<List<TerminalVO.TerminalStatistics>> getCycleStatistics(@RequestBody TerminalParam.TerminalCycleParam param) {
|
||||||
|
String methodDescribe = getMethodDescribe("getCycleStatistics");
|
||||||
|
List<TerminalVO.TerminalStatistics> list = pmsTerminalDetectionService.getCycleStatistics(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.njcn.process.mapper;
|
||||||
|
|
||||||
|
import com.njcn.process.pojo.param.TerminalParam;
|
||||||
|
import com.njcn.process.pojo.po.PmsTerminalDetection;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.process.pojo.vo.TerminalVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-02-27
|
||||||
|
*/
|
||||||
|
public interface PmsTerminalDetectionMapper extends BaseMapper<PmsTerminalDetection> {
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 终端入网检测台账统计
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-28 11:14
|
||||||
|
* @param param
|
||||||
|
* @param ids
|
||||||
|
* @return List<TerminalStatistics>
|
||||||
|
*/
|
||||||
|
List<TerminalVO.TerminalStatistics> selectStatistics(@Param("param") TerminalParam param,
|
||||||
|
@Param("ids") List<String> ids);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 周期检测统计
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-28 11:14
|
||||||
|
* @param param
|
||||||
|
* @param ids
|
||||||
|
* @return List<TerminalStatistics>
|
||||||
|
*/
|
||||||
|
List<TerminalVO.TerminalStatistics> selectCycleStatistics(@Param("param") TerminalParam.TerminalCycleParam param,
|
||||||
|
@Param("ids") List<String> ids);
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?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.process.mapper.PmsTerminalDetectionMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="com.njcn.process.pojo.po.PmsTerminalDetection">
|
||||||
|
<id column="Id" property="id" />
|
||||||
|
<result column="Create_Time" property="createTime" />
|
||||||
|
<result column="Update_Time" property="updateTime" />
|
||||||
|
<result column="Name" property="name" />
|
||||||
|
<result column="Org_Name" property="orgName" />
|
||||||
|
<result column="Org_No" property="orgNo" />
|
||||||
|
<result column="Manufacture" property="manufacture" />
|
||||||
|
<result column="Install_place" property="installPlace" />
|
||||||
|
<result column="Inspection_Name" property="inspectionName" />
|
||||||
|
<result column="Test_results" property="testResults" />
|
||||||
|
<result column="Inspection_Time" property="inspectionTime" />
|
||||||
|
<result column="Next_inspection_Time" property="nextInspectionTime" />
|
||||||
|
<result column="Inspection_Report" property="inspectionReport" />
|
||||||
|
<result column="Original_Report" property="originalReport" />
|
||||||
|
<result column="Status" property="status" />
|
||||||
|
<result column="Create_By" property="createBy" />
|
||||||
|
<result column="Update_By" property="updateBy" />
|
||||||
|
</resultMap>
|
||||||
|
<select id="selectStatistics" resultType="com.njcn.process.pojo.vo.TerminalVO$TerminalStatistics">
|
||||||
|
SELECT
|
||||||
|
Org_No,
|
||||||
|
count( id ) AS count
|
||||||
|
FROM
|
||||||
|
pms_terminal_detection
|
||||||
|
<where>
|
||||||
|
<if test="ids != null and ids.size > 0">
|
||||||
|
AND org_no IN
|
||||||
|
<foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="param!=null and param.startTime != null and param.startTime !=''">
|
||||||
|
AND data_date >= #{param.startTime}
|
||||||
|
</if>
|
||||||
|
<if test="param!=null and param.endTime != null and param.endTime != ''">
|
||||||
|
AND data_date <= #{param.endTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY
|
||||||
|
Org_No
|
||||||
|
</select>
|
||||||
|
<select id="selectCycleStatistics" resultType="com.njcn.process.pojo.vo.TerminalVO$TerminalStatistics">
|
||||||
|
SELECT
|
||||||
|
Org_No,
|
||||||
|
count( id ) AS count
|
||||||
|
FROM
|
||||||
|
pms_terminal_detection
|
||||||
|
<where>
|
||||||
|
Next_inspection_Time <= DATE_FORMAT( now(), '%Y-%m-%d' )
|
||||||
|
<if test="ids != null and ids.size > 0">
|
||||||
|
AND org_no IN
|
||||||
|
<foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="param!=null and param.testResults != null and param.testResults !=''">
|
||||||
|
AND Test_results = #{param.testResults}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY
|
||||||
|
Org_No
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package com.njcn.process.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.process.pojo.param.TerminalParam;
|
||||||
|
import com.njcn.process.pojo.po.PmsTerminalDetection;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.process.pojo.vo.TerminalVO;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 终端检测监督
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-02-27
|
||||||
|
*/
|
||||||
|
public interface PmsTerminalDetectionService extends IService<PmsTerminalDetection> {
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 终端检测监督列表
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-27 13:58
|
||||||
|
* @param param
|
||||||
|
* @return Page<?>
|
||||||
|
*/
|
||||||
|
Page<TerminalVO> terminalPage(TerminalParam.TerminalPageParam param);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 导出模板
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-27 16:14
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
void exportTemplate(HttpServletResponse response);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 终端检测监督单条新增
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-27 14:02
|
||||||
|
* @param param
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
Boolean insertTerminal(TerminalParam param);
|
||||||
|
/***
|
||||||
|
* 终端检测监督批量新增
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-27 14:02
|
||||||
|
* @param file
|
||||||
|
* @param response
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
void batchTerminal(MultipartFile file, HttpServletResponse response);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 终端检测监督修改
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-27 14:02
|
||||||
|
* @param param
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
Boolean updateTerminal(TerminalParam.TerminalUpdateParam param);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 终端检测监督删除
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-27 14:02
|
||||||
|
* @param ids
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
Boolean dekTerminal(List<String> ids);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 批量导入检测报告
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-28 9:55
|
||||||
|
* @param files
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
void importReport(MultipartFile[] files, HttpServletResponse response);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 终端入网检测台账统计
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-28 11:03
|
||||||
|
* @param param
|
||||||
|
* @return List<TerminalStatistics>
|
||||||
|
*/
|
||||||
|
List<TerminalVO.TerminalStatistics> getStatistics(TerminalParam param);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 周期检测统计
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-28 13:48
|
||||||
|
* @param param
|
||||||
|
* @return List<TerminalStatistics>
|
||||||
|
*/
|
||||||
|
List<TerminalVO.TerminalStatistics> getCycleStatistics(TerminalParam.TerminalCycleParam param);
|
||||||
|
}
|
||||||
@@ -0,0 +1,289 @@
|
|||||||
|
package com.njcn.process.service.impl;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||||
|
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.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.device.pms.enums.PmsDeviceResponseEnum;
|
||||||
|
import com.njcn.poi.excel.ExcelUtil;
|
||||||
|
import com.njcn.poi.util.PoiUtil;
|
||||||
|
import com.njcn.process.pojo.dto.excel.TerminalExcel;
|
||||||
|
import com.njcn.process.pojo.param.TerminalParam;
|
||||||
|
import com.njcn.process.pojo.po.PmsTerminalDetection;
|
||||||
|
import com.njcn.process.mapper.PmsTerminalDetectionMapper;
|
||||||
|
import com.njcn.process.pojo.vo.TerminalVO;
|
||||||
|
import com.njcn.process.service.PmsTerminalDetectionService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.process.utils.ExcelStyleUtil;
|
||||||
|
import com.njcn.user.api.DeptFeignClient;
|
||||||
|
import com.njcn.user.pojo.dto.DeptDTO;
|
||||||
|
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 终端检测监督
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2023-02-27
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PmsTerminalDetectionServiceImpl extends ServiceImpl<PmsTerminalDetectionMapper, PmsTerminalDetection> implements PmsTerminalDetectionService {
|
||||||
|
|
||||||
|
private final DeptFeignClient deptFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<TerminalVO> terminalPage(TerminalParam.TerminalPageParam param) {
|
||||||
|
Page<PmsTerminalDetection> pageList = this.page(new Page<>(param.getPageNum(), param.getPageSize())
|
||||||
|
, new LambdaQueryWrapper<PmsTerminalDetection>()
|
||||||
|
.eq(PmsTerminalDetection::getStatus, DataStateEnum.ENABLE.getCode())
|
||||||
|
// .in(RMpWpPowerDetailQ::getMeasurementPointId, monitorIds)
|
||||||
|
.le(param.getType() != 0, PmsTerminalDetection::getNextInspectionTime, LocalDate.now())
|
||||||
|
// .le(StrUtil.isNotBlank(param.getEndTime()), PmsTerminalDetection::getDataDate, param.getEndTime())
|
||||||
|
);
|
||||||
|
List<TerminalVO> rMpWpPowerDetailVOS2 = BeanUtil.copyToList(pageList.getRecords(), TerminalVO.class);
|
||||||
|
|
||||||
|
Page<TerminalVO> page = BeanUtil.copyProperties(pageList, Page.class);
|
||||||
|
page.setRecords(rMpWpPowerDetailVOS2);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exportTemplate(HttpServletResponse response) {
|
||||||
|
ExportParams exportParams = new ExportParams("批量导入模板(请严格按照模板标准填入数据)", "终端入网检测录入信息");
|
||||||
|
exportParams.setStyle(ExcelStyleUtil.class);
|
||||||
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, TerminalExcel.class, new ArrayList<TerminalExcel>());
|
||||||
|
PoiUtil.exportFileByWorkbook(workbook, "终端入网检测录入模板.xlsx", response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean insertTerminal(TerminalParam param) {
|
||||||
|
PmsTerminalDetection detection = BeanUtil.copyProperties(param, PmsTerminalDetection.class);
|
||||||
|
|
||||||
|
return this.save(detection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void batchTerminal(MultipartFile file, HttpServletResponse response) {
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setHeadRows(1);
|
||||||
|
params.setTitleRows(1);
|
||||||
|
params.setNeedVerify(true);
|
||||||
|
//第一个sheet为台账信息
|
||||||
|
params.setStartSheetIndex(0);
|
||||||
|
params.setSheetNum(1);
|
||||||
|
try {
|
||||||
|
ExcelImportResult<TerminalExcel> terminalList = ExcelImportUtil.importExcelMore(file.getInputStream(), TerminalExcel.class, params);
|
||||||
|
//如果存在非法数据,将不合格的数据导出
|
||||||
|
if (terminalList.isVerifyFail()) {
|
||||||
|
PoiUtil.exportFileByWorkbook(terminalList.getFailWorkbook(), "非法终端入网检测录入信息.xlsx", response);
|
||||||
|
} else {
|
||||||
|
saveTerminalBase(terminalList.getList());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean updateTerminal(TerminalParam.TerminalUpdateParam param) {
|
||||||
|
long count = this.count(new LambdaQueryWrapper<PmsTerminalDetection>()
|
||||||
|
.ne(PmsTerminalDetection::getId, param.getId())
|
||||||
|
.and(wrapper ->
|
||||||
|
wrapper.eq(PmsTerminalDetection::getName, param.getName())
|
||||||
|
)
|
||||||
|
|
||||||
|
);
|
||||||
|
if (count > 0) {
|
||||||
|
throw new BusinessException(PmsDeviceResponseEnum.MODEL_NAME_REPEAT);
|
||||||
|
}
|
||||||
|
PmsTerminalDetection detection = BeanUtil.copyProperties(param, PmsTerminalDetection.class);
|
||||||
|
return this.updateById(detection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean dekTerminal(List<String> ids) {
|
||||||
|
return this.removeByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void importReport(MultipartFile[] files, HttpServletResponse response) {
|
||||||
|
PmsTerminalDetection detection;
|
||||||
|
List<PmsTerminalDetection> data = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
detection = new PmsTerminalDetection();
|
||||||
|
//上传的文件名称
|
||||||
|
String originalFilename = files[i].getOriginalFilename();
|
||||||
|
String[] split = originalFilename.split("-");
|
||||||
|
if (split.length > 0) {
|
||||||
|
if (split[1].substring(0, split[1].indexOf(".")).equals("检测报告")) {
|
||||||
|
//todo 文件名称
|
||||||
|
detection.setInspectionReport(originalFilename);
|
||||||
|
detection.setId(split[0]);
|
||||||
|
data.add(detection);
|
||||||
|
}
|
||||||
|
if (split[1].substring(0, split[1].indexOf(".")).equals("原始数据报告")) {
|
||||||
|
//todo 文件名称
|
||||||
|
detection.setOriginalReport(originalFilename);
|
||||||
|
detection.setId(split[0]);
|
||||||
|
data.add(detection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(data)) {
|
||||||
|
Map<String, PmsTerminalDetection> terminalMap = data.stream().collect(Collectors.toMap(PmsTerminalDetection::getId, Function.identity(), (key1, key2) -> {
|
||||||
|
//检测报告告为空
|
||||||
|
if (key1.getInspectionReport() == null) {
|
||||||
|
key1.setInspectionReport(key2.getInspectionReport());
|
||||||
|
}
|
||||||
|
//原始数据报告为空
|
||||||
|
if (key1.getOriginalReport() == null) {
|
||||||
|
key1.setOriginalReport(key2.getOriginalReport());
|
||||||
|
}
|
||||||
|
return key1;
|
||||||
|
}));
|
||||||
|
List<PmsTerminalDetection> updateTerminal = new ArrayList<>(terminalMap.values());
|
||||||
|
this.updateBatchById(updateTerminal);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TerminalVO.TerminalStatistics> getStatistics(TerminalParam param) {
|
||||||
|
List<DeptDTO> deptDTOS = deptFeignClient.getDepSonDetailByDeptId(param.getId()).getData();
|
||||||
|
List<String> ids = deptDTOS.stream().map(DeptDTO::getCode).collect(Collectors.toList());
|
||||||
|
List<TerminalVO.TerminalStatistics> list = this.baseMapper.selectStatistics(param, ids);
|
||||||
|
return getStatisticsList(deptDTOS, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TerminalVO.TerminalStatistics> getCycleStatistics(TerminalParam.TerminalCycleParam param) {
|
||||||
|
List<DeptDTO> deptDTOS = deptFeignClient.getDepSonDetailByDeptId(param.getId()).getData();
|
||||||
|
List<String> ids = deptDTOS.stream().map(DeptDTO::getCode).collect(Collectors.toList());
|
||||||
|
List<TerminalVO.TerminalStatistics> list = this.baseMapper.selectCycleStatistics(param, ids);
|
||||||
|
return getStatisticsList(deptDTOS, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 统计数据,单位名称赋值
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-28 14:04
|
||||||
|
* @param deptDTOS
|
||||||
|
* @param list
|
||||||
|
* @return List<TerminalStatistics>
|
||||||
|
*/
|
||||||
|
private List<TerminalVO.TerminalStatistics> getStatisticsList(List<DeptDTO> deptDTOS, List<TerminalVO.TerminalStatistics> list) {
|
||||||
|
Map<String, String> deptMap = deptDTOS.stream().collect(Collectors.toMap(DeptDTO::getCode, DeptDTO::getName));
|
||||||
|
for (TerminalVO.TerminalStatistics t : list) {
|
||||||
|
if (deptMap.containsKey(t.getOrgNo())) {
|
||||||
|
t.setOrgName(deptMap.get(t.getOrgNo()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, TerminalVO.TerminalStatistics> listMap = list.stream().collect(
|
||||||
|
Collectors.toMap(TerminalVO.TerminalStatistics::getOrgNo, Function.identity()));
|
||||||
|
|
||||||
|
List<DeptDTO> notDeptDTOS = deptDTOS.stream().filter(r -> !listMap.containsKey(r.getCode()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(notDeptDTOS)) {
|
||||||
|
TerminalVO.TerminalStatistics notTerminal;
|
||||||
|
for (DeptDTO notDeptDTO : notDeptDTOS) {
|
||||||
|
notTerminal = new TerminalVO.TerminalStatistics();
|
||||||
|
notTerminal.setOrgNo(notDeptDTO.getCode());
|
||||||
|
notTerminal.setOrgName(notDeptDTO.getName());
|
||||||
|
notTerminal.setCount(0);
|
||||||
|
list.add(notTerminal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 批量导入t终端入网检测信息
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-28 14:05
|
||||||
|
* @param terminalList
|
||||||
|
*/
|
||||||
|
private void saveTerminalBase(List<TerminalExcel> terminalList) {
|
||||||
|
List<PvTerminalTreeVO> data = deptFeignClient.allDeptList().getData();
|
||||||
|
List<PmsTerminalDetection> list = this.list(new LambdaQueryWrapper<PmsTerminalDetection>()
|
||||||
|
.eq(PmsTerminalDetection::getStatus, DataStateEnum.ENABLE.getCode()));
|
||||||
|
Map<String, PmsTerminalDetection> terminalMap = list.stream().collect(Collectors.toMap(p -> p.getId(), Function.identity()));
|
||||||
|
List<TerminalExcel.TerminalExcelMsg> terminalExcelMsg = new ArrayList<>();
|
||||||
|
//错误数据初始化
|
||||||
|
TerminalExcel.TerminalExcelMsg msg = null;
|
||||||
|
List<PmsTerminalDetection> pmsTerminalDetections = new ArrayList<>();
|
||||||
|
//正常数据
|
||||||
|
PmsTerminalDetection detection;
|
||||||
|
for (TerminalExcel terminalExcel : terminalList) {
|
||||||
|
//根据终端编号和终端名称判断数据是否又重复终端
|
||||||
|
if (terminalMap.containsKey(terminalExcel.getId())) {
|
||||||
|
addMsg(terminalExcelMsg, terminalExcel, msg, "当前终端编号重复");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String orgName = terminalExcel.getOrgName();
|
||||||
|
//判断
|
||||||
|
List<PvTerminalTreeVO> deptList = data.stream().filter(d ->
|
||||||
|
d.getName().indexOf(orgName) > -1
|
||||||
|
).collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isEmpty(deptList)) {
|
||||||
|
addMsg(terminalExcelMsg, terminalExcel, msg, "当前部门机构不存在");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (deptList.size() > 1) {
|
||||||
|
addMsg(terminalExcelMsg, terminalExcel, msg, "当前部门机构模糊匹配出现多个部门,请详细编写部门机构");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
detection = BeanUtil.copyProperties(terminalExcel, PmsTerminalDetection.class);
|
||||||
|
detection.setOrgNo(deptList.get(0).getCode());
|
||||||
|
detection.setOrgName(deptList.get(0).getName());
|
||||||
|
detection.setTestResults(0);
|
||||||
|
detection.setStatus(1);
|
||||||
|
pmsTerminalDetections.add(detection);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.saveBatch(pmsTerminalDetections);
|
||||||
|
|
||||||
|
//错误信息不为空,则以excel的形式输出到前台
|
||||||
|
if (CollectionUtil.isNotEmpty(terminalExcelMsg)) {
|
||||||
|
ExcelUtil.exportExcel("失败列表.xlsx", TerminalExcel.TerminalExcelMsg.class, terminalExcelMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 错误信息,赋值
|
||||||
|
* @author wr
|
||||||
|
* @date 2023-02-28 14:05
|
||||||
|
* @param terminalExcelMsg
|
||||||
|
* @param terminalExcel
|
||||||
|
* @param msg
|
||||||
|
* @param content
|
||||||
|
*/
|
||||||
|
private void addMsg(List<TerminalExcel.TerminalExcelMsg> terminalExcelMsg, TerminalExcel terminalExcel, TerminalExcel.TerminalExcelMsg msg, String content) {
|
||||||
|
msg = BeanUtil.copyProperties(terminalExcel, TerminalExcel.TerminalExcelMsg.class);
|
||||||
|
msg.setMsg(content);
|
||||||
|
terminalExcelMsg.add(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user