1.数据单位管理
2.谐波模块-excel和word报告数据单位调整 3.监测点权重管理
This commit is contained in:
@@ -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) ;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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 = "2~50次谐波电压含有率")
|
||||
private String vharmonicRate = "%";
|
||||
|
||||
@TableField("I_HARMONIC")
|
||||
@ApiModelProperty(value = "2~50次谐波电流有效值")
|
||||
private String iharmonic = "A";
|
||||
|
||||
@TableField("P_HARMONIC")
|
||||
@ApiModelProperty(value = "2~50次谐波有功功率")
|
||||
private String pharmonic = "kW";
|
||||
|
||||
@TableField("I_IHARMONIC")
|
||||
@ApiModelProperty(value = "0.5~49.5次间谐波电流有效值")
|
||||
private String iiharmonic = "A";
|
||||
|
||||
@TableField("POSITIVE_V")
|
||||
@ApiModelProperty(value = "正序电压")
|
||||
private String positiveV = "kV";
|
||||
|
||||
@TableField("NO_POSITIVE_V")
|
||||
@ApiModelProperty(value = "零序负序电压")
|
||||
private String noPositiveV = "V";
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
@@ -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 = "2~50次谐波电压含有率")
|
||||
private String vharmonicRate;
|
||||
|
||||
@ApiModelProperty(value = "2~50次谐波电流有效值")
|
||||
private String iharmonic;
|
||||
|
||||
@ApiModelProperty(value = "2~50次谐波有功功率")
|
||||
private String pharmonic;
|
||||
|
||||
@ApiModelProperty(value = "0.5~49.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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,22 @@ package com.njcn.harmonic.controller;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.pms.api.MonitorClient;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import com.njcn.device.pq.api.DeviceUnitClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.harmonic.pojo.param.ReportQueryParam;
|
||||
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
|
||||
import com.njcn.harmonic.pojo.po.report.EnumPass;
|
||||
import com.njcn.harmonic.pojo.po.report.OverLimitInfo;
|
||||
import com.njcn.harmonic.pojo.po.report.Pass;
|
||||
@@ -22,6 +29,9 @@ import com.njcn.harmonic.service.ReportService;
|
||||
import com.njcn.harmonic.utils.WordUtil2;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.ThemeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.Theme;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -37,6 +47,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@@ -46,8 +57,6 @@ import java.util.*;
|
||||
@AllArgsConstructor
|
||||
public class ExportModelController extends BaseController {
|
||||
|
||||
|
||||
|
||||
// 非谐波数据
|
||||
List<ReportTarget> listVirtual;
|
||||
List<ReportTarget> listPower;
|
||||
@@ -67,14 +76,15 @@ public class ExportModelController extends BaseController {
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final ThemeFeignClient themeFeignClient;
|
||||
private final ReportService reportService;
|
||||
private final DeviceUnitClient deviceUnitClient;
|
||||
|
||||
@PostMapping("/exportModel")
|
||||
@ApiOperation("word报告")
|
||||
public String exportworld(HttpServletResponse response,
|
||||
String startTime, String endTime, Integer type, String lineIndex,
|
||||
String name, String reportNumber, String crmName,
|
||||
MultipartFile file) throws IOException {
|
||||
|
||||
public HttpResult<String> exportWorld(HttpServletResponse response,
|
||||
String startTime, String endTime, Integer type, String lineIndex,
|
||||
String name, String reportNumber, String crmName,
|
||||
MultipartFile file) throws IOException {
|
||||
String methodDescribe = getMethodDescribe("exportWorld");
|
||||
//获取监测点信息
|
||||
String bdname = "";
|
||||
Integer pttype = 0;
|
||||
@@ -152,7 +162,7 @@ public class ExportModelController extends BaseController {
|
||||
|
||||
|
||||
if (0 == overLimitData.getOverLimitRate().size()) {
|
||||
return "datafail";
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "dataFail", methodDescribe);
|
||||
}
|
||||
|
||||
String rtfPath = "";
|
||||
@@ -188,15 +198,17 @@ public class ExportModelController extends BaseController {
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
flagPath = false;
|
||||
return "readerror";
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "readError", methodDescribe);
|
||||
} finally {
|
||||
if (ins != null) {
|
||||
ins.close();
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> reportmap = new HashMap<String, Object>();// 报告Map
|
||||
|
||||
Map<String, Object> reportmap = new HashMap<>();// 报告Map
|
||||
//数据单位
|
||||
PqsDeviceUnit deviceUnit = deviceUnitClient.lineUnitDetail(lineIndex).getData();
|
||||
reportmap.putAll(unitMap(deviceUnit));
|
||||
reportmap.put("$atype$", atype);
|
||||
reportmap.put("$btype$", btype);
|
||||
reportmap.put("$ctype$", ctype);
|
||||
@@ -356,9 +368,9 @@ public class ExportModelController extends BaseController {
|
||||
iCount++;
|
||||
}
|
||||
// 假如所有的数据都为null,则返回(所选的时间段内未找到数据)
|
||||
if (iCount == reportmap.size())
|
||||
return "exportworld";// 未找到数据
|
||||
|
||||
if (iCount == reportmap.size()){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "exportWorld", methodDescribe);
|
||||
}
|
||||
// 基本数据判断
|
||||
for (int i = 0; i < 3; i++) {
|
||||
String tmpstrMap = "A";
|
||||
@@ -637,16 +649,16 @@ public class ExportModelController extends BaseController {
|
||||
}
|
||||
|
||||
if (maxValue > limit) {
|
||||
tmpstrResultFre += "最大值为:" + valueOfFreValue.getFmaxValue().toString() + "Hz";
|
||||
tmpstrResultFre += "最大值为:" + valueOfFreValue.getFmaxValue().toString() + deviceUnit.getUnitFrequencyDev();
|
||||
}
|
||||
if (minValue > limit) {
|
||||
tmpstrResultFre += "最小值为:" + valueOfFreValue.getMinValue().toString() + "Hz";
|
||||
tmpstrResultFre += "最小值为:" + valueOfFreValue.getMinValue().toString() + deviceUnit.getUnitFrequencyDev();
|
||||
}
|
||||
if (aveValue > limit) {
|
||||
tmpstrResultFre += "平均值为:" + valueOfFreValue.getMeanValue().toString() + "Hz";
|
||||
tmpstrResultFre += "平均值为:" + valueOfFreValue.getMeanValue().toString() + deviceUnit.getUnitFrequencyDev();
|
||||
}
|
||||
if (cp95Value > limit) {
|
||||
tmpstrResultFre += "95%概率值为:" + valueOfFreValue.getCp95Value().toString() + "Hz";
|
||||
tmpstrResultFre += "95%概率值为:" + valueOfFreValue.getCp95Value().toString() + deviceUnit.getUnitFrequencyDev();
|
||||
}
|
||||
|
||||
if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) {
|
||||
@@ -662,12 +674,12 @@ public class ExportModelController extends BaseController {
|
||||
|
||||
if ("".equals(tmpstrResultFre)) {
|
||||
reportmap.put("$FV0R$", "合格");// 三张大表取值
|
||||
strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差均满足国标限值(±" + valueOfFreLimit + "Hz)的要求。";
|
||||
strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差均满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev()+")的要求。";
|
||||
} else {
|
||||
reportmap.put("$FV0R$", "不合格");// 三张大表取值
|
||||
strAnalysis += tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit + "Hz)的要求。";
|
||||
strAnalysis += tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev()+")的要求。";
|
||||
strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差" + tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit
|
||||
+ "Hz)的要求。";
|
||||
+ deviceUnit.getUnitFrequencyDev()+")的要求。";
|
||||
}
|
||||
|
||||
reportmap.put("$ResultFre$", strResultFre);
|
||||
@@ -1194,10 +1206,65 @@ public class ExportModelController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
log.error("获取报告发生异常,异常是" + e.getMessage());
|
||||
}
|
||||
|
||||
return "success";
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据单位信息 重组
|
||||
* @param deviceUnit 数据单位对象
|
||||
* @return
|
||||
*/
|
||||
private Map<String,String> unitMap(PqsDeviceUnit deviceUnit){
|
||||
List<DictData> dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData();
|
||||
Map<String,String> unit=new HashMap<>();
|
||||
List<String> list = dictData.stream().map(DictData::getCode).collect(Collectors.toList());
|
||||
for (String s : list) {
|
||||
//有效值
|
||||
if(s.equals(DicDataEnum.EFFECTIVE.getCode())){
|
||||
unit.put("$"+s+"_i$",deviceUnit.getIeffective());
|
||||
unit.put("$"+s+"_v$",deviceUnit.getLineVoltage());
|
||||
}
|
||||
//功率
|
||||
if(s.equals(DicDataEnum.POWER.getCode())){
|
||||
unit.put("$"+s+"_p$",deviceUnit.getTotalActiveP());
|
||||
unit.put("$"+s+"_q$",deviceUnit.getTotalNoP());
|
||||
unit.put("$"+s+"_s$",deviceUnit.getTotalViewP());
|
||||
}
|
||||
//畸变率
|
||||
if(s.equals(DicDataEnum.DISTORTION.getCode())){
|
||||
unit.put("$"+s+"_v$",deviceUnit.getVdistortion());
|
||||
}
|
||||
//电压偏差
|
||||
if(s.equals(DicDataEnum.VOLTAGE.getCode())){
|
||||
unit.put("$"+s+"_v$",deviceUnit.getVoltageDev());
|
||||
}
|
||||
//频率
|
||||
if(s.equals(DicDataEnum.UNIT_FREQUENCY.getCode())){
|
||||
unit.put("$"+s+"_freq$",deviceUnit.getUnitFrequency());
|
||||
unit.put("$"+s+"_freqDev$",deviceUnit.getUnitFrequencyDev());
|
||||
}
|
||||
//三项不平衡度
|
||||
if(s.equals(DicDataEnum.UNBALANCE.getCode())){
|
||||
unit.put("$"+s+"_v$","%");
|
||||
unit.put("$"+s+"_vPos$",deviceUnit.getPositiveV());
|
||||
unit.put("$"+s+"_vNeg$",deviceUnit.getNoPositiveV());
|
||||
unit.put("$"+s+"_vZero$",deviceUnit.getNoPositiveV());
|
||||
unit.put("$"+s+"_i$","%");
|
||||
unit.put("$"+s+"_iPos$","A");
|
||||
unit.put("$"+s+"_iNeg$","A");
|
||||
unit.put("$"+s+"_iZero$","A");
|
||||
}
|
||||
//基波
|
||||
if(s.equals(DicDataEnum.FUND.getCode())){
|
||||
unit.put("$"+s+"_i$",deviceUnit.getIfund());
|
||||
unit.put("$"+s+"_v$",deviceUnit.getVfundEffective());
|
||||
|
||||
}
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析base64,返回图片所在路径
|
||||
*
|
||||
|
||||
@@ -7,10 +7,11 @@ import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.FileUtil;
|
||||
import com.njcn.device.pq.api.DeviceUnitClient;
|
||||
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
|
||||
import com.njcn.harmonic.enums.HarmonicResponseEnum;
|
||||
import com.njcn.harmonic.mapper.DeptTempMapper;
|
||||
import com.njcn.harmonic.mapper.EleEpdMapper;
|
||||
@@ -23,6 +24,10 @@ import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import com.njcn.influx.service.CommonService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.harmonic.pojo.po.ExcelRpt;
|
||||
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
|
||||
@@ -39,7 +44,6 @@ import com.njcn.web.utils.WebUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -48,10 +52,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -80,6 +81,9 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
|
||||
private final CommonService commonService;
|
||||
|
||||
private final DeviceUnitClient deviceUnitClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
@Override
|
||||
public boolean addCustomReportTemplate(ReportTemplateParam reportTemplateParam) {
|
||||
@@ -421,6 +425,8 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(endList)) {
|
||||
//数据单位信息
|
||||
Map<String, String> unit = unitMap(reportSearchParam.getLineId());
|
||||
//进行反向赋值到模板
|
||||
//1、根据itemName分组
|
||||
Map<String, List<ReportTemplateDTO>> assMap = endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
|
||||
@@ -444,6 +450,16 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
}
|
||||
son.set("v", str);
|
||||
}
|
||||
//解决数据单位问题 @指标#类型@
|
||||
if (v.charAt(0) == '@' && v.contains("#")) {
|
||||
String replace = v.replace("@", "");
|
||||
if(unit.containsKey(replace)){
|
||||
son.set("v", unit.get(replace));
|
||||
}else{
|
||||
son.set("v", "/");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -468,6 +484,61 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
return newContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据单位信息
|
||||
* @param lineID
|
||||
* @return
|
||||
*/
|
||||
private Map<String,String> unitMap(String lineID){
|
||||
PqsDeviceUnit deviceUnit = deviceUnitClient.lineUnitDetail(lineID).getData();
|
||||
List<DictData> dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData();
|
||||
Map<String,String> unit=new HashMap<>();
|
||||
List<String> list = dictData.stream().map(DictData::getCode).collect(Collectors.toList());
|
||||
for (String s : list) {
|
||||
//有效值
|
||||
if(s.equals(DicDataEnum.EFFECTIVE.getCode())){
|
||||
unit.put(s+"#i",deviceUnit.getIeffective());
|
||||
unit.put(s+"#v",deviceUnit.getLineVoltage());
|
||||
}
|
||||
//功率
|
||||
if(s.equals(DicDataEnum.POWER.getCode())){
|
||||
unit.put(s+"#p",deviceUnit.getTotalActiveP());
|
||||
unit.put(s+"#q",deviceUnit.getTotalNoP());
|
||||
unit.put(s+"#s",deviceUnit.getTotalViewP());
|
||||
}
|
||||
//畸变率
|
||||
if(s.equals(DicDataEnum.DISTORTION.getCode())){
|
||||
unit.put(s+"#v",deviceUnit.getVdistortion());
|
||||
}
|
||||
//电压偏差
|
||||
if(s.equals(DicDataEnum.VOLTAGE.getCode())){
|
||||
unit.put(s+"#v",deviceUnit.getVoltageDev());
|
||||
}
|
||||
//频率
|
||||
if(s.equals(DicDataEnum.UNIT_FREQUENCY.getCode())){
|
||||
unit.put(s+"#freq",deviceUnit.getUnitFrequency());
|
||||
unit.put(s+"#freqDev",deviceUnit.getUnitFrequencyDev());
|
||||
}
|
||||
//三项不平衡度
|
||||
if(s.equals(DicDataEnum.UNBALANCE.getCode())){
|
||||
unit.put(s+"#v","%");
|
||||
unit.put(s+"#vPos",deviceUnit.getPositiveV());
|
||||
unit.put(s+"#vNeg",deviceUnit.getNoPositiveV());
|
||||
unit.put(s+"#vZero",deviceUnit.getNoPositiveV());
|
||||
unit.put(s+"#i","%");
|
||||
unit.put(s+"#iPos","A");
|
||||
unit.put(s+"#iNeg","A");
|
||||
unit.put(s+"#iZero","A");
|
||||
}
|
||||
//基波
|
||||
if(s.equals(DicDataEnum.FUND.getCode())){
|
||||
unit.put(s+"#i",deviceUnit.getIfund());
|
||||
unit.put(s+"#v",deviceUnit.getVfundEffective());
|
||||
|
||||
}
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装influxDB查询sql,查询value并封装endlist
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -9,12 +9,13 @@ import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.FileUtil;
|
||||
import com.njcn.device.pq.api.DeptLineFeignClient;
|
||||
import com.njcn.device.pq.api.DeviceUnitClient;
|
||||
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
|
||||
import com.njcn.harmonic.enums.HarmonicResponseEnum;
|
||||
import com.njcn.harmonic.pojo.dto.ReportTemplateDTO;
|
||||
import com.njcn.harmonic.pojo.po.ExcelRpt;
|
||||
@@ -29,17 +30,15 @@ import com.njcn.prepare.harmonic.mapper.mysql.line.ExcelRptMapper;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.line.ExcelRptTempMapper;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.ReportService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@@ -65,6 +64,9 @@ public class ReportServiceImpl implements ReportService {
|
||||
private final ExcelRptMapper excelRptMapper;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final DeviceUnitClient deviceUnitClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -131,7 +133,7 @@ public class ReportServiceImpl implements ReportService {
|
||||
|
||||
//根据数据填充content
|
||||
if (CollUtil.isNotEmpty(endList)) {
|
||||
contentChange(jsonArray, endList);
|
||||
contentChange(jsonArray, endList,lineId);
|
||||
}
|
||||
|
||||
//存入报表库
|
||||
@@ -196,7 +198,9 @@ public class ReportServiceImpl implements ReportService {
|
||||
* @param jsonArray 参数
|
||||
* @return 结果
|
||||
*/
|
||||
private void contentChange(JSONArray jsonArray, List<ReportTemplateDTO> endList) {
|
||||
private void contentChange(JSONArray jsonArray, List<ReportTemplateDTO> endList,String lineID) {
|
||||
//数据单位信息
|
||||
Map<String, String> unit = unitMap(lineID);
|
||||
//进行反向赋值到模板
|
||||
//1、根据itemName分组
|
||||
Map<String, List<ReportTemplateDTO>> assMap = endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
|
||||
@@ -220,6 +224,16 @@ public class ReportServiceImpl implements ReportService {
|
||||
}
|
||||
son.set("v", str);
|
||||
}
|
||||
//解决数据单位问题 @指标#类型@
|
||||
if (v.charAt(0) == '@' && v.contains("#")) {
|
||||
String replace = v.replace("@", "");
|
||||
if(unit.containsKey(replace)){
|
||||
son.set("v", unit.get(replace));
|
||||
}else{
|
||||
son.set("v", "/");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -276,6 +290,61 @@ public class ReportServiceImpl implements ReportService {
|
||||
return reportTemplateDTOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据单位信息
|
||||
* @param lineID
|
||||
* @return
|
||||
*/
|
||||
private Map<String,String> unitMap(String lineID){
|
||||
PqsDeviceUnit deviceUnit = deviceUnitClient.lineUnitDetail(lineID).getData();
|
||||
Map<String,String> unit=new HashMap<>();
|
||||
List<DictData> dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData();
|
||||
List<String> list = dictData.stream().map(DictData::getCode).collect(Collectors.toList());
|
||||
for (String s : list) {
|
||||
//有效值
|
||||
if(s.equals(DicDataEnum.EFFECTIVE.getCode())){
|
||||
unit.put(s+"#i",deviceUnit.getIeffective());
|
||||
unit.put(s+"#v",deviceUnit.getLineVoltage());
|
||||
}
|
||||
//功率
|
||||
if(s.equals(DicDataEnum.POWER.getCode())){
|
||||
unit.put(s+"#p",deviceUnit.getTotalActiveP());
|
||||
unit.put(s+"#q",deviceUnit.getTotalNoP());
|
||||
unit.put(s+"#s",deviceUnit.getTotalViewP());
|
||||
}
|
||||
//畸变率
|
||||
if(s.equals(DicDataEnum.DISTORTION.getCode())){
|
||||
unit.put(s+"#v",deviceUnit.getVdistortion());
|
||||
}
|
||||
//电压偏差
|
||||
if(s.equals(DicDataEnum.VOLTAGE.getCode())){
|
||||
unit.put(s+"#v",deviceUnit.getVoltageDev());
|
||||
}
|
||||
//频率
|
||||
if(s.equals(DicDataEnum.UNIT_FREQUENCY.getCode())){
|
||||
unit.put(s+"#freq",deviceUnit.getUnitFrequency());
|
||||
unit.put(s+"#freqDev",deviceUnit.getUnitFrequencyDev());
|
||||
}
|
||||
//三项不平衡度
|
||||
if(s.equals(DicDataEnum.UNBALANCE.getCode())){
|
||||
unit.put(s+"#v","%");
|
||||
unit.put(s+"#vPos",deviceUnit.getPositiveV());
|
||||
unit.put(s+"#vNeg",deviceUnit.getNoPositiveV());
|
||||
unit.put(s+"#vZero",deviceUnit.getNoPositiveV());
|
||||
unit.put(s+"#i","%");
|
||||
unit.put(s+"#iPos","A");
|
||||
unit.put(s+"#iNeg","A");
|
||||
unit.put(s+"#iZero","A");
|
||||
}
|
||||
//基波
|
||||
if(s.equals(DicDataEnum.FUND.getCode())){
|
||||
unit.put(s+"#i",deviceUnit.getIfund());
|
||||
unit.put(s+"#v",deviceUnit.getVfundEffective());
|
||||
|
||||
}
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
/**
|
||||
* 组装influxDB查询sql,查询value并封装endlist
|
||||
*
|
||||
|
||||
@@ -476,6 +476,17 @@ public enum DicDataEnum {
|
||||
AUTHORITY_TRANSFER("权限转移","Authority_transfer"),
|
||||
DATA_RECOVERY("数据恢复","Data_recovery"),
|
||||
|
||||
/**
|
||||
* 谐波数据报表,数据单位类别
|
||||
*/
|
||||
EFFECTIVE("有效值","effective"),
|
||||
POWER("功率","power"),
|
||||
DISTORTION("畸变率","distortion"),
|
||||
VOLTAGE("电压偏差","voltage"),
|
||||
UNIT_FREQUENCY("频率","unitFrequency"),
|
||||
UNBALANCE("三项不平横","unbalance"),
|
||||
FUND("基波","fund"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
|
||||
@@ -95,7 +95,9 @@ public enum DicDataTypeEnum {
|
||||
|
||||
APP_BASE_INFORMATION_TYPE("app基础信息类型","appInformationType"),
|
||||
|
||||
APP_DEVICE_EVENT_TYPE("app设备事件类型","appDeviceEventType")
|
||||
APP_DEVICE_EVENT_TYPE("app设备事件类型","appDeviceEventType"),
|
||||
|
||||
DEVICE_UNIT("数据单位类型","Device_Unit")
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user