Browse Source

#水电站运行月报生成接口

zhongwei
yang_shj 6 months ago
parent
commit
791f2ffdfc
  1. 7
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java
  2. 6
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java
  3. 6
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java
  4. 1
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java
  5. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml
  6. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java
  7. 1
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java
  8. 47
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  9. 5
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java
  10. 10
      hzims-service/operational/pom.xml
  11. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java
  12. 63
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java
  13. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java
  14. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java
  15. 543
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

7
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java

@ -19,6 +19,7 @@ package com.hnac.hzims.equipment.feign;
import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.vo.DeviceVO; import com.hnac.hzims.equipment.vo.DeviceVO;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.system.vo.CreateTableVO; import org.springblade.system.vo.CreateTableVO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
@ -84,6 +85,9 @@ public interface IEmInfoClient {
String DEVICE_BY_PATH = API_PREFIX + "/deviceByPath"; String DEVICE_BY_PATH = API_PREFIX + "/deviceByPath";
String EM_INFO_LIST = API_PREFIX + "/emInfoList"; String EM_INFO_LIST = API_PREFIX + "/emInfoList";
String RIDE_DEVICES = API_PREFIX + "/rideDevices";
@PostMapping(DETAIL) @PostMapping(DETAIL)
EmInfoEntity getByCode(@RequestParam("code") String id); EmInfoEntity getByCode(@RequestParam("code") String id);
@ -169,4 +173,7 @@ public interface IEmInfoClient {
@GetMapping(EM_INFO_LIST) @GetMapping(EM_INFO_LIST)
R<List<EmInfoEntity>> emInfoList(EmInfoEntity req); R<List<EmInfoEntity>> emInfoList(EmInfoEntity req);
@GetMapping(RIDE_DEVICES)
List<RideDeviceVo> rideDevices(List<Long> longs);
} }

6
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java

@ -2,6 +2,7 @@ package com.hnac.hzims.equipment.feign;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.vo.DeviceVO; import com.hnac.hzims.equipment.vo.DeviceVO;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.system.vo.CreateTableVO; import org.springblade.system.vo.CreateTableVO;
@ -114,4 +115,9 @@ public class IEmInfoClientBack implements IEmInfoClient {
public R<List<EmInfoEntity>> emInfoList(EmInfoEntity req) { public R<List<EmInfoEntity>> emInfoList(EmInfoEntity req) {
return R.fail("远程调用失败"); return R.fail("远程调用失败");
} }
@Override
public List<RideDeviceVo> rideDevices(List<Long> longs) {
return new ArrayList<>();
}
} }

6
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java

@ -9,6 +9,7 @@ import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.service.IEmInfoService;
import com.hnac.hzims.equipment.vo.DeviceVO; import com.hnac.hzims.equipment.vo.DeviceVO;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
@ -155,6 +156,11 @@ public class EmInfoClient implements IEmInfoClient {
return R.data(service.list(queryWrapper)); return R.data(service.list(queryWrapper));
} }
@Override
public List<RideDeviceVo> rideDevices(List<Long> deptIds) {
return service.rideDevices(deptIds);
}
@PostMapping(GET_EM_CREATE_TABLE) @PostMapping(GET_EM_CREATE_TABLE)
@Override @Override
public List<CreateTableVO> getEmCreateTable(List<String> tableNames) { public List<CreateTableVO> getEmCreateTable(List<String> tableNames) {

1
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java

@ -19,4 +19,5 @@ public interface EmParamMapper extends UserDataScopeBaseMapper<EmParamEntity> {
List<EmParamEntity> selectRideCountGroupEmIdByDepts(@Param("list") List<Long> list); List<EmParamEntity> selectRideCountGroupEmIdByDepts(@Param("list") List<Long> list);
List<EmParamEntity> rides(List<Long> deviceIds);
} }

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml

@ -53,4 +53,13 @@
'installedCapacity') 'installedCapacity')
</select> </select>
<select id="rides" resultType="com.hnac.hzims.equipment.entity.EmParamEntity">
SELECT * FROM HZIMS_EM_PARAM
WHERE `IS_DELETED` = 0
AND (PARAM_NAME = 'ct' OR PARAM_NAME = 'CT' OR PARAM_NAME = 'PR' OR PARAM_NAME = 'pt')
AND INFO_ID IN
<foreach collection="deviceIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper> </mapper>

