|
@@ -5,6 +5,7 @@ import com.huaxu.dto.AlarmDetailsDto;
|
|
|
import com.huaxu.dto.AppSmsDataDto;
|
|
|
import com.huaxu.dto.SceneDataDto;
|
|
|
import com.huaxu.dto.SceneDataForAppDto;
|
|
|
+import com.huaxu.dto.generalView.WaterSupplyChart;
|
|
|
import com.huaxu.entity.*;
|
|
|
import com.huaxu.model.AjaxMessage;
|
|
|
import com.huaxu.model.ResultStatus;
|
|
@@ -29,48 +30,16 @@ import java.util.stream.Collectors;
|
|
|
@Api(tags = "App数据")
|
|
|
public class AppDataController {
|
|
|
@Autowired
|
|
|
- private MonitorDataReportService monitorDataReportService;
|
|
|
+ private AppDataService appDataService;
|
|
|
@Autowired
|
|
|
private SceneService sceneService;
|
|
|
@Autowired
|
|
|
- private MonitorInfoService monitorInfoService;
|
|
|
- @Autowired
|
|
|
- private RedisUtil redisUtil;
|
|
|
- @Autowired
|
|
|
- private AlarmDetailsService alarmDetailsService;
|
|
|
- @Autowired
|
|
|
- private DeviceAttributeSpecsService deviceAttributeSpecsService;
|
|
|
- @Autowired
|
|
|
- private DeviceParmService deviceParmService;
|
|
|
+ private MonitorDataReportService monitorDataReportService;
|
|
|
|
|
|
@RequestMapping(value = "getProductionDataForSameMonth", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "综合调度——本月供水情况")
|
|
|
public AjaxMessage<AppSmsDataDto> getMonthWaterSupply(@ApiParam(value = "类型名称(水源、水厂、泵站、售水)") @RequestParam(required = true) String typeName) {
|
|
|
- //3用水量or供水量or制水量 4 取水量or进水量 5耗电量 6耗药量
|
|
|
- AppSmsDataDto appSmsDataDto = new AppSmsDataDto();
|
|
|
- switch (typeName) {
|
|
|
- case "水源":
|
|
|
- appSmsDataDto.setIntakeWaterUsage(monitorDataReportService.getAmountCount(null, null, typeName, 4, 2).doubleValue());
|
|
|
- appSmsDataDto.setPowerUsage(monitorDataReportService.getAmountCount(null, null, typeName, 5, 2).doubleValue());
|
|
|
- break;
|
|
|
- case "水厂":
|
|
|
- appSmsDataDto.setIntakeWaterUsage(monitorDataReportService.getAmountCount(null, null, typeName, 3, 2).doubleValue());
|
|
|
- appSmsDataDto.setPowerUsage(monitorDataReportService.getAmountCount(null, null, typeName, 5, 2).doubleValue());
|
|
|
- appSmsDataDto.setDrugUsage(monitorDataReportService.getAmountCount(null, null, typeName, 6, 2).doubleValue());
|
|
|
- break;
|
|
|
- case "泵站":
|
|
|
- appSmsDataDto.setYieldWaterUsage(monitorDataReportService.getAmountCount(null, null, typeName, 3, 2).doubleValue());
|
|
|
- appSmsDataDto.setPowerUsage(monitorDataReportService.getAmountCount(null, null, typeName, 5, 2).doubleValue());
|
|
|
- break;
|
|
|
- case "售水":
|
|
|
- appSmsDataDto.setYieldWaterUsage(monitorDataReportService.getAmountCount(null, null, "水厂", 3, 2).doubleValue());
|
|
|
- appSmsDataDto.setWaterUsage(monitorDataReportService.getUseAmount(null, 1).doubleValue());
|
|
|
- double amount = appSmsDataDto.getYieldWaterUsage() - appSmsDataDto.getWaterUsage();
|
|
|
- if (appSmsDataDto.getYieldWaterUsage() != null && appSmsDataDto.getYieldWaterUsage() != 0d) {
|
|
|
- appSmsDataDto.setWaterFeeRecoveryRate(BigDecimal.valueOf(amount).divide(BigDecimal.valueOf(appSmsDataDto.getYieldWaterUsage()), 3, BigDecimal.ROUND_HALF_UP).doubleValue() * 100);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
+ AppSmsDataDto appSmsDataDto = appDataService.getProductionDataForSameMonth(typeName);
|
|
|
return new AjaxMessage<>(ResultStatus.OK, appSmsDataDto);
|
|
|
}
|
|
|
|
|
@@ -82,146 +51,25 @@ public class AppDataController {
|
|
|
return new AjaxMessage<>(ResultStatus.OK, sceneEntities);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 今日统计量
|
|
|
- * @param typeName
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- private List<SceneDataDto> getTotalAmount(@ApiParam(value = "类型名称(水源、水厂、泵站、售水)") @RequestParam(required = true) String typeName,
|
|
|
- @ApiParam(value = "场景ID", required = true) @RequestParam Long id) {
|
|
|
- List<SceneDataDto> sceneDataDtos = new ArrayList<>();
|
|
|
- switch (typeName) {
|
|
|
- case "水源":
|
|
|
- SceneDataDto item1 = new SceneDataDto();
|
|
|
- item1.setMonitorName("今日取水量");
|
|
|
- item1.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 4, 1).doubleValue() + "m³");
|
|
|
- sceneDataDtos.add(item1);
|
|
|
- SceneDataDto item2 = new SceneDataDto();
|
|
|
- item2.setMonitorName("今日耗电量");
|
|
|
- item2.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 5, 1).doubleValue() + "kw");
|
|
|
- sceneDataDtos.add(item2);
|
|
|
- break;
|
|
|
- case "水厂":
|
|
|
- SceneDataDto item5 = new SceneDataDto();
|
|
|
- item5.setMonitorName("今日进水量");
|
|
|
- item5.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 4, 1).doubleValue() + "m³");
|
|
|
- sceneDataDtos.add(item5);
|
|
|
- SceneDataDto item3 = new SceneDataDto();
|
|
|
- item3.setMonitorName("今日制水量");
|
|
|
- item3.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 3, 1).doubleValue() + "m³");
|
|
|
- sceneDataDtos.add(item3);
|
|
|
- SceneDataDto item4 = new SceneDataDto();
|
|
|
- item4.setMonitorName("今日耗电量");
|
|
|
- item4.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 5, 1).doubleValue() + "kw");
|
|
|
- sceneDataDtos.add(item4);
|
|
|
- SceneDataDto item6 = new SceneDataDto();
|
|
|
- item6.setMonitorName("今日耗药量");
|
|
|
- item6.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 6, 1).doubleValue() + "kg");
|
|
|
- sceneDataDtos.add(item6);
|
|
|
- break;
|
|
|
- case "泵站":
|
|
|
- SceneDataDto item7 = new SceneDataDto();
|
|
|
- item7.setMonitorName("今日进水量");
|
|
|
- item7.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 4, 1).doubleValue() + "m³");
|
|
|
- sceneDataDtos.add(item7);
|
|
|
- SceneDataDto item8 = new SceneDataDto();
|
|
|
- item8.setMonitorName("今日供水量");
|
|
|
- item8.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 3, 1).doubleValue() + "m³");
|
|
|
- sceneDataDtos.add(item8);
|
|
|
- SceneDataDto item9 = new SceneDataDto();
|
|
|
- item9.setMonitorName("今日耗电量");
|
|
|
- item9.setMonitorValue(monitorDataReportService.getAmountCount(null, id.intValue(), typeName, 5, 1).doubleValue() + "kw");
|
|
|
- sceneDataDtos.add(item9);
|
|
|
- break;
|
|
|
- }
|
|
|
- return sceneDataDtos;
|
|
|
- }
|
|
|
|
|
|
@ApiOperation(value = "综合调度——工艺场景(详情)")
|
|
|
@RequestMapping(value = "/findBySceneId", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
public AjaxMessage<SceneDataForAppDto> findBySceneId(
|
|
|
- @ApiParam(value = "类型名称(水源、水厂、泵站、售水)") @RequestParam(required = true) String typeName,
|
|
|
+ @ApiParam(value = "类型名称(水源、水厂、泵站)") @RequestParam(required = true) String typeName,
|
|
|
@ApiParam(value = "场景ID", required = true) @RequestParam Long id) {
|
|
|
- SceneDataForAppDto returnInfo = new SceneDataForAppDto();
|
|
|
- SceneEntity sceneEntity = sceneService.findSceneByIdForApp(id);
|
|
|
- if (sceneEntity != null) {
|
|
|
- returnInfo.setAddress(sceneEntity.getAddress());
|
|
|
- returnInfo.setSceneName(sceneEntity.getSceneName());
|
|
|
- returnInfo.setImagePath(sceneEntity.getSceneImages().size() > 0 ? sceneEntity.getSceneImages().get(0).getImagePath() : null);
|
|
|
- if (sceneEntity.getParentSceneId().equals("0")) {
|
|
|
- List<SceneDataDto> sceneDataDtos = getTotalAmount(typeName, id);
|
|
|
- returnInfo.getInfos().addAll(sceneDataDtos);
|
|
|
- }
|
|
|
- } else {
|
|
|
- return null;
|
|
|
- }
|
|
|
- List<SceneDataDto> sceneDataDtos = new ArrayList<>();
|
|
|
- List<String> deviceCodes = new ArrayList<>();
|
|
|
- //查询到所有的测点信息
|
|
|
- List<DeviceParmEntity> deviceParmEntities = deviceParmService.selectByScendId(id.intValue());
|
|
|
- Map<String, List<AlarmDetailsDto>> alarms = new HashMap<>();
|
|
|
- Map<String, List<DeviceParmEntity>> parmMap = new HashMap<>();
|
|
|
- for (DeviceParmEntity deviceParmEntity : deviceParmEntities) {
|
|
|
- if (!deviceCodes.contains(deviceParmEntity.getDeviceCode())) {
|
|
|
- deviceCodes.add(deviceParmEntity.getDeviceCode());
|
|
|
- //查询报警信息
|
|
|
- List<AlarmDetailsDto> alarmDetailsDtos = alarmDetailsService.selectByDeviceId(deviceParmEntity.getDeviceId());
|
|
|
- alarms.put(deviceParmEntity.getDeviceCode(), alarmDetailsDtos);
|
|
|
- List<DeviceParmEntity> deviceParms = new ArrayList<>();
|
|
|
- deviceParms.add(deviceParmEntity);
|
|
|
- parmMap.put(deviceParmEntity.getDeviceCode(), deviceParms);
|
|
|
- } else {
|
|
|
- parmMap.get(deviceParmEntity.getDeviceId()).add(deviceParmEntity);
|
|
|
- }
|
|
|
- }
|
|
|
- for (String deveiceCode : deviceCodes) {
|
|
|
- byte[] bytes = redisUtil.get(("sms_water_" + deveiceCode).getBytes());
|
|
|
- //将报警信息放置map中
|
|
|
- Map<Integer, AlarmDetailsDto> mapAlarm = new HashMap<>();
|
|
|
- List<AlarmDetailsDto> alarmDetailsDtos = alarms.get(deveiceCode);
|
|
|
- mapAlarm = alarmDetailsDtos.stream().collect(Collectors.toMap(AlarmDetailsDto::getAttributeId, a -> a, (k1, k2) -> k1));
|
|
|
- //将缓存中的实时数据放到map中方便进行遍历
|
|
|
- if (bytes != null && bytes.length > 0) {
|
|
|
- MonitorDataEntity monitorDataEntity = (MonitorDataEntity) ByteArrayUtils.bytesToObject(bytes).get();
|
|
|
- Map<Long, MonitorDataValueEntity> map = new HashMap<>();
|
|
|
- returnInfo.setCollectDate(monitorDataEntity.getCollectDate());
|
|
|
- //将缓存中的实时数据放到map中方便进行遍历
|
|
|
- map = monitorDataEntity.getDataValues().stream().collect(Collectors.toMap(MonitorDataValueEntity::getAttributeId, a -> a, (k1, k2) -> k1));
|
|
|
- for (DeviceParmEntity item : parmMap.get(deveiceCode)) {
|
|
|
- SceneDataDto sceneDataDto = new SceneDataDto();
|
|
|
- sceneDataDto.setMonitorName(item.getAttributeName());
|
|
|
- //按属性ID查询标签值
|
|
|
- DeviceAttributeSpecsEntity deviceAttributeSpecsEntity = new DeviceAttributeSpecsEntity();
|
|
|
- deviceAttributeSpecsEntity.setAttributeId(Long.valueOf(item.getAttributeId()));
|
|
|
- List<DeviceAttributeSpecsEntity> deviceAttributeSpecsEntities = deviceAttributeSpecsService.findList(deviceAttributeSpecsEntity);
|
|
|
- if (map.containsKey(item.getAttributeId())) {
|
|
|
- Double value = map.get(item.getAttributeId()).getDataValue();
|
|
|
- if (deviceAttributeSpecsEntities.size() > 0) {
|
|
|
- if (value != null) {
|
|
|
- for (DeviceAttributeSpecsEntity specsEntity : deviceAttributeSpecsEntities)
|
|
|
- if (Integer.valueOf(specsEntity.getSpecsValue()) == value.intValue()) {
|
|
|
- sceneDataDto.setMonitorValue(specsEntity.getSpecsName());
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (value != null) {
|
|
|
- sceneDataDto.setMonitorValue(String.format("%.3f", map.get(item.getAttributeId()).getDataValue()) + (StringUtils.isNotEmpty(map.get(item.getAttributeId()).getUnit()) ? map.get(item.getAttributeId()).getUnit() : ""));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //判断是否报警
|
|
|
- if (mapAlarm.containsKey(item.getAttributeId().intValue()))
|
|
|
- sceneDataDto.setIsAlarm(1);
|
|
|
- else
|
|
|
- sceneDataDto.setIsAlarm(0);
|
|
|
- sceneDataDtos.add(sceneDataDto);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- returnInfo.setInfos(sceneDataDtos);
|
|
|
+ SceneDataForAppDto returnInfo = appDataService.getSceneDataForApp(typeName, id);
|
|
|
return new AjaxMessage<>(ResultStatus.OK, returnInfo);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "综合调度——供水制水电耗(曲线)")
|
|
|
+ @RequestMapping(value = "/findwaterSupplyChartsForCurrentMonth", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public AjaxMessage<List<WaterSupplyChart>> waterSupplyChartsForCurrentMonth(
|
|
|
+ @ApiParam(value = "类型名称(水源、水厂、泵站)") @RequestParam(required = true) String typeName,
|
|
|
+ @ApiParam(value = "场景ID", required = true) @RequestParam Long id) {
|
|
|
+ List<WaterSupplyChart> waterSupplyCharts = monitorDataReportService.waterSupplyChartsForCurrentMonth(typeName, id);
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, waterSupplyCharts);
|
|
|
+ }
|
|
|
+
|
|
|
}
|