1.数据单位管理

2.谐波模块-excel和word报告数据单位调整
3.监测点权重管理
This commit is contained in:
wr
2023-08-24 15:07:12 +08:00
parent 5d288a6720
commit df51123872
26 changed files with 1477 additions and 44 deletions

View File

@@ -0,0 +1,35 @@
package com.njcn.device.pq.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.fallback.LineIntegrityClientFallbackFactory;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 监测点数据完整性
* @author cdf
* @date 2023/6/7
*/
@FeignClient(value = ServerInfo.DEVICE,
path = "/pq/pqsDeviceUnit",
fallbackFactory = LineIntegrityClientFallbackFactory.class,
contextId = "pqsDeviceUnit")
public interface DeviceUnitClient {
/**
* @Description: 根据监测点id获取数据单位
* @param lineID
* @return: com.njcn.common.pojo.response.HttpResult<com.njcn.device.pq.pojo.po.PqsDeviceUnit>
* @Author: wr
* @Date: 2023/8/22 16:21
*/
@PostMapping("/lineUnitDetail")
HttpResult<PqsDeviceUnit> lineUnitDetail(@RequestParam("lineID") String lineID) ;
}

View File

@@ -1,18 +1,13 @@
package com.njcn.device.pq.api;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.fallback.GeneralDeviceInfoClientFallbackFactory;
import com.njcn.device.pq.pojo.bo.BaseLineInfo;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.po.OnlineRate;
import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

View File