2
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java

@ -98,4 +98,6 @@ public interface IEmInfoService extends BaseService<EmInfoEntity> {
List<EmInfoEntity> select(Long deptId); List<EmInfoEntity> select(Long deptId);
List<EmInfoTreeVO> getEmInfoTree(EmInfoEntity req); List<EmInfoTreeVO> getEmInfoTree(EmInfoEntity req);
List<RideDeviceVo> rideDevices(List<Long> deptIds);
} }

1
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java

@ -19,4 +19,5 @@ public interface IEmParamService extends BaseService<EmParamEntity> {
Map<Long, Map<String,Double>> getRideCountGroupEmIdByDepts(List<Long> emIds); Map<Long, Map<String,Double>> getRideCountGroupEmIdByDepts(List<Long> emIds);
List<EmParamEntity> rides(List<Long> deviceIds);
} }

47
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java

@ -949,4 +949,51 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
return this.baseMapper.getEmInfoTree(queryWrapper); return this.baseMapper.getEmInfoTree(queryWrapper);
} }
@Override
public List<RideDeviceVo> rideDevices(List<Long> deptIds) {
// 查询设备
List<EmInfoEntity> devices = this.list(Wrappers.<EmInfoEntity>lambdaQuery()
.in(EmInfoEntity::getDepartment,deptIds)
.eq(EmInfoEntity::getHomePageDisplay,"1")
.eq(EmInfoEntity::getEmType,"2")
);
if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>();
}
List<EmParamEntity> paramList = paramService.rides(devices.stream().map(EmInfoEntity::getId).collect(Collectors.toList()));
return devices.stream().map(device->{
RideDeviceVo rideDevice = new RideDeviceVo();
BeanUtil.copyProperties(device,rideDevice);
// 寻找设备配置参数
List<EmParamEntity> itemParamList = paramList.stream().filter(o->device.getId().equals(o.getInfoId())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(itemParamList)) {
// 遍历设备配置参数
for (EmParamEntity paramEntity : itemParamList) {
String paramName = paramEntity.getParamName();
switch (paramName) {
case "ct":
case "CT":
rideDevice.setCt(Double.parseDouble(paramEntity.getParamValue()));
break;
case "pt":
case "PT":
rideDevice.setPt(Double.parseDouble(paramEntity.getParamValue()));
break;
default:
break;
}
}
// 设置ct * pt
if (null != rideDevice.getCt() && null != rideDevice.getPt()) {
rideDevice.setRide(rideDevice.getCt() * rideDevice.getPt());
}else{
rideDevice.setRide(1.0);
}
}else{
rideDevice.setRide(1.0);
}
return rideDevice;
}).collect(Collectors.toList());
}
} }

5
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java

@ -69,4 +69,9 @@ public class EmParamServiceImpl extends BaseServiceImpl<EmParamMapper, EmParamEn
return result; return result;
} }
@Override
public List<EmParamEntity> rides(List<Long> deviceIds) {
return this.baseMapper.rides(deviceIds);
}
} }

10
hzims-service/operational/pom.xml

@ -240,6 +240,10 @@
<groupId>com.hnac.hzinfo.data</groupId> <groupId>com.hnac.hzinfo.data</groupId>
<artifactId>hzinfo-data-sdk</artifactId> <artifactId>hzinfo-data-sdk</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>alarm-api</artifactId>
</dependency>
@ -255,6 +259,12 @@
<version>3.9.1</version> <version>3.9.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>alarm-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java

@ -15,10 +15,13 @@ public interface IAnalyseDataService {
<T> List<AnalyzeCodeBySignagesVO> getAnalyzeCodeBySignages(Function<T, MultiAnalyzeCodePO> convert, T resource); <T> List<AnalyzeCodeBySignagesVO> getAnalyzeCodeBySignages(Function<T, MultiAnalyzeCodePO> convert, T resource);
List<AnalyzeCodeBySignagesVO> analyzeCodeBySignages(List<MultiAnalyzeCodePO> list);
List<AnalyzeDataConditionVO> periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List<String> signages);
List<AnalyseDataTaosVO> periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); List<AnalyseDataTaosVO> periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages);
List<AnalyseDataTaosVO> periodTargetDatas(String startTime, String endTime, Integer accessRules, Integer cycleType, List<String> deviceCodes, String signages); List<AnalyseDataTaosVO> periodTargetDatas(String startTime, String endTime, Integer accessRules, Integer cycleType, List<String> deviceCodes, String signages);
Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Integer ride ,String signages); Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Double ride ,String signages);
} }

63
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java

@ -1,8 +1,6 @@
package com.hnac.hzims.operational.main.service.impl; package com.hnac.hzims.operational.main.service.impl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.main.service.IAnalyseDataService; import com.hnac.hzims.operational.main.service.IAnalyseDataService;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;
@ -22,7 +20,10 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -47,6 +48,58 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
return result; return result;
} }
/**
* 查询设备实例属性标识
* @param list
* @return
*/
@Override
public List<AnalyzeCodeBySignagesVO> analyzeCodeBySignages(List<MultiAnalyzeCodePO> list) {
R<List<AnalyzeCodeBySignagesVO>> result = analyseDataSearchClient.getAnalyzeCodeBySignages(list);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>();
}
return result.getData();
}
/***
* 指标数据列表查询
* @param startTime 开始时间
* @param endTime 结束时间
* @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值
* @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6->
* @param deviceCode 设备编号
* @param signages 指标集合
* @return
*/
@Override
public List<AnalyzeDataConditionVO> periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List<String> signages) {
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
signages.forEach(signage->{
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
analyzeDataConditionPO.setFull(1);
po.setDeviceCode(deviceCode);
analyzeDataConditionPO.setKeepFigures(2);
analyzeDataConditionPO.setAccessRules(accessRules);
analyzeDataConditionPO.setSaveTimeType(cycleType);
analyzeDataConditionPO.setSignages(signage);
// 间隔
analyzeDataConditionPO.setTimeInterval(1);
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
signboardConditions.add(analyzeDataConditionPO);
});
po.setSignboardConditions(signboardConditions);
log.error("period_targets_data_request {}",po);
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) {
return new ArrayList<>();
}
log.error("period_targets_data_resp {}",result);
return result.getData();
}
/*** /***
* 指标数据列表查询 * 指标数据列表查询
* @param startTime 开始时间 * @param startTime 开始时间
@ -134,7 +187,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
* @return * @return
*/ */
@Override @Override
public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Integer ride,String signages) { public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signages) {
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>(); List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
@ -170,7 +223,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) {
return 0f; return 0f;
} }
return Float.parseFloat(Optional.ofNullable(analyseDataTaosVO.getVal()).orElse("0")) * ride; return Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO.getVal()) * ride)) ;
} }

18
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java

@ -23,6 +23,22 @@ public class RunMonthController {
private final RunMonthService runMonthService; private final RunMonthService runMonthService;
@GetMapping("/generate")
@ApiOperation(value = "生成站点月报",notes = "生成站点月报")
@ApiOperationSupport(order = 1)
public R<Boolean> generate(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){
return R.data(runMonthService.generate(mon,stationCode));
}
@GetMapping("/check")
@ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据")
@ApiOperationSupport(order = 2)
public R<Boolean> check(@RequestParam("stationCode") String stationCode){
return R.data(runMonthService.check(stationCode));
}
@GetMapping("/data") @GetMapping("/data")
@ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据") @ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
@ -33,7 +49,7 @@ public class RunMonthController {
@GetMapping("/export") @GetMapping("/export")
@ApiOperation(value = "导出站点运行月报",notes = "导出站点运行月报") @ApiOperation(value = "导出站点运行月报",notes = "导出站点运行月报")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 4)
public void export(@RequestParam("mon") String mon, public void export(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){ @RequestParam("stationCode") String stationCode){
runMonthService.export(mon,stationCode); runMonthService.export(mon,stationCode);

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java

@ -11,4 +11,8 @@ public interface RunMonthService extends BaseService<RunMonthEntity> {
RunMonthEntity data(String mon, String stationCode); RunMonthEntity data(String mon, String stationCode);
void export(String mon, String stationCode); void export(String mon, String stationCode);
Boolean generate(String mon, String stationCode);
Boolean check(String stationCode);
} }

543
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

@ -3,10 +3,38 @@ package com.hnac.hzims.operational.report.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.alarm.config.constants.AlarmConstants;
import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant;
import com.hnac.hzims.common.logs.utils.StringUtils;
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.RideDeviceVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.IAnalyseDataService;
import com.hnac.hzims.operational.report.entity.RunMonthEntity; import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import com.hnac.hzims.operational.report.mapper.RunMonthMapper; import com.hnac.hzims.operational.report.mapper.RunMonthMapper;
import com.hnac.hzims.operational.report.service.RunMonthService; import com.hnac.hzims.operational.report.service.RunMonthService;
import com.hnac.hzims.operational.report.vo.*; import com.hnac.hzims.operational.report.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.StationVO;
import com.hnac.hzinfo.datasearch.PointData;
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.history.IHistoryDataSearchClient;
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation;
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.soe.SoeDataClient;
import com.hnac.hzinfo.sdk.v5.soe.dto.StbAnalysisDTO;
import com.hnac.hzinfo.sdk.v5.soe.vo.StbAnalysisVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.hssf.usermodel.HSSFFont;
@ -17,10 +45,9 @@ import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.*;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
@ -31,19 +58,33 @@ import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.time.LocalDateTime;
import java.util.Comparator; import java.util.*;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* @author ysj * @author ysj
*/ */
@SuppressWarnings("ALL")
@Service @Service
@AllArgsConstructor @AllArgsConstructor
@Slf4j @Slf4j
public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMonthEntity> implements RunMonthService { public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMonthEntity> implements RunMonthService {
private final IStationService stationService;
private final IAnalyseDataService dataService;
private final ISoeClient soeClient;
private final IEmInfoClient deivceClient;
private final SoeDataClient soeDataClient;
private final IPlanGenertionClient planClient;
private final IHistoryDataSearchClient historyDataSearchClient;
/** /**
* 查询站点月报运行数据 * 查询站点月报运行数据
* @param mon * @param mon
@ -124,6 +165,488 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
} }
/** /**
* 生成站点月报
* @param mon
* @param stationCode
* @return
*/
@Override
public Boolean generate(String mon, String stationCode) {
// 步骤2.查询站点
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getDataOrigin, HomePageConstant.DATA_ORIGIN)
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER)
.eq(StationEntity::getCode,stationCode)
);
if(ObjectUtil.isEmpty(station)){
throw new ServiceException("未查询到站点信息!");
}
// 查询站点设备
List<RideDeviceVo> devices = deivceClient.rideDevices(Collections.singletonList(station.getRefDept()));
if(CollectionUtil.isEmpty(devices)){
throw new ServiceException("站点未配置机组设备信息、请先为站点添加设备,绑定设备实例,再进行月报查询!");
}
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(Collections.singletonList(stationCode), null , DateUtil.format(new Date(),"yyyy"));
RunMonthEntity run = new RunMonthEntity();
run.setTenantId(station.getTenantId());
run.setCreateDept(station.getRefDept());
run.setCreateUser(station.getCreateUser());
run.setUpdateUser(station.getUpdateUser());
run.setStationCode(station.getCode());
run.setStationName(station.getName());
Calendar calendar = Calendar.getInstance();
calendar.setTime(org.springblade.core.tool.utils.DateUtil.parse("2024-05-01 00:00:00", org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.DAY_OF_MONTH,-1);
run.setMonth(DateUtil.format(calendar.getTime(),"yyyy-MM"));
List<RideDeviceVo> stationDevices = devices.stream().filter(device->device.getDepartment().equals(station.getRefDept())).collect(Collectors.toList());
// 运行数据
run.setRunData(this.runData(station.getCode(),stationDevices,plans));
// 告警数据
run.setAlarmData(this.alarmData(station.getCode()));
// 月度运行曲线
run.setCurveData(this.curveData(stationDevices));
// TODO 运行数据分析
// TODO 运行建议及其他
// TODO 保存生成月报数据
// runMonService.save(run);
return true;
}
/**
* 运行数据
* @param devices
* @return
*/
private String runData(String stationCode,List<RideDeviceVo> devices,List<PlanGenerationEntity> plans) {
List<RunDataVo> runs = new ArrayList<>();
devices.forEach(device->{
RunDataVo run = new RunDataVo();
run.setDeviceCode(device.getNumber());
run.setDeviceName(device.getName());
// 运行时长
run.setRunHours(this.runHours(device));
// 月发电量
Double day = this.generates(0,device.getNumber(),device.getRide());
if(ObjectUtil.isEmpty(day)){
run.setGenerate(0.0);
}else{
run.setGenerate(day/10000);
}
// 年发电量
Double year = this.generates(1,device.getNumber(),device.getRide());
if(ObjectUtil.isEmpty(day)){
run.setGenerateYear(0.0);
}else{
run.setGenerateYear(year/10000);
}
// 计划发电量
run.setPlan(this.planGenerate(0,stationCode,plans)/10000);
// 年计划发电量
run.setPlanYear(this.planGenerate(1,stationCode,plans)/10000);
runs.add(run);
});
return JSONObject.toJSONString(runs);
}
/**
* 实际发电量
* @param type
* @param deviceCode
* @param ride
* @return
*/
private Double generates(int type,String deviceCode,double ride) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
String end = null,start = null;
int cycleType = 5;
switch (type){
case 0 :
calendar.add(Calendar.DAY_OF_MONTH,-1);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
break;
case 1 :
cycleType = 6;
end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-calendar.get(Calendar.MONTH));
calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH));
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
calendar.add(Calendar.DAY_OF_MONTH,1);
start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
break;
}
return Double.valueOf(dataService.periodTargetFloat(start,end,5,cycleType,deviceCode,ride,HomePageConstant.HYDROPOWER_GENERATE_POWER));
}
/**
* 计划发电量
* @param type
* @param stationCode
* @param plans
* @return
*/
private Double planGenerate(int type, String stationCode,List<PlanGenerationEntity> plans) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
if(type == 0){
calendar.add(Calendar.DAY_OF_MONTH,-1);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY) + 1);
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String time = DateUtil.format(calendar.getTime(),"yyyy-MM");
return plans.stream().filter(plan -> plan.getStationId().equals(stationCode) && plan.getDateTime().contains(time))
.mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
}
String time = DateUtil.format(calendar.getTime(),"yyyy");
return plans.stream().filter(plan -> plan.getStationId().equals(stationCode) && plan.getDateTime().contains(time))
.mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
}
/**
* 获取运行数据
* @param device
* @return
*/
private Double runHours(EmInfoEntity device) {
MultiAnalyzeCodePO analyze = new MultiAnalyzeCodePO();
analyze.setDeviceCode(device.getNumber());
analyze.setSignages(Collections.singletonList(HomePageConstant.ACTIVE_POWER));
List<AnalyzeCodeBySignagesVO> signages = dataService.analyzeCodeBySignages(Collections.singletonList(analyze));
if(CollectionUtil.isEmpty(signages)){
return 0.0;
}
// 监测点
String realId = signages.get(0).getRealId();
if(StringUtils.isEmpty(realId)){
return 0.0;
}
// 确定查询时间范围: 年、月
Date startDate,endDate;
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
endDate = calendar.getTime();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
startDate = calendar.getTime();
return this.getRunConvertData(realId,startDate,endDate);
}
/**
* 获取时间范围内运行时长
* @param realId
* @param startDate
* @param endDate
* @return
*/
private Double getRunConvertData(String realId, Date startDate, Date endDate) {
OriginalDataQuery originalDataQuery = new OriginalDataQuery();
originalDataQuery.setRealId(realId);
originalDataQuery.setBeginTime(startDate);
originalDataQuery.setEndTime(endDate);
originalDataQuery.setLimit(100000);
originalDataQuery.setPage(1);
// 查询时间范围开关机监测点历史数据
Result<HzPage<PointData>> result = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){
return 0.0;
}
// 开机运行时长
long time = this.getRunTime(result.getData().getRecords(),startDate,endDate);
return BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
/**
* 获取运行时长
* @param result
* @return
*/
private long getRunTime(List<PointData> result,Date startDate,Date endDate) {
if(result.size() == 1){
// 一直开机
if(Double.parseDouble(result.get(0).getValue()) > 0){
return endDate.getTime() - startDate.getTime();
}
// 一直关机
return 0;
}
long time=0;
// 遍历累计开机时长
for(int i = 0; i< result.size() ; i++){
// 记录为开机状态 就计算到下次关机的时间差
if(Double.parseDouble(result.get(i).getValue()) <= 0){
continue;
}
Date endTime,startTime = DateUtil.parse(result.get(i).getTime(), DateUtil.PATTERN_DATETIME);
// 遍历至最后一条数据,累计至当前时间
if(i == result.size() - 1){
endTime = endDate;
}else {
endTime = DateUtil.parse(result.get(i+1).getTime(), DateUtil.PATTERN_DATETIME);
}
time += endTime.getTime() - startTime.getTime();
}
return time;
}
/**
* 告警数据
* @param code
* @return
*/
private String alarmData(String code) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1);
calendar.add(Calendar.DAY_OF_MONTH,1);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
// HZ3000:故障告警
List<RunAlarmVo> alarms = this.hz3000Alarm(code,start,end);
// FIXME 设备实例:一级告警
// FDP智能预警
alarms.addAll(this.intelligentEarly(code,start,end));
return JSONObject.toJSONString(alarms);
}
/**
* 查询hz3000告警
* @param code
*/
private List<RunAlarmVo> hz3000Alarm(String code,String start,String end) {
SoeQueryConditionByStation query = new SoeQueryConditionByStation();
query.setStationIds(Collections.singletonList(code));
query.setTypes(Collections.singletonList(AlarmHandleConstant.FAULT));
query.setBeginTime(LocalDateTime.parse(start,DateUtil.DATETIME_FORMATTER));
query.setEndTime(LocalDateTime.parse(end,DateUtil.DATETIME_FORMATTER));
query.setNeedPage(false);
Result<HzPage<SoeData>> result = soeClient.getByStationsAndTime(query);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){
return new ArrayList<>();
}
return result.getData().getRecords().stream().collect(Collectors.groupingBy(SoeData::getSoeExplain)).entrySet().stream().map(entry->{
RunAlarmVo alarm = new RunAlarmVo();
alarm.setAlarmTime(DateUtil.format(entry.getValue().stream().sorted(Comparator.comparing(SoeData::getTs)).collect(Collectors.toList()).get(0).getTs(),DateUtil.PATTERN_DATETIME));
alarm.setDeviceName(entry.getValue().get(0).getDeviceName());
alarm.setContent(entry.getKey());
alarm.setType(String.valueOf(AlarmConstants.FAULT));
alarm.setTypeName("故障");
alarm.setCount(Math.max(entry.getValue().stream().filter(o->StringUtil.isNotBlank(o.getTraceCount())).mapToInt(soe->Integer.parseInt(soe.getTraceCount())).sum(), 1));
return alarm;
}).collect(Collectors.toList());
}
/**
* 智能预警
* @param code
* @param start
* @param end
* @return
*/
private List<RunAlarmVo> intelligentEarly(String code, String start, String end) {
StbAnalysisDTO param = new StbAnalysisDTO();
param.setStartTime(LocalDateTime.parse(start,DateUtil.DATETIME_FORMATTER));
param.setEndTime(LocalDateTime.parse(end, DateUtil.DATETIME_FORMATTER));
param.setStations(Collections.singletonList(code));
param.setNeedPage(false);
Result<HzPage<StbAnalysisVO>> result = soeDataClient.pageStbAnalysis(param);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){
return new ArrayList<>();
}
return result.getData().getRecords().stream().collect(Collectors.groupingBy(StbAnalysisVO::getName)).entrySet().stream().map(entry->{
RunAlarmVo alarm = new RunAlarmVo();
alarm.setAlarmTime(entry.getValue().stream().sorted(Comparator.comparing(StbAnalysisVO::getTs)).collect(Collectors.toList()).get(0).getTs());
alarm.setDeviceName(entry.getValue().get(0).getOrd());
alarm.setContent(entry.getKey());
alarm.setType(String.valueOf(AlarmConstants.EARLY));
alarm.setTypeName("智能预警");
alarm.setReason(entry.getValue().get(0).getFinfo());
alarm.setMemo(entry.getValue().get(0).getInfo());
alarm.setCount(entry.getValue().size());
return alarm;
}).collect(Collectors.toList());
}
/**
* 运行曲线
* @param devices
* @return
*/
private String curveData(List<RideDeviceVo> devices) {
List<CurveEchartVo> curveDatas = devices.stream().map(device -> {
CurveEchartVo curveData = new CurveEchartVo();
curveData.setDeviceCode(device.getNumber());
curveData.setDeviceName(device.getName());
// 负荷曲线
curveData.setLoadCurve(this.curve(this.attribute(0), device.getNumber()));
// 轴承温度曲线
curveData.setBearingTempCurve(this.curve(this.attribute(1), device.getNumber()));
// 定子温度曲线
curveData.setStatorTempCurve(this.curve(this.attribute(2), device.getNumber()));
return curveData;
}).collect(Collectors.toList());
return JSONObject.toJSONString(curveDatas);
}
/**
* 获取曲线数据
* @param attributes
* @param deviceCode
* @return
*
*
*/
private List<EchartVo> curve(List<AttributeVo> attributes, String deviceCode) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.setTime(DateUtil.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
List<AnalyzeDataConditionVO> datas = dataService.periodTargetSignages(start,end,3,3,deviceCode,attributes.stream().map(AttributeVo::getSignage).collect(Collectors.toList()));
if(CollectionUtil.isEmpty(datas)){
return new ArrayList<>();
}
List<AnalyseDataTaosVO> analyseDatas = new ArrayList<>();
Calendar day = Calendar.getInstance();
datas.forEach(data->{
if(CollectionUtil.isEmpty(data.getList())){
return;
}
analyseDatas.addAll(data.getList().stream().peek(item->{
item.setSignage(data.getSignage());
Date date = DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s");
day.setTime(date);
item.setTs(String.valueOf(day.get(Calendar.DAY_OF_MONTH)));
}).collect(Collectors.toList()));
});
if(CollectionUtil.isEmpty(analyseDatas)){
return new ArrayList<>();
}
Map<String,List<AnalyseDataTaosVO>> map = analyseDatas.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs));
return map.entrySet().stream().map(entry->{
EchartVo echart = new EchartVo();
echart.setTime(Integer.valueOf(entry.getKey()));
echart.setValues(entry.getValue().stream().map(value->{
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())){
echartValue.setValue(0.0);
}else{
echartValue.setValue(Double.parseDouble(value.getVal()));
}
return echartValue;
}).collect(Collectors.toList()));
return echart;
}).sorted(Comparator.comparing(EchartVo::getTime)).collect(Collectors.toList());
}
/**
* 曲线属性获取
* @param attributeType
* @return
*/
private List<AttributeVo> attribute(int attributeType) {
List<AttributeVo> attributes = new ArrayList<>();
switch (attributeType){
case 0:
AttributeVo attribute = new AttributeVo();
attribute.setSignage(HomePageConstant.ACTIVE_POWER);
attribute.setSignageName("负荷");
attributes.add(attribute);
break;
case 1:
AttributeVo upper_temp = new AttributeVo();
upper_temp.setSignage(HomePageConstant.UPPER_GUIDE_BEARING_TEMP);
upper_temp.setSignageName("上导轴承瓦温1");
attributes.add(upper_temp);
AttributeVo oil_tem = new AttributeVo();
oil_tem.setSignage(HomePageConstant.UPPER_GUIDE_BEARING_OIL_GROOVE_TEMP);
oil_tem.setSignageName("上导轴承油槽温度");
attributes.add(oil_tem);
AttributeVo thrust_tem = new AttributeVo();
thrust_tem.setSignage(HomePageConstant.THRUST_BEARING_TEMP);
thrust_tem.setSignageName("推力轴瓦温度1");
attributes.add(thrust_tem);
AttributeVo lower_tem = new AttributeVo();
lower_tem.setSignage(HomePageConstant.LOWER_GUIDE_BEARING_TEMP);
lower_tem.setSignageName("下导轴承瓦温1");
attributes.add(lower_tem);
AttributeVo tank_tem = new AttributeVo();
tank_tem.setSignage(HomePageConstant.LOWER_GUIDE_OIL_TANK_TEMP);
tank_tem.setSignageName("下导油槽温度");
attributes.add(tank_tem);
AttributeVo tile_tem = new AttributeVo();
tile_tem.setSignage(HomePageConstant.WATER_GUIDE_TILE_TEMP);
tile_tem.setSignageName("水导瓦温");
attributes.add(tile_tem);
AttributeVo water_tem = new AttributeVo();
water_tem.setSignage(HomePageConstant.WATER_GUIDE_OIL_TANK_TEMP);
water_tem.setSignageName("水导油槽温度");
attributes.add(water_tem);
break;
case 2:
AttributeVo A_tem = new AttributeVo();
A_tem.setSignage(HomePageConstant.A_PHASE_IRON_CORE_TEMP);
A_tem.setSignageName("A相铁芯温度1");
attributes.add(A_tem);
AttributeVo B_tem = new AttributeVo();
B_tem.setSignage(HomePageConstant.B_PHASE_IRON_CORE_TEMP);
B_tem.setSignageName("B相铁芯温度1");
attributes.add(B_tem);
AttributeVo C_tem = new AttributeVo();
C_tem.setSignage(HomePageConstant.C_PHASE_IRON_CORE_TEMP);
C_tem.setSignageName("C相铁芯温度1");
attributes.add(C_tem);
break;
}
return attributes;
}
/**
* 检查站点是否存在设备信息
* @param stationCode
* @return
*/
@Override
public Boolean check(String stationCode) {
// 查询站点
StationVO station = stationService.getStationByCode(stationCode);
if(ObjectUtil.isEmpty(station)){
throw new ServiceException("未查询到站点信息!");
}
// 查询设备
R<List<EmInfoEntity>> emInfos = deivceClient.getEmInfoByDept(Collections.singletonList(station.getRefDept()));
if(!emInfos.isSuccess() || CollectionUtil.isEmpty(emInfos.getData())){
throw new ServiceException("站点未配置机组设备信息、请先为站点添加设备,绑定设备实例,再进行月报查询!");
}
List<EmInfoEntity> devices = emInfos.getData().stream().filter(o->"2".equals(o.getEmType())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(devices)){
throw new ServiceException("站点未配置机组设备信息、请先为站点添加设备,绑定设备实例,再进行月报查询!");
}
return true;
}
/**
* 手绘运行数据表格 * 手绘运行数据表格
* @return * @return
*/ */
@ -280,16 +803,14 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
*/ */
private List<CurveYArrayVo> curveToArray(List<EchartVo> curves) { private List<CurveYArrayVo> curveToArray(List<EchartVo> curves) {
List<CurveAttrValueVo> attrValues = new ArrayList<>(); List<CurveAttrValueVo> attrValues = new ArrayList<>();
curves.forEach(curve->{ curves.forEach(curve-> attrValues.addAll(curve.getValues().stream().map(value->{
attrValues.addAll(curve.getValues().stream().map(value->{
CurveAttrValueVo attrValue = new CurveAttrValueVo(); CurveAttrValueVo attrValue = new CurveAttrValueVo();
attrValue.setAttribute(value.getAttribute()); attrValue.setAttribute(value.getAttribute());
attrValue.setAttributeName(value.getAttributeName()); attrValue.setAttributeName(value.getAttributeName());
attrValue.setTime(curve.getTime()); attrValue.setTime(curve.getTime());
attrValue.setValue(value.getValue()); attrValue.setValue(value.getValue());
return attrValue; return attrValue;
}).collect(Collectors.toList())); }).collect(Collectors.toList())));
});
return attrValues.stream().collect(Collectors.groupingBy(CurveAttrValueVo::getAttribute)).entrySet().stream().map(entry->{ return attrValues.stream().collect(Collectors.groupingBy(CurveAttrValueVo::getAttribute)).entrySet().stream().map(entry->{
CurveYArrayVo yArray = new CurveYArrayVo(); CurveYArrayVo yArray = new CurveYArrayVo();
yArray.setAttribute(entry.getKey()); yArray.setAttribute(entry.getKey());

Loading…
Cancel
Save