|
@@ -1,23 +1,19 @@
|
|
|
package org.jeecg.modules.homePageData.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
-import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
|
|
|
-import org.jeecg.modules.deviceLesm.entity.DevicePoint;
|
|
|
-import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
|
|
|
-import org.jeecg.modules.deviceLesm.entity.DeviceRegionInformation;
|
|
|
+import org.jeecg.modules.deviceLesm.entity.*;
|
|
|
import org.jeecg.modules.deviceLesm.mapper.DevicePointMapper;
|
|
|
-import org.jeecg.modules.deviceLesm.mapper.DeviceRegionMapper;
|
|
|
import org.jeecg.modules.deviceLesm.service.IDeviceInformationService;
|
|
|
import org.jeecg.modules.deviceLesm.service.IDeviceRegionService;
|
|
|
-import org.jeecg.modules.deviceLesm.service.impl.DeviceRegionServiceImpl;
|
|
|
+import org.jeecg.modules.gatherData.mapper.FpgGatherDataMapper;
|
|
|
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.stereotype.Service;
|
|
|
|
|
|
-import java.text.ParseException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
@@ -35,20 +31,58 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
|
|
|
@Autowired
|
|
|
private DevicePointMapper devicePointMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FpgGatherDataMapper fpgGatherDataMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IPeaksAndValleysTimeConfigService peaksAndValleysTimeConfigService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<Map<String, String>> regionPfvElectricity() {
|
|
|
+ Date today = new Date();
|
|
|
+ String dayDate = new SimpleDateFormat("yyyy-MM-dd").format(today);
|
|
|
List<DeviceRegion> list = deviceRegionService.list();
|
|
|
+ List<PeaksAndValleysTimeConfig> peaksAndValleysTimeConfiglist = peaksAndValleysTimeConfigService.list();
|
|
|
List<Map<String, String>> res = new ArrayList<>();
|
|
|
if(oConvertUtils.listIsNotEmpty(list)){
|
|
|
list.forEach(deviceRegion -> {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
- Double electricity = Math.random()*100+200;
|
|
|
+ Map<String, Object> mapSum = new HashMap<>();
|
|
|
+ mapSum.put("topsSum", 0.00);
|
|
|
+ mapSum.put("peaksSum", 0.00);
|
|
|
+ mapSum.put("flatSum", 0.00);
|
|
|
+ mapSum.put("valleysSum", 0.00);
|
|
|
+ // 峰平谷时段处理
|
|
|
+ peaksAndValleysTimeConfiglist.forEach(peaksAndValleysTime -> {
|
|
|
+ String startDate = dayDate + " " + peaksAndValleysTime.getStartTime();
|
|
|
+ String endDate = dayDate + " " + peaksAndValleysTime.getEndTime();
|
|
|
+ Map peaksAndValleysTimeMap= fpgGatherDataMapper.getFpgTheLeftSideOneData(deviceRegion.getId(), startDate, endDate);
|
|
|
+ if(peaksAndValleysTimeMap != null){
|
|
|
+ if("tops".equals(peaksAndValleysTime.getType())){ // 尖值处理
|
|
|
+ BigDecimal topsAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
|
|
|
+ BigDecimal topsSum = new BigDecimal(String.valueOf(mapSum.get("topsSum")));
|
|
|
+ mapSum.put("topsSum", topsSum.add(topsAmount));
|
|
|
+ }else if("peaks".equals(peaksAndValleysTime.getType())){ // 峰值处理
|
|
|
+ BigDecimal peaksAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
|
|
|
+ BigDecimal peaksSum = new BigDecimal(String.valueOf(mapSum.get("peaksSum")));
|
|
|
+ mapSum.put("peaksSum", peaksSum.add(peaksAmount));
|
|
|
+ }else if("flat".equals(peaksAndValleysTime.getType())){ // 平值处理
|
|
|
+ BigDecimal flatAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
|
|
|
+ BigDecimal flatSum = new BigDecimal(String.valueOf(mapSum.get("flatSum")));
|
|
|
+ mapSum.put("flatSum", flatSum.add(flatAmount));
|
|
|
+ }else if("valleys".equals(peaksAndValleysTime.getType())){ // 谷值处理
|
|
|
+ BigDecimal valleysAmount = new BigDecimal(String.valueOf(peaksAndValleysTimeMap.get("active_power")));
|
|
|
+ BigDecimal valleysSum = new BigDecimal(String.valueOf(mapSum.get("valleysSum")));
|
|
|
+ mapSum.put("valleysSum", valleysSum.add(valleysAmount));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
map.put("name",deviceRegion.getRegionTitle());
|
|
|
- map.put("tops", String.format("%.2f",electricity*(Math.random()*0.2+1)));
|
|
|
- map.put("peaks", String.format("%.2f",electricity));
|
|
|
- map.put("flat", String.format("%.2f",electricity*(Math.random()*0.2+0.7)));
|
|
|
- map.put("valleys", String.format("%.2f",electricity*(Math.random()*0.2+0.5)));
|
|
|
+ map.put("tops", String.format("%.2f", mapSum.get("topsSum")));
|
|
|
+ map.put("peaks", String.format("%.2f", mapSum.get("peaksSum")));
|
|
|
+ map.put("flat", String.format("%.2f", mapSum.get("flatSum")));
|
|
|
+ map.put("valleys", String.format("%.2f", mapSum.get("valleysSum")));
|
|
|
res.add(map);
|
|
|
});
|
|
|
}
|
|
@@ -66,10 +100,12 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
|
|
|
list.forEach(deviceRegion -> {
|
|
|
List<DeviceRegionInformation> devicePointList = devicePointMapper.getPointInformation(deviceRegion.getId());
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("online", 0);
|
|
|
+ map.put("offline", 0);
|
|
|
devicePointList.forEach(devicePointInfo -> {
|
|
|
- if(devicePointInfo.getGatherStatus() == "1"){ // 在线
|
|
|
+ if("1".equals(devicePointInfo.getGatherStatus())){ // 在线
|
|
|
map.put("online", devicePointInfo.getSum());
|
|
|
- }else if(devicePointInfo.getGatherStatus() == "0"){ // 离线
|
|
|
+ }else if("0".equals(devicePointInfo.getGatherStatus())){ // 离线
|
|
|
map.put("offline", devicePointInfo.getSum());
|
|
|
}
|
|
|
});
|