@@ -0,0 +1,37 @@
package com.njcn.device.pq.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.biz.utils.DeviceEnumUtil;
import com.njcn.device.pq.api.DeviceUnitClient;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author denghuajun
* @date 2022/2/28
*/
@Slf4j
@Component
public class DeviceUnitFallbackFactory implements feign.hystrix.FallbackFactory<DeviceUnitClient> {
@Override
public DeviceUnitClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable.getCause();
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new DeviceUnitClient() {
@Override
public HttpResult<PqsDeviceUnit> lineUnitDetail(String lineID) {
log.error("{}异常,降级处理,异常为:{}", "根据监测点id获取数据单位", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,120 @@
package com.njcn.device.pq.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Description: 数据单位管理表
* @Author: wr
* @Date: 2023/8/21 9:56
*/
@Data
@TableName("pqs_device_unit")
public class PqsDeviceUnit {
private static final long serialVersionUID = 1L;
@TableId(value = "DEV_INDEX")
@ApiModelProperty(value = "终端编号")
private String devIndex;
@TableField("UNIT_FREQUENCY")
@ApiModelProperty(value = "频率")
private String unitFrequency = "Hz";
@TableField("UNIT_FREQUENCY_DEV")
@ApiModelProperty(value = "频率偏差")
private String unitFrequencyDev = "Hz";
@TableField("PHASE_VOLTAGE")
@ApiModelProperty(value = "相电压有效值")
private String phaseVoltage = "kV";
@TableField("LINE_VOLTAGE")
@ApiModelProperty(value = "线电压有效值")
private String lineVoltage = "kV";
@TableField("VOLTAGE_DEV")
@ApiModelProperty(value = "电压上偏差")
private String voltageDev = "%";
@TableField("UVOLTAGE_DEV")
@ApiModelProperty(value = "电压下偏差")
private String uvoltageDev = "%";
@TableField("I_EFFECTIVE")
@ApiModelProperty(value = "电流有效值")
private String ieffective = "A";
@TableField("SINGLE_P")
@ApiModelProperty(value = "单相有功功率")
private String singleP = "kW";
@TableField("SINGLE_VIEW_P")
@ApiModelProperty(value = "单相视在功率")
private String singleViewP = "kVA";
@TableField("SINGLE_NO_P")
@ApiModelProperty(value = "单相无功功率")
private String singleNoP = "kVar";
@TableField("TOTAL_ACTIVE_P")
@ApiModelProperty(value = "总有功功率")
private String totalActiveP = "kW";
@TableField("TOTAL_VIEW_P")
@ApiModelProperty(value = "总视在功率")
private String totalViewP = "kVA";
@TableField("TOTAL_NO_P")
@ApiModelProperty(value = "总无功功率")
private String totalNoP = "kVar";
@TableField("V_FUND_EFFECTIVE")
@ApiModelProperty(value = "相(线)电压基波有效值")
private String vfundEffective = "kV";
@TableField("I_FUND")
@ApiModelProperty(value = "基波电流")
private String ifund = "A";
@TableField("FUND_ACTIVE_P")
@ApiModelProperty(value = "基波有功功率")
private String fundActiveP = "kW";
@TableField("FUND_NO_P")
@ApiModelProperty(value = "基波无功功率")
private String fundNoP = "kVar";
@TableField("V_DISTORTION")
@ApiModelProperty(value = "电压总谐波畸变率")
private String vdistortion = "%";
@TableField("V_HARMONIC_RATE")
@ApiModelProperty(value = "250次谐波电压含有率")
private String vharmonicRate = "%";
@TableField("I_HARMONIC")
@ApiModelProperty(value = "250次谐波电流有效值")
private String iharmonic = "A";
@TableField("P_HARMONIC")
@ApiModelProperty(value = "250次谐波有功功率")
private String pharmonic = "kW";
@TableField("I_IHARMONIC")
@ApiModelProperty(value = "0.549.5次间谐波电流有效值")
private String iiharmonic = "A";
@TableField("POSITIVE_V")
@ApiModelProperty(value = "正序电压")
private String positiveV = "kV";
@TableField("NO_POSITIVE_V")
@ApiModelProperty(value = "零序负序电压")
private String noPositiveV = "V";
}

View File

@@ -0,0 +1,87 @@
package com.njcn.device.pq.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import java.io.Serializable;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Getter;
import lombok.Setter;
/**
* <p>
* 监测点评分权重
* </p>
*
* @author wr
* @since 2023-08-24
*/
@Getter
@Setter
@TableName("pqs_line_weight")
public class PqsLineWeight {
private static final long serialVersionUID = 1L;
/**
* 监测点id
*/
@TableId("LINE_INDEX")
@ApiModelProperty("监测点id")
private String lineIndex;
/**
* 通讯费用评分
*/
@TableField("COMMUN_FEE_MARK")
@ApiModelProperty("通讯费用评分")
private Integer communFeeMark;
/**
* 服务条款评分
*/
@TableField("SERVICE_MARK")
@ApiModelProperty("服务条款评分")
private Integer serviceMark;
/**
* 中间户数据需求
*/
@TableField("AGENT_MARK")
@ApiModelProperty("中间户数据需求")
private Integer agentMark;
/**
* 公司数据需求
*/
@TableField("COMPANY_MARK")
@ApiModelProperty("公司数据需求")
private Integer companyMark;
/**
* 用户需求
*/
@TableField("USER_MARK")
@ApiModelProperty("用户需求")
private Integer userMark;
/**
* 监测点类型
*/
@TableField("LINE_TYPE_MARK")
@ApiModelProperty("监测点类型")
private Integer lineTypeMark;
/**
* 行业重要度
*/
@TableField("BUSINESS_MARK")
@ApiModelProperty("行业重要度")
private Integer businessMark;
}

View File

@@ -0,0 +1,121 @@
package com.njcn.device.pq.pojo.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author wr
* @description
* @date 2023/8/21 10:16
*/
@Data
public class PqsDeviceUnitVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "编号")
private String id;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "频率")
private String unitFrequency;
@ApiModelProperty(value = "频率偏差")
private String unitFrequencyDev;
@ApiModelProperty(value = "相电压有效值")
private String phaseVoltage;
@ApiModelProperty(value = "线电压有效值")
private String lineVoltage;
@ApiModelProperty(value = "电压上偏差")
private String voltageDev;
@ApiModelProperty(value = "电压下偏差")
private String uvoltageDev;
@ApiModelProperty(value = "电流有效值")
private String ieffective;
@ApiModelProperty(value = "单相有功功率")
private String singleP;
@ApiModelProperty(value = "单相视在功率")
private String singleViewP;
@ApiModelProperty(value = "单相无功功率")
private String singleNoP;
@ApiModelProperty(value = "总有功功率")
private String totalActiveP;
@ApiModelProperty(value = "总视在功率")
private String totalViewP;
@ApiModelProperty(value = "总无功功率")
private String totalNoP;
@ApiModelProperty(value = "相(线)电压基波有效值")
private String vfundEffective;
@ApiModelProperty(value = "基波电流")
private String ifund;
@ApiModelProperty(value = "基波有功功率")
private String fundActiveP;
@ApiModelProperty(value = "基波无功功率")
private String fundNoP;
@ApiModelProperty(value = "电压总谐波畸变率")
private String vdistortion;
@ApiModelProperty(value = "250次谐波电压含有率")
private String vharmonicRate;
@ApiModelProperty(value = "250次谐波电流有效值")
private String iharmonic;
@ApiModelProperty(value = "250次谐波有功功率")
private String pharmonic;
@ApiModelProperty(value = "0.549.5次间谐波电流有效值")
private String iiharmonic;
@ApiModelProperty(value = "正序电压")
private String positiveV;
@ApiModelProperty(value = "运行状态")
private String devFlag;
@ApiModelProperty(value = "零序负序电压")
private String noPositiveV;
@ApiModelProperty(value = "子集数据")
List<?> children;
@Data
public static class DeviceUnit extends PqsDeviceUnit {
@ApiModelProperty(value = "编号")
private String id;
@ApiModelProperty(value = "父节点")
private String pid;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "运行状态")
private String devFlag;
@ApiModelProperty(value = "子集数据")
List<?> children;
}
}

