Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

zhongwei
haungxing 4 months ago
parent
commit
72a74b8afc
  1. 5
      hzims-service-api/target/classes/META-INF/build-info.properties
  2. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java
  3. 3
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/mapper/ProcessDictMapper.java
  4. 17
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  5. 39
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java
  6. 129
      hzims-service/hzims-simulate/pom.xml
  7. 28
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java
  8. 43
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java
  9. 31
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java
  10. 195
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java
  11. 20
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java
  12. 46
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java
  13. 66
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java
  14. 22
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java
  15. 19
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java
  16. 38
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java
  17. 42
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java
  18. 30
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java
  19. 33
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java
  20. 18
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java
  21. 18
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java
  22. 19
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java
  23. 13
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml
  24. 16
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java
  25. 19
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java
  26. 34
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml
  27. 15
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java
  28. 15
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml
  29. 17
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java
  30. 9
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml
  31. 18
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml
  32. 53
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java
  33. 11
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java
  34. 24
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java
  35. 21
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java
  36. 280
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java
  37. 13
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java
  38. 304
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java
  39. 357
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java
  40. 105
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java
  41. 52
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java
  42. 18
      hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java
  43. 13
      hzims-service/hzims-simulate/src/main/resources/application-dev.yml
  44. 6
      hzims-service/hzims-simulate/src/main/resources/application-prod.yml
  45. 15
      hzims-service/hzims-simulate/src/main/resources/application.yml
  46. 5
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectMapper.java
  47. 4
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java
  48. 3
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java
  49. 101
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java
  50. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java
  51. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java
  52. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java
  53. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java
  54. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java
  55. 55
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java
  56. 36
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  57. 228
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java
  58. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java
  59. 40
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java
  60. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java
  61. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java
  62. 12
      pom.xml
  63. 5
      target/classes/META-INF/build-info.properties

5
hzims-service-api/target/classes/META-INF/build-info.properties

@ -0,0 +1,5 @@
build.artifact=hzims-service-api
build.group=com.hnac.hzims
build.name=hzims-service-api
build.time=2024-07-22T06\:45\:56.469Z
build.version=4.0.0-SNAPSHOT

6
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfigHzims.java

@ -60,11 +60,11 @@ public class MqttConfigHzims {
log.info(fdpClient.toString()+fdpClient.getClientId());
//drools
DroolsSoeSubscribe droolsSoeSubscribe = new DroolsSoeSubscribe();
MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), droolsMqttConsumer);
MqttAsyncClient droolsClient = droolsSoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), droolsMqttConsumer);
log.info(droolsClient.toString()+droolsClient.getClientId());
//Soe
SoeSubscribe soeSubscribe = new SoeSubscribe();
MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), soeMqttConsumer);
MqttAsyncClient soeClient = soeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), soeMqttConsumer);
log.info(soeClient.toString()+soeClient.getClientId());
//hz3000
HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe();
@ -72,7 +72,7 @@ public class MqttConfigHzims {
log.info(hz3000Client.toString()+hz3000Client.getClientId());
//视频
SoeSubscribe subscribe = new SoeSubscribe();
MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, "#",Collections.singletonList("#"), videoMqttConsumer);
MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer);
log.info(videoClient.toString()+videoClient.getClientId());
}catch (Exception e){
log.error(e.toString()) ;

3
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/mapper/ProcessDictMapper.java

@ -1,5 +1,6 @@
package com.hnac.hzims.middle.processflow.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.middle.processflow.entity.ProcessDict;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
@ -9,6 +10,6 @@ import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
* @Serial 1.0
* @Date 2023/6/5 8:49
*/
public interface ProcessDictMapper extends UserDataScopeBaseMapper<ProcessDict> {
public interface ProcessDictMapper extends BaseMapper<ProcessDict> {
}

17
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java

@ -37,9 +37,6 @@ import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient;
import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO;
import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO;
import io.undertow.util.CopyOnWriteMap;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
@ -56,7 +53,6 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.*;
@ -1274,7 +1270,7 @@ public class RealTargetServiceImpl implements RealTargetService {
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 存储数据map :<站点id,<月份,发电量>>
Map<Long, Map<String, Float>> powerMap = new ConcurrentHashMap <>();
Map<String, Map<String, Float>> powerMap = new ConcurrentHashMap <>();
// 将站点切割
int limit = countStep(stations.size());
List<List<StationEntity>> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 3).limit(3).parallel().collect(Collectors.toList())).collect(Collectors.toList());
@ -1289,7 +1285,7 @@ public class RealTargetServiceImpl implements RealTargetService {
if(MapUtils.isEmpty(generateMap)){
return;
}
powerMap.put(station.getId(),generateMap);
powerMap.put(station.getCode(),generateMap);
});
countDownLatch.countDown();
log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
@ -1359,9 +1355,6 @@ public class RealTargetServiceImpl implements RealTargetService {
in(StationEntity::getType, types);
}
}});
// 设备信息
// List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {
// });
// 开始时间
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
@ -1372,16 +1365,14 @@ public class RealTargetServiceImpl implements RealTargetService {
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 存储数据map :<站点id,<月份,发电量>>
Map<Long, Map<String, Float>> powerMap = new HashMap<>();
Map<String, Map<String, Float>> powerMap = new HashMap<>();
stationList.forEach(station -> {
// 站点设备集合
// List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
// log.error("load_power_data station :" + station.getCode() + "==== device :" + stationDevices );
Map<String, Float> generateMap = this.getGenerateYearByWindEnergy(station,start,end);
if(MapUtils.isEmpty(generateMap)){
return;
}
powerMap.put(station.getId(),generateMap);
powerMap.put(station.getCode(),generateMap);
});
redisTemplate.opsForValue().set(key, powerMap);
}

39
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java

@ -69,7 +69,6 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
@ -149,7 +148,7 @@ public class ReportServiceImpl implements ReportService {
return;
}
// 站点近年发电数据
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_cache_final);
Map<String, Map<String, Float>> powerMap = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_cache_final);
// 存储数据节点 key - 月份 value - 区域数据集合
Map<String, List<AreaMonthReportVo>> map = new HashMap<>();
// 月份集合
@ -187,7 +186,7 @@ public class ReportServiceImpl implements ReportService {
return;
}
// 站点近年发电数据
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(key);
Map<String, Map<String, Float>> powerMap = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(key);
// 存储数据节点 key - 月份 value - 区域数据集合
Map<String, List<AreaMonthReportVo>> map = new HashMap<>();
// 月份集合
@ -242,15 +241,15 @@ public class ReportServiceImpl implements ReportService {
* @param mon
* @return
*/
private List<AreaMonthReportVo> getAreaReportByMon(List<Dept> deptList, Map<Long, Map<String, Float>> powerMap, List<StationEntity> stationList, String mon) {
private List<AreaMonthReportVo> getAreaReportByMon(List<Dept> deptList, Map<String, Map<String, Float>> powerMap, List<StationEntity> stationList, String mon) {
// 查询所有站点的计划发电量
List<PlanGenerationEntity> planList = this.planPower(stationList, mon);
// 站点实际发电量
Map<Long, Float> actualMap = this.actualPower(powerMap, stationList, mon + "-01");
Map<String, Float> actualMap = this.actualPower(powerMap, stationList, mon + "-01");
// 站点去年发电量
Map<Long, Float> oldActualMap = this.actualPower(powerMap, stationList, lastyear(1,mon));
Map<String, Float> oldActualMap = this.actualPower(powerMap, stationList, lastyear(1,mon));
// 站点前发电量
Map<Long, Float> oldOldActualMap = this.actualPower(powerMap, stationList, lastyear(2,mon));
Map<String, Float> oldOldActualMap = this.actualPower(powerMap, stationList, lastyear(2,mon));
// 取机构中区域部分
List<Dept> areaList = deptList.stream().filter(o -> o.getDeptCategory().equals(3)).collect(Collectors.toList());
if (CollectionUtil.isEmpty(areaList)) {
@ -295,14 +294,14 @@ public class ReportServiceImpl implements ReportService {
/**
* 获取站点月份实际发电量
*/
private Map<Long, Float> actualPower(Map<Long, Map<String, Float>> powerMap, List<StationEntity> stationList, String month) {
private Map<String, Float> actualPower(Map<String, Map<String, Float>> powerMap, List<StationEntity> stationList, String month) {
if (MapUtils.isEmpty(powerMap)) {
return null;
}
// 站点Id集合
List<Long> stationIdList = stationList.stream().map(StationEntity::getId).collect(Collectors.toList());
List<String> stationIdList = stationList.stream().map(StationEntity::getCode).collect(Collectors.toList());
// 存储站点实际发电量
Map<Long, Float> actualPowerMap = new HashMap<>();
Map<String, Float> actualPowerMap = new HashMap<>();
stationIdList.forEach(key -> {
Map<String, Float> monthMap = powerMap.get(key);
if (MapUtils.isEmpty(monthMap)) {
@ -349,7 +348,7 @@ public class ReportServiceImpl implements ReportService {
* @param areaStationList
* @param areaMonthReport
*/
private void powerMonth(List<PlanGenerationEntity> planList, Map<Long, Float> actualMap, Map<Long, Float> oldActualMap, List<StationEntity> areaStationList, AreaMonthReportVo areaMonthReport) {
private void powerMonth(List<PlanGenerationEntity> planList, Map<String, Float> actualMap, Map<String, Float> oldActualMap, List<StationEntity> areaStationList, AreaMonthReportVo areaMonthReport) {
// 计划发电量
List<String> codeList = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList());
double planPower = planList.stream().filter(o -> codeList.contains(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
@ -360,8 +359,8 @@ public class ReportServiceImpl implements ReportService {
return;
}
// 实际发电量
List<Long> ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList());
double actualPower = actualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
List<String> codes = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList());
double actualPower = actualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
areaMonthReport.setActualPower(Float.parseFloat(String.valueOf(actualPower)));
if (Math.abs(planPower) <= 0) {
areaMonthReport.setPowerFinishRate(0.0);
@ -371,7 +370,7 @@ public class ReportServiceImpl implements ReportService {
areaMonthReport.setPowerFinishRate(powerFinishRate);
}
// 同比
double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
double oldActualPower = oldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
if (Math.abs(actualPower) <= 0 || Math.abs(oldActualPower) <= 0) {
areaMonthReport.setComparePowerRate(0.0);
return;
@ -490,15 +489,15 @@ public class ReportServiceImpl implements ReportService {
* @param areaStationList
* @param areaMonthReport
*/
private void predictPlanPower(Map<Long, Float> oldActualMap, Map<Long, Float> oldOldActualMap, List<StationEntity> areaStationList, AreaMonthReportVo areaMonthReport) {
private void predictPlanPower(Map<String, Float> oldActualMap, Map<String, Float> oldOldActualMap, List<StationEntity> areaStationList, AreaMonthReportVo areaMonthReport) {
areaMonthReport.setPredictPlanPower(0.0);
// 实际发电量
List<Long> ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList());
if(CollectionUtil.isEmpty(ids)){
List<String> codes = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList());
if(CollectionUtil.isEmpty(codes)){
return;
}
double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
double oldOldActualPower = oldOldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
double oldActualPower = oldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
double oldOldActualPower = oldOldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
if(Math.abs(oldActualPower) <= 0 && Math.abs(oldOldActualPower) <= 0 ){
return;
}
@ -1009,7 +1008,7 @@ public class ReportServiceImpl implements ReportService {
EchartValueVo echartValue = new EchartValueVo();
echartValue.setAttribute(value.getSignage());
echartValue.setAttributeName(attributes.stream().filter(o->o.getSignage().equals(value.getSignage())).collect(Collectors.toList()).get(0).getSignageName());
if(StringUtil.isEmpty(value.getVal())){
if(StringUtil.isBlank(value.getVal())){
echartValue.setValue(0.0);
}else{
echartValue.setValue(Double.parseDouble(value.getVal()));

129
hzims-service/hzims-simulate/pom.xml

@ -1,129 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.hnac.hzims</groupId>
<artifactId>hzims-service</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hzims-simulate</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>failureaccess</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-common</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-boot</artifactId>
<exclusions>
<exclusion>
<groupId>org.springblade</groupId>
<artifactId>blade-core-cloud</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-http</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-cloud</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-datascope</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>equipment-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>weather-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.hzinfo.framework</groupId>
<artifactId>hnac-framework-mqtt-starters</artifactId>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-cloud</artifactId>
<version>5.1.1.RELEASE.fix.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.name}-${project.version}</finalName>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.6</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

28
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java

@ -1,28 +0,0 @@
package com.hnac.hzims.simulate;
import org.mybatis.spring.annotation.MapperScan;
import org.springblade.core.cloud.feign.EnableBladeFeign;
import org.springblade.core.launch.BladeApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.SpringCloudApplication;
/**
* @author admin
*/
@EnableBladeFeign
@SpringCloudApplication
@MapperScan(basePackages={"com.hnac.hzims.**.mapper"})
//@ComponentScan(basePackages = {"com.hnac.hzinfo.simulate"})
public class SimulateApplication extends SpringBootServletInitializer {
static String APPLICATION_NAME="hzims-simulate";
public static void main(String[] args) {
BladeApplication.run(APPLICATION_NAME, SimulateApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return BladeApplication.createSpringApplicationBuilder(builder, APPLICATION_NAME, SimulateApplication.class);
}
}

43
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java

@ -1,43 +0,0 @@
package com.hnac.hzims.simulate.constants;
/**
* @author ysj
* @describe 实时数据写入常量
*/
public interface WriteRealDataConstant {
String REAL_DATA_V3 = "3";
String REAL_DATA_V4 = "4";
String GATE_FLOW = "过闸流量(m³/s)";
String OPENING_DEGREE = "开度(m)";
String GATE_STATUS = "闸门状态";
String WRITE_REAL_GATE_DATA = "writeRealGateData";
String WRITE_REAL_RAIN_DATA = "writeRealRainData";
Long OPEN = 0L;
Long CLOSE = 1L;
String WRITE_GATE = "1";
String WRITE_RAIN = "2";
// 降雨站属性标识
String ATTR_RAIN = "attr_rain";
String ATTR_WIND360 = "wind360";
String ATTR_WIND_SCALE = "wind_scale";
String ATTR_WIND_SPEED = "wind_speed ";
String ATTR_HUMIDITY = "humidity";
String ATTR_PRESSURE = "pressure";
String ATTR_VIS = "vis";
String ATTR_CLOUD = "cloud";
String ATTR_DEW = "dew";
String ATTR_FEELS_LIKE = "feels_like";
String ATTR_TEMP = "temp";
}

31
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java

@ -1,31 +0,0 @@
package com.hnac.hzims.simulate.controller;
import com.hnac.hzims.simulate.service.WriteRealDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ysj
*/
@RestController
@AllArgsConstructor
@RequestMapping("/gate")
@Api(value = "闸门开关机模拟服务", tags = "闸门开关机模拟服务")
public class GageController {
private final WriteRealDataService writeRealDataService;
@GetMapping("/isOpen")
@ApiOperation(value = "枢纽天气情况")
public R<Boolean> weather(@RequestParam("deviceCode") String deviceCode,
@RequestParam("isOpen") Long isOpen){
return R.data(writeRealDataService.isOpen(deviceCode,isOpen));
}
}

195
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java

@ -1,195 +0,0 @@
package com.hnac.hzims.simulate.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.Maps;
import com.hnac.hzims.common.enums.ExceptionEnum;
import com.hnac.hzims.simulate.entity.DataModel;
import com.hnac.hzims.simulate.entity.Device;
import com.hnac.hzims.simulate.entity.DeviceField;
import com.hnac.hzims.simulate.entity.DeviceFieldGap;
import com.hnac.hzims.simulate.service.DeviceFieldGapService;
import com.hnac.hzims.simulate.service.DeviceFieldService;
import com.hnac.hzims.simulate.service.SimulationService;
import com.hnac.hzims.simulate.util.ParseFacUtils;
import com.hnac.hzims.simulate.util.TopicConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.mqtt.producer.IMqttSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/simulationData")
@Api(value = "数据模拟服务", tags = "数据模拟服务")
@Slf4j
public class SimulationDataController {
@Autowired
private SimulationService simulationService;
@Autowired
private DeviceFieldService deviceFieldService;
@Autowired
private DeviceFieldGapService deviceFieldGapService;
@Autowired
private IMqttSender mqttSender;
@Value("fac.path")
private String facPath;
public static Map<String, String> cacheMap = Maps.newHashMap();
@ApiOperation(value = "解析v3.0场信息文件", notes = "解析场信息文件")
@GetMapping("/readFac")
public R<Void> readFac() {
InputStream inputStream = null;
try {
inputStream = new FileInputStream(new File(facPath+File.separator+"factory.fac"));
List<DataModel> list = ParseFacUtils.parsePoint(inputStream);
list.forEach(entity -> {
mqttSender.sendToMqtt(TopicConstant.TOPIC_DEVICE_MODEL, JsonUtil.toJson(entity));
});
return R.success("解析场信息文件成功");
} catch (Exception e) {
log.error(e.getMessage(), e);
return R.fail("解析场信息文件失败");
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
@ApiOperation(value = "分页范围配置", notes = "分页范围配置")
@GetMapping("/pageGap")
public R<IPage<DeviceFieldGap>> pageGap(String stationId, Query query) {
List<Device> list=simulationService.getDeviceListByStationId(stationId);
List<String> ids=list.stream().map(Device::getId).collect(Collectors.toList());
LambdaQueryWrapper<DeviceFieldGap> lambdaQueryWrapper=new LambdaQueryWrapper();
lambdaQueryWrapper.in(DeviceFieldGap::getFacDeviceId,ids);
IPage<DeviceFieldGap> pageList=deviceFieldGapService.page(Condition.getPage(query),lambdaQueryWrapper);
return R.data(pageList);
}
@ApiOperation(value = "更新设备属性范围配置", notes = "更新设备属性范围配置")
@PostMapping("/updateGap")
public R updateGap(@RequestBody DeviceFieldGap deviceFieldGap) {
deviceFieldGapService.updateById(deviceFieldGap);
return R.status(true);
}
@ApiOperation(value = "第一次同步设备属性", notes = "第一次同步设备属性")
@GetMapping("/syncOneGap")
public R syncGap() {
//存在表
int count=deviceFieldService.existGapTable();
if(count<=0){//建表
deviceFieldService.createGapTable();
}
//同步
List<DeviceField> list=deviceFieldService.list();
List<DeviceFieldGap> gaps=list.stream().map(result -> new DeviceFieldGap(result.getId(), result.getFacDeviceId(),
result.getSignage(),result.getName(), BigDecimal.ZERO,BigDecimal.ZERO))
.collect(Collectors.toList());
deviceFieldGapService.saveOrUpdateBatch(gaps);
return R.status(true);
}
@ApiOperation(value = "第二次同步设备属性", notes = "第二次同步设备属性")
@GetMapping("/syncTwoGap")
public R syncTwoGap() {
//同步
List<DeviceField> list=deviceFieldService.queryNewInsert();
if(list!=null && !list.isEmpty()) {
List<DeviceFieldGap> gaps = list.stream().map(result -> new DeviceFieldGap(result.getId(), result.getFacDeviceId(),
result.getSignage(), result.getName(), BigDecimal.ZERO, BigDecimal.ZERO))
.collect(Collectors.toList());
deviceFieldGapService.saveBatch(gaps);
}
return R.status(true);
}
@ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据")
@GetMapping("/simulationMultiple")
public R<Void> simulationMultipleV3(String stationId, Long sleepTime) {
String key = "simulation:" + stationId;
String hasExc = cacheMap.get(key);
if (Func.isNotBlank(hasExc)) {
return R.fail("该站已经在模拟数据了");
}
try {
simulationService.simulationMultiple(stationId, sleepTime);
}catch (Exception e) {
throw new ServiceException(ExceptionEnum.SIMULATE_ERROR);
}
cacheMap.put(key, "true");
return R.status(true);
}
@ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据")
@GetMapping("/simulationMultipleV4")
public R<Void> simulationMultipleV4(String stationId, Long sleepTime) {
String key = "simulation:" + stationId;
String hasExc = cacheMap.get(key);
if (Func.isNotBlank(hasExc)) {
return R.fail("该站已经在模拟数据了");
}
try {
simulationService.simulationMultipleV4(stationId, sleepTime);
}catch (Exception e) {
throw new ServiceException(ExceptionEnum.SIMULATE_ERROR);
}
cacheMap.put(key, "true");
return R.status(true);
}
// @ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据")
// @GetMapping("/simulationMultipleFlow")
// public R<Void> simulationMultipleInFlow() {
// String key = "simulationMultipleInFlow";
// String hasExc = cacheMap.get(key);
// if (Func.isNotBlank(hasExc)) {
// return R.fail("该站已经在模拟数据了");
// }
// simulationService.simulationMultipleInFlow();
// cacheMap.put(key, "true");
// return R.status(true);
// }
@ApiOperation(value = "停止模拟", notes = "停止模拟")
@GetMapping("/stopStart")
public R<Void> stopStart() {
simulationService.stopStart();
return R.status(true);
}
}

20
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java

@ -1,20 +0,0 @@
package com.hnac.hzims.simulate.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class DataItem {
private String id;
private String signage;//hz3000定义的id
private String name;
private String type;
private String soeType;
private String eventType;
}

46
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java

@ -1,46 +0,0 @@
package com.hnac.hzims.simulate.entity;
import lombok.Data;
import java.util.List;
/**
* {
* "station": "4543",
* "structType": "dataGroup",
* "id": "5016387599_0",
* "pid": "5016387585",
* "name": "温度传感器",
* "children": [{
* "id": "5016387607",
* "name": "温度",
* "type": "YC"
* },{
* "id": "5016387617",
* "name": "高度",
* "type": "YC"
* },{
* "id": "5016387608",
* "name": "工作状态",
* "type": "YX"
* },{
* "id": "5016387609",
* "name": "工作状态",
* "type": "SOE",
* "eventType": ""
* }]
* }
* 数据组
* @author ninglong
*/
@Data
public class DataModel {
private String station;
private String structType;
private String id;
private String signage;//hz3000定义的id
private String pid;
private String name;
private List<DataItem> children;
}

66
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java

@ -1,66 +0,0 @@
package com.hnac.hzims.simulate.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 数据组
*
* @author ninglong
*/
@TableName(value = "hzinfo_fac_device")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Device implements Serializable {
@ApiModelProperty(value = "id")
@TableId(type = IdType.INPUT)
private String id;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "0-云端cms,1-站端直传")
private Integer source;
@ApiModelProperty("hz3000定义的id,如果定义的是大id则值与id字段值相同")
private String sid;
@ApiModelProperty("version=v3,version=v4")
private String modelKind;
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty("创建时间")
private Date createTime;
@JsonSerialize(
using = ToStringSerializer.class
)
@ApiModelProperty("项目id")
private String projectId;
@ApiModelProperty("写入方式")
private String isWrite;
}

22
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java

@ -1,22 +0,0 @@
package com.hnac.hzims.simulate.entity;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 设备数据
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class DeviceData {
private String station;
private String time;
private List<Kvtq> children = Lists.newArrayList();
}

19
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java

@ -1,19 +0,0 @@
package com.hnac.hzims.simulate.entity;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class DeviceDataV4 {
private String stationId;
private String time;
private List<KvtqV4> children = Lists.newArrayList();
}

38
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java

@ -1,38 +0,0 @@
package com.hnac.hzims.simulate.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author ysj
*/
@TableName("hzinfo_fac_device_config")
@Data
public class DeviceFacConfig implements Serializable {
@ApiModelProperty("id")
@TableId(type = IdType.INPUT)
private String id;
@ApiModelProperty("设备id")
private String deviceCode;
@ApiModelProperty("字段标识")
private String facDeviceId;
@ApiModelProperty("站点Id")
private String stationId;
@ApiModelProperty("站点类型")
private String modelKind;
@ApiModelProperty("sid")
private String sid;
@ApiModelProperty("数据写入方式: 1-闸门,2-天气")
private String writeMethod;
}

42
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java

@ -1,42 +0,0 @@
package com.hnac.hzims.simulate.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@TableName("hzinfo_fac_device_attr")
@Data
public class DeviceField implements Serializable {
@ApiModelProperty("id")
@TableId(type = IdType.INPUT)
private String id;
@ApiModelProperty("设备id")
private String facDeviceId;
@ApiModelProperty("字段标识")
private String signage;
@ApiModelProperty("字段名称")
private String name;
@ApiModelProperty("最大值")
private String projectId;
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty("创建时间")
private Date createTime;
private Long modelClassifyId;
private String alarmType;
}

30
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java

@ -1,30 +0,0 @@
package com.hnac.hzims.simulate.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@TableName("hzinfo_fac_device_attr_gap")
@Data
@AllArgsConstructor
public class DeviceFieldGap implements Serializable {
@ApiModelProperty("id")
@TableId(type = IdType.INPUT)
private String id;
@ApiModelProperty("设备id")
private String facDeviceId;
@ApiModelProperty("字段标识")
private String signage;
@ApiModelProperty("字段名称")
private String name;
@ApiModelProperty("最大值")
private BigDecimal maxVal;
@ApiModelProperty("最小值")
private BigDecimal minVal;
}

33
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java

@ -1,33 +0,0 @@
package com.hnac.hzims.simulate.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author ysj
*/
@TableName("hzinfo_fac_device_rain_gap")
@Data
public class DeviceRainGap implements Serializable {
@ApiModelProperty("id")
@TableId(type = IdType.INPUT)
private String id;
@ApiModelProperty("设备id")
private String facDeviceId;
@ApiModelProperty("属性标识名称")
private String name;
@ApiModelProperty("属性标识")
private String attribute;
@ApiModelProperty("字段标识")
private String signage;
}

18
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java

@ -1,18 +0,0 @@
package com.hnac.hzims.simulate.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Kvtq {
private String k;
private String v;
private String t;
private Integer q;
}

18
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java

@ -1,18 +0,0 @@
package com.hnac.hzims.simulate.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class KvtqV4 {
private String sid;
private String k;
private String v;
private String t;
private Integer q;
}

19
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java

@ -1,19 +0,0 @@
package com.hnac.hzims.simulate.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.simulate.entity.DeviceFacConfig;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author ysj
*/
@Mapper
public interface DeviceFacConfigMapper extends BaseMapper<DeviceFacConfig> {
List<DeviceFacConfig> queryConfigDevice(@Param("method") String method);
DeviceFacConfig configByDeviceCode(@Param("deviceCode") String deviceCode);
}

13
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.simulate.mapper.DeviceFacConfigMapper">
<select id="queryConfigDevice" resultType="com.hnac.hzims.simulate.entity.DeviceFacConfig">
SELECT * FROM HZINFO_FAC_DEVICE_CONFIG
WHERE WRITE_METHOD = #{method}
</select>
<select id="configByDeviceCode" resultType="com.hnac.hzims.simulate.entity.DeviceFacConfig">
SELECT * FROM HZINFO_FAC_DEVICE_CONFIG
WHERE DEVICE_CODE = #{deviceCode}
</select>
</mapper>

16
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java

@ -1,16 +0,0 @@
package com.hnac.hzims.simulate.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.simulate.entity.DeviceFieldGap;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
@Mapper
public interface DeviceFieldGapMapper extends BaseMapper<DeviceFieldGap> {
List<DeviceFieldGap> queryDeviceLimits(@Param("signages") List<String> signages);
void updateLimitById(@Param("maxValue") BigDecimal maxValue, @Param("minValue") BigDecimal minValue,@Param("id") String id);
}

19
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java

@ -1,19 +0,0 @@
package com.hnac.hzims.simulate.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.simulate.entity.DeviceField;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface DeviceFieldMapper extends BaseMapper<DeviceField> {
int existGapTable();
int createGapTable();
List<DeviceField> queryNewInsert();
List<DeviceField> queryDeviceFields(@Param("devices") List<String> devices);
List<DeviceField> querySignages(@Param("facDeviceId") String facDeviceId);
}

34
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.simulate.mapper.DeviceFieldMapper">
<select id="existGapTable" resultType="int">
select count(*) from information_schema.TABLES where table_name = 'hzinfo_device_field_gap'
</select>
<update id="createGapTable">
CREATE TABLE hzinfo_device_field_gap (
id varchar(64) COLLATE utf8mb4_bin NOT NULL COMMENT '字段类型',
fac_device_id varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '设备实例id',
signage varchar(25) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字段标识',
name varchar(100) COLLATE utf8mb4_bin NOT NULL COMMENT '字段名称',
max_val decimal(9,3) DEFAULT NULL,
min_val decimal(9,3) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='设备字段'
</update>
<select id="queryNewInsert" resultType="com.hnac.hzims.simulate.entity.DeviceField">
select * from hzinfo_fac_device_attr field where NOT EXISTS (select id from hzinfo_fac_device_attr_gap gap where field.id=gap.id)
</select>
<select id="queryDeviceFields" resultType="com.hnac.hzims.simulate.entity.DeviceField">
select * from hzinfo_fac_device_attr
where fac_device_id in
<foreach collection="devices" item="item" open="(" close=")" separator="," >
#{item}
</foreach>
</select>
<select id="querySignages" resultType="com.hnac.hzims.simulate.entity.DeviceField">
SELECT * FROM HZINFO_FAC_DEVICE_ATTR
WHERE FAC_DEVICE_ID = #{facDeviceId}
</select>
</mapper>

15
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java

@ -1,15 +0,0 @@
package com.hnac.hzims.simulate.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.simulate.entity.Device;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface DeviceMapper extends BaseMapper<Device> {
String getSid(@Param("stationId") String stationId);
// List<String> selectStcd();
//
// int insertData(@Param("param") Map<String,Object> param);
}

15
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.simulate.mapper.DeviceMapper">
<select id="getSid" resultType="java.lang.String">
select sid from hzinfo_fac_device where project_id=#{stationId} limit 1
</select>
<!-- <select id="selectStcd" resultType="java.lang.String">-->
<!-- select rscd from blade_ris.st_rsr_bsin where is_deleted=0-->
<!-- </select>-->
<!-- <insert id="insertData" keyProperty="id" useGeneratedKeys="true">-->
<!-- insert into blade_ris.reservoir_data(STCD,DT,INFLOW) values (#{param.stcd},#{param.dt},#{param.inflow})-->
<!-- </insert>-->
</mapper>

17
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java

@ -1,17 +0,0 @@
package com.hnac.hzims.simulate.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.simulate.entity.DeviceRainGap;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author ysj
*/
@Mapper
public interface DeviceRainGapMapper extends BaseMapper<DeviceRainGap> {
List<DeviceRainGap> RainGapByFacDeviceId(@Param("facDeviceId") String facDeviceId);
}

9
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.simulate.mapper.DeviceRainGapMapper">
<select id="RainGapByFacDeviceId" resultType="com.hnac.hzims.simulate.entity.DeviceRainGap">
SELECT * FROM HZINFO_FAC_DEVICE_RAIN_GAP
WHERE FAC_DEVICE_ID = #{facDeviceId}
</select>
</mapper>

18
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.simulate.mapper.DeviceFieldGapMapper">
<select id="queryDeviceLimits" resultType="com.hnac.hzims.simulate.entity.DeviceFieldGap">
select * from HZINFO_FAC_DEVICE_ATTR_GAP
where signage in
<foreach collection="signages" item="item" open="(" close=")" separator="," >
#{item}
</foreach>
</select>
<update id="updateLimitById">
UPDATE HZINFO_FAC_DEVICE_ATTR_GAP
SET max_val = #{maxValue},
min_val = #{minValue}
WHERE id = #{id}
</update>
</mapper>

53
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java

@ -1,53 +0,0 @@
package com.hnac.hzims.simulate.scheduled;
import com.hnac.hzims.simulate.constants.WriteRealDataConstant;
import com.hnac.hzims.simulate.service.WriteRealDataService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* @author ysj
* @describe 实时数据写入定时任务
*/
@Slf4j
@Component
public class WriteRealDataTask {
@Autowired
private WriteRealDataService writeRealDataService;
/**
* 设备模型信息
*/
@XxlJob(WriteRealDataConstant.WRITE_REAL_GATE_DATA)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> writeRealGateData(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
writeRealDataService.writeRealGateData(param);
return new ReturnT<>("SUCCESS");
}
/**
* 设备模型信息
*/
@XxlJob(WriteRealDataConstant.WRITE_REAL_RAIN_DATA)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> writeRealRainData(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
writeRealDataService.writeRealRainData(param);
return new ReturnT<>("SUCCESS");
}
}

11
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java

@ -1,11 +0,0 @@
package com.hnac.hzims.simulate.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.simulate.entity.DeviceFieldGap;
import com.hnac.hzims.simulate.mapper.DeviceFieldGapMapper;
import org.springframework.stereotype.Service;
@Service
public class DeviceFieldGapService extends ServiceImpl<DeviceFieldGapMapper, DeviceFieldGap> {
}

24
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java

@ -1,24 +0,0 @@
package com.hnac.hzims.simulate.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.simulate.entity.DeviceField;
import com.hnac.hzims.simulate.mapper.DeviceFieldMapper;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class DeviceFieldService extends ServiceImpl<DeviceFieldMapper, DeviceField> {
public int existGapTable(){
return this.baseMapper.existGapTable();
}
public int createGapTable(){
return this.baseMapper.createGapTable();
}
public List<DeviceField> queryNewInsert(){
return this.baseMapper.queryNewInsert();
}
}

21
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java

@ -1,21 +0,0 @@
package com.hnac.hzims.simulate.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.simulate.entity.Device;
import com.hnac.hzims.simulate.mapper.DeviceMapper;
import org.springframework.stereotype.Service;
@Service
public class DeviceService extends ServiceImpl<DeviceMapper, Device> {
public String getSid(String stationId){
return this.baseMapper.getSid(stationId);
}
// public List<String> selectStcd(){
// return this.baseMapper.selectStcd();
// }
//
// public int insertData(Map<String,Object> param){
// return this.baseMapper.insertData(param);
// }
}

280
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java

@ -1,280 +0,0 @@
package com.hnac.hzims.simulate.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.hnac.hzims.simulate.entity.*;
import com.hnac.hzims.simulate.util.DataConstants;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.DateTimeUtil;
import org.springblade.core.tool.utils.ThreadUtil;
import org.springblade.mqtt.producer.IMqttSender;
import com.hnac.hzims.simulate.util.TopicConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Slf4j
public class SimulationService {
@Autowired
IMqttSender mqttSender;
@Autowired
DeviceService deviceService;
@Autowired
DeviceFieldService deviceFieldService;
@Autowired
DeviceFieldGapService deviceFieldGapService;
public List<Device> getDeviceListByStationId(String projectId){
LambdaQueryWrapper<Device> lambdaQueryWrapper=new LambdaQueryWrapper();
lambdaQueryWrapper.eq(Device::getProjectId,projectId);
lambdaQueryWrapper.eq(Device::getIsWrite,"0");
List<Device> list = deviceService.list(lambdaQueryWrapper);
return list;
}
String getSid(String stationId){
return deviceService.getSid(stationId);
}
//模拟启停标识
private volatile boolean flag=true;
public void stopStart(){
flag = !flag;
}
@Async
public void simulationMultiple(String stationId, Long sleepTime) {
List<Device> list = getDeviceListByStationId(stationId);
//查询所有属性
List<DeviceField> fieldList = deviceFieldService.list();
List<DeviceFieldGap> gapList = deviceFieldGapService.list();
log.info("本站{}有{}个设备实例,每{}毫秒发送{}条数据", stationId, list.size(), sleepTime, list.size());
while (true) {
if (flag) {//启动或关闭模拟
for (Device device : list) {
Map<String, DeviceData> map = simulation(stationId, device,fieldList,gapList);
// log.info("map data: "+ JsonUtil.toJson(map));
if (map.get("yc") != null && map.get("yc").getChildren().size() > 0) {
log.info("模拟推送遥测,主题:topic_hzinfo_props:{}", JsonUtil.toJson(map.get("yc")));
mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_PROPS, JsonUtil.toJson(map.get("yc")));
}
// if (map.get("dd") != null && map.get("dd").getChildren().size() > 0) {
// mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_DD, JsonUtil.toJson(map.get("dd")));
// }
if (map.get("yx") != null && map.get("yx").getChildren().size() > 0) {
mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_YX, JsonUtil.toJson(map.get("yx")));
}
}
//最小10毫秒
if (sleepTime == null || sleepTime == 0) {
sleepTime = 10L;
}
ThreadUtil.sleep(sleepTime);
}
}
}
// @Async
// public void simulationMultipleInFlow(){
// List<String> list=deviceService.selectStcd();
// while (true) {
// List<Map<String,Object>> datas = simulationFlow(list);
// for(Map<String,Object> param:datas){
// deviceService.insertData(param);
// }
// ThreadUtil.sleep(3600000);
// }
// }
private List<Map<String,Object>> simulationFlow(List<String> list){
List<Map<String,Object>> datas =new ArrayList<>();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dt=sdf.format(new Date());
for(String stcd:list){
Map<String,Object> data=new HashMap<>();
String value = getRandomRedPacketBetweenMinAndMax(new BigDecimal("0"), new BigDecimal("20")).toString();
data.put("stcd",stcd);
data.put("dt",dt);
data.put("inflow",value);
datas.add(data);
}
return datas;
}
@Async
public void simulationMultipleV4(String stationId, Long sleepTime){
String sid=getSid(stationId);
List<Device> list = getDeviceListByStationId(stationId);
//查询所有属性
List<DeviceField> fieldList = deviceFieldService.list();
List<DeviceFieldGap> gapList = deviceFieldGapService.list();
log.info("本站{}有{}个设备实例,每{}毫秒发送{}条数据", stationId, list.size(), sleepTime, list.size());
while (true) {
if (flag) {//启动或关闭模拟
for (Device device : list) {
Map<String, DeviceDataV4> map = simulationV4(stationId,sid, device,fieldList,gapList);
//log.info("map data: "+ JsonUtil.toJson(map));
if (map.get("yc") != null && map.get("yc").getChildren().size() > 0) {
mqttSender.sendToMqtt("hzinfo_v4_yc", JsonUtil.toJson(map.get("yc")));
}
// if (map.get("dd") != null && map.get("dd").getChildren().size() > 0) {
// mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_DD, JsonUtil.toJson(map.get("dd")));
// }
if (map.get("yx") != null && map.get("yx").getChildren().size() > 0) {
mqttSender.sendToMqtt("hzinfo_v4_yx", JsonUtil.toJson(map.get("yx")));
}
}
//最小10毫秒
if (sleepTime == null || sleepTime == 0) {
sleepTime = 10L;
}
ThreadUtil.sleep(sleepTime);
}
}
}
public static BigDecimal getRandomRedPacketBetweenMinAndMax(BigDecimal min, BigDecimal max){
float minF = min.floatValue();
float maxF = max.floatValue();
//生成随机数
BigDecimal db = new BigDecimal(Math.random() * (maxF - minF) + minF);
//返回保留两位小数的随机数。不进行四舍五入
return db.setScale(3,BigDecimal.ROUND_DOWN);
}
public static int getIntBetweenMinAndMax(int min, int max){
//生成随机数
int randomNum = min + (int)(Math.random() * ((max - min) + 1));
//返回保留两位小数的随机数。不进行四舍五入
return randomNum;
}
/**
* 模拟一条数据
*/
private Map<String, DeviceData> simulation(String stationId, Device device,List<DeviceField> fieldListAll,List<DeviceFieldGap> gapListAll) {
// List<DeviceField> fieldList = getListByDeviceId(device.getId());
// List<DeviceFieldGap> gapList = getListByDeviceGapId(device.getId());
List<DeviceField> fieldList =fieldListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList());
List<DeviceFieldGap> gapList =gapListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList());
// log.info("fieldList data: "+ JsonUtil.toJson(fieldList));
// log.info("gapList data: "+ JsonUtil.toJson(gapList));
List<Kvtq> ycList = Lists.newArrayList();
List<Kvtq> yxList = Lists.newArrayList();
//List<Kvtq> ddList = Lists.newArrayList();
for (DeviceField field : fieldList) {
Optional<DeviceFieldGap> gapOpt=gapList.stream().filter(e->e.getSignage().equals(field.getSignage())).findFirst();
if (DataConstants.DeviceDataType.YC.ordinal()== field.getModelClassifyId().intValue()) {
if(gapOpt!=null) {
DeviceFieldGap gap=gapOpt.get();
String value = getRandomRedPacketBetweenMinAndMax(gap.getMinVal(), gap.getMaxVal()).toString();
Kvtq kvtq = Kvtq.builder().k(field.getSignage()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build();
ycList.add(kvtq);
}
}
// if (DataConstants.DeviceDataType.DD.name().equals(field.getType())) {
// String value = Func.random(1, RandomType.INT) + "." + Func.random(1, RandomType.INT);
// Kvtq kvtq = Kvtq.builder().k(field.getId()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build();
// ddList.add(kvtq);
// }
if (DataConstants.DeviceDataType.YX.ordinal()== field.getModelClassifyId().intValue()) {
if(gapOpt!=null) {
DeviceFieldGap gap=gapOpt.get();
int value = getIntBetweenMinAndMax(gap.getMinVal().intValue(), gap.getMaxVal().intValue());
Kvtq kvtq = Kvtq.builder().k(field.getSignage()).v(String.valueOf(value)).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build();
yxList.add(kvtq);
}
}
}
Map<String, DeviceData> map = Maps.newHashMap();
if (ycList.size() > 0) {
map.put("yc", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycList).build());
}
// if (ddList.size() > 0) {
// map.put("dd", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ddList).build());
// }
if (yxList.size() > 0) {
map.put("yx", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxList).build());
}
return map;
}
private Map<String, DeviceDataV4> simulationV4(String stationId,String sid, Device device,List<DeviceField> fieldListAll,List<DeviceFieldGap> gapListAll) {
// List<DeviceField> fieldList = getListByDeviceId(device.getId());
// List<DeviceFieldGap> gapList = getListByDeviceGapId(device.getId());
List<DeviceField> fieldList =fieldListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList());
List<DeviceFieldGap> gapList =gapListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList());
// log.info("fieldList data: "+ JsonUtil.toJson(fieldList));
// log.info("gapList data: "+ JsonUtil.toJson(gapList));
List<KvtqV4> ycList = Lists.newArrayList();
List<KvtqV4> yxList = Lists.newArrayList();
//List<Kvtq> ddList = Lists.newArrayList();
for (DeviceField field : fieldList) {
Optional<DeviceFieldGap> gapOpt=gapList.stream().filter(e->e.getSignage().equals(field.getSignage())).findFirst();
if (DataConstants.DeviceDataType.YC.ordinal()== field.getModelClassifyId().intValue()) {
if(gapOpt!=null) {
DeviceFieldGap gap=gapOpt.get();
String value = getRandomRedPacketBetweenMinAndMax(gap.getMinVal(), gap.getMaxVal()).toString();
KvtqV4 kvtq = KvtqV4.builder().sid(sid).k(field.getSignage()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build();
ycList.add(kvtq);
}
}
// if (DataConstants.DeviceDataType.DD.name().equals(field.getType())) {
// String value = Func.random(1, RandomType.INT) + "." + Func.random(1, RandomType.INT);
// Kvtq kvtq = Kvtq.builder().k(field.getId()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build();
// ddList.add(kvtq);
// }
if (DataConstants.DeviceDataType.YX.ordinal()== field.getModelClassifyId().intValue()) {
if(gapOpt!=null) {
DeviceFieldGap gap=gapOpt.get();
int value = getIntBetweenMinAndMax(gap.getMinVal().intValue(), gap.getMaxVal().intValue());
KvtqV4 kvtq = KvtqV4.builder().sid(sid).k(field.getSignage()).v(String.valueOf(value)).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build();
yxList.add(kvtq);
}
}
}
Map<String, DeviceDataV4> map = Maps.newHashMap();
if (ycList.size() > 0) {
map.put("yc", DeviceDataV4.builder().stationId(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycList).build());
}
// if (ddList.size() > 0) {
// map.put("dd", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ddList).build());
// }
if (yxList.size() > 0) {
map.put("yx", DeviceDataV4.builder().stationId(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxList).build());
}
return map;
}
private List<DeviceField> getListByDeviceId(String deviceId) {
return deviceFieldService.list(Wrappers.<DeviceField>lambdaQuery().ne(DeviceField::getModelClassifyId, DataConstants.DeviceDataType.SOE.name()).eq(DeviceField::getFacDeviceId, deviceId));
}
private List<DeviceFieldGap> getListByDeviceGapId(String deviceId){
return deviceFieldGapService.list(Wrappers.<DeviceFieldGap>lambdaQuery().eq(DeviceFieldGap::getFacDeviceId, deviceId));
}
}

13
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java

@ -1,13 +0,0 @@
package com.hnac.hzims.simulate.service;
/**
* @author ysj
*/
public interface WriteRealDataService {
void writeRealGateData(String param);
void writeRealRainData(String param);
Boolean isOpen(String deviceCode, Long isOpen);
}

304
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java

@ -1,304 +0,0 @@
package com.hnac.hzims.simulate.service.impl;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse;
import com.hnac.hzims.simulate.constants.WriteRealDataConstant;
import com.hnac.hzims.simulate.entity.*;
import com.hnac.hzims.simulate.mapper.DeviceFacConfigMapper;
import com.hnac.hzims.simulate.mapper.DeviceFieldGapMapper;
import com.hnac.hzims.simulate.mapper.DeviceFieldMapper;
import com.hnac.hzims.simulate.mapper.DeviceRainGapMapper;
import com.hnac.hzims.simulate.service.WriteRealDataService;
import com.hnac.hzims.simulate.util.DataConstants;
import com.hnac.hzims.simulate.util.TopicConstant;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.*;
import org.springblade.mqtt.producer.IMqttSender;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static com.hnac.hzims.simulate.constants.WriteRealDataConstant.REAL_DATA_V3;
import static com.hnac.hzims.simulate.constants.WriteRealDataConstant.REAL_DATA_V4;
/**
* @author ysj
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class WriteRealDataServiceImpl implements WriteRealDataService {
private final IEmInfoClient deviceClient;
private final IHeWeatherWeatherClient weatherClient;
private final IMqttSender mqttSender;
private final DeviceFieldMapper fieldMapper;
private final DeviceFieldGapMapper limitMapper;
private final DeviceFacConfigMapper configMapper;
private final DeviceRainGapMapper deviceRainGapMapper;
/**
* 实时数据写入
* @param param
*/
@Override
public void writeRealGateData(String param) {
// 查询设备配置
List<DeviceFacConfig> configs = configMapper.queryConfigDevice(WriteRealDataConstant.WRITE_GATE);
if(CollectionUtil.isEmpty(configs)){
return;
}
//#.000 表示三位小数
DecimalFormat df = new DecimalFormat("#0.000");
// 遍历发送mqtt实时数据
configs.stream().collect(Collectors.groupingBy(DeviceFacConfig::getModelKind)).forEach((modeKind,groups)->{
// 查询设备属性
List<DeviceField> fields = fieldMapper.queryDeviceFields(groups.stream().map(DeviceFacConfig::getFacDeviceId).collect(Collectors.toList()));
if(CollectionUtil.isEmpty(fields)){
return;
}
// 查询设备限制
List<DeviceFieldGap> limits = limitMapper.queryDeviceLimits(fields.stream().map(DeviceField::getSignage).collect(Collectors.toList()));
if(CollectionUtil.isEmpty(limits)){
return;
}
// v3
if(REAL_DATA_V3.equals(modeKind)){
fields.stream().collect(Collectors.groupingBy(DeviceField::getModelClassifyId)).forEach((key, models) -> models.stream().collect(Collectors.groupingBy(DeviceField::getProjectId)).forEach((projectId, value)-> {
// 遥测实时数据对象
List<Kvtq> ycs = value.stream().filter(o -> DataConstants.DeviceDataType.YC.ordinal() == o.getModelClassifyId()).map(field -> {
List<DeviceFieldGap> limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(limit)) {
return new Kvtq();
}
Kvtq real = new Kvtq();
double random = Math.random() * limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue();
real.setK(field.getSignage());
real.setV(df.format(random));
real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"));
real.setQ(0);
return real;
}).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(ycs)) {
log.error("yc_real_data_v3 : {}", JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build()));
mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_PROPS, JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build()));
}
// 遥信实时数据对象
List<Kvtq> yxs = value.stream().filter(o -> DataConstants.DeviceDataType.YX.ordinal() == o.getModelClassifyId()).map(field -> {
List<DeviceFieldGap> limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(limit)) {
return new Kvtq();
}
Kvtq real = new Kvtq();
double random = limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue();
real.setK(field.getSignage());
real.setV(df.format(random));
real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"));
real.setQ(0);
return real;
}).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(yxs)) {
log.error("yx_real_data_v3 : {}", JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build()));
mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_YX, JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build()));
}
}));
}
// v4
if(REAL_DATA_V4.equals(modeKind)){
fields.stream().collect(Collectors.groupingBy(DeviceField::getModelClassifyId)).forEach((key, models) -> models.stream().collect(Collectors.groupingBy(DeviceField::getProjectId)).forEach((projectId, value)->{
// 遥测实时数据对象
List<KvtqV4> ycs = value.stream().filter(o -> DataConstants.DeviceDataType.YC.ordinal() == o.getModelClassifyId()).map(field -> {
List<DeviceFieldGap> limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(limit)) {
return new KvtqV4();
}
// 查找sid
Optional<DeviceFacConfig> sid = groups.stream().filter(group->field.getFacDeviceId().equals(group.getFacDeviceId())).findFirst();
if(!sid.isPresent()){
return new KvtqV4();
}
KvtqV4 real = new KvtqV4();
double random = Math.random() * limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue();
real.setSid(sid.get().getSid());
real.setK(field.getSignage());
real.setV(df.format(random));
real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"));
real.setQ(0);
return real;
}).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(ycs)) {
log.error("yc_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build()));
mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YC,JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build()));
}
// 遥信实时数据对象
List<KvtqV4> yxs = value.stream().filter(o -> DataConstants.DeviceDataType.YX.ordinal() == o.getModelClassifyId()).map(field -> {
List<DeviceFieldGap> limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(limit)) {
return new KvtqV4();
}
// 查找sid
Optional<DeviceFacConfig> sid = groups.stream().filter(group->field.getFacDeviceId().equals(group.getFacDeviceId())).findFirst();
if(!sid.isPresent()){
return new KvtqV4();
}
KvtqV4 real = new KvtqV4();
double random = limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue();
real.setSid(sid.get().getSid());
real.setK(field.getSignage());
real.setV(df.format(random));
real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"));
real.setQ(0);
return real;
}).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(yxs)) {
log.error("yx_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build()));
mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YX,JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build()));
}
}));
}
});
}
/**
* 雨量站实时数据写入
* @param param
*/
@Override
public void writeRealRainData(String param) {
// 查询设备配置
List<DeviceFacConfig> configs = configMapper.queryConfigDevice(WriteRealDataConstant.WRITE_RAIN);
if(CollectionUtil.isEmpty(configs)){
return;
}
R<List<EmInfoEntity>> devices = deviceClient.getEmInfoByEmCodes(configs.stream().map(DeviceFacConfig::getDeviceCode).collect(Collectors.toList()));
if(!devices.isSuccess() || CollectionUtil.isEmpty(devices.getData())){
return;
}
devices.getData().forEach(device->{
if(ObjectUtil.isEmpty(device.getLgtd()) || ObjectUtil.isEmpty(device.getLttd())){
return;
}
// 查询设备经纬度
String location = device.getLgtd() + "," + device.getLttd();
R<HeWeatherWeatherNowResponse> weather = weatherClient.getWeatherNowWithCache(location);
if(!weather.isSuccess() || ObjectUtil.isEmpty(weather.getData()) || ObjectUtil.isEmpty(weather.getData().getNow())){
return;
}
Optional<DeviceFacConfig> optional = configs.stream().filter(o->o.getDeviceCode().equals(device.getNumber())).findFirst();
if(!optional.isPresent()){
return;
}
List<DeviceRainGap> deviceRainGap = deviceRainGapMapper.RainGapByFacDeviceId(optional.get().getFacDeviceId());
if(CollectionUtil.isEmpty(deviceRainGap)){
return;
}
List<KvtqV4> yxs = deviceRainGap.stream().map(o->{
KvtqV4 real = new KvtqV4();
real.setSid(optional.get().getSid());
real.setK(o.getSignage());
real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"));
real.setQ(0);
if(WriteRealDataConstant.ATTR_RAIN.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getPrecip());
}else if(WriteRealDataConstant.ATTR_WIND360.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getWind360());
}else if(WriteRealDataConstant.ATTR_WIND_SCALE.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getWindScale());
}else if(WriteRealDataConstant.ATTR_WIND_SPEED.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getWindSpeed());
}else if(WriteRealDataConstant.ATTR_HUMIDITY.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getHumidity());
}else if(WriteRealDataConstant.ATTR_PRESSURE.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getPressure());
}else if(WriteRealDataConstant.ATTR_VIS.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getVis());
}else if(WriteRealDataConstant.ATTR_CLOUD.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getCloud());
}else if(WriteRealDataConstant.ATTR_DEW.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getDew());
}else if(WriteRealDataConstant.ATTR_FEELS_LIKE.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getFeelsLike());
}else if(WriteRealDataConstant.ATTR_TEMP.equals(o.getAttribute())){
real.setV(weather.getData().getNow().getTemp());
}
if(StringUtil.isEmpty(real.getV())){
real.setV("0.0");
}
return real;
}).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(yxs)) {
log.error("yx_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(optional.get().getStationId()).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build()));
mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YX,JsonUtil.toJson(DeviceDataV4.builder().stationId(optional.get().getStationId()).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build()));
}
});
}
/**
* 开启/关闭闸门数据
* @param deviceCode
* @param isOpen
* @return
*/
@Override
public Boolean isOpen(String deviceCode, Long isOpen) {
// 查询写入设备配置
DeviceFacConfig config = configMapper.configByDeviceCode(deviceCode);
if(ObjectUtil.isEmpty(config)){
return false;
}
// 查询设备属性
List<DeviceField> fields = fieldMapper.querySignages(config.getFacDeviceId());
if(CollectionUtil.isEmpty(fields)){
return false;
}
// 查询属性限制
List<DeviceFieldGap> limits = limitMapper.queryDeviceLimits(fields.stream().map(DeviceField::getSignage).collect(Collectors.toList()));
if(CollectionUtil.isEmpty(limits)){
return false;
}
limits.forEach(limit->{
Optional<DeviceField> optional = fields.stream().filter(o->o.getSignage().equals(limit.getSignage())).findFirst();
if(!optional.isPresent()){
return;
}
String signage = optional.get().getName();
if(WriteRealDataConstant.GATE_STATUS.equals(signage)){
if(WriteRealDataConstant.OPEN.equals(isOpen)){
limitMapper.updateLimitById(BigDecimal.ONE,BigDecimal.ZERO,limit.getId());
}else{
limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId());
}
}else if(WriteRealDataConstant.GATE_FLOW.equals(signage)){
if(WriteRealDataConstant.OPEN.equals(isOpen)){
limitMapper.updateLimitById(BigDecimal.valueOf(3560.000),BigDecimal.valueOf(0.000),limit.getId());
}else{
limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId());
}
}else if(WriteRealDataConstant.OPENING_DEGREE.equals(signage)){
if(WriteRealDataConstant.OPEN.equals(isOpen)){
limitMapper.updateLimitById(BigDecimal.valueOf(10),BigDecimal.valueOf(0.000),limit.getId());
}else{
limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId());
}
}
});
return true;
}
}

357
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java

@ -1,357 +0,0 @@
package com.hnac.hzims.simulate.util;
public interface DataConstants {
String REDIS_MESSAGE_TOPIC = "hzinfo_config_message_topic";
String TIME_COLUMN = "ts";
String VALUE_COLUMN = "val";
String Q_COLUMN = "q";
String REAL_ID_COLUMN = "realid";
String TBNAME = "tbname";
String YC_TABLE_PREFIX = "yc_";
String YX_TABLE_PREFIX = "yx_";
String SOE_TABLE_PREFIX = "soe_";
String SOE_ALARM_TABLE_PREFIX = "soe_alarm_";
String YC = "YC";
String YX = "YX";
String SOE = "SOE";
String YK_RETURN_PREFIX = "ykfj:";
String REALID_CALCULATE = "16777215";
String DEVICE_SUPER_TABLE_PREFIX = "hz_";
String DEVICE_TABLE_PREFIX = "d_";
public static enum DataStructTypeEnum {
struct,
dataGroup;
private DataStructTypeEnum() {
}
}
public static enum EYkRetStatus {
yrsSuccess,
yrsServerErr,
yrsChannelErr,
yrsModuleErr,
yrsDeviceTimeOut,
yrsDeviceFail,
yrsExpired;
private EYkRetStatus() {
}
}
public static enum SoeType {
skNone(0, "0", "默认"),
skSys(1, "1", "系统"),
skAlarm(2, "2", "报警"),
skAct(3, "3", "事故"),
skOperate(4, "4", "用户操作"),
skYcOut(5, "5,11,12", "遥测越限"),
skYxChange(6, "6,10", "遥信变位"),
skReg(7, "7", "注册信息"),
skHint(8, "8", "信息提示"),
skInspect(9, "9", "设备巡检"),
skMonitorOperate(10, "13,14", "遥控操作"),
skRDSYcOutOfLimitResume(11, "15", "遥测越限恢复"),
skUndefine(12, "16,17,18", "未定义"),
skNetworkAnomaly(13, "-1", "通讯异常"),
skCommunicateAnomaly(14, "-2", "数据异常");
private Integer index;
private String soeKind;
private String name;
private SoeType(Integer index, String soeKind, String name) {
this.index = index;
this.soeKind = soeKind;
this.name = name;
}
public static String getName(Integer id) {
SoeType[] values = values();
for (int i = 0; i < values.length; ++i) {
if (values[i].index.equals(id)) {
return values[i].getName();
}
}
return null;
}
public static Integer getIndexBySoeKind(String soeType) {
SoeType[] values = values();
SoeType[] var2 = values;
int var3 = values.length;
for (int var4 = 0; var4 < var3; ++var4) {
SoeType type = var2[var4];
if (type.getSoeKind().contains(soeType)) {
return type.getIndex();
}
}
return skUndefine.getIndex();
}
public static String getSoeKindByIndex(Integer index) {
SoeType[] values = values();
SoeType[] var2 = values;
int var3 = values.length;
for (int var4 = 0; var4 < var3; ++var4) {
SoeType type = var2[var4];
if (type.getIndex().equals(index)) {
return type.getSoeKind();
}
}
return "";
}
public Integer getIndex() {
return this.index;
}
public String getSoeKind() {
return this.soeKind;
}
public String getName() {
return this.name;
}
}
public static enum SoeKind {
skNone(0, "默认"),
skSys(1, "系统"),
skAlarm(2, "报警"),
skAct(3, "事故"),
skOperate(4, "操作"),
skYcOut(5, "遥测越限(告警)"),
skYxChange(6, "遥信变位(告警)"),
skReg(7, "注册信息"),
skHint(8, "信息提示"),
skInspect(9, "设备巡检"),
skRDSYxChange(10, "遥信变位(数据)"),
skRDSYcOutOfLimit(11, "遥测越上/下限(数据)"),
skRDSYcOutOfLimit2(12, "遥测越上上/下下限(数据)"),
skMonitorOperate(13, "操作记录(遥控)"),
skMonitorOperateII(14, "操作记录(写定值)"),
skRDSYcOutOfLimitResume(15, "越限恢复"),
bak_7(16, "备用7"),
bak_8(17, "备用8"),
skUndefine(18, "未定义");
private Integer index;
private String name;
private SoeKind(Integer index, String name) {
this.index = index;
this.name = name;
}
public static String getName(Integer id) {
SoeKind[] values = values();
for (int i = 0; i < values.length; ++i) {
if (values[i].index.equals(id)) {
return values[i].getName();
}
}
return null;
}
public Integer getIndex() {
return this.index;
}
public String getName() {
return this.name;
}
}
public static enum DeviceDataType {
YC("遥测"),
YX("遥信"),
DD("电渡"),
YK("遥控"),
YT("遥调"),
SOE("事件"),
STR("字符串"),
OTHER("其它");
private String displayName;
private DeviceDataType(String displayName) {
this.displayName = displayName;
}
public static String getDisplayName(String name) {
DeviceDataType type = valueOf(name);
return type.getDisplayName();
}
public String getDisplayName() {
return this.displayName;
}
}
public static enum YkDelayType {
none_store,
store,
delay_store;
private YkDelayType() {
}
}
public static enum RedisGroupMessageTypeEnum {
NOTICE_CLEAN_LOCAL_CACHE_DEVICE("clean.local.cache.device"),
NOTICE_CLEAN_LOCAL_CACHE_DEVICE_GROUP("clean.local.cache.group"),
NOTICE_CLEAN_LOCAL_CACHE_ALARM("clean.local.cache.alarm"),
NOTICE_CLEAN_LOCAL_CACHE_YK("clean.local.cache.yk");
private String value;
private RedisGroupMessageTypeEnum(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
}
public static enum DataStatusEnum {
offline,
online;
private DataStatusEnum() {
}
}
public static enum StatisticsType {
avg("AVG"),
max("MAX"),
min("MIN");
private String computeStrategy;
private StatisticsType(String fun) {
this.computeStrategy = fun;
}
public static StatisticsType getStatisticsType(int index) {
StatisticsType[] values = values();
StatisticsType[] var2 = values;
int var3 = values.length;
for (int var4 = 0; var4 < var3; ++var4) {
StatisticsType value = var2[var4];
if (index == value.ordinal()) {
return value;
}
}
return null;
}
public String getComputeStrategy() {
return this.computeStrategy;
}
public void setComputeStrategy(final String computeStrategy) {
this.computeStrategy = computeStrategy;
}
}
public static enum AnalyzeInstanceAlarmConfType {
changeAlarm("变化告警"),
supassAlarm("越限告警");
private String name;
private AnalyzeInstanceAlarmConfType(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
public static enum StatisticsAnalyEnum {
Hour("h"),
Day("d"),
Month("n"),
Year("h");
private String type;
private StatisticsAnalyEnum(String fun) {
this.type = fun;
}
public static StatisticsAnalyEnum getStatisticsAnalyEnum(int index) {
StatisticsAnalyEnum[] values = values();
StatisticsAnalyEnum[] var2 = values;
int var3 = values.length;
for (int var4 = 0; var4 < var3; ++var4) {
StatisticsAnalyEnum value = var2[var4];
if (value.ordinal() == index) {
return value;
}
}
return null;
}
public String getType() {
return this.type;
}
}
public static enum StationFromSouceEnum {
cloud,
station;
private StationFromSouceEnum() {
}
}
public static enum AnalyzeInstanceDataResoureEnum {
deviceUp("设备上报"),
hz3000Up("华自网关上报");
private String name;
private AnalyzeInstanceDataResoureEnum(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
public static enum ThresholdLevelEnum {
one,
two,
three;
private ThresholdLevelEnum() {
}
}
public static enum Hz3000VersionEnum {
v3,
v4;
private Hz3000VersionEnum() {
}
}
}

105
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java

@ -1,105 +0,0 @@
package com.hnac.hzims.simulate.util;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Lists;
import com.hnac.hzims.simulate.entity.DataItem;
import com.hnac.hzims.simulate.entity.DataModel;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.xml.sax.SAXException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.List;
/**
* 解析厂信息工具类
* @author ninglong
*/
public class ParseFacUtils {
public static List<DataModel> parsePoint(InputStream inputStream) throws SAXException, DocumentException, JsonProcessingException {
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(inputStream);
List groupElements = document.selectNodes("/Factorys/Factory/Group");
List<DataModel> list = parseDataGroup(groupElements);
List ycElements = document.selectNodes("/Factorys/Factory/Group/AIS/AI");
list = pastePointElement(ycElements, DataConstants.DeviceDataType.YC.name(),list);
List yxElements = document.selectNodes("/Factorys/Factory/Group/DIS/DI");
list = pastePointElement(yxElements, DataConstants.DeviceDataType.YX.name(),list);
List ddElements = document.selectNodes("/Factorys/Factory/Group/DDS/DD");
list = pastePointElement(ddElements, DataConstants.DeviceDataType.DD.name(),list);
List soeElements = document.selectNodes("/Factorys/Factory/Group/SOES/SOE");
list = pastePointElement(soeElements, DataConstants.DeviceDataType.SOE.name(),list);
List ykElements = document.selectNodes("/Factorys/Factory/Group/DOS/DO");
list = pastePointElement(ykElements, DataConstants.DeviceDataType.YK.name(),list);
return list;
}
/**
* 解析数据组
*/
private static List<DataModel> parseDataGroup(List elements){
List<DataModel> list = Lists.newArrayList();
for (Element element : (List<Element>) elements) {
DataModel model = new DataModel();
model.setStructType(DataConstants.DataStructTypeEnum.dataGroup.name());
model.setId(element.attribute("ID").getValue());
model.setSignage(bigId2SmallId(element.attribute("ID").getValue()));
model.setName(element.attribute("Name").getValue());
String stationNumStr = element.getParent().attribute("StationNum").getValue();
model.setStation(stationNumStr);
list.add(model);
}
return list;
}
/**
* 将大id转换成小id
*/
public static String bigId2SmallId(String realId){
BigInteger bigRealId = new BigInteger(realId);
return bigRealId.and(new BigInteger(DataConstants.REALID_CALCULATE)).toString();
}
/**
* 解析数据点
*/
private static List<DataModel> pastePointElement(List elements, String type, List<DataModel> list) throws JsonProcessingException {
for (Element element : (List<Element>) elements) {
String groupId = element.getParent().getParent().attribute("ID").getValue();
for(DataModel dm:list){
if(!groupId.equals(dm.getId())){
continue;
}
DataItem dataItem = DataItem.builder()
.id(element.attribute("ID").getValue())
.signage(bigId2SmallId(element.attribute("ID").getValue()))
.name(element.attribute("Name").getValue())
.type(type)
.build();
if(DataConstants.DeviceDataType.SOE.name().equals(type)){
dataItem.setEventType(element.attribute("SOEAlarmType").getValue());
dataItem.setSoeType(element.attribute("SOEType").getValue());
}
if(DataConstants.DeviceDataType.YX.name().equals(type)){
dataItem.setEventType(element.attribute("YXAlarmType").getValue());
dataItem.setSoeType(element.attribute("SOEType").getValue());
}
List<DataItem> childrens = dm.getChildren();
if(childrens==null){
childrens = Lists.newArrayList();
}
childrens.add(dataItem);
dm.setChildren(childrens);
}
}
return list;
}
}

52
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java

@ -1,52 +0,0 @@
package com.hnac.hzims.simulate.util;
import java.math.BigInteger;
public class RealIdConvertUtils {
private void demo() {
BigInteger ss = new BigInteger("16777215");
BigInteger s = new BigInteger("15122982502953650999");
BigInteger stationId = s.shiftRight(24);
System.out.println(stationId.toString());
BigInteger realId = s.and(ss);
System.out.println(realId.toString());
BigInteger xxx = stationId.shiftLeft(24);
BigInteger yyy = xxx.or(realId);
System.out.println(s.toString());
System.out.println(yyy.toString());
}
/**
* 将大id转换成小id
*/
public static String bigId2SmallId(String realId) {
BigInteger bigRealId = new BigInteger(realId);
return bigRealId.and(new BigInteger(DataConstants.REALID_CALCULATE)).toString();
}
/**
* 将小id转换成大id
*/
public static String smallId2BigId(String station, String realId) {
BigInteger stationId = new BigInteger(station);
BigInteger BigRealId = stationId.shiftLeft(24).or(new BigInteger(realId));
return BigRealId.toString();
}
// public static void main(String[] args) {
// System.out.println(RealIdConvertUtils.getStationId("262952509021093892"));
// System.out.println(RealIdConvertUtils.bigId2SmallId("262952509021093892"));
// System.out.println(smallId2BigId("15673190893", "32"));
// }
/**
* 获取站点id
*/
public static String getStationId(String realId) {
BigInteger bigRealId = new BigInteger(realId);
return bigRealId.shiftRight(24).toString();
}
}

18
hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java

@ -1,18 +0,0 @@
package com.hnac.hzims.simulate.util;
public interface TopicConstant {
String TOPIC_DEVICE_MODEL = "topic_device_model";
String TOPIC_HZINFO_PROPS = "topic_hzinfo_props";
String TOPIC_HZINFO_V4_YC = "hzinfo_v4_yc";
String TOPIC_HZINFO_V4_YX = "hzinfo_v4_yx";
String TOPIC_HZINFO_YX = "topic_hzinfo_yx";
String TOPIC_HZINFO_DD = "topic_hzinfo_dd";
String TOPIC_HZINFO_EVENTS = "topic_hzinfo_events";
String TOPIC_HZINFO_EVENTS_ALARM = "topic_hzinfo_events_alarm";
String TOPIC_HZINFO_CONTROL_RETURN = "topic_hzinfo_control_return";
String TOPIC_HZINFO_HEART_BEAT = "topic_hzinfo_heart_beat";
String TOPIC_HZINFO_BROADCAST = "topic_hzinfo_broadcast";
String TOPIC_HZINFO_DATA = "topic_hzinfo_data";
}

13
hzims-service/hzims-simulate/src/main/resources/application-dev.yml

@ -1,13 +0,0 @@
#服务器端口
server:
port: 8211
#数据源配置
spring:
datasource:
url: ${blade.datasource.dev.url}
username: ${blade.datasource.dev.username}
password: ${blade.datasource.dev.password}
cloud:
inetutils:
preferred-networks: 192.168.65

6
hzims-service/hzims-simulate/src/main/resources/application-prod.yml

@ -1,6 +0,0 @@
#数据源配置
spring:
datasource:
url: ${blade.datasource.prod.url}
username: ${blade.datasource.prod.username}
password: ${blade.datasource.prod.password}

15
hzims-service/hzims-simulate/src/main/resources/application.yml

@ -1,15 +0,0 @@
spring:
application:
name: lewa-simulate
#mybatis-plus配置
mybatis-plus:
mapper-locations: classpath:org/springbalde/**/mapper/*Mapper.xml,classpath:com/hnac/hzinfo/**/mapper/*Mapper.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: org.springbalde.**.entity,com.hnac.hzinfo.**.entity
#swagger扫描路径配置
swagger:
base-packages:
- org.springbalde
- com.hnac.hzinfo

5
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectMapper.java

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity;
import com.hnac.hzinfo.inspect.obj.vo.ProjectOfflineVO;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.core.datascope.annotation.UserDataAuth;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.util.List;
@ -11,7 +13,8 @@ import java.util.List;
* 巡检项目
*/
@Mapper
public interface ProjectMapper extends BaseMapper<ProjectEntity> {
public interface ProjectMapper extends UserDataScopeBaseMapper<ProjectEntity> {
@UserDataAuth
List<ProjectOfflineVO> getProjectData(String tenantId);
}

4
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java

@ -20,10 +20,10 @@ import com.hnac.hzinfo.inspect.obj.services.impl.ProjectContentServiceImpl;
import com.hnac.hzinfo.inspect.obj.utils.CodeUtils;
import com.hnac.hzinfo.inspect.obj.vo.ProjectListQueryVO;
import com.hnac.hzinfo.inspect.obj.vo.ProjectVO;
import com.hnac.hzinfo.inspect.utils.Condition;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
@ -192,7 +192,7 @@ public class ProjectController {
@ApiOperation(value = "获取巡检项目下的机构")
@ApiOperationSupport(order = 9)
public R<List> getProjectDept() {
QueryWrapper<ProjectEntity> queryWrapper = Wrappers.<ProjectEntity>query().select("distinct create_dept deptId");
QueryWrapper<ProjectEntity> queryWrapper = Wrappers.<ProjectEntity>query().select("distinct create_dept");
List<Long> deptIdList = projectService.listObjs(queryWrapper, Func::toLong);
List<HashMap> result = deptIdList.stream().map(deptId -> new HashMap() {{
put("deptId", deptId);

3
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java

@ -965,8 +965,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
private MultipartFile getMultipartFile(File file) {
FileItem fileItem = this.createFileItem(file);
MultipartFile mfile = new CommonsMultipartFile(fileItem);
return mfile;
return new CommonsMultipartFile(fileItem);
}

101
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java

@ -53,7 +53,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
@ -142,7 +141,7 @@ public class TargetServiceImpl implements TargetService {
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type);
//wappers.eq(StationEntity::getServeType,2);
if(!StringUtils.isEmpty(stationName)){
if(!StringUtil.isBlank(stationName)){
wappers.like(StationEntity::getName,stationName);
}
List<StationEntity> stations = stationService.list(wappers);
@ -183,7 +182,7 @@ public class TargetServiceImpl implements TargetService {
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type);
//wappers.eq(StationEntity::getServeType,2);
if(!StringUtils.isEmpty(stationName)){
if(!StringUtil.isBlank(stationName)){
wappers.like(StationEntity::getName,stationName);
}
List<StationEntity> stations = stationService.list(wappers);
@ -217,7 +216,7 @@ public class TargetServiceImpl implements TargetService {
}).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList());
}else if(HomePageConstant.PHOTOVOLTAIC.equals(type)) {
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if (CollectionUtil.isEmpty(targets)) {
if (CollectionUtils.isEmpty(targets)) {
return page;
}
electrics = stations.stream().map(station -> {
@ -273,7 +272,7 @@ public class TargetServiceImpl implements TargetService {
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type);
//wappers.eq(StationEntity::getServeType,2);
if(!StringUtils.isEmpty(stationName)){
if(!StringUtil.isBlank(stationName)){
wappers.like(StationEntity::getName,stationName);
}
List<StationEntity> stations = stationService.list(wappers);
@ -374,7 +373,7 @@ public class TargetServiceImpl implements TargetService {
generations = stations.stream().map(station -> {
CompleteGenerationVo item = new CompleteGenerationVo();
item.setStationName(station.getName());
if(CollectionUtil.isEmpty(plans)){
if(CollectionUtils.isEmpty(plans)){
item.setPlanGeneration(0.0);
}else{
item.setPlanGeneration(plans.stream().filter(plan->plan.getStationId().equals(station.getCode())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
@ -425,7 +424,7 @@ public class TargetServiceImpl implements TargetService {
CountDownLatch countDownLatch = new CountDownLatch(areas.size());
List<CompleteTicketVo> completes = new ArrayList<>();
exe.execute(()-> {
if(!StringUtil.isEmpty(areaName)){
if(!StringUtil.isBlank(areaName)){
for (Dept dept: areas.stream().filter(area->area.getDeptName().equals(areaName)).collect(Collectors.toList())) {
// 双票
TicketStatisticDTO ticketStatisticDTO=new TicketStatisticDTO();
@ -496,16 +495,16 @@ public class TargetServiceImpl implements TargetService {
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.in(StationEntity::getType,types)
);
if(CollectionUtil.isEmpty(stations)){
if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>();
}
R<List<Dept>> result = sysClient.getDeptByCurrentUser();
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
if(!result.isSuccess() || CollectionUtils.isEmpty(result.getData())){
return new ArrayList<>();
}
// 站点父级区域
List<Long> parents = result.getData().stream().filter(dept->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).distinct().collect(Collectors.toList());
if(CollectionUtil.isEmpty(parents)){
if(CollectionUtils.isEmpty(parents)){
return new ArrayList<>();
}
return result.getData().stream().filter(dept->parents.contains(dept.getId()) && HomePageConstant.AREA.equals(dept.getDeptCategory())).collect(Collectors.toList());
@ -537,7 +536,7 @@ public class TargetServiceImpl implements TargetService {
item.setTicketCount("*");
item.setCompleteCount("*");
List<PowerEntity> stationPower = powers.stream().filter(power->power.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(stationPower)){
if(CollectionUtils.isEmpty(stationPower)){
item.setCompleteRate("0.0");
}else{
double rate = stationPower.stream().mapToDouble(o->Double.parseDouble(o.getDoubleQualifyRate())).sum();
@ -565,7 +564,7 @@ public class TargetServiceImpl implements TargetService {
if(MapUtils.isEmpty(areas)){
return page;
}
List<Dept> depts = areas.keySet().stream().filter(dept -> StringUtils.isEmpty(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList());
List<Dept> depts = areas.keySet().stream().filter(dept -> StringUtil.isBlank(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList());
if(CollectionUtils.isEmpty(depts)){
return page;
}
@ -619,7 +618,7 @@ public class TargetServiceImpl implements TargetService {
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type);
wappers.eq(StationEntity::getServeType,2);
if(!StringUtils.isEmpty(stationName)){
if(!StringUtil.isBlank(stationName)){
wappers.like(StationEntity::getName,stationName);
}
List<StationEntity> stations = stationService.list(wappers);
@ -666,7 +665,7 @@ public class TargetServiceImpl implements TargetService {
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type);
wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
if(!StringUtils.isEmpty(stationName)){
if(!StringUtil.isBlank(stationName)){
wappers.like(StationEntity::getName,stationName);
}
List<StationEntity> stations = stationService.list(wappers);
@ -710,7 +709,7 @@ public class TargetServiceImpl implements TargetService {
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type);
wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
if(!StringUtils.isEmpty(areaName)){
if(!StringUtil.isBlank(areaName)){
wappers.like(StationEntity::getName,areaName);
}
List<StationEntity> stations = stationService.list(wappers);
@ -775,7 +774,7 @@ public class TargetServiceImpl implements TargetService {
public R<IPage<OperAccessTaskVO>> examineRepair(OperAccessTaskDTO params, Query query, Integer type) {
// 获取区域机构
Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE,true);
if(MapUtils.isEmpty(areas)){
if(ObjectUtil.isEmpty(areas)){
return null;
}
// 查询检修任务
@ -806,7 +805,7 @@ public class TargetServiceImpl implements TargetService {
if(CollectionUtils.isEmpty(stations)){
return page;
}
List<Long> detpIds = stations.stream().filter(o-> StringUtils.isEmpty(stationName) || o.getName().contains(stationName)).map(StationEntity::getRefDept).collect(Collectors.toList());
List<Long> detpIds = stations.stream().filter(o-> StringUtil.isBlank(stationName) || o.getName().contains(stationName)).map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtils.isEmpty(detpIds)){
return page;
}
@ -830,7 +829,7 @@ public class TargetServiceImpl implements TargetService {
deviceClassify.setDeviceStatus(2);
}
return deviceClassify;
}).filter(deviceClass -> StringUtils.isEmpty(stationName) || deviceClass.getStationName().contains(stationName)).collect(Collectors.toList());
}).filter(deviceClass -> StringUtil.isBlank(stationName) || deviceClass.getStationName().contains(stationName)).collect(Collectors.toList());
List<DeviceClassifyVo> records;
// 状态过滤
if(ObjectUtil.isEmpty(status)){
@ -855,7 +854,7 @@ public class TargetServiceImpl implements TargetService {
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER);
wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
if(!StringUtil.isEmpty(stationName)){
if(!StringUtil.isBlank(stationName)){
wappers.like(StationEntity::getName,stationName);
}
if(ObjectUtil.isNotEmpty(deptId)){
@ -872,7 +871,7 @@ public class TargetServiceImpl implements TargetService {
List<HydropowerTargetVo> records = stations.stream().map(station->{
HydropowerTargetVo hydropower = new HydropowerTargetVo();
hydropower.setStationName(station.getName());
if(CollectionUtil.isEmpty(reals)){
if(CollectionUtils.isEmpty(reals)){
hydropower.setPower(0.0);
}else{
hydropower.setPower(reals.stream().filter(real->real.getDeptId().equals(station.getRefDept())).mapToDouble(real->{
@ -930,7 +929,7 @@ public class TargetServiceImpl implements TargetService {
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.in(StationEntity::getType, HomePageConstant.waterList);
wappers.eq(StationEntity::getServeType,2);
if(!StringUtils.isEmpty(stationName)){
if(!StringUtil.isBlank(stationName)){
wappers.like(StationEntity::getName,stationName);
}
if(!ObjectUtil.isEmpty(deptId)){
@ -947,7 +946,7 @@ public class TargetServiceImpl implements TargetService {
List<WaterTargetVo> records = stations.stream().map(station->{
WaterTargetVo water = new WaterTargetVo();
water.setStationName(station.getName());
if(CollectionUtil.isEmpty(pumps)){
if(CollectionUtils.isEmpty(pumps)){
water.setLoad(0.0);
return water;
}
@ -964,7 +963,7 @@ public class TargetServiceImpl implements TargetService {
List<WaterTargetVo> records = stations.stream().map(station->{
WaterTargetVo water = new WaterTargetVo();
water.setStationName(station.getName());
if(CollectionUtil.isEmpty(targets)){
if(CollectionUtils.isEmpty(targets)){
water.setUse(0.0);
return water;
}
@ -994,7 +993,7 @@ public class TargetServiceImpl implements TargetService {
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC);
wappers.eq(StationEntity::getServeType,2);
if(!StringUtils.isEmpty(stationName)){
if(!StringUtil.isBlank(stationName)){
wappers.like(StationEntity::getName,stationName);
}
if(!ObjectUtil.isEmpty(deptId)){
@ -1012,7 +1011,7 @@ public class TargetServiceImpl implements TargetService {
List<PhotovoTargetVo> records = stations.stream().map(station->{
PhotovoTargetVo photovo = new PhotovoTargetVo();
photovo.setStationName(station.getName());
if(CollectionUtil.isEmpty(reals)){
if(CollectionUtils.isEmpty(reals)){
photovo.setLoad(0.0);
}else{
photovo.setLoad(reals.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum());
@ -1028,7 +1027,7 @@ public class TargetServiceImpl implements TargetService {
List<PhotovoTargetVo> records = stations.stream().map(station->{
PhotovoTargetVo photovo = new PhotovoTargetVo();
photovo.setStationName(station.getName());
if(CollectionUtil.isEmpty(targets)){
if(CollectionUtils.isEmpty(targets)){
photovo.setGenerate(0.0);
}else{
switch (target){
@ -1067,12 +1066,12 @@ public class TargetServiceImpl implements TargetService {
}
// redis中取区域数据
List<AreaDutyVo> areaDutyVoList = (List<AreaDutyVo>) redisTemplate.opsForValue().get(areaDutyInfoKey);
List<DutyGroupVo> records = areas.keySet().stream().filter(stationEntities -> StringUtil.isEmpty(areaName) || stationEntities.getDeptName().contains(areaName)).map(stationEntities -> {
List<DutyGroupVo> records = areas.keySet().stream().filter(stationEntities -> StringUtil.isBlank(areaName) || stationEntities.getDeptName().contains(areaName)).map(stationEntities -> {
DutyGroupVo duty = new DutyGroupVo();
duty.setDeptId(stationEntities.getId());
duty.setAreaName(stationEntities.getDeptName());
List<AreaDutyVo> dutys = areaDutyVoList.stream().filter(area -> area.getDepartId().equals(stationEntities.getId())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(dutys)) {
if (CollectionUtils.isEmpty(dutys)) {
return duty;
}
// 操作票
@ -1122,25 +1121,25 @@ public class TargetServiceImpl implements TargetService {
public IPage<MaintenanceTaskVo> maintenance(IPage<OperMaintenanceTaskEntity> page, MaintenanceAssociationVo business) {
Wrapper<OperMaintenanceTaskEntity> queryWrapper = new LambdaQueryWrapper<OperMaintenanceTaskEntity>() {{
orderByDesc(OperMaintenanceTaskEntity::getDisposeTime);
if (!StringUtil.isEmpty(business.getTitle())) {
if (!StringUtil.isBlank(business.getTitle())) {
like(OperMaintenanceTaskEntity::getTitle, business.getTitle());
}
if (!StringUtil.isEmpty(business.getTaskType())) {
if (!StringUtil.isBlank(business.getTaskType())) {
eq(OperMaintenanceTaskEntity::getTaskType, business.getTaskType());
}
if (!StringUtil.isEmpty(business.getContent())) {
if (!StringUtil.isBlank(business.getContent())) {
like(OperMaintenanceTaskEntity::getContent, business.getContent());
}
if (!StringUtil.isEmpty(business.getStartTime())) {
if (!StringUtil.isBlank(business.getStartTime())) {
ge(OperMaintenanceTaskEntity::getDisposeTime,business.getStartTime());
}
if (!StringUtil.isEmpty(business.getEndTime())) {
if (!StringUtil.isBlank(business.getEndTime())) {
le(OperMaintenanceTaskEntity::getDisposeTime,business.getEndTime());
}
if(!StringUtil.isEmpty(business.getType()) && "1".equals(business.getType())){
if(!StringUtil.isBlank(business.getType()) && "1".equals(business.getType())){
eq(OperMaintenanceTaskEntity::getFlowTaskName,"结束");
}
if(!StringUtil.isEmpty(business.getDeptIds())){
if(!StringUtil.isBlank(business.getDeptIds())){
in(OperMaintenanceTaskEntity::getCreateDept, Func.toLongList(",",business.getDeptIds()));
}
}};
@ -1159,29 +1158,29 @@ public class TargetServiceImpl implements TargetService {
public IPage<OperPhenomenonVO> phenomenon(IPage<OperPhenomenonEntity> page, MaintenancePhenomenonVo business) {
Wrapper<OperPhenomenonEntity> queryWrapper = new LambdaQueryWrapper<OperPhenomenonEntity>() {{
orderByDesc(OperPhenomenonEntity::getCreateTime);
if (!StringUtil.isEmpty(business.getFaultName())) {
if (!StringUtil.isBlank(business.getFaultName())) {
like(OperPhenomenonEntity::getFaultName,business.getFaultName());
}
if (!ObjectUtil.isEmpty(business.getIsDefect())) {
eq(OperPhenomenonEntity::getIsDefect,business.getIsDefect());
}
if (!StringUtil.isEmpty(business.getFindStartTime())) {
if (!StringUtil.isBlank(business.getFindStartTime())) {
ge(OperPhenomenonEntity::getFindTime,business.getFindStartTime());
}
if (!StringUtil.isEmpty(business.getFindEndTime())) {
if (!StringUtil.isBlank(business.getFindEndTime())) {
le(OperPhenomenonEntity::getFindTime,business.getFindEndTime());
}
if (!StringUtil.isEmpty(business.getStartTime())) {
if (!StringUtil.isBlank(business.getStartTime())) {
ge(OperPhenomenonEntity::getCreateTime,business.getStartTime());
}
if (!StringUtil.isEmpty(business.getEndTime())) {
if (!StringUtil.isBlank(business.getEndTime())) {
le(OperPhenomenonEntity::getCreateTime,business.getEndTime());
}
if(!StringUtil.isEmpty(business.getType()) && "1".equals(business.getType())){
if(!StringUtil.isBlank(business.getType()) && "1".equals(business.getType())){
isNotNull(OperPhenomenonEntity::getHandleTaskId);
}
if(!StringUtil.isEmpty(business.getDeptIds())){
if(!StringUtil.isBlank(business.getDeptIds())){
in(OperPhenomenonEntity::getCreateDept, Func.toLongList(",",business.getDeptIds()));
}
}};
@ -1200,19 +1199,19 @@ public class TargetServiceImpl implements TargetService {
public IPage<OperAccessTaskVO> access(IPage<OperAccessTaskEntity> page, AccessAssociationVo business) {
Wrapper<OperAccessTaskEntity> queryWrapper = new LambdaQueryWrapper<OperAccessTaskEntity>() {{
orderByDesc(OperAccessTaskEntity::getPlanStartTime);
if (!StringUtil.isEmpty(business.getName())) {
if (!StringUtil.isBlank(business.getName())) {
like(OperAccessTaskEntity::getName,business.getName());
}
if (!StringUtil.isEmpty(business.getStartTime())) {
if (!StringUtil.isBlank(business.getStartTime())) {
ge(OperAccessTaskEntity::getPlanStartTime,business.getStartTime());
}
if (!StringUtil.isEmpty(business.getEndTime())) {
if (!StringUtil.isBlank(business.getEndTime())) {
le(OperAccessTaskEntity::getPlanStartTime,business.getEndTime());
}
if(!StringUtil.isEmpty(business.getType()) && "1".equals(business.getType())){
if(!StringUtil.isBlank(business.getType()) && "1".equals(business.getType())){
eq(OperAccessTaskEntity::getStatus,4);
}
if(!StringUtil.isEmpty(business.getDeptIds())){
if(!StringUtil.isBlank(business.getDeptIds())){
in(OperAccessTaskEntity::getCreateDept, Func.toLongList(",",business.getDeptIds()));
}
}};
@ -1237,7 +1236,7 @@ public class TargetServiceImpl implements TargetService {
}
if(HomePageConstant.YEAR.equals(type)){
// 站点近年发电数据
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
Map<String, Map<String, Float>> powerMap = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
// 填报发电量
List<String> mons = this.mons(0,12,false);
return mons.stream().map(mon->{
@ -1249,7 +1248,7 @@ public class TargetServiceImpl implements TargetService {
return detail;
}
// 发电量
Map<String,Float> monMap = powerMap.get(station.getId());
Map<String,Float> monMap = powerMap.get(station.getCode());
if(MapUtils.isEmpty(monMap)){
detail.setElectric(0.0);
return detail;
@ -1266,12 +1265,12 @@ public class TargetServiceImpl implements TargetService {
HydropowerTargetDetailVo detail = new HydropowerTargetDetailVo();
detail.setTime(day.getDate());
detail.setElectric(Double.valueOf(day.getGenerate()));
if(CollectionUtil.isEmpty(targets)){
if(CollectionUtils.isEmpty(targets)){
return detail;
}
// 设备指标数据
List<GenerationPowerVo> generations = targets.stream().filter(o-> CollectionUtil.isNotEmpty(o.getGenerationPowerVoList()) && o.getDeptId().equals(station.getRefDept())).flatMap(v -> v.getGenerationPowerVoList().stream()).collect(Collectors.toList());
if(CollectionUtil.isEmpty(generations)){
if(CollectionUtils.isEmpty(generations)){
return detail;
}
detail.setElectric(generations.stream().filter(o->o.getDate().equals(day.getDate())).mapToDouble(GenerationPowerVo::getGenerate).sum());

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java

@ -22,7 +22,6 @@ import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IHzimsAnalyzeModelStationService;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
@ -232,7 +231,7 @@ public class HzimsDataServiceImpl implements HzimsDataService {
List<EminfoAndEmParamVo> deviceList = maintenanceTaskService.getEmInfoList();
HydropowerStationVo response = new HydropowerStationVo();
// 近年发电量数据
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
Map<String, Map<String, Float>> map = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
response.setDeptId(station.getRefDept());
response.setDeptName(station.getName());
response.setStationCode(station.getCode());
@ -734,7 +733,7 @@ public class HzimsDataServiceImpl implements HzimsDataService {
* 年发电量完成百分比
* @param stations
*/
private List<PowerMonthVo> handlePowerFinish(List<StationEntity> stations, Map<Long, Map<String, Float>> map) {
private List<PowerMonthVo> handlePowerFinish(List<StationEntity> stations, Map<String, Map<String, Float>> map) {
if (CollectionUtil.isEmpty(stations)) {
return null;
}
@ -755,7 +754,7 @@ public class HzimsDataServiceImpl implements HzimsDataService {
vo.setPower(0f);
} else {
float generate = (float) map.entrySet().stream().
filter(entry -> stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(entry.getKey())).
filter(entry -> stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(entry.getKey())).
mapToDouble(valueMap -> valueMap.getValue().entrySet().stream().filter(entry -> entry.getKey().equals(o))
.mapToDouble(Map.Entry::getValue).sum()).sum();
vo.setPower(generate);

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java

@ -408,7 +408,11 @@ public class ImsDutyGroupServiceImpl extends ServiceImpl<ImsDutyGroupMapper, Ims
List<DutyMemberVO> members = group.getMember().stream().peek(member->{
User person = UserCache.getUser(member.getPersonId());
if (ObjectUtil.isNotEmpty(person)) {
member.setPersonName(person.getName());
if(StringUtil.isBlank(person.getRealName())){
member.setPersonName(person.getName());
}else{
member.setPersonName(person.getRealName());
}
}
}).collect(Collectors.toList());
group.setMember(members.stream().filter(o->StringUtil.isNotBlank(o.getPersonName())).collect(Collectors.toList()));

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java

@ -1,14 +1,10 @@
package com.hnac.hzims.operational.history.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.history.service.AlarmService;
import com.hnac.hzims.operational.history.service.PointService;
import com.hnac.hzims.operational.history.vo.HistoricalCurveVo;
import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo;
import com.hnac.hzinfo.dataconfig.entity.Device;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO;
import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO;
@ -19,8 +15,8 @@ import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import org.springblade.core.mp.support.Query;
import javax.management.Query;
import java.util.List;
import java.util.Map;

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/AlarmService.java

@ -1,13 +1,8 @@
package com.hnac.hzims.operational.history.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryCondition;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO;
import org.springblade.core.mp.support.Query;
import javax.management.Query;
import java.util.List;
import java.util.Map;
/**

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/service/impl/AlarmServiceImpl.java

@ -3,13 +3,13 @@ package com.hnac.hzims.operational.history.service.impl;
import com.hnac.hzims.operational.history.service.AlarmService;
import com.hnac.hzims.operational.history.vo.HistoryProjectAlarmVo;
import com.hnac.hzinfo.sdk.core.response.Result;
import org.springblade.core.mp.support.Query;
import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.stereotype.Service;
import javax.management.Query;
import java.util.HashMap;
import java.util.Map;
@ -39,7 +39,8 @@ public class AlarmServiceImpl implements AlarmService {
alarm.getSoeType(),
alarm.getStartTime(),
alarm.getEndTime(),
query
query.getCurrent(),
query.getSize()
);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new HashMap<>();

55
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java

@ -288,8 +288,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
}else {
map.put("commissionTime", 0);
}
List<Long> stationIds = Optional.ofNullable(stationEntityList)
.orElse(new ArrayList<>()).stream().map(BaseEntity::getId).collect(Collectors.toList());
List<String> stationIds = Optional.ofNullable(stationEntityList)
.orElse(new ArrayList<>()).stream().map(StationEntity::getCode).collect(Collectors.toList());
//其它普通数据
map.put("year", year);
Integer yearBefore = year - 1;
@ -706,13 +706,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return R.success("成功");
}
private List<MonPowerPercentageVo> getMonPowerPercentageVos(Integer year, Integer month, List<Dept> deptList, List<Long> deptIds, List<StationEntity> stationEntityList, List<Long> stationIds, Integer yearBefore, Integer monthBefore) {
private List<MonPowerPercentageVo> getMonPowerPercentageVos(Integer year, Integer month, List<Dept> deptList, List<Long> deptIds, List<StationEntity> stationEntityList, List<String> stationIds, Integer yearBefore, Integer monthBefore) {
List<String> deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList());
//年计划发电量
List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString());
List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>();
//水电站,光伏站和带代运维数据近三年数据
Map<Long, Map<String, Float>> powerMapThree = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
Map<String, Map<String, Float>> powerMapThree = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
List<String> listByYear = TimeUtils.getListByYear(year);
List<String> listByYearBefore = TimeUtils.getListByYear(yearBefore);
String monStart = TimeUtils.getMon(year, month);
@ -720,12 +720,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
String monStartMonBefore = TimeUtils.getEarlyTime(yearBefore, month);
// String monStartMonBefore = TimeUtils.getMon(year, monthBefore);
// 格式:站点-日期-发电量
for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) {
for (Map.Entry<String, Map<String, Float>> deviceMap : powerMapThree.entrySet()) {
String deptNameByKey;
if (stationIds.contains(deviceMap.getKey())) {
MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
powerVo.setDeptId(deviceMap.getKey());
List<StationEntity> collect = stationEntityList.stream().filter(s -> deviceMap.getKey().equals(s.getId())).collect(Collectors.toList());
//powerVo.setDeptId(deviceMap.getKey());
List<StationEntity> collect = stationEntityList.stream().filter(s -> deviceMap.getKey().equals(s.getCode())).collect(Collectors.toList());
Long dept = collect.get(0).getRefDept();
List<Dept> dep = deptList.stream().filter(s -> dept.equals(s.getId())).collect(Collectors.toList());
deptNameByKey=dep.get(0).getDeptName();
@ -738,7 +738,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
Double planGeneration = 0d;
List<PlanGenerationEntity> planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(planGenerationById)) {
planGeneration = Double.valueOf(planGenerationById.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
planGeneration = planGenerationById.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
}
//当前机构近三年的数据
Map<String, Float> value = deviceMap.getValue();
@ -760,11 +760,9 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
BigDecimal planPercentage = new BigDecimal(0);
if (powerYearBefore.compareTo(BigDecimal.ZERO) != 0) {
yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, RoundingMode.UP);
yearPercentage.setScale(2, RoundingMode.UP);
}
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) {
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, RoundingMode.UP);
planPercentage.setScale(2, RoundingMode.UP);
}
powerVo.setPlanPercentage(planPercentage.doubleValue());
powerVo.setPowerYearPercentage(yearPercentage.doubleValue());
@ -774,7 +772,6 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
BigDecimal monPercentage = new BigDecimal(0);
if (powerMonthYearBefore.compareTo(BigDecimal.ZERO) != 0) {
monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, RoundingMode.UP);
monPercentage.setScale(2, RoundingMode.UP);
}
powerVo.setPowerMonPercentage(monPercentage.doubleValue());
powerPercentageVoList.add(powerVo);
@ -1246,7 +1243,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return;
}
// 站点近年发电数据
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
Map<String, Map<String, Float>> powerMap = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
// 存储数据节点 key - 月份 value - 区域数据集合
Map<String, List<AreaMonthReportVo>> map = new HashMap<>();
// 月份集合
@ -1290,7 +1287,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return;
}
// 站点近年发电数据
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
Map<String, Map<String, Float>> powerMap = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
// 存储数据节点 key - 月份 value - 区域数据集合
Map<String, List<AreaMonthReportVo>> map = new HashMap<>();
// 月份集合
@ -1345,17 +1342,17 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
* @param mon
* @return
*/
private List<AreaMonthReportVo> getAreaReportByMon(List<Dept> deptList, Map<Long, Map<String, Float>> powerMap, List<StationEntity> stationList, String mon) {
private List<AreaMonthReportVo> getAreaReportByMon(List<Dept> deptList, Map<String, Map<String, Float>> powerMap, List<StationEntity> stationList, String mon) {
LocalDateTime startTime = LocalDateTime.parse(mon + "-01 00:00:00", dtf);
LocalDateTime endTime = getEndTime(mon);
// 查询所有站点的计划发电量
List<PlanGenerationEntity> planList = getPlanPower(stationList, mon);
// 站点实际发电量
Map<Long, Float> actualMap = getActualPower(powerMap, stationList, mon + "-01");
Map<String, Float> actualMap = getActualPower(powerMap, stationList, mon + "-01");
// 站点去年发电量
Map<Long, Float> oldActualMap = getActualPower(powerMap, stationList, getLastyear(1, mon));
Map<String, Float> oldActualMap = getActualPower(powerMap, stationList, getLastyear(1, mon));
// 站点前发电量
Map<Long, Float> oldOldActualMap = getActualPower(powerMap, stationList, getLastyear(2, mon));
Map<String, Float> oldOldActualMap = getActualPower(powerMap, stationList, getLastyear(2, mon));
// 取机构中区域部分
List<Dept> areaList = deptList.stream().filter(o -> o.getDeptCategory().equals(3)).collect(Collectors.toList());
if (CollectionUtil.isEmpty(areaList)) {
@ -1397,15 +1394,15 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
* @param areaStationList
* @param areaMonthReport
*/
private void getPredictPlanPower(Map<Long, Float> oldActualMap, Map<Long, Float> oldOldActualMap, List<StationEntity> areaStationList, AreaMonthReportVo areaMonthReport) {
private void getPredictPlanPower(Map<String, Float> oldActualMap, Map<String, Float> oldOldActualMap, List<StationEntity> areaStationList, AreaMonthReportVo areaMonthReport) {
areaMonthReport.setPredictPlanPower(0.0);
// 实际发电量
List<Long> ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList());
if (CollectionUtil.isEmpty(ids)) {
List<String> codes = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList());
if (CollectionUtil.isEmpty(codes)) {
return;
}
double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
double oldOldActualPower = oldOldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
double oldActualPower = oldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
double oldOldActualPower = oldOldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
if (Math.abs(oldActualPower) <= 0 && Math.abs(oldOldActualPower) <= 0) {
return;
}
@ -1523,14 +1520,14 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
* @param stationList
* @return
*/
private Map<Long, Float> getActualPower(Map<Long, Map<String, Float>> powerMap, List<StationEntity> stationList, String month) {
private Map<String, Float> getActualPower(Map<String, Map<String, Float>> powerMap, List<StationEntity> stationList, String month) {
if (MapUtils.isEmpty(powerMap)) {
return null;
}
// 站点Id集合
List<Long> stationIdList = stationList.stream().map(StationEntity::getId).collect(Collectors.toList());
List<String> stationIdList = stationList.stream().map(StationEntity::getCode).collect(Collectors.toList());
// 存储站点实际发电量
Map<Long, Float> actualPowerMap = new HashMap<>();
Map<String, Float> actualPowerMap = new HashMap<>();
stationIdList.forEach(key -> {
Map<String, Float> monthMap = powerMap.get(key);
if (MapUtils.isEmpty(monthMap)) {
@ -1554,7 +1551,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
* @param areaStationList
* @param areaMonthReport
*/
private void powerMonth(List<PlanGenerationEntity> planList, Map<Long, Float> actualMap, Map<Long, Float> oldActualMap, List<StationEntity> areaStationList, AreaMonthReportVo areaMonthReport) {
private void powerMonth(List<PlanGenerationEntity> planList, Map<String, Float> actualMap, Map<String, Float> oldActualMap, List<StationEntity> areaStationList, AreaMonthReportVo areaMonthReport) {
// 计划发电量
List<String> codeList = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList());
double planPower = planList.stream().filter(o -> codeList.contains(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
@ -1566,8 +1563,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
return;
}
// 实际发电量
List<Long> ids = areaStationList.stream().map(StationEntity::getId).collect(Collectors.toList());
double actualPower = actualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
List<String> codes = areaStationList.stream().map(StationEntity::getCode).collect(Collectors.toList());
double actualPower = actualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
areaMonthReport.setActualPower(Float.parseFloat(String.valueOf(actualPower)));
if (Math.abs(planPower) <= 0) {
areaMonthReport.setPowerFinishRate(0.0);
@ -1577,7 +1574,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
areaMonthReport.setPowerFinishRate(powerFinishRate);
}
// 同比
double oldActualPower = oldActualMap.entrySet().stream().filter(e -> ids.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
double oldActualPower = oldActualMap.entrySet().stream().filter(e -> codes.contains(e.getKey())).mapToDouble(Map.Entry::getValue).sum();
if (Math.abs(actualPower) <= 0 || Math.abs(oldActualPower) <= 0) {
areaMonthReport.setComparePowerRate(0.0);
return;

36
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java

@ -28,10 +28,8 @@ import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient;
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO;
import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient;
import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO;
import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
@ -142,7 +140,7 @@ public class HydropowerServiceImpl implements HydropowerService {
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(Collections.singletonList(station.getCode()));
HydropowerStationVo response = new HydropowerStationVo();
// 近年发电量数据
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
Map<String, Map<String, Float>> map = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
response.setDeptId(station.getRefDept());
response.setDeptName(station.getName());
response.setStationCode(station.getCode());
@ -167,7 +165,7 @@ public class HydropowerServiceImpl implements HydropowerService {
// 年计划发电量
response.setPlanPowerYear(this.getPlanPowerYear(station.getCode()));
// 年发电量、月发电量
this.stationMonthPower(station.getId(),map,response);
this.stationMonthPower(station.getCode(),map,response);
// 水位、水位曲线
this.handleWaterLeve(station.getCode(),response);
// 年发电量完成百分比
@ -391,24 +389,24 @@ public class HydropowerServiceImpl implements HydropowerService {
/**
* 月发电量
* @param id
* @param code
* @param map
* @param response
*/
private void stationMonthPower(Long id, Map<Long, Map<String, Float>> map, HydropowerStationVo response) {
if(MapUtils.isEmpty(map) || !map.containsKey(id)){
private void stationMonthPower(String code, Map<String, Map<String, Float>> map, HydropowerStationVo response) {
if(MapUtils.isEmpty(map) || !map.containsKey(code)){
response.setPowerMon(0f);
return;
}
// 月发电量
String month = DateUtil.format(new Date(),"yyyy-MM") + "-01";
float powerMon = map.get(id).getOrDefault(month, 0f);
float powerMon = map.get(code).getOrDefault(month, 0f);
if(powerMon > 0){
response.setPowerMon(powerMon);
}
String year = DateUtil.format(new Date(),"yyyy");
// 年发电量
float powerYear = (float) map.get(id).entrySet().stream().filter(o->o.getKey().contains(year)).mapToDouble(Map.Entry::getValue).sum();
float powerYear = (float) map.get(code).entrySet().stream().filter(o->o.getKey().contains(year)).mapToDouble(Map.Entry::getValue).sum();
response.setPowerYear(powerYear);
// 年发电完成率
float planPowerYear = response.getPlanPowerYear();
@ -446,7 +444,7 @@ public class HydropowerServiceImpl implements HydropowerService {
* 年发电量完成百分比
* @param stations
*/
private List<PowerMonthVo> handlePowerFinish(List<StationEntity> stations,Map<Long, Map<String, Float>> map) {
private List<PowerMonthVo> handlePowerFinish(List<StationEntity> stations,Map<String, Map<String, Float>> map) {
if(CollectionUtil.isEmpty(stations)){
return null;
}
@ -467,7 +465,7 @@ public class HydropowerServiceImpl implements HydropowerService {
vo.setPower(0f);
}else{
float generate = (float) map.entrySet().stream().
filter(entry->stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(entry.getKey())).
filter(entry->stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(entry.getKey())).
mapToDouble(valueMap-> valueMap.getValue().entrySet().stream().filter(entry->entry.getKey().equals(o))
.mapToDouble(Map.Entry::getValue).sum()).sum();
vo.setPower(generate);
@ -535,7 +533,7 @@ public class HydropowerServiceImpl implements HydropowerService {
// 七天天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 站点近年发电数据 key - id value - 月份,发电量
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
Map<String, Map<String, Float>> map = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
return stations.stream().map(station->{
HydropowerStationVo hydropower = new HydropowerStationVo();
hydropower.setDeptId(station.getRefDept());
@ -562,7 +560,7 @@ public class HydropowerServiceImpl implements HydropowerService {
// 年计划发电量
hydropower.setPlanPowerYear(this.getPlanPowerYear(station.getCode()));
// 月发电量、年发电量、年发电完成率
this.stationMonthPower(station.getId(),map,hydropower);
this.stationMonthPower(station.getCode(),map,hydropower);
// 水位、水位曲线
this.handleWaterLeve(station.getCode(),hydropower);
// 年发电量完成百分比
@ -619,8 +617,6 @@ public class HydropowerServiceImpl implements HydropowerService {
// 年发电量
kpi.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum());
// 月发电量
kpi.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum());
// 日发电量
kpi.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum());
@ -636,13 +632,13 @@ public class HydropowerServiceImpl implements HydropowerService {
}
}
// 站点近年发电数据 key - id value - 月份,发电量
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
Map<String, Map<String, Float>> map = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
if (MapUtils.isEmpty(map)) {
return kpi;
}
// 当月发电量
String month = DateUtil.format(new Date(),"yyyy-MM") + "-01";
double generateMon = map.entrySet().stream().filter(o->stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(o.getKey())).mapToDouble(entry->{
double generateMon = map.entrySet().stream().filter(o->stations.stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(o.getKey())).mapToDouble(entry->{
if(entry.getValue().containsKey(month)){
return Double.valueOf(entry.getValue().get(month));
}
@ -654,7 +650,7 @@ public class HydropowerServiceImpl implements HydropowerService {
// 今年发电趋势
kpi.setPowerMonthVoList(this.handlePowerFinish(stations,map));
// 近3年发电量
kpi.setPowerYearVoList(this.generateThreeYear(stations.stream().map(StationEntity::getId).collect(Collectors.toList()),map));
kpi.setPowerYearVoList(this.generateThreeYear(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),map));
return kpi;
}
@ -801,8 +797,8 @@ public class HydropowerServiceImpl implements HydropowerService {
* @param stations
* @return
*/
private List<PowerYearVo> generateThreeYear(List<Long> stations,Map<Long, Map<String, Float>> map) {
List<Map<String, Float>> filter = map.entrySet().stream().filter(e -> stations.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList());
private List<PowerYearVo> generateThreeYear(List<String> stations,Map<String, Map<String, Float>> map) {
List<Map<String, Float>> filter = map.entrySet().stream().filter(entry -> stations.contains(entry.getKey())).map(Map.Entry::getValue).collect(Collectors.toList());
if (CollectionUtil.isEmpty(filter)) {
return new ArrayList<>();
}

228
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java

@ -35,13 +35,11 @@ import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO;
import com.hnac.hzinfo.datasearch.real.IRealDataSearchClient;
import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
@ -105,23 +103,35 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
@Value("${hzims.operation.realIdKey}")
public String realIdKeyPath;
private final static String GENERATE_SIGNAGE = "generation_capacity";//发电标识
private final static String POWER_SIGNAGE = "active_power";//有功功率标识
private final static String JOINT_RELAY_SIGNAGE = "joint_relay";//开关机状态
private final static String WATER_LEVEL = "water_level";//前池水位
private final static String LIMIT_WATER_LEVEL = "limit_water_level";//限制水位
private final static String UNIT_REV = "index_jzzs";//机组转速
private final static String GUIDE_VANE_OPENING = "index_dykd";//导叶开度
private final static String REACTIV_POWER = "reactive_power";//无功功率Q
private final static String POWER_FACTOR = "index_jz_cos";//机组Cos
private final static String HZVE_ADJUST_THE_GIVEN = "index_ygtzgd";//有功调整给定
private final static String FEEDBACK = "index_jz_f";//频率
private final static String IDLE_ADJUST_THE_GIVEN = "index_wgtzgd";//无功调整给定
private final static String STATOR_CURRENT = "stator_current";//定子电流
private final static String STATOR_VOLTAGE = "stator_voltage";//定子电压
//发电标识
private final static String GENERATE_SIGNAGE = "generation_capacity";
//有功功率标识
private final static String POWER_SIGNAGE = "active_power";
//开关机状态
private final static String JOINT_RELAY_SIGNAGE = "joint_relay";
//前池水位
private final static String WATER_LEVEL = "water_level";
//限制水位
private final static String LIMIT_WATER_LEVEL = "limit_water_level";
//机组转速
private final static String UNIT_REV = "index_jzzs";
//导叶开度
private final static String GUIDE_VANE_OPENING = "index_dykd";
//无功功率Q
private final static String REACTIV_POWER = "reactive_power";
//机组Cos
private final static String POWER_FACTOR = "index_jz_cos";
//有功调整给定
private final static String HZVE_ADJUST_THE_GIVEN = "index_ygtzgd";
//频率
private final static String FEEDBACK = "index_jz_f";
//无功调整给定
private final static String IDLE_ADJUST_THE_GIVEN = "index_wgtzgd";
//定子电流
private final static String STATOR_CURRENT = "stator_current";
//定子电压
private final static String STATOR_VOLTAGE = "stator_voltage";
/**
* 从Redis获取设备信息
@ -244,11 +254,12 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
Map<String, List<YearGenerationVo>> yearGenerationMap = new HashMap<>();
Object yearGenerationDataObject = redisTemplate.opsForValue().get(yearGenerationData);
if (ObjectUtil.isNotEmpty(yearGenerationDataObject)) {
yearGenerationMap = JSONObject.parseObject(yearGenerationDataObject.toString(), new TypeReference<Map<String, List<YearGenerationVo>>>() {{
}});
yearGenerationMap = JSONObject.parseObject(yearGenerationDataObject.toString(), new TypeReference<Map<String, List<YearGenerationVo>>>() {
});
}
Float powerSumCount = 0f;
Float waterStageCount = 0f;//池水位统计
//池水位统计
Float waterStageCount;
Map<String, StationBodyVo> stringStationBodyVoMap = new HashMap<>();
Object json = redisTemplate.opsForValue().get(hisDataNew);
if (ObjectUtil.isNotEmpty(json)) {
@ -281,14 +292,6 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
}
// 限制水位
stationBodyVo.setLimitWaterLevel(dept.getLimitWaterLevel());
/*String realIdLimitWaterLevel = realMap.get(dept.getCode() + LIMIT_WATER_LEVEL);
if (StringUtil.isNotBlank(realIdLimitWaterLevel)) {
if (null != realIdKeyMap.get(realIdLimitWaterLevel)) {
Float aFloat = realIdKeyMap.get(realIdLimitWaterLevel);
stationBodyVo.setLimitWaterLevel(aFloat);
}
}*/
stationBodyVo.setPowerSumCount(powerSumCount);
log.info("powerSumCount:{};installedCapacityCount:{}", powerSumCount, stationBodyVo.getInstalledCapacityCount());
//logger.info("getRedisHisDataByDeptNewArgs", "powerSumCount:" + powerSumCount + ";installedCapacityCount:" + stationBodyVo.getInstalledCapacityCount());
@ -333,11 +336,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
}
List<Long> ids = new ArrayList<>();
Map<Long, Map<String, Double>> rideCountGroupEmIdByDepts = emParamClient.getRideCountGroupEmIdByDepts(ids);
/*List<HzimsAnalyzeModelStationEntity> analyzeModelStationEntityList = analyzeModelStationService.list(new LambdaQueryWrapper<HzimsAnalyzeModelStationEntity>() {{
eq(HzimsAnalyzeModelStationEntity::getIsDeleted, 0);
}});*/
for (StationEntity dept : stations) {
//前池水位数据
List<AnalyseDataTaosVO> waterLevelList = this.getWaterLevelTheDay(dept.getCode(), beginTime, endTime);
@ -396,7 +395,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
}
}
} catch (Exception e) {
log.error("-----getTheDayHydrographRedis-error{}-----", e);
log.error("-----getTheDayHydrographRedis-error{}-----", e.getMessage());
}
}
@ -417,7 +416,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
List<EminfoAndEmParamVo> eminfoAndEmParamVos = this.getEmInfoList();
//获取计划发电量
List<PlanGenerationEntity> planGenerationByDateAndStationList = planGenertionClient.getPlanGenerationByParam(stations.stream().map(s -> s.getCode()).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy-"));
List<PlanGenerationEntity> planGenerationByDateAndStationList = planGenertionClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy-"));
LocalDateTime yearBeginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-01-01 00:00:00"), df);
@ -485,7 +484,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
}
}
} catch (Exception e) {
log.error("-----getTheDayHydrographRedis-error{}-----", e);
log.error("-----getTheDayHydrographRedis-error{}-----", e.getMessage());
}
}
@ -605,7 +604,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
map.put("rideCount", rideCount);
map.put("installedCapacityCount", installedCapacityCount);
int installedCapacity = 0;
int installedCapacity;
if (MapUtils.isNotEmpty(paramCountGroupEmIds)) {
Map<String, Integer> stringIntegerMap = paramCountGroupEmIds.get(emInfoExtendVo.getId());
if (MapUtils.isNotEmpty(stringIntegerMap)) {
@ -660,7 +659,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
R<List<String>> listAnalyseCode = analyseInstanceClient.getListAnalyseCode(emInfoList.stream().map(EmInfoExtendVo::getEmCode).collect(Collectors.toList()));
if (listAnalyseCode.isSuccess() && CollectionUtil.isNotEmpty(listAnalyseCode.getData())) {
List<String> emCodeList = listAnalyseCode.getData();
List<EminfoAndEmParamVo> emInfoEntityList = emInfoList.stream().filter(o -> emCodeList.stream().collect(Collectors.toList()).contains(o.getEmCode())).collect(Collectors.toList());
List<EminfoAndEmParamVo> emInfoEntityList = emInfoList.stream().filter(o -> new ArrayList<>(emCodeList).contains(o.getEmCode())).collect(Collectors.toList());
UnitVo unitVo = new UnitVo();
if (CollectionUtil.isNotEmpty(emInfoEntityList)) {
for (EminfoAndEmParamVo emInfoEntity : emInfoEntityList) {
@ -716,7 +715,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
if (ObjectUtil.isNotEmpty(dept.getCommissionTime())) {
Duration dur = Duration.between(dept.getCommissionTime(), LocalDateTime.now());
//天数
day = Integer.valueOf(dur.toDays() + "");
day = Integer.parseInt(dur.toDays() + "");
}
stationVo.setSafetyOperationNumber(day);
stationVo.setLatitude(dept.getLttd());
@ -745,7 +744,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
LocalDateTime beginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"), df);
LocalDateTime endTime = LocalDateTime.now();
//给站点年发电量中的月份以及计划发电量赋值
List<YearGenerationVo> yearGenerationVos = this.setYearGenerationData(12, dept.getCode(), planGenerationByDateAndStationList);
List<YearGenerationVo> yearGenerationVos = this.setYearGenerationData(dept.getCode(), planGenerationByDateAndStationList);
//前池水位数据
List<AnalyseDataTaosVO> waterLevelList = this.getWaterLevelTheDay(dept.getCode(),beginTime,endTime);
@ -760,7 +759,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
R<List<String>> listAnalyseCode = analyseInstanceClient.getListAnalyseCode(emInfoList.stream().map(EmInfoExtendVo::getEmCode).collect(Collectors.toList()));
if (listAnalyseCode.isSuccess() && CollectionUtil.isNotEmpty(listAnalyseCode.getData())) {
List<String> emCodeList = listAnalyseCode.getData();
List<EminfoAndEmParamVo> emInfoEntityList = emInfoList.stream().filter(o -> emCodeList.stream().collect(Collectors.toList()).contains(o.getEmCode())).collect(Collectors.toList());
List<EminfoAndEmParamVo> emInfoEntityList = emInfoList.stream().filter(o -> new ArrayList<>(emCodeList).contains(o.getEmCode())).collect(Collectors.toList());
UnitVo unitVo = new UnitVo();
if (CollectionUtil.isNotEmpty(emInfoEntityList)) {
for (EminfoAndEmParamVo emInfoEntity : emInfoEntityList) {
@ -865,7 +864,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
if (ObjectUtil.isNotEmpty(dept.getCommissionTime())) {
Duration dur = Duration.between(dept.getCommissionTime(), LocalDateTime.now());
//天数
day = Integer.valueOf(dur.toDays() + "");
day = Integer.parseInt(dur.toDays() + "");
}
if (null != stationVo.getYearPlanGenerateSumCount()) {
stationVo.setYearSentGenerationCount(stationVo.getYearGenerateSumCount() / stationVo.getYearPlanGenerateSumCount() * 100);
@ -897,11 +896,11 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
if (CollectionUtil.isNotEmpty(analyzeDataConditionVO.getList())) {
List<AnalyseDataTaosVO> list = analyzeDataConditionVO.getList();
for (AnalyseDataTaosVO analyseDataTaosVO : list) {
float count = 0;
float count;
if (StringUtil.isBlank(analyseDataTaosVO.getVal())) {
analyseDataTaosVO.setVal("0");
} else {
count = Float.valueOf(analyseDataTaosVO.getVal()) * (float) rideCount;
count = Float.parseFloat(analyseDataTaosVO.getVal()) * (float) rideCount;
analyseDataTaosVO.setVal(count + "");
}
}
@ -915,17 +914,16 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
/**
* 给站点年发电量中的月份以及计划发电量赋值
*
* @param month
* @return
*/
private List<YearGenerationVo> setYearGenerationData(int month, String stationId, List<PlanGenerationEntity> planGenerationByDateAndStationList) {
private List<YearGenerationVo> setYearGenerationData(String stationId, List<PlanGenerationEntity> planGenerationByDateAndStationList) {
List<PlanGenerationEntity> collect = new ArrayList<>();
if (CollectionUtil.isNotEmpty(planGenerationByDateAndStationList)) {
collect = planGenerationByDateAndStationList.stream().filter(s -> s.getStationId().equals(stationId)).collect(Collectors.toList());
}
List<YearGenerationVo> yearGenerationVoList = new ArrayList<>();
String format = DateUtil.format(new Date(), "yyyy-");
for (int i = 1; i <= month; i++) {
for (int i = 1; i <= 12; i++) {
YearGenerationVo vo = new YearGenerationVo();
if (i < 10) {
vo.setYearMonth(format + "0" + i);
@ -959,7 +957,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
for (int i = 0; i < list.size(); i++) {
AnalyseDataTaosVO analyseDataTaosVO = list.get(i);
YearGenerationVo yearGenerationVo = yearGenerationVoList.get(i);
float count = 0;
float count;
if (StringUtil.isNotBlank(analyseDataTaosVO.getVal())) {
count = Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO.getVal()) * rideCount));
analyseDataTaosVO.setVal(count + "");
@ -1328,9 +1326,10 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
if (CollectionUtil.isNotEmpty(record.getList())) {
AnalyseDataTaosVO analyseDataTaosVO1 = record.getList().get(0);
if (ObjectUtil.isNotEmpty(analyseDataTaosVO1) && StringUtil.isNotBlank(analyseDataTaosVO1.getVal())) {
Float aFloat = Float.valueOf(analyseDataTaosVO1.getVal());
float aFloat = Float.parseFloat(analyseDataTaosVO1.getVal());
if (0 != rideCount) {
aFloat = Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO1.getVal()) * rideCount));; //获取发电量的值 且 * rideCount
//获取发电量的值 且 * rideCount
aFloat = Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO1.getVal()) * rideCount));
}
if (typeCycle == EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType()) {
vo.setDayGenerateCount(aFloat);
@ -1358,11 +1357,11 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
List<String> listByYear = TimeUtils.getListByYearMon(year, mon);
String currentMon = TimeUtils.getMon(year, mon);
Integer count=0;
Map<Long, Map<String, Float>> powerMapThree = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
Map<String, Map<String, Float>> powerMapThree = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
log.info("Redis近三年发电量数据查询:"+powerMapThree);
for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) {
for (Map.Entry<String, Map<String, Float>> deviceMap : powerMapThree.entrySet()) {
for (StationEntity stationEntity : stationEntityList) {
if (stationEntity.getId().equals(deviceMap.getKey())) {
if (stationEntity.getCode().equals(deviceMap.getKey())) {
StationRunReportVO stationReportVO = new StationRunReportVO();
count++;
stationReportVO.setIndex(count);
@ -1392,7 +1391,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
.divide(BigDecimal.valueOf(stationReportVO.getPowerMonPlan()), 2, RoundingMode.UP);
stationReportVO.setPowerMonRate(String.valueOf(monRate.doubleValue()));
}else {
stationReportVO.setPowerMonRate(new Double(0).toString());
stationReportVO.setPowerMonRate(Double.toString(0));
}
if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear())
&&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan())
@ -1401,7 +1400,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
.divide(BigDecimal.valueOf(stationReportVO.getPowerYearPlan()), 2, RoundingMode.UP);
stationReportVO.setPowerYearRate(String.valueOf(yearRate.doubleValue()));
}else {
stationReportVO.setPowerYearRate(new Double(0).toString());
stationReportVO.setPowerYearRate(Double.toString(0));
}
reportVOS.add(stationReportVO);
}
@ -1493,7 +1492,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
.divide(BigDecimal.valueOf(stationReportVO.getPowerMonPlan()), 2, RoundingMode.UP);
stationReportVO.setPowerMonRate(String.valueOf(monRate.doubleValue()));
}else {
stationReportVO.setPowerMonRate(new Double(0).toString());
stationReportVO.setPowerMonRate(Double.toString(0));
}
if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear())
&&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan())
@ -1502,7 +1501,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
.divide(BigDecimal.valueOf(stationReportVO.getPowerYearPlan()), 2, RoundingMode.UP);
stationReportVO.setPowerYearRate(String.valueOf(yearRate.doubleValue()));
}else {
stationReportVO.setPowerYearRate(new Double(0).toString());
stationReportVO.setPowerYearRate(Double.toString(0));
}
stationReportVOList.add(stationReportVO);
return stationReportVOList;
@ -1589,7 +1588,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
R<Float> planGenerationMonthCount = planGenertionClient.planGenerationMonthCount(stationEntity.getCode(), month);//获取计划月发电量
stationReportVO.setEnergy(powerCount.get());
if (planGenerationMonthCount.isSuccess() && ObjectUtil.isNotEmpty(planGenerationMonthCount.getData()) && planGenerationMonthCount.getData() != 0) {
Float rate = powerCount.get() / planGenerationMonthCount.getData() * 100;
float rate = powerCount.get() / planGenerationMonthCount.getData() * 100;
stationReportVO.setYearPlanCompleteRate((float) (Math.round(rate * 100) / 100));
}
stationReportVOList.add(stationReportVO);
@ -1710,8 +1709,8 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
//全部
//List<Integer> stationTypesAll = stationAll.stream().map(s -> s.getType()).distinct().collect(Collectors.toList());
//用户权限
List<Integer> refDomainTypesUserAuth = stationUserAuth.stream().map(s -> s.getRefDomain()).distinct().collect(Collectors.toList());
List<Integer> stationTypesUserAuth = stationUserAuth.stream().map(s -> s.getType()).distinct().collect(Collectors.toList());
List<Integer> refDomainTypesUserAuth = stationUserAuth.stream().map(StationEntity::getRefDomain).distinct().collect(Collectors.toList());
List<Integer> stationTypesUserAuth = stationUserAuth.stream().map(StationEntity::getType).distinct().collect(Collectors.toList());
if (refDomainTypesUserAuth.size() > 1) {//多个行业 系统数据总览
@ -1742,10 +1741,10 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
List<StationEntity> stationUserAuth = stationService.getStationByUserAuth(user);
List<StationEntity> stationAll = stationService.getAll();
//全部
List<Integer> stationTypesAll = stationAll.stream().map(s -> s.getType()).distinct().collect(Collectors.toList());
List<Integer> stationTypesAll = stationAll.stream().map(StationEntity::getType).distinct().collect(Collectors.toList());
//用户权限
Integer refDomainTypesUserAuthByRefDomain = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(s -> s.getRefDomain()).distinct().collect(Collectors.toList()).get(0);
List<Integer> stationTypesUserAuth = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(s -> s.getType()).distinct().collect(Collectors.toList());
Integer refDomainTypesUserAuthByRefDomain = stationUserAuth.stream().map(StationEntity::getRefDomain).filter(domain -> domain.toString().equals(refDomain)).distinct().collect(Collectors.toList()).get(0);
List<Integer> stationTypesUserAuth = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(StationEntity::getType).distinct().collect(Collectors.toList());
InDustryVo inDustryVo = new InDustryVo();
inDustryVo.setType(OperationalConstants.InDustryEnum.INDUSTRY.getVal());
inDustryVo.setMainWorkBenchExtendVo(this.getRouteByRefDomain(null, inDustryVo, refTerminal, stationTypesAll, refDomainTypesUserAuthByRefDomain, stationTypesUserAuth, stationUserAuth));
@ -1764,7 +1763,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
stationTypes.add(Integer.valueOf(stationType));
InDustryVo inDustryVo = new InDustryVo();
MainWorkBenchExtendVo mainWorkBenchExtendVo = new MainWorkBenchExtendVo();
int userStaionCount = this.staionTypeSingle(user, type, stationType, null);
int userStaionCount = this.staionTypeSingle(user, type, stationType);
mainWorkBenchExtendVo.setMainWorkBenchEntityList(this.getResult(userStaionCount, Integer.valueOf(type), refTerminal, stationTypes));
inDustryVo.setType(OperationalConstants.InDustryEnum.INDUSTRY.getVal());
inDustryVo.setMainWorkBenchExtendVo(mainWorkBenchExtendVo);
@ -1786,10 +1785,10 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
List<StationEntity> stationUserAuth = stationService.getStationByUserAuth(user);
List<StationEntity> stationAll = stationService.getAll();
//全部
List<Integer> stationTypesAll = stationAll.stream().map(s -> s.getType()).distinct().collect(Collectors.toList());
List<Integer> stationTypesAll = stationAll.stream().map(StationEntity::getType).distinct().collect(Collectors.toList());
//用户权限
Integer refDomainTypesUserAuthByRefDomain = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(s -> s.getRefDomain()).distinct().collect(Collectors.toList()).get(0);
List<Integer> stationTypesUserAuth = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(s -> s.getType()).distinct().collect(Collectors.toList());
Integer refDomainTypesUserAuthByRefDomain = stationUserAuth.stream().map(StationEntity::getRefDomain).filter(domain -> domain.toString().equals(refDomain)).distinct().collect(Collectors.toList()).get(0);
List<Integer> stationTypesUserAuth = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomain)).map(StationEntity::getType).distinct().collect(Collectors.toList());
InDustryVo inDustryVo = new InDustryVo();
inDustryVo.setType(OperationalConstants.InDustryEnum.INDUSTRY.getVal());
@ -1859,31 +1858,31 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
List<Integer> stationTypes = new ArrayList<>();
if (bool) {
for (Long deptId : deptIds) {
stationTypesUserAuthDeptIds.addAll(stationUserAuth.stream().filter(o -> o.getRefDept().toString().equals(deptId.toString())).map(s -> s.getType()).collect(Collectors.toList()));
stationTypesUserAuthDeptIds.addAll(stationUserAuth.stream().filter(o -> o.getRefDept().toString().equals(deptId.toString())).map(StationEntity::getType).collect(Collectors.toList()));
station.addAll(stationUserAuth.stream().filter(o -> o.getRefDept().toString().equals(deptId.toString())).collect(Collectors.toList()));
}
} else {
stationTypesUserAuthDeptIds.addAll(stationTypesUserAuth);
station.addAll(stationUserAuth);
}
if (0 == stationTypesUserAuthDeptIds.size()) {
if (stationTypesUserAuthDeptIds.isEmpty()) {
return null;
}
if (stationTypesAllByRefDomain.size() == stationTypesUserAuthDeptIds.size()) {//行业数据总览
List<MainWorkBenchEntity> mainWorkBenchByType = mainWorkBenchService.getMainWorkBenchByType(OperationalConstants.FirstPageTypeEnum.INDUSTRY.getVal(), refDomainTypesUserAuth, refTerminal, stationTypesUserAuthDeptIds);
mainWorkBenchEntityList.addAll(mainWorkBenchByType);
} else if (stationTypesAllByRefDomain.size() != stationTypesUserAuthDeptIds.size() && stationTypesUserAuthDeptIds.size() > 1) {//多个站点类型
} else if (stationTypesUserAuthDeptIds.size() > 1) {//多个站点类型
inDustryVo.setType(OperationalConstants.InDustryEnum.MORE_STATION_TYPE.getVal());
List<StationEntity> userStation = stationUserAuth.stream().filter(o -> o.getRefDomain().toString().equals(refDomainTypesUserAuth.toString())).collect(Collectors.toList());
for (StationEntity vo : userStation) {
int refDomainStationCount = userStation.stream().filter(o -> o.getType().toString().equals(vo.getType().toString())).collect(Collectors.toList()).size();
int refDomainStationCount = (int) userStation.stream().filter(o -> o.getType().toString().equals(vo.getType().toString())).count();
stationTypes.add(vo.getType());
List<MainWorkBenchEntity> result = this.getResult(refDomainStationCount, vo.getRefDomain(), refTerminal, stationTypes);
mainWorkBenchEntityList.addAll(result);
}
} else if (stationTypesAllByRefDomain.size() != stationTypesUserAuthDeptIds.size() && stationTypesUserAuthDeptIds.size() == 1) {//单个站点类型
} else {//单个站点类型
inDustryVo.setType(OperationalConstants.InDustryEnum.SINGLE_STATION_TYPE.getVal());
int refDomainStationCount = station.stream().filter(o -> o.getType().toString().equals(stationTypesUserAuthDeptIds.get(0).toString())).collect(Collectors.toList()).size();
int refDomainStationCount = (int) station.stream().filter(o -> o.getType().toString().equals(stationTypesUserAuthDeptIds.get(0).toString())).count();
stationTypes.add(stationTypesUserAuthDeptIds.get(0));
List<MainWorkBenchEntity> result = this.getResult(refDomainStationCount, refDomainTypesUserAuth, refTerminal, stationTypes);
mainWorkBenchEntityList.addAll(result);
@ -1917,19 +1916,18 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
* @param user
* @param refDomain
* @param type
* @param deptIds
* @return
*/
private int staionTypeSingle(BladeUser user, String refDomain, String type, List<Long> deptIds) {
private int staionTypeSingle(BladeUser user, String refDomain, String type) {
int userStaionCount = 0;
if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.EMPLOYER_VISIBLE.getVal()) && ObjectUtil.isNotEmpty(user.getDeptId())) {//所属机构
userStaionCount = stationService.getEqualToRefDeptStationCount(Long.valueOf(user.getDeptId()), refDomain, type, deptIds);
userStaionCount = stationService.getEqualToRefDeptStationCount(Long.valueOf(user.getDeptId()), refDomain, type, null);
} else if ((user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.EMPLOYER_SUBORDINATE_BODY.getVal()) || user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.SELT_SUBORDINATE_BODY.getVal())) && ObjectUtil.isNotEmpty(user.getDeptId())) {//所属机构及下属机构
userStaionCount = stationService.getLikeRefDeptStationCount(Long.valueOf(user.getDeptId()), refDomain, type, deptIds);
userStaionCount = stationService.getLikeRefDeptStationCount(Long.valueOf(user.getDeptId()), refDomain, type, null);
} else if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.AFFILIATE.getVal()) && ObjectUtil.isNotEmpty(user.getDeptIds())) {//附属机构
userStaionCount = stationService.getInRefDeptStationCount(Func.toLongList(user.getDeptIds()), refDomain, type, deptIds);
userStaionCount = stationService.getInRefDeptStationCount(Func.toLongList(user.getDeptIds()), refDomain, type, null);
} else if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.AFFILIATE_SUBORDINATE_BODY.getVal()) && ObjectUtil.isNotEmpty(user.getDeptIds())) {//附属机构及下属
userStaionCount = stationService.getForEachRefDeptStationCount(Func.toLongList(user.getDeptIds()), refDomain, type, deptIds);
userStaionCount = stationService.getForEachRefDeptStationCount(Func.toLongList(user.getDeptIds()), refDomain, type, null);
}
return userStaionCount;
}
@ -1941,70 +1939,9 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
if ("admin".equals(user.getAccount())) {
return stationService.getAll();
}
return getStationList(true);
return getStationList();
}
/*@Override
public List<StationDeptVo> doListByAuthDept() {
List<StationDeptVo> stationDeptVos = new ArrayList<>();
BladeUser user = AuthUtil.getUser();
if (user.getAccount().equals("admin")) {
R<List<Dept>> deptByType = sysClient.getDeptByType("200000", null, null);
if (deptByType.isSuccess() && CollectionUtil.isNotEmpty(deptByType.getData())) {
deptByType.getData().forEach(o -> {
StationDeptVo vo = new StationDeptVo();
vo.setRefDept(o.getId().toString());
vo.setStationId(o.getStationId());
vo.setName(o.getDeptName());
stationDeptVos.add(vo);
});
}
List<StationEntity> stationEntityList = stationService.getAll();
stationEntityList.forEach(o -> {
StationDeptVo vo = new StationDeptVo();
vo.setRefDept(o.getRefDept().toString());
vo.setStationId(o.getCode());
vo.setName(o.getName());
stationDeptVos.add(vo);
});
if (CollectionUtil.isNotEmpty(stationDeptVos) && user.getAccount().equals("admin")) {
Set<StationDeptVo> collect = stationDeptVos.stream().collect(Collectors.toSet());
List<StationDeptVo> collect1 = collect.stream().collect(Collectors.toList());
return collect1;
}
return stationDeptVos;
}
List<StationEntity> list = getStationList(true);
String userDepts = this.classifyUserDataStringDepts();
if (CollectionUtil.isNotEmpty(list) && StringUtil.isNotBlank(userDepts)) {
for (String deptId : userDepts.split(",")) {
List<StationEntity> collect = list.stream().filter(iter -> iter.getRefDept().toString().equals(deptId)).collect(Collectors.toList());
if (CollectionUtil.isEmpty(collect)) {
R<Dept> dept = sysClient.getDept(Long.valueOf(deptId));
if (dept.isSuccess() && ObjectUtil.isNotEmpty(dept.getData())) {
StationDeptVo vo = new StationDeptVo();
Dept data = dept.getData();
vo.setName(data.getDeptName());
vo.setStationId(data.getStationId());
vo.setRefDept(data.getId().toString());
stationDeptVos.add(vo);
}
}
}
for (StationEntity stationEntity : list) {
StationDeptVo vo = new StationDeptVo();
vo.setName(stationEntity.getName());
vo.setStationId(stationEntity.getCode());
vo.setRefDept(stationEntity.getRefDept().toString());
stationDeptVos.add(vo);
}
}
return stationDeptVos;
}
*/
@Override
public List<StationDeptVo> doListByAuthDept() {
List<StationDeptVo> stationDeptVos = new ArrayList<>();
@ -2024,13 +1961,12 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
@Override
public R deptByAuthUser() {
R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser();
return deptByCurrentUser;
return sysClient.getDeptByCurrentUser();
}
private List<StationEntity> getStationList(boolean bool) {
return this.classifyUserDataScopeType(null, null, null, bool);
private List<StationEntity> getStationList() {
return this.classifyUserDataScopeType(null, null, null, true);
}

18
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

@ -151,7 +151,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
// 减少森林砍伐
kpi.setDeforest(targets.stream().mapToDouble(PhotovoltaicTargetVo::getDeforest).sum());
// 近3年发电量
kpi.setPowerYearVoList(this.getPowerList(stations.stream().map(StationEntity::getId).collect(Collectors.toList())));
kpi.setPowerYearVoList(this.getPowerList(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())));
return kpi;
}
@ -160,9 +160,9 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
*
* @return
*/
private List<PowerYearVo> getPowerList(List<Long> stations) {
private List<PowerYearVo> getPowerList(List<String> stations) {
// 站点近年发电数据 key - stationCode value - 月份,发电量
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
Map<String, Map<String, Float>> map = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
if (MapUtils.isEmpty(map)) {
return new ArrayList<>();
}
@ -227,7 +227,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return this.getGeneration(stations.stream().map(StationEntity::getRefDept).distinct().collect(Collectors.toList()), false);
// 年
case "2":
return this.getGenerationYear(stations.stream().map(StationEntity::getId).distinct().collect(Collectors.toList()));
return this.getGenerationYear(stations.stream().map(StationEntity::getCode).distinct().collect(Collectors.toList()));
default:
throw new ServiceException("无效查询类型!");
}
@ -285,9 +285,9 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
*
* @return
*/
private List<GenerationVo> getGenerationYear(List<Long> stations) {
private List<GenerationVo> getGenerationYear(List<String> stations) {
// 站点近年发电数据 key - stationCode value - 月份,发电量
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
Map<String, Map<String, Float>> map = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
if (MapUtils.isEmpty(map)) {
return new ArrayList<>();
}
@ -745,7 +745,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return this.periodLoadGenerate(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()), type, false);
// 年
case "3":
return this.periodLoadGenerateYear(stations.stream().map(StationEntity::getId).collect(Collectors.toList()));
return this.periodLoadGenerateYear(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
default:
throw new ServiceException("无效查询类型!");
@ -850,9 +850,9 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
* @param stations
* @return
*/
private List<PhotovoltaicLoadGenerateVo> periodLoadGenerateYear(List<Long> stations) {
private List<PhotovoltaicLoadGenerateVo> periodLoadGenerateYear(List<String> stations) {
// 站点近年发电数据 key - stationCode value - 月份,发电量
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
Map<String, Map<String, Float>> map = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data);
if (MapUtils.isEmpty(map)) {
return new ArrayList<>();
}

40
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java

@ -1,16 +1,13 @@
package com.hnac.hzims.operational.main.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse;
@ -21,9 +18,6 @@ import com.hnac.hzims.operational.defect.constants.DefectConstant;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService;
import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.duty.vo.DutyInfoVo;
import com.hnac.hzims.operational.duty.vo.DutyTaskVo;
import com.hnac.hzims.operational.duty.vo.NextDutyInfoVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.entity.UserDeptEntity;
import com.hnac.hzims.operational.main.service.*;
@ -31,24 +25,20 @@ import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.report.vo.DutyDefectVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient;
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient;
import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient;
import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.entity.Region;
import org.springblade.system.feign.ISysClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
@ -57,16 +47,10 @@ import org.springframework.stereotype.Service;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
/**
@ -185,7 +169,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
if(MapUtils.isEmpty(map)){
return null;
}
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
Map<String, Map<String, Float>> powerMap = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
List<String> monList = this.getMonthList(0,12,false);
// 获取总发电量
float sumPower = this.getSumPower(map.values(),powerMap,monList);
@ -226,7 +210,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
// 获取站点7日天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.weatherService.getWeekWeather( codes);
// 近年发电量
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
Map<String, Map<String, Float>> powerMap = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
// 计划发电量
List<PlanGenerationEntity> planGenerationList = this.getStaionPlanPower(map);
// 站点容量、设备运行情况
@ -311,7 +295,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
* @param powerMap
* @return
*/
private float getSumPower(Collection<List<StationEntity>> values, Map<Long, Map<String, Float>> powerMap,List<String> monList) {
private float getSumPower(Collection<List<StationEntity>> values, Map<String, Map<String, Float>> powerMap,List<String> monList) {
if(CollectionUtil.isEmpty(values) || MapUtils.isEmpty(powerMap) || CollectionUtil.isEmpty(monList)){
return 0f;
}
@ -330,11 +314,11 @@ public class SideHustleServiceImpl implements ISideHustleService {
* @param powerMap
* @return
*/
private float getPower(List<StationEntity> list,Map<Long, Map<String, Float>> powerMap,List<String> monList) {
private float getPower(List<StationEntity> list,Map<String, Map<String, Float>> powerMap,List<String> monList) {
if(CollectionUtil.isEmpty(list) || MapUtils.isEmpty(powerMap) || CollectionUtil.isEmpty(monList)){
return 0f;
}
List<Long> stationIdList = list.stream().map(StationEntity::getId).collect(Collectors.toList());
List<String> stationIdList = list.stream().map(StationEntity::getCode).collect(Collectors.toList());
if(CollectionUtil.isEmpty(stationIdList)){
return 0f;
}
@ -344,7 +328,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
}
float sumPower = 0f;
for(Map<String,Float> item : floatList){
sumPower += item.entrySet().stream().filter(o->monList.contains(o.getKey())).mapToDouble(Map.Entry::getValue).sum();
sumPower += (float) item.entrySet().stream().filter(o->monList.contains(o.getKey())).mapToDouble(Map.Entry::getValue).sum();
}
return sumPower;
}
@ -719,7 +703,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
@Override
public List<PowerFinishVo> areaPowerMonth(Long deptId) {
// 实际发电量
Map<Long, Map<String, Float>> powerMap = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
Map<String, Map<String, Float>> powerMap = (Map<String, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
// 确定获取数据区域
Map<Dept,List<StationEntity>> map = areaService.getAuthArea(null,deptId,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true);
if (MapUtils.isEmpty(map)) {
@ -756,11 +740,11 @@ public class SideHustleServiceImpl implements ISideHustleService {
* @param powerMap
* @return
*/
private float getStationActualPower(List<StationEntity> value, Map<Long, Map<String, Float>> powerMap,String mon) {
private float getStationActualPower(List<StationEntity> value, Map<String, Map<String, Float>> powerMap,String mon) {
if(CollectionUtil.isEmpty(value) || MapUtils.isEmpty(powerMap)){
return 0f;
}
List<Long> stationIdList = value.stream().map(StationEntity::getId).collect(Collectors.toList());
List<String> stationIdList = value.stream().map(StationEntity::getCode).collect(Collectors.toList());
if(CollectionUtil.isEmpty(stationIdList)){
return 0f;
}

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java

@ -53,6 +53,9 @@ public class HikVideoServiceImpl implements IHikVideoService {
String contentType = "application/json";
String resultStr = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null);
JSONObject resultObj = JSONObject.parseObject(resultStr);
if(ObjectUtil.isEmpty(resultObj)){
throw new ServiceException("该平台信息录入有误,无法找到对应点位!");
}
Assert.isTrue("0".equals(resultObj.getString("code")),()-> {
throw new ServiceException(resultObj.getString("msg"));
});

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java

@ -107,7 +107,7 @@ public class OperationTicketServiceImpl implements OperationTicketService , Star
String standardTicketInfoVoBySave = this.saveEntity(JSONObject.toJSONString(standardTicketInfoVo));
//查询流程对应value
String dictValue = processDictFeignService.selectDictValueByKey(OPERATION_TICKET_KEY);
if (true){
if (isOffice){
dictValue = processDictFeignService.selectDictValueByKey(OFFLINE_OPERATION_TICKET);
}
log.info("查询第操作票值: {}", dictValue);

12
pom.xml

@ -15,7 +15,7 @@
<properties>
<hzinfo.platform.version>5.1.3.RELEASE.fix2</hzinfo.platform.version>
<data.sdk.version>5.2.0.0-SNAPSHOT</data.sdk.version>
<data.sdk.version>5.1.3.RELEASE.fix3</data.sdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@ -112,11 +112,6 @@
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>message-api</artifactId>
<version>${hzims.project.version}</version>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>middle-api</artifactId>
<version>${hzims.project.version}</version>
</dependency>
@ -140,11 +135,6 @@
<artifactId>safeproduct-api</artifactId>
<version>${hzims.project.version}</version>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>topvision-api</artifactId>
<version>${hzims.project.version}</version>
</dependency>
<dependency>
<groupId>com.hikvision.ga</groupId>

5
target/classes/META-INF/build-info.properties

@ -0,0 +1,5 @@
build.artifact=hzims-back
build.group=com.hnac.hzims
build.name=hzims-back
build.time=2024-07-22T06\:45\:56.469Z
build.version=4.0.0-SNAPSHOT
Loading…
Cancel
Save