|
@@ -1,13 +1,15 @@
|
|
|
package org.jeecg.modules.homePageData.service.impl;
|
|
|
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.common.ModelCodeContant;
|
|
|
import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
|
|
|
import org.jeecg.modules.deviceLesm.entity.DeviceRegionInformation;
|
|
|
import org.jeecg.modules.deviceLesm.mapper.DevicePointMapper;
|
|
|
import org.jeecg.modules.deviceLesm.service.IDeviceRegionService;
|
|
|
+import org.jeecg.modules.fpgLeanModel.entity.DeviceStatiscsModelMongodb;
|
|
|
import org.jeecg.modules.fpgLeanModel.entity.FpgLeanModel;
|
|
|
import org.jeecg.modules.fpgLeanModel.service.IFpgLeanModelService;
|
|
|
-import org.jeecg.modules.gatherData.entity.FpgMiddleTwoData;
|
|
|
import org.jeecg.modules.gatherData.mapper.FpgGatherDataMapper;
|
|
|
import org.jeecg.modules.homePageData.entity.LeanEventWarnInfoResult;
|
|
|
import org.jeecg.modules.homePageData.mapper.LeanEventWarnInfoMapper;
|
|
@@ -15,6 +17,10 @@ import org.jeecg.modules.homePageData.service.IHomePageDataService;
|
|
|
import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
|
|
|
import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
+import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -44,6 +50,8 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
|
|
|
@Autowired
|
|
|
private IFpgLeanModelService fpgLeanModelService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MongoTemplate mongoTemplate;
|
|
|
|
|
|
@Override
|
|
|
public List<Map<String, String>> regionPfvElectricity(String modelId) {
|
|
@@ -181,38 +189,50 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
|
|
|
@Override
|
|
|
public Map<String, List> fpvTimeElectricity(String modelId) {
|
|
|
Map<String, List> res = new HashMap<>();
|
|
|
- String leanModelCode = queryLeanModelCodeById(modelId);
|
|
|
|
|
|
- Date today = new Date();
|
|
|
- String dayDate = new SimpleDateFormat("yyyy-MM-dd 00:00:00").format(today);
|
|
|
List<Map<String,String>> tops = new ArrayList<>();
|
|
|
List<Map<String,String>> peaks = new ArrayList<>();
|
|
|
List<Map<String,String>> flat = new ArrayList<>();
|
|
|
List<Map<String,String>> valleys = new ArrayList<>();
|
|
|
- List<PeaksAndValleysTimeConfig> peaksAndValleysTimeConfiglist = peaksAndValleysTimeConfigService.list();
|
|
|
- // 查询时段数据
|
|
|
- List<FpgMiddleTwoData> fpgGatherDatalist = fpgGatherDataMapper.getFpgTheLeftSideOneData(dayDate);
|
|
|
- // 归类尖峰平谷数据
|
|
|
- // fpgGatherDatalist.forEach(fpgGatherData -> {
|
|
|
- // 峰平谷时段处理
|
|
|
- // peaksAndValleysTimeConfiglist.forEach(peaksAndValleysTime -> {
|
|
|
- // String startDate = dayDate + " " + peaksAndValleysTime.getStartTime();
|
|
|
- // String endDate = dayDate + " " + peaksAndValleysTime.getEndTime();
|
|
|
- // });
|
|
|
- // });
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.set(Calendar.SECOND, 0);
|
|
|
- calendar.set(Calendar.MINUTE, 0);
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- calendar.set(Calendar.MILLISECOND, 0);
|
|
|
-
|
|
|
- for (int i = 0; i < 24; i++) {
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, i);
|
|
|
- Double electricity = Math.random()*100+200;
|
|
|
- tops.add(getMap(calendar.getTime(),String.format("%.2f",electricity*(Math.random()*0.2+1))));
|
|
|
- peaks.add(getMap(calendar.getTime(),String.format("%.2f",electricity)));
|
|
|
- flat.add(getMap(calendar.getTime(),String.format("%.2f",electricity*(Math.random()*0.2+0.7))));
|
|
|
- valleys.add(getMap(calendar.getTime(),String.format("%.2f",electricity*(Math.random()*0.2+0.5))));
|
|
|
+ // 根据模型ID查询模型编码
|
|
|
+ String leanModelCode = queryLeanModelCodeById(modelId);
|
|
|
+
|
|
|
+ if (oConvertUtils.isEmpty(leanModelCode)){
|
|
|
+ res.put("tops",tops);
|
|
|
+ res.put("peaks",peaks);
|
|
|
+ res.put("flat",flat);
|
|
|
+ res.put("valleys",valleys);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (leanModelCode.equals(ModelCodeContant.LARGE_SCREEN_RUN_REALTIME)){
|
|
|
+ Query query = new Query();
|
|
|
+ query.with(Sort.by(Sort.Direction.ASC, "createTime"));
|
|
|
+ Date startTime = new Date();
|
|
|
+ // 加8小时
|
|
|
+ Calendar calendar1 = Calendar.getInstance();
|
|
|
+ calendar1.setTime(startTime);
|
|
|
+ calendar1.add(Calendar.HOUR, 8);
|
|
|
+ Date specifiedTimePlus8HoursStartTime = calendar1.getTime();
|
|
|
+
|
|
|
+ String e = DateUtils.date2Str(new Date(), DateUtils.date_sdf.get())+ " 08:00:00";
|
|
|
+ Date specifiedTimePlus8HoursStartEndTime = DateUtils.str2Date(e, DateUtils.datetimeFormat.get());
|
|
|
+
|
|
|
+ query.addCriteria(Criteria.where("createTime").gte(specifiedTimePlus8HoursStartEndTime).lt(specifiedTimePlus8HoursStartTime));
|
|
|
+ // 执行查询
|
|
|
+ List<DeviceStatiscsModelMongodb> deviceStatiscsModelMongodbList = mongoTemplate.find(query, DeviceStatiscsModelMongodb.class, "large_screen_run_realtime");
|
|
|
+ if (oConvertUtils.listIsEmpty(deviceStatiscsModelMongodbList)){
|
|
|
+ res.put("tops",tops);
|
|
|
+ res.put("peaks",peaks);
|
|
|
+ res.put("flat",flat);
|
|
|
+ res.put("valleys",valleys);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ deviceStatiscsModelMongodbList.forEach(x ->{
|
|
|
+ tops.add(getMap(x.getCreateTime(), x.getTopsPower().toString()));
|
|
|
+ peaks.add(getMap(x.getCreateTime(), x.getPeaksPower().toString()));
|
|
|
+ flat.add(getMap(x.getCreateTime(), x.getFlatPower().toString()));
|
|
|
+ valleys.add(getMap(x.getCreateTime(), x.getValleysPower().toString()));
|
|
|
+ });
|
|
|
}
|
|
|
res.put("tops",tops);
|
|
|
res.put("peaks",peaks);
|
|
@@ -305,4 +325,12 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
|
|
|
}
|
|
|
return fpgLeanModel.getLeanModelCode();
|
|
|
}
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+
|
|
|
+ String e = DateUtils.date2Str(new Date(), DateUtils.date_sdf.get())+ " 08:00:00";
|
|
|
+ Date endTime = DateUtils.str2Date(e, DateUtils.datetimeFormat.get());
|
|
|
+ System.out.println(e);
|
|
|
+ System.out.println(endTime);
|
|
|
+ }
|
|
|
}
|