1.增加导出模板下拉框设置

2.支持台区导入和发电用户导入模板
3.添加灿能云远程监测点接口,流量信息
This commit is contained in:
wr
2023-11-24 16:08:12 +08:00
parent e1c8983800
commit a8c8f3dff6
22 changed files with 1283 additions and 41 deletions

View File

@@ -0,0 +1,198 @@
package com.njcn.device.pms.pojo.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.njcn.device.pms.utils.ExcelValid;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
* 台区导入模板
* </p>
*
* @author hongawen
* @since 2022-10-14
*/
@Data
public class PowerDistributionAreaExcel implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "*台区编号", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*台区编号")
@ExcelValid(message = "台区编号不能为空")
private String id;
@Excel(name = "*台区名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*台区名称")
@ExcelValid(message = "台区名称不能为空")
private String name;
@Excel(name = "*组织机构名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*组织机构名称")
@ExcelValid(message = "组织机构名称不能为空")
private String orgName;
@Excel(name = "*组织机构ID", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*组织机构ID")
@ExcelValid(message = "组织机构ID不能为空")
private String orgId;
@Excel(name = "*运维单位名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*运维单位名称")
@ExcelValid(message = "运维单位名称不能为空")
private String operationName;
@Excel(name = "*运维单位ID", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*运维单位ID")
@ExcelValid(message = "运维单位ID不能为空")
private String operationId;
@Excel(name = "*变电站名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*变电站名称")
@ExcelValid(message = "变电站名称不能为空")
private String powerrName;
@Excel(name = "*变电站ID", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*变电站ID")
@ExcelValid(message = "变电站ID不能为空")
private String powerStationId;
@Excel(name = "*监测线路名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*监测线路名称")
@ExcelValid(message = "监测线路名称不能为空")
private String lineName;
@Excel(name = "*所属线路ID", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*所属线路ID")
@ExcelValid(message = "所属线路ID不能为空")
private String lineId;
@Excel(name = "*电压等级", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*电压等级")
@ExcelValid(message = "电压等级不能为空")
private String voltageLevel;
@Excel(name = "*配变容量", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*配变容量")
@ExcelValid(message = "配变容量不能为空")
private Float pCapacity;
@Excel(name = "*地区特征", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*地区特征")
@ExcelValid(message = "地区特征不能为空")
private String regionalism;
@Excel(name = "*是否农网", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*是否农网")
@ExcelValid(message = "是否农网不能为空")
private String ifRuralPowerGrid;
@Excel(name = "*使用性质", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*使用性质")
@ExcelValid(message = "使用性质不能为空")
private String natureOfUse;
@Excel(name = "*供电半径", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*供电半径")
@ExcelValid(message = "供电半径不能为空")
private Float powerSupplyRadius;
@Excel(name = "*供电线路总长度", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*供电线路总长度")
@ExcelValid(message = "供电线路总长度不能为空")
private Float lineLength;
@Excel(name = "*运行状态", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*运行状态")
@ExcelValid(message = "运行状态不能为空")
private String state;
@Excel(name = "*分布式光伏用户数", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*分布式光伏用户数")
@ExcelValid(message = "分布式光伏用户数不能为空")
private Integer distributedPhotovoltaicNum;
@Excel(name = "*分布式光伏总装机容量", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*分布式光伏总装机容量")
@ExcelValid(message = "分布式光伏总装机容量不能为空")
private Float photovoltaicCapacity;
@Excel(name = "*是否有电动汽车接入", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*是否有电动汽车接入")
@ExcelValid(message = "是否有电动汽车接入不能为空")
private String ifBevAp;
@Excel(name = "*接入负荷类型", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*接入负荷类型")
@ExcelValid(message = "接入负荷类型不能为空")
private String apLoadType;
@Excel(name = "*是否是上送国网监测点", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*是否是上送国网监测点")
@ExcelValid(message = "是否是上送国网监测点不能为空")
private String isUpToGrid;
@Data
public static class ErrMsg extends PowerDistributionAreaExcel {
@Excel(name = "错误信息", width = 50)
@ColumnWidth(60)
@ExcelProperty(value = "错误信息")
private String errMsg;
}
}

View File

@@ -0,0 +1,158 @@
package com.njcn.device.pms.pojo.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.njcn.device.pms.utils.ExcelValid;
import lombok.Data;
import java.io.Serializable;
/**
* 发电用户导入模板
*/
@Data
public class PowerGenerationUserExcel implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "*用户编号", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*用户编号")
@ExcelValid(message = "用户编号不能为空")
private String id;
@Excel(name = "*用户名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*用户名称")
@ExcelValid(message = "用户名称不能为空")
private String name;
@Excel(name = "*组织机构名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*组织机构名称")
@ExcelValid(message = "组织机构名称不能为空")
private String orgName;
@Excel(name = "*组织机构ID", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*组织机构ID")
@ExcelValid(message = "组织机构ID不能为空")
private String orgId;
@Excel(name = "*运维单位名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*运维单位名称")
@ExcelValid(message = "运维单位名称不能为空")
private String operationName;
@Excel(name = "*运维单位ID", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*运维单位ID")
@ExcelValid(message = "运维单位ID不能为空")
private String operationId;
@Excel(name = "*电源类别", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*电源类别")
@ExcelValid(message = "电源类别不能为空")
private String powerCategory;
@Excel(name = "*电站类型", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*电站类型")
@ExcelValid(message = "电站类型不能为空")
private String powerStationType;
@Excel(name = "*发电方式", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*发电方式")
@ExcelValid(message = "发电方式不能为空")
private String powerGenerationMode;
@Excel(name = "*并网电压等级", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*并网电压等级")
@ExcelValid(message = "并网电压等级不能为空")
private String voltageLevel;
@Excel(name = "*总装机容量", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*总装机容量")
@ExcelValid(message = "总装机容量不能为空")
private Float sourceCapacity;
@Excel(name = "*并网日期(yyyy-MM-dd)", importFormat = "yyyy-MM-dd", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*并网日期(yyyy-MM-dd)")
@ExcelValid(message = "并网日期(yyyy-MM-dd)不能为空")
private String connectionDate;
@Excel(name = "*能源消纳方式", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*能源消纳方式")
@ExcelValid(message = "能源消纳方式不能为空")
private String connectionMode;
@Excel(name = "*客户状态", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*客户状态")
@ExcelValid(message = "客户状态不能为空")
private String gcStat;
@Excel(name = "*变电站编号", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*变电站编号")
@ExcelValid(message = "变电站编号不能为空")
private String powerStationId;
@Excel(name = "*变电站名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*变电站名称")
@ExcelValid(message = "变电站名称不能为空")
private String powerStationName;
@Excel(name = "*供电线路编号", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*供电线路编号")
@ExcelValid(message = "供电线路编号不能为空")
private String lineId;
@Excel(name = "*供电线路名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*供电线路名称")
@ExcelValid(message = "供电线路名称不能为空")
private String lineName;
@Excel(name = "*供电台区", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*供电台区")
@ExcelValid(message = "供电台区不能为空")
private String platformId;
@Excel(name = "*供电台区名称", width = 30)
@ColumnWidth(30)
@ExcelProperty(value = "*供电台区名称")
@ExcelValid(message = "供电台区名称不能为空")
private String platformName;
@Excel(name = "*是否是上送国网监测点", replace = {"否_0", "是_1"}, width = 40)
@ColumnWidth(45)
@ExcelProperty(value = "*是否是上送国网监测点")
@ExcelValid(message = "是否是上送国网监测点不能为空")
private String isUpToGrid;
@Data
public static class ErrMsg extends PowerGenerationUserExcel {
@Excel(name = "错误信息", width = 50)
@ColumnWidth(60)
@ExcelProperty(value = "错误信息")
private String errMsg;
}
}

View File

@@ -43,6 +43,7 @@ public class GeneratrixWire extends BaseEntity {
/**
* 关联中台的母线id
*/
@TableField(exist = false)
private String relationId;

View File

@@ -1,5 +1,6 @@
package com.njcn.device.pms.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;
@@ -72,6 +73,7 @@ public class StatationStat extends BaseEntity {
/**
* 关联中台的母线id
*/
@TableField(exist = false)
private String relationId;

View File

@@ -0,0 +1,16 @@
package com.njcn.device.pms.utils;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p>Excel导入必填校验注解</p>
*
*/
@Target({ ElementType.FIELD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface ExcelValid {
String message() default "导入有未填入的字段";
}

View File

@@ -0,0 +1,96 @@
package com.njcn.device.pms.utils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.CharsetUtil;
import com.alibaba.excel.EasyExcel;
import com.njcn.system.pojo.po.DictData;
import lombok.SneakyThrows;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author wr
* @description
* @date 2023/11/23 19:48
*/
public class PubUtil {
/**
* 导入模拟判断是否为空
* @param object
* @return
*/
@SneakyThrows
public static String isObjNull(Object object) {
Field[] fields = object.getClass().getSuperclass().getDeclaredFields();
StringBuilder builder = new StringBuilder();
for (Field field : fields) {
//设置可访问
field.setAccessible(true);
//属性的值
Object fieldValue = field.get(object);
//是否包含必填校验注解
boolean isExcelValid = field.isAnnotationPresent(ExcelValid.class);
if (isExcelValid && Objects.isNull(fieldValue)) {
builder.append(field.getAnnotation(ExcelValid.class).message() + "; ");
}
}
return builder.toString();
}
public static String subString(String name){
String replace ;
if(name.equals("古冶")){
replace = name
.replace("古冶","古冶供电中心");
}else{
replace = name.replace("国网冀北", "")
.replace("唐山市","")
.replace("双桥","双桥区")
.replace("张家口","国网张家口")
.replace("唐山","国网唐山")
.replace("国网昌黎县供电公司","昌黎县供电公司")
.replace("双滦客服中心","双滦区供电中心")
.replace("营子客服中心","营子区供电中心")
.replace("安次客户服务分中心","安次供电中心")
.replace("广阳客户服务分中心","广阳供电中心")
.replace("国网卢龙县供电公司","卢龙县供电公司")
.replace("国网青龙县供电公司","青龙县供电公司")
.replace("广阳客户服务分中心","广阳供电中心")
.replace("国网秦皇岛市抚宁区供电公司","抚宁县供电公司")
.replace("滦县供电公司","滦南县供电公司")
.replace("下花园客户服务分中心","下花园区供电中心")
.replace("宣化客户服务分中心","宣化区供电中心")
.replace("客户服务中心","供电公司")
.replace("有限","")
.replace("","");
}
return replace;
}
public static String getDicById(String name, List<DictData> dictData) {
List<DictData> dictDataList = dictData.stream().filter(x -> x.getName().indexOf(name) != -1).collect(Collectors.toList());
if (CollUtil.isNotEmpty(dictDataList)) {
return dictDataList.get(0).getId();
}
return "";
}
public static void exportExcel(String fileName, List<?> list,Class<?> t, HttpServletResponse response) {
try (ServletOutputStream outputStream = response.getOutputStream()) {
fileName = URLEncoder.encode(fileName, CharsetUtil.UTF_8);
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
response.setContentType("application/octet-stream;charset=UTF-8");
EasyExcel.write(outputStream,t).sheet("sheet").doWrite(list);
} catch (IOException e) {
e.printStackTrace();
}
}
}