2023-09-26 19:35:33 +08:00
|
|
|
package com.njcn.jbsyncdata.controller;
|
|
|
|
|
|
2023-10-09 15:53:21 +08:00
|
|
|
import cn.hutool.core.util.StrUtil;
|
2023-09-26 19:35:33 +08:00
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
import com.njcn.jbsyncdata.pojo.DisPhotovoltaic10Excel;
|
|
|
|
|
import com.njcn.jbsyncdata.pojo.DisPhotovoltaic380Excel;
|
2023-10-09 15:53:21 +08:00
|
|
|
import com.njcn.jbsyncdata.pojo.ExcelData;
|
2023-10-10 20:04:11 +08:00
|
|
|
import com.njcn.jbsyncdata.service.DisPhotovoltaicService;
|
2023-10-09 15:53:21 +08:00
|
|
|
import com.njcn.jbsyncdata.service.IBusinessService;
|
|
|
|
|
import com.njcn.jbsyncdata.util.StreamUtil;
|
2023-09-26 19:35:33 +08:00
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2023-10-10 20:04:11 +08:00
|
|
|
import org.springframework.http.MediaType;
|
2023-09-26 19:35:33 +08:00
|
|
|
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;
|
|
|
|
|
|
2023-10-10 20:04:11 +08:00
|
|
|
import javax.servlet.http.HttpServletResponse;
|
2023-09-26 19:35:33 +08:00
|
|
|
import java.util.List;
|
2023-10-09 15:53:21 +08:00
|
|
|
import java.util.stream.Collectors;
|
2023-09-26 19:35:33 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author wr
|
|
|
|
|
* @description
|
|
|
|
|
* @date 2023/9/26 15:28
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Api(tags = "冀北数据管理")
|
|
|
|
|
@RequestMapping("/dataImport")
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class DisPhotovoltaicController {
|
|
|
|
|
|
2023-10-09 15:53:21 +08:00
|
|
|
private final IBusinessService businessService;
|
2023-10-10 20:04:11 +08:00
|
|
|
private final DisPhotovoltaicService disPhotovoltaicService;
|
2023-10-09 15:53:21 +08:00
|
|
|
|
2023-09-26 19:35:33 +08:00
|
|
|
@ApiOperation(value = "获取10kv分布式光伏接入情况")
|
|
|
|
|
@PostMapping("/import10")
|
|
|
|
|
public void importTakeOrder(MultipartFile file) throws Exception {
|
2023-10-09 15:53:21 +08:00
|
|
|
List<ExcelData> list = EasyExcel.read(file.getInputStream())
|
|
|
|
|
.head(ExcelData.class)
|
2023-09-26 19:35:33 +08:00
|
|
|
.headRowNumber(2)
|
|
|
|
|
.sheet(2).doReadSync();
|
2023-10-09 15:53:21 +08:00
|
|
|
//排重
|
|
|
|
|
list = list.stream()
|
|
|
|
|
.filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
|
|
|
|
|
.filter(StreamUtil.distinctByKey(ExcelData::getGenerationUserID))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
businessService.testInterfaceByUserId(list);
|
2023-09-26 19:35:33 +08:00
|
|
|
System.out.println();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取380kv分布式光伏接入情况")
|
|
|
|
|
@PostMapping("/import380")
|
|
|
|
|
public void import380(MultipartFile file) throws Exception {
|
2023-10-09 15:53:21 +08:00
|
|
|
List<ExcelData> list = EasyExcel.read(file.getInputStream())
|
|
|
|
|
.head(ExcelData.class)
|
2023-09-26 19:35:33 +08:00
|
|
|
.headRowNumber(2)
|
|
|
|
|
.sheet(3).doReadSync();
|
2023-10-09 15:53:21 +08:00
|
|
|
//排重
|
|
|
|
|
list = list.stream()
|
|
|
|
|
.filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
|
|
|
|
|
.filter(StreamUtil.distinctByKey(ExcelData::getGenerationUserID))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
businessService.testInterfaceByUserId(list);
|
2023-09-26 19:35:33 +08:00
|
|
|
System.out.println();
|
|
|
|
|
|
|
|
|
|
}
|
2023-10-09 15:53:21 +08:00
|
|
|
|
2023-10-10 20:04:11 +08:00
|
|
|
@ApiOperation(value = "导入10kv分布式光伏接入情况", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
|
|
@PostMapping("/import10KV")
|
|
|
|
|
public void import10(MultipartFile file, HttpServletResponse response) throws Exception {
|
|
|
|
|
List<DisPhotovoltaic10Excel> list = EasyExcel.read(file.getInputStream())
|
|
|
|
|
.head(DisPhotovoltaic10Excel.class)
|
|
|
|
|
.headRowNumber(2)
|
|
|
|
|
.sheet(2).doReadSync();
|
|
|
|
|
list = list.stream()
|
|
|
|
|
.filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
|
|
|
|
|
.filter(t -> StrUtil.isNotBlank(t.getStageID()))
|
|
|
|
|
.filter(StreamUtil.distinctByKey(DisPhotovoltaic10Excel::getGenerationUserID))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
disPhotovoltaicService.SavaPmsPowerGenerationUser10KV(list, response);
|
2023-10-09 15:53:21 +08:00
|
|
|
|
2023-10-10 20:04:11 +08:00
|
|
|
}
|
|
|
|
|
@ApiOperation(value = "导入380kv分布式光伏接入情况", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
|
|
@PostMapping("/import380KV")
|
|
|
|
|
public void import380KV(MultipartFile file, HttpServletResponse response) throws Exception {
|
|
|
|
|
List<DisPhotovoltaic380Excel> list = EasyExcel.read(file.getInputStream())
|
|
|
|
|
.head(DisPhotovoltaic380Excel.class)
|
|
|
|
|
.headRowNumber(1)
|
|
|
|
|
.sheet(0).doReadSync();
|
|
|
|
|
list = list.stream()
|
|
|
|
|
.filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
|
|
|
|
|
.filter(t -> StrUtil.isNotBlank(t.getStageID()))
|
|
|
|
|
.filter(StreamUtil.distinctByKey(DisPhotovoltaic380Excel::getGenerationUserID))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
disPhotovoltaicService.SavaPmsPowerGenerationUser380KV(list, response);
|
|
|
|
|
System.out.println();
|
2023-10-09 15:53:21 +08:00
|
|
|
|
2023-10-10 20:04:11 +08:00
|
|
|
}
|
2023-09-26 19:35:33 +08:00
|
|
|
}
|