View File

@@ -0,0 +1,105 @@
package com.njcn.device.pq.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.njcn.device.pq.pojo.po.PqsLineWeight;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author wr
* @description
* @date 2023/8/24 10:31
*/
@Data
public class PqsLineWeightVo extends PqsLineWeight {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "区域")
private String areaName;
@ApiModelProperty(value = "供电公司")
private String gbName;
@ApiModelProperty(value = "变电站名称")
private String subName;
@ApiModelProperty(value = "装置名称")
private String devName;
@ApiModelProperty(value = "监测点名称")
private String lineName;
@ApiModelProperty(value = "终端运行状态")
private String runFlag;
@ApiModelProperty(value = "监测点评级")
private String lineGrade;
@Data
public static class WeightExcel {
private static final long serialVersionUID = 1L;
@Excel(name = "省份",width = 15,height = 20)
@NotBlank(message = "省份名称不为空")
private String areaName;
@Excel(name = "供电公司",width = 15)
@NotBlank(message = "供电公司名称不为空")
private String gbName;
@Excel(name = "变电站",width = 15)
@NotBlank(message = "变电站名称不为空")
private String subName;
@Excel(name = "装置名称",width = 15)
@NotBlank(message = "装置名称不为空")
private String devName;
@Excel(name = "监测点名称",width = 15)
@NotBlank(message = "监测点名称不为空")
private String lineName;
@Excel(name ="通讯费用评分",width = 15)
@NotNull(message = "通讯费用评分不为空")
private Integer communFeeMark;
@Excel(name ="服务条款评分",width = 15)
@NotNull(message = "服务条款评分不为空")
private Integer serviceMark;
@Excel(name ="中间户数据需求",width = 15)
@NotNull(message = "中间户数据需求不为空")
private Integer agentMark;
@Excel(name ="公司数据需求",width = 15)
@NotNull(message = "公司数据需求不为空")
private Integer companyMark;
@Excel(name ="用户需求",width = 15)
@NotNull(message = "用户需求不为空")
private Integer userMark;
@Excel(name ="监测点类型",width = 15)
@NotNull(message = "监测点类型不为空")
private Integer lineTypeMark;
@Excel(name ="行业重要度",width = 15)
@NotNull(message = "行业重要度不为空")
private Integer businessMark;
}
@Data
public static class Msg extends WeightExcel{
private static final long serialVersionUID = 1L;
@Excel(name = "错误信息",width = 60)
private String msg;
}
}

View File

