|
@@ -13,7 +13,11 @@ import com.jiayue.ipfcst.common.data.repository.WindSpeedPointInfoRepository;
|
|
|
import com.jiayue.ipfcst.common.data.repository.WindTurbinePowerCurveRepository;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.swing.plaf.multi.MultiInternalFrameUI;
|
|
|
+import java.io.File;
|
|
|
+import java.io.InputStream;
|
|
|
import java.sql.SQLException;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
@@ -30,16 +34,18 @@ public class ReadtoMysql {
|
|
|
|
|
|
private static WindSpeedPointInfoRepository windSpeedPointInfoRepository;
|
|
|
private static WindTurbinePowerCurveRepository windTurbinePowerCurveRepository;
|
|
|
+
|
|
|
@Autowired
|
|
|
- public void setWindSpeedPointInfoRepository(WindSpeedPointInfoRepository windSpeedPointInfoRepository){
|
|
|
+ public void setWindSpeedPointInfoRepository(WindSpeedPointInfoRepository windSpeedPointInfoRepository) {
|
|
|
ReadtoMysql.windSpeedPointInfoRepository = windSpeedPointInfoRepository;
|
|
|
}
|
|
|
+
|
|
|
@Autowired
|
|
|
- public void setWindTurbinePowerCurveRepository(WindTurbinePowerCurveRepository windTurbinePowerCurveRepository){
|
|
|
+ public void setWindTurbinePowerCurveRepository(WindTurbinePowerCurveRepository windTurbinePowerCurveRepository) {
|
|
|
ReadtoMysql.windTurbinePowerCurveRepository = windTurbinePowerCurveRepository;
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) throws Exception{
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
// 读取机组信息到数据库
|
|
|
// readFanUnitInfo();
|
|
|
/**
|
|
@@ -59,12 +65,33 @@ public class ReadtoMysql {
|
|
|
|
|
|
/**
|
|
|
* 读取机组信息
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- public static ResponseVO readFanUnitInfo() throws Exception{
|
|
|
+ public static ResponseVO readFanUnitInfo(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);
|
|
|
+
|
|
|
//机组信息读取 sheet 0
|
|
|
List<FanUnitInfo> fanUnitInfoList;
|
|
|
- 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");
|
|
@@ -79,17 +106,18 @@ public class ReadtoMysql {
|
|
|
Entity.create("t_fan_unit_info")
|
|
|
// .set("C_ID",fanUnitInfo.getId())
|
|
|
.set("C_FAN_NAME", fanUnitInfo.getFanName())
|
|
|
- .set("C_FAN_UNIT_CAPACITY",fanUnitInfo.getFanUnitCapacity())
|
|
|
- .set("C_FULL_WIND_SPEED",fanUnitInfo.getFullWindSpeed())
|
|
|
- .set("C_CUT_OUT_SPEED",fanUnitInfo.getCutOutSpeed())
|
|
|
- .set("C_BENCHMARK_FAN",fanUnitInfo.getBenchmarkFan())
|
|
|
- .set("C_FAN_NUM_ARRS",fanUnitInfo.getFanNumArrs())
|
|
|
+ .set("C_FAN_UNIT_CAPACITY", fanUnitInfo.getFanUnitCapacity())
|
|
|
+ .set("C_FULL_WIND_SPEED", fanUnitInfo.getFullWindSpeed())
|
|
|
+ .set("C_CUT_OUT_SPEED", fanUnitInfo.getCutOutSpeed())
|
|
|
+ .set("C_BENCHMARK_FAN", fanUnitInfo.getBenchmarkFan())
|
|
|
+ .set("C_FAN_NUM_ARRS", fanUnitInfo.getFanNumArrs())
|
|
|
);
|
|
|
}
|
|
|
- }catch (cn.hutool.poi.exceptions.POIException e){
|
|
|
+ } catch (cn.hutool.poi.exceptions.POIException e) {
|
|
|
return ResponseVO.error(e);
|
|
|
}
|
|
|
-
|
|
|
+ //删除文件
|
|
|
+ file.delete();
|
|
|
return ResponseVO.success(1);
|
|
|
|
|
|
}
|
|
@@ -98,9 +126,9 @@ public class ReadtoMysql {
|
|
|
* 读取 东北风向风速 东南风向风速 西南风向风速 西北风向风速 4个sheet表风速点表
|
|
|
*/
|
|
|
public static ResponseVO readSpeedSheet() throws SQLException {
|
|
|
- Map<Integer,List<String>> fanidInfo = new HashMap<>();
|
|
|
+ Map<Integer, List<String>> fanidInfo = new HashMap<>();
|
|
|
List<WindSpeedPointInfo> windSpeedPointInfoList = new ArrayList<>();
|
|
|
- DecimalFormat decimalFormat=new DecimalFormat(".00");
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat(".00");
|
|
|
|
|
|
try (ExcelReader reader = ExcelUtil.getReader(modleParamFilePath, 0)) {
|
|
|
reader.addHeaderAlias("序号", "id");
|
|
@@ -153,16 +181,17 @@ public class ReadtoMysql {
|
|
|
}
|
|
|
}
|
|
|
windSpeedPointInfoRepository.saveAll(windSpeedPointInfoList);
|
|
|
- }catch (cn.hutool.poi.exceptions.POIException e){
|
|
|
+ } catch (cn.hutool.poi.exceptions.POIException e) {
|
|
|
return ResponseVO.error(e);
|
|
|
}
|
|
|
return ResponseVO.success(1);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 读取风速曲线
|
|
|
*/
|
|
|
public static ResponseVO readWindTurbinePowerCurveMap() throws SQLException {
|
|
|
- for(int sheelIndex=10;sheelIndex<=14;sheelIndex++){
|
|
|
+ for (int sheelIndex = 10; sheelIndex <= 14; sheelIndex++) {
|
|
|
//读取风速曲线 sheet
|
|
|
String sheetName;
|
|
|
List<List<Object>> readRows;
|
|
@@ -172,8 +201,8 @@ public class ReadtoMysql {
|
|
|
sheetName = readerWind.getSheet().getSheetName();
|
|
|
//按行读取所有数据
|
|
|
readRows = readerWind.read();
|
|
|
- for(List<Object> r: readRows){
|
|
|
- if(String.valueOf(r.get(0)).contains("风")){
|
|
|
+ for (List<Object> r : readRows) {
|
|
|
+ if (String.valueOf(r.get(0)).contains("风")) {
|
|
|
continue;
|
|
|
}
|
|
|
WindTurbinePowerCurve windTurbinePowerCurve = new WindTurbinePowerCurve();
|
|
@@ -184,14 +213,16 @@ public class ReadtoMysql {
|
|
|
}
|
|
|
|
|
|
windTurbinePowerCurveRepository.saveAll(windTurbinePowerCurves);
|
|
|
- }catch (cn.hutool.poi.exceptions.POIException e){
|
|
|
+ } catch (cn.hutool.poi.exceptions.POIException e) {
|
|
|
return ResponseVO.error(e);
|
|
|
}
|
|
|
}
|
|
|
return ResponseVO.success(1);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 满发风速之后各风速发电曲线
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
public static ResponseVO readFanCutOutSpeedInfo() throws SQLException {
|
|
@@ -204,17 +235,17 @@ public class ReadtoMysql {
|
|
|
reader.addHeaderAlias("发电功率kW", "powerGeneration");
|
|
|
reader.addHeaderAlias("所属机组", "UnitBelongs");
|
|
|
cutOutSpeedSpecifyInfoList = reader.readAll(CutOutSpeedSpecifyInfo.class);
|
|
|
- for(CutOutSpeedSpecifyInfo cs : cutOutSpeedSpecifyInfoList){
|
|
|
+ for (CutOutSpeedSpecifyInfo cs : cutOutSpeedSpecifyInfoList) {
|
|
|
Db.use().insertForGeneratedKey(
|
|
|
Entity.create("t_cut_out_speed_specify_info")
|
|
|
// .set("C_ID",cs.getId())
|
|
|
- .set("C_LOWER_WIND_SPEED_LIMIT",cs.getLowerWindSpeedLimit())
|
|
|
- .set("C_HIGH_WIND_SPEED_LIMIT",cs.getHighWindSpeedLimit())
|
|
|
- .set("C_POWER_GENERATION",cs.getPowerGeneration())
|
|
|
- .set("C_UNIT_BELONGS",cs.getFanId())
|
|
|
+ .set("C_LOWER_WIND_SPEED_LIMIT", cs.getLowerWindSpeedLimit())
|
|
|
+ .set("C_HIGH_WIND_SPEED_LIMIT", cs.getHighWindSpeedLimit())
|
|
|
+ .set("C_POWER_GENERATION", cs.getPowerGeneration())
|
|
|
+ .set("C_UNIT_BELONGS", cs.getFanId())
|
|
|
);
|
|
|
}
|
|
|
- } catch (cn.hutool.poi.exceptions.POIException e){
|
|
|
+ } catch (cn.hutool.poi.exceptions.POIException e) {
|
|
|
return ResponseVO.error(e);
|
|
|
}
|
|
|
return ResponseVO.success(1);
|