河北数据台账信息导入和日报表数据导入代码提交
This commit is contained in:
@@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
@@ -13,6 +14,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@MapperScan("com.njcn.**.mapper")
|
@MapperScan("com.njcn.**.mapper")
|
||||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||||
|
@EnableScheduling
|
||||||
public class HBSyncDataApplication {
|
public class HBSyncDataApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(HBSyncDataApplication.class, args);
|
SpringApplication.run(HBSyncDataApplication.class, args);
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
package com.njcn.syncdata.controller;
|
package com.njcn.syncdata.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.njcn.syncdata.pojo.po.*;
|
import com.njcn.syncdata.pojo.po.*;
|
||||||
import com.njcn.syncdata.service.IPowerDistributionareaService;
|
import com.njcn.syncdata.service.IPowerDistributionareaService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -37,12 +41,39 @@ public class DataImportController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/getAdsList")
|
@GetMapping("/getAdsList")
|
||||||
public List<AdsAstXbjcptGetFctgDi> adsList() {
|
public List<AdsAstXbjcptGetFctgDi> adsList() {
|
||||||
return service.adsList();
|
List<AdsAstXbjcptGetFctgDi> info = new ArrayList<>();
|
||||||
|
//定义初始页数
|
||||||
|
Integer num = 0;
|
||||||
|
//定义每页返回数据条数
|
||||||
|
Integer size = 30000;
|
||||||
|
while (true) {
|
||||||
|
log.info(Thread.currentThread().getName() + "2.数据查询 循环了:" + num + 1 + "次。结束----!");
|
||||||
|
List<AdsAstXbjcptGetFctgDi> adsList = service.adsList(size, num * size);
|
||||||
|
info.addAll(adsList);
|
||||||
|
log.info(Thread.currentThread().getName() + "2.数据查询 循环数据多少条:" + info + "结束----!");
|
||||||
|
if (adsList.size() < size) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info(Thread.currentThread().getName() + "2.数据查询 AdsAstXbjcptGetFctgDi:" + info + "结束----!");
|
||||||
|
log.info(Thread.currentThread().getName() + "3.数据查询多少条 info:" + info.size() + "结束----!");
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取中台日报表数据
|
||||||
|
*
|
||||||
|
* @param ds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping("/adsDiList")
|
@GetMapping("/adsDiList")
|
||||||
public List<AdsAstXbjcptGetFctgValueDi> adsDiList(String ds) {
|
public List<AdsAstXbjcptGetFctgValueDi> adsDiList(String ds) {
|
||||||
return service.adsDiList(ds);
|
return service.adsDiList(ds,300,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,9 +126,23 @@ public class DataImportController {
|
|||||||
String s = service.insertData();
|
String s = service.insertData();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/insertDataDi")
|
@PostMapping("/insertDataDi")
|
||||||
public String insertDataDi(String ds) {
|
public String insertDataDi(String ds) {
|
||||||
String s = service.insertDataDi(ds);
|
String s = service.insertDataDi(ds);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 30 17 * * ?")
|
||||||
|
public void insert() {
|
||||||
|
log.info(Thread.currentThread().getName() + "1.定时器启动----!");
|
||||||
|
DateTime dateTime = DateUtil.offsetDay(new Date(), -3);
|
||||||
|
String s=dateTime.toString();
|
||||||
|
String ds = s.substring(0, s.indexOf(" ")).replace("-","");
|
||||||
|
log.info(Thread.currentThread().getName() + "2.定时器执行数据日期 "+ds+"----!");
|
||||||
|
service.insertDataDi(ds);
|
||||||
|
log.info(Thread.currentThread().getName() + "2.定时器执行数据成功 "+ds+"----!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -86,6 +86,11 @@ public class PowerDistributionarea {
|
|||||||
*/
|
*/
|
||||||
private String regionalism;
|
private String regionalism;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备地区特征
|
||||||
|
*/
|
||||||
|
private String devRegionalism;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否农网:0-否;1:是;
|
* 是否农网:0-否;1:是;
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ public interface IPowerDistributionareaService extends IReplenishMybatisService<
|
|||||||
* 获取数据中台数据
|
* 获取数据中台数据
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<AdsAstXbjcptGetFctgDi> adsList();
|
List<AdsAstXbjcptGetFctgDi> adsList(Integer limitValue,Integer offsetValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取日报表数据
|
* 获取日报表数据
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<AdsAstXbjcptGetFctgValueDi> adsDiList(String ds);
|
List<AdsAstXbjcptGetFctgValueDi> adsDiList(String ds,Integer limitValue,Integer offsetValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用资源数据中台数据查询
|
* 通用资源数据中台数据查询
|
||||||
@@ -49,4 +49,5 @@ public interface IPowerDistributionareaService extends IReplenishMybatisService<
|
|||||||
String insertData();
|
String insertData();
|
||||||
|
|
||||||
String insertDataDi(String ds);
|
String insertDataDi(String ds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.njcn.syncdata.pojo.enums.DicDataEnum;
|
|||||||
import com.njcn.syncdata.pojo.enums.DicDataTypeEnum;
|
import com.njcn.syncdata.pojo.enums.DicDataTypeEnum;
|
||||||
import com.njcn.syncdata.pojo.po.*;
|
import com.njcn.syncdata.pojo.po.*;
|
||||||
import com.njcn.syncdata.service.IPowerDistributionareaService;
|
import com.njcn.syncdata.service.IPowerDistributionareaService;
|
||||||
|
import com.njcn.syncdata.service.IRDisMpMeasurePhaseReportDService;
|
||||||
import com.njcn.syncdata.utils.RestTemplateUtil;
|
import com.njcn.syncdata.utils.RestTemplateUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -59,7 +60,7 @@ import java.util.stream.Collectors;
|
|||||||
public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImpl<PowerDistributionareaMapper, PowerDistributionarea> implements IPowerDistributionareaService {
|
public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImpl<PowerDistributionareaMapper, PowerDistributionarea> implements IPowerDistributionareaService {
|
||||||
|
|
||||||
private final DictDataMapper dictDataMapper;
|
private final DictDataMapper dictDataMapper;
|
||||||
|
private final IRDisMpMeasurePhaseReportDService irDisMpMeasurePhaseReportDService;
|
||||||
@Override
|
@Override
|
||||||
public String LoginToken() {
|
public String LoginToken() {
|
||||||
String token = null;
|
String token = null;
|
||||||
@@ -89,7 +90,7 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AdsAstXbjcptGetFctgDi> adsList() {
|
public List<AdsAstXbjcptGetFctgDi> adsList(Integer limitValue,Integer offsetValue) {
|
||||||
List<AdsAstXbjcptGetFctgDi> aas = new ArrayList<>();
|
List<AdsAstXbjcptGetFctgDi> aas = new ArrayList<>();
|
||||||
String key = "0e3bac160fd246f181ad4fd47da6929a";
|
String key = "0e3bac160fd246f181ad4fd47da6929a";
|
||||||
String secret = "383b4b2536234d84ac909cd605762061";
|
String secret = "383b4b2536234d84ac909cd605762061";
|
||||||
@@ -108,9 +109,11 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
//API中 header头传输的参数
|
//API中 header头传输的参数
|
||||||
request.addHeader("x-api-id", apiId);
|
request.addHeader("x-api-id", apiId);
|
||||||
request.addHeader("Content-Type", "Application/json");
|
// request.addHeader("Content-Type", "Application/json");
|
||||||
//API中 Query传输的参数
|
//API中 Query传输的参数
|
||||||
//request.addQueryStringParam("name", "value");
|
request.addQueryStringParam("fcgc_a", limitValue.toString());
|
||||||
|
request.addQueryStringParam("fcgc_b", offsetValue.toString());
|
||||||
|
log.info(Thread.currentThread().getName() + "链接 a:" + limitValue+", b:" +offsetValue+ "失败");
|
||||||
//API中 Body体参数
|
//API中 Body体参数
|
||||||
//request.setBody("demo");
|
//request.setBody("demo");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -141,8 +144,14 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
String s = EntityUtils.toString(resEntity, "UTF-8");
|
String s = EntityUtils.toString(resEntity, "UTF-8");
|
||||||
log.info(System.getProperty("line.separator") + s);
|
log.info(System.getProperty("line.separator") + s);
|
||||||
JSONObject jsonObject = JSON.parseObject(s);
|
JSONObject jsonObject = JSON.parseObject(s);
|
||||||
|
String errCode = jsonObject.getString("errCode");
|
||||||
|
if(StrUtil.isBlank(errCode)){
|
||||||
Map data = jsonObject.getObject("data", Map.class);
|
Map data = jsonObject.getObject("data", Map.class);
|
||||||
aas = JSONArray.parseArray(data.get("data").toString(), AdsAstXbjcptGetFctgDi.class);
|
aas = JSONArray.parseArray(data.get("data").toString(), AdsAstXbjcptGetFctgDi.class);
|
||||||
|
}else if("DLM.4094".equals(errCode)){
|
||||||
|
log.info(Thread.currentThread().getName() + "数据链接超时" + s + "结束----!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(Thread.currentThread().getName() + "链接" + apiName + "失败");
|
log.error(Thread.currentThread().getName() + "链接" + apiName + "失败");
|
||||||
@@ -160,7 +169,7 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AdsAstXbjcptGetFctgValueDi> adsDiList(String ds) {
|
public List<AdsAstXbjcptGetFctgValueDi> adsDiList(String ds,Integer limitValue,Integer offsetValue) {
|
||||||
List<AdsAstXbjcptGetFctgValueDi> aas = new ArrayList<>();
|
List<AdsAstXbjcptGetFctgValueDi> aas = new ArrayList<>();
|
||||||
String key = "0e3bac160fd246f181ad4fd47da6929a";
|
String key = "0e3bac160fd246f181ad4fd47da6929a";
|
||||||
String secret = "383b4b2536234d84ac909cd605762061";
|
String secret = "383b4b2536234d84ac909cd605762061";
|
||||||
@@ -179,9 +188,10 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
//API中 header头传输的参数
|
//API中 header头传输的参数
|
||||||
request.addHeader("x-api-id", apiId);
|
request.addHeader("x-api-id", apiId);
|
||||||
request.addHeader("Content-Type", "Application/json");
|
|
||||||
//API中 Query传输的参数
|
//API中 Query传输的参数
|
||||||
request.addQueryStringParam("ds", ds);
|
request.addQueryStringParam("ds", ds);
|
||||||
|
request.addQueryStringParam("fcgc_va", limitValue.toString());
|
||||||
|
request.addQueryStringParam("fcgc_vb", offsetValue.toString());
|
||||||
//API中 Body体参数
|
//API中 Body体参数
|
||||||
//request.setBody("demo");
|
//request.setBody("demo");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -212,8 +222,15 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
String s = EntityUtils.toString(resEntity, "UTF-8");
|
String s = EntityUtils.toString(resEntity, "UTF-8");
|
||||||
log.info(System.getProperty("line.separator") + s);
|
log.info(System.getProperty("line.separator") + s);
|
||||||
JSONObject jsonObject = JSON.parseObject(s);
|
JSONObject jsonObject = JSON.parseObject(s);
|
||||||
|
String errCode = jsonObject.getString("errCode");
|
||||||
|
if(StrUtil.isBlank(errCode)){
|
||||||
Map data = jsonObject.getObject("data", Map.class);
|
Map data = jsonObject.getObject("data", Map.class);
|
||||||
aas = JSONArray.parseArray(data.get("data").toString(), AdsAstXbjcptGetFctgValueDi.class);
|
aas = JSONArray.parseArray(data.get("data").toString(), AdsAstXbjcptGetFctgValueDi.class);
|
||||||
|
log.info(Thread.currentThread().getName() + "获取日报表数据多少条 adsDiList:" + aas.size() + "结束----!");
|
||||||
|
}else if("DLM.4094".equals(errCode)){
|
||||||
|
log.info(Thread.currentThread().getName() + "数据链接超时" + s + "结束----!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(Thread.currentThread().getName() + "链接" + apiName + "失败");
|
log.error(Thread.currentThread().getName() + "链接" + apiName + "失败");
|
||||||
@@ -276,8 +293,19 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
//1.获取数据台账信息
|
//1.获取数据台账信息
|
||||||
|
|
||||||
//获取数据中台数据
|
//获取数据中台数据
|
||||||
List<AdsAstXbjcptGetFctgDi> aas = adsList();
|
List<AdsAstXbjcptGetFctgDi> aas=new ArrayList<>();
|
||||||
|
Integer numPum = 0;
|
||||||
|
//定义每页返回数据条数
|
||||||
|
Integer size = 20000;
|
||||||
|
while (true) {
|
||||||
|
List<AdsAstXbjcptGetFctgDi> adsList = adsList(size, numPum * size);
|
||||||
|
aas.addAll(adsList);
|
||||||
|
if (adsList.size() < size) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
numPum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
Assert.isTrue(CollUtil.isNotEmpty(aas), "获取中台数据为空!");
|
Assert.isTrue(CollUtil.isNotEmpty(aas), "获取中台数据为空!");
|
||||||
//进行数据拆分查询
|
//进行数据拆分查询
|
||||||
ArrayList<AdsAstXbjcptGetFctgDi> dome = aas.stream().collect(Collectors.collectingAndThen(
|
ArrayList<AdsAstXbjcptGetFctgDi> dome = aas.stream().collect(Collectors.collectingAndThen(
|
||||||
@@ -379,7 +407,7 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
//todo 要做处理(处理)
|
//todo 要做处理(处理)
|
||||||
area.setVoltageLevel(getAlgoDescribe(pwopTransformerPSR.getVOLTAGELEVEL_ID(), devVoltage));
|
area.setVoltageLevel(getAlgoDescribe(pwopTransformerPSR.getVOLTAGELEVEL_ID(), devVoltage));
|
||||||
//todo 要做处理(处理)
|
//todo 要做处理(处理)
|
||||||
area.setRegionalism(getAlgoDescribe(pwopTransformerPSR.getREGION_TYPE(), regional));
|
area.setDevRegionalism(getAlgoDescribe(pwopTransformerPSR.getREGION_TYPE(), regional));
|
||||||
//todo 要做处理(处理)
|
//todo 要做处理(处理)
|
||||||
area.setNatureOfUse(getAlgoDescribe(pwopTransformerPSR.getUse_nature(), userNature));
|
area.setNatureOfUse(getAlgoDescribe(pwopTransformerPSR.getUse_nature(), userNature));
|
||||||
//判断数据是否为空
|
//判断数据是否为空
|
||||||
@@ -399,7 +427,7 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
area.setDistributedPhotovoltaicNum(fctgDi.getFc_num());
|
area.setDistributedPhotovoltaicNum(fctgDi.getFc_num());
|
||||||
area.setPhotovoltaicCapacity(fctgDi.getFc_sum_cap().floatValue());
|
area.setPhotovoltaicCapacity(fctgDi.getFc_sum_cap().floatValue());
|
||||||
area.setIfBevAp(0);
|
area.setIfBevAp(0);
|
||||||
area.setApLoadType(photovoltaics.getId());
|
area.setApLoadType("分布式光伏");
|
||||||
area.setIsUpToGrid(1);
|
area.setIsUpToGrid(1);
|
||||||
area.setStatus(1);
|
area.setStatus(1);
|
||||||
area.setCreateTime(LocalDateTime.now());
|
area.setCreateTime(LocalDateTime.now());
|
||||||
@@ -436,19 +464,55 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
@Override
|
@Override
|
||||||
public String insertDataDi(String ds) {
|
public String insertDataDi(String ds) {
|
||||||
List<RDisMpMeasurePhaseReportD> info=new ArrayList<>();
|
List<RDisMpMeasurePhaseReportD> info=new ArrayList<>();
|
||||||
//查询日报表数据
|
|
||||||
List<AdsAstXbjcptGetFctgValueDi> adsDis = adsDiList(ds);
|
|
||||||
List<PowerDistributionarea> list = this.list(new QueryWrapper<PowerDistributionarea>()
|
List<PowerDistributionarea> list = this.list(new QueryWrapper<PowerDistributionarea>()
|
||||||
.select("Id")
|
.select("Id")
|
||||||
.eq("input_Status", 1)
|
.eq("input_Status", 1)
|
||||||
.eq("Status", 1));
|
.eq("Status", 1));
|
||||||
//获取台区id
|
//获取台区id
|
||||||
List<String> tgId = list.stream().map(PowerDistributionarea::getId).collect(Collectors.toList());
|
List<String> tgId = list.stream().map(PowerDistributionarea::getId).distinct().collect(Collectors.toList());
|
||||||
|
log.info(Thread.currentThread().getName() + "1.数据添加 tgId:" + tgId.size() + "结束----!");
|
||||||
|
if(CollUtil.isEmpty(tgId)){
|
||||||
|
return "日报表数据导入失败!当前台区编号为空。";
|
||||||
|
}
|
||||||
|
//查询日报表数据
|
||||||
|
List<AdsAstXbjcptGetFctgValueDi> adsDis = new ArrayList<>();
|
||||||
|
|
||||||
|
//分片集合
|
||||||
|
List<AdsAstXbjcptGetFctgValueDi> dis;
|
||||||
|
List<AdsAstXbjcptGetFctgValueDi> tgList;
|
||||||
|
Integer num = 0;
|
||||||
|
//定义每页返回数据条数
|
||||||
|
Integer size = 20000;
|
||||||
|
while (true) {
|
||||||
|
dis = adsDiList(ds, size, num * size);
|
||||||
|
if(CollUtil.isNotEmpty(dis)){
|
||||||
|
//剔除不存在的台区信息
|
||||||
|
tgList = dis.stream().filter(x -> tgId.contains(x.getTg_id())).collect(Collectors.toList());
|
||||||
|
if(CollUtil.isNotEmpty(tgList)){
|
||||||
|
log.info(Thread.currentThread().getName() + "1.数据添加 tgList:" + tgList.size() + "结束----!");
|
||||||
|
adsDis.addAll(tgList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(dis)||dis.size() < size) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(Thread.currentThread().getName() + "2.数据添加 adsDis:" + adsDis.size() + "结束----!");
|
||||||
|
JSONArray objects = new JSONArray(Collections.singletonList(adsDis));
|
||||||
|
log.info(Thread.currentThread().getName() + "2.数据添加信息 adsDis:" + objects + "结束----!");
|
||||||
DateTime parse = DateUtil.parse(ds, "yyyyMMdd");
|
DateTime parse = DateUtil.parse(ds, "yyyyMMdd");
|
||||||
LocalDateTime localDateTime = LocalDateTime.ofInstant(parse.toInstant(), ZoneId.systemDefault());
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(parse.toInstant(), ZoneId.systemDefault());
|
||||||
|
|
||||||
Map<String, List<AdsAstXbjcptGetFctgValueDi>> adsMap = adsDis.stream().collect(Collectors.groupingBy(AdsAstXbjcptGetFctgValueDi::getTg_id));
|
Map<String, List<AdsAstXbjcptGetFctgValueDi>> adsMap = adsDis.stream().collect(Collectors.groupingBy(AdsAstXbjcptGetFctgValueDi::getTg_id));
|
||||||
|
|
||||||
|
|
||||||
|
OptionalDouble max,min,avg,maxP,minP,avgP,maxQ,minQ,avgQ,max715,max15,maxDown,maxNeg;
|
||||||
|
BigDecimal add,addP,addQ,divide,divideP,divideQ;
|
||||||
for (Map.Entry<String, List<AdsAstXbjcptGetFctgValueDi>> stringListEntry : adsMap.entrySet()) {
|
for (Map.Entry<String, List<AdsAstXbjcptGetFctgValueDi>> stringListEntry : adsMap.entrySet()) {
|
||||||
String key = stringListEntry.getKey();
|
String key = stringListEntry.getKey();
|
||||||
if(!tgId.contains(key)){
|
if(!tgId.contains(key)){
|
||||||
@@ -462,7 +526,7 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
reportD.setDatdate(localDateTime);
|
reportD.setDatdate(localDateTime);
|
||||||
reportD.setMonitoringDuration(24);
|
reportD.setMonitoringDuration(24);
|
||||||
//max_u
|
//max_u
|
||||||
OptionalDouble max = value.stream().filter(x->ObjectUtil.isNotNull(x.getMax_u())).mapToDouble(temp -> {
|
max = value.stream().filter(x->ObjectUtil.isNotNull(x.getMax_u())).mapToDouble(temp -> {
|
||||||
return temp.getMax_u().doubleValue();
|
return temp.getMax_u().doubleValue();
|
||||||
}).max();
|
}).max();
|
||||||
if(!max.isPresent()){
|
if(!max.isPresent()){
|
||||||
@@ -470,23 +534,23 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
}
|
}
|
||||||
|
|
||||||
//min_u
|
//min_u
|
||||||
OptionalDouble min = value.stream().filter(x->ObjectUtil.isNotNull(x.getMin_u())).mapToDouble(temp -> {
|
min = value.stream().filter(x->ObjectUtil.isNotNull(x.getMin_u())).mapToDouble(temp -> {
|
||||||
return temp.getMin_u().doubleValue();
|
return temp.getMin_u().doubleValue();
|
||||||
}).min();
|
}).min();
|
||||||
if(!min.isPresent()){
|
if(!min.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//avg_u
|
//avg_u
|
||||||
OptionalDouble avg = value.stream().filter(x->ObjectUtil.isNotNull(x.getAvg_u())).mapToDouble(temp -> {
|
avg = value.stream().filter(x->ObjectUtil.isNotNull(x.getAvg_u())).mapToDouble(temp -> {
|
||||||
return temp.getAvg_u().doubleValue();
|
return temp.getAvg_u().doubleValue();
|
||||||
}).average();
|
}).average();
|
||||||
if(!avg.isPresent()){
|
if(!avg.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//95
|
//95
|
||||||
BigDecimal add = new BigDecimal(max.getAsDouble()).add(new BigDecimal(avg.getAsDouble()));
|
add = new BigDecimal(max.getAsDouble()).add(new BigDecimal(avg.getAsDouble()));
|
||||||
if(add.floatValue()!=0){
|
if(add.floatValue()!=0){
|
||||||
BigDecimal divide = add.divide(new BigDecimal(2), 4, BigDecimal.ROUND_UP);
|
divide = add.divide(new BigDecimal(2), 4, BigDecimal.ROUND_UP);
|
||||||
reportD.setPhaseVoltageEffective95(divide.floatValue());
|
reportD.setPhaseVoltageEffective95(divide.floatValue());
|
||||||
}else{
|
}else{
|
||||||
reportD.setSpActivePower_95(0.0f);
|
reportD.setSpActivePower_95(0.0f);
|
||||||
@@ -496,31 +560,31 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
reportD.setPhaseVoltageEffectiveAvg((float) avg.getAsDouble());
|
reportD.setPhaseVoltageEffectiveAvg((float) avg.getAsDouble());
|
||||||
//---------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------
|
||||||
//max_u
|
//max_u
|
||||||
OptionalDouble maxP = value.stream().filter(x->ObjectUtil.isNotNull(x.getMax_p())).mapToDouble(temp -> {
|
maxP = value.stream().filter(x->ObjectUtil.isNotNull(x.getMax_p())).mapToDouble(temp -> {
|
||||||
return temp.getMax_p().doubleValue();
|
return temp.getMax_p().doubleValue();
|
||||||
}).max();
|
}).max();
|
||||||
if(!maxP.isPresent()){
|
if(!maxP.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//min_u
|
//min_u
|
||||||
OptionalDouble minP = value.stream().filter(x->ObjectUtil.isNotNull(x.getMin_p())).mapToDouble(temp -> {
|
minP = value.stream().filter(x->ObjectUtil.isNotNull(x.getMin_p())).mapToDouble(temp -> {
|
||||||
return temp.getMin_p().doubleValue();
|
return temp.getMin_p().doubleValue();
|
||||||
}).min();
|
}).min();
|
||||||
if(!minP.isPresent()){
|
if(!minP.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//avg_u
|
//avg_u
|
||||||
OptionalDouble avgP = value.stream().filter(x->ObjectUtil.isNotNull(x.getAvg_p())).mapToDouble(temp -> {
|
avgP = value.stream().filter(x->ObjectUtil.isNotNull(x.getAvg_p())).mapToDouble(temp -> {
|
||||||
return temp.getAvg_p().doubleValue();
|
return temp.getAvg_p().doubleValue();
|
||||||
}).average();
|
}).average();
|
||||||
if(!avgP.isPresent()){
|
if(!avgP.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//95
|
//95
|
||||||
BigDecimal addP = new BigDecimal(maxP.getAsDouble()).add(new BigDecimal(avgP.getAsDouble()));
|
addP = new BigDecimal(maxP.getAsDouble()).add(new BigDecimal(avgP.getAsDouble()));
|
||||||
if(addP.floatValue()!=0){
|
if(addP.floatValue()!=0){
|
||||||
BigDecimal divide = addP.divide(new BigDecimal(2), 4, BigDecimal.ROUND_UP);
|
divideP = addP.divide(new BigDecimal(2), 4, BigDecimal.ROUND_UP);
|
||||||
reportD.setSpActivePower_95(divide.floatValue());
|
reportD.setSpActivePower_95(divideP.floatValue());
|
||||||
}else{
|
}else{
|
||||||
reportD.setSpActivePower_95(0.0f);
|
reportD.setSpActivePower_95(0.0f);
|
||||||
}
|
}
|
||||||
@@ -529,31 +593,31 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
reportD.setSpActivePowerAvg((float) avgP.getAsDouble());
|
reportD.setSpActivePowerAvg((float) avgP.getAsDouble());
|
||||||
//---------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------
|
||||||
//max_Q
|
//max_Q
|
||||||
OptionalDouble maxQ = value.stream().filter(x->ObjectUtil.isNotNull(x.getMax_q())).mapToDouble(temp -> {
|
maxQ = value.stream().filter(x->ObjectUtil.isNotNull(x.getMax_q())).mapToDouble(temp -> {
|
||||||
return temp.getMax_q().doubleValue();
|
return temp.getMax_q().doubleValue();
|
||||||
}).max();
|
}).max();
|
||||||
if(!maxQ.isPresent()){
|
if(!maxQ.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//min_Q
|
//min_Q
|
||||||
OptionalDouble minQ = value.stream().filter(x->ObjectUtil.isNotNull(x.getMin_q())).mapToDouble(temp -> {
|
minQ = value.stream().filter(x->ObjectUtil.isNotNull(x.getMin_q())).mapToDouble(temp -> {
|
||||||
return temp.getMin_q().doubleValue();
|
return temp.getMin_q().doubleValue();
|
||||||
}).min();
|
}).min();
|
||||||
if(!minQ.isPresent()){
|
if(!minQ.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//avg_u
|
//avg_u
|
||||||
OptionalDouble avgQ = value.stream().filter(x->ObjectUtil.isNotNull(x.getAvg_q())).mapToDouble(temp -> {
|
avgQ = value.stream().filter(x->ObjectUtil.isNotNull(x.getAvg_q())).mapToDouble(temp -> {
|
||||||
return temp.getAvg_q().doubleValue();
|
return temp.getAvg_q().doubleValue();
|
||||||
}).average();
|
}).average();
|
||||||
if(!avgQ.isPresent()){
|
if(!avgQ.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//95
|
//95
|
||||||
BigDecimal addQ = new BigDecimal(maxQ.getAsDouble()).add(new BigDecimal(avgQ.getAsDouble()));
|
addQ = new BigDecimal(maxQ.getAsDouble()).add(new BigDecimal(avgQ.getAsDouble()));
|
||||||
if(addQ.floatValue()!=0){
|
if(addQ.floatValue()!=0){
|
||||||
BigDecimal divide = addQ.divide(new BigDecimal(2), 4, BigDecimal.ROUND_UP);
|
divideQ = addQ.divide(new BigDecimal(2), 4, BigDecimal.ROUND_UP);
|
||||||
reportD.setSpApparentPower95(divide.floatValue());
|
reportD.setSpApparentPower95(divideQ.floatValue());
|
||||||
}else{
|
}else{
|
||||||
reportD.setSpApparentPower95(0.0f);
|
reportD.setSpApparentPower95(0.0f);
|
||||||
}
|
}
|
||||||
@@ -564,25 +628,25 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------
|
||||||
//max_Q
|
//max_Q
|
||||||
OptionalDouble max715 = value.stream().filter(x->ObjectUtil.isNotNull(x.getUp7_over_time())).mapToDouble(temp -> {
|
max715 = value.stream().filter(x->ObjectUtil.isNotNull(x.getUp7_over_time())).mapToDouble(temp -> {
|
||||||
return temp.getUp7_over_time().doubleValue();
|
return temp.getUp7_over_time().doubleValue();
|
||||||
}).max();
|
}).max();
|
||||||
if(!max715.isPresent()){
|
if(!max715.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
OptionalDouble max15 = value.stream().filter(x->ObjectUtil.isNotNull(x.getUp15_over_time())).mapToDouble(temp -> {
|
max15 = value.stream().filter(x->ObjectUtil.isNotNull(x.getUp15_over_time())).mapToDouble(temp -> {
|
||||||
return temp.getUp15_over_time().doubleValue();
|
return temp.getUp15_over_time().doubleValue();
|
||||||
}).max();
|
}).max();
|
||||||
if(!max15.isPresent()){
|
if(!max15.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
OptionalDouble maxDown = value.stream().filter(x->ObjectUtil.isNotNull(x.getDown_over_time())).mapToDouble(temp -> {
|
maxDown = value.stream().filter(x->ObjectUtil.isNotNull(x.getDown_over_time())).mapToDouble(temp -> {
|
||||||
return temp.getDown_over_time().doubleValue();
|
return temp.getDown_over_time().doubleValue();
|
||||||
}).max();
|
}).max();
|
||||||
if(!maxDown.isPresent()){
|
if(!maxDown.isPresent()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
OptionalDouble maxNeg = value.stream().filter(x->ObjectUtil.isNotNull(x.getNeg_p_time())).mapToDouble(temp -> {
|
maxNeg = value.stream().filter(x->ObjectUtil.isNotNull(x.getNeg_p_time())).mapToDouble(temp -> {
|
||||||
return temp.getNeg_p_time().doubleValue();
|
return temp.getNeg_p_time().doubleValue();
|
||||||
}).max();
|
}).max();
|
||||||
if(!maxNeg.isPresent()){
|
if(!maxNeg.isPresent()){
|
||||||
@@ -596,8 +660,16 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
reportD.setPracticalTargetNum(96);
|
reportD.setPracticalTargetNum(96);
|
||||||
info.add(reportD);
|
info.add(reportD);
|
||||||
}
|
}
|
||||||
|
log.info(Thread.currentThread().getName() + "1.数据添加 info:" + info.size() + "结束----!");
|
||||||
|
if(CollUtil.isNotEmpty(info)){
|
||||||
|
LambdaQueryWrapper<RDisMpMeasurePhaseReportD> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(RDisMpMeasurePhaseReportD::getDatdate, ds);
|
||||||
|
irDisMpMeasurePhaseReportDService.remove(lambdaQueryWrapper);
|
||||||
|
irDisMpMeasurePhaseReportDService.insertBatchBySlice(info,1000);
|
||||||
|
}
|
||||||
return "日报表数据导入成功";
|
return "日报表数据导入成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> List<T> resourceMethod(Integer a, String token, Integer num, String ids, Class<T> t) {
|
public <T> List<T> resourceMethod(Integer a, String token, Integer num, String ids, Class<T> t) {
|
||||||
List<T> aas = new ArrayList<>();
|
List<T> aas = new ArrayList<>();
|
||||||
switch (a) {
|
switch (a) {
|
||||||
@@ -883,7 +955,8 @@ public class PowerDistributionareaServiceImpl extends ReplenishMybatisServiceImp
|
|||||||
reportD.setFlowBackflowOverloadLoadrateMin(0.0F);
|
reportD.setFlowBackflowOverloadLoadrateMin(0.0F);
|
||||||
reportD.setFlowBackflowOverloadLoadrateAvg(0.0F);
|
reportD.setFlowBackflowOverloadLoadrateAvg(0.0F);
|
||||||
reportD.setFlowBackflowOverloadLoadrate95(0.0F);
|
reportD.setFlowBackflowOverloadLoadrate95(0.0F);
|
||||||
reportD.setHarmonicVoltageOverrunDuration(0);
|
reportD.setHarmonicVoltageOverrunDuration(0.0F);
|
||||||
reportD.setTpVoltageUnbalanceOverrunDuration(0);
|
reportD.setTpVoltageUnbalanceOverrunDuration(0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user