|
@@ -17,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.swing.plaf.multi.MultiInternalFrameUI;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.sql.SQLException;
|
|
|
import java.text.DecimalFormat;
|
|
@@ -125,12 +126,33 @@ public class ReadtoMysql {
|
|
|
/**
|
|
|
* 读取 东北风向风速 东南风向风速 西南风向风速 西北风向风速 4个sheet表风速点表
|
|
|
*/
|
|
|
- public static ResponseVO readSpeedSheet() throws SQLException {
|
|
|
+ public static ResponseVO readSpeedSheet(MultipartFile multipartFile) throws Exception {
|
|
|
+
|
|
|
+ //获取到文件名
|
|
|
+ String originalFilename = multipartFile.getOriginalFilename();
|
|
|
+ File fileP = new File("");
|
|
|
+ //获取项目路径
|
|
|
+ String filePath = fileP.getCanonicalPath();
|
|
|
+
|
|
|
+ String route = filePath + "/" + "Temporary/";
|
|
|
+ File file1 = new File(route);
|
|
|
+
|
|
|
+ if (!file1.exists()) {
|
|
|
+ file1.mkdirs();
|
|
|
+ }
|
|
|
+ File[] files = file1.listFiles();
|
|
|
+ //判断文件夹中是否有文件
|
|
|
+ if(files.length < 1){
|
|
|
+ multipartFile.transferTo(new File(route + originalFilename));
|
|
|
+ }
|
|
|
+ File file = new File(route + originalFilename);
|
|
|
+
|
|
|
+
|
|
|
Map<Integer, List<String>> fanidInfo = new HashMap<>();
|
|
|
List<WindSpeedPointInfo> windSpeedPointInfoList = new ArrayList<>();
|
|
|
DecimalFormat decimalFormat = new DecimalFormat(".00");
|
|
|
|
|
|
- try (ExcelReader reader = ExcelUtil.getReader(modleParamFilePath, 0)) {
|
|
|
+ try (ExcelReader reader = ExcelUtil.getReader(file.getPath(), 0)) {
|
|
|
reader.addHeaderAlias("序号", "id");
|
|
|
reader.addHeaderAlias("机组名称", "fanName");
|
|
|
reader.addHeaderAlias("风机容量KW", "fanUnitCapacity");
|
|
@@ -184,20 +206,43 @@ public class ReadtoMysql {
|
|
|
} catch (cn.hutool.poi.exceptions.POIException e) {
|
|
|
return ResponseVO.error(e);
|
|
|
}
|
|
|
+ //删除文件
|
|
|
+ file.delete();
|
|
|
return ResponseVO.success(1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 读取风速曲线
|
|
|
*/
|
|
|
- public static ResponseVO readWindTurbinePowerCurveMap() throws SQLException {
|
|
|
+ public static ResponseVO readWindTurbinePowerCurveMap(MultipartFile multipartFile) throws Exception {
|
|
|
+
|
|
|
+ //获取到文件名
|
|
|
+ String originalFilename = multipartFile.getOriginalFilename();
|
|
|
+ File fileP = new File("");
|
|
|
+ //获取项目路径
|
|
|
+ String filePath = fileP.getCanonicalPath();
|
|
|
+
|
|
|
+ String route = filePath + "/" + "Temporary/";
|
|
|
+ File file1 = new File(route);
|
|
|
+
|
|
|
+ if (!file1.exists()) {
|
|
|
+ file1.mkdirs();
|
|
|
+ }
|
|
|
+ File[] files = file1.listFiles();
|
|
|
+ //判断文件夹中是否有文件
|
|
|
+ if(files.length < 1){
|
|
|
+ multipartFile.transferTo(new File(route + originalFilename));
|
|
|
+ }
|
|
|
+ File file = new File(route + originalFilename);
|
|
|
+
|
|
|
+
|
|
|
for (int sheelIndex = 10; sheelIndex <= 14; sheelIndex++) {
|
|
|
//读取风速曲线 sheet
|
|
|
String sheetName;
|
|
|
List<List<Object>> readRows;
|
|
|
List<WindTurbinePowerCurve> windTurbinePowerCurves = new ArrayList<>();
|
|
|
try (
|
|
|
- ExcelReader readerWind = ExcelUtil.getReader(modleParamFilePath, sheelIndex)) {
|
|
|
+ ExcelReader readerWind = ExcelUtil.getReader(file.getPath(), sheelIndex)) {
|
|
|
sheetName = readerWind.getSheet().getSheetName();
|
|
|
//按行读取所有数据
|
|
|
readRows = readerWind.read();
|
|
@@ -217,6 +262,8 @@ public class ReadtoMysql {
|
|
|
return ResponseVO.error(e);
|
|
|
}
|
|
|
}
|
|
|
+ //删除文件
|
|
|
+ file.delete();
|
|
|
return ResponseVO.success(1);
|
|
|
}
|
|
|
|
|
@@ -225,10 +272,29 @@ public class ReadtoMysql {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public static ResponseVO readFanCutOutSpeedInfo() throws SQLException {
|
|
|
+ public static ResponseVO readFanCutOutSpeedInfo(MultipartFile multipartFile) throws SQLException, IOException {
|
|
|
+ //获取到文件名
|
|
|
+ String originalFilename = multipartFile.getOriginalFilename();
|
|
|
+ File fileP = new File("");
|
|
|
+ //获取项目路径
|
|
|
+ String filePath = fileP.getCanonicalPath();
|
|
|
+
|
|
|
+ String route = filePath + "/" + "Temporary/";
|
|
|
+ File file1 = new File(route);
|
|
|
+
|
|
|
+ if (!file1.exists()) {
|
|
|
+ file1.mkdirs();
|
|
|
+ }
|
|
|
+ File[] files = file1.listFiles();
|
|
|
+ //判断文件夹中是否有文件
|
|
|
+ if(files.length < 1){
|
|
|
+ multipartFile.transferTo(new File(route + originalFilename));
|
|
|
+ }
|
|
|
+ File file = new File(route + originalFilename);
|
|
|
+
|
|
|
//机组信息读取 sheet 0
|
|
|
List<CutOutSpeedSpecifyInfo> cutOutSpeedSpecifyInfoList;
|
|
|
- try (ExcelReader reader = ExcelUtil.getReader(modleParamFilePath, 9)) {
|
|
|
+ try (ExcelReader reader = ExcelUtil.getReader(file.getPath(), 9)) {
|
|
|
reader.addHeaderAlias("序号", "id");
|
|
|
reader.addHeaderAlias("风速下限(包含)m/s", "lowerWindSpeedLimit");
|
|
|
reader.addHeaderAlias("风速上限(不包含)m/s", "highWindSpeedLimit");
|
|
@@ -248,6 +314,8 @@ public class ReadtoMysql {
|
|
|
} catch (cn.hutool.poi.exceptions.POIException e) {
|
|
|
return ResponseVO.error(e);
|
|
|
}
|
|
|
+ //删除文件
|
|
|
+ file.delete();
|
|
|
return ResponseVO.success(1);
|
|
|
}
|
|
|
}
|