|
@@ -216,7 +216,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getIngTime(), b.getSelectricCurrent(), b.getPower(), b.getTopsPower(), b.getPeaksPower(), b.getFlatPower(), b.getValleysPower(),
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
- b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, null, null,null);
|
|
|
+ b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, null, null, null);
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(x -> x != null).collect(Collectors.toList());
|
|
@@ -369,7 +369,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getIngTime(), b.getSelectricCurrent(), b.getPower(), b.getTopsPower(), b.getPeaksPower(), b.getFlatPower(), b.getValleysPower(),
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
- b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, b.getRegionTitle(), mapDeviceType(a.getDeviceType()),"龙钢公司");
|
|
|
+ b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, b.getRegionTitle(), mapDeviceType(a.getDeviceType()), "龙钢公司");
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(x -> x != null).collect(Collectors.toList());
|
|
@@ -443,13 +443,31 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject electricityControl() {
|
|
|
+ public JSONObject electricityControl(ExportQueryDTO queryDTO) {
|
|
|
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
+ // 根据 queryDTO 中的 month 字段动态设置日期范围过滤
|
|
|
+ String month = queryDTO.getMonth();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ if (month == null || month.isEmpty()) {
|
|
|
+ // 如果 month 为空,则默认查询当前月份的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfMonth(1); // 当前月的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ } else {
|
|
|
+ // 解析传入的 month 参数
|
|
|
+ startDate = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
@@ -505,7 +523,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getIngTime(), b.getSelectricCurrent(), b.getPower(), b.getTopsPower(), b.getPeaksPower(), b.getFlatPower(), b.getValleysPower(),
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
- b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, b.getRegionTitle(), mapDeviceType(a.getDeviceType()),"龙钢公司");
|
|
|
+ b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, b.getRegionTitle(), mapDeviceType(a.getDeviceType()), "龙钢公司");
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(x -> x != null).collect(Collectors.toList());
|
|
@@ -772,12 +790,30 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject electricityControlDay() {
|
|
|
+ public JSONObject electricityControlDay(ExportQueryDTO queryDTO) {
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
+
|
|
|
+ // 根据 queryDTO 中的 month 字段动态设置日期范围过滤
|
|
|
+ String month = queryDTO.getMonth();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ if (month == null || month.isEmpty()) {
|
|
|
+ // 如果 month 为空,则默认查询当前月份的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfMonth(1); // 当前月的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ } else {
|
|
|
+ startDate = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
@@ -833,7 +869,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getIngTime(), b.getSelectricCurrent(), b.getPower(), b.getTopsPower(), b.getPeaksPower(), b.getFlatPower(), b.getValleysPower(),
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
- b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, b.getRegionTitle(), mapDeviceType(a.getDeviceType()),"龙钢公司");
|
|
|
+ b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, b.getRegionTitle(), mapDeviceType(a.getDeviceType()), "龙钢公司");
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(x -> x != null).collect(Collectors.toList());
|
|
@@ -1026,7 +1062,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
Collectors.mapping(ElectricityControlReport::getValue,
|
|
|
Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
|
|
|
|
|
|
- // 根据分组结果,将totalNum字段设置为对应的分组总和
|
|
|
+ // 根据分组结果,将totalNum字段设置为对应的分组总和
|
|
|
modelDataResults.forEach(report -> {
|
|
|
BigDecimal totalValueForGroup = groupedTotalValues.get(report.getCreateTime() + "_" + report.getDeviceTitle());
|
|
|
report.setTotalNum(totalValueForGroup); // 将分组总和赋值给totalNum// 计算占比(value / totalValueForGroup)
|
|
@@ -1049,12 +1085,30 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject electricityControlGxDay() {
|
|
|
+ public JSONObject electricityControlGxDay(ExportQueryDTO queryDTO) {
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
+ // 根据 queryDTO 中的 month 字段动态设置日期范围过滤
|
|
|
+ String month = queryDTO.getMonth();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ if (month == null || month.isEmpty()) {
|
|
|
+ // 如果 month 为空,则默认查询当前月份的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfMonth(1); // 当前月的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ } else {
|
|
|
+ // 解析传入的 month 参数
|
|
|
+ startDate = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
@@ -1125,7 +1179,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
Map<String, BigDecimal> dailyTotals = finalResult.stream()
|
|
|
.collect(Collectors.groupingBy(report -> {
|
|
|
String key = report.getCreateTime() + "_" + report.getRegionTitle();
|
|
|
- if (report.getDeviceTypeName()!= null &&!report.getDeviceTypeName().isEmpty()) {
|
|
|
+ if (report.getDeviceTypeName() != null && !report.getDeviceTypeName().isEmpty()) {
|
|
|
key += "_" + report.getDeviceTypeName();
|
|
|
}
|
|
|
return key;
|
|
@@ -1150,7 +1204,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
String yearFormattedDate = date.getYear() + "年";
|
|
|
|
|
|
String totalKey = createTime + "_" + regionTitle;
|
|
|
- if (deviceTypeName!= null &&!deviceTypeName.isEmpty()) {
|
|
|
+ if (deviceTypeName != null && !deviceTypeName.isEmpty()) {
|
|
|
totalKey += "_" + deviceTypeName;
|
|
|
}
|
|
|
BigDecimal dailyTotal = dailyTotals.get(totalKey); // 获取当天总值
|
|
@@ -1206,12 +1260,30 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject electricityControlFcDay() {
|
|
|
+ public JSONObject electricityControlFcDay(ExportQueryDTO queryDTO) {
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
+ // 根据 queryDTO 中的 month 字段动态设置日期范围过滤
|
|
|
+ String month = queryDTO.getMonth();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ if (month == null || month.isEmpty()) {
|
|
|
+ // 如果 month 为空,则默认查询当前月份的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfMonth(1); // 当前月的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ } else {
|
|
|
+ // 解析传入的 month 参数
|
|
|
+ startDate = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
@@ -1352,13 +1424,31 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject electricityControlGsDay() {
|
|
|
+ public JSONObject electricityControlGsDay(ExportQueryDTO queryDTO) {
|
|
|
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
+ // 根据 queryDTO 中的 month 字段动态设置日期范围过滤
|
|
|
+ String month = queryDTO.getMonth();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ if (month == null || month.isEmpty()) {
|
|
|
+ // 如果 month 为空,则默认查询当前月份的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfMonth(1); // 当前月的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ } else {
|
|
|
+ // 解析传入的 month 参数
|
|
|
+ startDate = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
@@ -1496,7 +1586,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject electricityControlMonth() {
|
|
|
+ public JSONObject electricityControlMonth(ExportQueryDTO queryDTO) {
|
|
|
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
@@ -1504,6 +1594,27 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+
|
|
|
+ // 获取 queryDTO 中的 year 字段
|
|
|
+ String year = queryDTO.getYear();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ // 判断是否传入了 year 参数
|
|
|
+ if (year == null || year.isEmpty()) {
|
|
|
+ // 如果 year 为空,默认查询当前年的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfYear(1); // 当前年的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ } else {
|
|
|
+ // 如果 year 不为空,解析 year 为年范围
|
|
|
+ startDate = LocalDate.parse(year + "-01-01", formatter); // 年份的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
+ // 查询数据
|
|
|
List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
|
if (oConvertUtils.listIsEmpty(fpgStatiscsModelDataList)) {
|
|
@@ -1556,7 +1667,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getIngTime(), b.getSelectricCurrent(), b.getPower(), b.getTopsPower(), b.getPeaksPower(), b.getFlatPower(), b.getValleysPower(),
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
- b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, b.getRegionTitle(), mapDeviceType(a.getDeviceType()),"龙钢公司");
|
|
|
+ b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, b.getRegionTitle(), mapDeviceType(a.getDeviceType()), "龙钢公司");
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(x -> x != null).collect(Collectors.toList());
|
|
@@ -1662,13 +1773,34 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject electricityControlGxMonth() {
|
|
|
+ public JSONObject electricityControlGxMonth(ExportQueryDTO queryDTO) {
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+
|
|
|
+ // 获取 queryDTO 中的 year 字段
|
|
|
+ String year = queryDTO.getYear();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ // 判断是否传入了 year 参数
|
|
|
+ if (year == null || year.isEmpty()) {
|
|
|
+ // 如果 year 为空,默认查询当前年的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfYear(1); // 当前年的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ } else {
|
|
|
+ // 如果 year 不为空,解析 year 为年范围
|
|
|
+ startDate = LocalDate.parse(year + "-01-01", formatter); // 年份的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
+ // 查询数据
|
|
|
List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
|
if (oConvertUtils.listIsEmpty(fpgStatiscsModelDataList)) {
|
|
@@ -1719,7 +1851,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
DeviceInformation deviceInfo = deviceInfoMap.get(data.getDeviceInformationId());
|
|
|
if (deviceInfo != null) {
|
|
|
ElectricityControlReport report = new ElectricityControlReport();
|
|
|
- LocalDate date = LocalDate.parse(DateUtils.date2Str(data.getCreateTime(), DateUtils.date_sdf.get()), formatter);
|
|
|
+ LocalDate date = LocalDate.parse(data.getDates(), formatter);
|
|
|
String monthStr = date.getYear() + "年" + date.getMonthValue() + "月";
|
|
|
report.setRegionTitle(data.getRegionTitle());
|
|
|
report.setDeviceTypeName(mapDeviceType(deviceInfo.getDeviceType()));
|
|
@@ -1741,7 +1873,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
Map<String, BigDecimal> monthTotals = finalResult.stream()
|
|
|
.collect(Collectors.groupingBy(report -> {
|
|
|
String key = report.getMonth() + "_" + report.getRegionTitle();
|
|
|
- if (report.getDeviceTypeName()!= null &&!report.getDeviceTypeName().isEmpty()) {
|
|
|
+ if (report.getDeviceTypeName() != null && !report.getDeviceTypeName().isEmpty()) {
|
|
|
key += "_" + report.getDeviceTypeName();
|
|
|
}
|
|
|
return key;
|
|
@@ -1767,7 +1899,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
|
|
|
|
|
|
String totalKey = month + "_" + regionTitle;
|
|
|
- if (deviceTypeName!= null &&!deviceTypeName.isEmpty()) {
|
|
|
+ if (deviceTypeName != null && !deviceTypeName.isEmpty()) {
|
|
|
totalKey += "_" + deviceTypeName;
|
|
|
}
|
|
|
BigDecimal monthlyTotal = monthTotals.get(totalKey); // 获取当天总值
|
|
@@ -1827,7 +1959,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject electricityControlFcMonth() {
|
|
|
+ public JSONObject electricityControlFcMonth(ExportQueryDTO queryDTO) {
|
|
|
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
@@ -1835,6 +1967,27 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+
|
|
|
+ // 获取 queryDTO 中的 year 字段
|
|
|
+ String year = queryDTO.getYear();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ // 判断是否传入了 year 参数
|
|
|
+ if (year == null || year.isEmpty()) {
|
|
|
+ // 如果 year 为空,默认查询当前年的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfYear(1); // 当前年的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ } else {
|
|
|
+ // 如果 year 不为空,解析 year 为年范围
|
|
|
+ startDate = LocalDate.parse(year + "-01-01", formatter); // 年份的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
+ // 查询数据
|
|
|
List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
|
if (oConvertUtils.listIsEmpty(fpgStatiscsModelDataList)) {
|
|
@@ -1885,7 +2038,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
DeviceInformation deviceInfo = deviceInfoMap.get(data.getDeviceInformationId());
|
|
|
if (deviceInfo != null) {
|
|
|
ElectricityControlReport report = new ElectricityControlReport();
|
|
|
- LocalDate date = LocalDate.parse(DateUtils.date2Str(data.getCreateTime(), DateUtils.date_sdf.get()), formatter);
|
|
|
+ LocalDate date = LocalDate.parse(data.getDates(), formatter);
|
|
|
String monthStr = date.getYear() + "年" + date.getMonthValue() + "月";
|
|
|
report.setRegionTitle(data.getRegionTitle());
|
|
|
report.setDeviceTypeName(mapDeviceType(deviceInfo.getDeviceType()));
|
|
@@ -1983,13 +2136,34 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject electricityControlGsMonth() {
|
|
|
+ public JSONObject electricityControlGsMonth(ExportQueryDTO queryDTO) {
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+
|
|
|
+ // 获取 queryDTO 中的 year 字段
|
|
|
+ String year = queryDTO.getYear();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ // 判断是否传入了 year 参数
|
|
|
+ if (year == null || year.isEmpty()) {
|
|
|
+ // 如果 year 为空,默认查询当前年的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfYear(1); // 当前年的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ } else {
|
|
|
+ // 如果 year 不为空,解析 year 为年范围
|
|
|
+ startDate = LocalDate.parse(year + "-01-01", formatter); // 年份的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
+ // 查询数据
|
|
|
List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
|
if (oConvertUtils.listIsEmpty(fpgStatiscsModelDataList)) {
|
|
@@ -2026,7 +2200,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
DeviceInformation deviceInfo = deviceInfoMap.get(data.getDeviceInformationId());
|
|
|
if (deviceInfo != null) {
|
|
|
ElectricityControlReport report = new ElectricityControlReport();
|
|
|
- LocalDate date = LocalDate.parse(DateUtils.date2Str(data.getCreateTime(), DateUtils.date_sdf.get()), formatter);
|
|
|
+ LocalDate date = LocalDate.parse(data.getDates(), formatter);
|
|
|
String monthStr = date.getYear() + "年" + date.getMonthValue() + "月";
|
|
|
report.setCompanyName("龙钢公司");
|
|
|
report.setKey1(key);
|
|
@@ -2172,7 +2346,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getIngTime(), b.getSelectricCurrent(), b.getPower(), b.getTopsPower(), b.getPeaksPower(), b.getFlatPower(), b.getValleysPower(),
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
- b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, b.getRegionTitle(), mapDeviceType(a.getDeviceType()),"龙钢公司");
|
|
|
+ b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString, b.getRegionTitle(), mapDeviceType(a.getDeviceType()), "龙钢公司");
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(x -> x != null).collect(Collectors.toList());
|
|
@@ -2494,19 +2668,33 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject valleyPeakDifferenceStatistics() {
|
|
|
+ public JSONObject valleyPeakDifferenceStatistics(ExportQueryDTO queryDTO) {
|
|
|
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
- query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+ // 根据 queryDTO 中的 month 字段动态设置日期范围过滤
|
|
|
+ String month = queryDTO.getMonth();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ if (month == null || month.isEmpty()) {
|
|
|
+ // 如果 month 为空,则默认查询当前月份的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfMonth(1); // 当前月的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ } else {
|
|
|
+ // 解析传入的 month 参数
|
|
|
+ startDate = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ }
|
|
|
|
|
|
- // 查询 MongoDB 中的数据
|
|
|
- List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList =
|
|
|
- mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
|
|
|
+ query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+ List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
if (CollectionUtils.isEmpty(fpgStatiscsModelDataList)) {
|
|
|
log.info("{}{}", "mongo数据查询为空,峰平谷报表导出失败!", "total_day_powerproportioncurrent");
|
|
|
result.put("data", new JSONArray());
|
|
@@ -2555,7 +2743,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(),
|
|
|
- b.getProportion(), b.getDates(), dateString, null, null,"龙钢公司");
|
|
|
+ b.getProportion(), b.getDates(), dateString, null, null, "龙钢公司");
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
@@ -2651,17 +2839,32 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject valleyPeakDifferenceGxStatistics() {
|
|
|
+ public JSONObject valleyPeakDifferenceGxStatistics(ExportQueryDTO queryDTO) {
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
- query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+ // 根据 queryDTO 中的 month 字段动态设置日期范围过滤
|
|
|
+ String month = queryDTO.getMonth();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ if (month == null || month.isEmpty()) {
|
|
|
+ // 如果 month 为空,则默认查询当前月份的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfMonth(1); // 当前月的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ } else {
|
|
|
+ // 解析传入的 month 参数
|
|
|
+ startDate = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ }
|
|
|
|
|
|
- // 查询 MongoDB 中的数据
|
|
|
- List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList =
|
|
|
- mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
+ query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+ List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
|
if (CollectionUtils.isEmpty(fpgStatiscsModelDataList)) {
|
|
|
log.info("{}{}", "mongo数据查询为空,峰平谷报表导出失败!", "total_day_powerproportioncurrent");
|
|
@@ -2712,7 +2915,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(),
|
|
|
- b.getProportion(), b.getDates(), dateString, regionMap.get(b.getDeviceRegionId()), mapDeviceType(a.getDeviceType()),"龙钢公司");
|
|
|
+ b.getProportion(), b.getDates(), dateString, regionMap.get(b.getDeviceRegionId()), mapDeviceType(a.getDeviceType()), "龙钢公司");
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
@@ -2778,18 +2981,33 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject valleyPeakDifferenceFcStatistics() {
|
|
|
+ public JSONObject valleyPeakDifferenceFcStatistics(ExportQueryDTO queryDTO) {
|
|
|
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
- query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+ // 根据 queryDTO 中的 month 字段动态设置日期范围过滤
|
|
|
+ String month = queryDTO.getMonth();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ if (month == null || month.isEmpty()) {
|
|
|
+ // 如果 month 为空,则默认查询当前月份的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfMonth(1); // 当前月的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ } else {
|
|
|
+ // 解析传入的 month 参数
|
|
|
+ startDate = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
|
|
|
- // 查询 MongoDB 中的数据
|
|
|
- List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList =
|
|
|
- mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
+ query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+ List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
|
if (CollectionUtils.isEmpty(fpgStatiscsModelDataList)) {
|
|
|
log.info("{}{}", "mongo数据查询为空,峰平谷报表导出失败!", "total_day_powerproportioncurrent");
|
|
@@ -2840,7 +3058,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(),
|
|
|
- b.getProportion(), b.getDates(), dateString, regionMap.get(b.getDeviceRegionId()), null,"龙钢公司");
|
|
|
+ b.getProportion(), b.getDates(), dateString, regionMap.get(b.getDeviceRegionId()), null, "龙钢公司");
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
@@ -2897,19 +3115,33 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject valleyPeakDifferenceGsStatistics() {
|
|
|
+ public JSONObject valleyPeakDifferenceGsStatistics(ExportQueryDTO queryDTO) {
|
|
|
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Query query = new Query();
|
|
|
- query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+ // 根据 queryDTO 中的 month 字段动态设置日期范围过滤
|
|
|
+ String month = queryDTO.getMonth();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ if (month == null || month.isEmpty()) {
|
|
|
+ // 如果 month 为空,则默认查询当前月份的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfMonth(1); // 当前月的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ } else {
|
|
|
+ // 解析传入的 month 参数
|
|
|
+ startDate = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份的第一天
|
|
|
+ endDate = startDate.plusMonths(1); // 下个月的第一天
|
|
|
+ }
|
|
|
|
|
|
- // 查询 MongoDB 中的数据
|
|
|
- List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList =
|
|
|
- mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
|
|
|
+ query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+ List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
if (CollectionUtils.isEmpty(fpgStatiscsModelDataList)) {
|
|
|
log.info("{}{}", "mongo数据查询为空,峰平谷报表导出失败!", "total_day_powerproportioncurrent");
|
|
|
result.put("data", new JSONArray());
|
|
@@ -2943,7 +3175,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(),
|
|
|
- b.getProportion(), b.getDates(), dateString, null, null,"龙钢公司"); // 使用DeviceInformation中的CompanyName
|
|
|
+ b.getProportion(), b.getDates(), dateString, null, null, "龙钢公司"); // 使用DeviceInformation中的CompanyName
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
@@ -3000,7 +3232,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject valleyPeakDifferenceStatisticsMonth() {
|
|
|
+ public JSONObject valleyPeakDifferenceStatisticsMonth(ExportQueryDTO queryDTO) {
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
@@ -3008,9 +3240,27 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
Query query = new Query();
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
|
|
|
- // 查询 MongoDB 中的数据
|
|
|
- List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList =
|
|
|
- mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
+ // 获取 queryDTO 中的 year 字段
|
|
|
+ String year = queryDTO.getYear();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ // 判断是否传入了 year 参数
|
|
|
+ if (year == null || year.isEmpty()) {
|
|
|
+ // 如果 year 为空,默认查询当前年的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfYear(1); // 当前年的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ } else {
|
|
|
+ // 如果 year 不为空,解析 year 为年范围
|
|
|
+ startDate = LocalDate.parse(year + "-01-01", formatter); // 年份的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
+ // 查询数据
|
|
|
+ List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
|
if (CollectionUtils.isEmpty(fpgStatiscsModelDataList)) {
|
|
|
log.info("{}{}", "mongo数据查询为空,峰平谷报表导出失败!", "total_day_powerproportioncurrent");
|
|
@@ -3057,7 +3307,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
|
|
|
b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
|
|
|
b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(),
|
|
|
- b.getProportion(), b.getDates(), dateString, null, null,"龙钢公司");
|
|
|
+ b.getProportion(), b.getDates(), dateString, null, null, "龙钢公司");
|
|
|
}
|
|
|
return null;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
@@ -3109,7 +3359,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject valleyPeakDifferenceGxStatisticsMonth() {
|
|
|
+ public JSONObject valleyPeakDifferenceGxStatisticsMonth(ExportQueryDTO queryDTO) {
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
@@ -3117,9 +3367,27 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
Query query = new Query();
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
|
|
|
- // 查询 MongoDB 中的数据
|
|
|
- List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList =
|
|
|
- mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
+ // 获取 queryDTO 中的 year 字段
|
|
|
+ String year = queryDTO.getYear();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ // 判断是否传入了 year 参数
|
|
|
+ if (year == null || year.isEmpty()) {
|
|
|
+ // 如果 year 为空,默认查询当前年的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfYear(1); // 当前年的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ } else {
|
|
|
+ // 如果 year 不为空,解析 year 为年范围
|
|
|
+ startDate = LocalDate.parse(year + "-01-01", formatter); // 年份的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
+ // 查询数据
|
|
|
+ List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
|
if (CollectionUtils.isEmpty(fpgStatiscsModelDataList)) {
|
|
|
log.info("{}{}", "mongo数据查询为空,峰平谷报表导出失败!", "total_day_powerproportioncurrent");
|
|
@@ -3231,7 +3499,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject valleyPeakDifferenceFcStatisticsMonth() {
|
|
|
+ public JSONObject valleyPeakDifferenceFcStatisticsMonth(ExportQueryDTO queryDTO) {
|
|
|
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
@@ -3240,9 +3508,27 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
Query query = new Query();
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
|
|
|
- // 查询 MongoDB 中的数据
|
|
|
- List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList =
|
|
|
- mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
+ // 获取 queryDTO 中的 year 字段
|
|
|
+ String year = queryDTO.getYear();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ // 判断是否传入了 year 参数
|
|
|
+ if (year == null || year.isEmpty()) {
|
|
|
+ // 如果 year 为空,默认查询当前年的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfYear(1); // 当前年的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ } else {
|
|
|
+ // 如果 year 不为空,解析 year 为年范围
|
|
|
+ startDate = LocalDate.parse(year + "-01-01", formatter); // 年份的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
+ // 查询数据
|
|
|
+ List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
|
if (CollectionUtils.isEmpty(fpgStatiscsModelDataList)) {
|
|
|
log.info("{}{}", "mongo数据查询为空,峰平谷报表导出失败!", "total_day_powerproportioncurrent");
|
|
@@ -3353,7 +3639,7 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject valleyPeakDifferenceGsStatisticsMonth() {
|
|
|
+ public JSONObject valleyPeakDifferenceGsStatisticsMonth(ExportQueryDTO queryDTO) {
|
|
|
|
|
|
// 定义日期格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
@@ -3362,9 +3648,27 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
|
|
|
Query query = new Query();
|
|
|
query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
|
|
|
- // 查询 MongoDB 中的数据
|
|
|
- List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList =
|
|
|
- mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
+ // 获取 queryDTO 中的 year 字段
|
|
|
+ String year = queryDTO.getYear();
|
|
|
+ LocalDate startDate, endDate;
|
|
|
+
|
|
|
+ // 判断是否传入了 year 参数
|
|
|
+ if (year == null || year.isEmpty()) {
|
|
|
+ // 如果 year 为空,默认查询当前年的数据
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ startDate = currentDate.withDayOfYear(1); // 当前年的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ } else {
|
|
|
+ // 如果 year 不为空,解析 year 为年范围
|
|
|
+ startDate = LocalDate.parse(year + "-01-01", formatter); // 年份的第一天
|
|
|
+ endDate = startDate.plusYears(1); // 下一年的第一天
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加过滤条件:dates 字段在 startDate 和 endDate 之间
|
|
|
+ query.addCriteria(Criteria.where("dates").gte(startDate.format(formatter)).lt(endDate.format(formatter)));
|
|
|
+
|
|
|
+ // 查询数据
|
|
|
+ List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "total_day_powerproportioncurrent");
|
|
|
|
|
|
if (CollectionUtils.isEmpty(fpgStatiscsModelDataList)) {
|
|
|
log.info("{}{}", "mongo数据查询为空,峰平谷报表导出失败!", "total_day_powerproportioncurrent");
|