|
@@ -1,356 +1,353 @@
|
|
|
-package service;
|
|
|
-
|
|
|
-import com.jiayue.NerpApplication;
|
|
|
-import com.jiayue.biz.domain.*;
|
|
|
-import com.jiayue.biz.service.StatisticsSituationService;
|
|
|
-import com.jiayue.biz.service.WindTowerInfoService;
|
|
|
-import com.jiayue.biz.service.impl.*;
|
|
|
-import com.jiayue.biz.util.CalculationUtil;
|
|
|
-import com.jiayue.common.utils.DateUtil;
|
|
|
-import org.apache.commons.math3.fitting.PolynomialCurveFitter;
|
|
|
-import org.apache.commons.math3.fitting.WeightedObservedPoints;
|
|
|
-import org.apache.poi.xssf.streaming.SXSSFRow;
|
|
|
-import org.apache.poi.xssf.streaming.SXSSFSheet;
|
|
|
-import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
-import org.junit.jupiter.api.Test;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-import wei.yigulu.modbus.domain.FunctionCode;
|
|
|
-import wei.yigulu.modbus.domain.Obj4RequestRegister;
|
|
|
-import wei.yigulu.modbus.domain.datatype.IModbusDataType;
|
|
|
-import wei.yigulu.modbus.domain.datatype.ModbusDataTypeEnum;
|
|
|
-import wei.yigulu.modbus.domain.datatype.NumericModbusData;
|
|
|
-import wei.yigulu.modbus.exceptiom.ModbusException;
|
|
|
-import wei.yigulu.modbus.netty.ModbusTcpMasterBuilder;
|
|
|
-import wei.yigulu.modbus.utils.ModbusRequestDataUtils;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-import javax.lang.model.SourceVersion;
|
|
|
-import java.io.*;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * 删除上报日志测试类
|
|
|
- *
|
|
|
- * @author xsl
|
|
|
- * @version 3.0
|
|
|
- */
|
|
|
-@SpringBootTest(classes = NerpApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
|
-public class DeleteUploadLogServiceTest {
|
|
|
- @Autowired
|
|
|
- WindTowerInfoService windTowerInfoService;
|
|
|
- @Autowired
|
|
|
- AnalysisLogServiceImpl analysisLogService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- HomePageServiceImpl homePageService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- WindTowerDataChildTableServiceImpl windTowerDataChildTableService;
|
|
|
- @Autowired
|
|
|
- WindTowerCalculationDataServiceImpl windTowerCalculationDataService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- WsWdServiceImpl wsWdService;
|
|
|
- @Autowired
|
|
|
- TurbulenceServiceImpl turbulenceService;
|
|
|
- @Autowired
|
|
|
- PdfServiceImpl pdfService;
|
|
|
- @Autowired
|
|
|
- EquipmentAttributeServiceImpl equipmentAttributeService;
|
|
|
- @Autowired
|
|
|
- WindTowerDataParentTableServiceImpl windTowerDataParentTableService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- StatisticsSituationService statisticsSituationService;
|
|
|
-
|
|
|
- public static void main(String[] args) throws Exception {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void mains() {
|
|
|
-// homePageService. getWsAndWpdForHeight("006174");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void homePageCharts() {
|
|
|
-// homePageService.getWsAndWpdForHeight("006174");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public void saveData(HashMap<String, BigDecimal> dataMap, HashSet<Integer> heightSet) {
|
|
|
- WindTowerDataParentTable windTowerDataParentTable = new WindTowerDataParentTable();
|
|
|
- List<WindTowerInfo> windTowerInfos = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getType, "2").eq(WindTowerInfo::getEquipmentNo, "3002").list();
|
|
|
- String id = String.valueOf(UUID.randomUUID());
|
|
|
- List<EquipmentAttribute> equipmentAttributes = equipmentAttributeService.lambdaQuery().eq(EquipmentAttribute::getAttributeFunction, "height").list();
|
|
|
- List<WindTowerDataChildTable> windTowerDataChildTableList = new ArrayList<>();
|
|
|
- for (Integer height : heightSet) {
|
|
|
- List<EquipmentAttribute> eqHeight = equipmentAttributes.stream().filter(e -> e.getFieldName().equals(height.toString())).collect(Collectors.toList());
|
|
|
- WindTowerDataChildTable windTowerDataChildTable = new WindTowerDataChildTable();
|
|
|
- windTowerDataChildTable.setParentId(id);
|
|
|
- windTowerDataChildTable.setLayerHeight(eqHeight.get(0).getId());
|
|
|
- windTowerDataChildTable.setWsAve(CalculationUtil.getBigDecimal(dataMap.get("wsAve" + height) == null ? null : dataMap.get("wsAve" + height).toString()));
|
|
|
- windTowerDataChildTable.setWsMin(CalculationUtil.getBigDecimal(dataMap.get("wsMin" + height) == null ? null : dataMap.get("wsMin" + height).toString()));
|
|
|
- windTowerDataChildTable.setWsMax(CalculationUtil.getBigDecimal(dataMap.get("wsMax" + height) == null ? null : dataMap.get("wsMax" + height).toString()));
|
|
|
- windTowerDataChildTable.setWsSta(CalculationUtil.getBigDecimal(dataMap.get("wsSta" + height) == null ? null : dataMap.get("wsSta" + height).toString()));
|
|
|
- windTowerDataChildTable.setWsInst(CalculationUtil.getBigDecimal(dataMap.get("wsInst" + height) == null ? null : dataMap.get("wsInst" + height).toString()));
|
|
|
- windTowerDataChildTable.setWsGust(CalculationUtil.getBigDecimal(dataMap.get("wsGust" + height) == null ? null : dataMap.get("wsGust" + height).toString()));
|
|
|
- windTowerDataChildTable.setWdAve(CalculationUtil.getBigDecimal(dataMap.get("wdAve" + height) == null ? null : dataMap.get("wdAve" + height).toString()));
|
|
|
- windTowerDataChildTable.setWdMax(CalculationUtil.getBigDecimal(dataMap.get("wdMax" + height) == null ? null : dataMap.get("wdMax" + height).toString()));
|
|
|
- windTowerDataChildTable.setWdMin(CalculationUtil.getBigDecimal(dataMap.get("wdMin" + height) == null ? null : dataMap.get("wdMin" + height).toString()));
|
|
|
- windTowerDataChildTable.setWdSta(CalculationUtil.getBigDecimal(dataMap.get("wdSta" + height) == null ? null : dataMap.get("wdSta" + height).toString()));
|
|
|
- windTowerDataChildTable.setWdInst(CalculationUtil.getBigDecimal(dataMap.get("wdInst" + height) == null ? null : dataMap.get("wdInst" + height).toString()));
|
|
|
- windTowerDataChildTableList.add(windTowerDataChildTable);
|
|
|
- }
|
|
|
-
|
|
|
- windTowerDataParentTable.setEquipmentId(windTowerInfos.get(0).getEquipmentNo());
|
|
|
- windTowerDataParentTable.setId(id);
|
|
|
- String time = dataMap.get("yyyy").toString() + (dataMap.get("MM")) + (dataMap.get("dd")) + (dataMap.get("HH")) + (dataMap.get("mm")) + (dataMap.get("ss"));
|
|
|
- //TODO 目前不知道接收的数据长什么样
|
|
|
- windTowerDataParentTable.setTime(DateUtil.parseDate(time));
|
|
|
- if (dataMap.get("paMax") != null)
|
|
|
- //kpa转hpa
|
|
|
- if (BigDecimal.valueOf(Double.parseDouble(dataMap.get("paMax").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
- windTowerDataParentTable.setPaMax(CalculationUtil.getBigDecimal(dataMap.get("paMax").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
- else
|
|
|
- windTowerDataParentTable.setPaMax(CalculationUtil.getBigDecimal(dataMap.get("paMax").toString()));
|
|
|
- if (dataMap.get("paMin") != null)
|
|
|
- //kpa转hpa
|
|
|
- if (BigDecimal.valueOf(Double.parseDouble(dataMap.get("paMin").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
- windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(dataMap.get("paMin").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
- else
|
|
|
- windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(dataMap.get("paMin").toString()));
|
|
|
- if (dataMap.get("paInst") != null)
|
|
|
- //kpa转hpa
|
|
|
- if (BigDecimal.valueOf(Double.parseDouble(dataMap.get("paInst").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
- windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(dataMap.get("paInst").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
- else
|
|
|
- windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(dataMap.get("paInst").toString()));
|
|
|
- if (dataMap.get("paAve") != null)
|
|
|
- //kpa转hpa
|
|
|
- if (BigDecimal.valueOf(Double.parseDouble(dataMap.get("paAve").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
- windTowerDataParentTable.setPaAve(CalculationUtil.getBigDecimal(dataMap.get("paAve").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
- else
|
|
|
- windTowerDataParentTable.setPaAve(CalculationUtil.getBigDecimal(dataMap.get("paAve").toString()));
|
|
|
- windTowerDataParentTable.setPaSta(CalculationUtil.getBigDecimal(dataMap.get("paSta") == null ? null : dataMap.get("paSta").toString()));
|
|
|
- windTowerDataParentTable.setTMax(CalculationUtil.getBigDecimal(dataMap.get("tMax") == null ? null : dataMap.get("tMax").toString()));
|
|
|
- windTowerDataParentTable.setTMin(CalculationUtil.getBigDecimal(dataMap.get("tMin") == null ? null : dataMap.get("tMin").toString()));
|
|
|
- windTowerDataParentTable.setTAve(CalculationUtil.getBigDecimal(dataMap.get("tAve") == null ? null : dataMap.get("tAve").toString()));
|
|
|
- windTowerDataParentTable.setTSta(CalculationUtil.getBigDecimal(dataMap.get("tSta") == null ? null : dataMap.get("tSta").toString()));
|
|
|
- windTowerDataParentTable.setTInst(CalculationUtil.getBigDecimal(dataMap.get("tInst") == null ? null : dataMap.get("tInst").toString()));
|
|
|
- windTowerDataParentTable.setRhMax(CalculationUtil.getBigDecimal(dataMap.get("rhMax") == null ? null : dataMap.get("rhMax").toString()));
|
|
|
- windTowerDataParentTable.setRhMin(CalculationUtil.getBigDecimal(dataMap.get("rhMin") == null ? null : dataMap.get("rhMin").toString()));
|
|
|
- windTowerDataParentTable.setRhAve(CalculationUtil.getBigDecimal(dataMap.get("rhAve") == null ? null : dataMap.get("rhAve").toString()));
|
|
|
- windTowerDataParentTable.setRhSta(CalculationUtil.getBigDecimal(dataMap.get("rhSta") == null ? null : dataMap.get("rhSta").toString()));
|
|
|
- windTowerDataParentTable.setRhInst(CalculationUtil.getBigDecimal(dataMap.get("rhInst") == null ? null : dataMap.get("rhInst").toString()));
|
|
|
-
|
|
|
- windTowerDataParentTable.setVMax(CalculationUtil.getBigDecimal(dataMap.get("vMax") == null ? null : dataMap.get("vMax").toString()));
|
|
|
- windTowerDataParentTable.setVMin(CalculationUtil.getBigDecimal(dataMap.get("vMin") == null ? null : dataMap.get("vhMin").toString()));
|
|
|
- windTowerDataParentTable.setVAve(CalculationUtil.getBigDecimal(dataMap.get("vAve") == null ? null : dataMap.get("vhAve").toString()));
|
|
|
- windTowerDataParentTable.setVSta(CalculationUtil.getBigDecimal(dataMap.get("vSta") == null ? null : dataMap.get("vhSta").toString()));
|
|
|
- windTowerDataParentTable.setVInst(CalculationUtil.getBigDecimal(dataMap.get("vInst") == null ? null : dataMap.get("vInst").toString()));
|
|
|
-
|
|
|
- //计算空气密度
|
|
|
- if (dataMap.get("TAve") != null && dataMap.get("paAve") != null) {
|
|
|
- BigDecimal airDensity = BigDecimal.valueOf(1.293).multiply(new BigDecimal(273).divide(new BigDecimal(273).add(dataMap.get("TAve")), 2, RoundingMode.HALF_UP)).multiply(dataMap.get("paAve")).divide(new BigDecimal(1013), 2, RoundingMode.HALF_UP);
|
|
|
- windTowerDataParentTable.setAirDensity(airDensity);
|
|
|
- }
|
|
|
- // TODO 目前没有异常数据校验
|
|
|
-// windTowerDataParentTable.setAbnormalData(dataMap.get("abnormalData") == null ? null : dataMap.get("abnormalData").toString());
|
|
|
-// windTowerDataParentTable.setAbnormalType(dataMap.get("abnormalType") == null ? null : dataMap.get("abnormalType").toString());
|
|
|
-// windTowerDataParentTableList.add(windTowerDataParentTable);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Test
|
|
|
- public void main() {
|
|
|
- System.out.println("DateUtil.formatTime(new Date()) = " + DateUtil.formatTime(new Date()));
|
|
|
-// List<EquipmentAttribute> awsDay = equipmentAttributeService.lambdaQuery().like(EquipmentAttribute::getFieldName, "awsDay").list();
|
|
|
-// List<WindTowerCalculationData> byBetweenTimeAndEquipmentId = windTowerCalculationDataService.getByBetweenTimeAndEquipmentId();
|
|
|
- windTowerDataParentTableService.selectDataByBetweenTimeAndEquipmetId(new Date(1659283200000l), new Date(1661961600000l), "006173");
|
|
|
- System.out.println("DateUtil.formatTime(new Date()) = " + DateUtil.formatTime(new Date()));
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test() {
|
|
|
- //TODO 两个路径需要变化
|
|
|
- String exl = "D:\\txt\\";
|
|
|
- File file = new File("D:\\txt\\txt");
|
|
|
- //将wnd文件转换成txt文件
|
|
|
- ConversionType();
|
|
|
- File[] files = file.listFiles();
|
|
|
- if (files != null) {
|
|
|
- for (File file1 : files) {
|
|
|
- int index = file1.getName().lastIndexOf(".");
|
|
|
- //转换excel路径
|
|
|
- String excelFile = exl + file1.getName().substring(0, index) + ".xls";
|
|
|
- /*实例化输入、输出流*/
|
|
|
- //输入文件
|
|
|
- File f_in = new File(file1.getPath());
|
|
|
- FileInputStream ips = null;
|
|
|
- InputStreamReader ipsr = null;
|
|
|
- //输出文件
|
|
|
- File f_out = new File(excelFile);
|
|
|
- FileOutputStream ops = null;
|
|
|
- try {
|
|
|
- ips = new FileInputStream(f_in);
|
|
|
- ipsr = new InputStreamReader(ips);
|
|
|
- ops = new FileOutputStream(f_out);
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- /*创建excel表格文件并输出*/
|
|
|
- //创建工作薄
|
|
|
- SXSSFWorkbook wb = new SXSSFWorkbook();
|
|
|
- try {
|
|
|
- //创建新的一页
|
|
|
- SXSSFSheet sheet = wb.createSheet("new sheet");
|
|
|
- BufferedReader br = new BufferedReader(ipsr);
|
|
|
- String valueString = null;
|
|
|
- //记录有效行
|
|
|
- int count_line = 0;
|
|
|
- int total = 0;
|
|
|
- StringBuffer wsHeight = new StringBuffer();
|
|
|
- StringBuffer wdHeight = new StringBuffer();
|
|
|
- StringBuilder dataName = new StringBuilder();
|
|
|
-
|
|
|
- while ((valueString = br.readLine()) != null) {
|
|
|
- if (valueString.contains("Date")) {
|
|
|
- total++;
|
|
|
- }
|
|
|
- if (total == 2) {
|
|
|
- //分解每一行有效行 去除两边的空格
|
|
|
- String[] strs_cell = valueString.trim().split("\\s+");
|
|
|
- //生成行
|
|
|
- SXSSFRow row = sheet.createRow((short) count_line);
|
|
|
- for (int i = 0; i < strs_cell.length; i++) {//循环每个切割得到的数据,除了最后一个(,,,)和第一个(空)
|
|
|
- //创建要显示的内容,创建一个单元格,第一个参数为列坐标,第二个参数为行坐标,第三个参数为内容
|
|
|
- //生成列并插入数据
|
|
|
- row.createCell((short) i).setCellValue(strs_cell[i]);
|
|
|
- //所有表头
|
|
|
- if (!dataName.toString().equals("")) {
|
|
|
- dataName.append(",");
|
|
|
- dataName.append(strs_cell[i]);
|
|
|
- } else {
|
|
|
- dataName.append(strs_cell[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- count_line++;
|
|
|
- }
|
|
|
- }
|
|
|
- //分解表头
|
|
|
- String[] dataHeader = dataName.toString().split(",");
|
|
|
- for (String header : dataHeader) {
|
|
|
- if (header.contains("WS") && !header.contains("-")) {
|
|
|
- int i = header.lastIndexOf("_");
|
|
|
- //截取带层高的字符串
|
|
|
- String substring = header.substring(i);
|
|
|
- String height = CalculationUtil.getNumberFromString(substring);
|
|
|
- wsHeight.append(height);
|
|
|
- wsHeight.append(",");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (header.contains("WD") && !header.contains("-")) {
|
|
|
- int i = header.lastIndexOf("_");
|
|
|
- //截取带层高的字符串
|
|
|
- String substring = header.substring(i);
|
|
|
- wdHeight.append(CalculationUtil.getNumberFromString(substring));
|
|
|
- wdHeight.append(",");
|
|
|
- }
|
|
|
- }
|
|
|
- //删除最后一个逗号
|
|
|
- //风速 TODO 入库 目前缺少测风塔编号、记录仪编号、经纬度
|
|
|
- String wsStr = wsHeight.substring(0, wsHeight.length() - 1);
|
|
|
- //风向 TODO 入库
|
|
|
- String wdStr = wdHeight.substring(0, wdHeight.length() - 1);
|
|
|
-
|
|
|
- //把创建的表格写入到输出流中,并关闭输出流
|
|
|
- wb.write(ops);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- } finally {
|
|
|
- if (wb != null) {
|
|
|
- try {
|
|
|
- wb.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- if (ips != null) {
|
|
|
- try {
|
|
|
- ips.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- if (ops != null) {
|
|
|
- try {
|
|
|
- ops.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //转换文件夹中所有文件类型
|
|
|
- public void ConversionType() {
|
|
|
- File file = new File("D:\\txt\\txt");
|
|
|
- String fileName = "";
|
|
|
- if (file.isDirectory()) {
|
|
|
- File[] files = file.listFiles();
|
|
|
- if (files != null) {
|
|
|
- for (File file1 : files) {
|
|
|
- String name = file1.getName();
|
|
|
- int i = name.lastIndexOf(".");
|
|
|
- if (name.substring(i).contains("wnd")) {
|
|
|
- //获取文件名
|
|
|
- fileName = name.substring(0, i);
|
|
|
- file1.renameTo(new File(file1.getParentFile() + "\\" + fileName + ".txt"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- @Test
|
|
|
- public void WindShearFit () {
|
|
|
-// homePageService.homePageCharts("006172");
|
|
|
- try {
|
|
|
-
|
|
|
- // 输入数据:高度和风切变指数
|
|
|
- double[] height = {500, 1000, 1500, 2000, 2500};
|
|
|
- double[] ehi = {1.5, 3.0, 4.5, 3.0, 1.5};
|
|
|
-
|
|
|
- // 使用WeightedObservedPoints类来存储输入数据
|
|
|
- WeightedObservedPoints obs = new WeightedObservedPoints();
|
|
|
- for (int i = 0; i < height.length; i++) {
|
|
|
- obs.add(height[i], ehi[i]);
|
|
|
- }
|
|
|
- // 使用PolynomialCurveFitter类进行二次拟合
|
|
|
- PolynomialCurveFitter fitter = PolynomialCurveFitter.create(2);
|
|
|
- double[] coefficients = fitter.fit(obs.toList());
|
|
|
-
|
|
|
- // 输出拟合曲线的系数
|
|
|
- System.out.println("拟合曲线系数: a = " + coefficients[2] + ", b = " + coefficients[1] + ", c = " + coefficients[0]);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
+//package service;
|
|
|
+//
|
|
|
+//import com.jiayue.NeimApplication;
|
|
|
+//import com.jiayue.biz.domain.*;
|
|
|
+//import com.jiayue.biz.service.StatisticsSituationService;
|
|
|
+//import com.jiayue.biz.service.WindTowerInfoService;
|
|
|
+//import com.jiayue.biz.service.impl.*;
|
|
|
+//import com.jiayue.biz.util.CalculationUtil;
|
|
|
+//import com.jiayue.common.utils.DateUtil;
|
|
|
+//import org.apache.commons.math3.fitting.PolynomialCurveFitter;
|
|
|
+//import org.apache.commons.math3.fitting.WeightedObservedPoints;
|
|
|
+//import org.apache.poi.xssf.streaming.SXSSFRow;
|
|
|
+//import org.apache.poi.xssf.streaming.SXSSFSheet;
|
|
|
+//import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
+//import org.junit.jupiter.api.Test;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+//import wei.yigulu.modbus.domain.FunctionCode;
|
|
|
+//import wei.yigulu.modbus.domain.Obj4RequestRegister;
|
|
|
+//import wei.yigulu.modbus.domain.datatype.IModbusDataType;
|
|
|
+//import wei.yigulu.modbus.domain.datatype.ModbusDataTypeEnum;
|
|
|
+//import wei.yigulu.modbus.domain.datatype.NumericModbusData;
|
|
|
+//import wei.yigulu.modbus.exceptiom.ModbusException;
|
|
|
+//import wei.yigulu.modbus.netty.ModbusTcpMasterBuilder;
|
|
|
+//import wei.yigulu.modbus.utils.ModbusRequestDataUtils;
|
|
|
+//
|
|
|
+//import java.io.*;
|
|
|
+//import java.math.BigDecimal;
|
|
|
+//import java.math.RoundingMode;
|
|
|
+//import java.util.*;
|
|
|
+//import java.util.stream.Collectors;
|
|
|
+//
|
|
|
+///**
|
|
|
+// * 删除上报日志测试类
|
|
|
+// *
|
|
|
+// * @author xsl
|
|
|
+// * @version 3.0
|
|
|
+// */
|
|
|
+//@SpringBootTest(classes = NeimApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
|
+//public class DeleteUploadLogServiceTest {
|
|
|
+// @Autowired
|
|
|
+// WindTowerInfoService windTowerInfoService;
|
|
|
+// @Autowired
|
|
|
+// AnalysisLogServiceImpl analysisLogService;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// HomePageServiceImpl homePageService;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// WindTowerDataChildTableServiceImpl windTowerDataChildTableService;
|
|
|
+// @Autowired
|
|
|
+// WindTowerCalculationDataServiceImpl windTowerCalculationDataService;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// WsWdServiceImpl wsWdService;
|
|
|
+// @Autowired
|
|
|
+// TurbulenceServiceImpl turbulenceService;
|
|
|
+// @Autowired
|
|
|
+// PdfServiceImpl pdfService;
|
|
|
+// @Autowired
|
|
|
+// EquipmentAttributeServiceImpl equipmentAttributeService;
|
|
|
+// @Autowired
|
|
|
+// WindTowerDataParentTableServiceImpl windTowerDataParentTableService;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// StatisticsSituationService statisticsSituationService;
|
|
|
+//
|
|
|
+// public static void main(String[] args) throws Exception {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void mains() {
|
|
|
+//// homePageService. getWsAndWpdForHeight("006174");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void homePageCharts() {
|
|
|
+//// homePageService.getWsAndWpdForHeight("006174");
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// public void saveData(HashMap<String, BigDecimal> dataMap, HashSet<Integer> heightSet) {
|
|
|
+// WindTowerDataParentTable windTowerDataParentTable = new WindTowerDataParentTable();
|
|
|
+// List<WindTowerInfo> windTowerInfos = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getType, "2").eq(WindTowerInfo::getEquipmentNo, "3002").list();
|
|
|
+// String id = String.valueOf(UUID.randomUUID());
|
|
|
+// List<EquipmentAttribute> equipmentAttributes = equipmentAttributeService.lambdaQuery().eq(EquipmentAttribute::getAttributeFunction, "height").list();
|
|
|
+// List<WindTowerDataChildTable> windTowerDataChildTableList = new ArrayList<>();
|
|
|
+// for (Integer height : heightSet) {
|
|
|
+// List<EquipmentAttribute> eqHeight = equipmentAttributes.stream().filter(e -> e.getFieldName().equals(height.toString())).collect(Collectors.toList());
|
|
|
+// WindTowerDataChildTable windTowerDataChildTable = new WindTowerDataChildTable();
|
|
|
+// windTowerDataChildTable.setParentId(id);
|
|
|
+// windTowerDataChildTable.setLayerHeight(eqHeight.get(0).getId());
|
|
|
+// windTowerDataChildTable.setWsAve(CalculationUtil.getBigDecimal(dataMap.get("wsAve" + height) == null ? null : dataMap.get("wsAve" + height).toString()));
|
|
|
+// windTowerDataChildTable.setWsMin(CalculationUtil.getBigDecimal(dataMap.get("wsMin" + height) == null ? null : dataMap.get("wsMin" + height).toString()));
|
|
|
+// windTowerDataChildTable.setWsMax(CalculationUtil.getBigDecimal(dataMap.get("wsMax" + height) == null ? null : dataMap.get("wsMax" + height).toString()));
|
|
|
+// windTowerDataChildTable.setWsSta(CalculationUtil.getBigDecimal(dataMap.get("wsSta" + height) == null ? null : dataMap.get("wsSta" + height).toString()));
|
|
|
+// windTowerDataChildTable.setWsInst(CalculationUtil.getBigDecimal(dataMap.get("wsInst" + height) == null ? null : dataMap.get("wsInst" + height).toString()));
|
|
|
+// windTowerDataChildTable.setWsGust(CalculationUtil.getBigDecimal(dataMap.get("wsGust" + height) == null ? null : dataMap.get("wsGust" + height).toString()));
|
|
|
+// windTowerDataChildTable.setWdAve(CalculationUtil.getBigDecimal(dataMap.get("wdAve" + height) == null ? null : dataMap.get("wdAve" + height).toString()));
|
|
|
+// windTowerDataChildTable.setWdMax(CalculationUtil.getBigDecimal(dataMap.get("wdMax" + height) == null ? null : dataMap.get("wdMax" + height).toString()));
|
|
|
+// windTowerDataChildTable.setWdMin(CalculationUtil.getBigDecimal(dataMap.get("wdMin" + height) == null ? null : dataMap.get("wdMin" + height).toString()));
|
|
|
+// windTowerDataChildTable.setWdSta(CalculationUtil.getBigDecimal(dataMap.get("wdSta" + height) == null ? null : dataMap.get("wdSta" + height).toString()));
|
|
|
+// windTowerDataChildTable.setWdInst(CalculationUtil.getBigDecimal(dataMap.get("wdInst" + height) == null ? null : dataMap.get("wdInst" + height).toString()));
|
|
|
+// windTowerDataChildTableList.add(windTowerDataChildTable);
|
|
|
+// }
|
|
|
+//
|
|
|
+// windTowerDataParentTable.setEquipmentId(windTowerInfos.get(0).getEquipmentNo());
|
|
|
+// windTowerDataParentTable.setId(id);
|
|
|
+// String time = dataMap.get("yyyy").toString() + (dataMap.get("MM")) + (dataMap.get("dd")) + (dataMap.get("HH")) + (dataMap.get("mm")) + (dataMap.get("ss"));
|
|
|
+// //TODO 目前不知道接收的数据长什么样
|
|
|
+// windTowerDataParentTable.setTime(DateUtil.parseDate(time));
|
|
|
+// if (dataMap.get("paMax") != null)
|
|
|
+// //kpa转hpa
|
|
|
+// if (BigDecimal.valueOf(Double.parseDouble(dataMap.get("paMax").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
+// windTowerDataParentTable.setPaMax(CalculationUtil.getBigDecimal(dataMap.get("paMax").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
+// else
|
|
|
+// windTowerDataParentTable.setPaMax(CalculationUtil.getBigDecimal(dataMap.get("paMax").toString()));
|
|
|
+// if (dataMap.get("paMin") != null)
|
|
|
+// //kpa转hpa
|
|
|
+// if (BigDecimal.valueOf(Double.parseDouble(dataMap.get("paMin").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
+// windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(dataMap.get("paMin").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
+// else
|
|
|
+// windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(dataMap.get("paMin").toString()));
|
|
|
+// if (dataMap.get("paInst") != null)
|
|
|
+// //kpa转hpa
|
|
|
+// if (BigDecimal.valueOf(Double.parseDouble(dataMap.get("paInst").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
+// windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(dataMap.get("paInst").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
+// else
|
|
|
+// windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(dataMap.get("paInst").toString()));
|
|
|
+// if (dataMap.get("paAve") != null)
|
|
|
+// //kpa转hpa
|
|
|
+// if (BigDecimal.valueOf(Double.parseDouble(dataMap.get("paAve").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
+// windTowerDataParentTable.setPaAve(CalculationUtil.getBigDecimal(dataMap.get("paAve").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
+// else
|
|
|
+// windTowerDataParentTable.setPaAve(CalculationUtil.getBigDecimal(dataMap.get("paAve").toString()));
|
|
|
+// windTowerDataParentTable.setPaSta(CalculationUtil.getBigDecimal(dataMap.get("paSta") == null ? null : dataMap.get("paSta").toString()));
|
|
|
+// windTowerDataParentTable.setTMax(CalculationUtil.getBigDecimal(dataMap.get("tMax") == null ? null : dataMap.get("tMax").toString()));
|
|
|
+// windTowerDataParentTable.setTMin(CalculationUtil.getBigDecimal(dataMap.get("tMin") == null ? null : dataMap.get("tMin").toString()));
|
|
|
+// windTowerDataParentTable.setTAve(CalculationUtil.getBigDecimal(dataMap.get("tAve") == null ? null : dataMap.get("tAve").toString()));
|
|
|
+// windTowerDataParentTable.setTSta(CalculationUtil.getBigDecimal(dataMap.get("tSta") == null ? null : dataMap.get("tSta").toString()));
|
|
|
+// windTowerDataParentTable.setTInst(CalculationUtil.getBigDecimal(dataMap.get("tInst") == null ? null : dataMap.get("tInst").toString()));
|
|
|
+// windTowerDataParentTable.setRhMax(CalculationUtil.getBigDecimal(dataMap.get("rhMax") == null ? null : dataMap.get("rhMax").toString()));
|
|
|
+// windTowerDataParentTable.setRhMin(CalculationUtil.getBigDecimal(dataMap.get("rhMin") == null ? null : dataMap.get("rhMin").toString()));
|
|
|
+// windTowerDataParentTable.setRhAve(CalculationUtil.getBigDecimal(dataMap.get("rhAve") == null ? null : dataMap.get("rhAve").toString()));
|
|
|
+// windTowerDataParentTable.setRhSta(CalculationUtil.getBigDecimal(dataMap.get("rhSta") == null ? null : dataMap.get("rhSta").toString()));
|
|
|
+// windTowerDataParentTable.setRhInst(CalculationUtil.getBigDecimal(dataMap.get("rhInst") == null ? null : dataMap.get("rhInst").toString()));
|
|
|
+//
|
|
|
+// windTowerDataParentTable.setVMax(CalculationUtil.getBigDecimal(dataMap.get("vMax") == null ? null : dataMap.get("vMax").toString()));
|
|
|
+// windTowerDataParentTable.setVMin(CalculationUtil.getBigDecimal(dataMap.get("vMin") == null ? null : dataMap.get("vhMin").toString()));
|
|
|
+// windTowerDataParentTable.setVAve(CalculationUtil.getBigDecimal(dataMap.get("vAve") == null ? null : dataMap.get("vhAve").toString()));
|
|
|
+// windTowerDataParentTable.setVSta(CalculationUtil.getBigDecimal(dataMap.get("vSta") == null ? null : dataMap.get("vhSta").toString()));
|
|
|
+// windTowerDataParentTable.setVInst(CalculationUtil.getBigDecimal(dataMap.get("vInst") == null ? null : dataMap.get("vInst").toString()));
|
|
|
+//
|
|
|
+// //计算空气密度
|
|
|
+// if (dataMap.get("TAve") != null && dataMap.get("paAve") != null) {
|
|
|
+// BigDecimal airDensity = BigDecimal.valueOf(1.293).multiply(new BigDecimal(273).divide(new BigDecimal(273).add(dataMap.get("TAve")), 2, RoundingMode.HALF_UP)).multiply(dataMap.get("paAve")).divide(new BigDecimal(1013), 2, RoundingMode.HALF_UP);
|
|
|
+// windTowerDataParentTable.setAirDensity(airDensity);
|
|
|
+// }
|
|
|
+// // TODO 目前没有异常数据校验
|
|
|
+//// windTowerDataParentTable.setAbnormalData(dataMap.get("abnormalData") == null ? null : dataMap.get("abnormalData").toString());
|
|
|
+//// windTowerDataParentTable.setAbnormalType(dataMap.get("abnormalType") == null ? null : dataMap.get("abnormalType").toString());
|
|
|
+//// windTowerDataParentTableList.add(windTowerDataParentTable);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void main() {
|
|
|
+// System.out.println("DateUtil.formatTime(new Date()) = " + DateUtil.formatTime(new Date()));
|
|
|
+//// List<EquipmentAttribute> awsDay = equipmentAttributeService.lambdaQuery().like(EquipmentAttribute::getFieldName, "awsDay").list();
|
|
|
+//// List<WindTowerCalculationData> byBetweenTimeAndEquipmentId = windTowerCalculationDataService.getByBetweenTimeAndEquipmentId();
|
|
|
+// windTowerDataParentTableService.selectDataByBetweenTimeAndEquipmetId(new Date(1659283200000l), new Date(1661961600000l), "006173");
|
|
|
+// System.out.println("DateUtil.formatTime(new Date()) = " + DateUtil.formatTime(new Date()));
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void test() {
|
|
|
+// //TODO 两个路径需要变化
|
|
|
+// String exl = "D:\\txt\\";
|
|
|
+// File file = new File("D:\\txt\\txt");
|
|
|
+// //将wnd文件转换成txt文件
|
|
|
+// ConversionType();
|
|
|
+// File[] files = file.listFiles();
|
|
|
+// if (files != null) {
|
|
|
+// for (File file1 : files) {
|
|
|
+// int index = file1.getName().lastIndexOf(".");
|
|
|
+// //转换excel路径
|
|
|
+// String excelFile = exl + file1.getName().substring(0, index) + ".xls";
|
|
|
+// /*实例化输入、输出流*/
|
|
|
+// //输入文件
|
|
|
+// File f_in = new File(file1.getPath());
|
|
|
+// FileInputStream ips = null;
|
|
|
+// InputStreamReader ipsr = null;
|
|
|
+// //输出文件
|
|
|
+// File f_out = new File(excelFile);
|
|
|
+// FileOutputStream ops = null;
|
|
|
+// try {
|
|
|
+// ips = new FileInputStream(f_in);
|
|
|
+// ipsr = new InputStreamReader(ips);
|
|
|
+// ops = new FileOutputStream(f_out);
|
|
|
+// } catch (FileNotFoundException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// /*创建excel表格文件并输出*/
|
|
|
+// //创建工作薄
|
|
|
+// SXSSFWorkbook wb = new SXSSFWorkbook();
|
|
|
+// try {
|
|
|
+// //创建新的一页
|
|
|
+// SXSSFSheet sheet = wb.createSheet("new sheet");
|
|
|
+// BufferedReader br = new BufferedReader(ipsr);
|
|
|
+// String valueString = null;
|
|
|
+// //记录有效行
|
|
|
+// int count_line = 0;
|
|
|
+// int total = 0;
|
|
|
+// StringBuffer wsHeight = new StringBuffer();
|
|
|
+// StringBuffer wdHeight = new StringBuffer();
|
|
|
+// StringBuilder dataName = new StringBuilder();
|
|
|
+//
|
|
|
+// while ((valueString = br.readLine()) != null) {
|
|
|
+// if (valueString.contains("Date")) {
|
|
|
+// total++;
|
|
|
+// }
|
|
|
+// if (total == 2) {
|
|
|
+// //分解每一行有效行 去除两边的空格
|
|
|
+// String[] strs_cell = valueString.trim().split("\\s+");
|
|
|
+// //生成行
|
|
|
+// SXSSFRow row = sheet.createRow((short) count_line);
|
|
|
+// for (int i = 0; i < strs_cell.length; i++) {//循环每个切割得到的数据,除了最后一个(,,,)和第一个(空)
|
|
|
+// //创建要显示的内容,创建一个单元格,第一个参数为列坐标,第二个参数为行坐标,第三个参数为内容
|
|
|
+// //生成列并插入数据
|
|
|
+// row.createCell((short) i).setCellValue(strs_cell[i]);
|
|
|
+// //所有表头
|
|
|
+// if (!dataName.toString().equals("")) {
|
|
|
+// dataName.append(",");
|
|
|
+// dataName.append(strs_cell[i]);
|
|
|
+// } else {
|
|
|
+// dataName.append(strs_cell[i]);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// count_line++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //分解表头
|
|
|
+// String[] dataHeader = dataName.toString().split(",");
|
|
|
+// for (String header : dataHeader) {
|
|
|
+// if (header.contains("WS") && !header.contains("-")) {
|
|
|
+// int i = header.lastIndexOf("_");
|
|
|
+// //截取带层高的字符串
|
|
|
+// String substring = header.substring(i);
|
|
|
+// String height = CalculationUtil.getNumberFromString(substring);
|
|
|
+// wsHeight.append(height);
|
|
|
+// wsHeight.append(",");
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (header.contains("WD") && !header.contains("-")) {
|
|
|
+// int i = header.lastIndexOf("_");
|
|
|
+// //截取带层高的字符串
|
|
|
+// String substring = header.substring(i);
|
|
|
+// wdHeight.append(CalculationUtil.getNumberFromString(substring));
|
|
|
+// wdHeight.append(",");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //删除最后一个逗号
|
|
|
+// //风速 TODO 入库 目前缺少测风塔编号、记录仪编号、经纬度
|
|
|
+// String wsStr = wsHeight.substring(0, wsHeight.length() - 1);
|
|
|
+// //风向 TODO 入库
|
|
|
+// String wdStr = wdHeight.substring(0, wdHeight.length() - 1);
|
|
|
+//
|
|
|
+// //把创建的表格写入到输出流中,并关闭输出流
|
|
|
+// wb.write(ops);
|
|
|
+// } catch (IOException e) {
|
|
|
+// throw new RuntimeException(e);
|
|
|
+// } finally {
|
|
|
+// if (wb != null) {
|
|
|
+// try {
|
|
|
+// wb.close();
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (ips != null) {
|
|
|
+// try {
|
|
|
+// ips.close();
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (ops != null) {
|
|
|
+// try {
|
|
|
+// ops.close();
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// //转换文件夹中所有文件类型
|
|
|
+// public void ConversionType() {
|
|
|
+// File file = new File("D:\\txt\\txt");
|
|
|
+// String fileName = "";
|
|
|
+// if (file.isDirectory()) {
|
|
|
+// File[] files = file.listFiles();
|
|
|
+// if (files != null) {
|
|
|
+// for (File file1 : files) {
|
|
|
+// String name = file1.getName();
|
|
|
+// int i = name.lastIndexOf(".");
|
|
|
+// if (name.substring(i).contains("wnd")) {
|
|
|
+// //获取文件名
|
|
|
+// fileName = name.substring(0, i);
|
|
|
+// file1.renameTo(new File(file1.getParentFile() + "\\" + fileName + ".txt"));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// @Test
|
|
|
+// public void WindShearFit () {
|
|
|
+//// homePageService.homePageCharts("006172");
|
|
|
+// try {
|
|
|
+//
|
|
|
+// // 输入数据:高度和风切变指数
|
|
|
+// double[] height = {500, 1000, 1500, 2000, 2500};
|
|
|
+// double[] ehi = {1.5, 3.0, 4.5, 3.0, 1.5};
|
|
|
+//
|
|
|
+// // 使用WeightedObservedPoints类来存储输入数据
|
|
|
+// WeightedObservedPoints obs = new WeightedObservedPoints();
|
|
|
+// for (int i = 0; i < height.length; i++) {
|
|
|
+// obs.add(height[i], ehi[i]);
|
|
|
+// }
|
|
|
+// // 使用PolynomialCurveFitter类进行二次拟合
|
|
|
+// PolynomialCurveFitter fitter = PolynomialCurveFitter.create(2);
|
|
|
+// double[] coefficients = fitter.fit(obs.toList());
|
|
|
+//
|
|
|
+// // 输出拟合曲线的系数
|
|
|
+// System.out.println("拟合曲线系数: a = " + coefficients[2] + ", b = " + coefficients[1] + ", c = " + coefficients[0]);
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//}
|