Compare commits
10 Commits
24fa9db4d4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
722c4e11c3 | ||
|
|
28daba40af | ||
|
|
b86cae2a0a | ||
|
|
6c8d5d3ff7 | ||
|
|
e1b216fbdc | ||
|
|
1129cee5b3 | ||
|
|
71ed4ffe12 | ||
|
|
e73aeabf46 | ||
|
|
fc5a1cc78b | ||
| 8c16d524e5 |
@@ -1,11 +1,17 @@
|
||||
package com.njcn.jbsyncdata;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.conf.EnableMPP;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@MapperScan("com.njcn.**.mapper")
|
||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||
@EnableScheduling
|
||||
@EnableAsync
|
||||
@EnableMPP
|
||||
public class JbSyncdataApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.njcn.jbsyncdata.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年03月11日 09:32
|
||||
*/
|
||||
@Data
|
||||
@Order(100)
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
@AllArgsConstructor
|
||||
public class AsyncConfiguration {
|
||||
|
||||
private final GeneralInfo generalInfo;
|
||||
|
||||
@Bean("asyncExecutor")
|
||||
public Executor asyncExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
// 核心线程数:线程池创建时候初始化的线程数
|
||||
executor.setCorePoolSize(generalInfo.getCorePoolSize());
|
||||
// 最大线程数:线程池最大的线程数,只有在缓冲队列满了之后才会申请超过核心线程数的线程
|
||||
executor.setMaxPoolSize(generalInfo.getMaxPoolSize());
|
||||
// 缓冲队列:用来缓冲执行任务的队列
|
||||
executor.setQueueCapacity(generalInfo.getQueueCapacity());
|
||||
// 允许线程的空闲时间60秒:当超过了核心线程之外的线程在空闲时间到达之后会被销毁
|
||||
executor.setKeepAliveSeconds(generalInfo.getKeepAliveSeconds());
|
||||
// 线程池名的前缀:设置好了之后可以方便我们定位处理任务所在的线程池
|
||||
executor.setThreadNamePrefix(generalInfo.getMicroServiceName());
|
||||
// 缓冲队列满了之后的拒绝策略:由调用线程处理(一般是主线程)
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
}
|
||||
33
src/main/java/com/njcn/jbsyncdata/config/GeneralInfo.java
Normal file
33
src/main/java/com/njcn/jbsyncdata/config/GeneralInfo.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.njcn.jbsyncdata.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年08月19日 15:56
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@Order(10)
|
||||
public class GeneralInfo {
|
||||
|
||||
@Value("${microservice.ename}")
|
||||
private String microServiceName;
|
||||
|
||||
@Value("${threadPool.corePoolSize}")
|
||||
private int corePoolSize;
|
||||
|
||||
@Value("${threadPool.maxPoolSize}")
|
||||
private int maxPoolSize;
|
||||
|
||||
@Value("${threadPool.queueCapacity}")
|
||||
private int queueCapacity;
|
||||
|
||||
@Value("${threadPool.keepAliveSeconds}")
|
||||
private int keepAliveSeconds;
|
||||
|
||||
}
|
||||
@@ -1,31 +1,30 @@
|
||||
package com.njcn.jbsyncdata.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.file.FileReader;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
import com.njcn.jbsyncdata.pojo.DisPhotovoltaic10Excel;
|
||||
import com.njcn.jbsyncdata.pojo.DisPhotovoltaic380Excel;
|
||||
import com.njcn.jbsyncdata.pojo.*;
|
||||
import com.njcn.jbsyncdata.service.DisPhotovoltaicService;
|
||||
import com.njcn.jbsyncdata.service.IBusinessService;
|
||||
import com.njcn.jbsyncdata.service.IPmsSubstationService;
|
||||
import com.njcn.jbsyncdata.util.RestTemplateUtil;
|
||||
import com.njcn.jbsyncdata.util.StreamUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -43,6 +42,7 @@ public class DisPhotovoltaicController {
|
||||
|
||||
private final IBusinessService businessService;
|
||||
private final DisPhotovoltaicService disPhotovoltaicService;
|
||||
private final IPmsSubstationService substationService;
|
||||
|
||||
/**
|
||||
* @param date yyyy-MM-dd
|
||||
@@ -80,6 +80,81 @@ public class DisPhotovoltaicController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date yyyy-MM-dd
|
||||
*/
|
||||
@ApiOperation(value = "查询指定日期所有台区用户的遥测数据")
|
||||
@PostMapping("/queryTelemetryAreaData")
|
||||
public void queryTelemetryAreaData(String date) {
|
||||
try {
|
||||
businessService.queryTelemetryAreaData(date);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param startTime 起始时间 yyyy-MM-dd
|
||||
* @param endTime 截止时间 yyyy-MM-dd
|
||||
*/
|
||||
@ApiOperation(value = "查询日期范围内所有台区用户的遥测数据")
|
||||
@PostMapping("/queryTelemetryAreaDataTimeRange")
|
||||
public void queryTelemetryAreaDataTimeRange(String startTime, String endTime) {
|
||||
try {
|
||||
DateTime startDate = DateUtil.parse(startTime, DatePattern.NORM_DATE_FORMAT);
|
||||
DateTime endDate = DateUtil.parse(endTime, DatePattern.NORM_DATE_FORMAT);
|
||||
long betweenDay = DateUtil.betweenDay(startDate, endDate, true);
|
||||
//第一天
|
||||
businessService.queryTelemetryAreaData(DateUtil.format(startDate, DatePattern.NORM_DATE_PATTERN));
|
||||
//后续递增1
|
||||
for (int i = 0; i < betweenDay; i++) {
|
||||
startDate = DateUtil.offsetDay(startDate, 1);
|
||||
businessService.queryTelemetryAreaData(DateUtil.format(startDate, DatePattern.NORM_DATE_PATTERN));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date yyyy-MM-dd
|
||||
*/
|
||||
@ApiOperation(value = "查询指定日期所有台区用户的谐波遥测数据")
|
||||
@PostMapping("/queryTelemetryAreaEmsData")
|
||||
public void queryTelemetryAreaEmsData(String date) {
|
||||
try {
|
||||
businessService.queryTelemetryInterfaceAreaData(date);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param startTime 起始时间 yyyy-MM-dd
|
||||
* @param endTime 截止时间 yyyy-MM-dd
|
||||
*/
|
||||
@ApiOperation(value = "查询日期范围内所有台区用户的谐波遥测数据")
|
||||
@PostMapping("/queryTelemetryAreaEmsDataTimeRange")
|
||||
public void queryTelemetryAreaEmsDataTimeRange(String startTime, String endTime) {
|
||||
try {
|
||||
DateTime startDate = DateUtil.parse(startTime, DatePattern.NORM_DATE_FORMAT);
|
||||
DateTime endDate = DateUtil.parse(endTime, DatePattern.NORM_DATE_FORMAT);
|
||||
long betweenDay = DateUtil.betweenDay(startDate, endDate, true);
|
||||
//第一天
|
||||
businessService.queryTelemetryInterfaceAreaData(DateUtil.format(startDate, DatePattern.NORM_DATE_PATTERN));
|
||||
//后续递增1
|
||||
for (int i = 0; i < betweenDay; i++) {
|
||||
startDate = DateUtil.offsetDay(startDate, 1);
|
||||
businessService.queryTelemetryInterfaceAreaData(DateUtil.format(startDate, DatePattern.NORM_DATE_PATTERN));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "导入10kv分布式光伏接入情况", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@PostMapping("/import10KV")
|
||||
@@ -114,10 +189,50 @@ public class DisPhotovoltaicController {
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导入唐山供电公司台区数据")
|
||||
@PostMapping("/importArea")
|
||||
public void importArea(MultipartFile file, HttpServletResponse response) throws Exception {
|
||||
List<DistributionAreaExcel> list = EasyExcel.read(file.getInputStream())
|
||||
.head(DistributionAreaExcel.class)
|
||||
.sheet(0).doReadSync();
|
||||
list = list.stream()
|
||||
.filter(t -> !"#N/A".equals(t.getPmsID()))
|
||||
.filter(t -> StrUtil.isNotBlank(t.getPmsID()))
|
||||
.collect(Collectors.toList());
|
||||
disPhotovoltaicService.SavaArea(list,response);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导入张家口供电公司台区数据")
|
||||
@PostMapping("/importZhangArea")
|
||||
public void importZhangArea(MultipartFile file, HttpServletResponse response) throws Exception {
|
||||
List<ZhangDistributionAreaExcel> list = EasyExcel.read(file.getInputStream())
|
||||
.head(ZhangDistributionAreaExcel.class)
|
||||
.doReadAllSync();
|
||||
list = list.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());
|
||||
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<PowerDistributionAreaExcel.ErrMsg> list = EasyExcel.read(file.getInputStream())
|
||||
.head(PowerDistributionAreaExcel.ErrMsg.class)
|
||||
.headRowNumber(2)
|
||||
.doReadAllSync();
|
||||
disPhotovoltaicService.importDistributionAreaExcel(list,response);
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "将用户数据导入到配网表中")
|
||||
@PostMapping("/insertDistributionMonitor")
|
||||
public String import380KV() throws Exception {
|
||||
public String import380KV() {
|
||||
Boolean aBoolean = disPhotovoltaicService.savePmsDistributionMonitor();
|
||||
if (aBoolean) {
|
||||
return "数据导入成功";
|
||||
@@ -125,4 +240,69 @@ public class DisPhotovoltaicController {
|
||||
return "数据导入失败";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "将台区数据导入到配网表中")
|
||||
@PostMapping("/insertDistributionArea")
|
||||
public String importArea() {
|
||||
Boolean aBoolean = disPhotovoltaicService.savePmsDistributionArea();
|
||||
if (aBoolean) {
|
||||
return "数据导入成功";
|
||||
}
|
||||
return "数据导入失败";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "业务中台")
|
||||
@GetMapping("/addYwZtSubstation")
|
||||
public String addYwZtSubstation(String distribution, String psrType) {
|
||||
Boolean aBoolean = substationService.addYwZtSubstation(distribution,psrType);
|
||||
if (aBoolean) {
|
||||
return "数据导入成功";
|
||||
}
|
||||
return "数据导入失败";
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 30 0 * * ?")
|
||||
public void insert() {
|
||||
log.error(Thread.currentThread().getName(),"1.定时器启动----!");
|
||||
DateTime dateTime = DateUtil.offsetDay(new Date(), -1);
|
||||
String s=dateTime.toString();
|
||||
String ds = s.substring(0, s.indexOf(" "));
|
||||
log.error(Thread.currentThread().getName() + "2.定时器执行数据日期 "+ds+"----!");
|
||||
businessService.queryTelemetryData(ds);
|
||||
log.error(Thread.currentThread().getName() + "台区定时器执行数据日期 "+ds+"----!");
|
||||
businessService.queryTelemetryAreaData(ds);
|
||||
log.error(Thread.currentThread().getName() + "2.定时器执行数据成功 "+ds+"----!");
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
public void insertPms() {
|
||||
log.error(Thread.currentThread().getName(),"1.定时器启动----!");
|
||||
DateTime dateTime = DateUtil.offsetDay(new Date(), -1);
|
||||
String s=dateTime.toString();
|
||||
String ds = s.substring(0, s.indexOf(" "));
|
||||
log.error(Thread.currentThread().getName() + "1.定时器执行遥测数据日期 "+ds+"----!");
|
||||
businessService.queryTelemetryInterfaceAreaData(ds);
|
||||
log.error(Thread.currentThread().getName() + "2.定时器执行数据成功 "+ds+"----!");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "将台区数据导入到配网表中")
|
||||
@PostMapping("/cs")
|
||||
public String importAreaaa() {
|
||||
Map<String, String> headers=new HashMap<>();
|
||||
headers.put("Content-Type", "application/xml");
|
||||
|
||||
String aa="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:face=\"http://face.service.prss.com.app\">\n" +
|
||||
" <soapenv:Header/>\n" +
|
||||
" <soapenv:Body>\n" +
|
||||
" <face:getBizcDytsYc>\n" +
|
||||
" <face:in0>{\"data\":{\"pms_id\":\"634cb757ff8af6df8752399e910152634c8e4b3bfd\",\"startdate\":\"2024-06-10 00:00:00\",\"enddate\":\"2024-06-10 03:00:00\"}}</face:in0>\n" +
|
||||
" </face:getBizcDytsYc>\n" +
|
||||
" </soapenv:Body>\n" +
|
||||
"</soapenv:Envelope>";
|
||||
RestTemplateUtil restTemplateUtil = new RestTemplateUtil();
|
||||
ResponseEntity<String> userEntity = restTemplateUtil.post("http://10.118.110.221:8013/prssface-ems/ws/EmsInterface",headers,aa, String.class);
|
||||
userEntity.getBody();
|
||||
|
||||
System.out.println();
|
||||
return userEntity.getBody().length() + "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.njcn.jbsyncdata.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public enum EmsInterfaceTypeEnum {
|
||||
|
||||
A_VTHD("70100","A相电压谐波总畸变率HVA","A","data_v","v_thd"),
|
||||
A_V3("70103","A相3次电压谐波","A","data_harmrate_v","v_3"),
|
||||
A_V4("70104","A相4次电压谐波","A","data_harmrate_v","v_4"),
|
||||
A_V5("70105","A相5次电压谐波","A","data_harmrate_v","v_5"),
|
||||
A_V6("70106","A相6次电压谐波","A","data_harmrate_v","v_6"),
|
||||
A_V7("70107","A相7次电压谐波","A","data_harmrate_v","v_7"),
|
||||
A_V8("70108","A相8次电压谐波","A","data_harmrate_v","v_8"),
|
||||
A_V9("70109","A相9次电压谐波","A","data_harmrate_v","v_9"),
|
||||
A_V10("70110","A相10次电压谐波","A","data_harmrate_v","v_10"),
|
||||
A_V11("70111","A相11次电压谐波","A","data_harmrate_v","v_11"),
|
||||
A_V12("70112","A相12次电压谐波","A","data_harmrate_v","v_12"),
|
||||
A_V13("70113","A相13次电压谐波","A","data_harmrate_v","v_13"),
|
||||
B_VTHD("70200","B相电压谐波总畸变率HVB","B","data_v","v_thd"),
|
||||
B_V3("70203","B相3次电压谐波","B","data_harmrate_v","v_3"),
|
||||
B_V4("70204","B相4次电压谐波","B","data_harmrate_v","v_4"),
|
||||
B_V5("70205","B相5次电压谐波","B","data_harmrate_v","v_5"),
|
||||
B_V6("70206","B相6次电压谐波","B","data_harmrate_v","v_6"),
|
||||
B_V7("70207","B相7次电压谐波","B","data_harmrate_v","v_7"),
|
||||
B_V8("70208","B相8次电压谐波","B","data_harmrate_v","v_8"),
|
||||
B_V9("70209","B相9次电压谐波","B","data_harmrate_v","v_9"),
|
||||
B_V10("70210","B相10次电压谐波","B","data_harmrate_v","v_10"),
|
||||
B_V11("70211","B相11次电压谐波","B","data_harmrate_v","v_11"),
|
||||
B_V12("70212","B相12次电压谐波","B","data_harmrate_v","v_12"),
|
||||
B_V13("70213","B相13次电压谐波","B","data_harmrate_v","v_13"),
|
||||
C_V4("70221","C相4次电压谐波","C","data_harmrate_v","v_4"),
|
||||
C_V6("70223","C相6次电压谐波","C","data_harmrate_v","v_6"),
|
||||
C_V8("70225","C相8次电压谐波","C","data_harmrate_v","v_8"),
|
||||
C_V10("70227","C相10次电压谐波","C","data_harmrate_v","v_10"),
|
||||
C_V12("70229","C相12次电压谐波","C","data_harmrate_v","v_12"),
|
||||
A_I4("70231","A相4次电流谐波","A","data_i","i_4"),
|
||||
A_I6("70232","A相6次电流谐波","A","data_i","i_6"),
|
||||
A_I8("70233","A相8次电流谐波","A","data_i","i_8"),
|
||||
A_I10("70234","A相10次电流谐波","A","data_i","i_10"),
|
||||
A_I12("70235","A相12次电流谐波","A","data_i","i_12"),
|
||||
B_I4("70236","B相4次电流谐波","B","data_i","i_4"),
|
||||
B_I6("70237","B相6次电流谐波","B","data_i","i_6"),
|
||||
B_I8("70238","B相8次电流谐波","B","data_i","i_8"),
|
||||
B_I10("70239","B相10次电流谐波","B","data_i","i_10"),
|
||||
B_I12("70240","B相12次电流谐波","B","data_i","i_12"),
|
||||
C_I4("70241","C相4次电流谐波","C","data_i","i_4"),
|
||||
C_I6("70242","C相6次电流谐波","C","data_i","i_6"),
|
||||
C_I8("70243","C相8次电流谐波","C","data_i","i_8"),
|
||||
C_I10("70244","C相10次电流谐波","C","data_i","i_10"),
|
||||
C_I12("70245","C相12次电流谐波","C","data_i","i_12"),
|
||||
A_V2("70246","A相2次电压谐波","A","data_harmrate_v","v_2"),
|
||||
B_V2("70247","B相2次电压谐波","B","data_harmrate_v","v_2"),
|
||||
C_V2("70248","C相2次电压谐波","C","data_harmrate_v","v_2"),
|
||||
A_I2("70249","A相2次电流谐波","A","data_i","i_2"),
|
||||
B_I2("70250","B相2次电流谐波","B","data_i","i_2"),
|
||||
C_I2("70251","C相2次电流谐波","C","data_i","i_2"),
|
||||
C_VTHD("70300","C相电压谐波总畸变率HVC","C","data_v","v_thd"),
|
||||
C_V3("70303","C相3次电压谐波","C","data_harmrate_v","v_3"),
|
||||
C_V5("70305","C相5次电压谐波","C","data_harmrate_v","v_5"),
|
||||
C_V7("70307","C相7次电压谐波","C","data_harmrate_v","v_7"),
|
||||
C_V9("70309","C相9次电压谐波","C","data_harmrate_v","v_9"),
|
||||
C_V11("70311","C相11次电压谐波","C","data_harmrate_v","v_11"),
|
||||
C_V13("70313","C相13次电压谐波","C","data_harmrate_v","v_13"),
|
||||
A_I3("70910","A相3次电流谐波","A","data_i","i_3"),
|
||||
A_I5("70911","A相5次电流谐波","A","data_i","i_5"),
|
||||
A_I7("70912","A相7次电流谐波","A","data_i","i_7"),
|
||||
A_I9("70913","A相9次电流谐波","A","data_i","i_9"),
|
||||
A_I11("70914","A相11次电流谐波","A","data_i","i_11"),
|
||||
A_I13("70915","A相13次电流谐波","A","data_i","i_13"),
|
||||
B_I3("70919","B相3次电流谐波","B","data_i","i_3"),
|
||||
B_I5("70920","B相5次电流谐波","B","data_i","i_5"),
|
||||
B_I7("70921","B相7次电流谐波","B","data_i","i_7"),
|
||||
B_I9("70922","B相9次电流谐波","B","data_i","i_9"),
|
||||
B_I11("70923","B相11次电流谐波","B","data_i","i_11"),
|
||||
B_I13("70924","B相13次电流谐波","B","data_i","i_13"),
|
||||
C_I3("70928","C相3次电流谐波","C","data_i","i_3"),
|
||||
C_I5("70929","C相5次电流谐波","C","data_i","i_5"),
|
||||
C_I7("70930","C相7次电流谐波","C","data_i","i_7"),
|
||||
C_I9("70931","C相9次电流谐波","C","data_i","i_9"),
|
||||
C_I11("70932","C相11次电流谐波","C","data_i","i_11"),
|
||||
C_I13("70933","C相13次电流谐波","C","data_i","i_13"),
|
||||
A_ITHD("70952","A相电流谐波畸变率","A","data_i","i_thd"),
|
||||
B_ITHD("70953","B相电流谐波畸变率","B","data_i","i_thd"),
|
||||
C_ITHD("70954","C相电流谐波畸变率","C","data_i","i_thd"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
//冀北指标名称
|
||||
private final String measType;
|
||||
//中文名
|
||||
private final String cnName;
|
||||
//相别
|
||||
private final String phaseType;
|
||||
//表名
|
||||
private final String tableName;
|
||||
//字段名
|
||||
private final String fieldName;
|
||||
|
||||
EmsInterfaceTypeEnum(String measType, String cnName, String phaseType, String tableName, String fieldName) {
|
||||
this.measType = measType;
|
||||
this.cnName = cnName;
|
||||
this.phaseType = phaseType;
|
||||
this.tableName = tableName;
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据指标获取当前指标的信息
|
||||
* @param measType 指标名称
|
||||
*/
|
||||
public static EmsInterfaceTypeEnum getMeasTypeEnumByMeasType(String measType) {
|
||||
for (EmsInterfaceTypeEnum item : values()) {
|
||||
if (item.getMeasType().equals(measType)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有指标类型名称集合
|
||||
*/
|
||||
public static List<String> getMeasList() {
|
||||
List<String> measLiST = new ArrayList<>();
|
||||
for (EmsInterfaceTypeEnum temp : values()) {
|
||||
String type = temp.getMeasType();
|
||||
measLiST.add(type);
|
||||
}
|
||||
return measLiST;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,27 @@ public enum MeasTypeEnum {
|
||||
|
||||
TOTW("TotW", "有功", "T","data_harmpower_p","p"),
|
||||
|
||||
TOTVAR("TotVar", "无功", "T","data_harmpower_q","q");
|
||||
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;
|
||||
|
||||
16
src/main/java/com/njcn/jbsyncdata/mapper/BusBarMapper.java
Normal file
16
src/main/java/com/njcn/jbsyncdata/mapper/BusBarMapper.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.njcn.jbsyncdata.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.BusBarResult;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
public interface BusBarMapper extends MppBaseMapper<BusBarResult.BusBar> {
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public interface DictDataMapper extends BaseMapper<DictData> {
|
||||
List<DictData> selectList(@Param("code") String code);
|
||||
DictData selectByCode(@Param("dataCode") String dataCode,@Param("typeCode") String typeCode);
|
||||
List<Dept> selectUserList();
|
||||
Boolean deletePmsDistributionMonitor(@Param("date") String date);
|
||||
Boolean deletePmsDistributionMonitor(@Param("dic") String dic,@Param("type") String type);
|
||||
Boolean insertPmsDistributionMonitor();
|
||||
|
||||
Boolean insertPmsDistributionArea(@Param("dic") String dic);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.jbsyncdata.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.IncomeAndOutgoLinesResult;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
public interface IncomeAndOutgoMapper extends MppBaseMapper<IncomeAndOutgoLinesResult.PsrInfo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.jbsyncdata.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.LineDetail;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
public interface LineDetailMapper extends MppBaseMapper<LineDetail> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.jbsyncdata.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.jbsyncdata.pojo.po.PmsGeneratrixWire;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-11-28
|
||||
*/
|
||||
public interface PmsGeneratrixWireMapper extends BaseMapper<PmsGeneratrixWire> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.jbsyncdata.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.jbsyncdata.pojo.po.PmsPowerDistributionarea;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台区信息 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-11-20
|
||||
*/
|
||||
public interface PmsPowerDistributionareaMapper extends BaseMapper<PmsPowerDistributionarea> {
|
||||
|
||||
List<String> getDeptIds(@Param("id") String id);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.jbsyncdata.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.jbsyncdata.pojo.PmsSubstation;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
public interface PmsSubstationMapper extends BaseMapper<PmsSubstation> {
|
||||
|
||||
}
|
||||
@@ -36,11 +36,48 @@
|
||||
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="date != null and date !=''">
|
||||
DATE_FORMAT(Create_Time, '%Y-%m-%d') = DATE_FORMAT(#{date}, '%Y-%m-%d')
|
||||
<if test="type != null and type !='' ">
|
||||
and If_Power_User = #{type}
|
||||
</if>
|
||||
<if test="dic != null and dic !=''">
|
||||
and Monitor_Sort = #{dic}
|
||||
</if>
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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.jbsyncdata.mapper.PmsGeneratrixWireMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?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.jbsyncdata.mapper.PmsPowerDistributionareaMapper">
|
||||
|
||||
<select id="getDeptIds" resultType="java.lang.String">
|
||||
select code from sys_dept where find_in_set(#{id},pids) and state = 1
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.njcn.jbsyncdata.pojo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台区信息
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-11-20
|
||||
*/
|
||||
@Data
|
||||
@ColumnWidth(30)
|
||||
public class DistributionAreaExcel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 台区编号
|
||||
*/
|
||||
@ExcelProperty(value = "台区编号")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 变压器名称
|
||||
*/
|
||||
@ExcelProperty("台区名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* PMS资源id(同源)
|
||||
*/
|
||||
@ExcelProperty("PMS资源id(同源)")
|
||||
private String pmsID;
|
||||
|
||||
/**
|
||||
* 监测线路名称
|
||||
*/
|
||||
@ExcelProperty("所属线路")
|
||||
private String lineName;
|
||||
|
||||
@ExcelProperty(value = "公司名称")
|
||||
private String orgName;
|
||||
|
||||
@ExcelProperty(value = "变电站名称")
|
||||
private String powerrName;
|
||||
|
||||
@ExcelProperty(value = "无数据的指标")
|
||||
private String types;
|
||||
|
||||
}
|
||||
25
src/main/java/com/njcn/jbsyncdata/pojo/InfluxAreaData.java
Normal file
25
src/main/java/com/njcn/jbsyncdata/pojo/InfluxAreaData.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.njcn.jbsyncdata.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class InfluxAreaData implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 台区id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* influxData数据
|
||||
*/
|
||||
private String influxData;
|
||||
|
||||
|
||||
}
|
||||
113
src/main/java/com/njcn/jbsyncdata/pojo/PmsSubstation.java
Normal file
113
src/main/java/com/njcn/jbsyncdata/pojo/PmsSubstation.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package com.njcn.jbsyncdata.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pq_ywzt_substation")
|
||||
public class PmsSubstation {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 变电站序号
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 所属地市
|
||||
*/
|
||||
private String orgId;
|
||||
|
||||
/**
|
||||
* 数据类型zf01:变电站 zf05:电厂
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 运维单位
|
||||
*/
|
||||
private String operationName;
|
||||
|
||||
/**
|
||||
* 电站名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 电压等级Id,字典表
|
||||
*/
|
||||
private String scale;
|
||||
|
||||
/**
|
||||
* 电压等级名称
|
||||
*/
|
||||
private String scaleName;
|
||||
|
||||
/**
|
||||
* 维护班组
|
||||
*/
|
||||
private String maintenanceName;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
*/
|
||||
private String runStatus;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String deviceCoding;
|
||||
|
||||
/**
|
||||
* 投运日期
|
||||
*/
|
||||
private LocalDateTime runTime;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private BigDecimal lng;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private BigDecimal lat;
|
||||
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台区导入模板
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
235
src/main/java/com/njcn/jbsyncdata/pojo/YWZTSubstation.java
Normal file
235
src/main/java/com/njcn/jbsyncdata/pojo/YWZTSubstation.java
Normal file
@@ -0,0 +1,235 @@
|
||||
package com.njcn.jbsyncdata.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2024/8/28 14:55
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class YWZTSubstation {
|
||||
|
||||
@JsonProperty("errors")
|
||||
private String errors;
|
||||
@JsonProperty("message")
|
||||
private String message;
|
||||
@JsonProperty("result")
|
||||
private ResultDTO result;
|
||||
@JsonProperty("status")
|
||||
private String status;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class ResultDTO {
|
||||
@JsonProperty("zf01")
|
||||
private Zf01DTO zf01;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class Zf01DTO {
|
||||
@JsonProperty("current")
|
||||
private Integer current;
|
||||
@JsonProperty("pages")
|
||||
private Integer pages;
|
||||
@JsonProperty("records")
|
||||
private List<RecordsDTO> records;
|
||||
@JsonProperty("size")
|
||||
private Integer size;
|
||||
@JsonProperty("total")
|
||||
private Integer total;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class RecordsDTO {
|
||||
@JsonProperty("assets")
|
||||
private List<AssetsDTO> assets;
|
||||
@JsonProperty("distribution")
|
||||
private Integer distribution;
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
@JsonProperty("modelId")
|
||||
private String modelId;
|
||||
@JsonProperty("resource")
|
||||
private ResourceDTO resource;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class ResourceDTO {
|
||||
@JsonProperty("maintOrg")
|
||||
private String maintOrg;
|
||||
@JsonProperty("stationType")
|
||||
private String stationType;
|
||||
@JsonProperty("voltageLevelName")
|
||||
private String voltageLevelName;// FIXME check this code
|
||||
@JsonProperty("contaminationLevelName")
|
||||
private String contaminationLevelName;// FIXME check this code
|
||||
@JsonProperty("dispatchMonitor")
|
||||
private String dispatchMonitor;
|
||||
@JsonProperty("fireAcceptance")
|
||||
private String fireAcceptance;
|
||||
@JsonProperty("type")
|
||||
private String type;
|
||||
@JsonProperty("pubPrivFlagName")
|
||||
private String pubPrivFlagName;// FIXME check this code
|
||||
@JsonProperty("arrangement")
|
||||
private String arrangement;
|
||||
@JsonProperty("regionalismName")
|
||||
private String regionalismName;// FIXME check this code
|
||||
@JsonProperty("coverArea")
|
||||
private Double coverArea;
|
||||
@JsonProperty("isTelecontrol")
|
||||
private String isTelecontrol;
|
||||
@JsonProperty("isRural")
|
||||
private String isRural;
|
||||
@JsonProperty("isRuralName")
|
||||
private String isRuralName;// FIXME check this code
|
||||
@JsonProperty("ctime")
|
||||
private String ctime;
|
||||
@JsonProperty("geoPositon")
|
||||
private String geoPositon;
|
||||
@JsonProperty("isSmartStationName")
|
||||
private String isSmartStationName;// FIXME check this code
|
||||
@JsonProperty("dutyModeName")
|
||||
private String dutyModeName;// FIXME check this code
|
||||
@JsonProperty("stationCapacity")
|
||||
private Double stationCapacity;
|
||||
@JsonProperty("isAvcName")
|
||||
private String isAvcName;// FIXME check this code
|
||||
@JsonProperty("equipmentOwner")
|
||||
private String equipmentOwner;
|
||||
@JsonProperty("arrangementName")
|
||||
private String arrangementName;// FIXME check this code
|
||||
@JsonProperty("importantLevelName")
|
||||
private String importantLevelName;// FIXME check this code
|
||||
@JsonProperty("psrId")
|
||||
private String psrId;
|
||||
@JsonProperty("telephone")
|
||||
private String telephone;
|
||||
@JsonProperty("dispatchJurisdiction")
|
||||
private String dispatchJurisdiction;
|
||||
@JsonProperty("isFirtsName")
|
||||
private String isFirtsName;// FIXME check this code
|
||||
@JsonProperty("isN1Name")
|
||||
private String isN1Name;// FIXME check this code
|
||||
@JsonProperty("astId")
|
||||
private String astId;
|
||||
@JsonProperty("isSmartStation")
|
||||
private String isSmartStation;
|
||||
@JsonProperty("isLoadStation")
|
||||
private String isLoadStation;
|
||||
@JsonProperty("maintOrgName")
|
||||
private String maintOrgName;// FIXME check this code
|
||||
@JsonProperty("dispatchName")
|
||||
private String dispatchName;
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
@JsonProperty("isAvc")
|
||||
private String isAvc;
|
||||
@JsonProperty("isLoadStationName")
|
||||
private String isLoadStationName;// FIXME check this code
|
||||
@JsonProperty("isGis")
|
||||
private String isGis;
|
||||
@JsonProperty("hisCrestStage")
|
||||
private Double hisCrestStage;
|
||||
@JsonProperty("isMultiStationIntegration")
|
||||
private String isMultiStationIntegration;
|
||||
@JsonProperty("lastUpdateTime")
|
||||
private String lastUpdateTime;
|
||||
@JsonProperty("dispatchPermission")
|
||||
private String dispatchPermission;
|
||||
@JsonProperty("psrState")
|
||||
private String psrState;
|
||||
@JsonProperty("regionalism")
|
||||
private String regionalism;
|
||||
@JsonProperty("city")
|
||||
private String city;
|
||||
@JsonProperty("importance")
|
||||
private String importance;
|
||||
@JsonProperty("isRemoteIntellpatrol")
|
||||
private String isRemoteIntellpatrol;
|
||||
@JsonProperty("isCentralMonitor")
|
||||
private String isCentralMonitor;
|
||||
@JsonProperty("dispatchOperation")
|
||||
private String dispatchOperation;
|
||||
@JsonProperty("highestDispatchJurisdiction")
|
||||
private String highestDispatchJurisdiction;
|
||||
@JsonProperty("importanceName")
|
||||
private String importanceName;// FIXME check this code
|
||||
@JsonProperty("runDevName")
|
||||
private String runDevName;
|
||||
@JsonProperty("fireTypeName")
|
||||
private String fireTypeName;// FIXME check this code
|
||||
@JsonProperty("psrStateName")
|
||||
private String psrStateName;// FIXME check this code
|
||||
@JsonProperty("startTime")
|
||||
private String startTime;
|
||||
@JsonProperty("pubPrivFlag")
|
||||
private String pubPrivFlag;
|
||||
@JsonProperty("isCentralMonitorName")
|
||||
private String isCentralMonitorName;// FIXME check this code
|
||||
@JsonProperty("transformerQuantity")
|
||||
private Integer transformerQuantity;
|
||||
@JsonProperty("hisLargestRainfall")
|
||||
private Double hisLargestRainfall;
|
||||
@JsonProperty("fireAcceptanceName")
|
||||
private String fireAcceptanceName;// FIXME check this code
|
||||
@JsonProperty("address")
|
||||
private String address;
|
||||
@JsonProperty("maintGroupName")
|
||||
private String maintGroupName;// FIXME check this code
|
||||
@JsonProperty("maintGroup")
|
||||
private String maintGroup;
|
||||
@JsonProperty("importantLevel")
|
||||
private String importantLevel;
|
||||
@JsonProperty("isGisName")
|
||||
private String isGisName;// FIXME check this code
|
||||
@JsonProperty("contaminationLevel")
|
||||
private String contaminationLevel;
|
||||
@JsonProperty("cityName")
|
||||
private String cityName;// FIXME check this code
|
||||
@JsonProperty("isJunctionStationName")
|
||||
private String isJunctionStationName;// FIXME check this code
|
||||
@JsonProperty("voltageLevel")
|
||||
private String voltageLevel;
|
||||
@JsonProperty("isFirts")
|
||||
private String isFirts;
|
||||
@JsonProperty("fireType")
|
||||
private String fireType;
|
||||
@JsonProperty("dutyMode")
|
||||
private String dutyMode;
|
||||
@JsonProperty("isJunctionStation")
|
||||
private String isJunctionStation;
|
||||
@JsonProperty("stationTypeName")
|
||||
private String StationTypeName;// FIXME check this code
|
||||
@JsonProperty("equipmentOwnerName")
|
||||
private String equipmentOwnerName;// FIXME check this code
|
||||
@JsonProperty("isFloodImportance")
|
||||
private String isFloodImportance;
|
||||
@JsonProperty("isN1")
|
||||
private String isN1;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class AssetsDTO {
|
||||
@JsonProperty("astId")
|
||||
private String astId;
|
||||
@JsonProperty("stationType")
|
||||
private String stationType;
|
||||
@JsonProperty("stationTypeName")
|
||||
private String stationTypeName;// FIXME check this code
|
||||
@JsonProperty("ctime")
|
||||
private String ctime;
|
||||
@JsonProperty("lastUpdateTime")
|
||||
private String lastUpdateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.njcn.jbsyncdata.pojo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台区信息
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-11-20
|
||||
*/
|
||||
@Data
|
||||
@ColumnWidth(30)
|
||||
public class ZhangDistributionAreaExcel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ExcelProperty("台区编号")
|
||||
private String id;
|
||||
|
||||
@ExcelProperty("台区(变压器)名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@ExcelProperty("组织机构名称")
|
||||
private String orgName;
|
||||
|
||||
|
||||
@ExcelProperty("组织机构id")
|
||||
private String orgId;
|
||||
|
||||
|
||||
@ExcelProperty("运维单位名称")
|
||||
private String operationName;
|
||||
|
||||
|
||||
@ExcelProperty("运维单位id")
|
||||
private String operationId;
|
||||
|
||||
|
||||
@ExcelProperty("变电站名称")
|
||||
private String powerrName;
|
||||
|
||||
|
||||
@ExcelProperty("变电站id")
|
||||
private String powerStationId;
|
||||
|
||||
|
||||
@ExcelProperty("监测线路名称")
|
||||
private String lineName;
|
||||
|
||||
|
||||
@ExcelProperty("所属线路ID")
|
||||
private String lineId;
|
||||
|
||||
|
||||
@ExcelProperty("电压等级")
|
||||
private String voltageLevel;
|
||||
|
||||
|
||||
@ExcelProperty("PMS中资源ID")
|
||||
private String pmsID;
|
||||
|
||||
|
||||
@ExcelProperty("配变容量")
|
||||
private String pCapacity;
|
||||
|
||||
|
||||
@ExcelProperty("地区特征")
|
||||
private String regionalism;
|
||||
|
||||
@ExcelProperty("是否农网")
|
||||
private String ifRuralPowerGrid;
|
||||
|
||||
@ExcelProperty("使用性质")
|
||||
private String natureOfUse;
|
||||
|
||||
|
||||
@ExcelProperty("供电半径")
|
||||
private Float powerSupplyRadius;
|
||||
|
||||
|
||||
@ExcelProperty("供电线路总长度")
|
||||
private Float lineLength;
|
||||
|
||||
|
||||
@ExcelProperty("运行状态")
|
||||
private String state;
|
||||
|
||||
|
||||
@ExcelProperty("分布式光伏用户数")
|
||||
private Integer distributedPhotovoltaicNum;
|
||||
|
||||
|
||||
@ExcelProperty("装机容量")
|
||||
private Float photovoltaicCapacity;
|
||||
|
||||
|
||||
@ExcelProperty("是否有电动汽车接入")
|
||||
private String ifBevAp;
|
||||
|
||||
|
||||
@ExcelProperty("接入负荷类型")
|
||||
private String apLoadType;
|
||||
|
||||
|
||||
@ExcelProperty(value = "无数据的指标")
|
||||
private String types;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.jbsyncdata.pojo.po;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.njcn.jbsyncdata.util.InstantDateSerializer;
|
||||
import com.njcn.influx.utils.InstantDateSerializer;
|
||||
import lombok.Data;
|
||||
import org.influxdb.annotation.Column;
|
||||
import org.influxdb.annotation.Measurement;
|
||||
|
||||
49
src/main/java/com/njcn/jbsyncdata/pojo/po/EmsInterface.java
Normal file
49
src/main/java/com/njcn/jbsyncdata/pojo/po/EmsInterface.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.njcn.jbsyncdata.pojo.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2024/6/11 15:46
|
||||
*/
|
||||
@Data
|
||||
public class EmsInterface {
|
||||
|
||||
//主键
|
||||
private String ID;
|
||||
|
||||
//市、县公司
|
||||
private String SXGS;
|
||||
|
||||
//遥测时间
|
||||
private String YCSJ;
|
||||
|
||||
//终端ID
|
||||
private String ZDID;
|
||||
|
||||
//测点ID
|
||||
private String CDID;
|
||||
|
||||
//设备ID
|
||||
private String SBID;
|
||||
|
||||
//PMS2.0编号
|
||||
private String PMSBH;
|
||||
|
||||
//测点值
|
||||
private String CDZ;
|
||||
|
||||
//遥测类型
|
||||
private String YCLX;
|
||||
|
||||
//更新时间
|
||||
private String GXSJ;
|
||||
|
||||
//据插入时间
|
||||
private String SJCRSJ;
|
||||
|
||||
//资源id
|
||||
private String PMS_ID;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
package com.njcn.jbsyncdata.pojo.po;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台区信息
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-11-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pms_power_distributionarea")
|
||||
public class PmsPowerDistributionarea {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 台区编号
|
||||
*/
|
||||
@TableId("Id")
|
||||
@ExcelProperty(value = "台区编号")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 台区名称
|
||||
*/
|
||||
@TableField("Name")
|
||||
@ExcelProperty("台区名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 组织机构名称
|
||||
*/
|
||||
@TableField("Org_Name")
|
||||
@ExcelProperty("所属部门")
|
||||
private String orgName;
|
||||
|
||||
/**
|
||||
* 组织机构ID(外键)
|
||||
*/
|
||||
@TableField("Org_Id")
|
||||
private String orgId;
|
||||
|
||||
/**
|
||||
* 运维单位名称
|
||||
*/
|
||||
@TableField("Operation_Name")
|
||||
private String operationName;
|
||||
|
||||
/**
|
||||
* 运维单位ID(外键)
|
||||
*/
|
||||
@TableField("Operation_Id")
|
||||
private String operationId;
|
||||
|
||||
/**
|
||||
* 变电站名称
|
||||
*/
|
||||
@TableField("Powerr_Name")
|
||||
@ExcelProperty(value = "变电站名称")
|
||||
private String powerrName;
|
||||
|
||||
/**
|
||||
* 电站ID(外键)
|
||||
*/
|
||||
@TableField("Power_Station_Id")
|
||||
private String powerStationId;
|
||||
|
||||
/**
|
||||
* 监测线路名称
|
||||
*/
|
||||
@TableField("Line_Name")
|
||||
@ExcelProperty("所属线路")
|
||||
private String lineName;
|
||||
|
||||
/**
|
||||
* 所属线路ID(外键)
|
||||
*/
|
||||
@TableField("Line_Id")
|
||||
private String lineId;
|
||||
|
||||
/**
|
||||
* 电压等级
|
||||
*/
|
||||
@TableField("Voltage_Level")
|
||||
private String voltageLevel;
|
||||
|
||||
/**
|
||||
* 配变容量
|
||||
*/
|
||||
@TableField("P_Capacity")
|
||||
private Float pCapacity;
|
||||
|
||||
/**
|
||||
* 地区特征(字典)
|
||||
*/
|
||||
@TableField("Regionalism")
|
||||
private String regionalism;
|
||||
|
||||
/**
|
||||
* 设备地区特征
|
||||
*/
|
||||
@TableField("Dev_Regionalism")
|
||||
private String devRegionalism;
|
||||
|
||||
/**
|
||||
* 是否农网:0-否;1:是;
|
||||
*/
|
||||
@TableField("If_Rural_Power_Grid")
|
||||
private Boolean ifRuralPowerGrid;
|
||||
|
||||
/**
|
||||
* 使用性质
|
||||
*/
|
||||
@TableField("Nature_Of_Use")
|
||||
private String natureOfUse;
|
||||
|
||||
/**
|
||||
* 供电半径
|
||||
*/
|
||||
@TableField("Power_Supply_Radius")
|
||||
private Float powerSupplyRadius;
|
||||
|
||||
/**
|
||||
* 供电线路总长度
|
||||
*/
|
||||
@TableField("Line_Length")
|
||||
private Float lineLength;
|
||||
|
||||
/**
|
||||
* 运行状态(字典)
|
||||
*/
|
||||
@TableField("State")
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 分布式光伏用户数
|
||||
*/
|
||||
@TableField("Distributed_Photovoltaic_Num")
|
||||
private Integer distributedPhotovoltaicNum;
|
||||
|
||||
/**
|
||||
* 分布式光伏总装机容量
|
||||
*/
|
||||
@TableField("Photovoltaic_Capacity")
|
||||
private Float photovoltaicCapacity;
|
||||
|
||||
/**
|
||||
* 是否有电动汽车接入:0-否;1:是;
|
||||
*/
|
||||
@TableField("If_Bev_Ap")
|
||||
private Boolean ifBevAp;
|
||||
|
||||
/**
|
||||
* 接入负荷类型(字典)
|
||||
*/
|
||||
@TableField("Ap_Load_Type")
|
||||
private String apLoadType;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@TableField("Longitude")
|
||||
private Double longitude;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
*/
|
||||
@TableField("Latitude")
|
||||
private Double latitude;
|
||||
|
||||
/**
|
||||
* 是否是上送国网监测点,0-否 1-是
|
||||
*/
|
||||
@TableField("Is_Up_To_Grid")
|
||||
private Boolean isUpToGrid;
|
||||
|
||||
/**
|
||||
* 数据状态:0-删除;1-正常;
|
||||
*/
|
||||
@TableField("Status")
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 数据状态:0-手动录入;1-gw台账录入
|
||||
*/
|
||||
@TableField("input_Status")
|
||||
private Integer inputStatus;
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
@TableField("Create_By")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("Create_Time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*/
|
||||
@TableField("Update_By")
|
||||
private String updateBy;
|
||||
|
||||
@TableField("Pms_Id")
|
||||
@ExcelProperty("PMS资源id(同源)")
|
||||
private String pmsID;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("Update_Time")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ExcelProperty(value = "无数据的指标")
|
||||
@TableField(exist = false)
|
||||
private String types;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.njcn.jbsyncdata.pojo.ywzt;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/9/25 16:56
|
||||
*/
|
||||
@Data
|
||||
public class BusBarResult {
|
||||
|
||||
private Result result;
|
||||
|
||||
|
||||
@Data
|
||||
public static class Result {
|
||||
private List<BusBar> records;
|
||||
}
|
||||
|
||||
@Data
|
||||
@TableName("pq_ywzt_busbar")
|
||||
public static class BusBar {
|
||||
@MppMultiId
|
||||
@TableField(value = "psr_id")
|
||||
private String psrId;
|
||||
@MppMultiId
|
||||
@TableField(value = "psr_sub_id")
|
||||
private String psrSubId;
|
||||
private String psrType;
|
||||
private String psrState;
|
||||
private String cityName;
|
||||
private String maintOrgName;
|
||||
private String maintGroupName;
|
||||
private String voltageLevelId;
|
||||
private String voltageLevelName;
|
||||
private String name;
|
||||
private String psrStateName;
|
||||
private String equipmentOwnerName;
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.njcn.jbsyncdata.pojo.ywzt;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class IncomeAndOutgoLinesResult {
|
||||
|
||||
/**
|
||||
* 获取进出线
|
||||
*/
|
||||
private Result result;
|
||||
|
||||
@Data
|
||||
public static class Result {
|
||||
|
||||
private int incomeTotal;
|
||||
private int outgoTotal;
|
||||
//进线
|
||||
private List<PsrInfo> incomeList;
|
||||
//出线
|
||||
private List<PsrInfo> outgoList;
|
||||
}
|
||||
|
||||
@Data
|
||||
@TableName("pq_ywzt_xl")
|
||||
public static class PsrInfo {
|
||||
@MppMultiId
|
||||
@TableField(value = "psr_id")
|
||||
private String psrId;
|
||||
@MppMultiId
|
||||
@TableField(value = "psr_sub_id")
|
||||
private String psrSubId;
|
||||
private String psrName;
|
||||
private String psrType;
|
||||
private String psrTypeName;
|
||||
private String voltageLevelId;
|
||||
private String voltageLevelCode;
|
||||
private String voltageLevelName;
|
||||
private String maintOrg;
|
||||
private String maintOrgName;
|
||||
//进线或者出线
|
||||
@MppMultiId
|
||||
@TableField(value = "type")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
31
src/main/java/com/njcn/jbsyncdata/pojo/ywzt/LineDetail.java
Normal file
31
src/main/java/com/njcn/jbsyncdata/pojo/ywzt/LineDetail.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.njcn.jbsyncdata.pojo.ywzt;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/9/28 10:32
|
||||
*/
|
||||
@Data
|
||||
@TableName("pq_ywzt_xl_detail")
|
||||
public class LineDetail {
|
||||
|
||||
@TableId(value = "psr_id")
|
||||
private String psrId;
|
||||
|
||||
private String psrSubStartId;
|
||||
|
||||
private String psrSubStartName;
|
||||
|
||||
private String psrSubEndId;
|
||||
|
||||
private String psrSubEndName;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package com.njcn.jbsyncdata.pojo.ywzt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/9/28 10:18
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class LineDetailResult {
|
||||
|
||||
|
||||
@JsonProperty("status")
|
||||
private String status;
|
||||
@JsonProperty("errors")
|
||||
private Object errors;
|
||||
@JsonProperty("result")
|
||||
private ResultDTO result;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class ResultDTO {
|
||||
@JsonProperty("equipType")
|
||||
private String equipType;
|
||||
@JsonProperty("distribution")
|
||||
private String distribution;
|
||||
@JsonProperty("equipTypeName")
|
||||
private String equipTypeName;
|
||||
@JsonProperty("specialMode")
|
||||
private Object specialMode;
|
||||
@JsonProperty("equipArchivesGroupList")
|
||||
private List<EquipArchivesGroupListDTO> equipArchivesGroupList;
|
||||
@JsonProperty("equipStatisticList")
|
||||
private Object equipStatisticList;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class EquipArchivesGroupListDTO {
|
||||
@JsonProperty("objId")
|
||||
private String objId;
|
||||
@JsonProperty("groupName")
|
||||
private String groupName;
|
||||
@JsonProperty("previousGroup")
|
||||
private Object previousGroup;
|
||||
@JsonProperty("parentGroup")
|
||||
private Object parentGroup;
|
||||
@JsonProperty("viewFlag")
|
||||
private Boolean viewFlag;
|
||||
@JsonProperty("subEquipArchivesGroupList")
|
||||
private List<SubEquipArchivesGroupListDTO> subEquipArchivesGroupList;
|
||||
@JsonProperty("equipArchivesFieldList")
|
||||
private List<?> equipArchivesFieldList;
|
||||
@JsonProperty("equipArchivesTabList")
|
||||
private Object equipArchivesTabList;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class SubEquipArchivesGroupListDTO {
|
||||
@JsonProperty("objId")
|
||||
private String objId;
|
||||
@JsonProperty("groupName")
|
||||
private String groupName;
|
||||
@JsonProperty("previousGroup")
|
||||
private Object previousGroup;
|
||||
@JsonProperty("parentGroup")
|
||||
private String parentGroup;
|
||||
@JsonProperty("viewFlag")
|
||||
private Boolean viewFlag;
|
||||
@JsonProperty("subEquipArchivesGroupList")
|
||||
private Object subEquipArchivesGroupList;
|
||||
@JsonProperty("equipArchivesFieldList")
|
||||
private List<EquipArchivesFieldListDTO> equipArchivesFieldList;
|
||||
@JsonProperty("equipArchivesTabList")
|
||||
private Object equipArchivesTabList;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class EquipArchivesFieldListDTO {
|
||||
@JsonProperty("objId")
|
||||
private String objId;
|
||||
@JsonProperty("modelType")
|
||||
private String modelType;
|
||||
@JsonProperty("fieldName")
|
||||
private String fieldName;
|
||||
@JsonProperty("lowerCamelFieldName")
|
||||
private String lowerCamelFieldName;
|
||||
@JsonProperty("fieldDescribe")
|
||||
private String fieldDescribe;
|
||||
@JsonProperty("fieldValue")
|
||||
private String fieldValue;
|
||||
@JsonProperty("fieldEscapeValue")
|
||||
private String fieldEscapeValue;
|
||||
@JsonProperty("fieldStorageType")
|
||||
private String fieldStorageType;
|
||||
@JsonProperty("fieldUnit")
|
||||
private Object fieldUnit;
|
||||
@JsonProperty("fieldGroup")
|
||||
private String fieldGroup;
|
||||
@JsonProperty("previousField")
|
||||
private Object previousField;
|
||||
@JsonProperty("detailedCardDisp")
|
||||
private String detailedCardDisp;
|
||||
@JsonProperty("dispRestrFieldName")
|
||||
private Object dispRestrFieldName;
|
||||
@JsonProperty("dispRestrFieldValue")
|
||||
private Object dispRestrFieldValue;
|
||||
@JsonProperty("dispMode")
|
||||
private String dispMode;
|
||||
@JsonProperty("linkMode")
|
||||
private Object linkMode;
|
||||
@JsonProperty("maintainEnable")
|
||||
private String maintainEnable;
|
||||
@JsonProperty("simpleMaintainEnable")
|
||||
private String simpleMaintainEnable;
|
||||
@JsonProperty("maintRestrFieldName")
|
||||
private String maintRestrFieldName;
|
||||
@JsonProperty("maintRestrFieldValue")
|
||||
private String maintRestrFieldValue;
|
||||
@JsonProperty("maintenanceMode")
|
||||
private String maintenanceMode;
|
||||
@JsonProperty("componentType")
|
||||
private Object componentType;
|
||||
@JsonProperty("textLength")
|
||||
private Object textLength;
|
||||
@JsonProperty("textRule")
|
||||
private Object textRule;
|
||||
@JsonProperty("minValue")
|
||||
private Object minValue;
|
||||
@JsonProperty("maxValue")
|
||||
private Object maxValue;
|
||||
@JsonProperty("accuracy")
|
||||
private Object accuracy;
|
||||
@JsonProperty("copyable")
|
||||
private Object copyable;
|
||||
@JsonProperty("required")
|
||||
private String required;
|
||||
@JsonProperty("reqRestrFieldName")
|
||||
private Object reqRestrFieldName;
|
||||
@JsonProperty("reqRestrFieldValue")
|
||||
private Object reqRestrFieldValue;
|
||||
@JsonProperty("refCons")
|
||||
private Object refCons;
|
||||
@JsonProperty("refConsFilterCond")
|
||||
private Object refConsFilterCond;
|
||||
@JsonProperty("foreignEquipType")
|
||||
private Object foreignEquipType;
|
||||
@JsonProperty("foreignDistribution")
|
||||
private Object foreignDistribution;
|
||||
@JsonProperty("commomCodeVoList")
|
||||
private Object commomCodeVoList;
|
||||
@JsonProperty("remark")
|
||||
private Object remark;
|
||||
@JsonProperty("equipType")
|
||||
private String equipType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.njcn.jbsyncdata.service;
|
||||
|
||||
import com.njcn.jbsyncdata.pojo.DisPhotovoltaic10Excel;
|
||||
import com.njcn.jbsyncdata.pojo.DisPhotovoltaic380Excel;
|
||||
import com.njcn.jbsyncdata.pojo.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
@@ -31,6 +30,21 @@ public interface DisPhotovoltaicService {
|
||||
*/
|
||||
void SavaPmsPowerGenerationUser380KV(List<DisPhotovoltaic380Excel> list, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 唐山模板导入
|
||||
* @param list
|
||||
* @param response
|
||||
*/
|
||||
void SavaArea(List<DistributionAreaExcel> list, HttpServletResponse response);
|
||||
|
||||
|
||||
/**
|
||||
* 张家口模板导入
|
||||
* @param list
|
||||
* @param response
|
||||
*/
|
||||
void SavaZhangArea(List<ZhangDistributionAreaExcel> list, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* @Description: 配网表数据新增
|
||||
* @param
|
||||
@@ -39,4 +53,18 @@ public interface DisPhotovoltaicService {
|
||||
* @Date: 2023/10/11 14:31
|
||||
*/
|
||||
Boolean savePmsDistributionMonitor();
|
||||
|
||||
/**
|
||||
* @Description: 配网表数据新增
|
||||
* @param
|
||||
* @return: java.lang.Boolean
|
||||
* @Author: wr
|
||||
* @Date: 2023/10/11 14:31
|
||||
*/
|
||||
Boolean savePmsDistributionArea();
|
||||
|
||||
/**
|
||||
* 批量导入台区台账数据
|
||||
*/
|
||||
void importDistributionAreaExcel(List<PowerDistributionAreaExcel.ErrMsg> list, HttpServletResponse response);
|
||||
}
|
||||
|
||||
@@ -5,4 +5,14 @@ public interface IBusinessService {
|
||||
|
||||
void queryTelemetryData(String date);
|
||||
|
||||
|
||||
void queryTelemetryAreaData(String date);
|
||||
|
||||
/**
|
||||
* 获取台区遥测数据
|
||||
* @param date
|
||||
*/
|
||||
void queryTelemetryInterfaceAreaData(String date);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.jbsyncdata.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.jbsyncdata.pojo.po.PmsGeneratrixWire;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-11-28
|
||||
*/
|
||||
public interface IPmsGeneratrixWireService extends IService<PmsGeneratrixWire> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.jbsyncdata.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.jbsyncdata.pojo.po.PmsPowerDistributionarea;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台区信息 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-11-20
|
||||
*/
|
||||
public interface IPmsPowerDistributionareaService extends IService<PmsPowerDistributionarea> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.jbsyncdata.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.jbsyncdata.pojo.PmsSubstation;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
public interface IPmsSubstationService extends IService<PmsSubstation> {
|
||||
|
||||
|
||||
Boolean addYwZtSubstation(String distribution, String psrType);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.jbsyncdata.service;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.BusBarResult;
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/9/25 17:13
|
||||
*/
|
||||
public interface YwZtBusBarService extends IMppService<BusBarResult.BusBar> {
|
||||
|
||||
/**
|
||||
* 获取业务中台变电站下所有母线
|
||||
* @param cookie
|
||||
* @param aMapToken
|
||||
* @return
|
||||
*/
|
||||
Boolean addYwZtBusBar(String cookie, String aMapToken);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.jbsyncdata.service;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.IncomeAndOutgoLinesResult;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/9/25 17:13
|
||||
*/
|
||||
public interface YwZtIncomeAndOutgoService extends IMppService<IncomeAndOutgoLinesResult.PsrInfo> {
|
||||
|
||||
/**
|
||||
* 获得变电站中进线和出线
|
||||
* @param cookie
|
||||
* @param aMapToken
|
||||
* @return
|
||||
*/
|
||||
Boolean addYwZtIncomeAndOutgo(String cookie, String aMapToken) throws InterruptedException;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.jbsyncdata.service;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.BusBarResult;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.LineDetail;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/9/25 17:13
|
||||
*/
|
||||
public interface YwZtLineDetailService extends IMppService<LineDetail> {
|
||||
|
||||
/**
|
||||
* 获取业务中台变电站下所有母线
|
||||
* @param aMapToken
|
||||
* @return
|
||||
*/
|
||||
Boolean addYwZtLineDetail(String aMapToken);
|
||||
}
|
||||
@@ -1,39 +1,31 @@
|
||||
package com.njcn.jbsyncdata.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.file.FileWriter;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.jbsyncdata.component.TokenComponent;
|
||||
import com.njcn.jbsyncdata.enums.MeasTypeEnum;
|
||||
import com.njcn.jbsyncdata.pojo.ExcelData;
|
||||
import com.njcn.jbsyncdata.mapper.PmsPowerDistributionareaMapper;
|
||||
import com.njcn.jbsyncdata.pojo.po.PmsPowerDistributionarea;
|
||||
import com.njcn.jbsyncdata.pojo.result.*;
|
||||
import com.njcn.jbsyncdata.service.IBusinessService;
|
||||
import com.njcn.jbsyncdata.service.IPmsPowerDistributionareaService;
|
||||
import com.njcn.jbsyncdata.service.IPmsPowerGenerationUserService;
|
||||
import com.njcn.jbsyncdata.util.AreaDataProcessing;
|
||||
import com.njcn.jbsyncdata.util.AreaInterfaceDataProcessing;
|
||||
import com.njcn.jbsyncdata.util.DataProcessing;
|
||||
import com.njcn.jbsyncdata.util.RestTemplateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.collections4.SetUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.dto.BatchPoints;
|
||||
import org.influxdb.dto.Point;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@@ -45,10 +37,19 @@ public class BusinessServiceImpl implements IBusinessService {
|
||||
private TokenComponent tokenComponent;
|
||||
|
||||
@Resource
|
||||
private InfluxDbUtils influxDbUtils;
|
||||
private DataProcessing dataProcessing;
|
||||
|
||||
@Resource
|
||||
private AreaDataProcessing areaDataProcessing;
|
||||
@Resource
|
||||
private AreaInterfaceDataProcessing areaInterfaceDataProcessing;
|
||||
@Resource
|
||||
private IPmsPowerGenerationUserService pmsPowerGenerationUserService;
|
||||
@Resource
|
||||
private IPmsPowerDistributionareaService powerDistributionareaService;
|
||||
|
||||
@Resource
|
||||
private PmsPowerDistributionareaMapper pmsPowerDistributionareaMapper;
|
||||
|
||||
/**
|
||||
* 此方法通过发电客户编号查询数据,该方法存在以下问题
|
||||
@@ -65,6 +66,7 @@ public class BusinessServiceImpl implements IBusinessService {
|
||||
* 4. StatisticsData统计数据的实际数值measValue为null-----对应时间、指标的数值设置为0
|
||||
*/
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public void queryTelemetryData(String date) {
|
||||
DateTime dateTemp = DateUtil.parse(date, DatePattern.NORM_DATE_FORMAT);
|
||||
DateTime beginOfDay = DateUtil.beginOfDay(dateTemp);
|
||||
@@ -79,7 +81,7 @@ public class BusinessServiceImpl implements IBusinessService {
|
||||
JSONObject jsonObject = JSONUtil.createObj();
|
||||
JSONObject jsonObjectSub = JSONUtil.createObj();
|
||||
jsonObject.set("page", 1);
|
||||
jsonObject.set("perPage", 10000);
|
||||
jsonObject.set("perPage", 2000);
|
||||
jsonObject.set("startTime", DateUtil.format(beginOfDay, DatePattern.NORM_DATETIME_FORMATTER));
|
||||
jsonObject.set("endTime", DateUtil.format(endOfDay, DatePattern.NORM_DATETIME_FORMATTER));
|
||||
//1公专变2低压用户3光伏
|
||||
@@ -97,188 +99,78 @@ public class BusinessServiceImpl implements IBusinessService {
|
||||
List<String> userIds = pmsPowerGenerationUserService.queryAllUserId();
|
||||
List<List<String>> singleQueryDataUserId = ListUtils.partition(userIds, 20000);
|
||||
for (int k = 0; k < singleQueryDataUserId.size(); k++) {
|
||||
//将发电用户编号按100尺寸分片
|
||||
List<List<String>> partitionList = ListUtils.partition(singleQueryDataUserId.get(k), 100);
|
||||
log.error("总计分了{}片", partitionList.size());
|
||||
int count = 0;
|
||||
tokenWithRestTemplate = tokenComponent.getTokenWithRestTemplate();
|
||||
headers.put("x-token", tokenWithRestTemplate.getAccess_token());
|
||||
//先获取数据
|
||||
List<ResponseEntity<String>> responseEntities = new ArrayList<>(2000);
|
||||
int kk = k + 1;
|
||||
for (List<String> generationUserIDList : partitionList) {
|
||||
count++;
|
||||
log.error("查询第{}大片,{}小片数据", kk, count);
|
||||
//按批次处理用户编号数据
|
||||
jsonObjectSub.set("consNos", generationUserIDList);
|
||||
JSONArray jsonArray = JSONUtil.createArray();
|
||||
jsonArray.add(jsonObjectSub);
|
||||
jsonObject.set("filters", jsonArray);
|
||||
try {
|
||||
responseEntities.add(restTemplateUtil.post(tokenComponent.getUrl().concat("/realMeasCenter/telemetry/commonQuery"), headers, jsonObject, String.class));
|
||||
} catch (Exception exception) {
|
||||
log.error("远程调用接口异常,异常为:" + exception);
|
||||
}
|
||||
}
|
||||
//开始解析数据
|
||||
Set<String> userIdConcatMeasType = new HashSet<>();
|
||||
//将指标+客户编号组合起来匹配返回数据的第一条记录:userId@measType
|
||||
for (String measType : typeList) {
|
||||
userIdConcatMeasType.addAll(singleQueryDataUserId.get(k).stream().map(t -> t.concat(StrPool.AT).concat(measType)).collect(Collectors.toSet()));
|
||||
}
|
||||
List</*各值以逗号分隔*/String> influxData;
|
||||
Map</*表名*/String, List</*各值以逗号分隔*/String>> typeData = new HashMap<>();
|
||||
StringBuilder tempInfluxData;
|
||||
ResponseEntity<String> response;
|
||||
JSONArray statisticsDataList;
|
||||
JSONObject result;
|
||||
JSONObject statisticsData;
|
||||
JSONObject body;
|
||||
JSONArray records;
|
||||
String dataIdentify;
|
||||
JSONObject commonTelemetry;
|
||||
MeasTypeEnum measTypeEnumByMeasType;
|
||||
for (int i = 0; i < partitionList.size(); i++) {
|
||||
log.error("解析第{}片数据", i);
|
||||
response = responseEntities.get(i);
|
||||
body = JSONUtil.parseObj(response.getBody());
|
||||
if (response.getStatusCodeValue() == 200 && body.get("status", String.class).equalsIgnoreCase("000000")) {
|
||||
result = JSONUtil.parseObj(body.get("result", String.class));
|
||||
records = JSONUtil.parseArray(result.get("records", String.class));
|
||||
log.error("查询遥测数据结束,返回数据量:{}", records.size());
|
||||
if (CollectionUtil.isEmpty(records)) {
|
||||
//日志输出:
|
||||
log.error("查询时间:{},无遥测数据;", date);
|
||||
continue;
|
||||
}
|
||||
//处理各个record的数据,因用户下可能有多个测量点,按指标循环,默认采用第一个匹配上的做数据处理
|
||||
for (Object obj : records) { // 最多循环100*16次
|
||||
commonTelemetry = JSONUtil.parseObj(obj);
|
||||
dataIdentify = commonTelemetry.get("consNo", String.class).concat(StrPool.AT).concat(commonTelemetry.get("measTypeCode", String.class));
|
||||
if (userIdConcatMeasType.contains(dataIdentify)) {
|
||||
//首个包含该标识的数据进行处理
|
||||
measTypeEnumByMeasType = MeasTypeEnum.getMeasTypeEnumByMeasType(commonTelemetry.get("measTypeCode", String.class));
|
||||
//统计数据,经过测试,接口响应json可能不包含该属性
|
||||
statisticsDataList = commonTelemetry.get("telemetryValue", JSONArray.class);
|
||||
if (CollectionUtil.isEmpty(statisticsDataList)) {
|
||||
//添加进有指标但无遥测数据集合
|
||||
continue;
|
||||
}
|
||||
influxData = new ArrayList<>();
|
||||
for (Object subObj : statisticsDataList) { // 匹配上进入,循环96次
|
||||
statisticsData = JSONUtil.parseObj(subObj);
|
||||
tempInfluxData = new StringBuilder();
|
||||
tempInfluxData.append(measTypeEnumByMeasType.getPhaseType())
|
||||
.append(StrPool.COMMA)
|
||||
.append(commonTelemetry.get("consNo", String.class))
|
||||
.append(StrPool.COMMA)
|
||||
.append(statisticsData.get("dataTime", String.class))
|
||||
.append(StrPool.COMMA)
|
||||
.append(measTypeEnumByMeasType.getFieldName())
|
||||
.append(StrPool.COMMA)
|
||||
.append(StrUtil.isBlank(statisticsData.get("measValue", String.class)) ? "0" : statisticsData.get("measValue", String.class));
|
||||
influxData.add(tempInfluxData.toString());
|
||||
}
|
||||
//userId@measType@tableName:存在多个指标存储表名一致,避免数据覆盖;
|
||||
typeData.put(commonTelemetry.get("consNo", String.class).concat(StrPool.AT).concat(measTypeEnumByMeasType.getMeasType()).concat(StrPool.AT).concat(measTypeEnumByMeasType.getTableName()), influxData);
|
||||
//处理完,删除该条记录,减少集合尺寸,提高效率
|
||||
userIdConcatMeasType.remove(dataIdentify);
|
||||
}
|
||||
}
|
||||
//没有匹配上的就是该用户没有数据
|
||||
log.error("剩余有{}条标识", userIdConcatMeasType.size());
|
||||
} else {
|
||||
log.error("查询遥测数据失败!第{}片,结果为:{}", count, response);
|
||||
}
|
||||
}
|
||||
//最后输出没有数据的用户编号
|
||||
/**
|
||||
* 输出到2个文件,lackData.txt、 excalationData.txt
|
||||
* 注:用户号去除160前缀
|
||||
* 1、所有指标均没有有数据的用户编号
|
||||
* 2、部分指标没有数据的用户编号,并表明是哪些指标
|
||||
*/
|
||||
if (CollectionUtil.isNotEmpty(userIdConcatMeasType)) {
|
||||
Map<String, List<String>> finalMap = userIdConcatMeasType.stream().collect(Collectors.groupingBy(str -> {
|
||||
String key = str.substring(3);
|
||||
key = key.substring(0, key.indexOf(StrPool.AT));
|
||||
return key;
|
||||
}));
|
||||
//全部缺失数据的用户
|
||||
List<String> lackData = new ArrayList<>();
|
||||
//部分缺失的用户及指标
|
||||
List<String> excalationData = new ArrayList<>();
|
||||
Set<String> keyedSet = finalMap.keySet();
|
||||
for (String key : keyedSet) {
|
||||
List<String> data = finalMap.get(key);
|
||||
if (data.size() == typeList.size()) {
|
||||
lackData.add(key);
|
||||
} else {
|
||||
data = data.stream().map(t -> t.substring(t.indexOf(StrPool.AT) + 1)).collect(Collectors.toList());
|
||||
key = key.concat(StrPool.COMMA).concat(StringUtils.join(data, StrPool.AT));
|
||||
excalationData.add(key);
|
||||
}
|
||||
}
|
||||
FileWriter lackDataWriter = FileWriter.create(new File("/usr/local/syncData/lackData" + date + k + ".txt"));
|
||||
lackDataWriter.writeLines(lackData);
|
||||
FileWriter excalationDataWriter = FileWriter.create(new File("/usr/local/syncData/excalationData" + date + k + ".txt"));
|
||||
excalationDataWriter.writeLines(excalationData);
|
||||
}
|
||||
log.error("用户有指标没有数据的长度为:{}", userIdConcatMeasType.size());
|
||||
//最后批量入库
|
||||
batchInsertData(typeData);
|
||||
dataProcessing.asyncInfluxDb(tokenComponent, date, restTemplateUtil, typeList, jsonObject, jsonObjectSub, headers, singleQueryDataUserId, k);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量入库influxDB
|
||||
*
|
||||
* @param typeData 远程根据用户编号获取的数据 Map</表名/String, List<Map</属性名/String,/数值/String>>> typeData = new HashMap<>();
|
||||
*/
|
||||
private void batchInsertData(Map<String, List<String>> typeData) {
|
||||
log.error("总计有{}条记录入库,以20000作为基数分片插入influxdb", typeData.size());
|
||||
List<String> sqlList = new ArrayList<>();
|
||||
Set<String> tableNames = typeData.keySet();
|
||||
String[] datas;
|
||||
Map<String, String> tags;
|
||||
Map<String, Object> fields;
|
||||
Point point;
|
||||
BatchPoints batchPoints;
|
||||
for (String tableName : tableNames) {
|
||||
List<String> data = typeData.get(tableName);
|
||||
tableName = tableName.substring(tableName.lastIndexOf(StrPool.AT) + 1);
|
||||
for (String datum : data) {
|
||||
datas = datum.split(StrPool.COMMA);
|
||||
//tag数据
|
||||
tags = new HashMap<>();
|
||||
tags.put("phasic_type", datas[0]);
|
||||
tags.put("line_id", datas[1]);
|
||||
tags.put("quality_flag", "0");
|
||||
tags.put("value_type", "AVG");
|
||||
String time = datas[2];
|
||||
//tag数据删完后,剩余均是filed数据,因filed属性名不固定,无法指定获取,直接循环
|
||||
fields = new HashMap<>();
|
||||
fields.put(datas[3], datas[4]);
|
||||
point = influxDbUtils.pointBuilder(tableName, DateUtil.parse(time, DatePattern.NORM_DATETIME_FORMATTER).getTime(), TimeUnit.MILLISECONDS, tags, fields);
|
||||
batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
sqlList.add(batchPoints.lineProtocol());
|
||||
}
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public void queryTelemetryAreaData(String date) {
|
||||
DateTime dateTemp = DateUtil.parse(date, DatePattern.NORM_DATE_FORMAT);
|
||||
DateTime beginOfDay = DateUtil.beginOfDay(dateTemp);
|
||||
DateTime endOfDay = DateUtil.endOfDay(dateTemp);
|
||||
RestTemplateUtil restTemplateUtil = new RestTemplateUtil();
|
||||
TokenResult tokenWithRestTemplate = tokenComponent.getTokenWithRestTemplate();
|
||||
if (null == tokenWithRestTemplate) {
|
||||
log.error("token信息获取失败");
|
||||
return;
|
||||
}
|
||||
List<List<String>> subSqlList = ListUtils.partition(sqlList, 20000);
|
||||
int count = 1;
|
||||
for (List<String> sql : subSqlList) {
|
||||
try {
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "autogen", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, sql);
|
||||
} catch (Exception exception) {
|
||||
log.error("数据批量入库异常,异常为:{}",exception.toString());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
log.error("已经入库{}条记录!", count * 20000);
|
||||
count++;
|
||||
List<String> typeList = MeasTypeEnum.getMeasList();
|
||||
JSONObject jsonObject = JSONUtil.createObj();
|
||||
JSONObject jsonObjectSub = JSONUtil.createObj();
|
||||
jsonObject.set("page", 1);
|
||||
jsonObject.set("perPage", 2000);
|
||||
jsonObject.set("startTime", DateUtil.format(beginOfDay, DatePattern.NORM_DATETIME_FORMATTER));
|
||||
jsonObject.set("endTime", DateUtil.format(endOfDay, DatePattern.NORM_DATETIME_FORMATTER));
|
||||
//1公专变2低压用户3光伏
|
||||
jsonObjectSub.set("consNos", new ArrayList<>());
|
||||
jsonObjectSub.set("consType", "");
|
||||
jsonObjectSub.set("astIds", new ArrayList<>());
|
||||
jsonObjectSub.set("astType", "");
|
||||
jsonObjectSub.set("psrType", "0401004");
|
||||
jsonObjectSub.set("measPointIds", new ArrayList<>());
|
||||
jsonObjectSub.set("telemetryTypes", typeList);
|
||||
//组装好json开始发送请求
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("x-token", tokenWithRestTemplate.getAccess_token());
|
||||
//获取所有发电用户的id
|
||||
List<PmsPowerDistributionarea> list = powerDistributionareaService.list(new LambdaQueryWrapper<PmsPowerDistributionarea>()
|
||||
.select(PmsPowerDistributionarea::getId, PmsPowerDistributionarea::getPmsID)
|
||||
.isNotNull(PmsPowerDistributionarea::getPmsID)
|
||||
);
|
||||
list = list.stream()
|
||||
.filter(t -> StrUtil.isNotBlank(t.getPmsID()))
|
||||
.collect(Collectors.toList());
|
||||
List<List<PmsPowerDistributionarea>> singleQueryDataUserId = ListUtils.partition(list, 20000);
|
||||
for (int k = 0; k < singleQueryDataUserId.size(); k++) {
|
||||
areaDataProcessing.asyncInfluxDb(tokenComponent, date, restTemplateUtil, typeList, jsonObject, jsonObjectSub, headers, singleQueryDataUserId, k);
|
||||
}
|
||||
log.error("当前批次所有数据,{}条均已入库!", sqlList.size());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryTelemetryInterfaceAreaData(String date) {
|
||||
DateTime dateTemp = DateUtil.parse(date, DatePattern.NORM_DATE_FORMAT);
|
||||
DateTime beginOfDay = DateUtil.beginOfDay(dateTemp);
|
||||
DateTime endOfDay = DateUtil.endOfDay(dateTemp);
|
||||
|
||||
String startTime = DateUtil.format(beginOfDay, DatePattern.NORM_DATETIME_FORMATTER);
|
||||
String endTime = DateUtil.format(endOfDay, DatePattern.NORM_DATETIME_FORMATTER);
|
||||
List<String> deptIds = pmsPowerDistributionareaMapper.getDeptIds("2adc64baf2308725c4e91105b3186b21");
|
||||
//获取所有发电用户的id
|
||||
List<PmsPowerDistributionarea> list = powerDistributionareaService.list(new LambdaQueryWrapper<PmsPowerDistributionarea>()
|
||||
.select(PmsPowerDistributionarea::getId, PmsPowerDistributionarea::getPmsID)
|
||||
.in(PmsPowerDistributionarea::getOrgId, deptIds)
|
||||
.isNotNull(PmsPowerDistributionarea::getPmsID)
|
||||
);
|
||||
list = list.stream()
|
||||
.filter(t -> StrUtil.isNotBlank(t.getPmsID()))
|
||||
.collect(Collectors.toList());
|
||||
List<List<PmsPowerDistributionarea>> singleQueryDataUserId = ListUtils.partition(list, 2000);
|
||||
for (int k = 0; k < singleQueryDataUserId.size(); k++) {
|
||||
areaInterfaceDataProcessing.asyncInfluxDb(startTime, endTime, singleQueryDataUserId.get(k), k);
|
||||
}
|
||||
System.out.println("结束");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,29 +3,36 @@ 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;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.service.DisPhotovoltaicService;
|
||||
import com.njcn.jbsyncdata.service.IPmsPowerGenerationUserService;
|
||||
import com.njcn.jbsyncdata.service.IPmsStatationStatService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.njcn.jbsyncdata.pojo.po.PmsGeneratrixWire;
|
||||
import com.njcn.jbsyncdata.pojo.po.PmsPowerDistributionarea;
|
||||
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;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
@@ -40,7 +47,8 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
private final IPmsPowerGenerationUserService iPmsPowerGenerationUserService;
|
||||
private final DictDataMapper dictDataMapper;
|
||||
private final IPmsStatationStatService iPmsStatationStatService;
|
||||
|
||||
private final IPmsPowerDistributionareaService powerDistributionareaService;
|
||||
private final IPmsGeneratrixWireService generatrixWireService;
|
||||
@Override
|
||||
public void SavaPmsPowerGenerationUser10KV(List<DisPhotovoltaic10Excel> list, HttpServletResponse response) {
|
||||
List<PmsPowerGenerationUser> info = new ArrayList<>();
|
||||
@@ -74,7 +82,7 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
excel.getLineID()
|
||||
)
|
||||
) {
|
||||
excel.setErrorMessage("线路/台区编号不能为空");
|
||||
excel.setErrorMessage("台区编号/PMS系统线路编号不能为空");
|
||||
errorInfo.add(excel);
|
||||
continue;
|
||||
}
|
||||
@@ -82,7 +90,7 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
String replace = subString(excel.getCounty());
|
||||
PmsStatationStat sub = getSub(excel.getPowerSupply() + "_" + replace, oldSubMap);
|
||||
if (ObjectUtil.isNull(sub)) {
|
||||
excel.setErrorMessage("部门信息不存在");
|
||||
excel.setErrorMessage("区县信息不存在");
|
||||
errorInfo.add(excel);
|
||||
continue;
|
||||
}
|
||||
@@ -103,7 +111,7 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
user.setPowerGenerationMode(powerGenerationMode.getId());
|
||||
|
||||
//todo 电压等级(需要转换)
|
||||
user.setVoltageLevel(getVoltage(excel.getVoltage_Level(), dev_voltage));
|
||||
user.setVoltageLevel(getVoltage(excel.getVoltage_Level().replace("交流",""), dev_voltage));
|
||||
|
||||
|
||||
user.setSourceCapacity(excel.getContractCapacity());
|
||||
@@ -173,7 +181,7 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
excel.getConnectionDate()
|
||||
)
|
||||
) {
|
||||
excel.setErrorMessage("并网时间/线路/台区编号不能为空");
|
||||
excel.setErrorMessage("并网时间/所属线路PMS编号/台区编号不能为空");
|
||||
errorInfo.add(excel);
|
||||
continue;
|
||||
}
|
||||
@@ -182,7 +190,7 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
|
||||
PmsStatationStat sub = getSub(excel.getPowerSupply() + "_" + replace, oldSubMap);
|
||||
if (ObjectUtil.isNull(sub)) {
|
||||
excel.setErrorMessage("部门信息不存在");
|
||||
excel.setErrorMessage("区县信息不存在");
|
||||
errorInfo.add(excel);
|
||||
continue;
|
||||
}
|
||||
@@ -240,14 +248,372 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void SavaArea(List<DistributionAreaExcel> list, HttpServletResponse response) {
|
||||
List<PmsPowerDistributionarea> info=new ArrayList<>();
|
||||
//电压等级
|
||||
DictData dictData = dictDataMapper.selectByCode("10kV", "Dev_Voltage");
|
||||
//运行状态
|
||||
DictData runData = dictDataMapper.selectByCode("Run", "Line_State");
|
||||
|
||||
List<Dept> depts = dictDataMapper.selectUserList();
|
||||
//获取变电站信息
|
||||
List<PmsStatationStat> oldList = iPmsStatationStatService.list(
|
||||
new LambdaQueryWrapper<PmsStatationStat>()
|
||||
.eq(PmsStatationStat::getStatus, 1)
|
||||
);
|
||||
Integer num=0;
|
||||
PmsPowerDistributionarea area;
|
||||
for (DistributionAreaExcel excel : list) {
|
||||
area=new PmsPowerDistributionarea();
|
||||
if(StrUtil.isNotBlank(excel.getId())){
|
||||
area.setId(excel.getId().equals("新上")?excel.getId()+excel.getPmsID().substring(0,30):excel.getId());
|
||||
}else{
|
||||
area.setId(excel.getPmsID().substring(0,32));
|
||||
}
|
||||
area.setName(excel.getName());
|
||||
List<Dept> dept = depts.stream().filter(x -> x.getName().contains(excel.getOrgName())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(dept)){
|
||||
area.setOrgName(dept.get(0).getName());
|
||||
area.setOrgId(dept.get(0).getCode());
|
||||
area.setOperationName(dept.get(0).getName());
|
||||
area.setOperationId(dept.get(0).getCode());
|
||||
}
|
||||
if(StrUtil.isNotEmpty(excel.getPowerrName())){
|
||||
List<PmsStatationStat> station = oldList.stream()
|
||||
.filter(x ->x.getPowerName().contains(excel.getPowerrName()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(station)){
|
||||
area.setPowerrName(station.get(0).getPowerName());
|
||||
area.setPowerStationId(station.get(0).getPowerId());
|
||||
area.setVoltageLevel(station.get(0).getVoltageLevel());
|
||||
}else {
|
||||
area.setPowerrName(excel.getPowerrName());
|
||||
area.setPowerStationId(IdUtil.simpleUUID());
|
||||
area.setVoltageLevel(dictData.getId());
|
||||
}
|
||||
}else{
|
||||
area.setPowerrName("");
|
||||
area.setPowerStationId("");
|
||||
area.setVoltageLevel(dictData.getId());
|
||||
}
|
||||
area.setLineName(StrUtil.isBlank(excel.getLineName())?"":excel.getLineName());
|
||||
area.setLineId(IdUtil.simpleUUID());
|
||||
area.setPCapacity(100.0F);
|
||||
area.setRegionalism("");
|
||||
area.setDevRegionalism("");
|
||||
area.setIfRuralPowerGrid(false);
|
||||
area.setNatureOfUse("");
|
||||
area.setPowerSupplyRadius(100.0F);
|
||||
area.setLineLength(100.0F);
|
||||
area.setState(runData.getId());
|
||||
area.setDistributedPhotovoltaicNum(10);
|
||||
area.setPhotovoltaicCapacity(100.0F);
|
||||
area.setIfBevAp(false);
|
||||
area.setApLoadType("分布式光伏");
|
||||
area.setLongitude(0.0D);
|
||||
area.setLatitude(0.0D);
|
||||
area.setIsUpToGrid(false);
|
||||
area.setStatus(true);
|
||||
area.setInputStatus(1);
|
||||
area.setCreateBy("");
|
||||
area.setCreateTime(LocalDateTime.now());
|
||||
area.setUpdateBy("");
|
||||
area.setUpdateTime(LocalDateTime.now());
|
||||
area.setPmsID(excel.getPmsID());
|
||||
info.add(area);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
info= info.stream()
|
||||
.filter(StreamUtil.distinctByKey(PmsPowerDistributionarea::getId))
|
||||
.collect(Collectors.toList());
|
||||
LambdaQueryWrapper<PmsPowerDistributionarea> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(PmsPowerDistributionarea::getInputStatus, 1);
|
||||
powerDistributionareaService.remove(lambdaQueryWrapper);
|
||||
powerDistributionareaService.saveBatch(info, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void SavaZhangArea(List<ZhangDistributionAreaExcel> list, HttpServletResponse response) {
|
||||
List<PmsPowerDistributionarea> info=new ArrayList<>();
|
||||
//电压等级
|
||||
List<DictData> dictData = dictDataMapper.selectList("Dev_Voltage");
|
||||
DictData data10KV = dictDataMapper.selectByCode("10kV", "Dev_Voltage");
|
||||
//运行状态
|
||||
DictData runData = dictDataMapper.selectByCode("Run", "Line_State");
|
||||
//获取部门信息
|
||||
List<Dept> depts = dictDataMapper.selectUserList();
|
||||
|
||||
Integer num=0;
|
||||
PmsPowerDistributionarea area;
|
||||
for (ZhangDistributionAreaExcel excel : list) {
|
||||
area=new PmsPowerDistributionarea();
|
||||
if("#N/A".equals(excel.getId())){
|
||||
area.setId(excel.getPmsID().substring(0,30));
|
||||
}else{
|
||||
area.setId(excel.getId());
|
||||
}
|
||||
area.setName(excel.getName());
|
||||
|
||||
|
||||
List<Dept> deptList = depts.stream().filter(x -> x.getCode().contains(excel.getOrgId())).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(deptList)){
|
||||
String org = subString(excel.getOrgName().replace("国网",""));
|
||||
List<Dept> 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{
|
||||
area.setOrgName(deptList.get(0).getName());
|
||||
area.setOrgId(deptList.get(0).getCode());
|
||||
}
|
||||
if(StrUtil.isNotBlank(excel.getOperationId())){
|
||||
area.setOperationName(excel.getOperationName());
|
||||
area.setOperationId(excel.getOperationId());
|
||||
}else{
|
||||
area.setOperationName("");
|
||||
area.setOperationId("");
|
||||
}
|
||||
area.setPowerrName(excel.getPowerrName());
|
||||
area.setPowerStationId(excel.getPowerStationId());
|
||||
if(StrUtil.isNotBlank(excel.getLineId())){
|
||||
area.setLineName(excel.getLineName());
|
||||
area.setLineId(excel.getLineId());
|
||||
}else{
|
||||
area.setLineName("");
|
||||
area.setLineId("");
|
||||
}
|
||||
if(StrUtil.isNotBlank(excel.getVoltageLevel())){
|
||||
int i = excel.getVoltageLevel().indexOf("(");
|
||||
if(i !=-1){
|
||||
area.setVoltageLevel(get380Voltage(excel.getVoltageLevel().substring(0,i), dictData));
|
||||
}else{
|
||||
area.setVoltageLevel(data10KV.getId());
|
||||
}
|
||||
}else{
|
||||
area.setVoltageLevel(data10KV.getId());
|
||||
}
|
||||
if(StrUtil.isNotBlank(excel.getPCapacity())&&!"#N/A".equals(excel.getPCapacity())){
|
||||
String substring = excel.getPCapacity().substring(excel.getPCapacity().lastIndexOf("-")+1, excel.getPCapacity().indexOf("/") );
|
||||
area.setPCapacity(Float.valueOf(substring));
|
||||
}else{
|
||||
area.setPCapacity(100.0f);
|
||||
}
|
||||
area.setRegionalism("");
|
||||
area.setDevRegionalism("");
|
||||
area.setIfRuralPowerGrid(false);
|
||||
area.setNatureOfUse("");
|
||||
area.setPowerSupplyRadius(ObjectUtil.isNull(excel.getPowerSupplyRadius())?100.0f:excel.getPowerSupplyRadius());
|
||||
area.setLineLength(ObjectUtil.isNull(excel.getLineLength())?100.0f:excel.getLineLength());
|
||||
area.setState(runData.getId());
|
||||
area.setDistributedPhotovoltaicNum(ObjectUtil.isNull(excel.getDistributedPhotovoltaicNum())?10:excel.getDistributedPhotovoltaicNum());
|
||||
area.setPhotovoltaicCapacity(ObjectUtil.isNull(excel.getPhotovoltaicCapacity())?100.0f:excel.getPhotovoltaicCapacity());
|
||||
area.setIfBevAp(false);
|
||||
area.setApLoadType("分布式光伏");
|
||||
area.setLongitude(0.0D);
|
||||
area.setLatitude(0.0D);
|
||||
area.setIsUpToGrid(false);
|
||||
area.setStatus(true);
|
||||
area.setInputStatus(2);
|
||||
area.setCreateBy("");
|
||||
area.setCreateTime(LocalDateTime.now());
|
||||
area.setUpdateBy("");
|
||||
area.setPmsID(excel.getPmsID());
|
||||
area.setUpdateTime(LocalDateTime.now());
|
||||
info.add(area);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
info= info.stream()
|
||||
.filter(StreamUtil.distinctByKey(PmsPowerDistributionarea::getId))
|
||||
.collect(Collectors.toList());
|
||||
LambdaQueryWrapper<PmsPowerDistributionarea> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(PmsPowerDistributionarea::getInputStatus, 2);
|
||||
powerDistributionareaService.remove(lambdaQueryWrapper);
|
||||
powerDistributionareaService.saveBatch(info, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean savePmsDistributionMonitor() {
|
||||
Boolean aBoolean = dictDataMapper.deletePmsDistributionMonitor(null);
|
||||
DictData dictData = dictDataMapper.selectByCode("Three_Line", "Line_Sort");
|
||||
Boolean aBoolean = dictDataMapper.deletePmsDistributionMonitor(dictData.getId(),"1");
|
||||
if(aBoolean){
|
||||
return dictDataMapper.insertPmsDistributionMonitor();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean savePmsDistributionArea() {
|
||||
DictData dictData = dictDataMapper.selectByCode("Two_Line", "Line_Sort");
|
||||
dictDataMapper.deletePmsDistributionMonitor(dictData.getId(),null);
|
||||
return dictDataMapper.insertPmsDistributionArea(dictData.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importDistributionAreaExcel(List<PowerDistributionAreaExcel.ErrMsg> list, HttpServletResponse response) {
|
||||
List<PmsPowerDistributionarea> info=new ArrayList<>();
|
||||
List<PowerDistributionAreaExcel.ErrMsg> errInfo=new ArrayList<>();
|
||||
if(CollUtil.isNotEmpty(list)){
|
||||
PmsPowerDistributionarea area;
|
||||
//获取部门信息
|
||||
List<Dept> depts = dictDataMapper.selectUserList();
|
||||
//电压等级
|
||||
List<DictData> devVoltage = dictDataMapper.selectList("Dev_Voltage");
|
||||
//地区特征
|
||||
List<DictData> deviceRegionLype = dictDataMapper.selectList("Area");
|
||||
//使用性质
|
||||
List<DictData> deviceUseNature = dictDataMapper.selectList("Device_UseNature");
|
||||
//运行状态
|
||||
List<DictData> 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<Dept> deptList = depts.stream().filter(x -> x.getCode().contains(msg.getOrgId())).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(deptList)){
|
||||
String org = subString(msg.getOrgName().replace("国网",""));
|
||||
List<Dept> 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<String> ids = info.stream().map(PmsPowerDistributionarea::getId).collect(Collectors.toList());
|
||||
List<PowerDistributionAreaExcel.ErrMsg> subInfo = list.stream().filter(x -> ids.contains(x.getId())).collect(Collectors.toList());
|
||||
addSubWire(subInfo,devVoltage);
|
||||
powerDistributionareaService.remove(new LambdaQueryWrapper<PmsPowerDistributionarea>()
|
||||
.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<PowerDistributionAreaExcel.ErrMsg> info,List<DictData> devVoltage) {
|
||||
List<PmsStatationStat> stats=new ArrayList<>();
|
||||
PmsStatationStat stat;
|
||||
List<PmsGeneratrixWire> wires=new ArrayList<>();
|
||||
PmsGeneratrixWire wire;
|
||||
List<PmsStatationStat> oldStat = iPmsStatationStatService.list();
|
||||
List<String> statIds = oldStat.stream().map(PmsStatationStat::getPowerId).distinct().collect(Collectors.toList());
|
||||
List<PmsGeneratrixWire> 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 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<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 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> dictData) {
|
||||
List<DictData> dictDataList = dictData.stream().filter(x -> x.getName().indexOf(name) != -1).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dictDataList)) {
|
||||
@@ -317,7 +683,7 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
stat.setOrgId(dept.getCode());
|
||||
stat.setOrgName(dept.getName());
|
||||
stat.setShouldBeNum(100);
|
||||
stat.setVoltageLevel(getVoltage(value.getVoltage_Level(), dev_voltage));
|
||||
stat.setVoltageLevel(getVoltage(value.getVoltage_Level().replace("交流",""), dev_voltage));
|
||||
stat.setStatus(1);
|
||||
stat.setCreateTime(LocalDateTime.now());
|
||||
stat.setUpdateTime(LocalDateTime.now());
|
||||
@@ -326,7 +692,7 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
}
|
||||
});
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
iPmsStatationStatService.saveBatch(info, 1000);
|
||||
iPmsStatationStatService.saveOrUpdateBatch(info, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +727,7 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
stat.setOrgId(dept.getCode());
|
||||
stat.setOrgName(dept.getName());
|
||||
stat.setShouldBeNum(100);
|
||||
stat.setVoltageLevel(getVoltage(value.getVoltage_Level(), dev_voltage));
|
||||
stat.setVoltageLevel(get380Voltage(value.getVoltage_Level(), dev_voltage));
|
||||
stat.setStatus(1);
|
||||
stat.setCreateTime(LocalDateTime.now());
|
||||
stat.setUpdateTime(LocalDateTime.now());
|
||||
@@ -370,7 +736,7 @@ public class DisPhotovoltaicServiceImpl implements DisPhotovoltaicService {
|
||||
}
|
||||
});
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
iPmsStatationStatService.saveBatch(info, 1000);
|
||||
iPmsStatationStatService.saveOrUpdateBatch(info, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-11-28
|
||||
*/
|
||||
@Service
|
||||
public class PmsGeneratrixWireServiceImpl extends ServiceImpl<PmsGeneratrixWireMapper, PmsGeneratrixWire> implements IPmsGeneratrixWireService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.jbsyncdata.service.impl;
|
||||
|
||||
import com.njcn.jbsyncdata.mapper.PmsPowerDistributionareaMapper;
|
||||
import com.njcn.jbsyncdata.pojo.po.PmsPowerDistributionarea;
|
||||
import com.njcn.jbsyncdata.service.IPmsPowerDistributionareaService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 台区信息 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-11-20
|
||||
*/
|
||||
@Service
|
||||
public class PmsPowerDistributionareaServiceImpl extends ServiceImpl<PmsPowerDistributionareaMapper, PmsPowerDistributionarea> implements IPmsPowerDistributionareaService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.njcn.jbsyncdata.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.jbsyncdata.component.TokenComponent;
|
||||
import com.njcn.jbsyncdata.mapper.DictDataMapper;
|
||||
import com.njcn.jbsyncdata.mapper.PmsSubstationMapper;
|
||||
import com.njcn.jbsyncdata.pojo.DictData;
|
||||
import com.njcn.jbsyncdata.pojo.PmsSubstation;
|
||||
import com.njcn.jbsyncdata.pojo.YWZTSubstation;
|
||||
import com.njcn.jbsyncdata.pojo.result.TokenResult;
|
||||
import com.njcn.jbsyncdata.service.IPmsSubstationService;
|
||||
import com.njcn.jbsyncdata.util.RestTemplateUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2024-08-07
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PmsSubstationServiceImpl extends ServiceImpl<PmsSubstationMapper, PmsSubstation> implements IPmsSubstationService {
|
||||
|
||||
private final DictDataMapper dictDataMapper;
|
||||
|
||||
private final TokenComponent tokenComponent;
|
||||
|
||||
@Override
|
||||
public Boolean addYwZtSubstation(String distribution, String psrType) {
|
||||
//数据中心(电压等级)
|
||||
List<DictData> devVoltage = dictDataMapper.selectList("Dev_Voltage_Stand");
|
||||
TokenResult tokenWithRestTemplate = tokenComponent.getTokenWithRestTemplate();
|
||||
if (null == tokenWithRestTemplate) {
|
||||
log.error("token信息获取失败");
|
||||
return false;
|
||||
}
|
||||
RestTemplateUtil restTemplateUtil = new RestTemplateUtil();
|
||||
JSONObject param = new JSONObject();
|
||||
JSONObject params = new JSONObject();
|
||||
List<cn.hutool.json.JSONObject> paramList = new ArrayList<>();
|
||||
param.put("distribution", distribution);
|
||||
param.put("psrType", psrType);
|
||||
param.put("params", params);
|
||||
//当前页数
|
||||
params.put("current", "1");
|
||||
//每页数据量
|
||||
params.put("size", "2000");
|
||||
cn.hutool.json.JSONObject filter = JSONUtil.createObj();
|
||||
params.put("fieldName", "");
|
||||
params.put("compare", "");
|
||||
params.put("fieldValue", "");
|
||||
params.put("fields", "name,city,psrId");
|
||||
paramList.add(filter);
|
||||
params.put("filters", paramList);
|
||||
//组装好json开始发送请求
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("x-token", tokenWithRestTemplate.getAccess_token());
|
||||
String a="{\n" +
|
||||
" \"distribution\": 1,\n" +
|
||||
" \"psrType\": \"zf01\",\n" +
|
||||
" \"params\": {\n" +
|
||||
" \"current\": 1,\n" +
|
||||
" \"size\": 20000,\n" +
|
||||
" \"filters\": [\n" +
|
||||
" {\n" +
|
||||
" \"fieldName\": \"\",\n" +
|
||||
" \"compare\": \"\",\n" +
|
||||
" \"fieldValue\": \"\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
ResponseEntity<String> post = restTemplateUtil.post(tokenComponent.getUrl().concat("/PSRCenter/queryServices/listPropertiesByFilters"), headers, a, String.class);
|
||||
String body = post.getBody().replaceAll("#", "");
|
||||
YWZTSubstation ywztSubstation = JSONObject.parseObject(body, YWZTSubstation.class);
|
||||
YWZTSubstation.ResultDTO.Zf01DTO zf01 = ywztSubstation.getResult().getZf01();
|
||||
List<YWZTSubstation.ResultDTO.Zf01DTO.RecordsDTO> records = zf01.getRecords();
|
||||
List<PmsSubstation> info = new ArrayList<>();
|
||||
for (YWZTSubstation.ResultDTO.Zf01DTO.RecordsDTO record : records) {
|
||||
YWZTSubstation.ResultDTO.Zf01DTO.RecordsDTO.ResourceDTO resource = record.getResource();
|
||||
PmsSubstation byId = this.getById(record.getId());
|
||||
if (ObjectUtil.isNull(byId)) {
|
||||
PmsSubstation substation = new PmsSubstation();
|
||||
substation.setId(record.getId());
|
||||
substation.setOrgId(resource.getCity());
|
||||
substation.setOperationName(resource.getCityName());
|
||||
substation.setType(psrType);
|
||||
substation.setName(resource.getName());
|
||||
substation.setScale(getAlgoDescribe(resource.getVoltageLevel(), devVoltage));
|
||||
substation.setScaleName(resource.getVoltageLevelName());
|
||||
substation.setMaintenanceName(resource.getMaintGroupName());
|
||||
substation.setRunStatus(resource.getPsrStateName());
|
||||
substation.setRunTime(LocalDateTimeUtil.parse(resource.getCtime(), "yyyy-MM-dd HH:mm:ss"));
|
||||
//经纬度
|
||||
String geoPositon = resource.getGeoPositon();
|
||||
if(StrUtil.
|
||||
isNotBlank(geoPositon)){
|
||||
String[] split = geoPositon.split(",");
|
||||
substation.setLng(new BigDecimal(split[0]));
|
||||
substation.setLat(new BigDecimal(split[1]));
|
||||
}
|
||||
substation.setCreateTime(LocalDateTime.now());
|
||||
substation.setUpdateTime(LocalDateTime.now());
|
||||
info.add(substation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
System.out.println(info);
|
||||
return this.saveOrUpdateBatch(info);
|
||||
}
|
||||
|
||||
public String getAlgoDescribe(String name, List<DictData> dictData) {
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
List<DictData> dictDataList = dictData.stream().filter(x -> x.getAlgoDescribe() == Integer.valueOf(name)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dictDataList)) {
|
||||
return dictDataList.get(0).getId();
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.njcn.jbsyncdata.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.jbsyncdata.mapper.BusBarMapper;
|
||||
import com.njcn.jbsyncdata.mapper.DictDataMapper;
|
||||
import com.njcn.jbsyncdata.pojo.DictData;
|
||||
import com.njcn.jbsyncdata.pojo.PmsSubstation;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.BusBarResult;
|
||||
import com.njcn.jbsyncdata.service.IPmsSubstationService;
|
||||
import com.njcn.jbsyncdata.service.YwZtBusBarService;
|
||||
import com.njcn.jbsyncdata.util.YwZtUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/9/25 17:13
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class YwZtBusBarServiceImpl extends MppServiceImpl<BusBarMapper, BusBarResult.BusBar> implements YwZtBusBarService {
|
||||
|
||||
private final IPmsSubstationService pmsSubstationService;
|
||||
private final DictDataMapper dictDataMapper;
|
||||
|
||||
@Override
|
||||
public Boolean addYwZtBusBar(String cookie, String aMapToken) {
|
||||
List<DictData> devVoltage = dictDataMapper.selectList("Dev_Voltage_Stand");
|
||||
List<PmsSubstation> list = pmsSubstationService.list().stream().filter(x->x.getType().equals("zf01")).collect(Collectors.toList());
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
System.out.println("-----------"+i);
|
||||
List<BusBarResult.BusBar> busBars = YwZtUtil.busBar(list.get(i).getId(), list.get(i).getType(), "0311", cookie, aMapToken);
|
||||
if (CollUtil.isNotEmpty(busBars)) {
|
||||
for (BusBarResult.BusBar busBar : busBars) {
|
||||
busBar.setVoltageLevelId(getAlgoDescribe(busBar.getVoltageLevelName(), devVoltage));
|
||||
busBar.setCreateTime(LocalDateTime.now());
|
||||
busBar.setUpdateTime(LocalDateTime.now());
|
||||
}
|
||||
this.saveOrUpdateBatchByMultiId(busBars);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getAlgoDescribe(String name, List<DictData> dictData) {
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
List<DictData> dictDataList = dictData.stream().filter(x -> name.contains(x.getName())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dictDataList)) {
|
||||
return dictDataList.get(0).getId();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.njcn.jbsyncdata.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.jbsyncdata.mapper.DictDataMapper;
|
||||
import com.njcn.jbsyncdata.mapper.IncomeAndOutgoMapper;
|
||||
import com.njcn.jbsyncdata.pojo.DictData;
|
||||
import com.njcn.jbsyncdata.pojo.PmsSubstation;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.IncomeAndOutgoLinesResult;
|
||||
import com.njcn.jbsyncdata.service.IPmsSubstationService;
|
||||
import com.njcn.jbsyncdata.service.YwZtIncomeAndOutgoService;
|
||||
import com.njcn.jbsyncdata.util.YwZtUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/9/25 17:13
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class YwZtIncomeAndOutgoServiceImpl extends MppServiceImpl<IncomeAndOutgoMapper, IncomeAndOutgoLinesResult.PsrInfo> implements YwZtIncomeAndOutgoService {
|
||||
|
||||
private final IPmsSubstationService pmsSubstationService;
|
||||
private final DictDataMapper dictDataMapper;
|
||||
@Override
|
||||
public Boolean addYwZtIncomeAndOutgo(String cookie, String aMapToken) throws InterruptedException {
|
||||
List<DictData> devVoltage = dictDataMapper.selectList("Dev_Voltage_Stand");
|
||||
List<PmsSubstation> list = pmsSubstationService.list().stream().collect(Collectors.toList());
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
System.out.println("------------------"+i);
|
||||
List<IncomeAndOutgoLinesResult.PsrInfo> list1 = this.list(new LambdaQueryWrapper<IncomeAndOutgoLinesResult.PsrInfo>()
|
||||
.eq(IncomeAndOutgoLinesResult.PsrInfo::getPsrSubId, list.get(i).getId()));
|
||||
if(CollUtil.isEmpty(list1)){
|
||||
List<IncomeAndOutgoLinesResult.PsrInfo> psrInfos = YwZtUtil.inComeAndOutgo(list.get(i).getId(), cookie, aMapToken);
|
||||
if (CollUtil.isNotEmpty(psrInfos)) {
|
||||
for (IncomeAndOutgoLinesResult.PsrInfo psrInfo : psrInfos) {
|
||||
psrInfo.setVoltageLevelId(getAlgoDescribe(psrInfo.getVoltageLevelCode(), devVoltage));
|
||||
psrInfo.setCreateTime(LocalDateTime.now());
|
||||
psrInfo.setUpdateTime(LocalDateTime.now());
|
||||
}
|
||||
this.saveOrUpdateBatchByMultiId(psrInfos);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getAlgoDescribe(String name, List<DictData> dictData) {
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
List<DictData> dictDataList = dictData.stream().filter(x -> x.getAlgoDescribe() == Integer.valueOf(name)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dictDataList)) {
|
||||
return dictDataList.get(0).getId();
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.jbsyncdata.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.jbsyncdata.mapper.BusBarMapper;
|
||||
import com.njcn.jbsyncdata.mapper.DictDataMapper;
|
||||
import com.njcn.jbsyncdata.mapper.LineDetailMapper;
|
||||
import com.njcn.jbsyncdata.pojo.DictData;
|
||||
import com.njcn.jbsyncdata.pojo.PmsSubstation;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.BusBarResult;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.IncomeAndOutgoLinesResult;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.LineDetail;
|
||||
import com.njcn.jbsyncdata.service.IPmsSubstationService;
|
||||
import com.njcn.jbsyncdata.service.YwZtBusBarService;
|
||||
import com.njcn.jbsyncdata.service.YwZtLineDetailService;
|
||||
import com.njcn.jbsyncdata.util.YwZtUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/9/25 17:13
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class YwZtLineDetailServiceImpl extends MppServiceImpl<LineDetailMapper, LineDetail> implements YwZtLineDetailService {
|
||||
|
||||
private final YwZtIncomeAndOutgoServiceImpl incomeAndOutgoService;
|
||||
|
||||
@Override
|
||||
public Boolean addYwZtLineDetail( String aMapToken) {
|
||||
List<IncomeAndOutgoLinesResult.PsrInfo> list = incomeAndOutgoService.list(new LambdaQueryWrapper<IncomeAndOutgoLinesResult.PsrInfo>()
|
||||
.eq(IncomeAndOutgoLinesResult.PsrInfo::getPsrType,"xl"));
|
||||
List<String> collect = list.stream().map(IncomeAndOutgoLinesResult.PsrInfo::getPsrId).distinct().collect(Collectors.toList());
|
||||
List<LineDetail> info=new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < collect.size(); i++) {
|
||||
System.out.println("-----------"+i);
|
||||
LineDetail lineDetail = YwZtUtil.lineDetailSub(collect.get(i), aMapToken);
|
||||
if (ObjUtil.isNotNull(lineDetail)) {
|
||||
info.add(lineDetail);
|
||||
}
|
||||
}
|
||||
if(CollUtil.isNotEmpty(info)){
|
||||
this.saveOrUpdateBatch(info);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
264
src/main/java/com/njcn/jbsyncdata/util/AreaDataProcessing.java
Normal file
264
src/main/java/com/njcn/jbsyncdata/util/AreaDataProcessing.java
Normal file
@@ -0,0 +1,264 @@
|
||||
package com.njcn.jbsyncdata.util;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.file.FileReader;
|
||||
import cn.hutool.core.io.file.FileWriter;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.njcn.jbsyncdata.component.TokenComponent;
|
||||
import com.njcn.jbsyncdata.enums.MeasTypeEnum;
|
||||
import com.njcn.jbsyncdata.pojo.InfluxAreaData;
|
||||
import com.njcn.jbsyncdata.pojo.po.PmsPowerDistributionarea;
|
||||
import com.njcn.jbsyncdata.pojo.result.TokenResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.dto.BatchPoints;
|
||||
import org.influxdb.dto.Point;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2023/10/20 14:14
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AreaDataProcessing {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
@Async("asyncExecutor")
|
||||
public void asyncInfluxDb(
|
||||
TokenComponent tokenComponent,
|
||||
String date,
|
||||
RestTemplateUtil restTemplateUtil,
|
||||
List<String> typeList,
|
||||
JSONObject jsonObject,
|
||||
JSONObject jsonObjectSub,
|
||||
Map<String, String> headers,
|
||||
List<List<PmsPowerDistributionarea>> singleQueryDataUserId, int k
|
||||
) {
|
||||
TokenResult tokenWithRestTemplate;
|
||||
//将发电用户编号按100尺寸分片
|
||||
List<List<PmsPowerDistributionarea>> partitionList = ListUtils.partition(singleQueryDataUserId.get(k), 20);
|
||||
log.error("总计分了{}片", partitionList.size());
|
||||
int count = 0;
|
||||
tokenWithRestTemplate = tokenComponent.getTokenWithRestTemplate();
|
||||
headers.put("x-token", tokenWithRestTemplate.getAccess_token());
|
||||
//先获取数据
|
||||
List<ResponseEntity<String>> responseEntities = new ArrayList<>(2000);
|
||||
int kk = k + 1;
|
||||
for (List<PmsPowerDistributionarea> generationAreaIDList : partitionList) {
|
||||
count++;
|
||||
log.error("查询第{}大片,{}小片数据", kk, count);
|
||||
//按批次处理用户编号数据
|
||||
List<String> psrIds = generationAreaIDList.stream().map(PmsPowerDistributionarea::getPmsID).collect(Collectors.toList());
|
||||
jsonObjectSub.set("psrIds", psrIds);
|
||||
JSONArray jsonArray = JSONUtil.createArray();
|
||||
jsonArray.add(jsonObjectSub);
|
||||
jsonObject.set("filters", jsonArray);
|
||||
try {
|
||||
responseEntities.add(restTemplateUtil.post(tokenComponent.getUrl().concat("/realMeasCenter/telemetry/commonQuery"), headers, jsonObject, String.class));
|
||||
} catch (Exception exception) {
|
||||
log.error("远程调用接口异常,异常为:" + exception);
|
||||
}
|
||||
}
|
||||
//开始解析数据
|
||||
Set<String> userIdConcatMeasType = new HashSet<>();
|
||||
//将指标+客户编号组合起来匹配返回数据的第一条记录:userId@measType
|
||||
for (String measType : typeList) {
|
||||
userIdConcatMeasType.addAll(singleQueryDataUserId.get(k).stream().map(x->x.getPmsID().concat(StrPool.AT).concat(measType)).collect(Collectors.toSet()));
|
||||
}
|
||||
List</*各值以逗号分隔*/InfluxAreaData> influxData;
|
||||
Map</*表名*/String, List</*各值以逗号分隔*/String>> typeData = new HashMap<>();
|
||||
StringBuilder tempInfluxData;
|
||||
ResponseEntity<String> response;
|
||||
JSONArray statisticsDataList;
|
||||
JSONObject result;
|
||||
JSONObject statisticsData;
|
||||
JSONObject body;
|
||||
JSONArray records;
|
||||
String dataIdentify;
|
||||
JSONObject commonTelemetry;
|
||||
MeasTypeEnum measTypeEnumByMeasType;
|
||||
|
||||
//获取资源id和台区的对应关系
|
||||
Map<String, List<String>> areaMap = singleQueryDataUserId.get(k).stream().collect(Collectors.groupingBy(PmsPowerDistributionarea::getPmsID, Collectors.mapping(PmsPowerDistributionarea::getId, Collectors.toList())));
|
||||
|
||||
for (int i = 0; i < partitionList.size(); i++) {
|
||||
log.error("解析第{}片数据", i);
|
||||
response = responseEntities.get(i);
|
||||
body = JSONUtil.parseObj(response.getBody());
|
||||
|
||||
// String path = "C:\\Users\\web2023\\Desktop\\分布式光伏台区API调用结果\\2.txt";
|
||||
// FileReader fileReader = new FileReader(path);
|
||||
// String jsonStr = fileReader.readString();
|
||||
// body = JSONUtil.parseObj(jsonStr);
|
||||
if (response.getStatusCodeValue() == 200 && body.get("status", String.class).equalsIgnoreCase("000000")) {
|
||||
result = JSONUtil.parseObj(body.get("result", String.class));
|
||||
records = JSONUtil.parseArray(result.get("records", String.class));
|
||||
log.error("查询遥测数据结束,返回数据量:{}", records.size());
|
||||
if (CollectionUtil.isEmpty(records)) {
|
||||
//日志输出:
|
||||
log.error("查询时间:{},无遥测数据;", date);
|
||||
continue;
|
||||
}
|
||||
//处理各个record的数据,因用户下可能有多个测量点,按指标循环,默认采用第一个匹配上的做数据处理
|
||||
for (Object obj : records) { // 最多循环100*16次
|
||||
commonTelemetry = JSONUtil.parseObj(obj);
|
||||
dataIdentify = commonTelemetry.get("psrId", String.class).concat(StrPool.AT).concat(commonTelemetry.get("measTypeCode", String.class));
|
||||
if (userIdConcatMeasType.contains(dataIdentify)) {
|
||||
//首个包含该标识的数据进行处理
|
||||
measTypeEnumByMeasType = MeasTypeEnum.getMeasTypeEnumByMeasType(commonTelemetry.get("measTypeCode", String.class));
|
||||
//统计数据,经过测试,接口响应json可能不包含该属性
|
||||
statisticsDataList = commonTelemetry.get("telemetryValue", JSONArray.class);
|
||||
if (CollectionUtil.isEmpty(statisticsDataList)) {
|
||||
//添加进有指标但无遥测数据集合
|
||||
continue;
|
||||
}
|
||||
influxData = new ArrayList<>();
|
||||
InfluxAreaData influxAreaData;
|
||||
for (Object subObj : statisticsDataList) { // 匹配上进入,循环96次
|
||||
statisticsData = JSONUtil.parseObj(subObj);
|
||||
if(areaMap.containsKey(commonTelemetry.get("psrId", String.class))){
|
||||
List<String> list = areaMap.get(commonTelemetry.get("psrId", String.class));
|
||||
for (String s : list) {
|
||||
tempInfluxData = new StringBuilder();
|
||||
tempInfluxData.append(measTypeEnumByMeasType.getPhaseType())
|
||||
.append(StrPool.COMMA)
|
||||
.append(s)
|
||||
.append(StrPool.COMMA)
|
||||
.append(statisticsData.get("dataTime", String.class))
|
||||
.append(StrPool.COMMA)
|
||||
.append(measTypeEnumByMeasType.getFieldName())
|
||||
.append(StrPool.COMMA)
|
||||
.append(StrUtil.isBlank(statisticsData.get("measValue", String.class)) ? "0" : statisticsData.get("measValue", String.class));
|
||||
influxAreaData=new InfluxAreaData();
|
||||
influxAreaData.setId(s);
|
||||
influxAreaData.setInfluxData(tempInfluxData.toString());
|
||||
|
||||
influxData.add(influxAreaData);
|
||||
}
|
||||
}
|
||||
}
|
||||
//userId@measType@tableName:存在多个指标存储表名一致,避免数据覆盖;
|
||||
Map<String, List<String>> influxLineData = influxData.stream().collect(Collectors.groupingBy(InfluxAreaData::getId,Collectors.mapping(InfluxAreaData::getInfluxData, Collectors.toList())));
|
||||
for (String s : influxLineData.keySet()) {
|
||||
typeData.put(s.concat(StrPool.AT).concat(measTypeEnumByMeasType.getMeasType()).concat(StrPool.AT).concat(measTypeEnumByMeasType.getTableName()),influxLineData.get(s) );
|
||||
}
|
||||
|
||||
//处理完,删除该条记录,减少集合尺寸,提高效率
|
||||
userIdConcatMeasType.remove(dataIdentify);
|
||||
}
|
||||
}
|
||||
//没有匹配上的就是该用户没有数据
|
||||
log.error("剩余有{}条标识", userIdConcatMeasType.size());
|
||||
} else {
|
||||
log.error("查询遥测数据失败!第{}片,结果为:{}", count, response);
|
||||
}
|
||||
}
|
||||
//最后输出没有数据的资源编号
|
||||
/**
|
||||
* 输出到2个文件,lackData.txt、 excalationData.txt
|
||||
* 注:
|
||||
* 1、所有指标均没有有数据的资源编号
|
||||
* 2、部分指标没有数据的资源编号,并表明是哪些指标
|
||||
*/
|
||||
if (CollectionUtil.isNotEmpty(userIdConcatMeasType)) {
|
||||
Map<String, List<String>> finalMap = userIdConcatMeasType.stream().collect(Collectors.groupingBy(str ->
|
||||
str.substring(0, str.indexOf(StrPool.AT))
|
||||
));
|
||||
//全部缺失数据的用户
|
||||
List<String> lackData = new ArrayList<>();
|
||||
//部分缺失的用户及指标
|
||||
List<String> excalationData = new ArrayList<>();
|
||||
Set<String> keyedSet = finalMap.keySet();
|
||||
for (String key : keyedSet) {
|
||||
List<String> data = finalMap.get(key);
|
||||
if (data.size() == typeList.size()) {
|
||||
lackData.add(key);
|
||||
} else {
|
||||
data = data.stream().map(t -> t.substring(t.indexOf(StrPool.AT) + 1)).collect(Collectors.toList());
|
||||
key = key.concat(StrPool.COMMA).concat(StringUtils.join(data, StrPool.AT));
|
||||
excalationData.add(key);
|
||||
}
|
||||
}
|
||||
FileWriter lackDataWriter = FileWriter.create(new File("/usr/local/syncData/lackData" + date + k + "台区.txt"));
|
||||
lackDataWriter.writeLines(lackData);
|
||||
FileWriter excalationDataWriter = FileWriter.create(new File("/usr/local/syncData/excalationData" + date + k + "台区.txt"));
|
||||
excalationDataWriter.writeLines(excalationData);
|
||||
}
|
||||
log.error("用户有指标没有数据的长度为:{}", userIdConcatMeasType.size());
|
||||
//最后批量入库
|
||||
batchInsertData(typeData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量入库influxDB
|
||||
*
|
||||
* @param typeData 远程根据用户编号获取的数据 Map</表名/String, List<Map</属性名/String,/数值/String>>> typeData = new HashMap<>();
|
||||
*/
|
||||
private void batchInsertData(Map<String, List<String>> typeData) {
|
||||
log.error("总计有{}条记录入库,以20000作为基数分片插入influxdb", typeData.size());
|
||||
List<String> sqlList = new ArrayList<>();
|
||||
Set<String> tableNames = typeData.keySet();
|
||||
String[] datas;
|
||||
Map<String, String> tags;
|
||||
Map<String, Object> fields;
|
||||
Point point;
|
||||
BatchPoints batchPoints;
|
||||
for (String tableName : tableNames) {
|
||||
List<String> data = typeData.get(tableName);
|
||||
tableName = tableName.substring(tableName.lastIndexOf(StrPool.AT) + 1);
|
||||
for (String datum : data) {
|
||||
datas = datum.split(StrPool.COMMA);
|
||||
//tag数据
|
||||
tags = new HashMap<>();
|
||||
tags.put("phasic_type", datas[0]);
|
||||
tags.put("line_id", datas[1]);
|
||||
tags.put("quality_flag", "0");
|
||||
tags.put("value_type", "AVG");
|
||||
String time = datas[2];
|
||||
//tag数据删完后,剩余均是filed数据,因filed属性名不固定,无法指定获取,直接循环
|
||||
fields = new HashMap<>();
|
||||
fields.put(datas[3], datas[4]);
|
||||
point = influxDbUtils.pointBuilder(tableName, DateUtil.parse(time, DatePattern.NORM_DATETIME_FORMATTER).getTime(), TimeUnit.MILLISECONDS, tags, fields);
|
||||
batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
sqlList.add(batchPoints.lineProtocol());
|
||||
}
|
||||
}
|
||||
List<List<String>> subSqlList = ListUtils.partition(sqlList, 20000);
|
||||
int count = 1;
|
||||
for (List<String> sql : subSqlList) {
|
||||
try {
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "autogen", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, sql);
|
||||
} catch (Exception exception) {
|
||||
log.error("数据批量入库异常,异常为:{}",exception.toString());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
log.error("已经入库{}条记录!", count * 20000);
|
||||
count++;
|
||||
}
|
||||
log.error("当前批次所有数据,{}条均已入库!", sqlList.size());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
package com.njcn.jbsyncdata.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.file.FileWriter;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.njcn.jbsyncdata.enums.EmsInterfaceTypeEnum;
|
||||
import com.njcn.jbsyncdata.pojo.InfluxAreaData;
|
||||
import com.njcn.jbsyncdata.pojo.po.EmsInterface;
|
||||
import com.njcn.jbsyncdata.pojo.po.PmsPowerDistributionarea;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.dto.BatchPoints;
|
||||
import org.influxdb.dto.Point;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.File;
|
||||
import java.io.StringReader;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2023/10/20 14:14
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AreaInterfaceDataProcessing {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
|
||||
@Async("asyncExecutor")
|
||||
public void asyncInfluxDb(
|
||||
String startTime,
|
||||
String endTime,
|
||||
List<PmsPowerDistributionarea> singleQueryDataUserId, int k
|
||||
) {
|
||||
StringReader stringReader;
|
||||
InputSource inputSource;
|
||||
DocumentBuilder documentBuilder;
|
||||
Document document;
|
||||
int count = 0;
|
||||
//获取初始化数据信息
|
||||
List<EmsInterface> responseEntities = new ArrayList<>();
|
||||
// // 创建 DocumentBuilder 对象
|
||||
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
// DocumentBuilder builder;
|
||||
// try {
|
||||
// builder = factory.newDocumentBuilder();
|
||||
// // 解析 SOAP XML 文件
|
||||
// Document document = builder.parse("C:\\Users\\web2023\\Desktop\\response.xml");
|
||||
// // 获取 SOAP Body 元素
|
||||
// Element body = (Element) document.getElementsByTagName("soap:Body").item(0);
|
||||
// // 获取 GetStockPrice 元素
|
||||
// Element stockPrice = (Element) body.getElementsByTagName("ns1:getBizcDytsYcResponse").item(0);
|
||||
// // 获取 StockName 元素的文本内容
|
||||
// String stockName = stockPrice.getElementsByTagName("ns1:out").item(0).getTextContent();
|
||||
// Map ma = JSONObject.parseObject(stockName, Map.class);
|
||||
// responseEntities.addAll(JSONArray.parseArray(JSONArray.toJSONString(ma.get("data")), EmsInterface.class));
|
||||
// } catch (ParserConfigurationException | SAXException | IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
//没有遥测数据的信息
|
||||
List<String> notEmsInterface = new ArrayList<>();
|
||||
int kk = k + 1;
|
||||
for (PmsPowerDistributionarea areaIds : singleQueryDataUserId) {
|
||||
count++;
|
||||
//log.error("查询第{}大片,{}小片数据", kk, count);
|
||||
try {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Content-Type", "application/xml");
|
||||
|
||||
String aa = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:face=\"http://face.service.prss.com.app\">\n" +
|
||||
" <soapenv:Header/>\n" +
|
||||
" <soapenv:Body>\n" +
|
||||
" <face:getBizcDytsYc>\n" +
|
||||
" <face:in0>{\"data\":{\"pms_id\":\"" + areaIds.getPmsID() + "\",\"startdate\":\"" + startTime + "\",\"enddate\":\"" + endTime + "\"}}</face:in0>\n" +
|
||||
" </face:getBizcDytsYc>\n" +
|
||||
" </soapenv:Body>\n" +
|
||||
"</soapenv:Envelope>";
|
||||
RestTemplateUtil restTemplateUtil = new RestTemplateUtil();
|
||||
ResponseEntity<String> userEntity = restTemplateUtil.post("http://10.118.110.221:8013/prssface-ems/ws/EmsInterface", headers, aa, String.class);
|
||||
if (userEntity.getStatusCodeValue() == 200) {
|
||||
String entityBody = userEntity.getBody();
|
||||
stringReader = new StringReader(entityBody);
|
||||
inputSource = new InputSource(stringReader);
|
||||
documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
document = documentBuilder.parse(inputSource);
|
||||
// 获取 SOAP Body 元素
|
||||
Element body = (Element) document.getElementsByTagName("soap:Body").item(0);
|
||||
// 获取 GetStockPrice 元素
|
||||
Element stockPrice = (Element) body.getElementsByTagName("ns1:getBizcDytsYcResponse").item(0);
|
||||
// 获取 StockName 元素的文本内容
|
||||
String stockName = stockPrice.getElementsByTagName("ns1:out").item(0).getTextContent();
|
||||
Map ma = JSONObject.parseObject(stockName, Map.class);
|
||||
if(ma.containsKey("data")){
|
||||
List<EmsInterface> resul = JSONArray.parseArray(com.alibaba.fastjson.JSONArray.toJSONString(ma.get("data")), EmsInterface.class);
|
||||
if(CollUtil.isNotEmpty(resul)){
|
||||
responseEntities.addAll(resul);
|
||||
}else{
|
||||
notEmsInterface.add(areaIds.getPmsID());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
//log.error("远程调用接口异常,异常为:" + exception);
|
||||
}
|
||||
}
|
||||
List<String> typeList = EmsInterfaceTypeEnum.getMeasList();
|
||||
//开始解析数据
|
||||
Set<String> userIdConcatMeasType = new HashSet<>();
|
||||
//将指标+pms_id组合起来匹配返回数据的第一条记录:pms_Id@measType
|
||||
for (String measType : typeList) {
|
||||
userIdConcatMeasType.addAll(singleQueryDataUserId.stream().map(x -> x.getPmsID().concat(StrPool.AT).concat(measType)).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
List</*各值以逗号分隔*/InfluxAreaData> influxData;
|
||||
Map</*表名*/String, List</*各值以逗号分隔*/String>> typeData = new HashMap<>();
|
||||
StringBuilder tempInfluxData;
|
||||
String dataIdentify;
|
||||
EmsInterfaceTypeEnum measTypeEnumByMeasType;
|
||||
|
||||
//获取资源id和台区的对应关系
|
||||
Map<String, List<String>> areaMap = singleQueryDataUserId.stream().collect(Collectors.groupingBy(PmsPowerDistributionarea::getPmsID, Collectors.mapping(PmsPowerDistributionarea::getId, Collectors.toList())));
|
||||
//数据处理
|
||||
for (EmsInterface emsInterface : responseEntities) {
|
||||
dataIdentify = emsInterface.getPMS_ID().concat(StrPool.AT).concat(emsInterface.getYCLX());
|
||||
if (userIdConcatMeasType.contains(dataIdentify)) {
|
||||
//获取该类型枚举
|
||||
measTypeEnumByMeasType = EmsInterfaceTypeEnum.getMeasTypeEnumByMeasType(emsInterface.getYCLX());
|
||||
influxData = new ArrayList<>();
|
||||
InfluxAreaData influxAreaData;
|
||||
if(areaMap.containsKey(emsInterface.getPMS_ID())){
|
||||
List<String> list = areaMap.get(emsInterface.getPMS_ID());
|
||||
for (String s : list) {
|
||||
tempInfluxData = new StringBuilder();
|
||||
tempInfluxData.append(measTypeEnumByMeasType.getPhaseType())
|
||||
.append(StrPool.COMMA)
|
||||
.append(s)
|
||||
.append(StrPool.COMMA)
|
||||
.append(emsInterface.getYCSJ())
|
||||
.append(StrPool.COMMA)
|
||||
.append(measTypeEnumByMeasType.getFieldName())
|
||||
.append(StrPool.COMMA)
|
||||
.append(StrUtil.isBlank(emsInterface.getCDZ()) ? "0" : emsInterface.getCDZ());
|
||||
influxAreaData=new InfluxAreaData();
|
||||
influxAreaData.setId(s);
|
||||
influxAreaData.setInfluxData(tempInfluxData.toString());
|
||||
influxData.add(influxAreaData);
|
||||
}
|
||||
//userId@measType@tableName:存在多个指标存储表名一致,避免数据覆盖;
|
||||
Map<String, List<String>> influxLineData = influxData.stream().collect(Collectors.groupingBy(InfluxAreaData::getId, Collectors.mapping(InfluxAreaData::getInfluxData, Collectors.toList())));
|
||||
for (String s : influxLineData.keySet()) {
|
||||
typeData.put(s.concat(StrPool.AT).concat(measTypeEnumByMeasType.getMeasType()).concat(StrPool.AT).concat(measTypeEnumByMeasType.getTableName()), influxLineData.get(s));
|
||||
}
|
||||
//处理完,删除该条记录,减少集合尺寸,提高效率
|
||||
userIdConcatMeasType.remove(dataIdentify);
|
||||
}
|
||||
} else {
|
||||
//log.error("查询遥测数据失败!结果为:{}", dataIdentify);
|
||||
}
|
||||
}
|
||||
//没有匹配上的就是该用户没有数据
|
||||
//log.error("剩余有{}条标识", userIdConcatMeasType.size());
|
||||
//最后输出没有数据的资源编号
|
||||
/**
|
||||
* 输出到2个文件,lackData.txt、 excalationData.txt
|
||||
* 注:
|
||||
* 1、所有指标均没有有数据的资源编号
|
||||
* 2、部分指标没有数据的资源编号,并表明是哪些指标
|
||||
*/
|
||||
if (CollectionUtil.isNotEmpty(userIdConcatMeasType)) {
|
||||
Map<String, List<String>> finalMap = userIdConcatMeasType.stream().collect(Collectors.groupingBy(str ->
|
||||
str.substring(0, str.indexOf(StrPool.AT))
|
||||
));
|
||||
//全部缺失数据的用户
|
||||
List<String> lackData = new ArrayList<>();
|
||||
//部分缺失的用户及指标
|
||||
List<String> excalationData = new ArrayList<>();
|
||||
Set<String> keyedSet = finalMap.keySet();
|
||||
for (String key : keyedSet) {
|
||||
List<String> data = finalMap.get(key);
|
||||
if (data.size() == typeList.size()) {
|
||||
lackData.add(key);
|
||||
} else {
|
||||
data = data.stream().map(t -> t.substring(t.indexOf(StrPool.AT) + 1)).collect(Collectors.toList());
|
||||
key = key.concat(StrPool.COMMA).concat(StringUtils.join(data, StrPool.AT));
|
||||
excalationData.add(key);
|
||||
}
|
||||
}
|
||||
FileWriter lackDataWriter = FileWriter.create(new File("/usr/local/syncDataEms/lackData" + startTime.substring(0,10) + k + "台区.txt"));
|
||||
lackDataWriter.writeLines(lackData);
|
||||
FileWriter excalationDataWriter = FileWriter.create(new File("/usr/local/syncDataEms/excalationData" + startTime.substring(0,10) + k + "台区.txt"));
|
||||
excalationDataWriter.writeLines(excalationData);
|
||||
}
|
||||
//log.error("用户有指标没有数据的长度为:{}", userIdConcatMeasType.size());
|
||||
//最后批量入库
|
||||
batchInsertData(typeData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量入库influxDB
|
||||
*
|
||||
* @param typeData 远程根据用户编号获取的数据 Map</表名/String, List<Map</属性名/String,/数值/String>>> typeData = new HashMap<>();
|
||||
*/
|
||||
private void batchInsertData(Map<String, List<String>> typeData) {
|
||||
//log.error("总计有{}条记录入库,以20000作为基数分片插入influxdb", typeData.size());
|
||||
List<String> sqlList = new ArrayList<>();
|
||||
Set<String> tableNames = typeData.keySet();
|
||||
String[] datas;
|
||||
Map<String, String> tags;
|
||||
Map<String, Object> fields;
|
||||
Point point;
|
||||
BatchPoints batchPoints;
|
||||
for (String tableName : tableNames) {
|
||||
List<String> data = typeData.get(tableName);
|
||||
tableName = tableName.substring(tableName.lastIndexOf(StrPool.AT) + 1);
|
||||
for (String datum : data) {
|
||||
datas = datum.split(StrPool.COMMA);
|
||||
//tag数据
|
||||
tags = new HashMap<>();
|
||||
tags.put("phasic_type", datas[0]);
|
||||
tags.put("line_id", datas[1]);
|
||||
tags.put("quality_flag", "0");
|
||||
tags.put("value_type", "AVG");
|
||||
String time = datas[2];
|
||||
//tag数据删完后,剩余均是filed数据,因filed属性名不固定,无法指定获取,直接循环
|
||||
fields = new HashMap<>();
|
||||
fields.put(datas[3], datas[4]);
|
||||
point = influxDbUtils.pointBuilder(tableName, DateUtil.parse(time, DatePattern.NORM_DATETIME_MS_PATTERN).getTime(), TimeUnit.MILLISECONDS, tags, fields);
|
||||
batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
sqlList.add(batchPoints.lineProtocol());
|
||||
}
|
||||
}
|
||||
List<List<String>> subSqlList = ListUtils.partition(sqlList, 20000);
|
||||
int count = 1;
|
||||
for (List<String> sql : subSqlList) {
|
||||
try {
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "autogen", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, sql);
|
||||
} catch (Exception exception) {
|
||||
//log.error("数据批量入库异常,异常为:{}", exception.toString());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
log.info("Pms遥测数据--已经入库{}条记录!", count * 20000);
|
||||
count++;
|
||||
}
|
||||
log.info("Pms遥测数据--当前批次所有数据,{}条均已入库!", sqlList.size());
|
||||
|
||||
}
|
||||
}
|
||||
239
src/main/java/com/njcn/jbsyncdata/util/DataProcessing.java
Normal file
239
src/main/java/com/njcn/jbsyncdata/util/DataProcessing.java
Normal file
@@ -0,0 +1,239 @@
|
||||
package com.njcn.jbsyncdata.util;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.file.FileWriter;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.njcn.jbsyncdata.component.TokenComponent;
|
||||
import com.njcn.jbsyncdata.enums.MeasTypeEnum;
|
||||
import com.njcn.jbsyncdata.pojo.result.TokenResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.dto.BatchPoints;
|
||||
import org.influxdb.dto.Point;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2023/10/20 14:14
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DataProcessing {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
@Async("asyncExecutor")
|
||||
public void asyncInfluxDb(
|
||||
TokenComponent tokenComponent,
|
||||
String date,
|
||||
RestTemplateUtil restTemplateUtil,
|
||||
List<String> typeList,
|
||||
JSONObject jsonObject,
|
||||
JSONObject jsonObjectSub,
|
||||
Map<String, String> headers,
|
||||
List<List<String>> singleQueryDataUserId, int k
|
||||
) {
|
||||
TokenResult tokenWithRestTemplate;
|
||||
//将发电用户编号按100尺寸分片
|
||||
List<List<String>> partitionList = ListUtils.partition(singleQueryDataUserId.get(k), 20);
|
||||
log.error("总计分了{}片", partitionList.size());
|
||||
int count = 0;
|
||||
tokenWithRestTemplate = tokenComponent.getTokenWithRestTemplate();
|
||||
headers.put("x-token", tokenWithRestTemplate.getAccess_token());
|
||||
//先获取数据
|
||||
List<ResponseEntity<String>> responseEntities = new ArrayList<>(2000);
|
||||
int kk = k + 1;
|
||||
for (List<String> generationUserIDList : partitionList) {
|
||||
count++;
|
||||
log.error("查询第{}大片,{}小片数据", kk, count);
|
||||
//按批次处理用户编号数据
|
||||
jsonObjectSub.set("consNos", generationUserIDList);
|
||||
JSONArray jsonArray = JSONUtil.createArray();
|
||||
jsonArray.add(jsonObjectSub);
|
||||
jsonObject.set("filters", jsonArray);
|
||||
try {
|
||||
responseEntities.add(restTemplateUtil.post(tokenComponent.getUrl().concat("/realMeasCenter/telemetry/commonQuery"), headers, jsonObject, String.class));
|
||||
} catch (Exception exception) {
|
||||
log.error("远程调用接口异常,异常为:" + exception);
|
||||
}
|
||||
}
|
||||
//开始解析数据
|
||||
Set<String> userIdConcatMeasType = new HashSet<>();
|
||||
//将指标+客户编号组合起来匹配返回数据的第一条记录:userId@measType
|
||||
for (String measType : typeList) {
|
||||
userIdConcatMeasType.addAll(singleQueryDataUserId.get(k).stream().map(t -> t.concat(StrPool.AT).concat(measType)).collect(Collectors.toSet()));
|
||||
}
|
||||
List</*各值以逗号分隔*/String> influxData;
|
||||
Map</*表名*/String, List</*各值以逗号分隔*/String>> typeData = new HashMap<>();
|
||||
StringBuilder tempInfluxData;
|
||||
ResponseEntity<String> response;
|
||||
JSONArray statisticsDataList;
|
||||
JSONObject result;
|
||||
JSONObject statisticsData;
|
||||
JSONObject body;
|
||||
JSONArray records;
|
||||
String dataIdentify;
|
||||
JSONObject commonTelemetry;
|
||||
MeasTypeEnum measTypeEnumByMeasType;
|
||||
for (int i = 0; i < partitionList.size(); i++) {
|
||||
log.error("解析第{}片数据", i);
|
||||
response = responseEntities.get(i);
|
||||
body = JSONUtil.parseObj(response.getBody());
|
||||
if (response.getStatusCodeValue() == 200 && body.get("status", String.class).equalsIgnoreCase("000000")) {
|
||||
result = JSONUtil.parseObj(body.get("result", String.class));
|
||||
records = JSONUtil.parseArray(result.get("records", String.class));
|
||||
log.error("查询遥测数据结束,返回数据量:{}", records.size());
|
||||
if (CollectionUtil.isEmpty(records)) {
|
||||
//日志输出:
|
||||
log.error("查询时间:{},无遥测数据;", date);
|
||||
continue;
|
||||
}
|
||||
//处理各个record的数据,因用户下可能有多个测量点,按指标循环,默认采用第一个匹配上的做数据处理
|
||||
for (Object obj : records) { // 最多循环100*16次
|
||||
commonTelemetry = JSONUtil.parseObj(obj);
|
||||
dataIdentify = commonTelemetry.get("consNo", String.class).concat(StrPool.AT).concat(commonTelemetry.get("measTypeCode", String.class));
|
||||
if (userIdConcatMeasType.contains(dataIdentify)) {
|
||||
//首个包含该标识的数据进行处理
|
||||
measTypeEnumByMeasType = MeasTypeEnum.getMeasTypeEnumByMeasType(commonTelemetry.get("measTypeCode", String.class));
|
||||
//统计数据,经过测试,接口响应json可能不包含该属性
|
||||
statisticsDataList = commonTelemetry.get("telemetryValue", JSONArray.class);
|
||||
if (CollectionUtil.isEmpty(statisticsDataList)) {
|
||||
//添加进有指标但无遥测数据集合
|
||||
continue;
|
||||
}
|
||||
influxData = new ArrayList<>();
|
||||
for (Object subObj : statisticsDataList) { // 匹配上进入,循环96次
|
||||
statisticsData = JSONUtil.parseObj(subObj);
|
||||
tempInfluxData = new StringBuilder();
|
||||
tempInfluxData.append(measTypeEnumByMeasType.getPhaseType())
|
||||
.append(StrPool.COMMA)
|
||||
.append(commonTelemetry.get("consNo", String.class))
|
||||
.append(StrPool.COMMA)
|
||||
.append(statisticsData.get("dataTime", String.class))
|
||||
.append(StrPool.COMMA)
|
||||
.append(measTypeEnumByMeasType.getFieldName())
|
||||
.append(StrPool.COMMA)
|
||||
.append(StrUtil.isBlank(statisticsData.get("measValue", String.class)) ? "0" : statisticsData.get("measValue", String.class));
|
||||
influxData.add(tempInfluxData.toString());
|
||||
}
|
||||
//userId@measType@tableName:存在多个指标存储表名一致,避免数据覆盖;
|
||||
typeData.put(commonTelemetry.get("consNo", String.class).concat(StrPool.AT).concat(measTypeEnumByMeasType.getMeasType()).concat(StrPool.AT).concat(measTypeEnumByMeasType.getTableName()), influxData);
|
||||
//处理完,删除该条记录,减少集合尺寸,提高效率
|
||||
userIdConcatMeasType.remove(dataIdentify);
|
||||
}
|
||||
}
|
||||
//没有匹配上的就是该用户没有数据
|
||||
log.error("剩余有{}条标识", userIdConcatMeasType.size());
|
||||
} else {
|
||||
log.error("查询遥测数据失败!第{}片,结果为:{}", count, response);
|
||||
}
|
||||
}
|
||||
//最后输出没有数据的用户编号
|
||||
/**
|
||||
* 输出到2个文件,lackData.txt、 excalationData.txt
|
||||
* 注:用户号去除160前缀
|
||||
* 1、所有指标均没有有数据的用户编号
|
||||
* 2、部分指标没有数据的用户编号,并表明是哪些指标
|
||||
*/
|
||||
if (CollectionUtil.isNotEmpty(userIdConcatMeasType)) {
|
||||
Map<String, List<String>> finalMap = userIdConcatMeasType.stream().collect(Collectors.groupingBy(str -> {
|
||||
String key = str.substring(3);
|
||||
key = key.substring(0, key.indexOf(StrPool.AT));
|
||||
return key;
|
||||
}));
|
||||
//全部缺失数据的用户
|
||||
List<String> lackData = new ArrayList<>();
|
||||
//部分缺失的用户及指标
|
||||
List<String> excalationData = new ArrayList<>();
|
||||
Set<String> keyedSet = finalMap.keySet();
|
||||
for (String key : keyedSet) {
|
||||
List<String> data = finalMap.get(key);
|
||||
if (data.size() == typeList.size()) {
|
||||
lackData.add(key);
|
||||
} else {
|
||||
data = data.stream().map(t -> t.substring(t.indexOf(StrPool.AT) + 1)).collect(Collectors.toList());
|
||||
key = key.concat(StrPool.COMMA).concat(StringUtils.join(data, StrPool.AT));
|
||||
excalationData.add(key);
|
||||
}
|
||||
}
|
||||
FileWriter lackDataWriter = FileWriter.create(new File("/usr/local/syncData/lackData" + date + k + ".txt"));
|
||||
lackDataWriter.writeLines(lackData);
|
||||
FileWriter excalationDataWriter = FileWriter.create(new File("/usr/local/syncData/excalationData" + date + k + ".txt"));
|
||||
excalationDataWriter.writeLines(excalationData);
|
||||
}
|
||||
log.error("用户有指标没有数据的长度为:{}", userIdConcatMeasType.size());
|
||||
//最后批量入库
|
||||
batchInsertData(typeData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量入库influxDB
|
||||
*
|
||||
* @param typeData 远程根据用户编号获取的数据 Map</表名/String, List<Map</属性名/String,/数值/String>>> typeData = new HashMap<>();
|
||||
*/
|
||||
private void batchInsertData(Map<String, List<String>> typeData) {
|
||||
log.error("总计有{}条记录入库,以20000作为基数分片插入influxdb", typeData.size());
|
||||
List<String> sqlList = new ArrayList<>();
|
||||
Set<String> tableNames = typeData.keySet();
|
||||
String[] datas;
|
||||
Map<String, String> tags;
|
||||
Map<String, Object> fields;
|
||||
Point point;
|
||||
BatchPoints batchPoints;
|
||||
for (String tableName : tableNames) {
|
||||
List<String> data = typeData.get(tableName);
|
||||
tableName = tableName.substring(tableName.lastIndexOf(StrPool.AT) + 1);
|
||||
for (String datum : data) {
|
||||
datas = datum.split(StrPool.COMMA);
|
||||
//tag数据
|
||||
tags = new HashMap<>();
|
||||
tags.put("phasic_type", datas[0]);
|
||||
tags.put("line_id", datas[1]);
|
||||
tags.put("quality_flag", "0");
|
||||
tags.put("value_type", "AVG");
|
||||
String time = datas[2];
|
||||
//tag数据删完后,剩余均是filed数据,因filed属性名不固定,无法指定获取,直接循环
|
||||
fields = new HashMap<>();
|
||||
fields.put(datas[3], datas[4]);
|
||||
point = influxDbUtils.pointBuilder(tableName, DateUtil.parse(time, DatePattern.NORM_DATETIME_FORMATTER).getTime(), TimeUnit.MILLISECONDS, tags, fields);
|
||||
batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
sqlList.add(batchPoints.lineProtocol());
|
||||
}
|
||||
}
|
||||
List<List<String>> subSqlList = ListUtils.partition(sqlList, 20000);
|
||||
int count = 1;
|
||||
for (List<String> sql : subSqlList) {
|
||||
try {
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "autogen", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, sql);
|
||||
} catch (Exception exception) {
|
||||
log.error("数据批量入库异常,异常为:{}",exception.toString());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
log.error("已经入库{}条记录!", count * 20000);
|
||||
count++;
|
||||
}
|
||||
log.error("当前批次所有数据,{}条均已入库!", sqlList.size());
|
||||
|
||||
}
|
||||
}
|
||||
16
src/main/java/com/njcn/jbsyncdata/util/ExcelValid.java
Normal file
16
src/main/java/com/njcn/jbsyncdata/util/ExcelValid.java
Normal file
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>Excel导入必填校验注解</p>
|
||||
*
|
||||
*/
|
||||
@Target({ ElementType.FIELD, ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ExcelValid {
|
||||
String message() default "导入有未填入的字段";
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.njcn.jbsyncdata.util;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年07月24日 13:33
|
||||
*/
|
||||
@Component
|
||||
public class InstantDateDeserializer extends StdDeserializer<Instant> {
|
||||
|
||||
|
||||
public InstantDateDeserializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
|
||||
protected InstantDateDeserializer(Class<?> vc) {
|
||||
super(vc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Instant deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
String text = p.getValueAsString();
|
||||
return PubUtils.dateToInstant(DateUtil.parse(text,DatePattern.NORM_DATETIME_PATTERN));
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.njcn.jbsyncdata.util;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年04月25日 16:33
|
||||
*/
|
||||
@Component
|
||||
public class InstantDateSerializer extends StdSerializer<Instant> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static DateTimeFormatter format = DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN);
|
||||
|
||||
public InstantDateSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public InstantDateSerializer(Class<Instant> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
/***
|
||||
* 转义为 yyyy-MM-dd HH:mm:ss
|
||||
* @author hongawen
|
||||
*/
|
||||
@Override
|
||||
public void serialize(Instant instant, JsonGenerator jsonGenerator, SerializerProvider provider)
|
||||
throws IOException {
|
||||
if (instant == null) {
|
||||
return;
|
||||
}
|
||||
String jsonValue = format.format(instant.atZone(ZoneId.of("+00:00")));
|
||||
jsonGenerator.writeString(jsonValue);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
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 io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@@ -452,55 +454,152 @@ public class PubUtils {
|
||||
//***************************************************添加结束********************************************************
|
||||
|
||||
|
||||
// public static void main(String[] args) throws IOException {
|
||||
// //读取10kV的数据
|
||||
// List<DisPhotovoltaic10Excel> list10kV = EasyExcel.read("D:\\temp\\基础表.xlsx")
|
||||
// .excelType(ExcelTypeEnum.XLSX)
|
||||
// .head(DisPhotovoltaic10Excel.class)
|
||||
// .headRowNumber(2)
|
||||
// .sheet(0).doReadSync();
|
||||
// list10kV = list10kV.stream()
|
||||
// .filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
|
||||
// .filter(t -> StrUtil.isNotBlank(t.getStageID()))
|
||||
// .filter(StreamUtil.distinctByKey(DisPhotovoltaic10Excel::getGenerationUserID))
|
||||
// .collect(Collectors.toList());
|
||||
// //读取380V的数据
|
||||
// List<DisPhotovoltaic380Excel> list380v = EasyExcel.read("D:\\temp\\基础表.xlsx")
|
||||
// .excelType(ExcelTypeEnum.XLSX)
|
||||
// .head(DisPhotovoltaic380Excel.class)
|
||||
// .headRowNumber(2)
|
||||
// .sheet(1).doReadSync();
|
||||
// list380v = list380v.stream()
|
||||
// .filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
|
||||
// .filter(t -> StrUtil.isNotBlank(t.getStageID()))
|
||||
// .filter(StreamUtil.distinctByKey(DisPhotovoltaic380Excel::getGenerationUserID))
|
||||
// .collect(Collectors.toList());
|
||||
// //读取所有没数据的用户号
|
||||
// FileReader fileReader = new FileReader("D:\\temp\\all.txt");
|
||||
// List<String> noData = fileReader.readLines();
|
||||
// Set<String> noDataSet = new HashSet<>(noData);
|
||||
// FileReader fileReader2 = new FileReader("D:\\temp\\part.txt");
|
||||
// List<String> noPartData = fileReader2.readLines();
|
||||
// Set<String> noPartDataSet = new HashSet<>(noPartData);
|
||||
//
|
||||
// long millis = System.currentTimeMillis();
|
||||
// //梳理10kV全部没有数据的
|
||||
// List<DisPhotovoltaic10Excel> collect = list10kV.stream().filter(t -> noDataSet.contains(t.getGenerationUserID())).collect(Collectors.toList());
|
||||
// EasyExcel.write("D:\\temp\\10kV全部没有数据的.xlsx", DisPhotovoltaic10Excel.class).sheet("10kV全部没有数据的").doWrite(collect);
|
||||
// long millis1 = System.currentTimeMillis();
|
||||
// System.out.println("10kV全部没有数据的耗时:" + (millis1 - millis));
|
||||
// //10kV部分没有数据的
|
||||
// Map<String, List<String>> noPartDataMap = noPartDataSet.stream().collect(Collectors.groupingBy(t -> t.substring(0, t.indexOf(StrPool.COMMA))));
|
||||
// Map<String, List<DisPhotovoltaic10Excel>> all10kVMap = list10kV.stream().collect(Collectors.groupingBy(DisPhotovoltaic10Excel::getGenerationUserID));
|
||||
// Set<String> keyedSet1 = all10kVMap.keySet();
|
||||
// List<DisPhotovoltaic10Excel> final10kVUserData = new LinkedList<>();
|
||||
// String info;
|
||||
// for (String userId : keyedSet1) {
|
||||
// List<String> infoList = noPartDataMap.get(userId);
|
||||
// if (CollectionUtil.isNotEmpty(infoList)) {
|
||||
// info = infoList.get(0);
|
||||
// DisPhotovoltaic10Excel disPhotovoltaic10Excel = all10kVMap.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", "无功");
|
||||
// disPhotovoltaic10Excel.setTypes(info);
|
||||
// final10kVUserData.add(disPhotovoltaic10Excel);
|
||||
// }
|
||||
// }
|
||||
// EasyExcel.write("D:\\temp\\10kV部分没有数据的.xlsx", DisPhotovoltaic10Excel.class).sheet("10kV部分没有数据的").doWrite(final10kVUserData);
|
||||
// long millis2 = System.currentTimeMillis();
|
||||
// System.out.println("10kV部分没有数据的:" + (millis2 - millis1));
|
||||
// //梳理380V全部没有数据的
|
||||
// List<DisPhotovoltaic380Excel> collect4 = list380v.stream().filter(t -> noDataSet.contains(t.getGenerationUserID())).collect(Collectors.toList());
|
||||
// EasyExcel.write("D:\\temp\\380V全部没有数据的.xlsx", DisPhotovoltaic380Excel.class).sheet("380V全部没有数据的").doWrite(collect4);
|
||||
// long millis3 = System.currentTimeMillis();
|
||||
// System.out.println("380V全部没有数据的:" + (millis3 - millis2));
|
||||
// //380V部分没有数据的
|
||||
// Map<String, List<DisPhotovoltaic380Excel>> all380VMap = list380v.stream().collect(Collectors.groupingBy(DisPhotovoltaic380Excel::getGenerationUserID));
|
||||
// Set<String> keyedSet = noPartDataMap.keySet();
|
||||
// List<DisPhotovoltaic380Excel> final380VUserData = new LinkedList<>();
|
||||
// List<DisPhotovoltaic380Excel> disPhotovoltaic380ExcelList;
|
||||
// DisPhotovoltaic380Excel disPhotovoltaic380Excel;
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// EasyExcel.write("D:\\temp\\380V部分没有数据的.xlsx", DisPhotovoltaic380Excel.class).sheet("380V部分没有数据的").doWrite(final380VUserData);
|
||||
// long millis4 = System.currentTimeMillis();
|
||||
// System.out.println("380V部分没有数据的:" + (millis4 - millis3));
|
||||
// }
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
//读取10kV的数据
|
||||
List<DisPhotovoltaic10Excel> list10kV = EasyExcel.read("D:\\temp\\基础表.xlsx")
|
||||
.excelType(ExcelTypeEnum.XLSX)
|
||||
.head(DisPhotovoltaic10Excel.class)
|
||||
.headRowNumber(2)
|
||||
List<DistributionAreaExcel> list = EasyExcel.read("D:\\test\\唐山.xlsx")
|
||||
.head(DistributionAreaExcel.class)
|
||||
.sheet(0).doReadSync();
|
||||
list10kV = list10kV.stream()
|
||||
.filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
|
||||
.filter(t -> StrUtil.isNotBlank(t.getStageID()))
|
||||
.filter(StreamUtil.distinctByKey(DisPhotovoltaic10Excel::getGenerationUserID))
|
||||
list = list.stream()
|
||||
.filter(t -> !"#N/A".equals(t.getPmsID()))
|
||||
.collect(Collectors.toList());
|
||||
//读取380V的数据
|
||||
List<DisPhotovoltaic380Excel> list380v = EasyExcel.read("D:\\temp\\基础表.xlsx")
|
||||
.excelType(ExcelTypeEnum.XLSX)
|
||||
.head(DisPhotovoltaic380Excel.class)
|
||||
.headRowNumber(2)
|
||||
.sheet(1).doReadSync();
|
||||
list380v = list380v.stream()
|
||||
.filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
|
||||
.filter(t -> StrUtil.isNotBlank(t.getStageID()))
|
||||
.filter(StreamUtil.distinctByKey(DisPhotovoltaic380Excel::getGenerationUserID))
|
||||
.collect(Collectors.toList());
|
||||
//读取所有没数据的用户号
|
||||
|
||||
FileReader fileReader = new FileReader("D:\\temp\\all.txt");
|
||||
List<ZhangDistributionAreaExcel> listZhang = EasyExcel.read("D:\\test\\张家口.xlsx")
|
||||
.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());
|
||||
|
||||
//读取所有没数据的用户号
|
||||
FileReader fileReader = new FileReader("D:\\test\\all.txt");
|
||||
List<String> noData = fileReader.readLines();
|
||||
Set<String> noDataSet = new HashSet<>(noData);
|
||||
FileReader fileReader2 = new FileReader("D:\\temp\\part.txt");
|
||||
|
||||
FileReader fileReader2 = new FileReader("D:\\test\\part.txt");
|
||||
List<String> noPartData = fileReader2.readLines();
|
||||
Set<String> noPartDataSet = new HashSet<>(noPartData);
|
||||
|
||||
long millis = System.currentTimeMillis();
|
||||
//梳理10kV全部没有数据的
|
||||
List<DisPhotovoltaic10Excel> collect = list10kV.stream().filter(t -> noDataSet.contains(t.getGenerationUserID())).collect(Collectors.toList());
|
||||
EasyExcel.write("D:\\temp\\10kV全部没有数据的.xlsx", DisPhotovoltaic10Excel.class).sheet("10kV全部没有数据的").doWrite(collect);
|
||||
//唐山没有数据的信息
|
||||
List<DistributionAreaExcel> collect = list.stream().filter(t -> noDataSet.contains(t.getPmsID())).collect(Collectors.toList());
|
||||
EasyExcel.write("D:\\test\\唐山全部没有数据的.xlsx", DistributionAreaExcel.class).sheet("唐山全部没有数据的").doWrite(collect);
|
||||
long millis1 = System.currentTimeMillis();
|
||||
System.out.println("10kV全部没有数据的耗时:" + (millis1 - millis));
|
||||
//10kV部分没有数据的
|
||||
System.out.println("唐山全部没有数据的耗时:" + (millis1 - millis));
|
||||
//唐山部分没有数据的
|
||||
Map<String, List<String>> noPartDataMap = noPartDataSet.stream().collect(Collectors.groupingBy(t -> t.substring(0, t.indexOf(StrPool.COMMA))));
|
||||
Map<String, List<DisPhotovoltaic10Excel>> all10kVMap = list10kV.stream().collect(Collectors.groupingBy(DisPhotovoltaic10Excel::getGenerationUserID));
|
||||
Map<String, List<DistributionAreaExcel>> all10kVMap = list.stream().collect(Collectors.groupingBy(DistributionAreaExcel::getPmsID));
|
||||
|
||||
Set<String> keyedSet1 = all10kVMap.keySet();
|
||||
List<DisPhotovoltaic10Excel> final10kVUserData = new LinkedList<>();
|
||||
List<DistributionAreaExcel> final10kVUserData = new LinkedList<>();
|
||||
String info;
|
||||
for (String userId : keyedSet1) {
|
||||
List<String> infoList = noPartDataMap.get(userId);
|
||||
if (CollectionUtil.isNotEmpty(infoList)) {
|
||||
info = infoList.get(0);
|
||||
DisPhotovoltaic10Excel disPhotovoltaic10Excel = all10kVMap.get(userId).get(0);
|
||||
DistributionAreaExcel disPhotovoltaic10Excel = all10kVMap.get(userId).get(0);
|
||||
info = info.substring(info.indexOf(StrPool.COMMA) + 1);
|
||||
info = info.replaceAll(StrPool.AT, "||")
|
||||
.replaceAll("A_phsA", "A相电流")
|
||||
@@ -510,47 +609,89 @@ 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);
|
||||
}
|
||||
}
|
||||
EasyExcel.write("D:\\temp\\10kV部分没有数据的.xlsx", DisPhotovoltaic10Excel.class).sheet("10kV部分没有数据的").doWrite(final10kVUserData);
|
||||
EasyExcel.write("D:\\test\\唐山部分没有数据的.xlsx", DistributionAreaExcel.class).sheet("唐山部分没有数据的").doWrite(final10kVUserData);
|
||||
long millis2 = System.currentTimeMillis();
|
||||
System.out.println("10kV部分没有数据的:" + (millis2 - millis1));
|
||||
System.out.println("唐山部分没有数据的:" + (millis2 - millis1));
|
||||
|
||||
|
||||
//梳理380V全部没有数据的
|
||||
List<DisPhotovoltaic380Excel> collect4 = list380v.stream().filter(t -> noDataSet.contains(t.getGenerationUserID())).collect(Collectors.toList());
|
||||
EasyExcel.write("D:\\temp\\380V全部没有数据的.xlsx", DisPhotovoltaic380Excel.class).sheet("380V全部没有数据的").doWrite(collect4);
|
||||
List<ZhangDistributionAreaExcel> collect4 = listZhang.stream().filter(t -> noDataSet.contains(t.getPmsID())).collect(Collectors.toList());
|
||||
EasyExcel.write("D:\\test\\张家口全部没有数据的.xlsx", ZhangDistributionAreaExcel.class).sheet("张家口全部没有数据的").doWrite(collect4);
|
||||
long millis3 = System.currentTimeMillis();
|
||||
System.out.println("380V全部没有数据的:" + (millis3 - millis2));
|
||||
System.out.println("张家口全部没有数据的:" + (millis3 - millis2));
|
||||
//380V部分没有数据的
|
||||
Map<String, List<DisPhotovoltaic380Excel>> all380VMap = list380v.stream().collect(Collectors.groupingBy(DisPhotovoltaic380Excel::getGenerationUserID));
|
||||
Map<String, List<ZhangDistributionAreaExcel>> all380VMap = listZhang.stream().collect(Collectors.groupingBy(ZhangDistributionAreaExcel::getPmsID));
|
||||
Set<String> keyedSet = noPartDataMap.keySet();
|
||||
List<DisPhotovoltaic380Excel> final380VUserData = new LinkedList<>();
|
||||
List<DisPhotovoltaic380Excel> disPhotovoltaic380ExcelList;
|
||||
DisPhotovoltaic380Excel disPhotovoltaic380Excel;
|
||||
List<ZhangDistributionAreaExcel> final380VUserData = new LinkedList<>();
|
||||
List<ZhangDistributionAreaExcel> disPhotovoltaic380ExcelList;
|
||||
ZhangDistributionAreaExcel disPhotovoltaic380Excel;
|
||||
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<ZhangDistributionAreaExcel> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
EasyExcel.write("D:\\temp\\380V部分没有数据的.xlsx", DisPhotovoltaic380Excel.class).sheet("380V部分没有数据的").doWrite(final380VUserData);
|
||||
List<String> collect1 = final380VUserData.stream().map(ZhangDistributionAreaExcel::getId).collect(Collectors.toList());
|
||||
List<String> 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("380V部分没有数据的:" + (millis4 - millis3));
|
||||
System.out.println("张家口部分没有数据的:" + (millis4 - millis3));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
215
src/main/java/com/njcn/jbsyncdata/util/YwZtUtil.java
Normal file
215
src/main/java/com/njcn/jbsyncdata/util/YwZtUtil.java
Normal file
@@ -0,0 +1,215 @@
|
||||
package com.njcn.jbsyncdata.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.BusBarResult;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.IncomeAndOutgoLinesResult;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.LineDetail;
|
||||
import com.njcn.jbsyncdata.pojo.ywzt.LineDetailResult;
|
||||
import okhttp3.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class YwZtUtil {
|
||||
public static List<IncomeAndOutgoLinesResult.PsrInfo> inComeAndOutgo(String prsId, String cookie, String aMapToken) {
|
||||
List<IncomeAndOutgoLinesResult.PsrInfo> info = new ArrayList<>();
|
||||
String url = "http://dwyzt.jibei.sgcc.com.cn/amap-gateway-service/amap-app-service/graphicsExtension/station/intervals?psrId=" + prsId;
|
||||
// 创建HTTP客户端
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(600, TimeUnit.SECONDS)
|
||||
.readTimeout(600, TimeUnit.SECONDS)
|
||||
.writeTimeout(600, TimeUnit.SECONDS)
|
||||
.build();
|
||||
// 创建请求
|
||||
Request request = new Request.Builder().url(url).addHeader("Cookie", cookie).addHeader("amap-token", aMapToken).get().build();
|
||||
try {
|
||||
// 发送请求并获取响应
|
||||
Response response = client.newCall(request).execute();
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
String responseBody = response.body().string();
|
||||
System.out.println(responseBody);
|
||||
|
||||
// 解析JSON响应
|
||||
IncomeAndOutgoLinesResult incomeAndOutgoLinesResult = JSONObject.parseObject(responseBody, IncomeAndOutgoLinesResult.class);
|
||||
if(ObjectUtil.isNotNull(incomeAndOutgoLinesResult.getResult())){
|
||||
for (IncomeAndOutgoLinesResult.PsrInfo in : incomeAndOutgoLinesResult.getResult().getIncomeList()) {
|
||||
in.setType(1);
|
||||
in.setPsrSubId(prsId);
|
||||
info.add(in);
|
||||
}
|
||||
for (IncomeAndOutgoLinesResult.PsrInfo out : incomeAndOutgoLinesResult.getResult().getOutgoList()) {
|
||||
out.setType(0);
|
||||
out.setPsrSubId(prsId);
|
||||
info.add(out);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
} else {
|
||||
System.out.println("请求失败,响应码: " + response.code());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取母线
|
||||
*
|
||||
* @param prsId
|
||||
* @param containerType
|
||||
* @param psrType
|
||||
* @param cookie
|
||||
* @param aMapToken
|
||||
* @return
|
||||
*/
|
||||
public static List<BusBarResult.BusBar> busBar(String prsId, String containerType, String psrType, String cookie, String aMapToken) {
|
||||
{
|
||||
String url = "http://dwyzt.jibei.sgcc.com.cn/amap-gateway-service/amap-app-service/associateDevStat/associateDeviceDetail";
|
||||
|
||||
// 创建HTTP客户端
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(6000, TimeUnit.SECONDS)
|
||||
.readTimeout(6000, TimeUnit.SECONDS)
|
||||
.writeTimeout(6000, TimeUnit.SECONDS)
|
||||
.build();
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), "{\n" +
|
||||
" \"containerId\": \"" + prsId + "\",\n" +
|
||||
" \"containerType\": \"" + containerType + "\",\n" +
|
||||
" \"psrType\": \"" + psrType + "\",\n" +
|
||||
" \"name\": \"\",\n" +
|
||||
" \"pageNo\": 1,\n" +
|
||||
" \"pageSize\": 10\n" +
|
||||
"}");
|
||||
|
||||
|
||||
// 创建请求
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.addHeader("Cookie", cookie)
|
||||
.addHeader("amap-token", aMapToken)
|
||||
.post(body)
|
||||
.build();
|
||||
|
||||
try {
|
||||
// 发送请求并获取响应
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
String responseBody = response.body().string();
|
||||
System.out.println(responseBody);
|
||||
|
||||
// 解析JSON响应
|
||||
BusBarResult apiResponse = JSONObject.parseObject(responseBody, BusBarResult.class);
|
||||
List<BusBarResult.BusBar> records = apiResponse.getResult().getRecords();
|
||||
if(CollUtil.isNotEmpty(records)){
|
||||
records.forEach(x -> x.setPsrSubId(prsId));
|
||||
}
|
||||
return apiResponse.getResult().getRecords();
|
||||
|
||||
} else {
|
||||
System.out.println("请求失败,响应码: " + response.code());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public static LineDetail lineDetailSub(String prsId, String aMapToken) {
|
||||
{
|
||||
String url = "http://25.42.182.119:32010/EquipArchivesCBB/pgpcom-cmpt-equip-archives-server/equipment/archives/queryEquipmentArchives";
|
||||
|
||||
// 创建HTTP客户端
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(6000, TimeUnit.SECONDS)
|
||||
.readTimeout(6000, TimeUnit.SECONDS)
|
||||
.writeTimeout(6000, TimeUnit.SECONDS)
|
||||
.build();
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), "{\n" +
|
||||
" \"astId\": \"\",\n" +
|
||||
" \"psrId\": \""+prsId+"\",\n" +
|
||||
" \"psrType\": \"xl\",\n" +
|
||||
" \"distribution\": \"1\"\n" +
|
||||
" \n" +
|
||||
"}");
|
||||
|
||||
|
||||
// 创建请求
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.addHeader("cmpt-token", aMapToken)
|
||||
.post(body)
|
||||
.build();
|
||||
|
||||
try {
|
||||
// 发送请求并获取响应
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
String responseBody = response.body().string();
|
||||
System.out.println(responseBody);
|
||||
|
||||
// 解析JSON响应
|
||||
LineDetailResult apiResponse = JSONObject.parseObject(responseBody, LineDetailResult.class);
|
||||
|
||||
|
||||
LineDetail lineDetail=new LineDetail();
|
||||
LineDetailResult.ResultDTO result = apiResponse.getResult();
|
||||
if(ObjUtil.isNotNull(result)){
|
||||
//运行管理参数
|
||||
List<LineDetailResult.ResultDTO.EquipArchivesGroupListDTO> equipArchivesGroupListDTOList = result.getEquipArchivesGroupList().stream()
|
||||
.filter(x -> "1744555113406.84960".equals(x.getObjId()))
|
||||
.collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(equipArchivesGroupListDTOList)){
|
||||
LineDetailResult.ResultDTO.EquipArchivesGroupListDTO equipArchivesGroupListDTO = equipArchivesGroupListDTOList.get(0);
|
||||
//起终点参数
|
||||
List<LineDetailResult.ResultDTO.EquipArchivesGroupListDTO.SubEquipArchivesGroupListDTO> subEquipArchivesGroupList = equipArchivesGroupListDTO.getSubEquipArchivesGroupList().stream()
|
||||
.filter(x -> "8a868de396228fbe019622a59ea20155".equals(x.getObjId()))
|
||||
.collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(subEquipArchivesGroupList)){
|
||||
lineDetail.setPsrId(prsId);
|
||||
List<LineDetailResult.ResultDTO.EquipArchivesGroupListDTO.SubEquipArchivesGroupListDTO.EquipArchivesFieldListDTO> startSub = subEquipArchivesGroupList.get(0).getEquipArchivesFieldList().stream()
|
||||
.filter(x -> "4e7a254cdb664239ac8134e6f8321929".equals(x.getObjId()))
|
||||
.collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(startSub)){
|
||||
if(StrUtil.isNotBlank(startSub.get(0).getFieldValue())){
|
||||
lineDetail.setPsrSubStartId(startSub.get(0).getFieldValue());
|
||||
lineDetail.setPsrSubStartName(startSub.get(0).getFieldEscapeValue());
|
||||
}
|
||||
|
||||
}
|
||||
List<LineDetailResult.ResultDTO.EquipArchivesGroupListDTO.SubEquipArchivesGroupListDTO.EquipArchivesFieldListDTO> endSub = subEquipArchivesGroupList.get(0).getEquipArchivesFieldList().stream()
|
||||
.filter(x -> "e507be02993446389f7dff237362126c".equals(x.getObjId()))
|
||||
.collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(endSub)){
|
||||
if(StrUtil.isNotBlank(endSub.get(0).getFieldValue())){
|
||||
lineDetail.setPsrSubEndId(endSub.get(0).getFieldValue());
|
||||
lineDetail.setPsrSubEndName(endSub.get(0).getFieldEscapeValue());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return lineDetail;
|
||||
} else {
|
||||
System.out.println("请求失败,响应码: " + response.code());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 10288
|
||||
port: 10299
|
||||
tomcat:
|
||||
max-swallow-size: 100MB #重要的一行,修改tomcat的吞吐量
|
||||
spring:
|
||||
@@ -9,12 +9,15 @@ spring:
|
||||
datasource:
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://10.118.135.128:13306/pqsinfo_pms_jb?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT&rewriteBatchedStatements=true
|
||||
url: jdbc:mysql://10.118.135.128:13306/pqsinfo_pms_jb?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT&rewriteBatchedStatements=true
|
||||
username: pqsadmin
|
||||
password: '@#Pqsadmin123'
|
||||
# url: jdbc:mysql://192.168.1.18:13306/pqsinfo_pms_jb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||
# username: root
|
||||
# password: njcnpqs
|
||||
url: jdbc:mysql://101.132.73.63:13306/pqsinfo_pms_jb?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||
username: root
|
||||
password: '*#Bg20230711'
|
||||
# url: jdbc:mysql://localhost:3306/info?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||
# username: root
|
||||
# password: root
|
||||
#初始化建立物理连接的个数、最小、最大连接数
|
||||
initial-size: 5
|
||||
min-idle: 5
|
||||
@@ -43,8 +46,8 @@ spring:
|
||||
enabled: true
|
||||
influx:
|
||||
url: http://10.118.135.129:8086
|
||||
user: admin
|
||||
password: 123456
|
||||
user: pqsadmin
|
||||
password: '@#Pqsadmin123'
|
||||
database: pqsbase
|
||||
mapper-location: com.njcn.jbsyncdata.imapper
|
||||
|
||||
@@ -71,4 +74,14 @@ jibei:
|
||||
client_id: bad079495dc111ee987b0a580a080620
|
||||
client_secret: OxXIgFs9HHI05L3cOg8ogYoFRFs8sKlTJhVocyOprxoWSadcX0we2wffjyTUYGsK
|
||||
grant_type: credentials
|
||||
url: http://25.42.182.119:32001
|
||||
url: http://25.42.182.119:32001
|
||||
|
||||
#线程池配置信息
|
||||
microservice:
|
||||
ename: async
|
||||
|
||||
threadPool:
|
||||
corePoolSize: 12
|
||||
maxPoolSize: 24
|
||||
queueCapacity: 500
|
||||
keepAliveSeconds: 60
|
||||
Reference in New Issue
Block a user