1.增加导出模板下拉框设置
2.支持台区导入和发电用户导入模板 3.添加灿能云远程监测点接口,流量信息
This commit is contained in:
@@ -2,6 +2,8 @@ package com.njcn.poi.excel;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.export.ExcelExportService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import com.njcn.web.utils.HttpServletUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -20,6 +22,8 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -54,13 +58,28 @@ public class ExcelUtil {
|
||||
* @param fileName 文件名
|
||||
*/
|
||||
public static void exportExcel(ExportParams exportParams,String fileName, Class<?> pojoClass, Collection<?> dataSet) {
|
||||
exportExcelPullDown(exportParams,fileName,null ,pojoClass, dataSet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 指定名称、数据下载报表(带指定标题将*显示比必填信息),带有下拉信息
|
||||
*
|
||||
* @param fileName 文件名
|
||||
*/
|
||||
public static void exportExcelPullDown(ExportParams exportParams, String fileName, List<PullDown> pullDowns, Class<?> pojoClass, Collection<?> dataSet) {
|
||||
HttpServletResponse response = HttpServletUtil.getResponse();
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
fileName = URLEncoder.encode(fileName, CharsetUtil.UTF_8);
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName );
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, dataSet);
|
||||
if(CollUtil.isNotEmpty(pullDowns)){
|
||||
for (PullDown pullDown : pullDowns) {
|
||||
ExcelUtil.selectList(workbook, pullDown.getFirstCol(), pullDown.getLastCol(), pullDown.getStrings().toArray(new String[]{}));
|
||||
}
|
||||
}
|
||||
Sheet sheetAt = workbook.getSheetAt(0);
|
||||
//获取列数
|
||||
int physicalNumberOfCells = sheetAt.getRow(0).getPhysicalNumberOfCells();
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.poi.excel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wr 设置下拉
|
||||
* @description
|
||||
* @date 2023/11/23 11:38
|
||||
*/
|
||||
@Data
|
||||
public class PullDown {
|
||||
|
||||
//起始列
|
||||
private Integer firstCol;
|
||||
//结束列
|
||||
private Integer lastCol;
|
||||
//属性值
|
||||
private List<String> strings;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ public class GeneratrixWire extends BaseEntity {
|
||||
/**
|
||||
* 关联中台的母线id
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String relationId;
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
@@ -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 "导入有未填入的字段";
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,5 +315,29 @@ public class PmsDistributionMonitorController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "将用户数据导入到配网表中")
|
||||
@PostMapping("/savePmsDistributionUser")
|
||||
public HttpResult<Boolean> savePmsDistributionUser() {
|
||||
String methodDescribe = getMethodDescribe("savePmsDistributionUser");
|
||||
boolean result = iDistributionMonitorService.savePmsDistributionUser();
|
||||
if(result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "将用户数据导入到配网表中")
|
||||
@PostMapping("/savePmsDistributionArea")
|
||||
public HttpResult<Boolean> savePmsDistributionArea() {
|
||||
String methodDescribe = getMethodDescribe("savePmsDistributionArea");
|
||||
boolean result = iDistributionMonitorService.savePmsDistributionArea();
|
||||
if(result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.device.pms.controller.ledgerManger;
|
||||
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
@@ -11,6 +12,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.device.pms.annotation.TerminalOperationLogDesc;
|
||||
import com.njcn.device.pms.pojo.excel.PowerDistributionAreaExcel;
|
||||
import com.njcn.device.pms.pojo.param.PowerDistributionareaParam;
|
||||
import com.njcn.device.pms.pojo.po.PowerDistributionarea;
|
||||
import com.njcn.device.pms.pojo.vo.PVCapacity;
|
||||
@@ -19,15 +21,20 @@ import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -168,5 +175,29 @@ public class PmsPowerDistributionareaController extends BaseController {
|
||||
List<PVCapacity.Absorptive> absorptiveCapacity = iPowerDistributionareaService.getAbsorptiveCapacity(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, absorptiveCapacity, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/export")
|
||||
@ApiOperation(value ="导出台区台账数据模板", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public HttpResult<String> export() {
|
||||
String methodDescribe = getMethodDescribe("export");
|
||||
iPowerDistributionareaService.export();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/importDistributionAreaExcel")
|
||||
@ApiOperation(value ="批量导入台区台账数据", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||
public HttpResult<String> importDistributionAreaExcel(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) throws IOException {
|
||||
String methodDescribe = getMethodDescribe("importDistributionAreaExcel");
|
||||
List<PowerDistributionAreaExcel.ErrMsg> list = EasyExcel.read(file.getInputStream())
|
||||
.head(PowerDistributionAreaExcel.ErrMsg.class)
|
||||
.headRowNumber(2)
|
||||
.doReadAllSync();
|
||||
iPowerDistributionareaService.importDistributionAreaExcel(list, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.device.pms.controller.ledgerManger;
|
||||
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
@@ -9,6 +10,7 @@ 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.pms.annotation.TerminalOperationLogDesc;
|
||||
import com.njcn.device.pms.pojo.excel.PowerGenerationUserExcel;
|
||||
import com.njcn.device.pms.pojo.param.PowerDistributionareaParam;
|
||||
import com.njcn.device.pms.pojo.param.PowerGenerationUserParam;
|
||||
import com.njcn.device.pms.pojo.param.PowerUserParam;
|
||||
@@ -19,15 +21,20 @@ import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -133,5 +140,26 @@ public class PmsPowerGenerationUserController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/export")
|
||||
@ApiOperation(value ="导出发电用户台账数据模板", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public HttpResult<String> export() {
|
||||
String methodDescribe = getMethodDescribe("export");
|
||||
iPowerGenerationUserService.export();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/importGenerationUserExcel")
|
||||
@ApiOperation(value ="批量导入发电用户台账数据", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
|
||||
public HttpResult<String> importGenerationUserExcel(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) throws IOException {
|
||||
String methodDescribe = getMethodDescribe("importGenerationUserExcel");
|
||||
List<PowerGenerationUserExcel.ErrMsg> list = EasyExcel.read(file.getInputStream())
|
||||
.head(PowerGenerationUserExcel.ErrMsg.class)
|
||||
.headRowNumber(2)
|
||||
.doReadAllSync();
|
||||
iPowerGenerationUserService.importGenerationUserExcel(list, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.njcn.device.pms.mapper.majornetwork;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
|
||||
@@ -9,7 +7,6 @@ import com.njcn.device.pms.pojo.dto.PmsMonitorBaseDTO;
|
||||
import com.njcn.device.pms.pojo.dto.PmsSimpleDTO;
|
||||
import com.njcn.device.pms.pojo.dto.PwPmsMonitorDTO;
|
||||
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
|
||||
import com.njcn.device.pms.pojo.param.PwPmsMonitorParam;
|
||||
import com.njcn.device.pms.pojo.param.TaiZhangParam;
|
||||
import com.njcn.device.pms.pojo.po.DistributionMonitor;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
@@ -18,7 +15,6 @@ import com.njcn.device.pms.pojo.vo.DoubleUserVO;
|
||||
import com.njcn.device.pms.pojo.vo.PmsPowerTreeMonitorVO;
|
||||
import com.njcn.device.pms.pojo.vo.PmsSummaryStatisticsVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -105,5 +101,25 @@ public interface DistributionMonitorMapper extends MppBaseMapper<DistributionMon
|
||||
|
||||
List<String> getBaseDisMonitorIds(@Param("list")List<String> list,@Param("monitorSortIds")List<String> monitorSortIds);
|
||||
|
||||
/**
|
||||
* 删除配网表数据
|
||||
* @param dic 监测点类型
|
||||
* @param type 是否是发电用户
|
||||
* @return
|
||||
*/
|
||||
Boolean deletePmsDistributionMonitor(@Param("dic") String dic,@Param("type") String type);
|
||||
|
||||
/**
|
||||
* 配网批量导入发电用户
|
||||
* @param dic
|
||||
* @return
|
||||
*/
|
||||
Boolean insertPmsDistributionUser(@Param("dic") String dic);
|
||||
|
||||
/**
|
||||
* 配网批量导入台区
|
||||
* @param dic
|
||||
* @return
|
||||
*/
|
||||
Boolean insertPmsDistributionArea(@Param("dic") String dic);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,87 @@
|
||||
<?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.pms.mapper.majornetwork.DistributionMonitorMapper">
|
||||
<insert id="insertPmsDistributionUser">
|
||||
INSERT INTO pms_distribution_monitor (
|
||||
Monitor_Sort,
|
||||
Monitor_Id,
|
||||
Org_Id,
|
||||
Voltage_Level,
|
||||
If_Power_User,
|
||||
Monitor_State,
|
||||
Created_Date,
|
||||
Status,
|
||||
Create_Time,
|
||||
Update_Time,
|
||||
Line_Id,
|
||||
Statistical_Interval,
|
||||
Power_Station_Id
|
||||
)
|
||||
select
|
||||
#{dic} as Monitor_Sort,
|
||||
id as Monitor_Id,
|
||||
Org_Id as Org_Id ,
|
||||
Voltage_Level as Voltage_Level,
|
||||
1 as If_Power_User,
|
||||
(select sd.id from sys_dict_data sd INNER JOIN sys_dict_type st on st.id=sd.Type_Id where sd.`Code`="Run" and st.`Code`="Line_State") as Monitor_State,
|
||||
now() as Created_Date,
|
||||
1 as Status,
|
||||
now() as Create_Time,
|
||||
now() as Update_Time,
|
||||
Line_Id as Statistical_Interval,
|
||||
15 as Statistical_Interval,
|
||||
Power_Station_Id as Power_Station_Id
|
||||
from
|
||||
pms_power_generation_user
|
||||
where Status=1
|
||||
</insert>
|
||||
|
||||
<insert id="insertPmsDistributionArea">
|
||||
INSERT INTO pms_distribution_monitor (
|
||||
Monitor_Sort,
|
||||
Monitor_Id,
|
||||
Org_Id,
|
||||
Voltage_Level,
|
||||
If_Power_User,
|
||||
Monitor_State,
|
||||
Created_Date,
|
||||
Status,
|
||||
Create_Time,
|
||||
Update_Time,
|
||||
Line_Id,
|
||||
Statistical_Interval,
|
||||
Power_Station_Id
|
||||
)
|
||||
select
|
||||
#{dic} as Monitor_Sort,
|
||||
id as Monitor_Id,
|
||||
Org_Id as Org_Id ,
|
||||
Voltage_Level as Voltage_Level,
|
||||
1 as If_Power_User,
|
||||
(select sd.id from sys_dict_data sd INNER JOIN sys_dict_type st on st.id=sd.Type_Id where sd.`Code`="Run" and st.`Code`="Line_State") as Monitor_State,
|
||||
now() as Created_Date,
|
||||
1 as Status,
|
||||
now() as Create_Time,
|
||||
now() as Update_Time,
|
||||
Line_Id as Statistical_Interval,
|
||||
15 as Statistical_Interval,
|
||||
Power_Station_Id as Power_Station_Id
|
||||
from
|
||||
pms_power_distributionarea
|
||||
where Status=1
|
||||
</insert>
|
||||
|
||||
<delete id="deletePmsDistributionMonitor">
|
||||
delete FROM pms_distribution_monitor
|
||||
<where>
|
||||
<if test="dic != null and dic !=''">
|
||||
and Monitor_Sort = #{dic}
|
||||
</if>
|
||||
<if test="type != null and type !='' ">
|
||||
and If_Power_User = #{type}
|
||||
</if>
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="getIdByOrgId" resultType="com.njcn.device.pms.pojo.dto.PmsMonitorBaseDTO">
|
||||
|
||||
@@ -126,4 +126,15 @@ public interface IDistributionMonitorService extends IMppService<DistributionMon
|
||||
|
||||
Boolean disMonitorWriteOrgId();
|
||||
|
||||
/**
|
||||
* 批量同步发电用户到配网表
|
||||
* @return
|
||||
*/
|
||||
Boolean savePmsDistributionUser();
|
||||
|
||||
/**
|
||||
* 批量同步台区到配网表
|
||||
* @return
|
||||
*/
|
||||
Boolean savePmsDistributionArea();
|
||||
}
|
||||
|
||||
@@ -3,11 +3,15 @@ package com.njcn.device.pms.service.majornetwork;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
|
||||
import com.njcn.device.pms.pojo.excel.PowerDistributionAreaExcel;
|
||||
import com.njcn.device.pms.pojo.param.PowerDistributionareaParam;
|
||||
import com.njcn.device.pms.pojo.po.PowerDistributionarea;
|
||||
import com.njcn.device.pms.pojo.vo.PVCapacity;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -76,4 +80,14 @@ public interface IPowerDistributionareaService extends IService<PowerDistributio
|
||||
* @return
|
||||
*/
|
||||
List<PVCapacity.Absorptive> getAbsorptiveCapacity(StatisticsBizBaseParam param);
|
||||
|
||||
/**
|
||||
* 导出台区模板
|
||||
*/
|
||||
void export();
|
||||
|
||||
/**
|
||||
* 批量导入台区台账数据
|
||||
*/
|
||||
void importDistributionAreaExcel(List<PowerDistributionAreaExcel.ErrMsg> list, HttpServletResponse response);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,17 @@ package com.njcn.device.pms.service.majornetwork;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.device.pms.pojo.excel.PowerGenerationUserExcel;
|
||||
import com.njcn.device.pms.pojo.param.PowerDistributionareaParam;
|
||||
import com.njcn.device.pms.pojo.param.PowerGenerationUserParam;
|
||||
import com.njcn.device.pms.pojo.param.PowerUserParam;
|
||||
import com.njcn.device.pms.pojo.po.PowerGenerationUser;
|
||||
import com.njcn.device.pms.pojo.vo.PowerGenerationUserVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -79,4 +83,13 @@ public interface IPowerGenerationUserService extends IService<PowerGenerationUse
|
||||
*/
|
||||
List<PowerGenerationUser> getGenerateElectricityUserList(PowerUserParam powerUserParam);
|
||||
|
||||
/**
|
||||
* 导出发电用户模板
|
||||
*/
|
||||
void export();
|
||||
|
||||
/**
|
||||
* 批量导入发电用户台账数据
|
||||
*/
|
||||
void importGenerationUserExcel(List<PowerGenerationUserExcel.ErrMsg> list, HttpServletResponse response);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.device.pms.service.majornetwork.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -562,6 +563,26 @@ public class DistributionMonitorServiceImpl extends MppServiceImpl<DistributionM
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean savePmsDistributionUser() {
|
||||
DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.THREE_LINE.getCode()).getData();
|
||||
if(ObjectUtil.isNotNull(data)){
|
||||
this.baseMapper.deletePmsDistributionMonitor(data.getId(),"1");
|
||||
this.baseMapper.insertPmsDistributionUser(data.getId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean savePmsDistributionArea() {
|
||||
DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.TWO_LINE.getCode()).getData();
|
||||
if(ObjectUtil.isNotNull(data)){
|
||||
this.baseMapper.deletePmsDistributionMonitor(data.getId(),null);
|
||||
this.baseMapper.insertPmsDistributionArea(data.getId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void overLimitAdd(String voltageLevel, String id) {
|
||||
DictData voltageDic = dicDataFeignClient.getDicDataById(voltageLevel).getData();
|
||||
float voltageLevelValue = Float.parseFloat(voltageDic.getValue());
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.njcn.device.pms.service.majornetwork.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
@@ -13,32 +18,46 @@ import com.njcn.device.biz.utils.COverlimitUtil;
|
||||
import com.njcn.device.pms.enums.PmsDeviceResponseEnum;
|
||||
import com.njcn.device.pms.mapper.majornetwork.OverlimitMapper;
|
||||
import com.njcn.device.pms.mapper.majornetwork.PowerDistributionareaMapper;
|
||||
import com.njcn.device.pms.pojo.excel.PowerDistributionAreaExcel;
|
||||
import com.njcn.device.pms.pojo.excel.PowerGenerationUserExcel;
|
||||
import com.njcn.device.pms.pojo.param.PowerDistributionareaParam;
|
||||
import com.njcn.device.pms.pojo.po.GeneratrixWire;
|
||||
import com.njcn.device.pms.pojo.po.PowerDistributionarea;
|
||||
import com.njcn.device.pms.pojo.po.PowerGenerationUser;
|
||||
import com.njcn.device.pms.pojo.po.StatationStat;
|
||||
import com.njcn.device.pms.pojo.vo.PVCapacity;
|
||||
import com.njcn.device.pms.service.majornetwork.IDistributionMonitorService;
|
||||
import com.njcn.device.pms.service.majornetwork.IGeneratrixWireService;
|
||||
import com.njcn.device.pms.service.majornetwork.IPowerDistributionareaService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.device.pms.service.majornetwork.IStatationStatService;
|
||||
import com.njcn.device.pms.utils.PubUtil;
|
||||
import com.njcn.event.pojo.vo.DeptLevelVO;
|
||||
import com.njcn.event.utils.DeptUtil;
|
||||
import com.njcn.poi.excel.ExcelUtil;
|
||||
import com.njcn.poi.excel.PullDown;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import com.njcn.web.utils.WebUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -54,10 +73,12 @@ import java.util.stream.Collectors;
|
||||
public class PowerDistributionareaServiceImpl extends ServiceImpl<PowerDistributionareaMapper, PowerDistributionarea> implements IPowerDistributionareaService {
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final IStatationStatService iStatationStatService;
|
||||
|
||||
private final IDistributionMonitorService iDistributionMonitorService;
|
||||
private final IStatationStatService statationStatService;
|
||||
private final IGeneratrixWireService generatrixWireService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -218,6 +239,209 @@ public class PowerDistributionareaServiceImpl extends ServiceImpl<PowerDistribut
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export() {
|
||||
ExportParams exportParams = new ExportParams("台区台账数据模板(带*字段均是必填,请严格按照模板标准填入数据)", "台区台账数据信息");
|
||||
List<PullDown> pullDowns=new ArrayList<>();
|
||||
//电压等级
|
||||
List<DictData> devVoltage = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
|
||||
//地区特征
|
||||
List<DictData> deviceRegionLype = dicDataFeignClient.getDicDataByTypeCode("Area").getData();
|
||||
//使用性质
|
||||
List<DictData> deviceUseNature = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_USERNATURE.getCode()).getData();
|
||||
//运行状态
|
||||
List<DictData> lineState = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_STATE.getCode()).getData();
|
||||
|
||||
PullDown pullDown;
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(10);
|
||||
pullDown.setLastCol(10);
|
||||
pullDown.setStrings(devVoltage.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(12);
|
||||
pullDown.setLastCol(12);
|
||||
pullDown.setStrings(deviceRegionLype.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(13);
|
||||
pullDown.setLastCol(13);
|
||||
pullDown.setStrings(Arrays.asList("是","否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(14);
|
||||
pullDown.setLastCol(14);
|
||||
pullDown.setStrings(deviceUseNature.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(17);
|
||||
pullDown.setLastCol(17);
|
||||
pullDown.setStrings(lineState.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(20);
|
||||
pullDown.setLastCol(20);
|
||||
pullDown.setStrings(Arrays.asList("是","否"));
|
||||
pullDowns.add(pullDown);
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(22);
|
||||
pullDown.setLastCol(22);
|
||||
pullDown.setStrings(Arrays.asList("是","否"));
|
||||
pullDowns.add(pullDown);
|
||||
ExcelUtil.exportExcelPullDown(exportParams,"台区台账数据信息.xlsx",pullDowns, PowerDistributionAreaExcel.class, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importDistributionAreaExcel(List<PowerDistributionAreaExcel.ErrMsg> list, HttpServletResponse response){
|
||||
List<PowerDistributionarea> info=new ArrayList<>();
|
||||
List<PowerDistributionAreaExcel.ErrMsg> errInfo=new ArrayList<>();
|
||||
if(CollUtil.isNotEmpty(list)){
|
||||
PowerDistributionarea area;
|
||||
//获取部门信息
|
||||
List<PvTerminalTreeVO> depts = deptFeignClient.allDeptList().getData();
|
||||
//电压等级
|
||||
List<DictData> devVoltage = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
|
||||
//地区特征
|
||||
List<DictData> deviceRegionLype = dicDataFeignClient.getDicDataByTypeCode("Area").getData();
|
||||
//使用性质
|
||||
List<DictData> deviceUseNature = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_USERNATURE.getCode()).getData();
|
||||
//运行状态
|
||||
List<DictData> lineState = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_STATE.getCode()).getData();
|
||||
for (PowerDistributionAreaExcel.ErrMsg msg : list) {
|
||||
String objNull = PubUtil.isObjNull(msg);
|
||||
if(StrUtil.isNotBlank(objNull)){
|
||||
msg.setErrMsg(objNull);
|
||||
errInfo.add(msg);
|
||||
continue;
|
||||
}
|
||||
area=new PowerDistributionarea();
|
||||
area.setId(msg.getId());
|
||||
area.setName(msg.getName());
|
||||
List<PvTerminalTreeVO> deptList = depts.stream().filter(x -> x.getCode().contains(msg.getOrgId())).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(deptList)){
|
||||
String org = PubUtil.subString(msg.getOrgName().replace("国网",""));
|
||||
List<PvTerminalTreeVO> deptName = depts.stream().filter(x -> x.getName().contains(org)).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(deptName)){
|
||||
area.setOrgName(deptName.get(0).getName());
|
||||
area.setOrgId(deptName.get(0).getCode());
|
||||
}else{
|
||||
msg.setErrMsg("组织机构不存在");
|
||||
errInfo.add(msg);
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
area.setOrgName(deptList.get(0).getName());
|
||||
area.setOrgId(deptList.get(0).getCode());
|
||||
}
|
||||
area.setOperationName(msg.getOperationName());
|
||||
area.setOperationId(msg.getOperationId());
|
||||
area.setPowerrName(msg.getPowerrName());
|
||||
area.setPowerStationId(msg.getPowerStationId());
|
||||
area.setLineName(msg.getLineName());
|
||||
area.setLineId(msg.getLineId());
|
||||
area.setVoltageLevel(PubUtil.getDicById(msg.getVoltageLevel(),devVoltage));
|
||||
area.setPCapacity(msg.getPCapacity());
|
||||
area.setRegionalism(PubUtil.getDicById(msg.getRegionalism(),deviceRegionLype));
|
||||
area.setIfRuralPowerGrid("是".equals(msg.getIfRuralPowerGrid())?1:0);
|
||||
area.setNatureOfUse(PubUtil.getDicById(msg.getNatureOfUse(),deviceUseNature));
|
||||
area.setPowerSupplyRadius(msg.getPowerSupplyRadius());
|
||||
area.setLineLength(msg.getLineLength());
|
||||
area.setState(PubUtil.getDicById(msg.getState(),lineState));
|
||||
area.setDistributedPhotovoltaicNum(msg.getDistributedPhotovoltaicNum());
|
||||
area.setPhotovoltaicCapacity(msg.getPhotovoltaicCapacity());
|
||||
area.setIfBevAp("是".equals(msg.getIfBevAp())?1:0);
|
||||
area.setApLoadType(msg.getApLoadType());
|
||||
area.setIsUpToGrid("是".equals(msg.getIfBevAp())?1:0);
|
||||
area.setStatus(1);
|
||||
area.setInputStatus(0);
|
||||
area.setCreateBy(RequestUtil.getUserIndex());
|
||||
area.setCreateTime(LocalDateTimeUtil.now());
|
||||
area.setUpdateBy(RequestUtil.getUserIndex());
|
||||
area.setUpdateTime(LocalDateTimeUtil.now());
|
||||
info.add(area);
|
||||
}
|
||||
if(CollUtil.isNotEmpty(info)){
|
||||
info = info.stream().collect(Collectors.collectingAndThen
|
||||
(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(o -> o.getId()))), ArrayList::new));
|
||||
List<String> ids = info.stream().map(PowerDistributionarea::getId).collect(Collectors.toList());
|
||||
List<PowerDistributionAreaExcel.ErrMsg> subInfo = list.stream().filter(x -> ids.contains(x.getId())).collect(Collectors.toList());
|
||||
addSub(subInfo,devVoltage);
|
||||
this.remove(new LambdaQueryWrapper<PowerDistributionarea>()
|
||||
.in(PowerDistributionarea::getId, ids)
|
||||
);
|
||||
this.saveBatch(info, 1000);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(errInfo)) {
|
||||
PubUtil.exportExcel(DateUtil.now() + "_台区台账错误信息.xlsx", errInfo,PowerDistributionAreaExcel.ErrMsg.class, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
//变电站和线路插入
|
||||
public void addSub(List<PowerDistributionAreaExcel.ErrMsg> info,List<DictData> devVoltage) {
|
||||
List<StatationStat> stats=new ArrayList<>();
|
||||
StatationStat stat;
|
||||
List<GeneratrixWire> wires=new ArrayList<>();
|
||||
GeneratrixWire wire;
|
||||
List<StatationStat> oldStat = statationStatService.list();
|
||||
List<String> statIds = oldStat.stream().map(StatationStat::getPowerId).distinct().collect(Collectors.toList());
|
||||
List<GeneratrixWire> oldWire = generatrixWireService.list();
|
||||
List<String> wireIds = oldWire.stream().map(x-> x.getId()+"_"+x.getStationId()).distinct().collect(Collectors.toList());
|
||||
//变电站集合
|
||||
ArrayList<PowerDistributionAreaExcel.ErrMsg> statList = info.stream().collect(Collectors.collectingAndThen
|
||||
(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(o -> o.getPowerStationId()))), ArrayList::new));
|
||||
for (PowerDistributionAreaExcel.ErrMsg errMsg : statList) {
|
||||
if(!statIds.contains(errMsg.getPowerStationId())){
|
||||
stat=new StatationStat();
|
||||
stat.setPowerId(errMsg.getPowerStationId());
|
||||
stat.setPowerName(errMsg.getPowerrName());
|
||||
stat.setOrgId(errMsg.getOrgId());
|
||||
stat.setOrgName(errMsg.getOrgName());
|
||||
stat.setShouldBeNum(100);
|
||||
stat.setVoltageLevel(PubUtil.getDicById(errMsg.getVoltageLevel(),devVoltage));
|
||||
stat.setStatus(1);
|
||||
stat.setCreateBy(RequestUtil.getUserIndex());
|
||||
stat.setCreateTime(LocalDateTimeUtil.now());
|
||||
stat.setUpdateBy(RequestUtil.getUserIndex());
|
||||
stat.setUpdateTime(LocalDateTimeUtil.now());
|
||||
stats.add(stat);
|
||||
}
|
||||
}
|
||||
//线路
|
||||
ArrayList<PowerDistributionAreaExcel.ErrMsg> wireList = info.stream().collect(Collectors.collectingAndThen
|
||||
(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(o -> o.getLineId()+";"+o.getPowerStationId()))), ArrayList::new));
|
||||
for (PowerDistributionAreaExcel.ErrMsg errMsg : wireList){
|
||||
if(!wireIds.contains(errMsg.getLineId()+"_"+errMsg.getPowerStationId())){
|
||||
wire=new GeneratrixWire();
|
||||
wire.setId(errMsg.getLineId());
|
||||
wire.setName(errMsg.getLineName());
|
||||
wire.setStationId(errMsg.getPowerStationId());
|
||||
wire.setStationName(errMsg.getPowerrName());
|
||||
wire.setGeneratrixName(errMsg.getPowerrName());
|
||||
wire.setScale(PubUtil.getDicById(errMsg.getVoltageLevel(),devVoltage));
|
||||
wire.setStatus(1);
|
||||
wire.setCreateBy(RequestUtil.getUserIndex());
|
||||
wire.setCreateTime(LocalDateTimeUtil.now());
|
||||
wire.setUpdateBy(RequestUtil.getUserIndex());
|
||||
wire.setUpdateTime(LocalDateTimeUtil.now());
|
||||
wires.add(wire);
|
||||
}
|
||||
}
|
||||
if(CollUtil.isNotEmpty(stats)){
|
||||
statationStatService.saveBatch(stats);
|
||||
}
|
||||
if(CollUtil.isNotEmpty(wires)){
|
||||
generatrixWireService.saveBatch(wires);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 名称重复校验
|
||||
*/
|
||||
|
||||
@@ -1,34 +1,59 @@
|
||||
package com.njcn.device.pms.service.majornetwork.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.pms.enums.PmsDeviceResponseEnum;
|
||||
import com.njcn.device.pms.mapper.majornetwork.PowerGenerationUserMapper;
|
||||
import com.njcn.device.pms.pojo.excel.PowerGenerationUserExcel;
|
||||
import com.njcn.device.pms.pojo.param.PowerDistributionareaParam;
|
||||
import com.njcn.device.pms.pojo.param.PowerGenerationUserParam;
|
||||
import com.njcn.device.pms.pojo.param.PowerUserParam;
|
||||
import com.njcn.device.pms.pojo.po.PowerClient;
|
||||
import com.njcn.device.pms.pojo.po.GeneratrixWire;
|
||||
import com.njcn.device.pms.pojo.po.PowerGenerationUser;
|
||||
import com.njcn.device.pms.pojo.po.StatationStat;
|
||||
import com.njcn.device.pms.pojo.vo.PowerGenerationUserVO;
|
||||
import com.njcn.device.pms.service.majornetwork.IDistributionMonitorService;
|
||||
import com.njcn.device.pms.service.majornetwork.IGeneratrixWireService;
|
||||
import com.njcn.device.pms.service.majornetwork.IPowerGenerationUserService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.device.pms.service.majornetwork.IStatationStatService;
|
||||
import com.njcn.device.pms.utils.PubUtil;
|
||||
import com.njcn.poi.excel.ExcelUtil;
|
||||
import com.njcn.poi.excel.PullDown;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -43,8 +68,10 @@ import java.util.Objects;
|
||||
public class PowerGenerationUserServiceImpl extends ServiceImpl<PowerGenerationUserMapper, PowerGenerationUser> implements IPowerGenerationUserService {
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final IDistributionMonitorService iDistributionMonitorService;
|
||||
private final IStatationStatService statationStatService;
|
||||
private final IGeneratrixWireService generatrixWireService;
|
||||
|
||||
@Override
|
||||
public boolean addPowerGenerationUser(PowerGenerationUserParam powerGenerationUserParam) {
|
||||
@@ -116,6 +143,159 @@ public class PowerGenerationUserServiceImpl extends ServiceImpl<PowerGenerationU
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export() {
|
||||
ExportParams exportParams = new ExportParams("发电用户台账数据模板(带*字段均是必填,请严格按照模板标准填入数据)", "发电用户台账数据信息");
|
||||
List<PullDown> pullDowns=new ArrayList<>();
|
||||
//电源类别
|
||||
List<DictData> powerCategory = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POWER_CATEGORY.getCode()).getData();
|
||||
//电站类型
|
||||
List<DictData> powerStationType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POWER_STATION_TYPE.getCode()).getData();
|
||||
//发电方式
|
||||
List<DictData> powerGeneration = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POWER_GENERATION.getCode()).getData();
|
||||
//电压等级
|
||||
List<DictData> devVoltage = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
|
||||
//能源消纳方式
|
||||
List<DictData> connectionMode = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.CONNECTION_MODE.getCode()).getData();
|
||||
//用电客户状态
|
||||
List<DictData> eccStat = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.ECC_STAT.getCode()).getData();
|
||||
|
||||
PullDown pullDown;
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(6);
|
||||
pullDown.setLastCol(6);
|
||||
pullDown.setStrings(powerCategory.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(7);
|
||||
pullDown.setLastCol(7);
|
||||
pullDown.setStrings(powerStationType.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(8);
|
||||
pullDown.setLastCol(8);
|
||||
pullDown.setStrings(powerGeneration.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(9);
|
||||
pullDown.setLastCol(9);
|
||||
pullDown.setStrings(devVoltage.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(12);
|
||||
pullDown.setLastCol(12);
|
||||
pullDown.setStrings(connectionMode.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(13);
|
||||
pullDown.setLastCol(13);
|
||||
pullDown.setStrings(eccStat.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
pullDown=new PullDown();
|
||||
pullDown.setFirstCol(20);
|
||||
pullDown.setLastCol(20);
|
||||
pullDown.setStrings(Arrays.asList("是","否"));
|
||||
pullDowns.add(pullDown);
|
||||
ExcelUtil.exportExcelPullDown(exportParams,"发电用户台账数据信息.xlsx",pullDowns, PowerGenerationUserExcel.class, new ArrayList<>());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importGenerationUserExcel(List<PowerGenerationUserExcel.ErrMsg> list, HttpServletResponse response) {
|
||||
List<PowerGenerationUser> info=new ArrayList<>();
|
||||
List<PowerGenerationUserExcel.ErrMsg> errInfo=new ArrayList<>();
|
||||
if(CollUtil.isNotEmpty(list)){
|
||||
PowerGenerationUser user;
|
||||
//获取部门信息
|
||||
List<PvTerminalTreeVO> depts = deptFeignClient.allDeptList().getData();
|
||||
//电源类别
|
||||
List<DictData> powerCategory = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POWER_CATEGORY.getCode()).getData();
|
||||
//电站类型
|
||||
List<DictData> powerStationType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POWER_STATION_TYPE.getCode()).getData();
|
||||
//发电方式
|
||||
List<DictData> powerGeneration = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POWER_GENERATION.getCode()).getData();
|
||||
//电压等级
|
||||
List<DictData> devVoltage = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
|
||||
//能源消纳方式
|
||||
List<DictData> connectionMode = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.CONNECTION_MODE.getCode()).getData();
|
||||
//用电客户状态
|
||||
List<DictData> eccStat = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.ECC_STAT.getCode()).getData();
|
||||
for (PowerGenerationUserExcel.ErrMsg msg : list) {
|
||||
String objNull = PubUtil.isObjNull(msg);
|
||||
if(StrUtil.isNotBlank(objNull)){
|
||||
msg.setErrMsg(objNull);
|
||||
errInfo.add(msg);
|
||||
continue;
|
||||
}
|
||||
user=new PowerGenerationUser();
|
||||
user.setId(msg.getId());
|
||||
user.setName(msg.getName());
|
||||
|
||||
List<PvTerminalTreeVO> deptList = depts.stream().filter(x -> x.getCode().contains(msg.getOrgId())).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(deptList)){
|
||||
String org = PubUtil.subString(msg.getOrgName().replace("国网",""));
|
||||
List<PvTerminalTreeVO> deptName = depts.stream().filter(x -> x.getName().contains(org)).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(deptName)){
|
||||
user.setOrgName(deptName.get(0).getName());
|
||||
user.setOrgId(deptName.get(0).getCode());
|
||||
}else{
|
||||
msg.setErrMsg("组织机构不存在");
|
||||
errInfo.add(msg);
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
user.setOrgName(deptList.get(0).getName());
|
||||
user.setOrgId(deptList.get(0).getCode());
|
||||
}
|
||||
user.setOperationName(msg.getOperationName());
|
||||
user.setOperationId(msg.getOperationId());
|
||||
user.setPowerCategory(PubUtil.getDicById(msg.getPowerCategory(),powerCategory));
|
||||
user.setPowerStationType(PubUtil.getDicById(msg.getPowerStationType(),powerStationType));
|
||||
user.setPowerGenerationMode(PubUtil.getDicById(msg.getPowerGenerationMode(),powerGeneration));
|
||||
user.setVoltageLevel(PubUtil.getDicById(msg.getVoltageLevel(),devVoltage));
|
||||
user.setSourceCapacity(msg.getSourceCapacity());
|
||||
user.setConnectionMode(PubUtil.getDicById(msg.getConnectionMode(),connectionMode));
|
||||
user.setGcStat(PubUtil.getDicById(msg.getGcStat(),eccStat));
|
||||
user.setPowerStationId(msg.getPowerStationId());
|
||||
user.setLineId(msg.getLineId());
|
||||
user.setPlatformId(msg.getPlatformId());
|
||||
user.setUserTag("发电用户");
|
||||
user.setIsUpToGrid("是".equals(msg.getIsUpToGrid())?1:0);
|
||||
DateTime dateTime = DateUtil.parseDate(msg.getConnectionDate());
|
||||
ZoneId zoneId = ZoneId.systemDefault();
|
||||
LocalDateTime localDateTime = dateTime.toInstant().atZone(zoneId).toLocalDateTime();
|
||||
user.setConnectionDate(localDateTime.toLocalDate());
|
||||
user.setStatus(1);
|
||||
user.setCreateBy(RequestUtil.getUserIndex());
|
||||
user.setCreateTime(LocalDateTimeUtil.now());
|
||||
user.setUpdateBy(RequestUtil.getUserIndex());
|
||||
user.setUpdateTime(LocalDateTimeUtil.now());
|
||||
info.add(user);
|
||||
}
|
||||
if(CollUtil.isNotEmpty(info)){
|
||||
info = info.stream().collect(Collectors.collectingAndThen
|
||||
(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(o -> o.getId()))), ArrayList::new));
|
||||
List<String> ids = info.stream().map(PowerGenerationUser::getId).distinct().collect(Collectors.toList());
|
||||
List<PowerGenerationUserExcel.ErrMsg> subInfo = list.stream().filter(x -> ids.contains(x.getId())).collect(Collectors.toList());
|
||||
addSub(subInfo,devVoltage);
|
||||
this.remove(new LambdaQueryWrapper<PowerGenerationUser>()
|
||||
.in(PowerGenerationUser::getId, ids)
|
||||
);
|
||||
this.saveBatch(info, 1000);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(errInfo)) {
|
||||
PubUtil.exportExcel(DateUtil.now() + "_发电用户台账错误信息.xlsx", errInfo,PowerGenerationUserExcel.ErrMsg.class, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void checkParam(PowerGenerationUserParam powerGenerationUserParam,Boolean updateFlag){
|
||||
|
||||
@@ -135,5 +315,63 @@ public class PowerGenerationUserServiceImpl extends ServiceImpl<PowerGenerationU
|
||||
|
||||
}
|
||||
|
||||
|
||||
//变电站和线路插入
|
||||
public void addSub(List<PowerGenerationUserExcel.ErrMsg> info, List<DictData> devVoltage) {
|
||||
List<StatationStat> stats=new ArrayList<>();
|
||||
StatationStat stat;
|
||||
List<GeneratrixWire> wires=new ArrayList<>();
|
||||
GeneratrixWire wire;
|
||||
List<StatationStat> oldStat = statationStatService.list();
|
||||
List<String> statIds = oldStat.stream().map(StatationStat::getPowerId).distinct().collect(Collectors.toList());
|
||||
List<GeneratrixWire> oldWire = generatrixWireService.list();
|
||||
List<String> wireIds = oldWire.stream().map(x-> x.getId()+"_"+x.getStationId()).distinct().collect(Collectors.toList());
|
||||
//变电站集合
|
||||
ArrayList<PowerGenerationUserExcel.ErrMsg> statList = info.stream().collect(Collectors.collectingAndThen
|
||||
(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(o -> o.getPowerStationId()))), ArrayList::new));
|
||||
for (PowerGenerationUserExcel.ErrMsg errMsg : statList) {
|
||||
if(!statIds.contains(errMsg.getPowerStationId())){
|
||||
stat=new StatationStat();
|
||||
stat.setPowerId(errMsg.getPowerStationId());
|
||||
stat.setPowerName(errMsg.getPowerStationName());
|
||||
stat.setOrgId(errMsg.getOrgId());
|
||||
stat.setOrgName(errMsg.getOrgName());
|
||||
stat.setShouldBeNum(100);
|
||||
stat.setVoltageLevel(PubUtil.getDicById(errMsg.getVoltageLevel(),devVoltage));
|
||||
stat.setStatus(1);
|
||||
stat.setCreateBy(RequestUtil.getUserIndex());
|
||||
stat.setCreateTime(LocalDateTimeUtil.now());
|
||||
stat.setUpdateBy(RequestUtil.getUserIndex());
|
||||
stat.setUpdateTime(LocalDateTimeUtil.now());
|
||||
stats.add(stat);
|
||||
}
|
||||
}
|
||||
//线路
|
||||
ArrayList<PowerGenerationUserExcel.ErrMsg> wireList = info.stream().collect(Collectors.collectingAndThen
|
||||
(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(o -> o.getLineId()+";"+o.getPowerStationId()))), ArrayList::new));
|
||||
for (PowerGenerationUserExcel.ErrMsg errMsg : wireList){
|
||||
if(!wireIds.contains(errMsg.getLineId()+"_"+errMsg.getPowerStationId())){
|
||||
wire=new GeneratrixWire();
|
||||
wire.setId(errMsg.getLineId());
|
||||
wire.setName(errMsg.getLineName());
|
||||
wire.setStationId(errMsg.getPowerStationId());
|
||||
wire.setStationName(errMsg.getPowerStationName());
|
||||
wire.setGeneratrixName(errMsg.getPowerStationName());
|
||||
wire.setScale(PubUtil.getDicById(errMsg.getVoltageLevel(),devVoltage));
|
||||
wire.setStatus(1);
|
||||
wire.setCreateBy(RequestUtil.getUserIndex());
|
||||
wire.setCreateTime(LocalDateTimeUtil.now());
|
||||
wire.setUpdateBy(RequestUtil.getUserIndex());
|
||||
wire.setUpdateTime(LocalDateTimeUtil.now());
|
||||
wires.add(wire);
|
||||
}
|
||||
}
|
||||
if(CollUtil.isNotEmpty(stats)){
|
||||
statationStatService.saveBatch(stats);
|
||||
}
|
||||
if(CollUtil.isNotEmpty(wires)){
|
||||
generatrixWireService.saveBatch(wires);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,5 +76,14 @@ public class LineDetailVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("CT二次变比")
|
||||
private Double CT2;
|
||||
|
||||
@ApiModelProperty("套餐流量")
|
||||
private Float flowMeal;
|
||||
|
||||
@ApiModelProperty("已用流量")
|
||||
private Float statisValue;
|
||||
|
||||
@ApiModelProperty("已用流量占比")
|
||||
private Float flowProportion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -87,6 +88,8 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
|
||||
private final PqsCommunicateMapper pqsCommunicateMapper;
|
||||
|
||||
private final TerminalMaintainMapper terminalMaintainMapper;
|
||||
|
||||
@Override
|
||||
public LineDetailDataVO getLineDetailData(String id) {
|
||||
//根据id查询当前信息的pids
|
||||
@@ -508,29 +511,42 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
@Override
|
||||
public List<LineDetailVO.Detail> getLineDetailByIds(List<String> ids) {
|
||||
List<LineDetailVO.Detail> details = this.baseMapper.selectByIds(ids);
|
||||
//获取行政区域
|
||||
List<String> areaIds = details.stream().map(LineDetailVO.Detail::getAreaId).distinct().collect(Collectors.toList());
|
||||
List<Area> data = areaFeignClient.areaNameByList(areaIds).getData();
|
||||
Map<String, String> areaMap = data.stream().collect(Collectors.toMap(Area::getId, Area::getName));
|
||||
//获取电压字典
|
||||
List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE_STAND.getCode()).getData();
|
||||
Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
|
||||
//获取终端等级
|
||||
List<DictData> gradeType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_GRADE.getCode()).getData();
|
||||
Map<String, Integer> gradeMap = gradeType.stream().collect(Collectors.toMap(DictData::getId, DictData::getAlgoDescribe));
|
||||
if(CollUtil.isNotEmpty(details)){
|
||||
List<String> devIds = details.stream().map(LineDetailVO.Detail::getDevId).distinct().collect(Collectors.toList());
|
||||
//获取终端流量信息
|
||||
List<LineFlowMealDetailVO> flow = terminalMaintainMapper.getMonthFlow(devIds, DateUtil.beginOfMonth(DateUtil.date()), DateUtil.endOfMonth(DateUtil.date()));
|
||||
Map<String, LineFlowMealDetailVO> flowMap = flow.stream().collect(Collectors.toMap(LineFlowMealDetailVO::getId, Function.identity()));
|
||||
//获取行政区域
|
||||
List<String> areaIds = details.stream().map(LineDetailVO.Detail::getAreaId).distinct().collect(Collectors.toList());
|
||||
List<Area> data = areaFeignClient.areaNameByList(areaIds).getData();
|
||||
Map<String, String> areaMap = data.stream().collect(Collectors.toMap(Area::getId, Area::getName));
|
||||
//获取电压字典
|
||||
List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE_STAND.getCode()).getData();
|
||||
Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
|
||||
//获取终端等级
|
||||
List<DictData> gradeType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_GRADE.getCode()).getData();
|
||||
Map<String, Integer> gradeMap = gradeType.stream().collect(Collectors.toMap(DictData::getId, DictData::getAlgoDescribe));
|
||||
|
||||
for (LineDetailVO.Detail detail : details) {
|
||||
//获取行政区域名称
|
||||
if(areaMap.containsKey(detail.getAreaId())){
|
||||
detail.setAreaName(areaMap.get(detail.getAreaId()));
|
||||
}
|
||||
//电压
|
||||
if(dictMap.containsKey(detail.getVoltageLevel())){
|
||||
detail.setVoltageLevel(dictMap.get(detail.getVoltageLevel()));
|
||||
}
|
||||
//终端等级
|
||||
if(gradeMap.containsKey(detail.getLineGrade())){
|
||||
detail.setLineGrade(String.valueOf(gradeMap.get(detail.getLineGrade())));
|
||||
for (LineDetailVO.Detail detail : details) {
|
||||
//获取行政区域名称
|
||||
if(areaMap.containsKey(detail.getAreaId())){
|
||||
detail.setAreaName(areaMap.get(detail.getAreaId()));
|
||||
}
|
||||
//电压
|
||||
if(dictMap.containsKey(detail.getVoltageLevel())){
|
||||
detail.setVoltageLevel(dictMap.get(detail.getVoltageLevel()));
|
||||
}
|
||||
//终端等级
|
||||
if(gradeMap.containsKey(detail.getLineGrade())){
|
||||
detail.setLineGrade(String.valueOf(gradeMap.get(detail.getLineGrade())));
|
||||
}
|
||||
//终端等级
|
||||
if(flowMap.containsKey(detail.getDevId())){
|
||||
LineFlowMealDetailVO flowVo = flowMap.get(detail.getDevId());
|
||||
detail.setFlowMeal(flowVo.getFlowMeal());
|
||||
detail.setStatisValue(flowVo.getStatisValue());
|
||||
detail.setFlowProportion(flowVo.getFlowProportion()*100);
|
||||
}
|
||||
}
|
||||
}
|
||||
return details;
|
||||
|
||||
@@ -15,6 +15,11 @@ public enum DicDataTypeEnum {
|
||||
* 字典类型名称
|
||||
*/
|
||||
FRONT_TYPE("前置类型","Front_Type"),
|
||||
POWER_CATEGORY("电源类别","Power_Category"),
|
||||
POWER_STATION_TYPE("电站类型","Power_Station_Type"),
|
||||
POWER_GENERATION("发电方式","Power_Generation"),
|
||||
CONNECTION_MODE("能源消纳方式","Connection_Mode"),
|
||||
ECC_STAT("用电客户状态","Ecc_Stat"),
|
||||
DEV_TYPE("终端型号","Dev_Type"),
|
||||
DEV_VARIETY("终端类型","Dev_Variety"),
|
||||
DEV_FUN("终端功能","Dev_Fun"),
|
||||
|
||||
Reference in New Issue
Block a user