|
@@ -3,7 +3,9 @@ package com.gyee.runeconomy.service.auto.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.gyee.common.model.StringUtils;
|
|
|
+import com.gyee.runeconomy.init.CacheContext;
|
|
|
import com.gyee.runeconomy.mapper.auto.ProEconSystemEfficiencyEquipmentMapper;
|
|
|
+import com.gyee.runeconomy.model.auto.ProBasicEquipment;
|
|
|
import com.gyee.runeconomy.model.auto.ProEconSystemEfficiencyEquipment;
|
|
|
import com.gyee.runeconomy.service.auto.IProEconSystemEfficiencyEquipmentService;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -13,6 +15,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
* <p>
|
|
@@ -50,36 +53,35 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
|
|
|
|
|
|
@Override
|
|
|
public List<ProEconSystemEfficiencyEquipment> getbq(String foreignKeyId, Date date) {
|
|
|
- QueryWrapper<ProEconSystemEfficiencyEquipment> qw = null;
|
|
|
-
|
|
|
List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
|
|
|
- if (null != date) {
|
|
|
- qw = new QueryWrapper<>();
|
|
|
- if (StringUtils.isNotEmpty(foreignKeyId)) {
|
|
|
- qw.lambda().eq(ProEconSystemEfficiencyEquipment::getStationId, foreignKeyId);
|
|
|
+ if (date != null) {
|
|
|
+ List<ProBasicEquipment> collect = CacheContext.wtls.stream()
|
|
|
+ .filter(wt -> foreignKeyId.equals(wt.getWindpowerstationId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (ProBasicEquipment wt : collect) {
|
|
|
+ QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(wt.getId())) {
|
|
|
+ qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
|
|
|
+ }
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
+ String dateString = sdf.format(date);
|
|
|
+ qw.lambda().apply("to_char(data_date, 'YYYY-MM') = '" + dateString + "'");
|
|
|
+ qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
|
|
|
+ List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
|
|
|
+ currlist.addAll(selectedList);
|
|
|
}
|
|
|
-
|
|
|
- String yearMonth = new SimpleDateFormat("yyyy-MM").format(date);
|
|
|
-
|
|
|
- String fixedDate = yearMonth + "-01";
|
|
|
- qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone >= to_timestamp('" + fixedDate + "', 'YYYY-MM-DD')");
|
|
|
- qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone < to_timestamp('" + fixedDate + "', 'YYYY-MM-DD') + interval '1 month'");
|
|
|
- qw.lambda().orderByAsc(ProEconSystemEfficiencyEquipment::getOrderNum);
|
|
|
- currlist = baseMapper.selectList(qw);
|
|
|
}
|
|
|
return currlist;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<ProEconSystemEfficiencyEquipment> gethb(String foreignKeyId, Date date) {
|
|
|
- QueryWrapper<ProEconSystemEfficiencyEquipment> qw = null;
|
|
|
-
|
|
|
+
|
|
|
List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
|
|
|
- if (null != date) {
|
|
|
- qw = new QueryWrapper<>();
|
|
|
- if (StringUtils.isNotEmpty(foreignKeyId)) {
|
|
|
- qw.lambda().eq(ProEconSystemEfficiencyEquipment::getStationId, foreignKeyId);
|
|
|
- }
|
|
|
+ if (date != null) {
|
|
|
+ List<ProBasicEquipment> collect = CacheContext.wtls.stream()
|
|
|
+ .filter(wt -> foreignKeyId.equals(wt.getWindpowerstationId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
@@ -87,15 +89,18 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
|
|
|
cal.add(Calendar.MONTH, -1);
|
|
|
Date previousMonth = cal.getTime();
|
|
|
|
|
|
-
|
|
|
- String yearMonth = new SimpleDateFormat("yyyy-MM").format(previousMonth);
|
|
|
-
|
|
|
-
|
|
|
- String fixedDate = yearMonth + "-01";
|
|
|
- qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone >= to_timestamp('" + fixedDate + "', 'YYYY-MM-DD')");
|
|
|
- qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone < to_timestamp('" + fixedDate + "', 'YYYY-MM-DD') + interval '1 month'");
|
|
|
- qw.lambda().orderByAsc(ProEconSystemEfficiencyEquipment::getOrderNum);
|
|
|
- currlist = baseMapper.selectList(qw);
|
|
|
+ for (ProBasicEquipment wt : collect) {
|
|
|
+ QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(wt.getId())) {
|
|
|
+ qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
|
|
|
+ }
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
+ String dateString = sdf.format(previousMonth);
|
|
|
+ qw.lambda().apply("to_char(data_date, 'YYYY-MM') = '" + dateString + "'");
|
|
|
+ qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
|
|
|
+ List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
|
|
|
+ currlist.addAll(selectedList);
|
|
|
+ }
|
|
|
}
|
|
|
return currlist;
|
|
|
}
|
|
@@ -103,27 +108,54 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
|
|
|
|
|
|
@Override
|
|
|
public List<ProEconSystemEfficiencyEquipment> gettb(String foreignKeyId, Date date) {
|
|
|
- QueryWrapper<ProEconSystemEfficiencyEquipment> qw = null;
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
|
|
|
- if (null != date) {
|
|
|
+ if (date != null) {
|
|
|
+ List<ProBasicEquipment> collect = CacheContext.wtls.stream()
|
|
|
+ .filter(wt -> foreignKeyId.equals(wt.getWindpowerstationId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
cal.setTime(date);
|
|
|
cal.add(Calendar.YEAR, -1);
|
|
|
Date oneYearAgo = cal.getTime();
|
|
|
|
|
|
- qw = new QueryWrapper<>();
|
|
|
- if (StringUtils.isNotEmpty(foreignKeyId)) {
|
|
|
- qw.lambda().eq(ProEconSystemEfficiencyEquipment::getStationId, foreignKeyId);
|
|
|
+ for (ProBasicEquipment wt : collect) {
|
|
|
+ QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(wt.getId())) {
|
|
|
+ qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
|
|
|
+ }
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
+ String dateString = sdf.format(oneYearAgo);
|
|
|
+ qw.lambda().apply("to_char(data_date, 'YYYY-MM') = '" + dateString + "'");
|
|
|
+ qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
|
|
|
+ List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
|
|
|
+ currlist.addAll(selectedList);
|
|
|
}
|
|
|
-
|
|
|
- String yearMonth = new SimpleDateFormat("yyyy-MM").format(oneYearAgo);
|
|
|
-
|
|
|
- String fixedDate = yearMonth + "-01";
|
|
|
- qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone >= to_timestamp('" + fixedDate + "', 'YYYY-MM-DD')");
|
|
|
- qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone < to_timestamp('" + fixedDate + "', 'YYYY-MM-DD') + interval '1 month'");
|
|
|
- qw.lambda().orderByAsc(ProEconSystemEfficiencyEquipment::getOrderNum);
|
|
|
- currlist = baseMapper.selectList(qw);
|
|
|
}
|
|
|
return currlist;
|
|
|
}
|