This commit is contained in:
2023-10-13 14:46:47 +08:00
parent a0109b0967
commit 5f7ccf837b
7 changed files with 38 additions and 39 deletions

View File

@@ -37,38 +37,10 @@ public class DisPhotovoltaicController {
private final IBusinessService businessService;
private final DisPhotovoltaicService disPhotovoltaicService;
@ApiOperation(value = "获取10kv分布式光伏接入情况")
@PostMapping("/import10")
public void importTakeOrder(MultipartFile file, String startTime, String endTime) throws Exception {
List<ExcelData> list = EasyExcel.read(file.getInputStream())
.head(ExcelData.class)
.headRowNumber(2)
.sheet(2).doReadSync();
//排重
list = list.stream()
.filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
.filter(StreamUtil.distinctByKey(ExcelData::getGenerationUserID))
.collect(Collectors.toList());
businessService.testInterfaceByUserId(list, startTime, endTime);
System.out.println();
}
@ApiOperation(value = "获取380kv分布式光伏接入情况")
@PostMapping("/import380")
public void import380(MultipartFile file, String startTime, String endTime) throws Exception {
List<ExcelData> list = EasyExcel.read(file.getInputStream())
.head(ExcelData.class)
.headRowNumber(2)
.sheet(3).doReadSync();
//排重
list = list.stream()
.filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
.filter(StreamUtil.distinctByKey(ExcelData::getGenerationUserID))
.collect(Collectors.toList());
businessService.testInterfaceByUserId(list, startTime, endTime);
System.out.println();
@ApiOperation(value = "查询所有用户的遥测数据")
@PostMapping("/queryTelemetryData")
public void queryTelemetryData(String startTime, String endTime) {
businessService.queryTelemetryData(startTime, endTime);
}
@ApiOperation(value = "导入10kv分布式光伏接入情况", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)

View File

@@ -3,6 +3,8 @@ package com.njcn.jbsyncdata.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.jbsyncdata.pojo.PmsPowerGenerationUser;
import java.util.List;
/**
* <p>
@@ -15,4 +17,5 @@ import com.njcn.jbsyncdata.pojo.PmsPowerGenerationUser;
public interface PmsPowerGenerationUserMapper extends MppBaseMapper<PmsPowerGenerationUser> {
List<String> queryAllUserId();
}

View File

@@ -2,5 +2,11 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.jbsyncdata.mapper.PmsPowerGenerationUserMapper">
<select id="queryAllUserId" resultType="String">
select
id
from
pms_power_generation_user
</select>
</mapper>

View File

@@ -6,6 +6,6 @@ import java.util.List;
public interface IBusinessService {
void testInterfaceByUserId(List<ExcelData> list,String startTime,String endTime);
void queryTelemetryData(String startTime,String endTime);
}

View File

@@ -3,6 +3,8 @@ package com.njcn.jbsyncdata.service;
import com.github.jeffreyning.mybatisplus.service.IMppService;
import com.njcn.jbsyncdata.pojo.PmsPowerGenerationUser;
import java.util.List;
/**
* <p>
* 发电用户台账 服务类
@@ -13,4 +15,9 @@ import com.njcn.jbsyncdata.pojo.PmsPowerGenerationUser;
*/
public interface IPmsPowerGenerationUserService extends IMppService<PmsPowerGenerationUser> {
/**
* 查询所有客户编号
* @return
*/
List<String> queryAllUserId();
}

View File

@@ -13,6 +13,7 @@ import com.njcn.jbsyncdata.enums.MeasTypeEnum;
import com.njcn.jbsyncdata.pojo.ExcelData;
import com.njcn.jbsyncdata.pojo.result.*;
import com.njcn.jbsyncdata.service.IBusinessService;
import com.njcn.jbsyncdata.service.IPmsPowerGenerationUserService;
import com.njcn.jbsyncdata.util.RestTemplateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
@@ -38,6 +39,9 @@ public class BusinessServiceImpl implements IBusinessService {
@Resource
private InfluxDbUtils influxDbUtils;
@Resource
private IPmsPowerGenerationUserService pmsPowerGenerationUserService;
/**
* 此方法通过发电客户编号查询数据,该方法存在以下问题
* 问题一一个发电客户编号同指标返回的数据会有多个但是目前看到最多2个测量点数据。
@@ -51,11 +55,9 @@ public class BusinessServiceImpl implements IBusinessService {
* 2. PageResult的records属性为null---------------------不做处理,直接过
* 3. CommonTelemetry的遥测数据集合telemetryValue为null--不做处理,直接过
* 4. StatisticsData统计数据的实际数值measValue为null-----对应时间、指标的数值设置为0
*
* @param excelDataList 客户编号集合
*/
@Override
public void testInterfaceByUserId(List<ExcelData> excelDataList, String startTime, String endTime) {
public void queryTelemetryData(String startTime, String endTime) {
RestTemplateUtil restTemplateUtil = new RestTemplateUtil();
TokenResult tokenWithRestTemplate = tokenComponent.getTokenWithRestTemplate();
if (null == tokenWithRestTemplate) {
@@ -64,9 +66,11 @@ public class BusinessServiceImpl implements IBusinessService {
}
JSONObject jsonObject;
JSONObject jsonObjectSub;
//获取所有发电用户的id
List<String> userIds = pmsPowerGenerationUserService.queryAllUserId();
//将发电用户编号按500尺寸分片
List<List<ExcelData>> partitionList = ListUtils.partition(excelDataList, 500);
for (List<ExcelData> excelData : partitionList) {
List<List<String>> partitionList = ListUtils.partition(userIds, 500);
for (List<String> userId : partitionList) {
Map</*表名*/String, List<Map</*属性名*/String,/*数值*/String>>> typeData = new HashMap<>();
jsonObject = JSONUtil.createObj();
jsonObjectSub = JSONUtil.createObj();
@@ -75,7 +79,7 @@ public class BusinessServiceImpl implements IBusinessService {
jsonObject.set("startTime", startTime);
jsonObject.set("endTime", endTime);
//按批次处理用户编号数据
List<String> generationUserIDList = excelData.stream().map(t -> "160".concat(t.getGenerationUserID())).collect(Collectors.toList());
List<String> generationUserIDList = userId.stream().map("160"::concat).collect(Collectors.toList());
jsonObjectSub.set("consNos", generationUserIDList);
//1公专变2低压用户3光伏
jsonObjectSub.set("consType", 3);

View File

@@ -1,5 +1,6 @@
package com.njcn.jbsyncdata.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.jbsyncdata.mapper.PmsPowerGenerationUserMapper;
import com.njcn.jbsyncdata.pojo.PmsPowerGenerationUser;
@@ -7,6 +8,8 @@ import com.njcn.jbsyncdata.service.IPmsPowerGenerationUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 发电用户台账 服务实现类
@@ -19,4 +22,8 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
public class PmsPowerGenerationUserServiceImpl extends MppServiceImpl<PmsPowerGenerationUserMapper, PmsPowerGenerationUser> implements IPmsPowerGenerationUserService {
@Override
public List<String> queryAllUserId() {
return this.baseMapper.queryAllUserId();
}
}