代码更新

This commit is contained in:
2022-09-07 15:01:12 +08:00
parent 8dda0820d5
commit 56182aa79c
35 changed files with 704 additions and 283 deletions

View File

@@ -309,7 +309,7 @@ public class InfluxDBResultMapperCn {
if (String.class.isAssignableFrom(fieldType)) { if (String.class.isAssignableFrom(fieldType)) {
if("timeId".equals(field.getName()) || "time".equals(field.getName())){ if("timeId".equals(field.getName()) || "time".equals(field.getName())){
LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.from(DateTimeFormatter.ISO_DATE_TIME.parse(String.valueOf(value))), ZoneId.systemDefault()); LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.from(DateTimeFormatter.ISO_DATE_TIME.parse(String.valueOf(value))), ZoneId.systemDefault());
String time = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); String time = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
field.set(object,time); field.set(object,time);
}else { }else {
field.set(object, String.valueOf(value)); field.set(object, String.valueOf(value));

View File

@@ -1,16 +1,20 @@
package com.njcn.influxdb.utils; package com.njcn.influxdb.utils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
/** /**
* pqs * pqs
* * 传入终端id集合返回influxdb使用sql
* @author cdf * @author cdf
* @date 2022/7/1 * @date 2022/7/1
*/ */
@Component @Component
@Validated
public class InfluxDBCommUtils { public class InfluxDBCommUtils {
/** /**
@@ -19,7 +23,7 @@ public class InfluxDBCommUtils {
* @param lineIds 监测点参数 * @param lineIds 监测点参数
* @return StringBuilder * @return StringBuilder
*/ */
public static StringBuilder assToInfluxParam(List<String> lineIds){ public static StringBuilder assToInfluxParam(@NotEmpty List<String> lineIds){
StringBuilder lineIdsStr = new StringBuilder("("); StringBuilder lineIdsStr = new StringBuilder("(");
for (int i = 0; i < lineIds.size(); i++) { for (int i = 0; i < lineIds.size(); i++) {
if (lineIds.size() - i != 1) { if (lineIds.size() - i != 1) {
@@ -30,4 +34,23 @@ public class InfluxDBCommUtils {
} }
return lineIdsStr; return lineIdsStr;
} }
/**
* 组装为influxdb监测点参数
*
* @param devIds 设备ids参数
* @return StringBuilder
*/
public static StringBuilder assToInfluxParamDev(@NotEmpty List<String> devIds){
StringBuilder lineIdsStr = new StringBuilder("(");
for (int i = 0; i < devIds.size(); i++) {
if (devIds.size() - i != 1) {
lineIdsStr.append("dev_id ='").append(devIds.get(i)).append("' or ");
} else {
lineIdsStr.append("dev_id ='").append(devIds.get(i)).append("') ");
}
}
return lineIdsStr;
}
} }

View File

@@ -1,3 +1,4 @@
/*
package com.njcn.microservice.compent; package com.njcn.microservice.compent;
import com.alibaba.cloud.nacos.NacosDiscoveryProperties; import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
@@ -12,9 +13,11 @@ import com.netflix.loadbalancer.Server;
import javax.annotation.Resource; import javax.annotation.Resource;
*/
/** /**
* 自定义负载均衡算法 * 自定义负载均衡算法
*/ *//*
public class NacosWeightLoadBalanceRule extends AbstractLoadBalancerRule { public class NacosWeightLoadBalanceRule extends AbstractLoadBalancerRule {
@Override @Override
@@ -38,4 +41,4 @@ public class NacosWeightLoadBalanceRule extends AbstractLoadBalancerRule {
} }
return null; return null;
} }
} }*/

View File

@@ -1,3 +1,4 @@
/*
package com.njcn.microservice.config; package com.njcn.microservice.config;
import com.netflix.loadbalancer.IRule; import com.netflix.loadbalancer.IRule;
@@ -5,11 +6,13 @@ import com.njcn.microservice.compent.NacosWeightLoadBalanceRule;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
*/
/** /**
* @author hongawen * @author hongawen
* @version 1.0.0 * @version 1.0.0
* @date 2022年08月25日 19:53 * @date 2022年08月25日 19:53
*/ *//*
@Configuration @Configuration
public class RibbonConfig { public class RibbonConfig {
@@ -20,3 +23,4 @@ public class RibbonConfig {
} }
*/

View File

@@ -136,6 +136,9 @@ public class DeviceInfoParam implements Serializable {
@Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误") @Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误")
private String searchEndTime; private String searchEndTime;
@ApiModelProperty("时间范围标志 0.查询展示天 1.查询展示月")
private Integer timeFlag;
} }
@Data @Data
@@ -152,20 +155,5 @@ public class DeviceInfoParam implements Serializable {
} }
@Data
@EqualsAndHashCode(callSuper = true)
public static class ConditionBusinessParam extends BusinessParam{
/**
* 0-年份
* 1-月份
* 2-天
*/
@ApiModelProperty("时间间隔标识0:按月查 1:按天查 2:查询当日)")
@Range(min = 0, max = 2, message = "时间间隔标识" + ValidMessage.PARAM_FORMAT_ERROR)
private int timeFlag;
}
} }

View File