@@ -0,0 +1,85 @@
package com.njcn.device.pq.controller;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import com.njcn.device.pq.pojo.vo.PqsDeviceUnitVo;
import com.njcn.device.pq.service.IPqsDeviceUnitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.njcn.web.controller.BaseController;
import java.util.List;
/**
* <p>
* 数据单位管理
* </p>
*
* @author wr
* @since 2023-08-21
*/
@RestController
@Api(tags = "数据单位管理")
@RequestMapping("/pq/pqsDeviceUnit")
@RequiredArgsConstructor
public class PqsDeviceUnitController extends BaseController {
private final IPqsDeviceUnitService iPqsDeviceUnitService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/nodeTree")
@ApiOperation("数据单位查询树")
@ApiImplicitParam(name = "devFlag", value = "实体", required = true)
public HttpResult<List<PqsDeviceUnitVo>> nodeTree(String devFlag) {
String methodDescribe = getMethodDescribe("nodeTree");
List<PqsDeviceUnitVo> pqsDeviceUnitVos = iPqsDeviceUnitService.nodeList(devFlag);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqsDeviceUnitVos, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/saveDeviceUnit")
@ApiOperation("数据单位修改")
@ApiImplicitParam(name = "unit", value = "实体", required = true)
public HttpResult<Boolean> saveDeviceUnit(@RequestBody PqsDeviceUnit unit) {
String methodDescribe = getMethodDescribe("saveDeviceUnit");
Boolean aBoolean = iPqsDeviceUnitService.saveDeviceUnit(unit);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, aBoolean, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/lineUnitDetail")
@ApiOperation("根据监测点id获取数据单位")
@ApiImplicitParam(name = "lineID", value = "实体", required = true)
public HttpResult<PqsDeviceUnit> lineUnitDetail(@RequestParam("lineID") String lineID) {
String methodDescribe = getMethodDescribe("lineUnitDetail");
PqsDeviceUnit pqsDeviceUnit = iPqsDeviceUnitService.lineUnitDetail(lineID);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqsDeviceUnit, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/devUnitDetail")
@ApiOperation("根据终端id获取数据单位")
@ApiImplicitParam(name = "devID", value = "实体", required = true)
public HttpResult<PqsDeviceUnit> devUnitDetail(@RequestParam("devID") String devID) {
String methodDescribe = getMethodDescribe("devUnitDetail");
PqsDeviceUnit pqsDeviceUnit = iPqsDeviceUnitService.devUnitDetail(devID);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqsDeviceUnit, methodDescribe);
}
}

View File

@@ -0,0 +1,78 @@
package com.njcn.device.pq.controller;
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.device.pq.pojo.po.PqsLineWeight;
import com.njcn.device.pq.pojo.vo.PqsLineWeightVo;
import com.njcn.device.pq.service.IPqsLineWeightService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.core.io.InputStreamResource;
import org.springframework.web.bind.annotation.*;
import com.njcn.web.controller.BaseController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
/**
* <p>
* 监测点评分权重
* </p>
*
* @author wr
* @since 2023-08-24
*/
@RestController
@RequestMapping("/LineWeight")
@Api(tags = "监测点评分权重")
@RequiredArgsConstructor
public class PqsLineWeightController extends BaseController {
private final IPqsLineWeightService iPqsLineWeightService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/LineWeightList")
@ApiOperation("查询监测点权重")
public HttpResult<List<PqsLineWeightVo>> LineWeightList() {
String methodDescribe = getMethodDescribe("nodeTree");
List<PqsLineWeightVo> pqsLineWeightVos = iPqsLineWeightService.LineWeightList();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqsLineWeightVos, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addLineWeight")
@ApiOperation("监测点评分权重修改")
public HttpResult<Boolean> LineWeightList(@RequestBody PqsLineWeight lineWeight) {
String methodDescribe = getMethodDescribe("nodeTree");
Boolean aBoolean = iPqsLineWeightService.addLineWeight(lineWeight);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, aBoolean, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/export")
@ApiOperation("监测点评分权重模板导出")
public InputStreamResource export() throws IOException {
return iPqsLineWeightService.exportTemplate();
}
@PostMapping(value = "/batchWeight")
@ApiOperation("批量导入监测点评分权重")
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
public HttpResult<String> batchTerminal(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("batchTerminal");
iPqsLineWeightService.batchWeight(file, response);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -0,0 +1,39 @@
package com.njcn.device.pq.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import com.njcn.device.pq.pojo.vo.PqsDeviceUnitVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wr
* @since 2023-08-21
*/
public interface PqsDeviceUnitMapper extends BaseMapper<PqsDeviceUnit> {
/**
* @Description: 查询终端单位信息
* @param devFlag
* @return: java.util.List<com.njcn.device.pq.pojo.vo.PqsDeviceUnitVo.DeviceUnit>
* @Author: wr
* @Date: 2023/8/21 14:17
*/
List<PqsDeviceUnitVo.DeviceUnit> deviceUnitList(@Param("devFlag") String devFlag);
/**
* @Description: 根据监测点信息查询
* @param ids
* @return: java.util.List<com.njcn.device.pq.pojo.po.PqsDeviceUnit>
* @Author: wr
* @Date: 2023/8/21 14:17
*/
PqsDeviceUnit deviceUnitByID(@Param("ids") String ids);
}

View File

@@ -0,0 +1,40 @@
package com.njcn.device.pq.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.device.pq.pojo.param.TerminalMainQueryParam;
import com.njcn.device.pq.pojo.po.PqsLineWeight;
import com.njcn.device.pq.pojo.vo.PqsLineWeightVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wr
* @since 2023-08-24
*/
public interface PqsLineWeightMapper extends BaseMapper<PqsLineWeight> {
/**
* @Description: 查询监测点权重
* @param
* @return: java.util.List<com.njcn.device.pq.pojo.vo.PqsLineWeightVo>
* @Author: wr
* @Date: 2023/8/24 10:45
*/
List<PqsLineWeightVo> selectWeight();
/**
* @Description: 根据区域/供电公司/终端等查询监测点id
* @param param
* @return: java.lang.String
* @Author: wr
* @Date: 2023/8/24 13:50
*/
String getLineID( @Param("param") PqsLineWeightVo.WeightExcel param);
}

View File

@@ -0,0 +1,39 @@
<?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.device.pq.mapper.PqsDeviceUnitMapper">
<select id="deviceUnitList" resultType="com.njcn.device.pq.pojo.vo.PqsDeviceUnitVo$DeviceUnit">
SELECT
dev.id as id,
dev.pid as pid,
dev.NAME as `name`,
pd.Run_Flag as devFlag,
b.*
FROM
pq_line dev
INNER JOIN pq_device pd ON dev.id = pd.id and dev.State = 1
LEFT JOIN pqs_device_unit b ON dev.id = b.dev_index
<where>
<if test="devFlag!=null and devFlag!='' ">
pd.Run_Flag = #{devFlag}
</if>
</where>
</select>
<select id="deviceUnitByID" resultType="com.njcn.device.pq.pojo.po.PqsDeviceUnit">
SELECT
unit.*
FROM
pq_line line
INNER JOIN pq_line vo ON vo.id = line.pid
INNER JOIN pq_line dev ON dev.id = vo.pid
INNER JOIN pq_device pd ON pd.id = dev.id
LEFT JOIN pqs_device_unit unit ON unit.DEV_INDEX = dev.id
<where>
line.State = 1
<if test="ids!=null and ids!='' ">
and line.id = #{ids}
</if>
</where>
</select>
</mapper>

View File

@@ -0,0 +1,51 @@
<?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.device.pq.mapper.PqsLineWeightMapper">
<select id="selectWeight" resultType="com.njcn.device.pq.pojo.vo.PqsLineWeightVo">
SELECT
area.id AS areaName,
gd.NAME AS gbName,
sub.NAME AS subName,
dev.NAME AS devName,
line.NAME AS lineName,
pd.Run_Flag AS runFlag,
pld.Line_Grade AS lineGrade,
line.id AS lineIndex,
COMMUN_FEE_MARK,
SERVICE_MARK,
AGENT_MARK,
COMPANY_MARK,
USER_MARK,
LINE_TYPE_MARK,
BUSINESS_MARK
FROM
pq_line line
INNER JOIN pq_line_detail pld ON line.Id = pld.Id
INNER JOIN pq_line vol ON vol.Id = line.Pid
INNER JOIN pq_line dev ON dev.Id = vol.Pid
INNER JOIN pq_device pd ON pd.Id = dev.Id
INNER JOIN pq_line sub ON sub.Id = dev.Pid
INNER JOIN pq_line gd ON gd.Id = sub.Pid
INNER JOIN pq_line area ON area.Id = gd.Pid
LEFT JOIN pqs_line_weight plw ON line.Id = plw.LINE_INDEX
where line.State = 1
</select>
<select id="getLineID" resultType="java.lang.String">
SELECT
line.id
FROM
pq_line line
INNER JOIN pq_line vol ON vol.Id = line.Pid
INNER JOIN pq_line dev ON dev.Id = vol.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 area ON area.Id = gd.Pid
where
line.name = #{param.lineName}
and dev.name = #{param.devName}
and sub.name = #{param.subName}
and gd.name = #{param.gbName}
and area.id = #{param.areaName}
</select>
</mapper>

View File

@@ -0,0 +1,55 @@
package com.njcn.device.pq.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import com.njcn.device.pq.pojo.vo.PqsDeviceUnitVo;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author wr
* @since 2023-08-21
*/
public interface IPqsDeviceUnitService extends IService<PqsDeviceUnit> {
/**
* @param devFlag
* @Description: 查询数据单位树
* @return: java.util.List<com.njcn.device.pq.pojo.vo.PqsDeviceUnitVo>
* @Author: wr
* @Date: 2023/8/21 13:58
*/
List<PqsDeviceUnitVo> nodeList(String devFlag);
/**
* @param unit
* @Description: 添加数据终端
* @return: java.lang.Boolean
* @Author: wr
* @Date: 2023/8/21 14:01
*/
Boolean saveDeviceUnit(PqsDeviceUnit unit);
/**
* @param lineID
* @Description: 根据监测点id查询数据单位
* @return: com.njcn.device.pq.pojo.po.PqsDeviceUnit
* @Author: wr
* @Date: 2023/8/21 14:02
*/
PqsDeviceUnit lineUnitDetail(String lineID);
/**
* @param devID
* @Description: 根据终端id查询数据单位
* @return: com.njcn.device.pq.pojo.po.PqsDeviceUnit
* @Author: wr
* @Date: 2023/8/21 14:02
*/
PqsDeviceUnit devUnitDetail(String devID);
}

View File

@@ -0,0 +1,59 @@
package com.njcn.device.pq.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.device.pq.pojo.po.PqsLineWeight;
import com.njcn.device.pq.pojo.vo.PqsLineWeightVo;
import org.springframework.core.io.InputStreamResource;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author wr
* @since 2023-08-24
*/
public interface IPqsLineWeightService extends IService<PqsLineWeight> {
/**
* @Description: 监测点评分权重修改
* @param lineWeight
* @return: java.lang.Boolean
* @Author: wr
* @Date: 2023/8/24 10:16
*/
Boolean addLineWeight(PqsLineWeight lineWeight);
/***
* @Description: 查询监测点权重
* @param
* @return: java.util.List<com.njcn.device.pq.pojo.vo.PqsLineWeightVo>
* @Author: wr
* @Date: 2023/8/24 10:44
*/
List<PqsLineWeightVo> LineWeightList();
/**
* @Description: 导出模板
* @param
* @return: org.springframework.core.io.InputStreamResource
* @Author: wr
* @Date: 2023/8/24 11:47
*/
InputStreamResource exportTemplate() throws IOException;
/**
* @Description: 批量导入监测点权重
* @param file
* @param response
* @Author: wr
* @Date: 2023/8/24 15:00
*/
void batchWeight(MultipartFile file, HttpServletResponse response);
}

View File

@@ -0,0 +1,119 @@
package com.njcn.device.pq.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.mapper.LineMapper;
import com.njcn.device.pq.mapper.PqsDeviceUnitMapper;
import com.njcn.device.pq.pojo.po.Line;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import com.njcn.device.pq.pojo.vo.PqsDeviceUnitVo;
import com.njcn.device.pq.pojo.vo.TerminalTree;
import com.njcn.device.pq.service.IPqsDeviceUnitService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 服务实现类
* </p>
*
* @author wr
* @since 2023-08-21
*/
@Service
@RequiredArgsConstructor
public class PqsDeviceUnitServiceImpl extends ServiceImpl<PqsDeviceUnitMapper, PqsDeviceUnit> implements IPqsDeviceUnitService {
private final LineMapper lineMapper;
@Override
public List<PqsDeviceUnitVo> nodeList(String devFlag) {
List<Line> lines = lineMapper.selectList(new LambdaQueryWrapper<Line>()
.in(Line::getLevel, Arrays.asList(0, 1, 2, 3))
.eq(Line::getState, 1)
);
List<PqsDeviceUnitVo.DeviceUnit> deviceUnits = this.baseMapper.deviceUnitList(devFlag);
List<TerminalTree> provinceList = lineMapper.getProvinceList(null, 0);
Map<String, String> areaMap = provinceList.stream().collect(Collectors.toMap(TerminalTree::getId, TerminalTree::getName));
lines.stream().filter(x -> x.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode())).forEach(x -> {
if (areaMap.containsKey(x.getId())) {
x.setName(areaMap.get(x.getId()));
}
}
);
List<PqsDeviceUnitVo> pqsDeviceUnitVos = recursionSelectList("0", lines, deviceUnits);
return pqsDeviceUnitVos;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean saveDeviceUnit(PqsDeviceUnit unit) {
PqsDeviceUnit byId = this.getById(unit.getDevIndex());
if (ObjectUtil.isNotNull(byId)) {
return this.updateById(unit);
}
return this.save(unit);
}
@Override
public PqsDeviceUnit lineUnitDetail(String lineID) {
PqsDeviceUnit pqsDeviceUnit = this.baseMapper.deviceUnitByID(lineID);
if(ObjectUtil.isNotNull(pqsDeviceUnit)){
return pqsDeviceUnit;
}
return new PqsDeviceUnit();
}
@Override
public PqsDeviceUnit devUnitDetail(String devID) {
PqsDeviceUnit byId = this.getById(devID);
if(ObjectUtil.isNotNull(byId)){
return byId;
}
return new PqsDeviceUnit();
}
/***
* 递归生成树
* @param id 父节点id
* @param deptInfos
* @param deviceUnits
* @return
*/
private static List<PqsDeviceUnitVo> recursionSelectList(String id, List<Line> deptInfos, List<PqsDeviceUnitVo.DeviceUnit> deviceUnits) {
List<PqsDeviceUnitVo> menuSelectList = new ArrayList<>();
Optional.ofNullable(deptInfos).ifPresent(customers -> customers.stream()
.filter(x -> x.getPid().equals(id))
.forEach(dto -> {
PqsDeviceUnitVo tree = new PqsDeviceUnitVo();
tree.setId(dto.getId());
tree.setName(dto.getName());
if (dto.getLevel().equals(LineBaseEnum.SUB_LEVEL.getCode())) {
List<PqsDeviceUnitVo.DeviceUnit> unit = getUnit(dto.getId(), deviceUnits);
tree.setChildren(unit);
} else {
tree.setChildren(recursionSelectList(dto.getId(), deptInfos, deviceUnits));
}
menuSelectList.add(tree);
}));
return menuSelectList;
}
/**
* 查询数据单位终端信息集合
*
* @param id
* @param deviceUnits
* @return
*/
private static List<PqsDeviceUnitVo.DeviceUnit> getUnit(String id, List<PqsDeviceUnitVo.DeviceUnit> deviceUnits) {
return deviceUnits.stream().filter(x -> x.getPid().equals(id)).collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,148 @@
package com.njcn.device.pq.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.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.device.pq.mapper.LineMapper;
import com.njcn.device.pq.mapper.PqsLineWeightMapper;
import com.njcn.device.pq.pojo.po.PqsLineWeight;
import com.njcn.device.pq.pojo.vo.PqsLineWeightVo;
import com.njcn.device.pq.pojo.vo.TerminalTree;
import com.njcn.device.pq.service.IPqsLineWeightService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.device.pq.utils.ExcelStyleUtil;
import com.njcn.poi.excel.ExcelUtil;
import com.njcn.poi.util.PoiUtil;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.core.io.InputStreamResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* <p>
* 服务实现类
* </p>
*
* @author wr
* @since 2023-08-24
*/
@Service
@RequiredArgsConstructor
public class PqsLineWeightServiceImpl extends ServiceImpl<PqsLineWeightMapper, PqsLineWeight> implements IPqsLineWeightService {
private final LineMapper lineMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean addLineWeight(PqsLineWeight lineWeight) {
PqsLineWeight weight = this.getById(lineWeight.getLineIndex());
if (ObjectUtil.isNotNull(weight)) {
return this.updateById(lineWeight);
}
return this.save(lineWeight);
}
@Override
public List<PqsLineWeightVo> LineWeightList() {
List<PqsLineWeightVo> lines = this.baseMapper.selectWeight();
List<TerminalTree> provinceList = lineMapper.getProvinceList(null, 0);
Map<String, String> areaMap = provinceList.stream().collect(Collectors.toMap(TerminalTree::getId, TerminalTree::getName));
lines.stream().forEach(x -> {
if (areaMap.containsKey(x.getAreaName())) {
x.setAreaName(areaMap.get(x.getAreaName()));
}
}
);
return lines;
}
@Override
public InputStreamResource exportTemplate() throws IOException {
ExportParams exportParams = new ExportParams("批量导入模板(所有字段均是必填,请严格按照模板标准填入数据)", "终端入网检测录入信息");
exportParams.setStyle(ExcelStyleUtil.class);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, PqsLineWeightVo.WeightExcel.class, new ArrayList<PqsLineWeightVo.WeightExcel>());
//临时缓冲区
ByteArrayOutputStream out = new ByteArrayOutputStream();
//创建临时文件
workbook.write(out);
byte[] bookByteAry = out.toByteArray();
InputStream in = new ByteArrayInputStream(bookByteAry);
InputStreamResource inputStreamResource = new InputStreamResource(in);
return inputStreamResource;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void batchWeight(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<PqsLineWeightVo.WeightExcel> weightList = ExcelImportUtil.importExcelMore(file.getInputStream(), PqsLineWeightVo.WeightExcel.class, params);
//如果存在非法数据,将不合格的数据导出
if (weightList.isVerifyFail()) {
PoiUtil.exportFileByWorkbook(weightList.getFailWorkbook(), "非法监测点权重录入信息.xlsx", response);
} else {
saveWeightBase(weightList.getList());
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void saveWeightBase(List<PqsLineWeightVo.WeightExcel> weightList) {
List<PqsLineWeightVo.Msg> weightExcelMsg = new ArrayList<>();
List<PqsLineWeight> info = new ArrayList<>();
List<TerminalTree> provinceList = lineMapper.getProvinceList(null, 0);
Map<String, String> areaMap = provinceList.stream().collect(Collectors.toMap(TerminalTree::getName, TerminalTree::getId));
weightList.stream().forEach(x -> {
if (areaMap.containsKey(x.getAreaName())) {
x.setAreaName(areaMap.get(x.getAreaName()));
}
}
);
for (PqsLineWeightVo.WeightExcel weightExcel : weightList) {
String lineID = this.baseMapper.getLineID(weightExcel);
if(StrUtil.isNotBlank(lineID)){
PqsLineWeight weight = BeanUtil.copyProperties(weightExcel, PqsLineWeight.class);
weight.setLineIndex(lineID);
info.add(weight);
}else{
PqsLineWeightVo.Msg msg = BeanUtil.copyProperties(weightExcel, PqsLineWeightVo.Msg.class);
msg.setMsg("未匹配到监测点对象,请仔细请检查/区域/供电公司/变电站名称/装置名称/监测点名称,是否对应正确");
weightExcelMsg.add(msg);
}
}
if(CollUtil.isNotEmpty(info)){
this.saveOrUpdateBatch(info);
}
//错误信息不为空则以excel的形式输出到前台
if (CollectionUtil.isNotEmpty(weightExcelMsg)) {
ExcelUtil.exportExcel("失败列表.xlsx", PqsLineWeightVo.Msg.class, weightExcelMsg);
}
}
}