|
@@ -1,6 +1,7 @@
|
|
|
package com.jiayue.biz.service.impl;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -503,29 +504,19 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
|
|
|
String fieldName = "airDensityMonth";
|
|
|
List<EquipmentAttribute> densityTypeList = equipmentAttributeService.lambdaQuery().eq(EquipmentAttribute::getFieldName, fieldName).list();
|
|
|
String densityId = densityTypeList.get(0).getId();
|
|
|
- //设置年份用的
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
|
|
|
- //获取查询的年份
|
|
|
- int toYearStart = Integer.parseInt(sdf.format(startTime));
|
|
|
- int toYearEnd = Integer.parseInt(sdf.format(endTime));
|
|
|
+
|
|
|
+ DateTime startTimeYear = DateUtil.beginOfYear(new Date(startTime));
|
|
|
+ DateTime endTimeYear = DateUtil.endOfYear(new Date(endTime));
|
|
|
+ List<WindTowerCalculationData> byBetweenTimeAndEquipmentId = getByStartTimeBetweenAndEquipmentIdAndEbId(startTimeYear, endTimeYear, eqId,densityTypeList.get(0).getId());
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
|
|
|
ArrayList<Object> PDataList = new ArrayList<>();
|
|
|
- for (int i = toYearStart; i <= toYearEnd; i++) {
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.clear();
|
|
|
- calendar.set(Calendar.YEAR, i);
|
|
|
- //当前年的开始时间
|
|
|
- long startHour = calendar.getTimeInMillis();
|
|
|
- calendar.clear();
|
|
|
- calendar.set(Calendar.YEAR, i);
|
|
|
- calendar.roll(Calendar.DAY_OF_YEAR, -1);
|
|
|
- //当前年的结束时间
|
|
|
- long endHour = calendar.getTimeInMillis() - 1l;
|
|
|
+ for (long i = startTimeYear.getTime(); i <= endTimeYear.getTime(); i = DateUtil.offsetMonth(new Date(i), 12).getTime()) {
|
|
|
//开始时间
|
|
|
- Date startTimeOfCurrentMonth = SEDateUtil.getStartTimeOfCurrentDay(new Date(startHour));
|
|
|
+ Date startTimeOfCurrentMonth = DateUtil.beginOfYear(new Date(i));
|
|
|
//结束时间
|
|
|
- Date endTimeOfCurrentMonth = SEDateUtil.getEndTimeOfCurrentDay(new Date(endHour));
|
|
|
- List<WindTowerCalculationData> byBetweenTimeAndEquipmentId = getByBetweenTimeAndEquipmentId(startTimeOfCurrentMonth, endTimeOfCurrentMonth, eqId);
|
|
|
- List<WindTowerCalculationData> densityDataList = byBetweenTimeAndEquipmentId.stream().filter(w -> w.getEbId().equals(densityId)).sorted(Comparator.comparing(WindTowerCalculationData::getTime)).collect(Collectors.toList());
|
|
|
+ Date endTimeOfCurrentMonth = DateUtil.offsetMonth(new Date(i), 12);
|
|
|
+ List<WindTowerCalculationData> densityDataList = byBetweenTimeAndEquipmentId.stream().filter(w -> w.getTime().getTime() >= startTimeOfCurrentMonth.getTime() && w.getTime().getTime() <=endTimeOfCurrentMonth.getTime()&&
|
|
|
+ w.getEbId().equals(densityId)).sorted(Comparator.comparing(WindTowerCalculationData::getTime)).collect(Collectors.toList());
|
|
|
|
|
|
BigDecimal pSum = BigDecimal.ZERO;
|
|
|
|
|
@@ -534,7 +525,7 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
|
|
|
}
|
|
|
HashMap<Object, Object> PTMap = new HashMap<>();
|
|
|
if (!densityDataList.isEmpty()) {
|
|
|
- PTMap.put(i, pSum.divide(BigDecimal.valueOf(densityDataList.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ PTMap.put(simpleDateFormat.format(new Date(i)), pSum.divide(BigDecimal.valueOf(densityDataList.size()), 2, RoundingMode.HALF_UP));
|
|
|
|
|
|
}
|
|
|
for (Map.Entry<Object, Object> pt : PTMap.entrySet()) {
|
|
@@ -565,30 +556,25 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
|
|
|
ArrayList<Object> DataOneList = new ArrayList<>();
|
|
|
ArrayList<Object> DataTWOList = new ArrayList<>();
|
|
|
|
|
|
- Calendar calendar1 = Calendar.getInstance();
|
|
|
- calendar1.clear();
|
|
|
- calendar1.set(Calendar.YEAR, DateUtil.year(new Date(endTime)));
|
|
|
- calendar1.roll(Calendar.DAY_OF_YEAR, -1);
|
|
|
- //获取年份最后一天
|
|
|
- endTime = calendar1.getTime().getTime();
|
|
|
+
|
|
|
List<WindTowerInfo> windTowerInfos = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, eqId).list();
|
|
|
if (height == null || height.equals("")) {
|
|
|
height = windTowerInfos.get(0).getHeights();
|
|
|
}
|
|
|
|
|
|
- //设置年份用的
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
|
|
|
//获取查询的年份
|
|
|
- int toYearStart = Integer.parseInt(sdf.format(startTime));
|
|
|
- int toYearEnd = Integer.parseInt(sdf.format(endTime));
|
|
|
+ DateTime startTimeYear = DateUtil.beginOfYear(new Date(startTime));
|
|
|
+ DateTime endTimeYear = DateUtil.endOfYear(new Date(endTime));
|
|
|
|
|
|
- List<String> heightSort = new ArrayList<>();
|
|
|
|
|
|
String[] heightAll = height.split(",");
|
|
|
|
|
|
- List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.list();
|
|
|
- List<WindTowerCalculationData> windTowerCalculationDataList = getByBetweenTimeAndEquipmentId(new Date(startTime), new Date(endTime), eqId);
|
|
|
-
|
|
|
+ List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.lambdaQuery().likeLeft(EquipmentAttribute::getFieldName, "awsMonth").or().likeLeft(EquipmentAttribute::getFieldName, "awsMonth").list();
|
|
|
+ List<EquipmentAttribute> equipmentAttributeList1 = equipmentAttributeService.lambdaQuery().likeLeft(EquipmentAttribute::getFieldName, "wpdMonth").or().likeLeft(EquipmentAttribute::getFieldName, "awsMonth").list();
|
|
|
+ equipmentAttributeList.addAll(equipmentAttributeList1);
|
|
|
+// List<WindTowerCalculationData> windTowerCalculationDataList = getByBetweenTimeAndEquipmentId(new Date(startTime), new Date(endTime), eqId);
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDataList = this.getByBetweenTimeAndEquipmentIdAndEbId(new Date(startTime), new Date(endTime), eqId, equipmentAttributeList);
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
|
|
|
//遍历层高
|
|
|
for (String h : heightAll) {
|
|
|
//设置 层高+fieldName(数据库字段 50awsMonth)
|
|
@@ -597,40 +583,25 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
|
|
|
|
|
|
List<EquipmentAttribute> allWsFiledNameList = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals(fieldNameWs)).collect(Collectors.toList());
|
|
|
List<EquipmentAttribute> allWpdFiledNameList = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals(fieldNameWpd)).collect(Collectors.toList());
|
|
|
-
|
|
|
- //存放最后数据的map 防止重复数据 new外面
|
|
|
+ //存放最后数据的map
|
|
|
HashMap<Object, Object> map1 = new HashMap<>();
|
|
|
-
|
|
|
HashMap<String, Object> HDMap = new HashMap<>();
|
|
|
|
|
|
-
|
|
|
//年平均风速存放的list
|
|
|
ArrayList<Object> list = new ArrayList<>();
|
|
|
//年风功率密度存放的list
|
|
|
ArrayList<Object> list1 = new ArrayList<>();
|
|
|
- for (int i = toYearStart; i <= toYearEnd; i++) {
|
|
|
-
|
|
|
-
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.clear();
|
|
|
- calendar.set(Calendar.YEAR, i);
|
|
|
- //当前年的开始时间
|
|
|
- long startHour = calendar.getTimeInMillis();
|
|
|
- calendar.clear();
|
|
|
- calendar.set(Calendar.YEAR, i);
|
|
|
- calendar.roll(Calendar.DAY_OF_YEAR, -1);
|
|
|
- //当前年的结束时间
|
|
|
- long endHour = calendar.getTimeInMillis() - 1L;
|
|
|
+
|
|
|
+ for (long l = startTimeYear.getTime(); l <= endTimeYear.getTime(); l = DateUtil.offsetMonth(new Date(l), 12).getTime()) {
|
|
|
+
|
|
|
//开始时间
|
|
|
- Date startTimeOfCurrentMonth = SEDateUtil.getStartTimeOfCurrentDay(new Date(startHour));
|
|
|
+ Date startTimeOfCurrentMonth = DateUtil.beginOfYear(new Date(l));
|
|
|
//结束时间
|
|
|
- Date endTimeOfCurrentMonth = SEDateUtil.getEndTimeOfCurrentDay(new Date(endHour));
|
|
|
+ Date endTimeOfCurrentMonth = DateUtil.offsetMonth(new Date(l), 12);
|
|
|
|
|
|
|
|
|
if (!allWsFiledNameList.isEmpty()) {
|
|
|
String awsMonthEqId = allWsFiledNameList.get(0).getId();
|
|
|
-
|
|
|
-
|
|
|
List<WindTowerCalculationData> allDataWsList = windTowerCalculationDataList.stream().filter(w -> w.getEquipmentId().equals(eqId) && w.getEbId().equals(awsMonthEqId) &&
|
|
|
w.getTime().after(startTimeOfCurrentMonth) && w.getTime().before(endTimeOfCurrentMonth)).sorted(Comparator.comparing(WindTowerCalculationData::getTime)).collect(Collectors.toList());
|
|
|
BigDecimal wsYearData = BigDecimal.ZERO;
|
|
@@ -640,12 +611,12 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
|
|
|
HashMap<Object, Object> wsMap = new HashMap<>();
|
|
|
|
|
|
if (!allDataWsList.isEmpty()) {
|
|
|
- wsMap.put(i, wsYearData.divide(BigDecimal.valueOf(allDataWsList.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ wsMap.put(simpleDateFormat.format(new Date(l)), wsYearData.divide(BigDecimal.valueOf(allDataWsList.size()), 2, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
|
|
|
//给时间和年平均数值添加标识
|
|
|
for (Map.Entry<Object, Object> ws1 : wsMap.entrySet()) {
|
|
|
- HashMap<Object, Object> map = new HashMap<>();
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
map.put("time", ws1.getKey());
|
|
|
map.put("ws", ws1.getValue());
|
|
|
list.add(map);
|
|
@@ -659,8 +630,6 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
|
|
|
map1.put("arr", hd.getValue());
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
if (!allWpdFiledNameList.isEmpty()) {
|
|
|
String wpdMonthEqId = allWpdFiledNameList.get(0).getId();
|
|
@@ -673,7 +642,7 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
|
|
|
HashMap<Object, Object> wpdMap = new HashMap<>();
|
|
|
//添加时间
|
|
|
if (!allDataWpdList.isEmpty()) {
|
|
|
- wpdMap.put(i, wpdYearData.divide(BigDecimal.valueOf(allDataWpdList.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ wpdMap.put(simpleDateFormat.format(new Date(l)), wpdYearData.divide(BigDecimal.valueOf(allDataWpdList.size()), 2, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
|
|
|
for (Map.Entry<Object, Object> wpd1 : wpdMap.entrySet()) {
|
|
@@ -2540,7 +2509,6 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 空气密度月逐时入库
|
|
|
*
|