@@ -26,7 +26,6 @@ import java.util.List;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel @ApiModel
@NoArgsConstructor
public class RunManageParam extends BaseParam implements Serializable { public class RunManageParam extends BaseParam implements Serializable {
@ApiModelProperty(name = "statisticalType", value = "统计类型") @ApiModelProperty(name = "statisticalType", value = "统计类型")
@@ -38,6 +37,7 @@ public class RunManageParam extends BaseParam implements Serializable {
private String deptIndex; private String deptIndex;
@ApiModelProperty(name = "serverName", value = "服务名称") @ApiModelProperty(name = "serverName", value = "服务名称")
@NotBlank(message = "服务名称不可为空")
private String serverName; private String serverName;
@ApiModelProperty(name = "scale", value = "电压等级") @ApiModelProperty(name = "scale", value = "电压等级")
@@ -56,7 +56,7 @@ public class RunManageParam extends BaseParam implements Serializable {
*/ */
@ApiModelProperty("网公司标识") @ApiModelProperty("网公司标识")
@Range(min = 0, max = 2, message = "网公司标识" + ValidMessage.PARAM_FORMAT_ERROR) @Range(min = 0, max = 2, message = "网公司标识" + ValidMessage.PARAM_FORMAT_ERROR)
private int monitorFlag; private Integer monitorFlag;
/** /**
* 0-电网侧 * 0-电网侧
@@ -64,14 +64,12 @@ public class RunManageParam extends BaseParam implements Serializable {
*/ */
@ApiModelProperty("电网侧标识") @ApiModelProperty("电网侧标识")
@Range(min = 0, max = 2, message = "电网侧标识" + ValidMessage.PARAM_FORMAT_ERROR) @Range(min = 0, max = 2, message = "电网侧标识" + ValidMessage.PARAM_FORMAT_ERROR)
private int powerFlag; private Integer powerFlag;
@ApiModelProperty(name = "comFlag", value = "通讯状态") @ApiModelProperty(name = "comFlag", value = "通讯状态")
@NotNull(message = "通讯状态不可为空")
private List<Integer> comFlag; private List<Integer> comFlag;
@ApiModelProperty(name = "runFlag", value = "终端状态") @ApiModelProperty(name = "runFlag", value = "终端状态")
@NotNull(message = "终端状态不可为空")
private List<Integer> runFlag; private List<Integer> runFlag;
} }

View File

@@ -26,6 +26,9 @@ public class AreaLineInfoVO implements Serializable {
@ApiModelProperty(name = "subName",value = "变电站名称") @ApiModelProperty(name = "subName",value = "变电站名称")
private String subName; private String subName;
@ApiModelProperty(name = "subScale",value = "变电站电压等级")
private String subScale;
@ApiModelProperty(name = "gdId",value = "供电公司id") @ApiModelProperty(name = "gdId",value = "供电公司id")
private String gdId; private String gdId;

View File

@@ -17,7 +17,7 @@ public class LineInfluxDbOnlineVO implements Serializable {
@Column(name = "dev_id") @Column(name = "dev_id")
private String devIndex; private String devIndex;
@Column(name = "onlinerate") @Column(name = "online_rate")
private Double onlineRate; private Double onlineRate;

View File

@@ -59,5 +59,5 @@ public class RunTimeVO implements Serializable {
private String updateTime; private String updateTime;
@ApiModelProperty(name = "onlineEvaluate",value = "在线率评价") @ApiModelProperty(name = "onlineEvaluate",value = "在线率评价")
private Float onlineEvaluate; private Double onlineEvaluate;
} }

View File

@@ -101,7 +101,7 @@ public class OperationContrController extends BaseController {
@PostMapping("/getComunicateStatics") @PostMapping("/getComunicateStatics")
@ApiOperation("获取中断异常统计") @ApiOperation("获取中断异常统计")
@ApiImplicitParam(name = "conditionBusinessParam", value = "实体", required = true) @ApiImplicitParam(name = "conditionBusinessParam", value = "实体", required = true)
public HttpResult<DeviceAbnormalVO> getComunicateStatics(@RequestBody @Validated DeviceInfoParam.ConditionBusinessParam conditionBusinessParam) { public HttpResult<DeviceAbnormalVO> getComunicateStatics(@RequestBody @Validated DeviceInfoParam.BusinessParam conditionBusinessParam) {
String methodDescribe = getMethodDescribe("getComunicateStatics"); String methodDescribe = getMethodDescribe("getComunicateStatics");
DeviceAbnormalVO result = lineService.getComunicateStatics(conditionBusinessParam); DeviceAbnormalVO result = lineService.getComunicateStatics(conditionBusinessParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);

View File

@@ -1,5 +1,6 @@
package com.njcn.device.controller; package com.njcn.device.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
@@ -44,10 +45,10 @@ public class RunManageController extends BaseController {
@PostMapping("/getLineLedger") @PostMapping("/getLineLedger")
@ApiOperation("监测点台账信息") @ApiOperation("监测点台账信息")
@ApiImplicitParam(name = "runManageParam", value = "监测点台账参数", required = true) @ApiImplicitParam(name = "runManageParam", value = "监测点台账参数", required = true)
public HttpResult<List<RunManageVO>> getLineLedger(@RequestBody @Validated RunManageParam runManageParam) { public HttpResult<Page<RunManageVO>> getLineLedger(@RequestBody @Validated RunManageParam runManageParam) {
String methodDescribe = getMethodDescribe("getLineLedger"); String methodDescribe = getMethodDescribe("getLineLedger");
List<RunManageVO> result = runManageService.getLineLedger(runManageParam); Page<RunManageVO> res = runManageService.getLineLedger(runManageParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)

View File

@@ -2,6 +2,7 @@ package com.njcn.device.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.device.pojo.po.Device; import com.njcn.device.pojo.po.Device;
import com.njcn.device.pojo.vo.RunManageVO; import com.njcn.device.pojo.vo.RunManageVO;
import com.njcn.device.pojo.vo.RunTimeVO; import com.njcn.device.pojo.vo.RunTimeVO;
@@ -34,7 +35,7 @@ public interface DeviceMapper extends BaseMapper<Device> {
* @param runFlag 状态 * @param runFlag 状态
* @return 结果 * @return 结果
*/ */
List<RunManageVO> getRunManageList(@Param("list") List<String> list, @Param("comFlag")List<Integer> comFlag, @Param("runFlag")List<Integer> runFlag); Page<RunManageVO> getRunManageList(@Param("page") Page<RunManageVO> page, @Param("list") List<String> list, @Param("comFlag")List<Integer> comFlag, @Param("runFlag")List<Integer> runFlag);
/** /**
* 获取监测点台账信息 * 获取监测点台账信息

View File

@@ -143,21 +143,21 @@
INNER JOIN pq_line sub ON sub.Id = dev.Pid INNER JOIN pq_line sub ON sub.Id = dev.Pid
INNER JOIN pq_line gd ON gd.Id = sub.Pid INNER JOIN pq_line gd ON gd.Id = sub.Pid
INNER JOIN pq_line areaId ON areaId.Id = gd.Pid INNER JOIN pq_line areaId ON areaId.Id = gd.Pid
INNER JOIN sys_area area ON area.Id = areaId. INNER JOIN sys_area area ON area.Id = areaId.NAME
NAME INNER JOIN pq_device device ON device.Id = dev.Id INNER JOIN pq_device device ON device.Id = dev.Id
INNER JOIN sys_dict_data manufacturerId ON manufacturerId.Id = device.Manufacturer INNER JOIN sys_dict_data manufacturerId ON manufacturerId.Id = device.Manufacturer
INNER JOIN sys_dict_data devT ON devT.Id = device.Dev_Type INNER JOIN sys_dict_data devT ON devT.Id = device.Dev_Type
WHERE dev.Id in WHERE dev.Id in
<foreach item="item" collection="list" open="(" separator="," close=")"> <foreach item="item" collection="list" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
<if test="runFlag == '' and type !=null"> <if test="runFlag == '' and runFlag !=null">
and device.Run_Flag in and device.Run_Flag in
<foreach item="item1" collection="runFlag" open="(" separator="," close=")"> <foreach item="item1" collection="runFlag" open="(" separator="," close=")">
#{item1} #{item1}
</foreach> </foreach>
</if> </if>
<if test="comFlag == '' and type !=null"> <if test="comFlag == '' and comFlag !=null">
and device.Com_Flag in and device.Com_Flag in
<foreach item="item2" collection="comFlag" open="(" separator="," close=")"> <foreach item="item2" collection="comFlag" open="(" separator="," close=")">
#{item2} #{item2}

View File

@@ -481,6 +481,7 @@
gd.`Name` gdName, gd.`Name` gdName,
substation.id subId, substation.id subId,
substation.`Name` subName, substation.`Name` subName,
subscale.name subScale,
pqdevice.IP ip, pqdevice.IP ip,
pqdevice.Com_Flag comFlag, pqdevice.Com_Flag comFlag,
factory.`Name` manufacturer, factory.`Name` manufacturer,
@@ -520,7 +521,7 @@
AND pqdevice.Manufacturer = factory.id AND pqdevice.Manufacturer = factory.id
AND device.pid = substation.id AND device.pid = substation.id
AND substation.id = pqsubstation.id AND substation.id = pqsubstation.id
AND pqsubstation.Scale = subscale.id AND pqsubstation.scale = subscale.id
AND substation.pid = gd.id AND substation.pid = gd.id
AND detail.load_type = loadtype.id AND detail.load_type = loadtype.id
AND line.Id IN AND line.Id IN
@@ -534,13 +535,6 @@
or substation.name like CONCAT('%', #{searchValue},'%') or substation.name like CONCAT('%', #{searchValue},'%')
or gd.name like CONCAT('%', #{searchValue},'%')) or gd.name like CONCAT('%', #{searchValue},'%'))
</if> </if>
<if test="searchValue!=null and searchValue!=''">
and (line.name like CONCAT('%', #{searchValue},'%')
or voltage.name like CONCAT('%', #{searchValue},'%')
or device.name like CONCAT('%', #{searchValue},'%')
or substation.name like CONCAT('%', #{searchValue},'%')
or gd.name like CONCAT('%', #{searchValue},'%'))
</if>
<if test="comFlag!=null"> <if test="comFlag!=null">
and pqdevice.com_flag = #{comFlag} and pqdevice.com_flag = #{comFlag}
</if> </if>

View File

@@ -146,6 +146,6 @@ public interface LineService {
* @param deviceInfoParam 参数 * @param deviceInfoParam 参数
* @return 结果 * @return 结果
*/ */
DeviceAbnormalVO getComunicateStatics(DeviceInfoParam.ConditionBusinessParam deviceInfoParam); DeviceAbnormalVO getComunicateStatics(DeviceInfoParam.BusinessParam deviceInfoParam);
} }

View File

@@ -1,5 +1,6 @@
package com.njcn.device.service; package com.njcn.device.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.device.pojo.param.DeviceInfoParam; import com.njcn.device.pojo.param.DeviceInfoParam;
import com.njcn.device.pojo.param.RunManageParam; import com.njcn.device.pojo.param.RunManageParam;
import com.njcn.device.pojo.param.TerminalLedgerParam; import com.njcn.device.pojo.param.TerminalLedgerParam;
@@ -20,7 +21,7 @@ public interface RunManageService {
* @param runManageParam 参数 * @param runManageParam 参数
* @return 结果 * @return 结果
*/ */
List<RunManageVO> getLineLedger(RunManageParam runManageParam); Page<RunManageVO> getLineLedger(RunManageParam runManageParam);
/** /**
* 获取终端台账信息 * 获取终端台账信息

View File

@@ -672,7 +672,7 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
@SneakyThrows @SneakyThrows
@Override @Override
public DeviceAbnormalVO getComunicateStatics(DeviceInfoParam.ConditionBusinessParam conditionBusinessParam) { public DeviceAbnormalVO getComunicateStatics(DeviceInfoParam.BusinessParam conditionBusinessParam) {
DeviceAbnormalVO deviceAbnormalVO = new DeviceAbnormalVO(); DeviceAbnormalVO deviceAbnormalVO = new DeviceAbnormalVO();
//获取所有监测点 //获取所有监测点
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(conditionBusinessParam, null, Stream.of(1).collect(Collectors.toList())); List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(conditionBusinessParam, null, Stream.of(1).collect(Collectors.toList()));

View File

@@ -4,8 +4,12 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.dto.SimpleDTO; import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils; import com.njcn.common.utils.PubUtils;
import com.njcn.device.enums.DeviceResponseEnum;
import com.njcn.device.enums.LineBaseEnum; import com.njcn.device.enums.LineBaseEnum;
import com.njcn.device.mapper.DeviceMapper; import com.njcn.device.mapper.DeviceMapper;
import com.njcn.device.mapper.LineDetailMapper; import com.njcn.device.mapper.LineDetailMapper;
@@ -16,34 +20,37 @@ import com.njcn.device.pojo.param.RunManageParam;
import com.njcn.device.pojo.po.Device; import com.njcn.device.pojo.po.Device;
import com.njcn.device.pojo.po.Line; import com.njcn.device.pojo.po.Line;
import com.njcn.device.pojo.po.LineDetail; import com.njcn.device.pojo.po.LineDetail;
import com.njcn.device.pojo.po.pv.PvVoltage;
import com.njcn.device.pojo.vo.*; import com.njcn.device.pojo.vo.*;
import com.njcn.device.service.LineService; import com.njcn.device.service.LineService;
import com.njcn.device.service.RunManageService; import com.njcn.device.service.RunManageService;
import com.njcn.device.service.TerminalBaseService; import com.njcn.device.service.TerminalBaseService;
import com.njcn.influxdb.mapper.InfluxDBResultMapperCn;
import com.njcn.influxdb.utils.InfluxDBCommUtils;
import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.system.api.AreaFeignClient; import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.enums.StatisticsEnum; import com.njcn.system.pojo.enums.StatisticsEnum;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.pojo.vo.LineDataVO; import com.njcn.web.pojo.vo.LineDataVO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static com.njcn.influxdb.param.InfluxDBPublicParam.*; import static com.njcn.influxdb.param.InfluxDBPublicParam.*;
import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
/** /**
* @author denghuajun * @author denghuajun
@@ -61,68 +68,56 @@ public class RunManageServiceImpl implements RunManageService {
private final DeviceMapper deviceMapper; private final DeviceMapper deviceMapper;
private final LineMapper lineMapper;
private final DicDataFeignClient dicDataFeignClient; private final DicDataFeignClient dicDataFeignClient;
private final TerminalBaseService terminalBaseService; private final TerminalBaseService terminalBaseService;
private final LineDetailMapper lineDetailMapper; private final LineDetailMapper lineDetailMapper;
private final AreaFeignClient areaFeignClient;
private final InfluxDbUtils influxDbUtils; private final InfluxDbUtils influxDbUtils;
@Override @Override
public List<RunManageVO> getLineLedger(RunManageParam runManageParam) { public Page<RunManageVO> getLineLedger(RunManageParam runManageParam) {
List<RunManageVO> runManageVOList = new ArrayList<>();
DeviceInfoParam deviceInfoParam = new DeviceInfoParam(); DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
BeanUtil.copyProperties(runManageParam, deviceInfoParam); BeanUtil.copyProperties(runManageParam, deviceInfoParam);
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList())); List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList()));
List<String> lineIndexes = new ArrayList<>(); List<String> lineIndexes = generalDeviceDTOList.stream().flatMap(list->list.getLineIndexes().stream()).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(generalDeviceDTOList)) { if (!CollectionUtils.isEmpty(lineIndexes)) {
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { Page<RunManageVO> page = new Page<>(PageFactory.getPageNum(runManageParam),PageFactory.getPageSize(runManageParam));
lineIndexes.addAll(generalDeviceDTO.getLineIndexes()); return deviceMapper.getRunManageList(page,lineIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag());
}else {
throw new BusinessException(CommonResponseEnum.FAIL);
} }
List<RunManageVO> list = deviceMapper.getRunManageList(lineIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag());
runManageVOList = list.stream().skip((runManageParam.getPageNum() - 1) * runManageParam.getPageSize()).limit(runManageParam.getPageSize()).
collect(Collectors.toList());
int i = 1;
for (RunManageVO runManageVO : runManageVOList) {
runManageVO.setRunNo(i);
i++;
}
}
return runManageVOList;
} }
@Override @Override
public List<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam) { public List<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam) {
List<RunTimeVO> runTimeVOList = new ArrayList<>(); List<RunTimeVO> runManageDevList = new ArrayList<>();
DeviceInfoParam deviceInfoParam = new DeviceInfoParam(); DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
BeanUtil.copyProperties(runManageParam, deviceInfoParam); BeanUtil.copyProperties(runManageParam, deviceInfoParam);
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList())); List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList()));
List<String> devIndexes = new ArrayList<>();
if (!CollectionUtils.isEmpty(generalDeviceDTOList)) { if (!CollectionUtils.isEmpty(generalDeviceDTOList)) {
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { List<String> devIndexes = generalDeviceDTOList.stream().flatMap(list->list.getDeviceIndexes().stream()).collect(Collectors.toList());
devIndexes.addAll(generalDeviceDTO.getDeviceIndexes());
} if(CollectionUtil.isNotEmpty(devIndexes)){
List<RunTimeVO> list = deviceMapper.getRunManageDevList(devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag()); runManageDevList = deviceMapper.getRunManageDevList(devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag());
runTimeVOList = list.stream().skip((runManageParam.getPageNum() - 1) * runManageParam.getPageSize()).limit(runManageParam.getPageSize()).
collect(Collectors.toList()); StringBuilder devSql = InfluxDBCommUtils.assToInfluxParamDev(devIndexes);
int i = 1; String stringBuilder = "time >= '" + runManageParam.getSearchBeginTime() + "' and " + "time <= '" + runManageParam.getSearchEndTime()+"' and "+devSql+" group by dev_id";
for (RunTimeVO runTimeVO : runTimeVOList) { //sql语句
runTimeVO.setRunNo(i); String sql = "SELECT MEAN(online_rate) AS online_rate FROM " + PQS_ONLINERATE + " WHERE " + stringBuilder + TIME_ZONE+")";
//获取在线率 QueryResult queryResult = influxDbUtils.query(sql);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
runTimeVO.setOnlineEvaluate(getCondition(formatter.format(DateUtil.lastMonth()), formatter.format(DateUtil.dateNew(new Date())), runTimeVO.getId()) * 100); InfluxDBResultMapper inCn = new InfluxDBResultMapper();
i++; List<LineInfluxDbOnlineVO> lineInfluxDbOnlineVOList = inCn.toPOJO(queryResult,LineInfluxDbOnlineVO.class);
runManageDevList = runManageDevList.stream().peek(item-> lineInfluxDbOnlineVOList.stream().filter(it-> Objects.equals(item.getId(),it.getDevIndex())).findFirst().ifPresent(i->item.setOnlineEvaluate(i.getOnlineRate()))).collect(Collectors.toList());
} }
} }
return runTimeVOList; return runManageDevList;
} }
private Float getCondition(String startTime, String endTime, String lineId) { /* private Float getCondition(String startTime, String endTime, String lineId) {
final Float[] floatList = {0.0f}; final Float[] floatList = {0.0f};
QueryResult queryResult; QueryResult queryResult;
if (!lineId.isEmpty()) { if (!lineId.isEmpty()) {
@@ -148,7 +143,7 @@ public class RunManageServiceImpl implements RunManageService {
} }
return floatList[0]; return floatList[0];
} }*/
@Override @Override
public List<TerminalLedgerVO> getTerminalLedger(DeviceInfoParam deviceInfoParam) { public List<TerminalLedgerVO> getTerminalLedger(DeviceInfoParam deviceInfoParam) {

View File

@@ -3,6 +3,9 @@ package com.njcn.event.pojo.po;
import lombok.Data; import lombok.Data;
import org.influxdb.annotation.Column; import org.influxdb.annotation.Column;
import org.influxdb.annotation.Measurement; import org.influxdb.annotation.Measurement;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.Instant;
/** /**
* @author cdf * @author cdf
@@ -18,7 +21,8 @@ public class EventDetailNew {
private String lineId; private String lineId;
@Column(name = "time") @Column(name = "time")
private String timeId; @DateTimeFormat(pattern = "yyyy-mm-dd")
private Instant timeId;
@Column(name = "event_describe") @Column(name = "event_describe")
private String eventDescribe; private String eventDescribe;

View File

@@ -23,7 +23,6 @@ import com.njcn.event.service.EventDetailService;
import com.njcn.influxdb.param.InfluxDBPublicParam; import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.system.pojo.enums.StatisticsEnum; import com.njcn.system.pojo.enums.StatisticsEnum;
import com.sun.org.apache.regexp.internal.RE;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;

View File

@@ -23,7 +23,9 @@ public enum HarmonicResponseEnum {
CUSTOM_REPORT_JSON("A00553","模板非严格json数据"), CUSTOM_REPORT_JSON("A00553","模板非严格json数据"),
CUSTOM_REPORT_DEPT("A00554","该部门已存在绑定报表模板"), CUSTOM_REPORT_DEPT("A00554","该部门已存在绑定报表模板"),
CUSTOM_TYPE("A00555","字典中未查询到报表模板类型") CUSTOM_TYPE("A00555","字典中未查询到报表模板类型"),
CUSTOM_REPORT_ACTIVE("A00556","不存在激活的自定义报告模板"),
CUSTOM_REPORT_EMPTY("A00557","自定义报表模板异常,模板数据为空"),
; ;
private final String code; private final String code;

View File

@@ -0,0 +1,30 @@
package com.njcn.harmonic.pojo.param;
import com.njcn.web.pojo.annotation.DateTimeStrValid;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* pqs
*
* @author cdf
* @date 2022/8/26
*/
@Data
public class ReportQueryParam {
@ApiModelProperty(name = "lineId",value = "监测点id")
private String lineId;
@ApiModelProperty(name = "startTime",value = "开始时间")
@NotBlank(message = "起始时间不可为空")
@DateTimeStrValid(message = "起始时间格式出错")
private String startTime;
@ApiModelProperty(name = "endTime",value = "结束时间")
@NotBlank(message = "结束时间不可为空")
private String endTime;
}

View File

@@ -9,6 +9,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil; import com.njcn.common.utils.LogUtil;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.param.ReportTemplateParam; import com.njcn.harmonic.pojo.param.ReportTemplateParam;
import com.njcn.harmonic.pojo.po.ReportTemplate; import com.njcn.harmonic.pojo.po.ReportTemplate;
import com.njcn.harmonic.pojo.vo.OverAreaLimitVO; import com.njcn.harmonic.pojo.vo.OverAreaLimitVO;
@@ -166,10 +167,10 @@ public class CustomReportController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getCustomReport") @PostMapping("/getCustomReport")
@ApiOperation("获取报表") @ApiOperation("获取报表")
@ApiImplicitParam(name = "id", value = "id", required = true) @ApiImplicitParam(name = "reportQueryParam", value = "查询体", required = true)
public HttpResult<JSONArray> getCustomReport(@RequestParam("id") String id){ public HttpResult<String> getCustomReport(@RequestBody @Validated ReportQueryParam reportQueryParam){
String methodDescribe = getMethodDescribe("getCustomReport"); String methodDescribe = getMethodDescribe("getCustomReport");
JSONArray res = customReportService.getCustomReport(); String res = customReportService.getCustomReport(reportQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
} }

View File

@@ -52,7 +52,7 @@ public class SteadyExceedRateController extends BaseController {
@PostMapping("/getSteadyExceedRateCensus") @PostMapping("/getSteadyExceedRateCensus")
@ApiOperation("稳态超标占比图表") @ApiOperation("稳态超标占比图表")
@ApiImplicitParam(name = "steadyExceedCensusParam", value = "稳态超标占比参数", required = true) @ApiImplicitParam(name = "steadyExceedCensusParam", value = "稳态超标占比参数", required = true)
public HttpResult<SteadyExceedRateCensusVO> getSteadyExceedRateCensus(@RequestBody @Validated DeviceInfoParam.ConditionBusinessParam steadyExceedCensusParam){ public HttpResult<SteadyExceedRateCensusVO> getSteadyExceedRateCensus(@RequestBody @Validated DeviceInfoParam.BusinessParam steadyExceedCensusParam){
String methodDescribe = getMethodDescribe("getSteadyExceedRateCensus"); String methodDescribe = getMethodDescribe("getSteadyExceedRateCensus");
SteadyExceedRateCensusVO censusVO = steadyExceedRateService.getSteadyExceedRateCensus(steadyExceedCensusParam); SteadyExceedRateCensusVO censusVO = steadyExceedRateService.getSteadyExceedRateCensus(steadyExceedCensusParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, censusVO, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, censusVO, methodDescribe);

View File

@@ -3,6 +3,7 @@ package com.njcn.harmonic.service;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.param.ReportTemplateParam; import com.njcn.harmonic.pojo.param.ReportTemplateParam;
import com.njcn.harmonic.pojo.po.ReportTemplate; import com.njcn.harmonic.pojo.po.ReportTemplate;
import com.njcn.harmonic.pojo.vo.ReportTemplateVO; import com.njcn.harmonic.pojo.vo.ReportTemplateVO;
@@ -16,7 +17,7 @@ import java.util.List;
/** /**
* pqs * pqs
* * 自定义报表
* @author cdf * @author cdf
* @date 2022/8/16 * @date 2022/8/16
*/ */
@@ -69,7 +70,20 @@ public interface CustomReportService {
boolean updateStatus(String id); boolean updateStatus(String id);
JSONArray getCustomReport(); /**
* 查询报告
* @param reportQueryParam 请求参数
* @return JSONArray
* @author cdf
* @date 2022/8/26
*/
String getCustomReport(ReportQueryParam reportQueryParam);
/**
* 查询报告模板树节点
* @author cdf
* @date 2022/8/26
*/
List<ReportTreeVO> reportChooseTree(); List<ReportTreeVO> reportChooseTree();
} }

View File

@@ -25,6 +25,6 @@ public interface SteadyExceedRateService {
* @param steadyExceedCensusParam * @param steadyExceedCensusParam
* @return * @return
*/ */
SteadyExceedRateCensusVO getSteadyExceedRateCensus(DeviceInfoParam.ConditionBusinessParam steadyExceedCensusParam); SteadyExceedRateCensusVO getSteadyExceedRateCensus(DeviceInfoParam.BusinessParam steadyExceedCensusParam);
} }

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -14,8 +15,10 @@ import com.njcn.harmonic.enums.HarmonicResponseEnum;
import com.njcn.harmonic.mapper.CustomReportMapper; import com.njcn.harmonic.mapper.CustomReportMapper;
import com.njcn.harmonic.mapper.EleEpdMapper; import com.njcn.harmonic.mapper.EleEpdMapper;
import com.njcn.harmonic.pojo.dto.ReportTemplateDTO; import com.njcn.harmonic.pojo.dto.ReportTemplateDTO;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.param.ReportTemplateParam; import com.njcn.harmonic.pojo.param.ReportTemplateParam;
import com.njcn.harmonic.pojo.po.EleEpdPqd; import com.njcn.harmonic.pojo.po.EleEpdPqd;
import com.njcn.harmonic.pojo.po.EventDetail;
import com.njcn.harmonic.pojo.po.ReportTemplate; import com.njcn.harmonic.pojo.po.ReportTemplate;
import com.njcn.harmonic.pojo.vo.ReportTemplateVO; import com.njcn.harmonic.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.pojo.vo.ReportTreeVO; import com.njcn.harmonic.pojo.vo.ReportTreeVO;
@@ -106,7 +109,7 @@ public class CustomReportServiceImpl implements CustomReportService {
@Override @Override
public Page<ReportTemplateVO> getReportTemplateList(BaseParam baseParam) { public Page<ReportTemplateVO> getReportTemplateList(BaseParam baseParam) {
return customReportMapper.getReportTemplateList(new Page<>(PageFactory.getPageNum(baseParam),PageFactory.getPageSize(baseParam)),baseParam); return customReportMapper.getReportTemplateList(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), baseParam);
} }
@Override @Override
@@ -124,8 +127,8 @@ public class CustomReportServiceImpl implements CustomReportService {
ReportTemplate report = new ReportTemplate(); ReportTemplate report = new ReportTemplate();
report.setActive(0); report.setActive(0);
UpdateWrapper<ReportTemplate> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<ReportTemplate> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("sys_report_template.active",1).eq("sys_report_template.state",1); updateWrapper.eq("sys_report_template.active", 1).eq("sys_report_template.state", 1);
customReportMapper.update(report,updateWrapper); customReportMapper.update(report, updateWrapper);
ReportTemplate reportTemplate = new ReportTemplate(); ReportTemplate reportTemplate = new ReportTemplate();
reportTemplate.setId(id); reportTemplate.setId(id);
@@ -136,41 +139,49 @@ public class CustomReportServiceImpl implements CustomReportService {
@Override @Override
public JSONArray getCustomReport() { public String getCustomReport(ReportQueryParam reportQueryParam) {
LambdaQueryWrapper<ReportTemplate> lambdaQuery = new LambdaQueryWrapper<>();
lambdaQuery.eq(ReportTemplate::getActive, DataStateEnum.ENABLE.getCode())
.eq(ReportTemplate::getState, DataStateEnum.ENABLE.getCode());
ReportTemplate tem = customReportMapper.selectOne(lambdaQuery);
if (Objects.isNull(tem)) {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
}
List<String> stringList = new ArrayList<>(); List<String> stringList = new ArrayList<>();
List<ReportTemplateDTO> reportTemplateDTOList = new ArrayList<>(); List<ReportTemplateDTO> reportTemplateDTOList = new ArrayList<>();
JSONArray jsonArray = null;
LambdaQueryWrapper<ReportTemplate> lambdaQuery= new LambdaQueryWrapper<>(); try {
lambdaQuery.eq(ReportTemplate::getActive,DataStateEnum.ENABLE.getCode()) jsonArray = JSONUtil.parseArray(tem.getDocContent());
.eq(ReportTemplate::getState,DataStateEnum.ENABLE.getCode()); jsonArray.forEach(item -> {
ReportTemplate tem = customReportMapper.selectOne(lambdaQuery); JSONObject jsonObject = (JSONObject) item;
JSONArray jsonArray = new JSONArray(tem.getDocContent());
jsonArray.forEach(item->{
JSONObject jsonObject = (JSONObject)item;
JSONArray itemArr = (JSONArray) jsonObject.get("data"); JSONArray itemArr = (JSONArray) jsonObject.get("data");
itemArr.forEach((ite)->{ itemArr.forEach((ite) -> {
JSONArray j = (JSONArray)ite; JSONArray j = (JSONArray) ite;
j.forEach(it->{ j.forEach(it -> {
if (Objects.nonNull(it) && !"null".equals(it.toString())) { if (Objects.nonNull(it) && !"null".equals(it.toString())) {
JSONObject son = (JSONObject) it; //获取到1列 JSONObject son = (JSONObject) it; //获取到1列
if (son.containsKey("v")) { if (son.containsKey("v")) {
String v = son.getStr("v"); String v = son.getStr("v");
System.out.println(v); System.out.println(v);
if (v.charAt(0) == '$' && v.contains("#")) { if (v.charAt(0) == '$' && v.contains("#")) {
v=v.replace("$",""); v = v.replace("$", "");
String[] vItem = v.split("#"); String[] vItem = v.split("#");
ReportTemplateDTO reportTemplateDTO = new ReportTemplateDTO(); ReportTemplateDTO reportTemplateDTO = new ReportTemplateDTO();
reportTemplateDTO.setItemName(v); reportTemplateDTO.setItemName(v);
String t = vItem[0].replace("_",""); String t = vItem[0].replace("_", "");
if(vItem.length == 3){ if (vItem.length == 3) {
reportTemplateDTO.setTemplateName(t); reportTemplateDTO.setTemplateName(t);
reportTemplateDTO.setPhase(vItem[1]); reportTemplateDTO.setPhase(vItem[1]);
reportTemplateDTO.setStatMethod(vItem[2]); reportTemplateDTO.setStatMethod(vItem[2]);
}else if(vItem.length == 2){ } else if (vItem.length == 2) {
reportTemplateDTO.setTemplateName(t); reportTemplateDTO.setTemplateName(t);
reportTemplateDTO.setStatMethod(vItem[1]); reportTemplateDTO.setStatMethod(vItem[1]);
reportTemplateDTO.setPhase("M"); reportTemplateDTO.setPhase("M");
@@ -190,150 +201,74 @@ public class CustomReportServiceImpl implements CustomReportService {
}); });
}); });
}); });
} catch (Exception e) {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
}
List<ReportTemplateDTO> endList = new ArrayList<>(); List<ReportTemplateDTO> endList = new ArrayList<>();
if(CollUtil.isEmpty(stringList) ||CollUtil.isEmpty(reportTemplateDTOList)){
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_EMPTY);
}
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(EleEpdPqd::getName,stringList.stream().distinct().collect(Collectors.toList())).orderByAsc(EleEpdPqd::getSort); lambdaQueryWrapper.in(EleEpdPqd::getName, stringList.stream().distinct().collect(Collectors.toList())).orderByAsc(EleEpdPqd::getSort);
List<EleEpdPqd> eleEpdPqdList = eleEpdMapper.selectList(lambdaQueryWrapper); List<EleEpdPqd> eleEpdPqdList = eleEpdMapper.selectList(lambdaQueryWrapper);
Map<String, List<EleEpdPqd>> mapEpd = eleEpdPqdList.stream().collect(Collectors.groupingBy(EleEpdPqd::getClassId)); Map<String, List<EleEpdPqd>> mapEpd = eleEpdPqdList.stream().collect(Collectors.groupingBy(EleEpdPqd::getClassId));
mapEpd.forEach((key,tableClass)->{
if(mapEpd.size() == 0){
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_EMPTY);
}
mapEpd.forEach((key, tableClass) -> {
List<String> column = tableClass.stream().map(EleEpdPqd::getName).distinct().collect(Collectors.toList()); List<String> column = tableClass.stream().map(EleEpdPqd::getName).distinct().collect(Collectors.toList());
List<ReportTemplateDTO> classList = reportTemplateDTOList.stream().filter(item->column.contains(item.getName())).collect(Collectors.toList()); List<ReportTemplateDTO> classList = reportTemplateDTOList.stream().filter(item -> column.contains(item.getName())).collect(Collectors.toList());
Map<String, List<ReportTemplateDTO>> phaseMap = classList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getPhase)); Map<String, List<ReportTemplateDTO>> phaseMap = classList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getPhase));
//开始组织sql //开始组织sql
phaseMap.forEach((phKey,phValue)->{ phaseMap.forEach((phKey, phValue) -> {
if("M".equals(phKey)){
}else {
Map<String, List<ReportTemplateDTO>> statMap = phValue.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getStatMethod)); Map<String, List<ReportTemplateDTO>> statMap = phValue.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getStatMethod));
statMap.forEach((statKey,statValue)->{ statMap.forEach((statKey, statValue) -> {
StringBuilder sql = new StringBuilder("select "); StringBuilder sql = new StringBuilder("select ");
if ("max".equals(statKey)) {
if(statKey.equals("max")){ assSql(statValue, sql, key, phKey, statKey, endList, "MAX",reportQueryParam);
for(int i = 0;i<statValue.size();i++){ } else if ("min".equals(statKey)) {
if(i==statValue.size()-1){ assSql(statValue, sql, key, phKey, statKey, endList, "MIN",reportQueryParam);
sql.append("MAX("+statValue.get(i).getTemplateName()+") as ").append(statValue.get(i).getTemplateName()); } else if ("avg".equals(statKey)) {
}else { assSql(statValue, sql, key, phKey, statKey, endList, "MEAN",reportQueryParam);
sql.append("MAX("+statValue.get(i).getTemplateName()+") as ").append(statValue.get(i).getTemplateName()).append(","); } else if ("cp95".equals(statKey)) {
assSql(statValue, sql, key, phKey, statKey, endList, "PERCENTILE",reportQueryParam);
} }
});
});
}
sql.append(" from ").append(key).append(" where Phase = '").append(phKey).append("' and LineId='00B78D123456$DEV$NPQS588$0002$NPQS588$01'").append(" and Stat_Method='").append(statKey+"'").append(" order by time desc limit 1").append(InfluxDBPublicParam.TIME_ZONE);
List<Map<String, Object>> resMap = influxDbUtils.getMapResult(sql.toString());
if(CollUtil.isNotEmpty(resMap)) {
List<ReportTemplateDTO> temValue = statValue.stream().map(item -> {
String value = resMap.get(0).get(item.getTemplateName()).toString();
item.setValue(value);
return item;
}).collect(Collectors.toList());
endList.addAll(temValue);
}
}else if(statKey.equals("min")){
for(int i = 0;i<statValue.size();i++){
if(i==statValue.size()-1){
sql.append("MIN("+statValue.get(i).getTemplateName()+") as ").append(statValue.get(i).getTemplateName());
}else {
sql.append("MIN("+statValue.get(i).getTemplateName()+") as ").append(statValue.get(i).getTemplateName()).append(",");
}
}
sql.append(" from ").append(key).append(" where Phase = '").append(phKey).append("' and LineId='00B78D123456$DEV$NPQS588$0002$NPQS588$01'").append(" and Stat_Method='").append(statKey+"'").append(" order by time desc limit 1").append(InfluxDBPublicParam.TIME_ZONE);
List<Map<String, Object>> resMap = influxDbUtils.getMapResult(sql.toString());
if(CollUtil.isNotEmpty(resMap)) {
List<ReportTemplateDTO> temValue = statValue.stream().map(item -> {
String value = resMap.get(0).get(item.getTemplateName()).toString();
item.setValue(value);
return item;
}).collect(Collectors.toList());
endList.addAll(temValue);
}
}else if(statKey.equals("avg")){
for(int i = 0;i<statValue.size();i++){
if(i==statValue.size()-1){
sql.append("MEAN("+statValue.get(i).getTemplateName()+") as ").append(statValue.get(i).getTemplateName());
}else {
sql.append("MEAN("+statValue.get(i).getTemplateName()+") as ").append(statValue.get(i).getTemplateName()).append(",");
}
}
sql.append(" from ").append(key).append(" where Phase = '").append(phKey).append("' and LineId='00B78D123456$DEV$NPQS588$0002$NPQS588$01'").append(" and Stat_Method='").append(statKey+"'").append(" order by time desc limit 1").append(InfluxDBPublicParam.TIME_ZONE);
List<Map<String, Object>> resMap = influxDbUtils.getMapResult(sql.toString());
if(CollUtil.isNotEmpty(resMap)) {
List<ReportTemplateDTO> temValue = statValue.stream().map(item -> {
String value = resMap.get(0).get(item.getTemplateName()).toString();
item.setValue(value);
return item;
}).collect(Collectors.toList());
endList.addAll(temValue);
}
}else if(statKey.equals("cp95")){
for(int i = 0;i<statValue.size();i++){
if(i==statValue.size()-1){
sql.append("PERCENTILE("+statValue.get(i).getTemplateName()+",95) as ").append(statValue.get(i).getTemplateName());
}else {
sql.append("PERCENTILE("+statValue.get(i).getTemplateName()+",95) as ").append(statValue.get(i).getTemplateName()).append(",");
}
}
sql.append(" from ").append(key).append(" where Phase = '").append(phKey).append("' and LineId='00B78D123456$DEV$NPQS588$0002$NPQS588$01'").append(" and Stat_Method='").append(statKey+"'").append(" order by time desc limit 1").append(InfluxDBPublicParam.TIME_ZONE);
List<Map<String, Object>> resMap = influxDbUtils.getMapResult(sql.toString());
if(CollUtil.isNotEmpty(resMap)) {
List<ReportTemplateDTO> temValue = statValue.stream().map(item -> {
String value = resMap.get(0).get(item.getTemplateName()).toString();
item.setValue(value);
return item;
}).collect(Collectors.toList());
endList.addAll(temValue);
}
}
}); });
if(CollUtil.isEmpty(endList)){
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_EMPTY);
} }
});
});
//进行反向赋值到模板 //进行反向赋值到模板
Map<String, List<ReportTemplateDTO>> assMap = endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName)); Map<String, List<ReportTemplateDTO>> assMap = endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
jsonArray.forEach(item->{ jsonArray.forEach(item -> {
JSONObject jsonObject = (JSONObject)item; JSONObject jsonObject = (JSONObject) item;
JSONArray itemArr = (JSONArray) jsonObject.get("data"); JSONArray itemArr = (JSONArray) jsonObject.get("data");
itemArr.forEach((ite)->{ itemArr.forEach((ite) -> {
JSONArray j = (JSONArray)ite; JSONArray j = (JSONArray) ite;
j.forEach(it->{ j.forEach(it -> {
if (Objects.nonNull(it) && !"null".equals(it.toString())) { if (Objects.nonNull(it) && !"null".equals(it.toString())) {
JSONObject son = (JSONObject) it; //获取到1列 JSONObject son = (JSONObject) it; //获取到1列
if (son.containsKey("v")) { if (son.containsKey("v")) {
String v = son.getStr("v"); String v = son.getStr("v");
System.out.println(v); System.out.println(v);
if (v.charAt(0) == '$' && v.contains("#")) { if (v.charAt(0) == '$' && v.contains("#")) {
String str = assMap.get(v.replace("$", "")).get(0).getValue();
String str = assMap.get(v.replace("$","")).get(0).getValue(); son.set("v", str);
son.set("v",str); son.set("m", str);
son.set("m",str);
} }
} }
} }
@@ -342,7 +277,30 @@ public class CustomReportServiceImpl implements CustomReportService {
}); });
return jsonArray; return jsonArray.toString();
}
private void assSql(List<ReportTemplateDTO> statValue, StringBuilder sql, String key, String phKey, String statKey, List<ReportTemplateDTO> endList, String tag,ReportQueryParam reportQueryParam) {
for (int i = 0; i < statValue.size(); i++) {
if (i == statValue.size() - 1) {
sql.append(tag).append("(").append(statValue.get(i).getTemplateName()).append(") as ").append(statValue.get(i).getTemplateName());
} else {
sql.append(tag).append("(").append(statValue.get(i).getTemplateName()).append(") as ").append(statValue.get(i).getTemplateName()).append(",");
}
}
sql.append(" from ").append(key).append(" where Phase = '").append(phKey).append("' and time>='").append(reportQueryParam.getStartTime()).append(InfluxDBPublicParam.START_TIME).append("' and time<='").append(reportQueryParam.getEndTime()).append(InfluxDBPublicParam.END_TIME).append("' and LineId='").append(reportQueryParam.getLineId()).append("' and Stat_Method='").append(statKey).append("'").append(InfluxDBPublicParam.TIME_ZONE);
List<Map<String, Object>> resMap = influxDbUtils.getMapResult(sql.toString());
if (CollUtil.isNotEmpty(resMap)) {
List<ReportTemplateDTO> temValue = statValue.stream().map(item -> {
String value = resMap.get(0).get(item.getTemplateName()).toString();
item.setValue(value);
return item;
}).collect(Collectors.toList());
endList.addAll(temValue);
}
} }
@Override @Override
@@ -368,12 +326,12 @@ public class CustomReportServiceImpl implements CustomReportService {
reportTreeCount.setName(value.get(0).getName() + "_" + i); reportTreeCount.setName(value.get(0).getName() + "_" + i);
reportTreeCount.setShowName(i + "" + value.get(0).getShowName()); reportTreeCount.setShowName(i + "" + value.get(0).getShowName());
reportTreeVO.setFlag(1); reportTreeVO.setFlag(1);
assPhase(value, reportTreeCount); assPhase(value, reportTreeCount,reportTreeCount.getName());
reHarm.add(reportTreeCount); reHarm.add(reportTreeCount);
} }
reportTreeVO.setChildren(reHarm); reportTreeVO.setChildren(reHarm);
} else { } else {
assPhase(value, reportTreeVO); assPhase(value, reportTreeVO,key);
} }
tree.add(reportTreeVO); tree.add(reportTreeVO);
}); });
@@ -385,7 +343,7 @@ public class CustomReportServiceImpl implements CustomReportService {
/*组装相别*/ /*组装相别*/
private void assPhase(List<EleEpdPqd> value, ReportTreeVO reportTreeItem) { private void assPhase(List<EleEpdPqd> value, ReportTreeVO reportTreeItem,String key) {
if (Objects.nonNull(value.get(0).getPhase()) && !"M".equals(value.get(0).getPhase())) { if (Objects.nonNull(value.get(0).getPhase()) && !"M".equals(value.get(0).getPhase())) {
List<ReportTreeVO> phaseTree = new ArrayList<>(); List<ReportTreeVO> phaseTree = new ArrayList<>();
value.forEach(item -> { value.forEach(item -> {
@@ -394,20 +352,20 @@ public class CustomReportServiceImpl implements CustomReportService {
reportTreePhase.setName(item.getPhase()); reportTreePhase.setName(item.getPhase());
reportTreePhase.setShowName(item.getPhase()); reportTreePhase.setShowName(item.getPhase());
assStatMethod(item, statTree); assStatMethod(item, statTree,key,item.getPhase());
reportTreePhase.setChildren(statTree); reportTreePhase.setChildren(statTree);
phaseTree.add(reportTreePhase); phaseTree.add(reportTreePhase);
}); });
reportTreeItem.setChildren(phaseTree); reportTreeItem.setChildren(phaseTree);
} else { } else {
List<ReportTreeVO> statTree = new ArrayList<>(); List<ReportTreeVO> statTree = new ArrayList<>();
assStatMethod(value.get(0), statTree); assStatMethod(value.get(0), statTree,key,"");
reportTreeItem.setChildren(statTree); reportTreeItem.setChildren(statTree);
} }
} }
private void assStatMethod(EleEpdPqd item, List<ReportTreeVO> statTree) { private void assStatMethod(EleEpdPqd item, List<ReportTreeVO> statTree,String oneKey,String twoKey) {
//存在向别为M但是Stat_Method不为空 //存在向别为M但是Stat_Method不为空
if (StrUtil.isNotBlank(item.getStatMethod())) { if (StrUtil.isNotBlank(item.getStatMethod())) {
String[] arr = item.getStatMethod().split(","); String[] arr = item.getStatMethod().split(",");
@@ -415,7 +373,12 @@ public class CustomReportServiceImpl implements CustomReportService {
if (CollUtil.isNotEmpty(stat)) { if (CollUtil.isNotEmpty(stat)) {
stat.forEach(statItem -> { stat.forEach(statItem -> {
ReportTreeVO reportTreeStat = new ReportTreeVO(); ReportTreeVO reportTreeStat = new ReportTreeVO();
reportTreeStat.setName(statItem); if(StrUtil.isNotBlank(twoKey)){
reportTreeStat.setName("$"+oneKey+"#"+twoKey+"#"+statItem+"$");
}else {
reportTreeStat.setName("$"+oneKey+"#"+statItem+"$");
}
reportTreeStat.setShowName(statItem); reportTreeStat.setShowName(statItem);
statTree.add(reportTreeStat); statTree.add(reportTreeStat);
}); });
@@ -441,16 +404,15 @@ public class CustomReportServiceImpl implements CustomReportService {
} }
if (StrUtil.isNotBlank(reportTemplateParam.getDeptId())) {
if(StrUtil.isNotBlank(reportTemplateParam.getDeptId())){
Dept dept = deptFeignClient.getDeptById(reportTemplateParam.getDeptId()).getData(); Dept dept = deptFeignClient.getDeptById(reportTemplateParam.getDeptId()).getData();
if(Objects.isNull(dept)){ if (Objects.isNull(dept)) {
throw new BusinessException(CommonResponseEnum.FAIL); throw new BusinessException(CommonResponseEnum.FAIL);
} }
lambdaQueryWrapper.clear(); lambdaQueryWrapper.clear();
lambdaQueryWrapper.eq(ReportTemplate::getDeptId,reportTemplateParam.getDeptId()) lambdaQueryWrapper.eq(ReportTemplate::getDeptId, reportTemplateParam.getDeptId())
.eq(ReportTemplate::getState,DataStateEnum.ENABLE.getCode()); .eq(ReportTemplate::getState, DataStateEnum.ENABLE.getCode());
if (isUpdate) { if (isUpdate) {
if (reportTemplateParam instanceof ReportTemplateParam.UpdateReportTemplateParam) { if (reportTemplateParam instanceof ReportTemplateParam.UpdateReportTemplateParam) {
@@ -459,7 +421,7 @@ public class CustomReportServiceImpl implements CustomReportService {
} }
int countDept = customReportMapper.selectCount(lambdaQueryWrapper); int countDept = customReportMapper.selectCount(lambdaQueryWrapper);
if(countDept>0){ if (countDept > 0) {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_DEPT); throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_DEPT);
} }
} }
@@ -467,7 +429,7 @@ public class CustomReportServiceImpl implements CustomReportService {
DictData dictData = dicDataFeignClient.getDicDataById(reportTemplateParam.getReportType()).getData(); DictData dictData = dicDataFeignClient.getDicDataById(reportTemplateParam.getReportType()).getData();
if(Objects.isNull(dictData)){ if (Objects.isNull(dictData)) {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_TYPE); throw new BusinessException(HarmonicResponseEnum.CUSTOM_TYPE);
} }

View File

@@ -72,7 +72,7 @@ public class SteadyExceedRateServiceImpl implements SteadyExceedRateService {
@Override @Override
public SteadyExceedRateCensusVO getSteadyExceedRateCensus(DeviceInfoParam.ConditionBusinessParam steadyExceedCensusParam) { public SteadyExceedRateCensusVO getSteadyExceedRateCensus(DeviceInfoParam.BusinessParam steadyExceedCensusParam) {
SteadyExceedRateCensusVO steadyExceedRateCensusVO = new SteadyExceedRateCensusVO(); SteadyExceedRateCensusVO steadyExceedRateCensusVO = new SteadyExceedRateCensusVO();
List<String> type = new ArrayList<>(), time = new ArrayList<>(); List<String> type = new ArrayList<>(), time = new ArrayList<>();
List<List<Double>> steadyExceedList = new ArrayList<>(); List<List<Double>> steadyExceedList = new ArrayList<>();

View File

@@ -29,6 +29,8 @@ public enum SystemResponseEnum {
DEV_VARIETY("A00359","查询字典终端类型数据为空"), DEV_VARIETY("A00359","查询字典终端类型数据为空"),
LINE_TYPE_VARIETY_EMPTY("A00360","查询字典监测点类型数据为空"), LINE_TYPE_VARIETY_EMPTY("A00360","查询字典监测点类型数据为空"),
EVENT_REPORT_REPEAT("A00361","暂态报告模板重复"),
; ;
private final String code; private final String code;

View File

@@ -0,0 +1,43 @@
package com.njcn.system.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.web.constant.ValidMessage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* pqs-event
*
* @author cdf
* @date 2022/8/29
*/
@Data
public class ReportTemplateParam {
private String name;
private String code;
private Integer type;
/**
* 更新操作实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class UpdateReportTemplateParam extends ReportTemplateParam {
/**
* 表Id
*/
@ApiModelProperty("id")
@NotBlank(message = ValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
private String id;
}
}

View File

@@ -0,0 +1,31 @@
package com.njcn.system.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.EqualsAndHashCode;
import nonapi.io.github.classgraph.json.Id;
/**
* pqs-event
*
* @author cdf
* @date 2022/8/29
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "pq_report_template")
public class ReportTemplate extends BaseEntity {
private String id;
private String name;
private String code;
private Integer type;
private Integer state;
}

View File

@@ -0,0 +1,142 @@
package com.njcn.system.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
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.system.pojo.param.ReportTemplateParam;
import com.njcn.system.pojo.po.ReportTemplate;
import com.njcn.system.service.ReportTemplateService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* pqs-event
* 暂态报告模板
* @author cdf
* @date 2022/8/29
*/
@Slf4j
@RestController
@RequestMapping("/reportTemplate")
@Api(tags = "暂态报告模板")
@AllArgsConstructor
public class ReportTemplateController extends BaseController {
private final ReportTemplateService reportTemplateService;
/**
* 新增暂态报表模板
* @param reportTemplateParam 暂态报表模板实体
* @author cdf
* @date 2022/7/5
*/
@PostMapping("addReportTemplate")
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.ADD)
@ApiOperation("新增暂态报表模板")
@ApiImplicitParam(name = "reportTemplateParam",value = "暂态报表模板实体",required = true)
public HttpResult<Object> addReportTemplate(@RequestBody @Validated ReportTemplateParam reportTemplateParam){
String methodDescribe = getMethodDescribe("addReportTemplate");
boolean res = reportTemplateService.addReportTemplate(reportTemplateParam);
if(res){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
/**
* 修改暂态报表模板
* @author cdf
* @date 2022/7/5
*/
@PostMapping("updateReportTemplate")
@OperateInfo(info = LogEnum.SYSTEM_COMMON,operateType = OperateType.UPDATE)
@ApiOperation("修改暂态报表模板")
@ApiImplicitParam(name = "updateReportTemplateParam",value = "暂态报表模板实体",required = true)
public HttpResult<Object> updateReportTemplate(@RequestBody @Validated ReportTemplateParam.UpdateReportTemplateParam updateReportTemplateParam){
String methodDescribe = getMethodDescribe("updateReportTemplate");
boolean res = reportTemplateService.updateReportTemplate(updateReportTemplateParam);
if(res){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
/**
* 查询所有暂态报表模板
* @author cdf
* @date 2022/7/5
* @return Page<ReportTemplate>
*/
@GetMapping("getAllReportTemplateList")
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@ApiOperation("查询所有暂态报表模板")
public HttpResult<List<ReportTemplate>> getAllReportTemplateList(){
String methodDescribe = getMethodDescribe("getAllReportTemplateList");
List<ReportTemplate> list = reportTemplateService.getAllReportTemplateList();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
/**
* 根据暂态报表模板id查询暂态报表模板
* @param id 暂态报表模板id
* @author cdf
* @date 2022/7/5
* @return ReportTemplate
*/
@GetMapping("getReportTemplateById")
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@ApiOperation("根据暂态报表模板id查询暂态报表模板")
@ApiImplicitParam(name = "id",value = "暂态报表模板id",required = true)
public HttpResult<ReportTemplate> getReportTemplateById(@RequestParam("id") String id){
String methodDescribe = getMethodDescribe("getReportTemplateById");
ReportTemplate reportTemplate = reportTemplateService.getReportTemplateById(id);
if(Objects.nonNull(reportTemplate)){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, reportTemplate, methodDescribe);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
/**
* 删除暂态报表模板
* @param ids 暂态报表模板id
* @author cdf
* @date 2022/7/5
* @return boolean
*/
@PostMapping("delReportTemplate")
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@ApiOperation("删除暂态报表模板")
@ApiImplicitParam(name = "ids",value = "暂态报表模板ids",required = true)
public HttpResult<ReportTemplate> delReportTemplate(@RequestBody List<String> ids){
String methodDescribe = getMethodDescribe("delReportTemplate");
boolean res = reportTemplateService.delReportTemplate(ids);
if(res){
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}

View File

@@ -0,0 +1,14 @@
package com.njcn.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.system.pojo.po.ReportTemplate;
/**
* pqs-event
* 报表模板
* @author cdf
* @date 2022/8/29
*/
public interface ReportTemplateMapper extends BaseMapper<ReportTemplate> {
}

View File

@@ -0,0 +1,58 @@
package com.njcn.system.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.system.pojo.param.ReportTemplateParam;
import com.njcn.system.pojo.po.ReportTemplate;
import java.util.List;
/**
* pqs-event
*
* @author cdf
* @date 2022/8/29
*/
public interface ReportTemplateService {
/**
* 新增暂态报告模板
* @param reportTemplateParam 暂态报告模板实体
* @author cdf
* @date 2022/7/5
* @return boolean
*/
boolean addReportTemplate(ReportTemplateParam reportTemplateParam);
/**
* 修改暂态报告模板
* @param updateReportTemplateParam 暂态报告模板实体
* @author cdf
* @date 2022/7/5
* @return boolean
*/
boolean updateReportTemplate(ReportTemplateParam.UpdateReportTemplateParam updateReportTemplateParam);
List<ReportTemplate> getAllReportTemplateList();
/**
* 根据暂态报告模板id查询暂态报告模板
* @param id 暂态报告模板id
* @author cdf
* @date 2022/7/5
* @return PvReportTemplate
*/
ReportTemplate getReportTemplateById(String id);
/**
* 删除暂态报告模板
* @param ids 暂态报告模板id
* @author cdf
* @date 2022/7/5
* @return boolean
*/
boolean delReportTemplate(List<String> ids);
}

View File

@@ -0,0 +1,108 @@
package com.njcn.system.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.SystemResponseEnum;
import com.njcn.system.mapper.ReportTemplateMapper;
import com.njcn.system.pojo.param.ReportTemplateParam;
import com.njcn.system.pojo.po.ReportTemplate;
import com.njcn.system.service.ReportTemplateService;
import com.njcn.web.factory.PageFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
/**
* pqs-event
*
* @author cdf
* @date 2022/8/29
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class ReportTemplateServiceImpl extends ServiceImpl<ReportTemplateMapper, ReportTemplate> implements ReportTemplateService {
@Override
public boolean addReportTemplate(ReportTemplateParam reportTemplateParam) {
checkNameAndParam(reportTemplateParam,false);
ReportTemplate reportTemplate = new ReportTemplate();
BeanUtils.copyProperties(reportTemplateParam,reportTemplate);
reportTemplate.setState(DataStateEnum.ENABLE.getCode());
return this.save(reportTemplate);
}
@Override
public boolean updateReportTemplate(ReportTemplateParam.UpdateReportTemplateParam updateReportTemplateParam) {
checkNameAndParam(updateReportTemplateParam,true);
ReportTemplate reportTemplate = new ReportTemplate();
BeanUtils.copyProperties(updateReportTemplateParam,reportTemplate);
return this.updateById(reportTemplate);
}
@Override
public List<ReportTemplate> getAllReportTemplateList() {
return this.list();
}
@Override
public ReportTemplate getReportTemplateById(String id) {
return this.getById(id);
}
@Override
public boolean delReportTemplate(List<String> ids) {
return this.removeByIds(ids);
}
/**
* 校验单位名称是否重复
*/
private void checkNameAndParam(ReportTemplateParam reportTemplateParam, boolean isUpdate) {
LambdaQueryWrapper<ReportTemplate> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ReportTemplate::getName, reportTemplateParam.getName())
.eq(ReportTemplate::getType,reportTemplateParam.getType());
if (isUpdate) {
//更新操作
if (reportTemplateParam instanceof ReportTemplateParam.UpdateReportTemplateParam) {
lambdaQueryWrapper.ne(ReportTemplate::getId, ((ReportTemplateParam.UpdateReportTemplateParam) reportTemplateParam).getId());
}
}
int count = this.count(lambdaQueryWrapper);
if (count > 0) {
throw new BusinessException(SystemResponseEnum.EVENT_REPORT_REPEAT);
}
lambdaQueryWrapper.clear();
lambdaQueryWrapper.eq(ReportTemplate::getCode, reportTemplateParam.getCode())
.eq(ReportTemplate::getType,reportTemplateParam.getType());
if (isUpdate) {
//更新操作
if (reportTemplateParam instanceof ReportTemplateParam.UpdateReportTemplateParam) {
lambdaQueryWrapper.ne(ReportTemplate::getId, ((ReportTemplateParam.UpdateReportTemplateParam) reportTemplateParam).getId());
}
}
int countUserCode = this.count(lambdaQueryWrapper);
if (countUserCode > 0) {
throw new BusinessException(SystemResponseEnum.EVENT_REPORT_REPEAT);
}
}
}