Commit e35bff65 authored by ZWT's avatar ZWT

feat(零碳): 长庆

1.添加easy excel配置,增加转换器,增加全局excel导出样式,增加场站下拉选解析器;
2.开发光伏电站模板导出接口,增加模板导出类,并完成接口冒烟测试及接口文档;
3.间开制度管理模块新增设为基础制度开关接口,添加线上接口文档并完成接口冒烟测试;
4.开发井口配置模板导出接口,增加模板导出类,并完成接口冒烟测试及接口文档;
5.开发第三方有功功率历史数据导入接口,增加模板配置类,添加线上接口文档并完成接口冒烟测试;
6.开发给长庆使用的获取第三方认证token接口,验证获取token后是否能正常跳转指定页面,创建长庆用演示用户及角色;
7.开发柴发设备配置模板导出接口,增加模板导出类,并完成接口冒烟测试及接口文档;
8.开发储能设备配置模板导出接口,增加模板导出类,并完成接口冒烟测试及接口文档;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 4384f415
......@@ -3,8 +3,6 @@ package pps.core.base.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
......@@ -163,12 +161,7 @@ public class ExcelService {
@XText("光伏电站配置导入")
@XApiUpload(anonymous = true)
public XServiceResult importPhotovoltaicPlant(XContext context, ImportExcelInput input) {
XUploadFile file = input.getFile();
// this.checkExcel(file);
ExcelListener<ExcelPhotovoltaicPlantTemplate> excelListener = new ExcelListener<>(-1);
EasyExcel.read(file.getInputStream(), ExcelPhotovoltaicPlantTemplate.class, excelListener).sheet().doRead();
List<ExcelPhotovoltaicPlantTemplate> dataList = excelListener.getDataList();
ValidationUtil.doValidate(dataList);
List<ExcelPhotovoltaicPlantTemplate> list = this.getExcelDataAndCheck(input.getFile(), ExcelPhotovoltaicPlantTemplate.class);
return XServiceResult.OK;
}
......@@ -183,7 +176,6 @@ public class ExcelService {
@XApiUpload(anonymous = true)
public XServiceResult importWellhead(XContext context, ImportExcelInput input) {
XUploadFile file = input.getFile();
this.checkExcel(file);
return XServiceResult.OK;
}
......@@ -198,7 +190,6 @@ public class ExcelService {
@XApiUpload(anonymous = true)
public XServiceResult importDieselGenerator(XContext context, ImportExcelInput input) {
XUploadFile file = input.getFile();
this.checkExcel(file);
return XServiceResult.OK;
}
......@@ -213,20 +204,34 @@ public class ExcelService {
@XApiUpload(anonymous = true)
public XServiceResult importEnergyStorageDevice(XContext context, ImportExcelInput input) {
XUploadFile file = input.getFile();
this.checkExcel(file);
return XServiceResult.OK;
}
/*------------------------------------ private ------------------------------------*/
/**
* 检查excel
* 获取excel数据并检查
*
* @param file 文件
* @param head 头
* @return {@link List }<{@link T }>
*/
private void checkExcel(XUploadFile file) {
// 文件名称
String fileName = file.getFileName();
private <T> List<T> getExcelDataAndCheck(XUploadFile file, Class<T> head) {
this.checkFileTypeIsExcel(file.getFileName());
ExcelListener<T> excelListener = new ExcelListener<>(-1);
EasyExcel.read(file.getInputStream(), head, excelListener).sheet().doRead();
List<T> dataList = excelListener.getDataList();
this.checkExcelDataSize(dataList);
ValidationUtil.doValidate(dataList);
return dataList;
}
/**
* 检查文件类型为excel
*
* @param fileName 文件名
*/
private void checkFileTypeIsExcel(String fileName) {
// 截取文件后缀
String fileSuffix = null;
if (CharSequenceUtil.isNotBlank(fileName)) {
......@@ -237,9 +242,15 @@ public class ExcelService {
if (!CharSequenceUtil.equalsAny(fileSuffix, parts)) {
throw new XServiceException(BusinessError.FileFormatError);
}
ExcelReader reader = ExcelUtil.getReader(file.getInputStream(), 0);
int rowCount = reader.getRowCount();
if (rowCount <= 1) {
}
/**
* 检查excel数据大小
*
* @param dataList 数据列表
*/
private void checkExcelDataSize(List dataList) {
if (CollUtil.isEmpty(dataList)) {
throw new XServiceException(BusinessError.UndiscoveredData);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment