|
@@ -229,275 +229,6 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * 组装数据
|
|
|
|
- *
|
|
|
|
- * @param allData 数据
|
|
|
|
- * @param equipmentId 设备编号
|
|
|
|
- * @param eTime 时间
|
|
|
|
- * @param type 文件类型
|
|
|
|
- * @param operation 操作类型(DataRecalculation数据重算)
|
|
|
|
- */
|
|
|
|
- public void packageData1(List<Map<String, Object>> allData, String equipmentId, String eTime, String type, String operation) {
|
|
|
|
-
|
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
|
|
|
- if (type.equals("rld")) {
|
|
|
|
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
- }
|
|
|
|
- if (type.equals("sld")) {
|
|
|
|
- simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmm");
|
|
|
|
- }
|
|
|
|
- String eqNo = equipmentId;
|
|
|
|
- List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.list();
|
|
|
|
- List<EquipmentAttribute> heightList = equipmentAttributeList.stream().filter(e -> "height".equals(e.getAttributeFunction())).collect(Collectors.toList());
|
|
|
|
- List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list();
|
|
|
|
- List<WindTowerInfo> windTowerInfo = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(eqNo)).collect(Collectors.toList());
|
|
|
|
- String windTowerInfoHeights = windTowerInfo.get(0).getHeights();
|
|
|
|
- String windTowerInfoWdHeights = windTowerInfo.get(0).getWdHeights();
|
|
|
|
- String[] wdHeight = windTowerInfoWdHeights.split(",");
|
|
|
|
- String[] heights = windTowerInfoHeights.split(",");
|
|
|
|
- HashSet<String> heightAll = new HashSet<>();
|
|
|
|
- heightAll.addAll(Arrays.asList(wdHeight));
|
|
|
|
- heightAll.addAll(Arrays.asList(heights));
|
|
|
|
- //层高
|
|
|
|
- List<WindTowerDataParentTable> windTowerDataParentTableList = new ArrayList<>();
|
|
|
|
- List<WindTowerDataChildTable> windTowerDataChildTableList = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- //所有数据
|
|
|
|
- if (operation.equals("DataRecalculation")) {
|
|
|
|
- for (Map<String, Object> m : allData) {
|
|
|
|
- WindTowerDataParentTable windTowerDataParentTable = new WindTowerDataParentTable();
|
|
|
|
- UUID uuid = UUID.randomUUID();
|
|
|
|
- for (String height : heightAll) {
|
|
|
|
- //层高对应的属性
|
|
|
|
- List<EquipmentAttribute> eqHeight = heightList.stream().filter(h -> height.equals(h.getFieldName())).collect(Collectors.toList());
|
|
|
|
- //组装子表数据
|
|
|
|
- WindTowerDataChildTable windTowerDataChildTable = new WindTowerDataChildTable();
|
|
|
|
- windTowerDataChildTable.setParentId(uuid.toString());
|
|
|
|
- windTowerDataChildTable.setLayerHeight(eqHeight.get(0).getId());
|
|
|
|
- windTowerDataChildTable.setWsAve(CalculationUtil.getBigDecimal(m.get("ws_ave" + height) == null ? null : m.get("ws_ave" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWsMin(CalculationUtil.getBigDecimal(m.get("ws_min" + height) == null ? null : m.get("ws_min" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWsMax(CalculationUtil.getBigDecimal(m.get("ws_max" + height) == null ? null : m.get("ws_max" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWsSta(CalculationUtil.getBigDecimal(m.get("ws_sta" + height) == null ? null : m.get("ws_sta" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWdAve(CalculationUtil.getBigDecimal(m.get("wd_ave" + height) == null ? null : m.get("wd_ave" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWdMax(CalculationUtil.getBigDecimal(m.get("wd_max" + height) == null ? null : m.get("wd_max" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWdMin(CalculationUtil.getBigDecimal(m.get("wd_min" + height) == null ? null : m.get("wd_min" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWdSta(CalculationUtil.getBigDecimal(m.get("wd_sta" + height) == null ? null : m.get("wd_sta" + height).toString()));
|
|
|
|
- windTowerDataChildTableList.add(windTowerDataChildTable);
|
|
|
|
- }
|
|
|
|
- //组装父表数据
|
|
|
|
- windTowerDataParentTable.setEquipmentId(equipmentId);
|
|
|
|
- windTowerDataParentTable.setId(uuid.toString());
|
|
|
|
- if (m.get("time") != null)
|
|
|
|
- try {
|
|
|
|
- try {
|
|
|
|
- windTowerDataParentTable.setTime(simpleDateFormat.parse(m.get("time").toString()));
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
-
|
|
|
|
- windTowerDataParentTable.setTime(new Date(Long.parseLong(m.get("time").toString())));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("时间转换异常:" + e);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (m.get("paMax") != null)
|
|
|
|
- //kpa转hpa
|
|
|
|
- if (BigDecimal.valueOf(Double.parseDouble(m.get("pa_max").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
|
- windTowerDataParentTable.setPaMax(CalculationUtil.getBigDecimal(m.get("pa_max").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
|
- else
|
|
|
|
- windTowerDataParentTable.setPaMax(CalculationUtil.getBigDecimal(m.get("pa_max").toString()));
|
|
|
|
- if (m.get("pa_min") != null)
|
|
|
|
- //kpa转hpa
|
|
|
|
- if (BigDecimal.valueOf(Double.parseDouble(m.get("pa_min").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
|
- windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(m.get("pa_min").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
|
- else
|
|
|
|
- windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(m.get("pa_min").toString()));
|
|
|
|
- if (m.get("pa_ave") != null)
|
|
|
|
- //kpa转hpa
|
|
|
|
- if (BigDecimal.valueOf(Double.parseDouble(m.get("pa_ave").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
|
- windTowerDataParentTable.setPaAve(CalculationUtil.getBigDecimal(m.get("pa_ave").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
|
- else
|
|
|
|
- windTowerDataParentTable.setPaAve(CalculationUtil.getBigDecimal(m.get("pa_ave").toString()));
|
|
|
|
- windTowerDataParentTable.setPaSta(CalculationUtil.getBigDecimal(m.get("pa_sta") == null ? null : m.get("pa_sta").toString()));
|
|
|
|
- windTowerDataParentTable.setTMax(CalculationUtil.getBigDecimal(m.get("t_max") == null ? null : m.get("t_max").toString()));
|
|
|
|
- windTowerDataParentTable.setTMin(CalculationUtil.getBigDecimal(m.get("t_min") == null ? null : m.get("t_min").toString()));
|
|
|
|
- windTowerDataParentTable.setTAve(CalculationUtil.getBigDecimal(m.get("t_ave") == null ? null : m.get("t_ave").toString()));
|
|
|
|
- windTowerDataParentTable.setTSta(CalculationUtil.getBigDecimal(m.get("t_sta") == null ? null : m.get("t_sta").toString()));
|
|
|
|
- windTowerDataParentTable.setRhMax(CalculationUtil.getBigDecimal(m.get("rh_max") == null ? null : m.get("rh_max").toString()));
|
|
|
|
- windTowerDataParentTable.setRhMin(CalculationUtil.getBigDecimal(m.get("rh_min") == null ? null : m.get("rh_min").toString()));
|
|
|
|
- windTowerDataParentTable.setRhAve(CalculationUtil.getBigDecimal(m.get("rh_ave") == null ? null : m.get("rh_ave").toString()));
|
|
|
|
- windTowerDataParentTable.setRhSta(CalculationUtil.getBigDecimal(m.get("rh_sta") == null ? null : m.get("rh_sta").toString()));
|
|
|
|
- windTowerDataParentTable.setAbnormalData(m.get("abnormalData") == null ? null : m.get("abnormalData").toString());
|
|
|
|
- windTowerDataParentTable.setAbnormalType(m.get("abnormalType") == null ? null : m.get("abnormalType").toString());
|
|
|
|
- windTowerDataParentTableList.add(windTowerDataParentTable);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- for (Map<String, Object> m : allData) {
|
|
|
|
- WindTowerDataParentTable windTowerDataParentTable = new WindTowerDataParentTable();
|
|
|
|
- UUID uuid = UUID.randomUUID();
|
|
|
|
- for (String height : heightAll) {
|
|
|
|
- //层高对应的属性
|
|
|
|
- List<EquipmentAttribute> eqHeight = heightList.stream().filter(h -> height.equals(h.getFieldName())).collect(Collectors.toList());
|
|
|
|
- //组装子表数据
|
|
|
|
- WindTowerDataChildTable windTowerDataChildTable = new WindTowerDataChildTable();
|
|
|
|
- windTowerDataChildTable.setParentId(uuid.toString());
|
|
|
|
- windTowerDataChildTable.setLayerHeight(eqHeight.get(0).getId());
|
|
|
|
- windTowerDataChildTable.setWsAve(CalculationUtil.getBigDecimal(m.get("wsAve_" + height) == null ? null : m.get("wsAve_" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWsMin(CalculationUtil.getBigDecimal(m.get("wsMin_" + height) == null ? null : m.get("wsMin_" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWsMax(CalculationUtil.getBigDecimal(m.get("wsMax_" + height) == null ? null : m.get("wsMax_" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWsSta(CalculationUtil.getBigDecimal(m.get("wsSta_" + height) == null ? null : m.get("wsSta_" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWdAve(CalculationUtil.getBigDecimal(m.get("wdAve_" + height) == null ? null : m.get("wdAve_" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWdMax(CalculationUtil.getBigDecimal(m.get("wdMax_" + height) == null ? null : m.get("wdMax_" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWdMin(CalculationUtil.getBigDecimal(m.get("wdMin_" + height) == null ? null : m.get("wdMin_" + height).toString()));
|
|
|
|
- windTowerDataChildTable.setWdSta(CalculationUtil.getBigDecimal(m.get("wdSta_" + height) == null ? null : m.get("wdSta_" + height).toString()));
|
|
|
|
- windTowerDataChildTableList.add(windTowerDataChildTable);
|
|
|
|
- }
|
|
|
|
- //组装父表数据
|
|
|
|
- windTowerDataParentTable.setEquipmentId(equipmentId);
|
|
|
|
- windTowerDataParentTable.setId(uuid.toString());
|
|
|
|
- if (m.get("time") != null)
|
|
|
|
- try {
|
|
|
|
- try {
|
|
|
|
- windTowerDataParentTable.setTime(simpleDateFormat.parse(m.get("time").toString()));
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
-
|
|
|
|
- windTowerDataParentTable.setTime(new Date(Long.parseLong(m.get("time").toString())));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("时间转换异常:" + e);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (m.get("paMax") != null)
|
|
|
|
- //kpa转hpa
|
|
|
|
- if (BigDecimal.valueOf(Double.parseDouble(m.get("paMax").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
|
- windTowerDataParentTable.setPaMax(CalculationUtil.getBigDecimal(m.get("paMax").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
|
- else
|
|
|
|
- windTowerDataParentTable.setPaMax(CalculationUtil.getBigDecimal(m.get("paMax").toString()));
|
|
|
|
- if (m.get("paMin") != null)
|
|
|
|
- //kpa转hpa
|
|
|
|
- if (BigDecimal.valueOf(Double.parseDouble(m.get("paMin").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
|
- windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(m.get("paMin").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
|
- else
|
|
|
|
- windTowerDataParentTable.setPaMin(CalculationUtil.getBigDecimal(m.get("paMin").toString()));
|
|
|
|
- if (m.get("paAve") != null)
|
|
|
|
- //kpa转hpa
|
|
|
|
- if (BigDecimal.valueOf(Double.parseDouble(m.get("paAve").toString())).compareTo(new BigDecimal(200)) < 0)
|
|
|
|
- windTowerDataParentTable.setPaAve(CalculationUtil.getBigDecimal(m.get("paAve").toString()).multiply(new BigDecimal(10)).setScale(4, RoundingMode.HALF_UP));
|
|
|
|
- else
|
|
|
|
- windTowerDataParentTable.setPaAve(CalculationUtil.getBigDecimal(m.get("paAve").toString()));
|
|
|
|
- windTowerDataParentTable.setPaSta(CalculationUtil.getBigDecimal(m.get("paSta") == null ? null : m.get("paSta").toString()));
|
|
|
|
- windTowerDataParentTable.setTMax(CalculationUtil.getBigDecimal(m.get("tMax") == null ? null : m.get("tMax").toString()));
|
|
|
|
- windTowerDataParentTable.setTMin(CalculationUtil.getBigDecimal(m.get("tMin") == null ? null : m.get("tMin").toString()));
|
|
|
|
- windTowerDataParentTable.setTAve(CalculationUtil.getBigDecimal(m.get("tAve") == null ? null : m.get("tAve").toString()));
|
|
|
|
- windTowerDataParentTable.setTSta(CalculationUtil.getBigDecimal(m.get("tSta") == null ? null : m.get("tSta").toString()));
|
|
|
|
- windTowerDataParentTable.setRhMax(CalculationUtil.getBigDecimal(m.get("rhMax") == null ? null : m.get("rhMax").toString()));
|
|
|
|
- windTowerDataParentTable.setRhMin(CalculationUtil.getBigDecimal(m.get("rhMin") == null ? null : m.get("rhMin").toString()));
|
|
|
|
- windTowerDataParentTable.setRhAve(CalculationUtil.getBigDecimal(m.get("rhAve") == null ? null : m.get("rhAve").toString()));
|
|
|
|
- windTowerDataParentTable.setRhSta(CalculationUtil.getBigDecimal(m.get("rhSta") == null ? null : m.get("rhSta").toString()));
|
|
|
|
- windTowerDataParentTable.setAbnormalData(m.get("abnormalData") == null ? null : m.get("abnormalData").toString());
|
|
|
|
- windTowerDataParentTable.setAbnormalType(m.get("abnormalType") == null ? null : m.get("abnormalType").toString());
|
|
|
|
- windTowerDataParentTableList.add(windTowerDataParentTable);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("组装数据异常");
|
|
|
|
- }
|
|
|
|
- this.dataSave(windTowerDataParentTableList, windTowerDataChildTableList, equipmentId, eTime, type);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 数据计算入库
|
|
|
|
- *
|
|
|
|
- * @param windTowerDataParentTableList 父表数据
|
|
|
|
- * @param windTowerDataChildTableList 子表数据
|
|
|
|
- * @param
|
|
|
|
- */
|
|
|
|
- private void dataSave(List<WindTowerDataParentTable> windTowerDataParentTableList, List<WindTowerDataChildTable> windTowerDataChildTableList, String equipmentId, String eTime, String type) {
|
|
|
|
- //获取设备编号 006177_2022-03-28_00.00_000060.rld 006177为设备编号
|
|
|
|
- //应该是文件的时间而不是系统时间
|
|
|
|
- Date date = new Date();
|
|
|
|
- if (type.equals("rld")) {
|
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
- try {
|
|
|
|
- date = simpleDateFormat.parse(eTime);
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
- log.error("RLD转换文件名日期异常");
|
|
|
|
- }
|
|
|
|
- } else if (type.equals("sld")) {
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm");
|
|
|
|
- try {
|
|
|
|
- date = sdf.parse(eTime);
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
- log.error("RWD转换文件名异常");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
- try {
|
|
|
|
- date = sdf.parse(eTime);
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
- log.error("声雷达日期转换异常常");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- List<WindTowerDataParentTable> parentTableList = new ArrayList<>();
|
|
|
|
- List<WindTowerDataParentTable> parentTableCollect = windTowerDataParentTableList.stream().sorted(Comparator.comparing(WindTowerDataParentTable::getTime)).collect(Collectors.toList());
|
|
|
|
- List<Map<String, Object>> windTowerDataParentTables = selectDataByBetweenTimeAndEquipmetId(parentTableCollect.get(0).getTime(), parentTableCollect.get(parentTableCollect.size() - 1).getTime(), equipmentId);
|
|
|
|
- List<String> parentIdList = new ArrayList<>();
|
|
|
|
- if (!windTowerDataParentTables.isEmpty()) {
|
|
|
|
- for (Map<String, Object> map : windTowerDataParentTables) {
|
|
|
|
- if (!map.get("id").toString().isEmpty()) {
|
|
|
|
- parentIdList.add(map.get("id").toString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- windTowerDataChildTableService.deleteBetweenTimeAndEquipmentIdAndChild(parentIdList, equipmentId);
|
|
|
|
- deleteBetweenTimeAndEquipmentIdAndParent(DateTimeUtil.getDayStartTime(date.getTime()), DateTimeUtil.getDayLastTime(date.getTime()), equipmentId);
|
|
|
|
- }
|
|
|
|
- for (WindTowerDataParentTable w : parentTableCollect) {
|
|
|
|
- //计算空气密度 1.293*(273/(273+温度摄氏度))*气压百帕/1013
|
|
|
|
- if (w.getTAve() != null && w.getPaAve() != null) {
|
|
|
|
- BigDecimal airDensity = BigDecimal.valueOf(1.293).multiply(new BigDecimal(273).divide(new BigDecimal(273).add(w.getTAve()), 2, RoundingMode.HALF_UP)).multiply(w.getPaAve()).divide(new BigDecimal(1013), 2, RoundingMode.HALF_UP);
|
|
|
|
- w.setAirDensity(airDensity);
|
|
|
|
- }
|
|
|
|
- w.setEquipmentId(equipmentId);
|
|
|
|
- parentTableList.add(w);
|
|
|
|
- }
|
|
|
|
- saveBatchByEquipmentId(parentTableList, windTowerDataChildTableList, equipmentId);
|
|
|
|
- AnalysisLog analysisLog = new AnalysisLog();
|
|
|
|
- analysisLog.setStatus("1");
|
|
|
|
- analysisLog.setTime(date);
|
|
|
|
- analysisLog.setEquipmentId(equipmentId);
|
|
|
|
- analysisLogService.save(analysisLog);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("数据入库失败" + e);
|
|
|
|
- AnalysisLog analysisLog = new AnalysisLog();
|
|
|
|
- analysisLog.setStatus("2");
|
|
|
|
- analysisLog.setTime(date);
|
|
|
|
- analysisLog.setEquipmentId(equipmentId);
|
|
|
|
- analysisLogService.save(analysisLog);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 存多条数据
|
|
|
|
- *
|
|
|
|
- * @param windTowerDataParentTableList
|
|
|
|
- * @param windTowerDataChildTableList
|
|
|
|
- * @param equipmentId
|
|
|
|
- */
|
|
|
|
- public void saveBatchById(List<WindTowerDataParentTable> windTowerDataParentTableList, List<WindTowerDataChildTable> windTowerDataChildTableList, String equipmentId) {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("equipment_id", equipmentId);
|
|
|
|
- RequestDataHelper.setRequestData(map);
|
|
|
|
- windTowerDataChildTableService.saveBatchByEquipmentId(windTowerDataChildTableList, equipmentId);
|
|
|
|
- this.saveBatch(windTowerDataParentTableList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
//通道数据保存
|
|
//通道数据保存
|
|
public void saveDataForTunnel(HashMap<String, BigDecimal> dataMap, HashSet<Integer> heightSet, String equipmentNo, String time) {
|
|
public void saveDataForTunnel(HashMap<String, BigDecimal> dataMap, HashSet<Integer> heightSet, String equipmentNo, String time) {
|
|
Timestamp curentTimestamp = new Timestamp(DateUtil.parse(time).getTime());
|
|
Timestamp curentTimestamp = new Timestamp(DateUtil.parse(time).getTime());
|