diff --git a/src/main/java/com/njcn/jbsyncdata/controller/DisPhotovoltaicController.java b/src/main/java/com/njcn/jbsyncdata/controller/DisPhotovoltaicController.java index aead0e7..f1dc6fd 100644 --- a/src/main/java/com/njcn/jbsyncdata/controller/DisPhotovoltaicController.java +++ b/src/main/java/com/njcn/jbsyncdata/controller/DisPhotovoltaicController.java @@ -5,10 +5,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.util.StrUtil; import com.alibaba.excel.EasyExcel; -import com.njcn.jbsyncdata.pojo.DisPhotovoltaic10Excel; -import com.njcn.jbsyncdata.pojo.DisPhotovoltaic380Excel; -import com.njcn.jbsyncdata.pojo.DistributionAreaExcel; -import com.njcn.jbsyncdata.pojo.ZhangDistributionAreaExcel; +import com.njcn.jbsyncdata.pojo.*; import com.njcn.jbsyncdata.service.DisPhotovoltaicService; import com.njcn.jbsyncdata.service.IBusinessService; import com.njcn.jbsyncdata.util.StreamUtil; @@ -177,6 +174,16 @@ public class DisPhotovoltaicController { disPhotovoltaicService.SavaZhangArea(list,response); System.out.println(); + } + @ApiOperation(value = "导入通用融合终端模板台区数据", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + @PostMapping("/importDistributionAreaExcel") + public void importDistributionAreaExcel(MultipartFile file, HttpServletResponse response) throws Exception { + List list = EasyExcel.read(file.getInputStream()) + .head(PowerDistributionAreaExcel.ErrMsg.class) + .headRowNumber(2) + .doReadAllSync(); + disPhotovoltaicService.importDistributionAreaExcel(list,response); + } @ApiOperation(value = "将用户数据导入到配网表中") diff --git a/src/main/java/com/njcn/jbsyncdata/enums/MeasTypeEnum.java b/src/main/java/com/njcn/jbsyncdata/enums/MeasTypeEnum.java index 018f543..aa2dd7a 100644 --- a/src/main/java/com/njcn/jbsyncdata/enums/MeasTypeEnum.java +++ b/src/main/java/com/njcn/jbsyncdata/enums/MeasTypeEnum.java @@ -22,10 +22,27 @@ public enum MeasTypeEnum { TOTW("TotW", "有功", "T","data_harmpower_p","p"), - TOTVAR("TotVar", "无功", "T","data_harmpower_q","q"); -// A_V3("HphV3_phsA", "A相电压3次谐波值", "A","data_v","v3"), -// B_V3("HphV3_phsB", "A相电压3次谐波值", "B","data_v","v3"), -// C_V3("Hphv3_phsC", "A相电压3次谐波值", "C","data_v","v3"); + TOTVAR("TotVar", "无功", "T","data_harmpower_q","q"), + A_V2("HphV2_phsA", "A相电压2次谐波值", "A","data_harmrate_v","v_2"), + B_V2("HphV2_phsB", "B相电压2次谐波值", "B","data_harmrate_v","v_2"), + C_V2("HphV2_phsC", "C相电压2次谐波值", "C","data_harmrate_v","v_2"), + + A_V3("HphV3_phsA", "A相电压3次谐波值", "A","data_harmrate_v","v_3"), + B_V3("HphV3_phsB", "B相电压3次谐波值", "B","data_harmrate_v","v_3"), + C_V3("HphV3_phsC", "C相电压3次谐波值", "C","data_harmrate_v","v_3"), + + A_V5("HphV5_phsA", "A相电压5次谐波值", "A","data_harmrate_v","v_5"), + B_V5("HphV5_phsB", "B相电压5次谐波值", "B","data_harmrate_v","v_5"), + C_V5("HphV5_phsC", "C相电压5次谐波值", "C","data_harmrate_v","v_5"), + + A_V7("HphV7_phsA", "A相电压7次谐波值", "A","data_harmrate_v","v_7"), + B_V7("HphV7_phsB", "B相电压7次谐波值", "B","data_harmrate_v","v_7"), + C_V7("HphV7_phsC", "C相电压7次谐波值", "C","data_harmrate_v","v_7"), + + A_V9("HphV9_phsA", "A相电压9次谐波值", "A","data_harmrate_v","v_9"), + B_V9("HphV9_phsB", "B相电压9次谐波值", "B","data_harmrate_v","v_9"), + C_V9("HphV9_phsC", "C相电压9次谐波值", "C","data_harmrate_v","v_9"); + //冀北指标名称 private final String measType; diff --git a/src/main/java/com/njcn/jbsyncdata/mapper/PmsGeneratrixWireMapper.java b/src/main/java/com/njcn/jbsyncdata/mapper/PmsGeneratrixWireMapper.java new file mode 100644 index 0000000..673744f --- /dev/null +++ b/src/main/java/com/njcn/jbsyncdata/mapper/PmsGeneratrixWireMapper.java @@ -0,0 +1,16 @@ +package com.njcn.jbsyncdata.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.jbsyncdata.pojo.po.PmsGeneratrixWire; + +/** + *

+ * Mapper 接口 + *

+ * + * @author wr + * @since 2023-11-28 + */ +public interface PmsGeneratrixWireMapper extends BaseMapper { + +} diff --git a/src/main/java/com/njcn/jbsyncdata/mapper/mapping/PmsGeneratrixWireMapper.xml b/src/main/java/com/njcn/jbsyncdata/mapper/mapping/PmsGeneratrixWireMapper.xml new file mode 100644 index 0000000..8bc71dd --- /dev/null +++ b/src/main/java/com/njcn/jbsyncdata/mapper/mapping/PmsGeneratrixWireMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/njcn/jbsyncdata/pojo/PowerDistributionAreaExcel.java b/src/main/java/com/njcn/jbsyncdata/pojo/PowerDistributionAreaExcel.java new file mode 100644 index 0000000..06b9a1c --- /dev/null +++ b/src/main/java/com/njcn/jbsyncdata/pojo/PowerDistributionAreaExcel.java @@ -0,0 +1,182 @@ +package com.njcn.jbsyncdata.pojo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.njcn.jbsyncdata.util.ExcelValid; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 台区导入模板 + *

+ * + * @author hongawen + * @since 2022-10-14 + */ +@Data +public class PowerDistributionAreaExcel implements Serializable { + + + private static final long serialVersionUID = 1L; + + + @ColumnWidth(30) + @ExcelProperty(value = "*台区编号") + @ExcelValid(message = "台区编号不能为空") + private String id; + + + @ColumnWidth(30) + @ExcelProperty(value = "*台区名称") + @ExcelValid(message = "台区名称不能为空") + private String name; + + + @ColumnWidth(30) + @ExcelProperty(value = "*组织机构名称") + @ExcelValid(message = "组织机构名称不能为空") + private String orgName; + + + @ColumnWidth(30) + @ExcelProperty(value = "*组织机构ID") + @ExcelValid(message = "组织机构ID不能为空") + private String orgId; + + + @ColumnWidth(30) + @ExcelProperty(value = "*运维单位名称") + @ExcelValid(message = "运维单位名称不能为空") + private String operationName; + + + @ColumnWidth(30) + @ExcelProperty(value = "*运维单位ID") + @ExcelValid(message = "运维单位ID不能为空") + private String operationId; + + + @ColumnWidth(30) + @ExcelProperty(value = "*变电站名称") + @ExcelValid(message = "变电站名称不能为空") + private String powerrName; + + + + @ColumnWidth(30) + @ExcelProperty(value = "*变电站ID") + @ExcelValid(message = "变电站ID不能为空") + private String powerStationId; + + + + @ColumnWidth(30) + @ExcelProperty(value = "*监测线路名称") + @ExcelValid(message = "监测线路名称不能为空") + private String lineName; + + + + @ColumnWidth(30) + @ExcelProperty(value = "*所属线路ID") + @ExcelValid(message = "所属线路ID不能为空") + private String lineId; + + + + @ColumnWidth(30) + @ExcelProperty(value = "*电压等级") + @ExcelValid(message = "电压等级不能为空") + private String voltageLevel; + + + + + @ColumnWidth(30) + @ExcelProperty(value = "*配变容量") + @ExcelValid(message = "配变容量不能为空") + private Float pCapacity; + + + @ColumnWidth(30) + @ExcelProperty(value = "*地区特征") + @ExcelValid(message = "地区特征不能为空") + private String regionalism; + + + + @ColumnWidth(30) + @ExcelProperty(value = "*是否农网") + @ExcelValid(message = "是否农网不能为空") + private String ifRuralPowerGrid; + + + @ColumnWidth(30) + @ExcelProperty(value = "*使用性质") + @ExcelValid(message = "使用性质不能为空") + private String natureOfUse; + + + @ColumnWidth(30) + @ExcelProperty(value = "*供电半径") + @ExcelValid(message = "供电半径不能为空") + private Float powerSupplyRadius; + + + @ColumnWidth(30) + @ExcelProperty(value = "*供电线路总长度") + @ExcelValid(message = "供电线路总长度不能为空") + private Float lineLength; + + + @ColumnWidth(30) + @ExcelProperty(value = "*运行状态") + @ExcelValid(message = "运行状态不能为空") + private String state; + + + @ColumnWidth(30) + @ExcelProperty(value = "*分布式光伏用户数") + @ExcelValid(message = "分布式光伏用户数不能为空") + private Integer distributedPhotovoltaicNum; + + + @ColumnWidth(30) + @ExcelProperty(value = "*分布式光伏总装机容量") + @ExcelValid(message = "分布式光伏总装机容量不能为空") + private Float photovoltaicCapacity; + + + @ColumnWidth(30) + @ExcelProperty(value = "*是否有电动汽车接入") + @ExcelValid(message = "是否有电动汽车接入不能为空") + private String ifBevAp; + + + @ColumnWidth(30) + @ExcelProperty(value = "*接入负荷类型") + @ExcelValid(message = "接入负荷类型不能为空") + private String apLoadType; + + @ColumnWidth(30) + @ExcelProperty(value = "*是否是上送国网监测点") + @ExcelValid(message = "是否是上送国网监测点不能为空") + private String isUpToGrid; + + @ColumnWidth(30) + @ExcelProperty(value = "*PMS资源id") + @ExcelValid(message = "PMS资源id不能为空") + private String pmsId; + + @Data + public static class ErrMsg extends PowerDistributionAreaExcel { + + @ColumnWidth(60) + @ExcelProperty(value = "错误信息") + private String errMsg; + + } + +} diff --git a/src/main/java/com/njcn/jbsyncdata/pojo/po/PmsGeneratrixWire.java b/src/main/java/com/njcn/jbsyncdata/pojo/po/PmsGeneratrixWire.java new file mode 100644 index 0000000..941ecc4 --- /dev/null +++ b/src/main/java/com/njcn/jbsyncdata/pojo/po/PmsGeneratrixWire.java @@ -0,0 +1,80 @@ +package com.njcn.jbsyncdata.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.time.LocalDateTime; +import lombok.Getter; +import lombok.Setter; + +/** + *

+ * + *

+ * + * @author wr + * @since 2023-11-28 + */ +@Getter +@Setter +@TableName("pms_generatrix_wire") +public class PmsGeneratrixWire { + + private static final long serialVersionUID = 1L; + + /** + * 线路id + */ + @TableId("Id") + private String id; + + /** + * 线路名称 + */ + @TableField("Name") + private String name; + + /** + * 电站编号 + */ + @TableField("Station_Id") + private String stationId; + + /** + * 电站名称 + */ + @TableField("Station_Name") + private String stationName; + + /** + * 母线名称 + */ + @TableField("Generatrix_Name") + private String generatrixName; + + /** + * 电压等级 + */ + @TableField("Scale") + private String scale; + + /** + * 数据状态 + */ + @TableField("Status") + private Boolean status; + + @TableField("Create_By") + private String createBy; + + @TableField("Create_Time") + private LocalDateTime createTime; + + @TableField("Update_By") + private String updateBy; + + @TableField("Update_Time") + private LocalDateTime updateTime; + + +} diff --git a/src/main/java/com/njcn/jbsyncdata/service/DisPhotovoltaicService.java b/src/main/java/com/njcn/jbsyncdata/service/DisPhotovoltaicService.java index 0420496..5d61246 100644 --- a/src/main/java/com/njcn/jbsyncdata/service/DisPhotovoltaicService.java +++ b/src/main/java/com/njcn/jbsyncdata/service/DisPhotovoltaicService.java @@ -1,9 +1,6 @@ package com.njcn.jbsyncdata.service; -import com.njcn.jbsyncdata.pojo.DisPhotovoltaic10Excel; -import com.njcn.jbsyncdata.pojo.DisPhotovoltaic380Excel; -import com.njcn.jbsyncdata.pojo.DistributionAreaExcel; -import com.njcn.jbsyncdata.pojo.ZhangDistributionAreaExcel; +import com.njcn.jbsyncdata.pojo.*; import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -65,4 +62,9 @@ public interface DisPhotovoltaicService { * @Date: 2023/10/11 14:31 */ Boolean savePmsDistributionArea(); + + /** + * 批量导入台区台账数据 + */ + void importDistributionAreaExcel(List list, HttpServletResponse response); } diff --git a/src/main/java/com/njcn/jbsyncdata/service/IPmsGeneratrixWireService.java b/src/main/java/com/njcn/jbsyncdata/service/IPmsGeneratrixWireService.java new file mode 100644 index 0000000..482f5e8 --- /dev/null +++ b/src/main/java/com/njcn/jbsyncdata/service/IPmsGeneratrixWireService.java @@ -0,0 +1,16 @@ +package com.njcn.jbsyncdata.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.jbsyncdata.pojo.po.PmsGeneratrixWire; + +/** + *

+ * 服务类 + *

+ * + * @author wr + * @since 2023-11-28 + */ +public interface IPmsGeneratrixWireService extends IService { + +} diff --git a/src/main/java/com/njcn/jbsyncdata/service/impl/DisPhotovoltaicServiceImpl.java b/src/main/java/com/njcn/jbsyncdata/service/impl/DisPhotovoltaicServiceImpl.java index fbda3a5..1975790 100644 --- a/src/main/java/com/njcn/jbsyncdata/service/impl/DisPhotovoltaicServiceImpl.java +++ b/src/main/java/com/njcn/jbsyncdata/service/impl/DisPhotovoltaicServiceImpl.java @@ -3,6 +3,7 @@ package com.njcn.jbsyncdata.service.impl; 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.IdUtil; import cn.hutool.core.util.ObjectUtil; @@ -11,13 +12,13 @@ import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.njcn.jbsyncdata.mapper.DictDataMapper; import com.njcn.jbsyncdata.pojo.*; +import com.njcn.jbsyncdata.pojo.po.PmsGeneratrixWire; import com.njcn.jbsyncdata.pojo.po.PmsPowerDistributionarea; -import com.njcn.jbsyncdata.service.DisPhotovoltaicService; -import com.njcn.jbsyncdata.service.IPmsPowerDistributionareaService; -import com.njcn.jbsyncdata.service.IPmsPowerGenerationUserService; -import com.njcn.jbsyncdata.service.IPmsStatationStatService; +import com.njcn.jbsyncdata.service.*; +import com.njcn.jbsyncdata.util.ExcelValid; import com.njcn.jbsyncdata.util.StreamUtil; import java.io.IOException; +import java.lang.reflect.Field; import java.net.URLEncoder; import java.time.LocalDateTime; import java.time.ZoneId; @@ -27,6 +28,7 @@ import java.util.stream.Collectors; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -46,7 +48,7 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService { private final DictDataMapper dictDataMapper; private final IPmsStatationStatService iPmsStatationStatService; private final IPmsPowerDistributionareaService powerDistributionareaService; - + private final IPmsGeneratrixWireService generatrixWireService; @Override public void SavaPmsPowerGenerationUser10KV(List list, HttpServletResponse response) { List info = new ArrayList<>(); @@ -453,6 +455,165 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService { return dictDataMapper.insertPmsDistributionArea(dictData.getId()); } + @Override + public void importDistributionAreaExcel(List list, HttpServletResponse response) { + List info=new ArrayList<>(); + List errInfo=new ArrayList<>(); + if(CollUtil.isNotEmpty(list)){ + PmsPowerDistributionarea area; + //获取部门信息 + List depts = dictDataMapper.selectUserList(); + //电压等级 + List devVoltage = dictDataMapper.selectList("Dev_Voltage"); + //地区特征 + List deviceRegionLype = dictDataMapper.selectList("Area"); + //使用性质 + List deviceUseNature = dictDataMapper.selectList("Device_UseNature"); + //运行状态 + List lineState = dictDataMapper.selectList("Line_State "); + for (PowerDistributionAreaExcel.ErrMsg msg : list) { + String objNull = isObjNull(msg); + if(StrUtil.isNotBlank(objNull)){ + msg.setErrMsg(objNull); + errInfo.add(msg); + continue; + } + area=new PmsPowerDistributionarea(); + area.setId(msg.getId()); + area.setName(msg.getName()); + List deptList = depts.stream().filter(x -> x.getCode().contains(msg.getOrgId())).collect(Collectors.toList()); + if(CollUtil.isEmpty(deptList)){ + String org = subString(msg.getOrgName().replace("国网","")); + List 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(getAlgoDescribe(msg.getVoltageLevel(),devVoltage)); + area.setPCapacity(msg.getPCapacity()); + area.setRegionalism(getAlgoDescribe(msg.getRegionalism(),deviceRegionLype)); + area.setIfRuralPowerGrid("是".equals(msg.getIfRuralPowerGrid())?true:false); + area.setNatureOfUse(getAlgoDescribe(msg.getNatureOfUse(),deviceUseNature)); + area.setPowerSupplyRadius(msg.getPowerSupplyRadius()); + area.setLineLength(msg.getLineLength()); + area.setState(getAlgoDescribe(msg.getState(),lineState)); + area.setDistributedPhotovoltaicNum(msg.getDistributedPhotovoltaicNum()); + area.setPhotovoltaicCapacity(msg.getPhotovoltaicCapacity()); + area.setIfBevAp("是".equals(msg.getIfBevAp())?true:false); + area.setApLoadType(msg.getApLoadType()); + area.setIsUpToGrid("是".equals(msg.getIfBevAp())?true:false); + area.setStatus(true); + area.setInputStatus(0); + area.setCreateTime(LocalDateTimeUtil.now()); + area.setUpdateTime(LocalDateTimeUtil.now()); + area.setPmsID(msg.getPmsId()); + 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 ids = info.stream().map(PmsPowerDistributionarea::getId).collect(Collectors.toList()); + List subInfo = list.stream().filter(x -> ids.contains(x.getId())).collect(Collectors.toList()); + addSubWire(subInfo,devVoltage); + powerDistributionareaService.remove(new LambdaQueryWrapper() + .in(PmsPowerDistributionarea::getId, ids) + ); + powerDistributionareaService.saveBatch(info, 1000); + } + if (CollUtil.isNotEmpty(errInfo)) { + exportExcel(DateUtil.now() + "_台区台账错误信息.xlsx", errInfo,PowerDistributionAreaExcel.ErrMsg.class, response); + } + } + } + //变电站和线路插入 + public void addSubWire(List info,List devVoltage) { + List stats=new ArrayList<>(); + PmsStatationStat stat; + List wires=new ArrayList<>(); + PmsGeneratrixWire wire; + List oldStat = iPmsStatationStatService.list(); + List statIds = oldStat.stream().map(PmsStatationStat::getPowerId).distinct().collect(Collectors.toList()); + List oldWire = generatrixWireService.list(); + List wireIds = oldWire.stream().map(x-> x.getId()+"_"+x.getStationId()).distinct().collect(Collectors.toList()); + //变电站集合 + ArrayList 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 PmsStatationStat(); + stat.setPowerId(errMsg.getPowerStationId()); + stat.setPowerName(errMsg.getPowerrName()); + stat.setOrgId(errMsg.getOrgId()); + stat.setOrgName(errMsg.getOrgName()); + stat.setShouldBeNum(100); + stat.setVoltageLevel(getAlgoDescribe(errMsg.getVoltageLevel(),devVoltage)); + stat.setStatus(1); + stat.setCreateTime(LocalDateTimeUtil.now()); + stat.setUpdateTime(LocalDateTimeUtil.now()); + stats.add(stat); + } + } + //线路 + ArrayList 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 PmsGeneratrixWire(); + wire.setId(errMsg.getLineId()); + wire.setName(errMsg.getLineName()); + wire.setStationId(errMsg.getPowerStationId()); + wire.setStationName(errMsg.getPowerrName()); + wire.setGeneratrixName(errMsg.getPowerrName()); + wire.setScale(getAlgoDescribe(errMsg.getVoltageLevel(),devVoltage)); + wire.setStatus(true); + wire.setCreateTime(LocalDateTimeUtil.now()); + wire.setUpdateTime(LocalDateTimeUtil.now()); + wires.add(wire); + } + } + if(CollUtil.isNotEmpty(stats)){ + iPmsStatationStatService.saveBatch(stats); + } + if(CollUtil.isNotEmpty(wires)){ + generatrixWireService.saveBatch(wires); + } + + } + + @SneakyThrows + public 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 String getAlgoDescribe(String name, List dictData) { List dictDataList = dictData.stream().filter(x -> x.getName().indexOf(name) != -1).collect(Collectors.toList()); if (CollUtil.isNotEmpty(dictDataList)) { diff --git a/src/main/java/com/njcn/jbsyncdata/service/impl/PmsGeneratrixWireServiceImpl.java b/src/main/java/com/njcn/jbsyncdata/service/impl/PmsGeneratrixWireServiceImpl.java new file mode 100644 index 0000000..c07dcb2 --- /dev/null +++ b/src/main/java/com/njcn/jbsyncdata/service/impl/PmsGeneratrixWireServiceImpl.java @@ -0,0 +1,20 @@ +package com.njcn.jbsyncdata.service.impl; + +import com.njcn.jbsyncdata.mapper.PmsGeneratrixWireMapper; +import com.njcn.jbsyncdata.pojo.po.PmsGeneratrixWire; +import com.njcn.jbsyncdata.service.IPmsGeneratrixWireService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author wr + * @since 2023-11-28 + */ +@Service +public class PmsGeneratrixWireServiceImpl extends ServiceImpl implements IPmsGeneratrixWireService { + +} diff --git a/src/main/java/com/njcn/jbsyncdata/util/ExcelValid.java b/src/main/java/com/njcn/jbsyncdata/util/ExcelValid.java new file mode 100644 index 0000000..b5d9032 --- /dev/null +++ b/src/main/java/com/njcn/jbsyncdata/util/ExcelValid.java @@ -0,0 +1,16 @@ +package com.njcn.jbsyncdata.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + *

Excel导入必填校验注解

+ * + */ +@Target({ ElementType.FIELD, ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface ExcelValid { + String message() default "导入有未填入的字段"; +} diff --git a/src/main/java/com/njcn/jbsyncdata/util/PubUtils.java b/src/main/java/com/njcn/jbsyncdata/util/PubUtils.java index ae18b9b..8936f9c 100644 --- a/src/main/java/com/njcn/jbsyncdata/util/PubUtils.java +++ b/src/main/java/com/njcn/jbsyncdata/util/PubUtils.java @@ -567,11 +567,11 @@ public class PubUtils { .head(ZhangDistributionAreaExcel.class) .doReadAllSync(); listZhang = listZhang.stream() - .filter(t -> StrUtil.isNotBlank(t.getId())) - .filter(StreamUtil.distinctByKey(ZhangDistributionAreaExcel::getId)) - .filter(t -> !"#N/A".equals(t.getPmsID())) - .filter(t -> StrUtil.isNotBlank(t.getPmsID())) - .collect(Collectors.toList()); + .filter(t -> StrUtil.isNotBlank(t.getId())) + .filter(StreamUtil.distinctByKey(ZhangDistributionAreaExcel::getId)) + .filter(t -> !"#N/A".equals(t.getPmsID())) + .filter(t -> StrUtil.isNotBlank(t.getPmsID())) + .collect(Collectors.toList()); //读取所有没数据的用户号 FileReader fileReader = new FileReader("D:\\test\\all.txt"); @@ -609,7 +609,23 @@ public class PubUtils { .replaceAll("PhV_phsB", "B相电压") .replaceAll("PhV_phsC", "C相电压") .replaceAll("TotW", "有功") - .replaceAll("TotVar", "无功"); + .replaceAll("TotVar", "无功") + .replaceAll("HphV2_phsA", "A相电压2次谐波值") + .replaceAll("HphV2_phsB", "B相电压2次谐波值") + .replaceAll("HphV2_phsC", "C相电压2次谐波值") + .replaceAll("HphV3_phsA", "A相电压3次谐波值") + .replaceAll("HphV3_phsB", "B相电压3次谐波值") + .replaceAll("HphV3_phsC", "C相电压3次谐波值") + .replaceAll("HphV5_phsA", "A相电压5次谐波值") + .replaceAll("HphV5_phsB", "B相电压5次谐波值") + .replaceAll("HphV7_phsC", "C相电压7次谐波值") + .replaceAll("HphV7_phsA", "A相电压7次谐波值") + .replaceAll("HphV7_phsB", "B相电压7次谐波值") + .replaceAll("HphV5_phsC", "C相电压5次谐波值") + .replaceAll("HphV9_phsA", "A相电压9次谐波值") + .replaceAll("HphV9_phsB", "B相电压9次谐波值") + .replaceAll("HphV9_phsC", "C相电压9次谐波值") + ; disPhotovoltaic10Excel.setTypes(info); final10kVUserData.add(disPhotovoltaic10Excel); } @@ -633,22 +649,47 @@ public class PubUtils { for (String userId : keyedSet) { disPhotovoltaic380ExcelList = all380VMap.get(userId); if (CollectionUtil.isNotEmpty(disPhotovoltaic380ExcelList)) { - disPhotovoltaic380Excel = disPhotovoltaic380ExcelList.get(0); - info = noPartDataMap.get(userId).get(0); - info = info.substring(info.indexOf(StrPool.COMMA) + 1); - info = info.replaceAll(StrPool.AT, "||") - .replaceAll("A_phsA", "A相电流") - .replaceAll("A_phsB", "B相电流") - .replaceAll("A_phsC", "C相电流") - .replaceAll("PhV_phsA", "A相电压") - .replaceAll("PhV_phsB", "B相电压") - .replaceAll("PhV_phsC", "C相电压") - .replaceAll("TotW", "有功") - .replaceAll("TotVar", "无功"); - disPhotovoltaic380Excel.setTypes(info); - final380VUserData.add(disPhotovoltaic380Excel); + List collect1 = disPhotovoltaic380ExcelList.stream().distinct().collect(Collectors.toList()); + for (ZhangDistributionAreaExcel zhangDistributionAreaExcel : collect1) { + disPhotovoltaic380Excel=zhangDistributionAreaExcel; + info = zhangDistributionAreaExcel.getPmsID(); + info = info.substring(info.indexOf(StrPool.COMMA) + 1); + info = info.replaceAll(StrPool.AT, "||") + .replaceAll("A_phsA", "A相电流") + .replaceAll("A_phsB", "B相电流") + .replaceAll("A_phsC", "C相电流") + .replaceAll("PhV_phsA", "A相电压") + .replaceAll("PhV_phsB", "B相电压") + .replaceAll("PhV_phsC", "C相电压") + .replaceAll("TotW", "有功") + .replaceAll("TotVar", "无功") + .replaceAll("HphV2_phsA", "A相电压2次谐波值") + .replaceAll("HphV2_phsB", "B相电压2次谐波值") + .replaceAll("HphV2_phsC", "C相电压2次谐波值") + .replaceAll("HphV3_phsA", "A相电压3次谐波值") + .replaceAll("HphV3_phsB", "B相电压3次谐波值") + .replaceAll("HphV3_phsC", "C相电压3次谐波值") + .replaceAll("HphV5_phsA", "A相电压5次谐波值") + .replaceAll("HphV5_phsB", "B相电压5次谐波值") + .replaceAll("HphV7_phsC", "C相电压7次谐波值") + .replaceAll("HphV7_phsA", "A相电压7次谐波值") + .replaceAll("HphV7_phsB", "B相电压7次谐波值") + .replaceAll("HphV5_phsC", "C相电压5次谐波值") + .replaceAll("HphV9_phsA", "A相电压9次谐波值") + .replaceAll("HphV9_phsB", "B相电压9次谐波值") + .replaceAll("HphV9_phsC", "C相电压9次谐波值") + ; + disPhotovoltaic380Excel.setTypes(info); + final380VUserData.add(disPhotovoltaic380Excel); + } + + } } + List collect1 = final380VUserData.stream().map(ZhangDistributionAreaExcel::getId).collect(Collectors.toList()); + List collect2 = collect4.stream().map(ZhangDistributionAreaExcel::getId).collect(Collectors.toList()); + listZhang= listZhang.stream().filter(t -> !collect1.contains(t.getId())).collect(Collectors.toList()); + listZhang= listZhang.stream().filter(t -> !collect2.contains(t.getId())).collect(Collectors.toList()); EasyExcel.write("D:\\test\\张家口部分没有数据的.xlsx", ZhangDistributionAreaExcel.class).sheet("张家口部分没有数据的").doWrite(final380VUserData); long millis4 = System.currentTimeMillis(); System.out.println("张家口部分没有数据的:" + (millis4 - millis3));