Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
ty 7 months ago
parent
commit
0ecef80497
  1. 6
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/EminfoAndEmParamVo.java
  2. 17
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/ConverElectricityVo.java
  3. 20
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/LoadWaterLevelVo.java
  4. 22
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/PowerConvertVo.java
  5. 19
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/StationNumberVo.java
  6. 20
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/WeatherRainVo.java
  7. 26
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/WeatherWaterVo.java
  8. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/entity/UserDeptEntity.java
  9. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppHydropowerStationVo.java
  10. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java
  11. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java
  12. 96
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  13. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/WindService.java
  14. 37
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  15. 3
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java
  16. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java
  17. 13
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java
  18. 15
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java
  19. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketServiceImpl.java
  20. 92
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java
  21. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml
  22. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java
  23. 20
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml
  24. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java
  25. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java
  26. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java
  27. 56
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java
  28. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java
  29. 34
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java
  30. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java
  31. 398
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java
  32. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/scheduled/DutyMainCreateTask.java
  33. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyChangeServiceImpl.java
  34. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupServiceImpl.java
  35. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecQRRecordServiceImpl.java
  36. 159
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java
  37. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HomeService.java
  38. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java
  39. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java
  40. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/ISideHustleService.java
  41. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWaterService.java
  42. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java
  43. 39
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java
  44. 402
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java
  45. 473
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  46. 38
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java
  47. 609
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java
  48. 660
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java
  49. 791
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java
  50. 20
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java
  51. 169
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java
  52. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceInspectionServiceImpl.java

6
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/EminfoAndEmParamVo.java

@ -16,15 +16,15 @@ public class EminfoAndEmParamVo extends EmInfoExtendVo {
@ApiModelProperty(value = "ct") @ApiModelProperty(value = "ct")
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private Integer ct; private Double ct;
@ApiModelProperty(value = "pt") @ApiModelProperty(value = "pt")
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private Integer pt; private Double pt;
@ApiModelProperty(value = "ct * pt") @ApiModelProperty(value = "ct * pt")
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private int rideCount; private Double rideCount;
@ApiModelProperty(value = "经度") @ApiModelProperty(value = "经度")
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)

17
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/ConverElectricityVo.java

@ -0,0 +1,17 @@
package com.hnac.hzims.operational.data.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
public class ConverElectricityVo {
@ApiModelProperty("时间")
private String time;
@ApiModelProperty("电量")
private Double electricity;
}

20
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/LoadWaterLevelVo.java

@ -0,0 +1,20 @@
package com.hnac.hzims.operational.data.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
public class LoadWaterLevelVo {
@ApiModelProperty("时间")
private String time;
@ApiModelProperty("水位")
private Double water;
@ApiModelProperty("功率")
private Double load;
}

22
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/PowerConvertVo.java

@ -0,0 +1,22 @@
package com.hnac.hzims.operational.data.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
public class PowerConvertVo {
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("功率/水位")
private List<LoadWaterLevelVo> loadWaters;
@ApiModelProperty("发电量")
private List<ConverElectricityVo> electricitys;
}

19
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/StationNumberVo.java

@ -0,0 +1,19 @@
package com.hnac.hzims.operational.data.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel(value = "水利站点首页对象")
public class StationNumberVo {
@ApiModelProperty(value = "站点类型")
private Integer type;
@ApiModelProperty(value = "站点数量")
private Integer count;
}

20
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/WeatherRainVo.java

@ -0,0 +1,20 @@
package com.hnac.hzims.operational.data.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
public class WeatherRainVo {
@ApiModelProperty("时间")
private String time;
@ApiModelProperty("水位")
private Double water;
@ApiModelProperty("降雨量")
private Double rain;
}

26
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/data/vo/WeatherWaterVo.java

@ -0,0 +1,26 @@
package com.hnac.hzims.operational.data.vo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
public class WeatherWaterVo {
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("限制水位")
private Double limitWater;
@ApiModelProperty("天气")
private List<Daily> dailys;
@ApiModelProperty("发电量")
private List<WeatherRainVo> weatherRains;
}

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/entity/UserDeptEntity.java

@ -28,6 +28,4 @@ public class UserDeptEntity extends TenantEntity implements Serializable {
@ApiModelProperty("机构Id") @ApiModelProperty("机构Id")
private Long deptId; private Long deptId;
} }

4
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AppHydropowerStationVo.java

@ -2,7 +2,6 @@ package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer; import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData; import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -48,6 +47,9 @@ public class AppHydropowerStationVo {
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private Double output; private Double output;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "运行天数") @ApiModelProperty(value = "运行天数")
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private Integer runDay; private Integer runDay;

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java

@ -54,6 +54,9 @@ public class HydropowerStationVo {
@ApiModelProperty(value = "月发电量") @ApiModelProperty(value = "月发电量")
private Float powerMon; private Float powerMon;
@ApiModelProperty(value = "月发电量完成率")
private Double powerRateMon;
@ApiModelProperty(value = "年发电量") @ApiModelProperty(value = "年发电量")
private Float powerYear; private Float powerYear;
@ -72,6 +75,9 @@ public class HydropowerStationVo {
@ApiModelProperty(value = "年发电量完成百分比") @ApiModelProperty(value = "年发电量完成百分比")
private List<PowerMonthVo> powerYearMap; private List<PowerMonthVo> powerYearMap;
@ApiModelProperty(value = "24小时机组有功功率")
private List<ActivePowerVo> activePowerVoList;
@ApiModelProperty(value = "设备信息") @ApiModelProperty(value = "设备信息")
private List<HydropowerUnitVo> deviceList; private List<HydropowerUnitVo> deviceList;
} }

3
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java

@ -1,8 +1,6 @@
package com.hnac.hzims.safeproduct.entity; package com.hnac.hzims.safeproduct.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -21,7 +19,6 @@ public class SpecialDeviceInspectionEntity extends BaseEntity {
@ApiModelProperty("设备id") @ApiModelProperty("设备id")
private Long deviceId; private Long deviceId;
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("检验时间") @ApiModelProperty("检验时间")
private Date inspectionTime; private Date inspectionTime;

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

@ -179,10 +179,8 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
em_info.getAttach().setEmId(infoId); em_info.getAttach().setEmId(infoId);
attachService.save(em_info.getAttach()); attachService.save(em_info.getAttach());
} }
if (em_info.getParams() != null && em_info.getParams().size() > 0) { if (em_info.getParams() != null && !em_info.getParams().isEmpty()) {
em_info.getParams().forEach(param -> { em_info.getParams().forEach(param -> param.setInfoId(infoId));
param.setInfoId(infoId);
});
paramService.saveBatch(em_info.getParams()); paramService.saveBatch(em_info.getParams());
} }
if (em_info.getIsModel().equals(EquipmentContants.isModelEnum.yes.getValue())) { if (em_info.getIsModel().equals(EquipmentContants.isModelEnum.yes.getValue())) {
@ -277,8 +275,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
if (listR.isSuccess() && CollectionUtil.isNotEmpty(listR.getData())) { if (listR.isSuccess() && CollectionUtil.isNotEmpty(listR.getData())) {
List<StationEntity> data = listR.getData(); List<StationEntity> data = listR.getData();
Map<String, List<EmInfoExtendVo>> stationKeyMap = new HashMap<>(); Map<String, List<EmInfoExtendVo>> stationKeyMap = new HashMap<>();
for (int i = 0; i < data.size(); i++) { for (StationEntity stationEntity : data) {
StationEntity stationEntity = data.get(i);
List<EmInfoExtendVo> collect = list.stream().filter(o -> o.getCreateDept().toString(). List<EmInfoExtendVo> collect = list.stream().filter(o -> o.getCreateDept().toString().
equals(stationEntity.getRefDept().toString())).collect(Collectors.toList()); equals(stationEntity.getRefDept().toString())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(collect)) { if (CollectionUtil.isNotEmpty(collect)) {
@ -293,10 +290,9 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
public Map<String, List<EmInfoExtendVo>> redisStationCode() { public Map<String, List<EmInfoExtendVo>> redisStationCode() {
Object json = redisTemplate.opsForValue().get(deviceCodePath); Object json = redisTemplate.opsForValue().get(deviceCodePath);
if (ObjectUtil.isNotEmpty(json)) { if (ObjectUtil.isNotEmpty(json)) {
LinkedHashMap<String, List<EmInfoExtendVo>> stringListLinkedHashMap = JSONObject.parseObject(json.toString(), return JSONObject.parseObject(json.toString(),
new TypeReference<LinkedHashMap<String, List<EmInfoExtendVo>>>() { new TypeReference<LinkedHashMap<String, List<EmInfoExtendVo>>>() {
}); });
return stringListLinkedHashMap;
} }
return null; return null;
} }
@ -305,10 +301,9 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
public List<EmInfoExtendVo> redisCode() { public List<EmInfoExtendVo> redisCode() {
Object json = redisTemplate.opsForValue().get(em_info_list_path); Object json = redisTemplate.opsForValue().get(em_info_list_path);
if (ObjectUtil.isNotEmpty(json)) { if (ObjectUtil.isNotEmpty(json)) {
List<EmInfoExtendVo> emInfoExtendVos = JSONObject.parseObject(json.toString(), return JSONObject.parseObject(json.toString(),
new TypeReference<List<EmInfoExtendVo>>() { new TypeReference<List<EmInfoExtendVo>>() {
}); });
return emInfoExtendVos;
} }
return null; return null;
} }
@ -340,7 +335,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
} }
public List<EmTreeNode> createGroupAndStationTrees(List<EmInfoEntity> resultList, List<EmTreeNode> rootNodes) { public List<EmTreeNode> createGroupAndStationTrees(List<EmInfoEntity> resultList, List<EmTreeNode> rootNodes) {
if (rootNodes == null || rootNodes.size() < 1) { if (rootNodes == null || rootNodes.isEmpty()) {
return null; return null;
} }
//遍历根节点 //遍历根节点
@ -353,7 +348,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
//找到子节点 //找到子节点
List<EmTreeNode> childNodes = listGroupNodeByPids(resultList, rootNode.getId() + "", rootNode.getLevel()); List<EmTreeNode> childNodes = listGroupNodeByPids(resultList, rootNode.getId() + "", rootNode.getLevel());
//如果没有数据了,就跳出循环 //如果没有数据了,就跳出循环
if (childNodes == null || childNodes.size() == 0) { if (childNodes == null || childNodes.isEmpty()) {
continue; continue;
} }
//遍历子节点 //遍历子节点
@ -384,7 +379,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
QueryWrapper<EmModelEntity> modelQw = new QueryWrapper<>(); QueryWrapper<EmModelEntity> modelQw = new QueryWrapper<>();
modelQw.lambda().eq(EmModelEntity::getModelName, modelName); modelQw.lambda().eq(EmModelEntity::getModelName, modelName);
List<EmModelEntity> modelList = modelService.list(modelQw); List<EmModelEntity> modelList = modelService.list(modelQw);
if (modelList.size() > 0) { if (!modelList.isEmpty()) {
return R.fail("母版名已存在"); return R.fail("母版名已存在");
} else { } else {
modelEntity.setType(type + ""); modelEntity.setType(type + "");
@ -420,16 +415,11 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
*/ */
@Override @Override
public void updateBachEmState(List<String> boot, List<String> shutdown) { public void updateBachEmState(List<String> boot, List<String> shutdown) {
boolean refresh = false;
if(CollectionUtil.isNotEmpty(boot)){ if(CollectionUtil.isNotEmpty(boot)){
this.baseMapper.updateBachEmState(boot,1); this.baseMapper.updateBachEmState(boot,1);
refresh = true;
} }
if(CollectionUtil.isNotEmpty(shutdown)){ if(CollectionUtil.isNotEmpty(shutdown)){
this.baseMapper.updateBachEmState(shutdown,2); this.baseMapper.updateBachEmState(shutdown,2);
refresh = true;
}
if(!refresh){
} }
} }
@ -669,13 +659,12 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
.eq(EmInfoEntity::getGpid, Optional.ofNullable(emInfo).map(EmInfoEntity::getId).orElse(0L)) .eq(EmInfoEntity::getGpid, Optional.ofNullable(emInfo).map(EmInfoEntity::getId).orElse(0L))
.eq(EmInfoEntity::getDepartment,deptId); .eq(EmInfoEntity::getDepartment,deptId);
List<EmInfoEntity> emInfoList = this.list(queryWrapper); List<EmInfoEntity> emInfoList = this.list(queryWrapper);
List<JSONObject> result = emInfoList.stream().map(emInfoEntity -> { return emInfoList.stream().map(emInfoEntity -> {
JSONObject object = JSONObject.parseObject(JSON.toJSONString(emInfoEntity)); JSONObject object = JSONObject.parseObject(JSON.toJSONString(emInfoEntity));
object.put("disabled", !emCodes.contains(emInfoEntity.getNumber())); object.put("disabled", !emCodes.contains(emInfoEntity.getNumber()));
object.put("children",this.getEmInfoTree(deptId,emInfoEntity.getNumber(),emCodes)); object.put("children", this.getEmInfoTree(deptId,emInfoEntity.getNumber(),emCodes));
return object; return object;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return result;
} }
/** /**
@ -708,7 +697,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
}); });
// 设备遍历 // 设备遍历
devices.forEach(item->{ devices.forEach(item->{
item.setRideCount(1); item.setRideCount(1.0);
item.setInstalledCapacity(0.0); item.setInstalledCapacity(0.0);
List<AnalyzeCodeBySignagesVO> signages = analys.stream().filter(o-> item.getEmCode().equals(o.getDeviceCode()) && !StringUtil.isEmpty(o.getSignage()) && !StringUtil.isEmpty(o.getRealId())).collect(Collectors.toList()); List<AnalyzeCodeBySignagesVO> signages = analys.stream().filter(o-> item.getEmCode().equals(o.getDeviceCode()) && !StringUtil.isEmpty(o.getSignage()) && !StringUtil.isEmpty(o.getRealId())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(signages)){ if(CollectionUtil.isNotEmpty(signages)){
@ -723,10 +712,10 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
String param_name = param.getParamName(); String param_name = param.getParamName();
switch (param_name){ switch (param_name){
case "ct": case "ct":
item.setCt(Integer.valueOf(param.getParamValue())); item.setCt(Double.valueOf(param.getParamValue()));
break; break;
case "pt": case "pt":
item.setPt(Integer.valueOf(param.getParamValue())); item.setPt(Double.valueOf(param.getParamValue()));
break; break;
case "installedCapacity": case "installedCapacity":
item.setInstalledCapacity(Double.valueOf(param.getParamValue())); item.setInstalledCapacity(Double.valueOf(param.getParamValue()));
@ -782,71 +771,14 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
throw new ServiceException("该设备编码在设备实例中找到对应记录,保存失败!"); throw new ServiceException("该设备编码在设备实例中找到对应记录,保存失败!");
}); });
} }
// 验证设备编号是否已存在
// EmInfoEntity emInfoEntity = this.baseMapper.selectEmInfoByCode(em_info.getInfo().getNumber());
// Assert.isTrue(ObjectUtil.isEmpty(emInfoEntity),() -> {
// throw new ServiceException("设备编号已存在");
// });
}
private List<EmTreeEntity> getFatherAndSonDevice(EmInfoEntity emInfo, List<Long> treeIds){
List<EmTreeEntity> fatherAndSonList = new ArrayList<>();
List<String> parentSignages = new ArrayList<>();
List<EmTreeEntity> emTreeList = emTreeService.listByIds(treeIds);
for (EmTreeEntity emTree : emTreeList) {
LambdaQueryWrapper<EmTreeEntity> emTreeWrapper = new LambdaQueryWrapper();
emTreeWrapper.eq(EmTreeEntity::getDefinitionId, emTree.getDefinitionId());
emTreeWrapper.likeRight(EmTreeEntity::getPath, emTree.getPath());
if (Func.isNotEmpty(emInfo)) {
// 有设备信息说明是导入子设备,防止本级设备二次导入
emTreeWrapper.ne(EmTreeEntity::getId, emInfo.getTreeId());
}
// 获取所有子设备
List<EmTreeEntity> list = emTreeService.list(emTreeWrapper);
if (Func.isNotEmpty(list)) {
fatherAndSonList.addAll(list);
}
int index = 0;
if (Func.isNotEmpty(emInfo)) {
EmTreeEntity parentEmTree = emTreeService.getById(emInfo.getTreeId());
// 导入子设备根目录从父设备后面开始
index = emTree.getPath().indexOf(parentEmTree.getSignage()) + parentEmTree.getSignage().length();
}
// 通过path获取所有父设备标识,不包括自己
String parentPath = emTree.getPath().substring(index, emTree.getPath().lastIndexOf("/"));
if (parentPath.length() > 0) {
parentSignages.addAll(Arrays.asList(parentPath.split("/")));
}
} }
if (Func.isNotEmpty(parentSignages)) {
LambdaQueryWrapper<EmTreeEntity> parentWrapper = new LambdaQueryWrapper();
parentWrapper.eq(EmTreeEntity::getDefinitionId, emTreeList.get(0).getDefinitionId());
parentWrapper.in(EmTreeEntity::getSignage, parentSignages);
// 通过标识获取父设备
List<EmTreeEntity> parentList = emTreeService.list(parentWrapper);
fatherAndSonList.addAll(parentList);
}
// 把List结构数据转换成树结构
Map<Long, List<EmTreeEntity>> fatherAndSonMap = fatherAndSonList.stream().collect(Collectors.groupingBy(EmTreeEntity::getPid));
fatherAndSonList.forEach(emTree -> {
emTree.setChildren(fatherAndSonMap.get(emTree.getId()));
});
List<EmTreeEntity> resultList = fatherAndSonList.stream().filter(item -> item.getPid() == 0).collect(Collectors.toList());
return resultList;
}
@Override @Override
public List<EmInfoEntity> getVideoDeviceByEmCode(EmInfoEntity emInfo){ public List<EmInfoEntity> getVideoDeviceByEmCode(EmInfoEntity emInfo){
LambdaQueryWrapper<EmInfoEntity> emTreeWrapper = new LambdaQueryWrapper(); LambdaQueryWrapper<EmInfoEntity> emTreeWrapper = new LambdaQueryWrapper();
emTreeWrapper.eq(EmInfoEntity::getEmType, emInfo.getEmType()); emTreeWrapper.eq(EmInfoEntity::getEmType, emInfo.getEmType());
emTreeWrapper.eq(EmInfoEntity::getIsDeleted, "0"); emTreeWrapper.eq(EmInfoEntity::getIsDeleted, "0");
List<EmInfoEntity> emInfoEntities = baseMapper.selectList(emTreeWrapper); return baseMapper.selectList(emTreeWrapper);
return emInfoEntities;
} }
private void copyDeviceTree(StationEntity station, Long pid, Long definitionId, String modelSignage, List<EmTreeIdsDTO> treeIds) { private void copyDeviceTree(StationEntity station, Long pid, Long definitionId, String modelSignage, List<EmTreeIdsDTO> treeIds) {

1
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/WindService.java

@ -10,6 +10,7 @@ import java.util.List;
* @author ysj * @author ysj
*/ */
public interface WindService extends BaseService<WindEntity> { public interface WindService extends BaseService<WindEntity> {
List<PowerMonthVo> generateThreeYear(String start, String end, Long station); List<PowerMonthVo> generateThreeYear(String start, String end, Long station);
} }

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

@ -143,7 +143,7 @@ public class RealTargetServiceImpl implements RealTargetService {
}); });
// 设备遍历 // 设备遍历
devices.forEach(item->{ devices.forEach(item->{
item.setRideCount(1); item.setRideCount(1.0);
item.setInstalledCapacity(0.0); item.setInstalledCapacity(0.0);
// 站点设置 // 站点设置
if(CollectionUtil.isNotEmpty(stations)){ if(CollectionUtil.isNotEmpty(stations)){
@ -166,10 +166,10 @@ public class RealTargetServiceImpl implements RealTargetService {
String param_name = paramEntity.getParamName(); String param_name = paramEntity.getParamName();
switch (param_name){ switch (param_name){
case "ct": case "ct":
item.setCt(Integer.valueOf(paramEntity.getParamValue())); item.setCt(Double.parseDouble(paramEntity.getParamValue()));
break; break;
case "pt": case "pt":
item.setPt(Integer.valueOf(paramEntity.getParamValue())); item.setPt(Double.valueOf(paramEntity.getParamValue()));
break; break;
case "installedCapacity": case "installedCapacity":
item.setInstalledCapacity(Double.valueOf(paramEntity.getParamValue())); item.setInstalledCapacity(Double.valueOf(paramEntity.getParamValue()));
@ -867,7 +867,11 @@ public class RealTargetServiceImpl implements RealTargetService {
PowerMonthVo generate = new PowerMonthVo(); PowerMonthVo generate = new PowerMonthVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrMonth(DateUtil.format(time, DateUtil.PATTERN_DATE)); generate.setStrMonth(DateUtil.format(time, DateUtil.PATTERN_DATE));
generate.setPower(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); if(StringUtil.isEmpty(record.getVal())){
generate.setPower(0f);
}else{
generate.setPower(Float.parseFloat(String.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount())));
}
return generate; return generate;
}).collect(Collectors.toMap(PowerMonthVo::getStrMonth,PowerMonthVo::getPower)); }).collect(Collectors.toMap(PowerMonthVo::getStrMonth,PowerMonthVo::getPower));
} }
@ -1138,7 +1142,7 @@ public class RealTargetServiceImpl implements RealTargetService {
private List<HzimsAnalyzeModelStationEntity> getModelStationList() { private List<HzimsAnalyzeModelStationEntity> getModelStationList() {
// 水利站点(All) // 水利站点(All)
List<StationEntity> stations = stationService.list(new LambdaQueryWrapper<StationEntity>() {{ List<StationEntity> stations = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
eq(StationEntity::getDataOrigin, HomePageConstant.DATA_ORIGIN); eq(StationEntity::getDataOrigin, "0");
}}); }});
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>(); return new ArrayList<>();
@ -1329,7 +1333,11 @@ public class RealTargetServiceImpl implements RealTargetService {
PowerMonthVo generate = new PowerMonthVo(); PowerMonthVo generate = new PowerMonthVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE));
generate.setPower(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); if(StringUtil.isEmpty(record.getVal())){
generate.setPower(0f);
}else{
generate.setPower(Float.parseFloat(String.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount())));
}
return generate; return generate;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
}); });
@ -1507,7 +1515,7 @@ public class RealTargetServiceImpl implements RealTargetService {
* @param type * @param type
* @return * @return
*/ */
private float sumValueByTime(String deviceCode, int rideCount, String type) { private float sumValueByTime(String deviceCode, Double rideCount, String type) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
String start, end; String start, end;
int cycleType = 3; int cycleType = 3;
@ -1784,8 +1792,13 @@ public class RealTargetServiceImpl implements RealTargetService {
* @return * @return
*/ */
private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) { private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) {
String start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; Calendar calendar = Calendar.getInstance();
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.DAY_OF_MONTH,-29);
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<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); List<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
if(CollectionUtil.isEmpty(records)){ if(CollectionUtil.isEmpty(records)){
return new ArrayList<>(); return new ArrayList<>();
@ -1794,7 +1807,11 @@ public class RealTargetServiceImpl implements RealTargetService {
GenerationPowerVo generate = new GenerationPowerVo(); GenerationPowerVo generate = new GenerationPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE));
generate.setGenerate(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); if(StringUtil.isEmpty(record.getVal())){
generate.setGenerate(0f);
}else{
generate.setGenerate(Float.parseFloat(String.valueOf(Double.parseDouble(record.getVal()) * device.getRideCount())));
}
return generate; return generate;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }

3
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java

@ -34,6 +34,7 @@ import com.hnac.hzims.scheduled.service.operation.plate.DataService;
import com.hnac.hzims.scheduled.service.operation.station.StationService; import com.hnac.hzims.scheduled.service.operation.station.StationService;
import com.hnac.hzims.scheduled.service.ticket.TicketService; import com.hnac.hzims.scheduled.service.ticket.TicketService;
import com.hnac.hzims.scheduled.service.ticket.WorkTicketService; import com.hnac.hzims.scheduled.service.ticket.WorkTicketService;
import com.hnac.hzims.ticket.allTicket.dto.TicketStatisticDTO;
import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO;
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO;
@ -79,8 +80,8 @@ public class ShowServiceImpl implements ShowService {
private final TaskService taskService; private final TaskService taskService;
private final OverService overService; private final OverService overService;
private final PlanService planService; private final PlanService planService;
private final PowerService powerService;
private final WindService windService; private final WindService windService;
private final PowerService powerService;
private final SolveService solveService; private final SolveService solveService;
private final OtherService otherService; private final OtherService otherService;
private final AccessService accessService; private final AccessService accessService;

4
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java

@ -26,7 +26,5 @@ public interface DataService {
List<AnalyzeDataConditionVO> periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List<String> signages); List<AnalyzeDataConditionVO> periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List<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);
void multipleTargetData(String startTime, String endTime);
} }

13
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java

@ -163,7 +163,7 @@ public class DataServiceImpl implements DataService {
* @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();
@ -199,14 +199,9 @@ public class DataServiceImpl implements DataService {
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; if(StringUtil.isEmpty(analyseDataTaosVO.getVal())){
return 0f;
} }
return Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO.getVal()) * ride));
@Override
public void multipleTargetData(String startTime, String endTime) {
HisDataDeviceDTO his = new HisDataDeviceDTO();
deviceDataClient.getHisDataByMultipleDeviceCode(his);
} }
} }

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

@ -243,8 +243,6 @@ public class ReportServiceImpl implements ReportService {
* @return * @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<Long, Map<String, Float>> powerMap, List<StationEntity> stationList, String mon) {
LocalDateTime startTime = LocalDateTime.parse(mon + "-01 00:00:00", DateUtil.DATETIME_FORMATTER);
LocalDateTime endTime = getEndTime(mon);
// 查询所有站点的计划发电量 // 查询所有站点的计划发电量
List<PlanGenerationEntity> planList = this.planPower(stationList, mon); List<PlanGenerationEntity> planList = this.planPower(stationList, mon);
// 站点实际发电量 // 站点实际发电量
@ -287,17 +285,6 @@ public class ReportServiceImpl implements ReportService {
} }
/** /**
* 获取结束时间
*/
private LocalDateTime getEndTime(String mon) {
Date date = DateUtil.parse(mon + "-01 00:00:00",DateUtil.DATETIME_FORMAT);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, 1);
return calendar.getTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}
/**
* 获取站点计划发电量 * 获取站点计划发电量
*/ */
private List<PlanGenerationEntity> planPower(List<StationEntity> stationList, String mon) { private List<PlanGenerationEntity> planPower(List<StationEntity> stationList, String mon) {
@ -697,7 +684,7 @@ public class ReportServiceImpl implements ReportService {
* @param ride * @param ride
* @return * @return
*/ */
private Double generate(int type,String deviceCode,int ride) { private Double generate(int type,String deviceCode,double ride) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.setTime(new Date()); //calendar.setTime(new Date());

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketServiceImpl.java

@ -139,7 +139,7 @@ public class TicketServiceImpl extends BaseServiceImpl<TicketMapper, StandardTic
eq(TicketInfoEvaluateEntity::getStatus, TicketConstants.TicketQualifiedEnum.Qualified.getCode()); eq(TicketInfoEvaluateEntity::getStatus, TicketConstants.TicketQualifiedEnum.Qualified.getCode());
}}); }});
if (CollectionUtil.isEmpty(operateQualifyList)) { if (CollectionUtil.isEmpty(operateQualifyList)) {
ticket.setOperateQualify(0); ticket.setWorkQualify(0);
}else{ }else{
ticket.setWorkQualify(operateQualifyList.size()); ticket.setWorkQualify(operateQualifyList.size());
} }

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

@ -132,8 +132,6 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
@Value(value = "${hzims.inspect.offline.upload.path}") @Value(value = "${hzims.inspect.offline.upload.path}")
public String upload_path; public String upload_path;
public List<String> fileList;
/** /**
* 下载离线文件 * 下载离线文件
*/ */
@ -326,7 +324,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param download * @param download
*/ */
private void tableDateMethod(Long taskId,List<String> tableNames, String download) { private void tableDateMethod(Long taskId,List<String> tableNames, String download) {
fileList = new ArrayList<>(); List<String> fileList = new ArrayList<>();
// 获取用户信息 // 获取用户信息
BladeUser user = AuthUtil.getUser(); BladeUser user = AuthUtil.getUser();
if(ObjectUtil.isEmpty(user)){ if(ObjectUtil.isEmpty(user)){
@ -345,48 +343,48 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
} }
List<Long> taskIds = taskUsers.stream().map(TaskUserEntity::getTaskId).collect(Collectors.toList()); List<Long> taskIds = taskUsers.stream().map(TaskUserEntity::getTaskId).collect(Collectors.toList());
// 巡检任务 // 巡检任务
List<TaskOfflineVO> tasks = this.taskData(taskIds,currentDate); List<TaskOfflineVO> tasks = this.taskData(taskIds,currentDate,fileList);
if(CollectionUtil.isEmpty(tasks)){ if(CollectionUtil.isEmpty(tasks)){
throw new ServiceException("巡检任务数据不存在!"); throw new ServiceException("巡检任务数据不存在!");
} }
// 巡检任务用户 // 巡检任务用户
List<TaskUserEntity> users = this.taskUserData(tasks.stream().map(TaskOfflineVO::getId).collect(Collectors.toList())); List<TaskUserEntity> users = this.taskUserData(tasks.stream().map(TaskOfflineVO::getId).collect(Collectors.toList()),fileList);
fileJson.add(JsonUtil.toJson(users)); fileJson.add(JsonUtil.toJson(users));
fileJson.add(JsonUtil.toJson(tasks)); fileJson.add(JsonUtil.toJson(tasks));
taskIds = tasks.stream().map(BaseEntity::getId).collect(Collectors.toList()); taskIds = tasks.stream().map(BaseEntity::getId).collect(Collectors.toList());
// 巡检计划 // 巡检计划
List<PlanOfflineVO> plans = this.getPlans(tasks.stream().map(TaskOfflineVO::getPlanId).collect(Collectors.toList())); List<PlanOfflineVO> plans = this.getPlans(tasks.stream().map(TaskOfflineVO::getPlanId).collect(Collectors.toList()),fileList);
fileJson.add(JsonUtil.toJson(plans)); fileJson.add(JsonUtil.toJson(plans));
// 巡检事件 // 巡检事件
List<EventEntity> events = this.eventData(taskIds); List<EventEntity> events = this.eventData(taskIds,fileList);
fileJson.add(JsonUtil.toJson(events)); fileJson.add(JsonUtil.toJson(events));
List<Long> eventIds = events.stream().map(EventEntity::getId).collect(Collectors.toList()); List<Long> eventIds = events.stream().map(EventEntity::getId).collect(Collectors.toList());
// 巡检情况事件附件 // 巡检情况事件附件
List<EventAttachmentEntity> eventAttachments = this.attachmentData(eventIds); List<EventAttachmentEntity> eventAttachments = this.attachmentData(eventIds,fileList);
fileJson.add(JsonUtil.toJson(eventAttachments)); fileJson.add(JsonUtil.toJson(eventAttachments));
// 巡检情况 // 巡检情况
List<EventRecordEntity> eventRecords = this.eventRecordData(eventIds); List<EventRecordEntity> eventRecords = this.eventRecordData(eventIds,fileList);
fileJson.add(JsonUtil.toJson(eventRecords)); fileJson.add(JsonUtil.toJson(eventRecords));
// 巡检任务对象 // 巡检任务对象
List<TaskObjectOfflineVO> taskObjects = this.exObjectData(taskIds); List<TaskObjectOfflineVO> taskObjects = this.exObjectData(taskIds,fileList);
fileJson.add(JsonUtil.toJson(taskObjects)); fileJson.add(JsonUtil.toJson(taskObjects));
// 巡检任务项目 // 巡检任务项目
List<TaskObjectProjectOfflineVO> taskObjectProjects = this.objectProjectData(taskIds); List<TaskObjectProjectOfflineVO> taskObjectProjects = this.objectProjectData(taskIds,fileList);
fileJson.add(JsonUtil.toJson(taskObjectProjects)); fileJson.add(JsonUtil.toJson(taskObjectProjects));
// 巡检任务内容 // 巡检任务内容
List<TaskObjectProjectContentEntity> taskContents = this.objectProjectContentData(taskIds); List<TaskObjectProjectContentEntity> taskContents = this.objectProjectContentData(taskIds,fileList);
fileJson.add(JsonUtil.toJson(taskContents)); fileJson.add(JsonUtil.toJson(taskContents));
// 巡检对象 // 巡检对象
List<ObjectOfflineVO> objects = this.reDbjectData(user.getTenantId()); List<ObjectOfflineVO> objects = this.reDbjectData(user.getTenantId(),fileList);
fileJson.add(JsonUtil.toJson(objects)); fileJson.add(JsonUtil.toJson(objects));
// 巡检项目 // 巡检项目
List<ProjectOfflineVO> projects = this.projectData(user.getTenantId()); List<ProjectOfflineVO> projects = this.projectData(user.getTenantId(),fileList);
fileJson.add(JsonUtil.toJson(projects)); fileJson.add(JsonUtil.toJson(projects));
// 巡检内容 // 巡检内容
List<ContentEntity> contents = this.contentData(user.getTenantId()); List<ContentEntity> contents = this.contentData(user.getTenantId(),fileList);
fileJson.add(JsonUtil.toJson(contents)); fileJson.add(JsonUtil.toJson(contents));
// 危险点 // 危险点
List<ObjectDangerEntity> dangers = this.dangerData(user.getTenantId()); List<ObjectDangerEntity> dangers = this.dangerData(user.getTenantId(),fileList);
fileJson.add(JsonUtil.toJson(dangers)); fileJson.add(JsonUtil.toJson(dangers));
// 危险源数据 // 危险源数据
List<SourceVO> sources = dangerSourceClient.listByTenantId(user.getTenantId()); List<SourceVO> sources = dangerSourceClient.listByTenantId(user.getTenantId());
@ -398,9 +396,9 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
List<FaultVO> faults = faultClient.listByTenantId(user.getTenantId()); List<FaultVO> faults = faultClient.listByTenantId(user.getTenantId());
fileJson.add(JsonUtil.toJson(faults)); fileJson.add(JsonUtil.toJson(faults));
// 离线任务任务 // 离线任务任务
List<OfflineTaskEntity> offlines = this.tasksData(taskId); List<OfflineTaskEntity> offlines = this.tasksData(taskId,fileList);
fileJson.add(JsonUtil.toJson(offlines)); fileJson.add(JsonUtil.toJson(offlines));
if(fileJson.size() <= 0){ if(fileJson.isEmpty()){
return; return;
} }
// 文件写入 // 文件写入
@ -421,7 +419,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param tenantId * @param tenantId
* @return * @return
*/ */
private List<ContentEntity> contentData(String tenantId) { private List<ContentEntity> contentData(String tenantId,List<String> fileList) {
if(StringUtil.isBlank(tenantId)){ if(StringUtil.isBlank(tenantId)){
return new ArrayList<>(); return new ArrayList<>();
} }
@ -430,7 +428,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
eq(ContentEntity::getTenantId, tenantId); eq(ContentEntity::getTenantId, tenantId);
}}); }});
// 返回数据 // 返回数据
return contents.stream().map(item -> this.convertFileOrVideo(item)).collect(Collectors.toList()); return contents.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
@ -438,7 +436,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param tenantId * @param tenantId
* @return * @return
*/ */
private List<ObjectDangerEntity> dangerData(String tenantId) { private List<ObjectDangerEntity> dangerData(String tenantId,List<String> fileList) {
if(StringUtil.isBlank(tenantId)){ if(StringUtil.isBlank(tenantId)){
return new ArrayList<>(); return new ArrayList<>();
} }
@ -447,7 +445,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
eq(ObjectDangerEntity::getTenantId, tenantId); eq(ObjectDangerEntity::getTenantId, tenantId);
}}); }});
// 返回数据 // 返回数据
return dangers.stream().map(item -> this.convertFileOrVideo(item)).collect(Collectors.toList()); return dangers.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
@ -457,7 +455,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param taskId * @param taskId
* @return * @return
*/ */
private List<OfflineTaskEntity> tasksData(Long taskId) { private List<OfflineTaskEntity> tasksData(Long taskId,List<String> fileList) {
if(ObjectUtil.isEmpty(taskId)){ if(ObjectUtil.isEmpty(taskId)){
return new ArrayList<>(); return new ArrayList<>();
} }
@ -466,7 +464,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
eq(OfflineTaskEntity::getId, taskId); eq(OfflineTaskEntity::getId, taskId);
}}); }});
// 返回数据 // 返回数据
return tasks.stream().map(item -> this.convertFileOrVideo(item)).collect(Collectors.toList()); return tasks.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
@ -474,7 +472,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* 巡检任务用户表数据 * 巡检任务用户表数据
* @return * @return
*/ */
private List<TaskUserEntity> taskUserData(List<Long> taskIds) { private List<TaskUserEntity> taskUserData(List<Long> taskIds,List<String> fileList) {
if(CollectionUtil.isEmpty(taskIds)){ if(CollectionUtil.isEmpty(taskIds)){
return new ArrayList<>(); return new ArrayList<>();
} }
@ -482,21 +480,21 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
List<TaskUserEntity> taskUsers = this.taskUserService.getOfflineTaskUser(taskIds); List<TaskUserEntity> taskUsers = this.taskUserService.getOfflineTaskUser(taskIds);
// 返回数据 // 返回数据
return taskUsers.stream().map(item -> this.convertFileOrVideo(item)).collect(Collectors.toList()); return taskUsers.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
* 巡检任务 * 巡检任务
* @return * @return
*/ */
private List<TaskOfflineVO> taskData(List<Long> taskId,String currentDate) { private List<TaskOfflineVO> taskData(List<Long> taskId,String currentDate,List<String> fileList) {
if(CollectionUtil.isEmpty(taskId)){ if(CollectionUtil.isEmpty(taskId)){
return new ArrayList<>(); return new ArrayList<>();
} }
// 查询巡检任务 // 查询巡检任务
List<TaskOfflineVO> tasks = taskService.getTaskData(taskId,currentDate); List<TaskOfflineVO> tasks = taskService.getTaskData(taskId,currentDate);
// 返回数据 // 返回数据
return tasks.stream().map(item -> this.convertFileOrVideo(item)).collect(Collectors.toList()); return tasks.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
@ -504,13 +502,13 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param planIds * @param planIds
* @return * @return
*/ */
private List<PlanOfflineVO> getPlans(List<Long> planIds) { private List<PlanOfflineVO> getPlans(List<Long> planIds,List<String> fileList) {
if(CollectionUtil.isEmpty(planIds)){ if(CollectionUtil.isEmpty(planIds)){
return new ArrayList<>(); return new ArrayList<>();
} }
List<PlanOfflineVO> tasks = planService.getPlans(planIds); List<PlanOfflineVO> tasks = planService.getPlans(planIds);
// 返回数据 // 返回数据
return tasks.stream().map(item -> this.convertFileOrVideo(item)).collect(Collectors.toList()); return tasks.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
@ -519,7 +517,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param taskIds * @param taskIds
* @return * @return
*/ */
private List<EventEntity> eventData(List<Long> taskIds) { private List<EventEntity> eventData(List<Long> taskIds,List<String> fileList) {
if(CollectionUtil.isEmpty(taskIds)){ if(CollectionUtil.isEmpty(taskIds)){
return new ArrayList<>(); return new ArrayList<>();
} }
@ -527,7 +525,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
List<EventEntity> events = eventService.list(new LambdaQueryWrapper<EventEntity>() {{ List<EventEntity> events = eventService.list(new LambdaQueryWrapper<EventEntity>() {{
in(EventEntity::getTaskId, taskIds); in(EventEntity::getTaskId, taskIds);
}}); }});
return events.stream().map(item -> this.convertFileOrVideo(item)).collect(Collectors.toList()); return events.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
@ -535,7 +533,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param eventIds * @param eventIds
* @return * @return
*/ */
private List<EventAttachmentEntity> attachmentData(List<Long> eventIds) { private List<EventAttachmentEntity> attachmentData(List<Long> eventIds,List<String> fileList) {
if(CollectionUtil.isEmpty(eventIds)){ if(CollectionUtil.isEmpty(eventIds)){
return new ArrayList<>(); return new ArrayList<>();
} }
@ -543,7 +541,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
List<EventAttachmentEntity> eventAttachments = eventAttachmentService.list(new LambdaQueryWrapper<EventAttachmentEntity>() {{ List<EventAttachmentEntity> eventAttachments = eventAttachmentService.list(new LambdaQueryWrapper<EventAttachmentEntity>() {{
in(EventAttachmentEntity::getEventId, eventIds); in(EventAttachmentEntity::getEventId, eventIds);
}}); }});
return eventAttachments.stream().map(item -> this.convertFileOrVideo(item)).collect(Collectors.toList()); return eventAttachments.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
@ -551,7 +549,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param eventIds * @param eventIds
* @return * @return
*/ */
private List<EventRecordEntity> eventRecordData(List<Long> eventIds) { private List<EventRecordEntity> eventRecordData(List<Long> eventIds,List<String> fileList) {
if(CollectionUtil.isEmpty(eventIds)){ if(CollectionUtil.isEmpty(eventIds)){
return new ArrayList<>(); return new ArrayList<>();
} }
@ -559,7 +557,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
in(EventRecordEntity::getEventId, eventIds); in(EventRecordEntity::getEventId, eventIds);
}}); }});
// 返回数据 // 返回数据
return eventRecords.stream().map(item -> this.convertFileOrVideo(item)).collect(Collectors.toList()); return eventRecords.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
@ -567,14 +565,14 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param taskIds * @param taskIds
* @return * @return
*/ */
private List<TaskObjectOfflineVO> exObjectData(List<Long> taskIds) { private List<TaskObjectOfflineVO> exObjectData(List<Long> taskIds,List<String> fileList) {
if(CollectionUtil.isEmpty(taskIds)){ if(CollectionUtil.isEmpty(taskIds)){
return new ArrayList<>(); return new ArrayList<>();
} }
// 查询巡检任务对象 // 查询巡检任务对象
List<TaskObjectOfflineVO> taskObjects = taskObjectService.getExObjectData(taskIds); List<TaskObjectOfflineVO> taskObjects = taskObjectService.getExObjectData(taskIds);
// 返回数据 // 返回数据
return taskObjects.stream().map(item -> this.convertFileOrVideo(item)).collect(Collectors.toList()); return taskObjects.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
@ -582,14 +580,14 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param taskIds * @param taskIds
* @return * @return
*/ */
private List<TaskObjectProjectOfflineVO> objectProjectData(List<Long> taskIds) { private List<TaskObjectProjectOfflineVO> objectProjectData(List<Long> taskIds,List<String> fileList) {
if(CollectionUtil.isEmpty(taskIds)){ if(CollectionUtil.isEmpty(taskIds)){
return new ArrayList<>(); return new ArrayList<>();
} }
// 查询巡检任务项目 // 查询巡检任务项目
List<TaskObjectProjectOfflineVO> taskObjectProjects = taskObjectProjectService.getObjectProjectData(taskIds); List<TaskObjectProjectOfflineVO> taskObjectProjects = taskObjectProjectService.getObjectProjectData(taskIds);
// 返回数据 // 返回数据
return taskObjectProjects.stream().map(this::convertFileOrVideo).collect(Collectors.toList()); return taskObjectProjects.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
@ -597,7 +595,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param taskIds * @param taskIds
* @return * @return
*/ */
private List<TaskObjectProjectContentEntity> objectProjectContentData(List<Long> taskIds) { private List<TaskObjectProjectContentEntity> objectProjectContentData(List<Long> taskIds,List<String> fileList) {
if(CollectionUtil.isEmpty(taskIds)){ if(CollectionUtil.isEmpty(taskIds)){
return new ArrayList<>(); return new ArrayList<>();
} }
@ -607,7 +605,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
in(TaskObjectProjectContentEntity::getTaskId, taskIds); in(TaskObjectProjectContentEntity::getTaskId, taskIds);
}}); }});
// 返回数据 // 返回数据
return contents.stream().map(this::convertFileOrVideo).collect(Collectors.toList()); return contents.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
@ -615,14 +613,14 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param tenantId * @param tenantId
* @return * @return
*/ */
private List<ObjectOfflineVO> reDbjectData(String tenantId) { private List<ObjectOfflineVO> reDbjectData(String tenantId,List<String> fileList) {
if(StringUtil.isBlank(tenantId)){ if(StringUtil.isBlank(tenantId)){
return new ArrayList<>(); return new ArrayList<>();
} }
// 查询巡检对象 // 查询巡检对象
List<ObjectOfflineVO> objects = objectService.getReDbjectData(tenantId); List<ObjectOfflineVO> objects = objectService.getReDbjectData(tenantId);
// 返回数据 // 返回数据
return objects.stream().map(this::convertFileOrVideo).collect(Collectors.toList()); return objects.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
@ -630,20 +628,20 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
* @param tenantId * @param tenantId
* @return * @return
*/ */
private List<ProjectOfflineVO> projectData(String tenantId) { private List<ProjectOfflineVO> projectData(String tenantId,List<String> fileList) {
if(StringUtil.isBlank(tenantId)){ if(StringUtil.isBlank(tenantId)){
return new ArrayList<>(); return new ArrayList<>();
} }
// 查询巡检项目 // 查询巡检项目
List<ProjectOfflineVO> projects = projectService.getProjectData(tenantId); List<ProjectOfflineVO> projects = projectService.getProjectData(tenantId);
// 返回数据 // 返回数据
return projects.stream().map(this::convertFileOrVideo).collect(Collectors.toList()); return projects.stream().map(o->this.convertFileOrVideo(o,fileList)).collect(Collectors.toList());
} }
/** /**
* 通过反射处理视频图片等 * 通过反射处理视频图片等
*/ */
private <T> T convertFileOrVideo(T entity) { private <T> T convertFileOrVideo(T entity,List<String> fileList) {
try { try {
if (entity == null) { if (entity == null) {
return entity; return entity;

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml

@ -31,7 +31,7 @@
</collection> </collection>
</resultMap> </resultMap>
<select id="selectPageList" resultMap="BaseResultMap"> <select id="selectPageList" resultMap="BaseResultMap">
SELECT OT.`NAME` AS taskName, OT.PLAN_HOURS, OT.EM_NAME, OS.* FROM hzims_oper_access_statistics OS SELECT OT.`NAME` AS taskName, OT.PLAN_HOURS AS planHours, OT.EM_NAME as emName, OS.* FROM hzims_oper_access_statistics OS
JOIN hzims_oper_access_task OT JOIN hzims_oper_access_task OT
ON OS.`TASK_ID` = OT.`ID` ON OS.`TASK_ID` = OT.`ID`
WHERE OS.IS_DELETED = 0 WHERE OS.IS_DELETED = 0

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java

@ -37,9 +37,6 @@ public interface OperAccessTaskMapper extends UserDataScopeBaseMapper<OperAccess
@SqlParser(filter = true) @SqlParser(filter = true)
List<AccessReportVO> getAccessTaskByDisposer(Map<String,Object> params); List<AccessReportVO> getAccessTaskByDisposer(Map<String,Object> params);
@SqlParser(filter = true)
List<Map<String,Object>> getAccessConclusion(Map<String,Object> params);
List<OperAccessTaskEntity> selectAccessTask(@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("list")List<Long> list); List<OperAccessTaskEntity> selectAccessTask(@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("list")List<Long> list);
List<RepairBillVO> getRepairBill(@Param("deviceCodes") List<String> deviceCodes,@Param("startTime") String startTime, @Param("endTime") String endTime); List<RepairBillVO> getRepairBill(@Param("deviceCodes") List<String> deviceCodes,@Param("startTime") String startTime, @Param("endTime") String endTime);

20
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml

@ -181,26 +181,6 @@
group by hoat.`HANDLER` group by hoat.`HANDLER`
</select> </select>
<select id="getAccessConclusion" resultType="java.util.Map">
select count(hoat.`id`) ACCESS_TASK_COUNT
,count(case when hoat.`status` = 1 then 1 else null end) ACCESS_COMPLETE
from `hzims_oper_access_task` hoat
left join (select `EM_CODE`,count(`ID`) findProblemCount from `hzims_oper_phenomenon` where `IS_DELETED` = 0
group by `EM_CODE`) hop on hoat.`EM_CODE` = hop.`EM_CODE`
<where>
hoat.`IS_DELETED` =0
<if test="startDate != null">
and DATE_FORMAT(hoat.`PLAN_START_TIME`,'%Y-%m-%d') &gt;= #{startDate}
</if>
<if test="endDate != null">
and DATE_FORMAT(hoat.`PLAN_START_TIME`,'%Y-%m-%d') &lt;= #{endDate}
</if>
and hoat.`CREATE_DEPT` in
<foreach collection="deptId" item="item" open="(" close=")" index="index" separator=",">
#{item}
</foreach>
</where>
</select>
<select id="selectAccessTask" resultType="com.hnac.hzims.operational.access.entity.OperAccessTaskEntity"> <select id="selectAccessTask" resultType="com.hnac.hzims.operational.access.entity.OperAccessTaskEntity">
select * from hzims_oper_access_task where `IS_DELETED` = 0 select * from hzims_oper_access_task where `IS_DELETED` = 0
<if test="startTime != null"> <if test="startTime != null">

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

@ -37,8 +37,6 @@ public interface IOperAccessTaskService extends BaseService<OperAccessTaskEntity
R<IPage<OperAccessTaskVO>> list(OperAccessTaskDTO req, Query query); R<IPage<OperAccessTaskVO>> list(OperAccessTaskDTO req, Query query);
R<IPage<OperAccessTaskVO>> listByStatus(OperAccessTaskDTO req, Query query); R<IPage<OperAccessTaskVO>> listByStatus(OperAccessTaskDTO req, Query query);
List<OperAccessTaskEntity> getByEmCode(String emCode,List<String> list);
/** /**
* 获取站点统计月报-检修 * 获取站点统计月报-检修
* @param startDate 开始时间 * @param startDate 开始时间
@ -48,10 +46,9 @@ public interface IOperAccessTaskService extends BaseService<OperAccessTaskEntity
*/ */
List<AccessReportVO> getAccessTaskByDisposer(LocalDate startDate, LocalDate endDate, List<Long> deptIdList); List<AccessReportVO> getAccessTaskByDisposer(LocalDate startDate, LocalDate endDate, List<Long> deptIdList);
List<AccessReportVO> getAccessTaskByDisposer(Map<String,Object> params);
List<AccessRunReportVO> getAccessTaskByName(Map<String,Object> params); List<AccessRunReportVO> getAccessTaskByName(Map<String,Object> params);
List<Map<String,Object>> getAccessConclusion(Map<String,Object> params);
List<OperAccessTaskEntity> getAccessTask(String startTime,String endTime,List<Long> list); List<OperAccessTaskEntity> getAccessTask(String startTime,String endTime,List<Long> list);

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java

@ -125,7 +125,6 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service {
*/ */
private void save(AccessTaskV4DTO entity) { private void save(AccessTaskV4DTO entity) {
entity.setCode("TASK" + DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("###").format(RandomUtils.nextInt(0, 999))); entity.setCode("TASK" + DateUtil.format(DateUtil.now(), DateUtil.PATTERN_DATETIME_MINI) + new DecimalFormat("###").format(RandomUtils.nextInt(0, 999)));
List<OperAccessMaterialEntity> materialEntityList = JSONObject.parseArray(JSON.toJSONString(entity.getAccessMaterials()), OperAccessMaterialEntity.class);
if (ObjectUtil.isNotEmpty(entity.getHandler())){ if (ObjectUtil.isNotEmpty(entity.getHandler())){
User user = UserCache.getUser(entity.getHandler()); User user = UserCache.getUser(entity.getHandler());
if (ObjectUtil.isNotEmpty(user)&& StringUtils.isNotEmpty(user.getRealName())){ if (ObjectUtil.isNotEmpty(user)&& StringUtils.isNotEmpty(user.getRealName())){
@ -274,6 +273,7 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service {
statisticsDTO.setId(null); statisticsDTO.setId(null);
statisticsDTO.setTaskId(entity.getId()); statisticsDTO.setTaskId(entity.getId());
statisticsDTO.setEmCode(entity.getEmCode()); statisticsDTO.setEmCode(entity.getEmCode());
statisticsDTO.setEmName(entity.getEmName());
statisticsDTO.setPlanHours(entity.getPlanHours()); statisticsDTO.setPlanHours(entity.getPlanHours());
statisticsDTO.setManager(entity.getHandler()); statisticsDTO.setManager(entity.getHandler());
statisticsDTO.setManagerName(entity.getHandlerName()); statisticsDTO.setManagerName(entity.getHandlerName());

19
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java

@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.message.enums.PushStatEnum;
import com.hnac.hzims.message.fegin.IMessagePushClient; import com.hnac.hzims.message.fegin.IMessagePushClient;
import com.hnac.hzims.message.req.PushExtrasReq; import com.hnac.hzims.message.req.PushExtrasReq;
import com.hnac.hzims.operational.OperationalConstants; import com.hnac.hzims.operational.OperationalConstants;
@ -61,7 +60,6 @@ import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.flow.core.utils.TaskUtil; import org.springblade.flow.core.utils.TaskUtil;
import org.springblade.flow.core.vo.ComleteTask; import org.springblade.flow.core.vo.ComleteTask;
import org.springblade.system.cache.DictCache;
import org.springblade.system.entity.Dept; import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
@ -254,11 +252,6 @@ public class OperAccessTaskServiceImpl extends BaseServiceImpl<OperAccessTaskMap
} }
@Override @Override
public List<OperAccessTaskEntity> getByEmCode(String emCode, List<String> list) {
return this.baseMapper.selectByEmCode(emCode, list);
}
@Override
public List<AccessReportVO> getAccessTaskByDisposer(LocalDate startDate, LocalDate endDate, List<Long> deptIdList) { public List<AccessReportVO> getAccessTaskByDisposer(LocalDate startDate, LocalDate endDate, List<Long> deptIdList) {
List<AccessReportVO> inspectOrAccessReportVOList = new ArrayList<>(); List<AccessReportVO> inspectOrAccessReportVOList = new ArrayList<>();
//获取月份内的检修任务 //获取月份内的检修任务
@ -299,14 +292,6 @@ public class OperAccessTaskServiceImpl extends BaseServiceImpl<OperAccessTaskMap
} }
@Override @Override
public List<AccessReportVO> getAccessTaskByDisposer(Map<String, Object> params) {
LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
List<Long> deptIdList = (List<Long>) params.get("deptId");
return getAccessTaskByDisposer(startDate, endDate, deptIdList);
}
@Override
public List<AccessRunReportVO> getAccessTaskByName(Map<String, Object> params) { public List<AccessRunReportVO> getAccessTaskByName(Map<String, Object> params) {
LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
@ -353,10 +338,6 @@ public class OperAccessTaskServiceImpl extends BaseServiceImpl<OperAccessTaskMap
return res; return res;
} }
@Override
public List<Map<String, Object>> getAccessConclusion(Map<String, Object> params) {
return mapper.getAccessConclusion(params);
}
@Override @Override
public List<OperAccessTaskEntity> getAccessTask(String startTime, String endTime, List<Long> list) { public List<OperAccessTaskEntity> getAccessTask(String startTime, String endTime, List<Long> list) {

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

@ -77,6 +77,8 @@ public class TargetServiceImpl implements TargetService {
private final OverService overService; private final OverService overService;
private final WindService windService;
private final PowerService powerService; private final PowerService powerService;
private final SolveService solveService; private final SolveService solveService;
@ -209,7 +211,7 @@ public class TargetServiceImpl implements TargetService {
double sum = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); double sum = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum();
item.setElectricGeneration(sum); item.setElectricGeneration(sum);
// 发电量详情 // 发电量详情
List<String> details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getPowerYear() +"kWh]").collect(Collectors.toList()); List<String> details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceName()).orElse("填报电量") + " " + target.getPowerYear() +"kWh]").collect(Collectors.toList());
item.setDetail(String.join("|",details)); item.setDetail(String.join("|",details));
return item; return item;
}).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList());
@ -231,26 +233,26 @@ public class TargetServiceImpl implements TargetService {
double sum = targets.stream().filter(target -> target.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum(); double sum = targets.stream().filter(target -> target.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum();
item.setElectricGeneration(sum); item.setElectricGeneration(sum);
// 发电量详情 // 发电量详情
List<String> details = targets.stream().filter(target -> target.getDeptId().equals(station.getRefDept())).map(target -> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getGenerationYear() + "kWh]").collect(Collectors.toList()); List<String> details = targets.stream().filter(target -> target.getDeptId().equals(station.getRefDept())).map(target -> "[" + Optional.ofNullable(target.getDeviceName()).orElse("填报电量") + " " + target.getGenerationYear() + "kWh]").collect(Collectors.toList());
item.setDetail(String.join("|", details)); item.setDetail(String.join("|", details));
return item; return item;
}).filter(generate -> Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); }).filter(generate -> Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList());
}else{ }else{
// 查询填报数据 // 查询填报数据
String mon = DateUtil.format(new Date(),"yyyy"); String mon = DateUtil.format(new Date(),"yyyy");
List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>lambdaQuery() List<WindEntity> powers = windService.list(Wrappers.<WindEntity>lambdaQuery()
.in(PowerEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) .in(WindEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()))
.ge(PowerEntity::getMon, mon + "-01") .ge(WindEntity::getFillDate, mon + "-01")
); );
electrics = stations.stream().map(station -> { electrics = stations.stream().map(station -> {
ElectricGenerationVo item = new ElectricGenerationVo(); ElectricGenerationVo item = new ElectricGenerationVo();
item.setStationName(station.getName()); item.setStationName(station.getName());
// 发电量 // 发电量
List<PowerEntity> stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); List<WindEntity> stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(stationPowers)){ if(CollectionUtils.isEmpty(stationPowers)){
item.setElectricGeneration(0.0); item.setElectricGeneration(0.0);
}else{ }else{
item.setElectricGeneration(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPowerYear()); item.setElectricGeneration(stationPowers.stream().sorted(Comparator.comparing(WindEntity::getFillDate).reversed()).collect(Collectors.toList()).get(0).getPower());
} }
item.setDetail("站点为填报数据,暂无设备装机发电量信息!"); item.setDetail("站点为填报数据,暂无设备装机发电量信息!");
return item; return item;
@ -362,24 +364,32 @@ public class TargetServiceImpl implements TargetService {
return item; return item;
}).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList()); }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList());
}else{ }else{
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy"));
String mon = DateUtil.format(new Date(),"yyyy"); String mon = DateUtil.format(new Date(),"yyyy");
List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>lambdaQuery() List<WindEntity> powers = windService.list(Wrappers.<WindEntity>lambdaQuery()
.in(PowerEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) .in(WindEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()))
.ge(PowerEntity::getMon, mon + "-01") .ge(WindEntity::getFillDate, mon + "-01")
); );
generations = stations.stream().map(station -> { generations = stations.stream().map(station -> {
CompleteGenerationVo item = new CompleteGenerationVo(); CompleteGenerationVo item = new CompleteGenerationVo();
item.setStationName(station.getName()); item.setStationName(station.getName());
if(CollectionUtil.isEmpty(plans)){
item.setPlanGeneration(0.0);
}else{
item.setPlanGeneration(plans.stream().filter(plan->plan.getStationId().equals(station.getCode())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
}
// 发电量 // 发电量
List<PowerEntity> stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); List<WindEntity> stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(stationPowers)){ if(CollectionUtils.isEmpty(stationPowers)){
item.setPlanGeneration(0.0);
item.setRealityGeneration(0.0); item.setRealityGeneration(0.0);
item.setCompleteRate(0.0);
}else{ }else{
item.setPlanGeneration(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPlannedPowerYear()); item.setRealityGeneration(stationPowers.stream().mapToDouble(WindEntity::getPower).sum());
item.setRealityGeneration(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPowerYear()); }
item.setCompleteRate(Double.valueOf(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPowerRateYear())); if(Math.abs(item.getPlanGeneration()) <= 0 || Math.abs(item.getRealityGeneration()) <= 0){
item.setCompleteRate(100.0);
}else{
item.setCompleteRate(BigDecimal.valueOf(item.getRealityGeneration() / item.getPlanGeneration() * 100).setScale(1, RoundingMode.HALF_UP).doubleValue());
} }
return item; return item;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
@ -395,13 +405,6 @@ public class TargetServiceImpl implements TargetService {
*/ */
@Override @Override
public IPage<CompleteTicketVo> completeTicket(IPage<CompleteTicketVo> page,String areaName,Integer type) { public IPage<CompleteTicketVo> completeTicket(IPage<CompleteTicketVo> page,String areaName,Integer type) {
// 光伏/风电双票填报数据
if(HomePageConstant.WIND_POWER.equals(type) || HomePageConstant.PHOTOVOLTAIC.equals(type)){
List<CompleteTicketVo> completes = this.getcompleteFillTicket(areaName,type);
page.setTotal(completes.size());
page.setRecords(completes.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList()));
return page;
}
// 平台业务数据 // 平台业务数据
List<Integer> types; List<Integer> types;
if(HomePageConstant.WATER_CONSERVANCY.equals(type)){ if(HomePageConstant.WATER_CONSERVANCY.equals(type)){
@ -872,7 +875,12 @@ public class TargetServiceImpl implements TargetService {
if(CollectionUtil.isEmpty(reals)){ if(CollectionUtil.isEmpty(reals)){
hydropower.setPower(0.0); hydropower.setPower(0.0);
}else{ }else{
hydropower.setPower(reals.stream().filter(real->real.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum()); hydropower.setPower(reals.stream().filter(real->real.getDeptId().equals(station.getRefDept())).mapToDouble(real->{
if("MW".equalsIgnoreCase(real.getPowerUnit())){
return real.getActivePower() * 1000;
}
return real.getActivePower();
}).sum());
} }
return hydropower; return hydropower;
})/*.filter(hydropower -> Math.abs(hydropower.getPower()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getPower).reversed()).collect(Collectors.toList()); })/*.filter(hydropower -> Math.abs(hydropower.getPower()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getPower).reversed()).collect(Collectors.toList());

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java

@ -1,5 +1,7 @@
package com.hnac.hzims.operational.config.service.impl; package com.hnac.hzims.operational.config.service.impl;
import cn.hutool.core.lang.TypeReference;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -75,10 +77,11 @@ public class CentralMonitorServiceImpl implements CentralMonitorService {
if (CollectionUtil.isEmpty(codeList)) { if (CollectionUtil.isEmpty(codeList)) {
return null; return null;
} }
List<RealStationVo> result = (List<RealStationVo>) redisTemplate.opsForValue().get(moniter_station_key); Object json = redisTemplate.opsForValue().get(moniter_station_key);
if (StringUtil.isEmpty(result)) { if (StringUtil.isEmpty(json)) {
return null; return null;
} }
List<RealStationVo> result = JSONObject.parseObject(json.toString(), new TypeReference<List<RealStationVo>>() {});
return result.stream().filter(o -> codeList.contains(o.getStationCode())).collect(Collectors.toList()); return result.stream().filter(o -> codeList.contains(o.getStationCode())).collect(Collectors.toList());
} }

34
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java

@ -26,9 +26,6 @@ public class HzimsDataController {
private final HzimsDataService service; private final HzimsDataService service;
/**
* 获取区域列表数据
*/
@ApiLog @ApiLog
@GetMapping("/saveArea") @GetMapping("/saveArea")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ -37,22 +34,35 @@ public class HzimsDataController {
return R.data(service.saveArea()); return R.data(service.saveArea());
} }
/**
* 获取区域列表数据
*/
@ApiLog @ApiLog
@GetMapping("/saveStation") @GetMapping("/stationNumber")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 4)
@ApiOperation(value = "获取站点统计数据", notes = "无需传入参数") @ApiOperation(value = "站点数量", notes = "无需传入参数")
public R saveStation() { public R stationNumber() {
return R.data(service.saveStation()); return R.data(service.stationNumber());
} }
@ApiLog @ApiLog
@GetMapping("/station") @GetMapping("/station")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 3)
@ApiOperation(value = "站点数据获取", notes = "传入站点code") @ApiOperation(value = "站点数据获取", notes = "传入站点code")
public R station(@RequestParam("stationCode") String stationCode) { public R station(@RequestParam("stationCode") String stationCode) {
return R.data(service.station(stationCode)); return R.data(service.station(stationCode));
} }
@ApiLog
@GetMapping("/weather")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "站点天气、降雨、水位", notes = "传入站点code")
public R weather(@RequestParam("stationCode") String stationCode) {
return R.data(service.weather(stationCode));
}
@ApiLog
@GetMapping("/power")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "站点功率换算电量", notes = "传入站点code")
public R power(@RequestParam("stationCode") String stationCode) {
return R.data(service.power(stationCode));
}
} }

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java

@ -1,10 +1,14 @@
package com.hnac.hzims.operational.data.service; package com.hnac.hzims.operational.data.service;
import com.hnac.hzims.operational.data.vo.PowerConvertVo;
import com.hnac.hzims.operational.data.vo.StationNumberVo;
import com.hnac.hzims.operational.data.vo.WeatherWaterVo;
import com.hnac.hzims.operational.main.vo.HydropowerStationVo; import com.hnac.hzims.operational.main.vo.HydropowerStationVo;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List;
/** /**
* @author ysj * @author ysj
@ -17,7 +21,11 @@ public interface HzimsDataService {
*/ */
boolean saveArea(); boolean saveArea();
boolean saveStation(); List<StationNumberVo> stationNumber();
HydropowerStationVo station(String stationCode); HydropowerStationVo station(String stationCode);
WeatherWaterVo weather(String stationCode);
PowerConvertVo power(String stationCode);
} }

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

@ -3,17 +3,26 @@ package com.hnac.hzims.operational.data.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; 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.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.feign.IRainfallClient;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.operational.data.service.HzimsDataService; import com.hnac.hzims.operational.data.service.HzimsDataService;
import com.hnac.hzims.operational.data.vo.AreaVo; import com.hnac.hzims.operational.data.vo.AreaVo;
import com.hnac.hzims.operational.data.vo.*;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.AreaService; import com.hnac.hzims.operational.main.service.AreaService;
import com.hnac.hzims.operational.main.service.IAnalyseDataService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.main.service.IWeatherService;
import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity;
import com.hnac.hzims.operational.station.entity.StationEntity; 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.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.HzimsStationCountVo; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
@ -40,6 +49,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -57,10 +67,20 @@ public class HzimsDataServiceImpl implements HzimsDataService {
private final IStationService stationService; private final IStationService stationService;
private final IWeatherService weatherService;
private final IAnalyseDataService dataService;
private final IHzimsAnalyzeModelStationService modelStationService;
private final IMainSystemMonitoringService maintenanceTaskService; private final IMainSystemMonitoringService maintenanceTaskService;
private final ISysClient sysClient; private final ISysClient sysClient;
private final IEmInfoClient deviceClient;
private final IRainfallClient rainfallClient;
private final IPlanGenertionClient planGenertionClient; private final IPlanGenertionClient planGenertionClient;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
@ -70,6 +90,13 @@ public class HzimsDataServiceImpl implements HzimsDataService {
@Value("${hzims.operation.save.station.url}") @Value("${hzims.operation.save.station.url}")
public String STATION_URL; public String STATION_URL;
private final static String charge = "hzims:operation:key:charge";
private final static String conver_power_key = "hzims:operation:conver:power:";
private final static String conver_weather_key = "hzims:operation:conver:weather:";
private final static String recent_year_power_data = "hzims:operation:key:power:data"; private final static String recent_year_power_data = "hzims:operation:key:power:data";
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; private final static String loadwater_level_key = "hzims:operation:loadwater:level:key";
@ -114,17 +141,33 @@ public class HzimsDataServiceImpl implements HzimsDataService {
return this.sendMessage(JSONObject.toJSONBytes(list),AREA_URL); return this.sendMessage(JSONObject.toJSONBytes(list),AREA_URL);
} }
/** /**
* 获取站点统计数据 * 站点数量统计
* @return * @return
*/ */
@Override @Override
public boolean saveStation() { public List<StationNumberVo> stationNumber() {
List<HzimsStationCountVo> list = this.stationService.getStationCount(); List<StationNumberVo> numbers = new ArrayList<>();
if(CollectionUtil.isEmpty(list)){ List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery().
return false; in(StationEntity::getType,Arrays.asList(0,1,5,8))
);
if(!CollectionUtil.isEmpty(stations)){
stations.stream().collect(Collectors.groupingBy(StationEntity::getType)).forEach((key, value) -> {
StationNumberVo number = new StationNumberVo();
number.setType(key);
number.setCount(value.size());
numbers.add(number);
});
}
TargetVo target = (TargetVo) redisTemplate.opsForValue().get(charge);
if(!ObjectUtil.isEmpty(target)){
StationNumberVo number = new StationNumberVo();
number.setType(7);
number.setCount(target.getCharge());
numbers.add(number);
} }
return this.sendMessage(JSONObject.toJSONBytes(list),STATION_URL); return numbers;
} }
@ -213,10 +256,341 @@ public class HzimsDataServiceImpl implements HzimsDataService {
this.handleWaterLeve(station.getCode(),response); this.handleWaterLeve(station.getCode(),response);
// 年发电量完成百分比 // 年发电量完成百分比
response.setPowerYearMap(this.handlePowerFinish(Collections.singletonList(station),map)); response.setPowerYearMap(this.handlePowerFinish(Collections.singletonList(station),map));
// 功率曲线
response.setActivePowerVoList(this.activePowers(station.getRefDept(),targetList));
return response; return response;
} }
/** /**
* 24小时功率曲线
* @param refDept
* @param targetList
* @return
*/
private List<ActivePowerVo> activePowers(Long refDept, List<HydropowerUnitTargetVo> targetList) {
if(CollectionUtil.isEmpty(targetList)){
return new ArrayList<>();
}
List<ActivePowerVo> actives = new ArrayList<>();
targetList.stream().filter(o-> CollectionUtil.isNotEmpty(o.getActivePowerVoList()) && ObjectUtil.isNotEmpty(o.getDeptId()) && o.getDeptId().equals(refDept)).map(HydropowerUnitTargetVo::getActivePowerVoList).collect(Collectors.toList()).forEach(actives::addAll);
if(CollectionUtil.isEmpty(actives)){
return new ArrayList<>();
}
Map<Integer,List<ActivePowerVo>> maps = actives.stream().collect(Collectors.groupingBy(ActivePowerVo::getHour));
return maps.entrySet().stream().map(entry->{
ActivePowerVo activePower = new ActivePowerVo();
activePower.setHour(entry.getKey());
activePower.setActivePower(String.valueOf(entry.getValue().stream().mapToDouble(o->Double.parseDouble(o.getActivePower())).sum()));
return activePower;
}).sorted(Comparator.comparing(ActivePowerVo::getHour)).collect(Collectors.toList());
}
/**
* 站点天气降雨水位
* @param stationCode
* @return
*/
@Override
public WeatherWaterVo weather(String stationCode) {
WeatherWaterVo redisCache = (WeatherWaterVo) redisTemplate.opsForValue().get(conver_weather_key + stationCode);
if(!ObjectUtil.isEmpty(redisCache)){
return redisCache;
}
WeatherWaterVo weatherWater = new WeatherWaterVo();
// 查询站点
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery().
eq(StationEntity::getCode,stationCode)
);
if(ObjectUtil.isEmpty(station)){
return new WeatherWaterVo();
}
weatherWater.setLimitWater(station.getLimitWaterLevel());
weatherWater.setStationName(station.getName());
// 七天天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(Collections.singletonList(station.getCode()));
if(!MapUtils.isEmpty(weekWeather)){
HeWeatherWeatherDailyResponse week = weekWeather.get(stationCode);
if(!ObjectUtil.isEmpty(week)){
weatherWater.setDailys(week.getDaily());
}
}
// 水位、降雨
weatherWater.setWeatherRains(this.waterRain(stationCode));
redisTemplate.opsForValue().set(conver_weather_key + stationCode,weatherWater);
redisTemplate.expire(conver_weather_key + stationCode,30, TimeUnit.MINUTES);
return weatherWater;
}
/**
* 站点功率换算电量
* @param stationCode
* @return
*/
@Override
public PowerConvertVo power(String stationCode) {
PowerConvertVo redisCache = (PowerConvertVo) redisTemplate.opsForValue().get(conver_power_key + stationCode);
if(!ObjectUtil.isEmpty(redisCache)){
return redisCache;
}
// 查询站点
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery().
eq(StationEntity::getCode,stationCode)
);
if(ObjectUtil.isEmpty(station)){
return new PowerConvertVo();
}
PowerConvertVo convert = new PowerConvertVo();
convert.setStationName(station.getName());
// 查询近30天发电量
convert.setElectricitys(this.poweyBy30Day(station.getRefDept()));
// 查询24小时水位、功率
convert.setLoadWaters(this.loadWaterBy24Hour(station.getRefDept(),station.getCode()));
redisTemplate.opsForValue().set(conver_power_key + stationCode,convert);
redisTemplate.expire(conver_power_key + stationCode,30, TimeUnit.MINUTES);
return convert;
}
/**
* 获取七天天气
* @param codes
*/
private Map<String, HeWeatherWeatherDailyResponse> getWeekWeather(List codes) {
if(CollectionUtil.isEmpty(codes)){
return null;
}
// 实时天气
return this.weatherService.getWeekWeather(codes);
}
/**
* 30天水位降雨量
* @param stationCode
* @return
*/
private List<WeatherRainVo> waterRain(String stationCode) {
Calendar calendar = Calendar.getInstance();
String endTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
String rainEnd = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
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,-29);
String startTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
String rainStart = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
// 查询水位数据
List<AnalyseDataTaosVO> waters = this.water(startTime,endTime,stationCode,3);
// 查询降雨数据
R<List<Map<String, Object>>> rains = rainfallClient.getDurationRainFall(stationCode,rainStart,rainEnd);
// 近30天水位、降雨量
List<String> days = this.get30Day();
return days.stream().map(day->{
WeatherRainVo weatherRain = new WeatherRainVo();
weatherRain.setTime(day);
// 水位
if(CollectionUtil.isEmpty(waters)){
weatherRain.setWater(0.0);
}else{
weatherRain.setWater(waters.stream().filter(o->o.getTs().contains(day)).mapToDouble(water->{
if(StringUtil.isEmpty(water.getVal())){
return 0.0;
}else{
return Double.parseDouble(water.getVal());
}
}).sum());
}
// 降雨
if(!rains.isSuccess() || CollectionUtil.isEmpty(rains.getData())){
weatherRain.setRain(0.0);
}else{
weatherRain.setRain(rains.getData().stream().mapToDouble(map->{
if (map.get("fx_date").equals(day)) {
Object object = map.get("precip");
if(ObjectUtil.isEmpty(object)){
return 0.0;
}else{
return Double.parseDouble(object.toString());
}
}
return 0.0;
}).sum());
}
return weatherRain;
}).collect(Collectors.toList());
}
/**
* 查询近30天发电量
* @param deptId
* @return
*/
private List<ConverElectricityVo> poweyBy30Day(Long deptId) {
// 查询设备
R<List<String>> result = deviceClient.getEmCodeByDeptId(deptId);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>();
}
Calendar calendar = Calendar.getInstance();
String endTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
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,-30);
String startTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
// 功率查询
List<AnalyseDataTaosVO> datas = dataService.periodTargetDatas(startTime,endTime,3,2,result.getData(),HomePageConstant.ACTIVE_POWER);
if(CollectionUtil.isEmpty(datas)){
return new ArrayList<>();
}
List<ConverElectricityVo> electricitys = new ArrayList<>();
// 数据累计
datas.forEach(item->{
if(CollectionUtil.isEmpty(datas)){
return;
}
datas.forEach(data->{
ConverElectricityVo electricity = new ConverElectricityVo();
Date date = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss.s");
electricity.setTime(DateUtil.format(date,DateUtil.PATTERN_DATE));
if(StringUtil.isEmpty(data.getVal())){
electricity.setElectricity(0.0);
}else{
electricity.setElectricity(Double.parseDouble(data.getVal()));
}
electricitys.add(electricity);
});
});
if(CollectionUtil.isEmpty(electricitys)){
return new ArrayList<>();
}
// 进行time分组
return electricitys.stream().collect(Collectors.groupingBy(ConverElectricityVo::getTime)).entrySet().stream().map(entry->{
ConverElectricityVo electricity = new ConverElectricityVo();
electricity.setTime(entry.getKey());
electricity.setElectricity(entry.getValue().stream().mapToDouble(ConverElectricityVo::getElectricity).sum());
return electricity;
}).sorted(Comparator.comparing(ConverElectricityVo::getTime)).collect(Collectors.toList());
}
/**
* 查询24小时水位功率
* @param stationCode
* @return
*/
private List<LoadWaterLevelVo> loadWaterBy24Hour(Long deptId,String stationCode) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.HOUR_OF_DAY,-3);
String endTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.HOUR_OF_DAY,-24);
String startTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
List<String> hours = this.get24Hours();
// 查询功率数据
List<AnalyseDataTaosVO> loads = this.loads(startTime,endTime,deptId);
// 查询水位数据
List<AnalyseDataTaosVO> waters = this.water(startTime,endTime,stationCode,2);
return hours.stream().map(hour ->{
LoadWaterLevelVo loadWater = new LoadWaterLevelVo();
Date time = DateUtil.parse(hour,"yyyy-MM-dd HH");
loadWater.setTime(String.valueOf(time.getHours()));
if(CollectionUtil.isEmpty(loads)){
loadWater.setLoad(0.0);
}else{
loadWater.setLoad(loads.stream().filter(o->o.getTs().contains(hour)).mapToDouble(load->{
if(StringUtil.isEmpty(load.getVal())){
return 0.0;
}
return Double.parseDouble(load.getVal());
}).sum());
}
if(CollectionUtil.isEmpty(waters)){
loadWater.setWater(0.0);
}else{
loadWater.setWater(waters.stream().filter(o->o.getTs().contains(hour)).mapToDouble(load->{
if(StringUtil.isEmpty(load.getVal())){
return 0.0;
}
return Double.parseDouble(load.getVal());
}).sum());
}
return loadWater;
}).collect(Collectors.toList());
}
/**
* 查询水位数据
* @param startTime
* @param endTime
* @param stationCode
* @return
*/
private List<AnalyseDataTaosVO> water(String startTime, String endTime, String stationCode,Integer cycleType) {
// 查询模型站点
HzimsAnalyzeModelStationEntity model = modelStationService.getOne(Wrappers.<HzimsAnalyzeModelStationEntity>lambdaQuery()
.eq(HzimsAnalyzeModelStationEntity::getStationId,stationCode)
);
if(ObjectUtil.isEmpty(model)){
return new ArrayList<>();
}
// 水位查询
return dataService.periodTargetData(startTime,endTime,3,cycleType,model.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL);
}
/**
* 获取24小时功率
* @param refDept
*/
private List<AnalyseDataTaosVO> loads(String start,String end,Long refDept) {
List<AnalyseDataTaosVO> datas = new ArrayList<>();
R<List<String>> result = deviceClient.getEmCodeByDeptId(refDept);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return datas;
}
return dataService.periodTargetDatas(start,end,3,2,result.getData(),HomePageConstant.ACTIVE_POWER);
}
/**
* 获取30天
* @return
*/
private List<String> get30Day() {
List<String> times = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
Date end = calendar.getTime();
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,-29);
Date start = calendar.getTime();
while (start.compareTo(end) < 0) {
times.add(DateUtil.format(calendar.getTime(),"yyyy-MM-dd"));
calendar.add(Calendar.DAY_OF_MONTH,1);
start = calendar.getTime();
}
return times;
}
/**
* 获取24小时
* @return
*/
private List<String> get24Hours() {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.HOUR_OF_DAY,-3);
Date end = calendar.getTime();
calendar.add(Calendar.HOUR_OF_DAY,-24);
Date start = calendar.getTime();
List<String> times = new ArrayList<>();
while (start.compareTo(end) < 0) {
times.add(DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH"));
calendar.add(Calendar.HOUR_OF_DAY,1);
start = calendar.getTime();
}
return times;
}
/**
* 获取站点运行天数 * 获取站点运行天数
* @param station * @param station
* @return * @return
@ -308,6 +682,14 @@ public class HzimsDataServiceImpl implements HzimsDataService {
// 月发电量 // 月发电量
float powerMont = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum(); float powerMont = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum();
response.setPowerMon(powerMont); response.setPowerMon(powerMont);
// 月发电完成率
float planPowerMon = response.getPlanPowerMon();
if(Math.abs(planPowerMon) <= 0){
response.setPowerRateMon(0.0);
} else {
double powerRateYear = BigDecimal.valueOf(powerMont / (double) planPowerMon * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
response.setPowerRateMon(powerRateYear);
}
// 年发电量 // 年发电量
float powerYear = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); float powerYear = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum();
response.setPowerYear(powerYear); response.setPowerYear(powerYear);
@ -316,7 +698,7 @@ public class HzimsDataServiceImpl implements HzimsDataService {
if(Math.abs(planPowerYear) <= 0){ if(Math.abs(planPowerYear) <= 0){
response.setPowerRateYear(0.0); response.setPowerRateYear(0.0);
} else { } else {
double powerRateYear = BigDecimal.valueOf(powerYear / planPowerYear * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); double powerRateYear = BigDecimal.valueOf(powerYear / (double) planPowerYear * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
response.setPowerRateYear(powerRateYear); response.setPowerRateYear(powerRateYear);
} }
} }

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/scheduled/DutyMainCreateTask.java

@ -273,7 +273,7 @@ public class DutyMainCreateTask {
* *
* @param rideCount * @param rideCount
*/ */
public float getGeneration(AnalyseCodeByAnalyseDataPO po, int rideCount) { public float getGeneration(AnalyseCodeByAnalyseDataPO po, Double rideCount) {
R<List<AnalyzeDataConditionVO>> analyzeDataByAnalyzeCodeAndSignages = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); R<List<AnalyzeDataConditionVO>> analyzeDataByAnalyzeCodeAndSignages = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
float count = 0; float count = 0;
if (analyzeDataByAnalyzeCodeAndSignages.isSuccess() && CollectionUtil.isNotEmpty(analyzeDataByAnalyzeCodeAndSignages.getData())) { if (analyzeDataByAnalyzeCodeAndSignages.isSuccess() && CollectionUtil.isNotEmpty(analyzeDataByAnalyzeCodeAndSignages.getData())) {
@ -284,9 +284,9 @@ public class DutyMainCreateTask {
for (AnalyseDataTaosVO analyseDataTaosVO : list) { for (AnalyseDataTaosVO analyseDataTaosVO : list) {
if (StringUtil.isNotBlank(analyseDataTaosVO.getVal())) { if (StringUtil.isNotBlank(analyseDataTaosVO.getVal())) {
if (0 != rideCount) { if (0 != rideCount) {
count = Float.valueOf(analyseDataTaosVO.getVal()) * rideCount; count = Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO.getVal()) * rideCount));
} else { } else {
count = Float.valueOf(analyseDataTaosVO.getVal()); count = Float.parseFloat(analyseDataTaosVO.getVal());
} }
} }
} }

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

@ -139,7 +139,7 @@ public class ImsDutyChangeServiceImpl extends BaseServiceImpl<ImsDutyChangeMappe
List<ImsDutyChangeTowVo> imsDutyChangeTowVos = this.baseMapper.selectListDetails(page); List<ImsDutyChangeTowVo> imsDutyChangeTowVos = this.baseMapper.selectListDetails(page);
for (ImsDutyChangeTowVo imsDutyChangeTowVo : imsDutyChangeTowVos) { for (ImsDutyChangeTowVo imsDutyChangeTowVo : imsDutyChangeTowVos) {
if (Func.isNotBlank(imsDutyChangeTowVo.getManager() + "")) { if (Func.isNotBlank(imsDutyChangeTowVo.getManager() + "")) {
imsDutyChangeTowVo.setManagerName(userClient.userInfoById(imsDutyChangeTowVo.getManager()).getData().getName()); imsDutyChangeTowVo.setManagerName(userClient.userInfoById(imsDutyChangeTowVo.getManager()).getData().getRealName());
} }
} }
return page.setRecords(imsDutyChangeTowVos); return page.setRecords(imsDutyChangeTowVos);
@ -147,8 +147,8 @@ public class ImsDutyChangeServiceImpl extends BaseServiceImpl<ImsDutyChangeMappe
@Override @Override
public void setUserNmae(ImsDutyChangeVO vo) { public void setUserNmae(ImsDutyChangeVO vo) {
vo.setApplyPersonName(userClient.userInfoById(vo.getApplyPersonId()).getData().getName());//申请人 vo.setApplyPersonName(userClient.userInfoById(vo.getApplyPersonId()).getData().getRealName());//申请人
vo.setAcceptPersonName(userClient.userInfoById(vo.getAcceptPersonId()).getData().getName());//调班人 vo.setAcceptPersonName(userClient.userInfoById(vo.getAcceptPersonId()).getData().getRealName());//调班人
} }

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

@ -343,7 +343,7 @@ public class ImsDutyGroupServiceImpl extends BaseServiceImpl<ImsDutyGroupMapper,
if (managerId!=null) { if (managerId!=null) {
R<User> userR = userClient.userInfoById(managerId); R<User> userR = userClient.userInfoById(managerId);
if (userR.isSuccess() && ObjectUtil.isNotEmpty(userR.getData())) { if (userR.isSuccess() && ObjectUtil.isNotEmpty(userR.getData())) {
userName = userR.getData().getName(); userName = userR.getData().getRealName();
} }
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecQRRecordServiceImpl.java

@ -45,7 +45,7 @@ public class ImsDutyRecQRRecordServiceImpl extends BaseServiceImpl<ImsDutyRecQRR
for (ImsDutyRecQRRecordVo imsDutyRecQRRecordVo : imsDutyRecQRRecordVoIPage) { for (ImsDutyRecQRRecordVo imsDutyRecQRRecordVo : imsDutyRecQRRecordVoIPage) {
User data = userClient.userInfoById(imsDutyRecQRRecordVo.getPersonId()).getData(); User data = userClient.userInfoById(imsDutyRecQRRecordVo.getPersonId()).getData();
if(ObjectUtil.isNotEmpty(data)){ if(ObjectUtil.isNotEmpty(data)){
imsDutyRecQRRecordVo.setUserName(data.getName()); imsDutyRecQRRecordVo.setUserName(data.getRealName());
} }
} }

159
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java

@ -1,7 +1,6 @@
package com.hnac.hzims.operational.main.scheduled; package com.hnac.hzims.operational.main.scheduled;
import com.hnac.hzims.monitor.utils.DateUtils; import com.hnac.hzims.monitor.utils.DateUtils;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.service.*;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
@ -13,10 +12,8 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -144,7 +141,6 @@ public class ScheduledCreateTask {
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
/** /**
* 获取机组当月运行时长 * 获取机组当月运行时长
* *
@ -162,49 +158,6 @@ public class ScheduledCreateTask {
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
/**
* 获取站点近3年发电量数据
* @return ReturnT<String>
*/
@XxlJob(ELECTRICITY_GENERATION_RECENT_YEAR)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> powerGenerationRecentYear(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
hydropowerService.loadPowerData(param, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),SERVE_TYPE,3);
return new ReturnT<>("SUCCESS");
}
/**
* 首页-区域班组数据
* @return ReturnT<String>
*/
@XxlJob(REGIONAL_DUTY_INFO)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadDutyInfo(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
}
regionService.loadDutyInfo(param);
return new ReturnT<>("SUCCESS");
}
/**
* 首页-区域设备分类统计
* @return ReturnT<String>
*/
@XxlJob(LOAD_DEVICE_CLASSIFY)
//@Scheduled(cron = "0/10 * * * * ? ")
public ReturnT<String> deviceClassify(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
}
regionService.deviceClassify(param);
return new ReturnT<>("SUCCESS");
}
/** /**
* 首页-生产月报表 * 首页-生产月报表
* @return ReturnT<String> * @return ReturnT<String>
@ -218,116 +171,4 @@ public class ScheduledCreateTask {
reportService.loadMonthReport(param,1); reportService.loadMonthReport(param,1);
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
/**
* 首页-指标数据加载
* @return ReturnT<String>
*/
@XxlJob(LOAD_HOME_TARGET)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadHomeTarget(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
homeService.loadHomeTarget(param);
return new ReturnT<>("SUCCESS");
}
/**
* 水利-泵组实时加载
* @return ReturnT<String>
*/
@XxlJob(LOAD_WATER_PUMP_REAL)
//@Scheduled(cron = "0/10 * * * * ? ")
public ReturnT<String> loadWaterPumpReal(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
waterService.loadWaterPumpReal(param);
return new ReturnT<>("SUCCESS");
}
/**
* 水利-泵组指标加载
* @return ReturnT<String>
*/
@XxlJob(LOAD_WATER_PUMP_TARGET)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadWaterPumpTarget(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
waterService.loadWaterPumpTarget(param);
return new ReturnT<>("SUCCESS");
}
/**
* 水利-站点水位数据
* @return ReturnT<String>
*/
@XxlJob(LOAD_WATER_LEVEL)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadWaterLevel(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
waterService.loadWaterLevel(param);
return new ReturnT<>("SUCCESS");
}
/**
* 水电站-机组实时加载
*/
@XxlJob(LOAD_HYDROPOWER_UNIT_REAL)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadHydropowerUnitReal(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
hydropowerService.loadHydropowerReal(param);
return new ReturnT<>("SUCCESS");
}
/**
* 水电站-机组指标加载
* @return ReturnT<String>
*/
@XxlJob(LOAD_HYDROPOWER_UNIT_TARGET)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadHydropowerUnitTarget(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
hydropowerService.loadHydropowerTarget(param);
return new ReturnT<>("SUCCESS");
}
/**
* 光伏站-逆变器实时加载
* @return ReturnT<String>
*/
@XxlJob(LOAD_PHOTOVOLTAIC_REAL)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadPhotovoltaicReal(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
photovoltaicService.loadPhotovoltaicReal(param);
return new ReturnT<>("SUCCESS");
}
/**
* 光伏站-逆变器指标加载
* @return ReturnT<String>
*/
@XxlJob(LOAD_PHOTOVOLTAIC_TARGET)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadPhotovoltaicTarget(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
photovoltaicService.loadPhotovoltaicTarget(param);
return new ReturnT<>("SUCCESS");
}
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HomeService.java

@ -11,8 +11,6 @@ import java.util.List;
*/ */
public interface HomeService { public interface HomeService {
void loadHomeTarget(String param);
List<StationCountVo> count(boolean make); List<StationCountVo> count(boolean make);
List<TargetVo> target(Integer type); List<TargetVo> target(Integer type);

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

@ -9,13 +9,6 @@ import java.util.List;
* @author ysj * @author ysj
*/ */
public interface HydropowerService { public interface HydropowerService {
void loadHydropowerReal(String param);
void loadHydropowerTarget(String param);
void loadPowerData(String param, List<Integer> types, Integer serveType, int year);
HydropowerStationVo station(Long deptId); HydropowerStationVo station(Long deptId);
List<HydropowerUnitVo> hydropowerDevice(Long deptId); List<HydropowerUnitVo> hydropowerDevice(Long deptId);

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

@ -18,5 +18,7 @@ public interface IAnalyseDataService {
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);
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, Integer ride ,String signages);
} }

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

@ -10,10 +10,6 @@ import java.util.Map;
public interface ISideHustleService { public interface ISideHustleService {
void loadDutyInfo(String param);
void deviceClassify(String param);
List<EquipmentStateCountVo> equipmentStateCount(Long deptId); List<EquipmentStateCountVo> equipmentStateCount(Long deptId);
PowerFinishVo powerFinishMonth(Long deptId); PowerFinishVo powerFinishMonth(Long deptId);

9
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWaterService.java

@ -1,6 +1,5 @@
package com.hnac.hzims.operational.main.service; package com.hnac.hzims.operational.main.service;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.main.vo.*;
import org.springblade.system.entity.Dept; import org.springblade.system.entity.Dept;
@ -11,12 +10,6 @@ import java.util.List;
*/ */
public interface IWaterService { public interface IWaterService {
void loadWaterPumpReal(String param);
void loadWaterPumpTarget(String param);
void loadWaterLevel(String param);
WaterConservancyVo waterConservancy(Long deptId); WaterConservancyVo waterConservancy(Long deptId);
List<WaterDetailsVo> waterDetails(Long deptId); List<WaterDetailsVo> waterDetails(Long deptId);
@ -34,6 +27,4 @@ public interface IWaterService {
List<WaterPumpVo> getPumpList(Long deptId); List<WaterPumpVo> getPumpList(Long deptId);
List<WaterGateVo> getGateList(Long deptId); List<WaterGateVo> getGateList(Long deptId);
List<ActivePowerVo> getActivePowerVoList(EminfoAndEmParamVo device);
} }

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java

@ -11,12 +11,6 @@ import java.util.List;
*/ */
public interface PhotovoltaicService { public interface PhotovoltaicService {
// 光伏站实时数据加载
void loadPhotovoltaicReal(String param);
// 光伏站指标数据加载
void loadPhotovoltaicTarget(String param);
// 集团/区域关键指标 // 集团/区域关键指标
PhotovoltaicKPIsVo KPIs(Long deptId); PhotovoltaicKPIsVo KPIs(Long deptId);

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

@ -89,6 +89,45 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
* @param endTime 结束时间 * @param endTime 结束时间
* @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值
* @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6-> * @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6->
* @param deviceCodes 设备编号集合
* @param signages 指标
* @return
*/
@Override
public List<AnalyseDataTaosVO> periodTargetDatas(String startTime, String endTime, Integer accessRules, Integer cycleType, List<String> deviceCodes, String signages) {
List<AnalyseDataTaosVO> dataTaos = new ArrayList<>();
deviceCodes.forEach(deviceCode->{
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
po.setDeviceCode(deviceCode);
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
analyzeDataConditionPO.setFull(1);
analyzeDataConditionPO.setSignages(signages);
analyzeDataConditionPO.setKeepFigures(2);
analyzeDataConditionPO.setAccessRules(accessRules);
analyzeDataConditionPO.setSaveTimeType(cycleType);
// 间隔
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)));
po.setSignboardConditions(Collections.singletonList(analyzeDataConditionPO));
log.error("period_target_data_request {}",po);
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) {
return;
}
log.error("period_target_data_resp {}",result);
dataTaos.addAll(result.getData().get(0).getList());
});
return dataTaos;
}
/***
* 指标数据列表查询
* @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 deviceCode 设备编号
* @param ride 配电比 * @param ride 配电比
* @param signages 指标 * @param signages 指标

402
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java

@ -1,20 +1,16 @@
package com.hnac.hzims.operational.main.service.impl; package com.hnac.hzims.operational.main.service.impl;
import com.alibaba.fastjson.JSONObject; 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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.fill.entity.*;
import com.hnac.hzims.operational.fill.service.*;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.HomeService; import com.hnac.hzims.operational.main.service.HomeService;
import com.hnac.hzims.operational.main.service.IMainTaskStatisticService; import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo;
import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.main.vo.HydropowerUnitTargetVo;
import com.hnac.hzims.operational.main.vo.StationCountVo;
import com.hnac.hzims.operational.main.vo.TargetVo;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.ticket.allTicket.dto.TicketStatisticDTO; import com.hnac.hzims.ticket.allTicket.dto.TicketStatisticDTO;
@ -46,8 +42,11 @@ import java.nio.charset.StandardCharsets;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.*; import java.util.ArrayList;
import java.util.concurrent.*; import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -59,29 +58,14 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class HomeServiceImpl implements HomeService { public class HomeServiceImpl implements HomeService {
private final WindService windService;
private final OverService overService;
private final OtherService otherService;
private final PowerService powerService;
private final SolveService solveService;
private final IStationService stationService; private final IStationService stationService;
private final IPlanGenertionClient planService; private final IPlanGenertionClient planService;
private final OverDetailsService overDetailsService;
private final IMainTaskStatisticService mainTaskStatisticService;
private final ISysClient sysClient; private final ISysClient sysClient;
private final ITicketInfoAllClient ticketClient; private final ITicketInfoAllClient ticketClient;
private final IPlanGenertionClient planClient;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
@ -90,51 +74,10 @@ public class HomeServiceImpl implements HomeService {
@Value("${hzims.operation.homePage.charge.url}") @Value("${hzims.operation.homePage.charge.url}")
public String charge_url; public String charge_url;
public final static String device_cache_final = "hzims:equipment:emInfo:deviceCode.emInfoList";
private final static String load_home_target_key = "load:operation:home:target:key"; private final static String load_home_target_key = "load:operation:home:target:key";
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key";
private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key";
private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key";
private static final int STORAGE_POOL_QUANTITY = 4;
private static final int NETWORK_POOL_QUANTITY = 3;
@Override
public void loadHomeTarget(String param) {
List<TargetVo> targets = HomePageConstant.HOME_TYPES.stream().map(type->{
if(type == 0) {
return this.hydropowerTaget();
}
if (type == 1) {
return this.windTaget();
}
if (type == 2) {
return this.waterStorageTaget(true);
}
if (type == 3) {
return this.waterStorageTaget(false);
}
if (type == 4) {
return this.networkTaget();
}
if (type == 5) {
return this.photovoltaicTaget();
}
if (type == 6) {
return this.affairsTaget();
}
if(type == 7) {
return this.chargeTarget();
}
return new TargetVo();
}).collect(Collectors.toList());
redisTemplate.opsForValue().set(load_home_target_key,targets.stream().filter(( target -> ObjectUtil.isNotEmpty(target.getType()))).collect(Collectors.toList()));
}
/** /**
* 首页站点数量 * 首页站点数量
@ -154,13 +97,15 @@ public class HomeServiceImpl implements HomeService {
count.setServeType(serve); count.setServeType(serve);
if(HomePageConstant.CHARGE.equals(type) && "2".equals(serve)){ if(HomePageConstant.CHARGE.equals(type) && "2".equals(serve)){
TargetVo target = (TargetVo) redisTemplate.opsForValue().get(charge); TargetVo target = (TargetVo) redisTemplate.opsForValue().get(charge);
if(ObjectUtil.isNotEmpty(target)){ if(ObjectUtil.isEmpty(target)){
TargetVo charge = this.chargeTarget(); TargetVo charge = this.chargeTarget();
if(ObjectUtil.isNotEmpty(charge)){ if(ObjectUtil.isNotEmpty(charge)){
count.setCount(Long.valueOf(charge.getCharge())); count.setCount(Long.valueOf(charge.getCharge()));
}else{ }else{
count.setCount(92L); count.setCount(113L);
} }
}else{
count.setCount(Long.valueOf(target.getCharge()));
} }
}else if(HomePageConstant.WATER_CONSERVANCY.equals(type) && "2".equals(serve)){ }else if(HomePageConstant.WATER_CONSERVANCY.equals(type) && "2".equals(serve)){
count.setCount(stations.stream().filter(station->serve.equals(station.getServeType()) && HomePageConstant.waterList.contains(station.getType())).count()); count.setCount(stations.stream().filter(station->serve.equals(station.getServeType()) && HomePageConstant.waterList.contains(station.getType())).count());
@ -188,327 +133,6 @@ public class HomeServiceImpl implements HomeService {
return targets; return targets;
} }
/**
* 水电站指标
* @return
*/
private TargetVo hydropowerTaget() {
TargetVo target = new TargetVo();
target.setType(HomePageConstant.HYDROPOWER);
target.setTypeName(DictCache.getValue("stationType", HomePageConstant.HYDROPOWER));
// 实时数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
// 指标数据
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key);
if(CollectionUtil.isNotEmpty(reals)){
// 装机容量
target.setTaget_one(reals.stream().mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum());
}
if(CollectionUtil.isNotEmpty(targets)){
// 发电量
target.setTaget_two(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum());
}
// 计划发电量
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER));
if(CollectionUtil.isNotEmpty(stations)){
List<PlanGenerationEntity> plans = planService.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy"));
if(CollectionUtil.isNotEmpty(plans)){
double plan = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
if(Math.abs(plan) > 0){
target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
}
}
// 双票合格率
R<List<Dept>> result = sysClient.getDeptList();
if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData()) && CollectionUtil.isNotEmpty(stations)){
List<Long> areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(areas)){
LocalDateTime firstDateTime = LocalDateTime.of(LocalDate.now().withDayOfYear(1), LocalTime.MIN);
TicketStatisticDTO ticketStatisticDTO=new TicketStatisticDTO();
ticketStatisticDTO.setDepatList(areas);
ticketStatisticDTO.setStartTime(firstDateTime);
ticketStatisticDTO.setEndTime(LocalDateTime.now());
DoublePassRateVO pass = ticketClient.getDoublePassRate(ticketStatisticDTO);
if(ObjectUtil.isNotEmpty(pass)){
target.setTaget_four(Double.valueOf(pass.getDoublePassRate()));
}
}
}
return target;
}
/**
* 风电指标
* @return
*/
private TargetVo windTaget() {
TargetVo target = new TargetVo();
target.setType(HomePageConstant.WIND_POWER);
target.setTypeName(DictCache.getValue("stationType", HomePageConstant.WIND_POWER));
// 填报发电量
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,HomePageConstant.WIND_POWER));
if(CollectionUtil.isEmpty(stations)){
return target;
}
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null, DateUtil.format(new Date(),"yyyy"));
// 填报信息
List<WindEntity> winds = windService.list(Wrappers.<WindEntity>lambdaQuery()
.in(WindEntity::getStationCode, stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.likeRight(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy")));
if(CollectionUtil.isEmpty(winds)){
return target;
}
double plan = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
double power = winds.stream().mapToDouble(WindEntity::getPower).sum();
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
// 装机容量
target.setTaget_one(devices.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum());
// 发电量
target.setTaget_two(power);
if(Math.abs(plan) > 0){
// 发电完成率
target.setTaget_three(BigDecimal.valueOf(power / plan * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
// 双票合格率
LocalDate firstDay = LocalDate.now().withDayOfYear(1);
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN);
R<List<Dept>> result = sysClient.getDeptList();
List<Long> areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList());
TicketStatisticDTO ticketStatisticDTO=new TicketStatisticDTO();
ticketStatisticDTO.setDepatList(areas);
ticketStatisticDTO.setStartTime(firstDateTime);
ticketStatisticDTO.setEndTime(LocalDateTime.now());
DoublePassRateVO pass = ticketClient.getDoublePassRate(ticketStatisticDTO);
if (ObjectUtil.isNotEmpty(pass)) {
target.setTaget_four(Double.valueOf(pass.getDoublePassRate()));
}
return target;
}
/**
* 光伏指标
* @return
*/
private TargetVo photovoltaicTaget() {
TargetVo target = new TargetVo();
target.setType(HomePageConstant.PHOTOVOLTAIC);
target.setTypeName(DictCache.getValue("stationType", HomePageConstant.PHOTOVOLTAIC));
// 实时数据
List<PhotovoltaicRealVo> reals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
// 指标数据
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if(CollectionUtil.isNotEmpty(reals)){
// 装机容量
target.setTaget_one(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
}
if(CollectionUtil.isNotEmpty(targets)){
// 发电量
target.setTaget_two(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum());
}
// 计划发电量、双票合格率
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,HomePageConstant.PHOTOVOLTAIC));
if(CollectionUtil.isNotEmpty(stations)){
QueryWrapper<PowerEntity> queryWrapper = new QueryWrapper<PowerEntity>() {{
in("create_dept", stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
eq("type", HomePageConstant.PHOTOVOLTAIC_TYPE);
likeRight("mon", DateUtil.format(new Date(),"yyyy"));
}};
List<PowerEntity> list = powerService.list(queryWrapper);
if(CollectionUtil.isEmpty(list)){
return target;
}
double plan = list.stream().mapToDouble(PowerEntity::getPlannedPowerMon).sum();
double pass = list.stream().mapToDouble(power -> Double.parseDouble(power.getDoubleQualifyRate())).sum();
if(Math.abs(plan) > 0){
// 发电完成率
target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
// 双票合格率
target.setTaget_four(BigDecimal.valueOf(pass / list.size()).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
return target;
}
/**
* 储能指标
* @param flag : true - 水利 false - 储能
* @return
*/
private TargetVo waterStorageTaget(boolean flag) {
TargetVo target = new TargetVo();
if(flag){
target.setType(HomePageConstant.WATER_CONSERVANCY);
target.setTypeName(DictCache.getValue("stationType", HomePageConstant.WATER_CONSERVANCY));
}else{
target.setType(HomePageConstant.ENERGY_STORAGE);
target.setTypeName(DictCache.getValue("stationType", HomePageConstant.ENERGY_STORAGE));
}
// 查询储能站点
LambdaQueryWrapper<StationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
if(flag){
wrapper.eq(StationEntity::getType,HomePageConstant.WATER_CONSERVANCY);
}else{
wrapper.eq(StationEntity::getType,HomePageConstant.ENERGY_STORAGE);
}
List<StationEntity> stations = stationService.list(wrapper);
if(CollectionUtil.isEmpty(stations)){
return target;
}
// 获取储能区域级别机构
R<List<Dept>> result = sysClient.getDeptList();
if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData()) && CollectionUtil.isNotEmpty(stations)){
List<Long> areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(areas)){
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build();
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(STORAGE_POOL_QUANTITY, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
// 监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(STORAGE_POOL_QUANTITY);
// 日常维护
exe.execute(() -> {
target.setTaget_one(Double.valueOf(mainTaskStatisticService.getRoutineMaintenanceCount(areas)));
countDownLatch.countDown();
});
// 检修任务
exe.execute(() -> {
target.setTaget_two(Double.valueOf(mainTaskStatisticService.getMaintenanceTasksCount(areas)));
countDownLatch.countDown();
});
// 消缺率
exe.execute(() -> {
target.setTaget_three(Double.valueOf(mainTaskStatisticService.getDeletionRate(areas)));
countDownLatch.countDown();
});
// 双票合格率
exe.execute(() -> {
LocalDate firstDay = LocalDate.now().withDayOfYear(1);
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN);
TicketStatisticDTO ticketStatisticDTO=new TicketStatisticDTO();
ticketStatisticDTO.setDepatList(areas);
ticketStatisticDTO.setStartTime(firstDateTime);
ticketStatisticDTO.setEndTime(LocalDateTime.now());
DoublePassRateVO pass = ticketClient.getDoublePassRate(ticketStatisticDTO);
if (ObjectUtil.isNotEmpty(pass)) {
target.setTaget_four(Double.valueOf(pass.getDoublePassRate()));
}
countDownLatch.countDown();
});
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
exe.shutdown();
}
}
return target;
}
/**
* 配网
* @return
*/
private TargetVo networkTaget() {
TargetVo target = new TargetVo();
target.setType(HomePageConstant.DISTRIBUTION_NETWORK);
target.setTypeName(DictCache.getValue("stationType", HomePageConstant.DISTRIBUTION_NETWORK));
// 线程池
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("network-taget-pool-%d").build();
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(NETWORK_POOL_QUANTITY, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
// 监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(NETWORK_POOL_QUANTITY);
// 当月
LocalDate firstDay = LocalDate.now().withDayOfYear(1);
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN);
// 检修卡
exe.execute(()->{
List<OverEntity> overs = overService.list(new QueryWrapper<OverEntity>() {{
ge("create_time", firstDateTime);
le("create_time", LocalDateTime.now());
}});
if(CollectionUtil.isEmpty(overs)){
countDownLatch.countDown();
return;
}
List<OverDetailsEntity> details = overDetailsService.list(new QueryWrapper<OverDetailsEntity>() {{
ge("create_time", firstDateTime);
le("create_time", LocalDateTime.now());
in("over_id",overs.stream().map(OverEntity::getId).collect(Collectors.toList()));
}});
if(CollectionUtil.isEmpty(details)){
countDownLatch.countDown();
return;
}
target.setTaget_one(details.stream().mapToDouble(OverDetailsEntity::getQuantity).sum());
countDownLatch.countDown();
});
// 消缺
exe.execute(()->{
List<SolveEntity> solves = solveService.list(new QueryWrapper<SolveEntity>() {{
ge("create_time", firstDateTime);
le("create_time", LocalDateTime.now());
}});
if(CollectionUtil.isEmpty(solves)){
countDownLatch.countDown();
return;
}
target.setTaget_two(solves.stream().mapToDouble(SolveEntity::getSolveQuantity).sum());
countDownLatch.countDown();
});
// 其他
exe.execute(()->{
List<OtherEntity> others = otherService.list(new QueryWrapper<OtherEntity>() {{
ge("create_time", firstDateTime);
le("create_time", LocalDateTime.now());
}});
if(CollectionUtil.isEmpty(others)){
countDownLatch.countDown();
return;
}
// FA上线率
double online = others.stream().mapToDouble(o-> Double.parseDouble(o.getOnlineRate())).sum();
if(Math.abs(online) > 0){
target.setTaget_three(BigDecimal.valueOf(online / others.size()).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
// FA投入条数
target.setTaget_four(others.stream().mapToDouble(OtherEntity::getFaQuantity).sum());
countDownLatch.countDown();
});
// 等待所有线程执行完成
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
exe.shutdown();
return target;
}
/**
* 水务指标
* @return
*/
private TargetVo affairsTaget() {
TargetVo target = new TargetVo();
target.setType(HomePageConstant.WATER_AFFAIRS);
target.setTypeName(DictCache.getValue("stationType", HomePageConstant.WATER_AFFAIRS));
// TODO 统计业务数据
return target;
}
/** /**
* 充电桩 * 充电桩
* @return * @return

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

@ -1,11 +1,8 @@
package com.hnac.hzims.operational.main.service.impl; package com.hnac.hzims.operational.main.service.impl;
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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
@ -20,8 +17,6 @@ import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService;
import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService;
import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo; import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo;
import com.hnac.hzims.operational.fill.service.GenerateService;
import com.hnac.hzims.operational.fill.service.PowerService;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.entity.UserDeptEntity; import com.hnac.hzims.operational.main.entity.UserDeptEntity;
import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.service.*;
@ -29,11 +24,9 @@ import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationAttributeService;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient; import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient;
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData; import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient; import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient;
@ -82,22 +75,14 @@ public class HydropowerServiceImpl implements HydropowerService {
private final IStationService stationService; private final IStationService stationService;
private final GenerateService generateService;
private final UserDeptService userDeptService; private final UserDeptService userDeptService;
private final PowerService photovoltaicService;
private final IImsDutyMainService dutyMainService; private final IImsDutyMainService dutyMainService;
private final IAnalyseDataService analyseDataService;
private final IOperPhenomenonService phenomenonService; private final IOperPhenomenonService phenomenonService;
private final IOperAccessTaskService accessTaskService; private final IOperAccessTaskService accessTaskService;
private final IStationAttributeService attributeService;
private final IMainSystemMonitoringService maintenanceTaskService; private final IMainSystemMonitoringService maintenanceTaskService;
private final IMainTaskStatisticService mainTaskStatisticService; private final IMainTaskStatisticService mainTaskStatisticService;
@ -130,417 +115,6 @@ public class HydropowerServiceImpl implements HydropowerService {
private final static int DUTY_POOL_QUANTITY = 5; private final static int DUTY_POOL_QUANTITY = 5;
/**
* 加载水电站机组实时数据
* @param param
*/
@Override
public void loadHydropowerReal(String param) {
// 水电站站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
//.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER)
);
if(CollectionUtil.isEmpty(stations)){
return;
}
// 水电站设备
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
if(CollectionUtil.isEmpty(devices)){
return;
}
// 实时数据
Map<String, String> map = this.getRealMap();
// 单位
Map<String, String> unitMap = this.attributeService.getPointUnit();
// 实时数据
List<HydropowerUnitRealVo> reals = devices.stream().map(device->{
HydropowerUnitRealVo real = new HydropowerUnitRealVo();
real.setDeptId(device.getCreateDept());
real.setDeviceCode(device.getEmCode());
real.setOrd(device.getOrd());
real.setDeptName(device.getName());
real.setDeviceName(device.getName());
// 装机容量
real.setInstalledCapacity(device.getInstalledCapacity());
// 开关机状态
real.setState(this.hydropowerState(device,map));
// 有功功率
real.setActivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER));
// 无功功率
real.setReactivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_REACTIVE_POWER));
// 功率因数
real.setPowerFactor(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_POWERFACTOR));
// 机组频率
real.setFrequency(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_FREQUENCY));
// 导叶开度
real.setGuideOpen(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_GUIDEOPEN));
// 定子电压
real.setStatorVoltage(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_VOLTAGE));
// 定子电流
real.setStatorCurrent(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_CURRENT));
// 单位设置
this.setttingUnit(device,unitMap,real);
return real;
}).collect(Collectors.toList());
if(CollectionUtil.isEmpty(reals)){
return;
}
redisTemplate.opsForValue().set(load_hydropower_unit_real_key,reals);
}
/**
* 加载水电站机组指标数据
* @param param
*/
@Override
public void loadHydropowerTarget(String param) {
// 水电站站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
//.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER)
);
if(CollectionUtil.isEmpty(stations)){
return;
}
// 补充填补发电指标
List<HydropowerUnitTargetVo> targets = this.generteFill(stations);
// 水电站设备
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
if(CollectionUtil.isNotEmpty(devices)){
targets.addAll(devices.stream().map(device->{
HydropowerUnitTargetVo target = new HydropowerUnitTargetVo();
target.setDeptId(device.getCreateDept());
target.setDeviceCode(device.getEmCode());
target.setDeviceName(device.getName());
target.setDeptName(device.getName());
// 当年发电量
target.setPowerYear(this.getGenerationPower(device,0));
// 当月发电量
target.setPowerMon(this.getGenerationPower(device,1));
// 当日发电量
target.setPowerDay(this.getGenerationPower(device,2));
// 当天有功功率
target.setActivePowerVoList(this.getLoadsByDay(device));
// 30天发电量
target.setGenerationPowerVoList(this.getGenerationPowerList(device));
return target;
}).collect(Collectors.toList()));
}
// 站点指标数据为空
if(CollectionUtil.isEmpty(targets)){
return;
}
redisTemplate.opsForValue().set(load_hydropower_unit_target_key,targets);
}
/**
* 设备状态
* @param device
* @param map
* @return
*/
private Boolean hydropowerState(EminfoAndEmParamVo device, Map<String, String> map) {
if(Math.abs(this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY)) > 0){
return true;
}
return Math.abs(this.getSignageValue(device, map, HomePageConstant.ACTIVE_POWER)) > 0;
}
/**
* 近年发电量数据
*
* @param param 时间
* @param serveType 站点类型
* @param year 近几年
*/
@Override
public void loadPowerData(String param, List<Integer> types, Integer serveType, int year) {
// 站点查询
List<StationEntity> stationList = stationService.getStationType(serveType, types, null,true);
// 设备信息
List<EminfoAndEmParamVo> devices = maintenanceTaskService.getEmInfoList();
// 开始时间
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 结束日期
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year);
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<>();
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.getGenerateYear(station,stationDevices,start,end);
if(MapUtils.isEmpty(generateMap)){
return;
}
powerMap.put(station.getId(),generateMap);
});
redisTemplate.opsForValue().set(recent_year_power_data, powerMap);
}
/**
* 当天有功功率
* @param device
* @return
*/
private List<ActivePowerVo> getLoadsByDay(EminfoAndEmParamVo device) {
String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00";
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD);
if (CollectionUtil.isEmpty(records)) {
return new ArrayList<>();
}
return records.stream().map(record -> {
ActivePowerVo load = new ActivePowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
load.setHour(time.getHours());
load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0"));
return load;
}).sorted(Comparator.comparing(ActivePowerVo::getHour)).collect(Collectors.toList());
}
/**
* 获取年发电量
* @param devices
* @param start
* @param end
* @return
*/
private Map<String, Float> getGenerateYear(StationEntity station,List<EminfoAndEmParamVo> devices, String start, String end) {
List<PowerMonthVo> datas = new ArrayList<>();
// 设备采集发电量
if(CollectionUtil.isNotEmpty(devices)){
devices.forEach(device->{
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
if(CollectionUtil.isEmpty(records)){
return;
}
datas.addAll(records.stream().map(record -> {
PowerMonthVo generate = new PowerMonthVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE));
generate.setPower(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount());
return generate;
}).collect(Collectors.toList()));
});
}
// 补充填报数据
datas.addAll(this.generateFill(station,start,end));
if(CollectionUtil.isEmpty(datas)){
return null;
}
return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum));
}
/**
* 获取填报用电量
* @param stations
* @return
*/
private List<HydropowerUnitTargetVo> generteFill(List<StationEntity> stations) {
Calendar calendar = Calendar.getInstance();
String day = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
String mon = DateUtil.format(calendar.getTime(),"yyyy-MM");
String year = String.valueOf(calendar.get(Calendar.YEAR));
return stations.stream().map(station ->{
HydropowerUnitTargetVo target = new HydropowerUnitTargetVo();
target.setDeptId(station.getRefDept());
target.setDeptName(station.getName());
// 当年发电量
target.setPowerYear(generateService.generate(year,station.getCode()));
// 当月发电量
target.setPowerMon(generateService.generate(mon,station.getCode()));
// 当日发电量
target.setPowerDay(generateService.generate(day,station.getCode()));
// 30天发电量
target.setGenerationPowerVoList(generateService.generate30Day(day,station.getCode()));
return target;
}).collect(Collectors.toList());
}
/**
* 补充填报数据
* @param station
* @param start
* @param end
*/
private List<PowerMonthVo> generateFill(StationEntity station, String start, String end) {
start = DateUtil.format(DateUtil.parse(start,DateUtil.PATTERN_DATETIME),"yyyy-MM");
end = DateUtil.format(DateUtil.parse(end,DateUtil.PATTERN_DATETIME),"yyyy-MM");
// 光伏
if(HomePageConstant.PHOTOVOLTAIC.equals(station.getType())){
return photovoltaicService.generateThreeYear(start,end,station.getRefDept());
}
// 水电
return generateService.generateThreeYear(start,end,station.getCode());
}
/**
* 泵站设备
* @param stations
* @return
*/
private List<EminfoAndEmParamVo> pumpDevices(List<Long> stations){
if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>();
}
List<EminfoAndEmParamVo> devices = maintenanceTaskService.getEmInfoList();
if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>();
}
return devices.stream().filter(device->stations.contains(device.getCreateDept())).collect(Collectors.toList());
}
/**
* 获取实时数据
* @return
*/
private Map<String, String> getRealMap() {
String json = (String) redisTemplate.opsForValue().get(real_id_key);
if(StringUtil.isBlank(json)){
return null;
}
return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {});
}
/**
* 获取监测点实时数据
* @param device
* @param targets
* @return
*/
private double getSignageValue(EminfoAndEmParamVo device,Map<String, String> map, String targets) {
if(ObjectUtil.isEmpty(device) || MapUtils.isEmpty(map)){
return 0.0;
}
Map<String,String> point = device.getPoint();
if(MapUtils.isEmpty(point)){
return 0.0;
}
String realId = point.get(targets);
if(StringUtil.isBlank(realId)){
return 0.0;
}
String value = map.get(realId);
if(StringUtil.isBlank(value)){
return 0.0;
}
// 获取value
return Double.parseDouble(value);
}
/**
* 单位设置
* @param device
* @param unitMap
* @param realVo
*/
private void setttingUnit(EminfoAndEmParamVo device, Map<String, String> unitMap, HydropowerUnitRealVo realVo) {
if(MapUtils.isEmpty(unitMap)){
return;
}
// 有功功率单位
String power = unitMap.get(device.getId()+HomePageConstant.CONCAT_P);
if(StringUtil.isNotBlank(power)){
realVo.setPowerUnit(power);
} else {
realVo.setPowerUnit("kW");
}
// 无功功率
String reactivePowerUnit = unitMap.get(device.getId()+HomePageConstant.CONCAT_Q);
if(StringUtil.isNotBlank(reactivePowerUnit)){
realVo.setReactivePowerUnit(reactivePowerUnit);
} else {
realVo.setReactivePowerUnit("kVa r");
}
// 定子电压单位
String voltage = unitMap.get(device.getId()+HomePageConstant.CONCAT_UAB);
if(StringUtil.isNotBlank(voltage)){
realVo.setVoltageUnit(voltage);
} else {
realVo.setVoltageUnit("V");
}
// 定子电流单位
String current = unitMap.get(device.getId()+HomePageConstant.CONCAT_IA);
if(StringUtil.isNotBlank(current)){
realVo.setCurrentUnit(current);
} else {
realVo.setCurrentUnit("A");
}
}
/**
* 获取年日发电量
* @param device
* @param scope
* @return
*/
private float getGenerationPower(EminfoAndEmParamVo device,int scope) {
String start,end;
int accessRules;
Calendar calendar = Calendar.getInstance();
switch (scope){
// 年
case 0:
end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
accessRules = EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType();
break;
// 月
case 1:
start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00";
end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
accessRules = EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType();
break;
// 日
case 2:
String time = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
start = time + " 00:00:00";
end = time + " 23:59:59";
accessRules = EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType();
break;
default:
throw new IllegalStateException("Unexpected value: " + scope);
}
return analyseDataService.periodTargetFloat(start,end,5,accessRules,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
}
/**
* 近30天发电量
* @param device
* @return
*/
private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) {
String start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00";
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
if(CollectionUtil.isEmpty(records)){
return new ArrayList<>();
}
return records.stream().map(record -> {
GenerationPowerVo generate = new GenerationPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE));
generate.setGenerate(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount());
return generate;
}).collect(Collectors.toList());
}
/** /**
* 水电站-站点信息 * 水电站-站点信息
* @param deptId * @param deptId
@ -1097,7 +671,6 @@ public class HydropowerServiceImpl implements HydropowerService {
// 获取站点机组指标数据 // 获取站点机组指标数据
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key);
// 获取总发电量 // 获取总发电量
List<String> monList = this.mons(0,12,false);
List<AreaScaleVo> scales = areas.entrySet().stream().map(entry->{ List<AreaScaleVo> scales = areas.entrySet().stream().map(entry->{
AreaScaleVo scale = new AreaScaleVo(); AreaScaleVo scale = new AreaScaleVo();
scale.setDeptId(entry.getKey().getId()); scale.setDeptId(entry.getKey().getId());
@ -1554,14 +1127,6 @@ public class HydropowerServiceImpl implements HydropowerService {
} }
// 装机容量 // 装机容量
hydropower.setCapacity(reals.stream().filter(real-> real.getDeptId().equals(station.getRefDept()) && !ObjectUtil.isEmpty(real.getInstalledCapacity())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum()); hydropower.setCapacity(reals.stream().filter(real-> real.getDeptId().equals(station.getRefDept()) && !ObjectUtil.isEmpty(real.getInstalledCapacity())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum());
// 负荷
hydropower.setLoad(reals.stream().filter(real-> real.getDeptId().equals(station.getRefDept()) && !ObjectUtil.isEmpty(real.getActivePower())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum());
// 出力
if(Math.abs(hydropower.getCapacity()) > 0){
hydropower.setOutput(BigDecimal.valueOf(hydropower.getLoad() / hydropower.getCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}else{
hydropower.setOutput(0.0);
}
// 运行天数 // 运行天数
hydropower.setRunDay(this.getRunDay(station)); hydropower.setRunDay(this.getRunDay(station));
// 告警 // 告警
@ -1572,8 +1137,9 @@ public class HydropowerServiceImpl implements HydropowerService {
// 站点设备 // 站点设备
List<HydropowerUnitRealVo> devices = reals.stream().filter(real-> real.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); List<HydropowerUnitRealVo> devices = reals.stream().filter(real-> real.getDeptId().equals(station.getRefDept())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(devices)){ if(CollectionUtil.isNotEmpty(devices)){
// 设备 List<AppHydropowerDeviceVo> hydropowerDevices = new ArrayList<>();
hydropower.setDevices(devices.stream().map(real->{ Double loadSum = 0.0;
for(HydropowerUnitRealVo real : devices){
AppHydropowerDeviceVo device = new AppHydropowerDeviceVo(); AppHydropowerDeviceVo device = new AppHydropowerDeviceVo();
device.setOrd(real.getOrd()); device.setOrd(real.getOrd());
device.setDeviceCode(real.getDeviceCode()); device.setDeviceCode(real.getDeviceCode());
@ -1581,14 +1147,32 @@ public class HydropowerServiceImpl implements HydropowerService {
device.setOrd(real.getOrd()); device.setOrd(real.getOrd());
device.setState(real.getState()); device.setState(real.getState());
device.setLoadUnit(Optional.ofNullable(real.getPowerUnit()).orElse("kW")); device.setLoadUnit(Optional.ofNullable(real.getPowerUnit()).orElse("kW"));
if("MW".equalsIgnoreCase(device.getLoadUnit())){
loadSum += (real.getActivePower() * 1000);
}else{
loadSum += real.getActivePower();
}
device.setCapacity(real.getInstalledCapacity()); device.setCapacity(real.getInstalledCapacity());
device.setLoad(real.getActivePower()); device.setLoad(real.getActivePower());
return device; hydropowerDevices.add(device);
}).sorted(Comparator.comparing(AppHydropowerDeviceVo::getOrd)).collect(Collectors.toList()));
hydropower.setLoadUnit(hydropower.getDevices().get(0).getLoadUnit());
} }
// 设备
hydropower.setDevices(hydropowerDevices.stream().sorted(Comparator.comparing(AppHydropowerDeviceVo::getOrd)).collect(Collectors.toList()));
// 负荷
hydropower.setLoad(loadSum);
}else{
hydropower.setLoad(0.0);
}
// 出力
if(Math.abs(hydropower.getLoad()) > 0 && Math.abs(hydropower.getCapacity()) > 0){
hydropower.setOutput(BigDecimal.valueOf(hydropower.getLoad() / hydropower.getCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
}else{
hydropower.setOutput(0.0);
}
// 负荷单位
hydropower.setLoadUnit("kW");
return hydropower; return hydropower;
}).collect(Collectors.toList()); }).sorted(Comparator.comparing(AppHydropowerStationVo::getSort)).collect(Collectors.toList());
} }
/** /**
@ -1644,7 +1228,6 @@ public class HydropowerServiceImpl implements HydropowerService {
// 开始时间、结束时间 // 开始时间、结束时间
LocalDateTime localDateTime = LocalDateTime.ofInstant(duty.getDutyDate().toInstant(), ZoneId.systemDefault()); LocalDateTime localDateTime = LocalDateTime.ofInstant(duty.getDutyDate().toInstant(), ZoneId.systemDefault());
LocalDateTime startDate = localDateTime.withHour(duty.getStartTime().getHours()).withMinute(duty.getStartTime().getMinutes()).withSecond(0); LocalDateTime startDate = localDateTime.withHour(duty.getStartTime().getHours()).withMinute(duty.getStartTime().getMinutes()).withSecond(0);
//LocalDateTime endDate = localDateTime.withHour(duty.getEndTime().getHours()).withMinute(duty.getEndTime().getMinutes()).withSecond(00);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME);
String start = dtf.format(startDate); String start = dtf.format(startDate);
String end = dtf.format(LocalDateTime.now()); String end = dtf.format(LocalDateTime.now());
@ -1660,7 +1243,7 @@ public class HydropowerServiceImpl implements HydropowerService {
}); });
// 缺陷 // 缺陷
pool.execute(()-> { pool.execute(()-> {
this.getDutyDefect(item,startDate); this.getDutyDefect(item,start,end);
countDownLatch.countDown(); countDownLatch.countDown();
}); });
// 巡检 // 巡检
@ -1819,10 +1402,10 @@ public class HydropowerServiceImpl implements HydropowerService {
* @param item * @param item
* @param startTime * @param startTime
*/ */
private void getDutyDefect(AppAreaDutyVo item, LocalDateTime startTime) { private void getDutyDefect(AppAreaDutyVo item, String startTime,String endTime) {
LambdaQueryWrapper<OperPhenomenonEntity> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<OperPhenomenonEntity> wrapper = Wrappers.lambdaQuery();
wrapper.ge(OperPhenomenonEntity::getCreateTime,startTime); wrapper.ge(OperPhenomenonEntity::getCreateTime,startTime);
//wrapper.le(OperPhenomenonEntity::getCreateTime,endTime); wrapper.le(OperPhenomenonEntity::getCreateTime,endTime);
wrapper.eq(OperPhenomenonEntity::getIsDefect, TreatMethodConstant.IS_DEFECT); wrapper.eq(OperPhenomenonEntity::getIsDefect, TreatMethodConstant.IS_DEFECT);
wrapper.eq(OperPhenomenonEntity::getDiscriminateStatus,TreatMethodConstant.AUTO_SCREENED); wrapper.eq(OperPhenomenonEntity::getDiscriminateStatus,TreatMethodConstant.AUTO_SCREENED);
// 查询现象 // 查询现象

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

@ -947,7 +947,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
* *
* @param rideCount * @param rideCount
*/ */
public void unitYearGeneration(AnalyseCodeByAnalyseDataPO po, int rideCount, List<YearGenerationVo> yearGenerationVoList) { public void unitYearGeneration(AnalyseCodeByAnalyseDataPO po, Double rideCount, List<YearGenerationVo> yearGenerationVoList) {
R<List<AnalyzeDataConditionVO>> analyzeDataByAnalyzeCodeAndSignages = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); R<List<AnalyzeDataConditionVO>> analyzeDataByAnalyzeCodeAndSignages = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if (analyzeDataByAnalyzeCodeAndSignages.isSuccess() && CollectionUtil.isNotEmpty(analyzeDataByAnalyzeCodeAndSignages.getData())) { if (analyzeDataByAnalyzeCodeAndSignages.isSuccess() && CollectionUtil.isNotEmpty(analyzeDataByAnalyzeCodeAndSignages.getData())) {
@ -960,7 +960,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
YearGenerationVo yearGenerationVo = yearGenerationVoList.get(i); YearGenerationVo yearGenerationVo = yearGenerationVoList.get(i);
float count = 0; float count = 0;
if (StringUtil.isNotBlank(analyseDataTaosVO.getVal())) { if (StringUtil.isNotBlank(analyseDataTaosVO.getVal())) {
count = Float.valueOf(analyseDataTaosVO.getVal()) * rideCount; count = Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO.getVal()) * rideCount));
analyseDataTaosVO.setVal(count + ""); analyseDataTaosVO.setVal(count + "");
yearGenerationVo.setPracticalGeneration(yearGenerationVo.getPracticalGeneration() + count); yearGenerationVo.setPracticalGeneration(yearGenerationVo.getPracticalGeneration() + count);
} }
@ -1107,7 +1107,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
float childFloat = Float.parseFloat(analyseDataTaosVO.getVal()); float childFloat = Float.parseFloat(analyseDataTaosVO.getVal());
if (0 != em.getRideCount()) { if (0 != em.getRideCount()) {
//获取发电量的值 且 * rideCount //获取发电量的值 且 * rideCount
aFloat = childFloat * em.getRideCount(); aFloat = Float.parseFloat(String.valueOf(childFloat * em.getRideCount()));
} else { } else {
aFloat = childFloat; aFloat = childFloat;
} }
@ -1275,7 +1275,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
* @param rideCount * @param rideCount
* @param vo * @param vo
*/ */
private void getGenerat(String emCode, DateTimeFormatter df, int rideCount, MainVo vo) { private void getGenerat(String emCode, DateTimeFormatter df, Double rideCount, MainVo vo) {
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
po.setDeviceCode(emCode); po.setDeviceCode(emCode);
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>(); List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
@ -1312,7 +1312,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
* @param bool 是否 new ArrayList<>(); * @param bool 是否 new ArrayList<>();
*/ */
private void setValueGenerateCount(AnalyzeDataConditionPO analyzeDataConditionPO, private void setValueGenerateCount(AnalyzeDataConditionPO analyzeDataConditionPO,
List<AnalyzeDataConditionPO> signboardConditions, AnalyseCodeByAnalyseDataPO po, int rideCount, MainVo vo, int typeCycle, boolean bool) { List<AnalyzeDataConditionPO> signboardConditions, AnalyseCodeByAnalyseDataPO po, Double rideCount, MainVo vo, int typeCycle, boolean bool) {
analyzeDataConditionPO.setSaveTimeType(typeCycle); analyzeDataConditionPO.setSaveTimeType(typeCycle);
if (bool) { if (bool) {
signboardConditions = new ArrayList<>(); signboardConditions = new ArrayList<>();
@ -1329,7 +1329,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
if (ObjectUtil.isNotEmpty(analyseDataTaosVO1) && StringUtil.isNotBlank(analyseDataTaosVO1.getVal())) { if (ObjectUtil.isNotEmpty(analyseDataTaosVO1) && StringUtil.isNotBlank(analyseDataTaosVO1.getVal())) {
Float aFloat = Float.valueOf(analyseDataTaosVO1.getVal()); Float aFloat = Float.valueOf(analyseDataTaosVO1.getVal());
if (0 != rideCount) { if (0 != rideCount) {
aFloat = Float.valueOf(analyseDataTaosVO1.getVal()) * rideCount; //获取发电量的值 且 * rideCount aFloat = Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO1.getVal()) * rideCount));; //获取发电量的值 且 * rideCount
} }
if (typeCycle == EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType()) { if (typeCycle == EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType()) {
vo.setDayGenerateCount(aFloat); vo.setDayGenerateCount(aFloat);
@ -1424,20 +1424,20 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
if (CollectionUtil.isNotEmpty(emCodeList)) { if (CollectionUtil.isNotEmpty(emCodeList)) {
List<EmInfoEntity> data = emInfoClient.getEmInfoByEmCodes(emCodeList).getData(); List<EmInfoEntity> data = emInfoClient.getEmInfoByEmCodes(emCodeList).getData();
for (EmInfoEntity emInfoEntity : data) { for (EmInfoEntity emInfoEntity : data) {
int ct = 0; double ct = 0;
int pt = 0; double pt = 0;
R<EmParamEntity> EmParamEntityCT = emParamClient.getParamByEmId(emInfoEntity.getId(), "ct"); R<EmParamEntity> EmParamEntityCT = emParamClient.getParamByEmId(emInfoEntity.getId(), "ct");
if (EmParamEntityCT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityCT.getData()) if (EmParamEntityCT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityCT.getData())
&& StringUtil.isNotBlank(EmParamEntityCT.getData().getParamValue())) { && StringUtil.isNotBlank(EmParamEntityCT.getData().getParamValue())) {
ct = Integer.valueOf(EmParamEntityCT.getData().getParamValue()); ct = Double.parseDouble(EmParamEntityCT.getData().getParamValue());
} }
R<EmParamEntity> EmParamEntityPT = emParamClient.getParamByEmId(emInfoEntity.getId(), "pt"); R<EmParamEntity> EmParamEntityPT = emParamClient.getParamByEmId(emInfoEntity.getId(), "pt");
if (EmParamEntityPT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityPT.getData()) if (EmParamEntityPT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityPT.getData())
&& StringUtil.isNotBlank(EmParamEntityPT.getData().getParamValue())) { && StringUtil.isNotBlank(EmParamEntityPT.getData().getParamValue())) {
pt = Integer.valueOf(EmParamEntityPT.getData().getParamValue()); pt = Double.parseDouble(EmParamEntityPT.getData().getParamValue());
} }
//TODO //TODO
int rideCount = ct * pt; double rideCount = ct * pt;
MainVo vo = new MainVo(); MainVo vo = new MainVo();
MainVo yearVo = new MainVo(); MainVo yearVo = new MainVo();
R<EmParamEntity> paramByEmId = emParamClient.getParamByEmId(emInfoEntity.getId(), EquipmentConstants.MainEnum.INSTALLED_CAPACITY.getVal()); R<EmParamEntity> paramByEmId = emParamClient.getParamByEmId(emInfoEntity.getId(), EquipmentConstants.MainEnum.INSTALLED_CAPACITY.getVal());
@ -1467,8 +1467,8 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
//年发电量 //年发电量
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(year + "-01-01 00:00:00", df)); analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(year + "-01-01 00:00:00", df));
setValueGenerateCount(analyzeDataConditionPO, signboardConditions, po, rideCount, vo, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), true); setValueGenerateCount(analyzeDataConditionPO, signboardConditions, po, rideCount, vo, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), true);
powerCount.updateAndGet(v -> new Float(v + vo.getMonthGenerateCount())); powerCount.updateAndGet(v -> v + vo.getMonthGenerateCount());
powerCountYear.updateAndGet(v -> new Float(v + yearVo.getYearGenerateCount())); powerCountYear.updateAndGet(v -> v + yearVo.getYearGenerateCount());
log.info("------------月发电量:[{}]--------", vo.getMonthGenerateCount()); log.info("------------月发电量:[{}]--------", vo.getMonthGenerateCount());
} }
} }
@ -1540,20 +1540,20 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
if (CollectionUtil.isNotEmpty(emCodeList)) { if (CollectionUtil.isNotEmpty(emCodeList)) {
List<EmInfoEntity> data = emInfoClient.getEmInfoByEmCodes(emCodeList).getData(); List<EmInfoEntity> data = emInfoClient.getEmInfoByEmCodes(emCodeList).getData();
for (EmInfoEntity emInfoEntity : data) { for (EmInfoEntity emInfoEntity : data) {
int ct = 0; double ct = 0;
int pt = 0; double pt = 0;
R<EmParamEntity> EmParamEntityCT = emParamClient.getParamByEmId(emInfoEntity.getId(), "ct"); R<EmParamEntity> EmParamEntityCT = emParamClient.getParamByEmId(emInfoEntity.getId(), "ct");
if (EmParamEntityCT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityCT.getData()) if (EmParamEntityCT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityCT.getData())
&& StringUtil.isNotBlank(EmParamEntityCT.getData().getParamValue())) { && StringUtil.isNotBlank(EmParamEntityCT.getData().getParamValue())) {
ct = Integer.valueOf(EmParamEntityCT.getData().getParamValue()); ct = Double.parseDouble(EmParamEntityCT.getData().getParamValue());
} }
R<EmParamEntity> EmParamEntityPT = emParamClient.getParamByEmId(emInfoEntity.getId(), "pt"); R<EmParamEntity> EmParamEntityPT = emParamClient.getParamByEmId(emInfoEntity.getId(), "pt");
if (EmParamEntityPT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityPT.getData()) if (EmParamEntityPT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityPT.getData())
&& StringUtil.isNotBlank(EmParamEntityPT.getData().getParamValue())) { && StringUtil.isNotBlank(EmParamEntityPT.getData().getParamValue())) {
pt = Integer.valueOf(EmParamEntityPT.getData().getParamValue()); pt = Double.parseDouble(EmParamEntityPT.getData().getParamValue());
} }
//TODO //TODO
int rideCount = ct * pt; double rideCount = ct * pt;
MainVo vo = new MainVo(); MainVo vo = new MainVo();
R<EmParamEntity> paramByEmId = emParamClient.getParamByEmId(emInfoEntity.getId(), EquipmentConstants.MainEnum.INSTALLED_CAPACITY.getVal()); R<EmParamEntity> paramByEmId = emParamClient.getParamByEmId(emInfoEntity.getId(), EquipmentConstants.MainEnum.INSTALLED_CAPACITY.getVal());
if (paramByEmId.isSuccess()) { if (paramByEmId.isSuccess()) {
@ -1579,7 +1579,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
String endDateTime = fmt.format(localDateMonth.with(TemporalAdjusters.lastDayOfMonth())) + " 23:59:59"; String endDateTime = fmt.format(localDateMonth.with(TemporalAdjusters.lastDayOfMonth())) + " 23:59:59";
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(endDateTime, df)); analyzeDataConditionPO.setEndTime(LocalDateTime.parse(endDateTime, df));
setValueGenerateCount(analyzeDataConditionPO, signboardConditions, po, rideCount, vo, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), true); setValueGenerateCount(analyzeDataConditionPO, signboardConditions, po, rideCount, vo, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), true);
powerCount.updateAndGet(v -> new Float(v + vo.getMonthGenerateCount())); powerCount.updateAndGet(v -> v + vo.getMonthGenerateCount());
log.info("------------月发电量:[{}]--------", vo.getMonthGenerateCount()); log.info("------------月发电量:[{}]--------", vo.getMonthGenerateCount());
} }
} }

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

@ -1,14 +1,11 @@
package com.hnac.hzims.operational.main.service.impl; package com.hnac.hzims.operational.main.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse;
import com.hnac.hzims.operational.fill.service.PowerService;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.service.*;
import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.main.vo.*;
@ -16,12 +13,7 @@ import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient; import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient;
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO;
import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient;
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
@ -69,10 +61,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
private final IMainTaskStatisticService taskService; private final IMainTaskStatisticService taskService;
private final PowerService generateService;
private final IHistoryDataSearchClient historySearchClient;
private final ISysClient sysClient; private final ISysClient sysClient;
private final ITicketInfoClient ticketInfoClient; private final ITicketInfoClient ticketInfoClient;
@ -92,532 +80,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
private final static int POOL_QUANTITY = 4; private final static int POOL_QUANTITY = 4;
/** /**
* 光伏站-逆变器实时加载
*
* @param param
*/
@Override
public void loadPhotovoltaicReal(String param) {
// 查询设备
List<EminfoAndEmParamVo> devices = this.getPhotovoltaicDevice();
if (CollectionUtil.isEmpty(devices)) {
return;
}
// 取redis实时数据
Map<String, String> map = this.getRealData();
if (MapUtils.isEmpty(map)) {
return;
}
// redis缓存设备实时数据
List<PhotovoltaicRealVo> history = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
// 设备实时数据
List<PhotovoltaicRealVo> list = devices.stream().map(device -> {
PhotovoltaicRealVo real = new PhotovoltaicRealVo();
real.setDeptId(device.getCreateDept());
real.setDeviceCode(device.getEmCode());
real.setDeviceName(device.getName());
real.setState(this.getPhotovoltaicState(device, map));
// 容量
real.setCapacity(device.getInstalledCapacity());
// 发电量
real.setGenerate(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.PV_GENERATION_CAPACITY)));
// 功率
real.setLoad(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.PV_LOAD)));
// 交流电压
real.setVoltage(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.PV_VOLTAGE)));
// 交流电流
real.setCurrent(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.PV_CURRENT)));
// 交流电压2
real.setVoltage_two(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.PV_VOLTAGE_TWO)));
// 交流电流2
real.setCurrent_two(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.PV_CURRENT_TWO)));
// 交流电压3
real.setVoltage_three(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.PV_VOLTAGE_THREE)));
// 交流电流3
real.setCurrent_three(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.PV_CURRENT_THREE)));
// 直流电流1
real.setDirect_one(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_ONE)));
// 直流电流2
real.setDirect_two(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_TWO)));
// 直流电流3
real.setDirect_three(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_THREE)));
// 直流电流4
real.setDirect_four(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_FOUR)));
// 直流电流5
real.setDirect_five(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_FIVE)));
// 直流电流6
real.setDirect_six(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_SIX)));
// 直流电流7
real.setDirect_seven(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_SEVEN)));
// 直流电流8
real.setDirect_eight(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_EIGHT)));
// 直流电流9
real.setDirect_nine(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_NINE)));
// 直流电流10
real.setDirect_ten(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_TEN)));
// 直流电流11
real.setDirect_eleven(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_ELEVEN)));
// 直流电流12
real.setDirect_twelve(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_TWELVE)));
// 直流电压1
real.setDc_voltage_one(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_ONE)));
// 直流电压2
real.setDc_voltage_two(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_TWO)));
// 直流电压3
real.setDc_voltage_three(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_THREE)));
// 直流电压4
real.setDc_voltage_four(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_FOUR)));
// 直流电压5
real.setDc_voltage_five(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_FIVE)));
// 直流电压6
real.setDc_voltage_six(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_SIX)));
// 直流电压7
real.setDc_voltage_seven(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_SEVEN)));
// 直流电压8
real.setDc_voltage_eight(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_EIGHT)));
// 直流电压9
real.setDc_voltage_nine(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_NINE)));
// 直流电压10
real.setDc_voltage_ten(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_TEN)));
// 直流电压11
real.setDc_voltage_eleven(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_ELEVEN)));
// 直流电压12
real.setDc_voltage_twelve(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DC_VOLTAGE_TWELVE)));
// 串流电流1
real.setDirect_one(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.DIRECT_ONE)));
// 串流电流2
real.setSeries_two(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_TWO)));
// 串流电流3
real.setSeries_three(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_THREE)));
// 串流电流4
real.setSeries_four(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_FOUR)));
// 串流电流5
real.setSeries_five(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_FIVE)));
// 串流电流6
real.setSeries_six(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_SIX)));
// 串流电流7
real.setSeries_seven(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_SEVEN)));
// 串流电流8
real.setSeries_eight(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_EIGHT)));
// 串流电流9
real.setSeries_nine(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_NINE)));
// 串流电流10
real.setSeries_ten(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_TEN)));
// 串流电流11
real.setSeries_eleven(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_ELEVEN)));
// 串流电流12
real.setSeries_twelve(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SERIES_TWELVE)));
// 串流电压1
real.setSe_voltage_one(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_ONE)));
// 串流电压2
real.setSe_voltage_two(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_TWO)));
// 串流电压3
real.setSe_voltage_three(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_THREE)));
// 串流电压4
real.setSe_voltage_four(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_FOUR)));
// 串流电压5
real.setSe_voltage_five(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_FIVE)));
// 串流电压6
real.setSe_voltage_six(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_SIX)));
// 串流电压7
real.setSe_voltage_seven(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_SEVEN)));
// 串流电压8
real.setSe_voltage_eight(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_EIGHT)));
// 串流电压9
real.setSe_voltage_nine(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_NINE)));
// 串流电压10
real.setSe_voltage_ten(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_TEN)));
// 串流电压11
real.setSe_voltage_eleven(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_ELEVEN)));
// 串流电压12
real.setSe_voltage_twelve(Double.valueOf(this.getSignageValue(device, map, HomePageConstant.SE_VOLTAGE_TWELVE)));
// 上次功率
real.setLastLoad(this.getLastLoad(device, history));
return real;
}).collect(Collectors.toList());
// 存储redis
redisTemplate.opsForValue().set(load_photovoltaic_real_key, list);
}
/**
* 光伏站-逆变器指标加载
*
* @param param
*/
@Override
public void loadPhotovoltaicTarget(String param) {
// 有效设备
List<EminfoAndEmParamVo> devices = this.getPhotovoltaicDevice();
if (CollectionUtil.isEmpty(devices)) {
return;
}
List<PhotovoltaicTargetVo> list = new ArrayList<>();
// 接入站点设备统计
devices.forEach(device -> {
PhotovoltaicTargetVo target = new PhotovoltaicTargetVo();
target.setDeptId(device.getCreateDept());
target.setDeviceCode(device.getEmCode());
target.setDeviceName(device.getName());
target.setDeptName(device.getName());
// 当日运行时长
target.setRunHours(this.runHours(device.getPoint().get(HomePageConstant.PV_JOINT_RELAY)));
// 年发电量
target.setGenerationYear((double) this.sumValueByTime(device.getEmCode(), device.getRideCount(), "0"));
// 月发电量
target.setGenerationMon((double) this.sumValueByTime(device.getEmCode(), device.getRideCount(), "1"));
// 日发电量
target.setGenerationDay((double) this.sumValueByTime(device.getEmCode(), device.getRideCount(), "2"));
// 昨日发电量
target.setGenerationYesterday((double) this.sumValueByTime(device.getEmCode(), device.getRideCount(), "3"));
// 收益
target.setIncome(target.getGenerationDay() * 0.34);
// 节约标准煤
target.setTec(target.getGenerationMon() * 0.0001229);
// 二氧化碳减排
target.setCo2(target.getGenerationMon() * 0.000997);
// 减少森林砍伐
target.setDeforest(target.getGenerationMon() * 0.000553);
// 当天有功功率
target.setActivePowerVoList(this.getLoadsByDay(device));
// 30天发电量
target.setGenerationPowerVoList(this.getGenerateByMon(device));
list.add(target);
});
// 补充站点填报发电量
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC)
.eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE)
);
if(CollectionUtil.isNotEmpty(stations)){
list.addAll(this.generateFill(stations));
}
redisTemplate.opsForValue().set(load_photovoltaic_target_key, list);
}
/**
* 当天有功功率
*
* @param device
* @return
*/
private List<PhotovoltaicPowerVo> getLoadsByDay(EminfoAndEmParamVo device) {
String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00";
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start, end, 1, 2, device.getEmCode(), HomePageConstant.PV_LOAD);
if (CollectionUtil.isEmpty(records)) {
return new ArrayList<>();
}
return records.stream().map(record -> {
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
load.setHour(time.getHours());
load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0"));
return load;
}).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList());
}
/**
* 近30天发电量
*
* @param device
* @return
*/
private List<GenerationPowerVo> getGenerateByMon(EminfoAndEmParamVo device) {
Calendar calendar = Calendar.getInstance();
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.DAY_OF_MONTH, -29);
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<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start, end, 5, 3, device.getEmCode(), HomePageConstant.PV_GENERATION_CAPACITY);
if (CollectionUtil.isEmpty(records)) {
return new ArrayList<>();
}
return records.stream().map(record -> {
GenerationPowerVo generate = new GenerationPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setDate(DateUtil.format(time, DateUtil.PATTERN_DATE));
generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0")));
return generate;
}).sorted(Comparator.comparing(GenerationPowerVo::getDate)).collect(Collectors.toList());
}
/**
* 获取光伏站点填报数据
* @param stations
* @return
*/
private List<PhotovoltaicTargetVo> generateFill(List<StationEntity> stations) {
Calendar calendar = Calendar.getInstance();
String mon = DateUtil.format(calendar.getTime(),"yyyy-MM");
String year = String.valueOf(calendar.get(Calendar.YEAR));
return stations.stream().map(station ->{
PhotovoltaicTargetVo target = new PhotovoltaicTargetVo();
target.setDeptId(station.getRefDept());
target.setDeptName(station.getName());
// 当日运行时长
target.setRunHours(0.0);
// 日发电量
target.setGenerationDay(0.0);
// 昨日发电量
target.setGenerationYesterday(0.0);
// 收益
target.setIncome(0.0);
// 日发电量
// 月发电量
target.setGenerationMon(generateService.generate(mon,station.getRefDept()));
// 节约标准煤
target.setTec(target.getGenerationMon() * 0.0001229);
// 二氧化碳减排
target.setCo2(target.getGenerationMon() * 0.000997);
// 减少森林砍伐
target.setDeforest(target.getGenerationMon() * 0.000553);
// 年发电量
target.setGenerationYear(generateService.generate(year,station.getRefDept()));
// 30天发电量
return target;
}).collect(Collectors.toList());
}
/**
* 根据事件查询数据值
*
* @param deviceCode
* @param rideCount
* @param type
* @return
*/
private float sumValueByTime(String deviceCode, int rideCount, String type) {
Calendar calendar = Calendar.getInstance();
String start, end;
int cycleType = 3;
switch (type) {
//年
case "0":
calendar.add(Calendar.HOUR_OF_DAY, +1);
end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DAY_OF_MONTH, -calendar.get(Calendar.DATE) + 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));
start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
cycleType = 6;
break;
//月
case "1":
start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00";
end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
cycleType = 5;
break;
//日
case "2":
start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00";
end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
break;
//昨日
case "3":
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));
start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
end = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00";
break;
default:
throw new ServiceException("无效查询类型!");
}
return analyseDataService.periodTargetFloat(start, end, 5, cycleType, deviceCode, rideCount, HomePageConstant.PV_GENERATION_CAPACITY);
}
/**
* 获取上一次功率
*
* @param device
* @param history
* @return
*/
private Double getLastLoad(EminfoAndEmParamVo device, List<PhotovoltaicRealVo> history) {
if (CollectionUtil.isEmpty(history)) {
return 0.0;
}
List<PhotovoltaicRealVo> historyDevice = history.stream().filter(o -> o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(historyDevice)) {
return 0.0;
}
return historyDevice.get(0).getLoad();
}
/**
* 获取开机状态
*
* @param device
* @return
*/
private int getPhotovoltaicState(EminfoAndEmParamVo device, Map<String, String> map) {
// 获取开关机监测点实时数据
String value = this.getSignageValue(device, map, HomePageConstant.PV_JOINT_RELAY);
// 开机状态
if (HomePageConstant.OFF.equals(value)) {
return 0;
}
return 1;
}
/**
* 获取监测点实时数据
*
* @param em
* @param map
* @param targets
* @return
*/
private String getSignageValue(EminfoAndEmParamVo em, Map<String, String> map, String targets) {
if (ObjectUtil.isEmpty(em) || MapUtils.isEmpty(map)) {
return "0";
}
Map<String, String> point = em.getPoint();
if (MapUtils.isEmpty(point)) {
return "0";
}
String realId = point.get(targets);
if (StringUtil.isEmpty(realId)) {
return "0";
}
String value = map.get(realId);
if (StringUtil.isEmpty(value)) {
return "0";
}
// 获取value
return value;
}
/**
* 当天运行时长
*
* @param realId
* @return
*/
private Double runHours(String realId) {
Calendar calendar = Calendar.getInstance();
Date end = calendar.getTime();
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));
Date start = calendar.getTime();
OriginalDataQuery originalDataQuery = new OriginalDataQuery();
originalDataQuery.setRealId(realId);
originalDataQuery.setBeginTime(start);
originalDataQuery.setEndTime(end);
originalDataQuery.setLimit(100000);
originalDataQuery.setPage(1);
// 查询时间范围开关机监测点历史数据
Result<HzPage<PointData>> R = historySearchClient.getOriginalDataByRealIds(originalDataQuery);
if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) {
return 0.0;
}
// 过滤相邻开关机状态相同数据
List<PointData> result = this.filterData(R.getData().getRecords());
if (CollectionUtil.isEmpty(result)) {
return 0.0;
}
// 开机运行时长
long time = this.runTime(result, start, end);
return BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
/**
* 当天运行时长
*
* @return
*/
private List<String> getDayHours() {
List<String> list = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
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));
// 获取时间
while (calendar.getTime().compareTo(new Date()) <= 0) {
list.add(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)));
calendar.add(Calendar.HOUR_OF_DAY, +1);
}
return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
}
/**
* 过滤相邻开关机状态相同数据
*
* @param list
* @return
*/
private List<PointData> filterData(List<PointData> list) {
if (CollectionUtil.isEmpty(list)) {
return null;
}
List<PointData> result = new ArrayList<>();
// 遍历数据
for (int i = 0; i < list.size(); i++) {
// 第一个数据保存下来
if (i == 0) {
result.add(list.get(i));
continue;
}
// 遍历数据状态
String value = list.get(i).getValue();
if (StringUtil.isBlank(value)) {
continue;
}
// 上一条数据状态
String up_value = list.get(i - 1).getValue();
if (value.equals(up_value)) {
continue;
}
result.add(list.get(i));
}
return result;
}
/**
* 获取运行时长
*
* @param result
* @return
*/
private long runTime(List<PointData> result, Date startDate, Date endDate) {
if (result.size() == 1) {
// 一直开机
if (HomePageConstant.PHOTOVOLTAIC_OFF.equals(result.get(0).getValue())) {
return endDate.getTime() - startDate.getTime();
}
// 一直关机
return 0;
}
long time = 0;
// 遍历累计开机时长
for (int i = 0; i < result.size(); i++) {
// 记录为开机状态 就计算到下次关机的时间差
if (HomePageConstant.ON.equals(result.get(i).getValue())) {
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;
}
/**
* 获取近30天集合 * 获取近30天集合
* *
* @return * @return
@ -641,41 +103,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} }
/** /**
* 获取实时数据
*
* @return
*/
private Map<String, String> getRealData() {
String json = (String) redisTemplate.opsForValue().get(real_id_key);
if (StringUtil.isBlank(json)) {
return null;
}
return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {
});
}
/**
* 获取光伏设备
*
* @return
*/
private List<EminfoAndEmParamVo> getPhotovoltaicDevice() {
// 光伏站点
List<StationEntity> stations = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC), null,true);
if (CollectionUtil.isEmpty(stations)) {
return null;
}
// 设备
List<EminfoAndEmParamVo> devices = deviceService.getEmInfoList();
if (CollectionUtil.isEmpty(devices)) {
return null;
}
return devices.stream().filter(device ->
stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getCreateDept())
).collect(Collectors.toList());
}
/**
* 集团/区域关键指标 * 集团/区域关键指标
* *
* @param deptId * @param deptId
@ -699,7 +126,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
// 容量 // 容量
kpi.setInstalledCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); kpi.setInstalledCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
// 负荷 // 负荷
kpi.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum()); kpi.setLoad(reals.stream().filter(o-> !ObjectUtil.isEmpty(o.getLoad())).mapToDouble(PhotovoltaicRealVo::getLoad).sum());
} }
} }
// 指标数据 // 指标数据
@ -946,7 +373,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
subordinate.setStationCount((long) entry.getValue().size()); subordinate.setStationCount((long) entry.getValue().size());
subordinate.setStationUseCount(reals.stream().filter(device -> device.getState() == 1).map(PhotovoltaicRealVo::getDeptId).distinct().count()); subordinate.setStationUseCount(reals.stream().filter(device -> device.getState() == 1).map(PhotovoltaicRealVo::getDeptId).distinct().count());
subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum()); subordinate.setLoad(reals.stream().filter(o-> !ObjectUtil.isEmpty(o.getLoad())).mapToDouble(PhotovoltaicRealVo::getLoad).sum());
} }
// 区域/站点 设备指标数据 // 区域/站点 设备指标数据
if (deviceTargets != null) { if (deviceTargets != null) {
@ -1515,31 +942,35 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return; return;
} }
// 容量 // 容量
photovoltaic.setCapacity(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getCapacity).sum()); photovoltaic.setCapacity(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getCapacity())).mapToDouble(PhotovoltaicDeviceVo::getCapacity).sum());
// 总发电量 // 总发电量
photovoltaic.setGenerate(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerate).sum()); photovoltaic.setGenerate(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerate())).mapToDouble(PhotovoltaicDeviceVo::getGenerate).sum());
// 收益 // // 收益
if(ObjectUtil.isEmpty(photovoltaic.getGenerate())){
photovoltaic.setIncome(0.0);
}else{
photovoltaic.setIncome(photovoltaic.getGenerate() * 0.34); photovoltaic.setIncome(photovoltaic.getGenerate() * 0.34);
}
// 年发电量 // 年发电量
photovoltaic.setGenerateYear(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateYear).sum()); photovoltaic.setGenerateYear(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerateYear())).mapToDouble(PhotovoltaicDeviceVo::getGenerateYear).sum());
// 月发电量 // 月发电量
photovoltaic.setGenerateMon(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateMon).sum()); photovoltaic.setGenerateMon(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerateMon())).mapToDouble(PhotovoltaicDeviceVo::getGenerateMon).sum());
// 日发电量 // 日发电量
photovoltaic.setGenerateDay(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateDay).sum()); photovoltaic.setGenerateDay(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerateDay())).mapToDouble(PhotovoltaicDeviceVo::getGenerateDay).sum());
// 功率 // 功率
photovoltaic.setLoad(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getLoad).sum()); photovoltaic.setLoad(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getLoad())).mapToDouble(PhotovoltaicDeviceVo::getLoad).sum());
double generationDay = photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateDay).sum(); double generationDay = photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerateDay())).mapToDouble(PhotovoltaicDeviceVo::getGenerateDay).sum();
double generationYesterday = photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerationYesterday).sum(); double generationYesterday = photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerationYesterday())).mapToDouble(PhotovoltaicDeviceVo::getGenerationYesterday).sum();
// 环比发电量 // 环比发电量
if (Math.abs(generationDay) <= 0 || Math.abs(generationYesterday) <= 0) { if (ObjectUtil.isEmpty(generationDay) || ObjectUtil.isEmpty(generationYesterday) || Math.abs(generationDay) <= 0 || Math.abs(generationYesterday) <= 0) {
photovoltaic.setGenerateDayRatio(0.0); photovoltaic.setGenerateDayRatio(0.0);
} else { } else {
photovoltaic.setGenerateDayRatio(BigDecimal.valueOf((generationDay - generationYesterday) / generationYesterday * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); photovoltaic.setGenerateDayRatio(BigDecimal.valueOf((generationDay - generationYesterday) / generationYesterday * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
} }
double load = photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getLoad).sum(); double load = photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getLoad())).mapToDouble(PhotovoltaicDeviceVo::getLoad).sum();
double lastLoad = photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getLastLoad).sum(); double lastLoad = photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getLastLoad())).mapToDouble(PhotovoltaicDeviceVo::getLastLoad).sum();
// 环比功率 // 环比功率
if (Math.abs(load) <= 0 || Math.abs(lastLoad) <= 0) { if (ObjectUtil.isEmpty(load) || ObjectUtil.isEmpty(lastLoad) || Math.abs(load) <= 0 || Math.abs(lastLoad) <= 0) {
photovoltaic.setLoadRatio(0.0); photovoltaic.setLoadRatio(0.0);
} else { } else {
photovoltaic.setLoadRatio(BigDecimal.valueOf((load - lastLoad) / lastLoad * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); photovoltaic.setLoadRatio(BigDecimal.valueOf((load - lastLoad) / lastLoad * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());
@ -1710,7 +1141,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
// 串流电压12 // 串流电压12
item.setSe_voltage_twelve(mateReals.get(0).getSe_voltage_twelve()); item.setSe_voltage_twelve(mateReals.get(0).getSe_voltage_twelve());
// 环比功率 // 环比功率
if (Math.abs(mateReals.get(0).getLoad()) <= 0 || mateReals.get(0).getLastLoad() <= 0) { if (ObjectUtil.isEmpty(mateReals.get(0).getLoad()) || ObjectUtil.isEmpty(mateReals.get(0).getLastLoad()) || Math.abs(mateReals.get(0).getLoad()) <= 0 || mateReals.get(0).getLastLoad() <= 0) {
item.setLoadRatio(0.0); item.setLoadRatio(0.0);
} else { } else {
item.setLoadRatio(BigDecimal.valueOf((mateReals.get(0).getLoad() - mateReals.get(0).getLastLoad()) / mateReals.get(0).getLastLoad() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); item.setLoadRatio(BigDecimal.valueOf((mateReals.get(0).getLoad() - mateReals.get(0).getLastLoad()) / mateReals.get(0).getLastLoad() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue());

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

@ -150,666 +150,6 @@ public class SideHustleServiceImpl implements ISideHustleService {
// 线程数量 // 线程数量
private final static int POOL_QUANTITY = 4; private final static int POOL_QUANTITY = 4;
/**
* 加载区域值班数据
*
* @param param
*/
@Override
public void loadDutyInfo(String param) {
R<List<Dept>> R = sysClient.getDeptList();
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) {
return;
}
Map<Dept,List<StationEntity>> map = areaService.getAuthArea(R.getData(),null,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true);
if (MapUtils.isEmpty(map)) {
return;
}
// 查询所有区域值班/接班数据
List<DutyInfoVo> dutyInfoVoList = dutyMainService.getDutyData(map.keySet().stream().map(Dept::getId).collect(Collectors.toList()));
if(CollectionUtil.isEmpty(dutyInfoVoList)){
return;
}
// 所有设备
List<EminfoAndEmParamVo> deviceList = maintenanceTaskService.getEmInfoList();
List<AreaDutyVo> areaDutyVoList = new ArrayList<>();
map.forEach((key,value) -> {
List<Long> singlet = Collections.singletonList(key.getId());
AreaDutyVo areaDutyVo = new AreaDutyVo();
areaDutyVo.setDepartId(key.getId());
areaDutyVo.setDepartName(key.getDeptName());
areaDutyVo.setSort(key.getSort());
// 值班情况
this.dutySituation(dutyInfoVoList, key, areaDutyVo);
// 厂站运行情况
this.factoryStationRun(deviceList, value, areaDutyVo);
// 当月任务执行情况
this.executeTaskMonth(singlet, areaDutyVo);
// 获取区域当班时间
List<DutyInfoVo> dutyList = dutyInfoVoList.stream().filter(o -> key.getId().equals(o.getCreateDept())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(dutyList)) {
areaDutyVoList.add(areaDutyVo);
return;
}
Date startDate = this.getDutyStartTime(dutyList.get(0).getDateTime(),dutyList.get(0).getStartTime());
Date endDate = this.getDutyEndTime(dutyList.get(0).getDateTime(),dutyList.get(0).getStartTime(),dutyList.get(0).getEndTime());
areaDutyVo.setStartTimeDuty(DateUtil.format(startDate,DateUtil.PATTERN_DATETIME));
areaDutyVo.setEndTimeDuty(DateUtil.format(endDate,DateUtil.PATTERN_DATETIME));
// 上一班组发电量
this.getUpDutyPower(dutyList,deviceList,key.getId(),value,areaDutyVo);
// 班组实时发电量
this.getDutyPower(startDate,endDate,deviceList,value,areaDutyVo,false);
// 当班双票
this.dutyDoubleTicket(startDate,endDate,singlet,areaDutyVo);
// 当班运行数据
this.dutyRunCondition(startDate,endDate,singlet,areaDutyVo);
areaDutyVoList.add(areaDutyVo);
});
XxlJobLogger.log("结果为:"+ JSON.toJSONString(areaDutyVoList));
redisTemplate.opsForValue().set(areaDutyInfoKey, areaDutyVoList);
}
/**
* 获取当班任务
* @param dateTime
* @param startTime
* @param endTime
* @param createDept
*/
private String getTaskCount(Date dateTime, Time startTime, Time endTime, Long createDept) {
DutyTaskVo task = new DutyTaskVo();
//通过线程池异步获取月报各模块内容 主要分为五块内容
ExecutorService exe = Executors.newFixedThreadPool(POOL_QUANTITY);
//监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY);
List<Long> list = Collections.singletonList(createDept);
String start = sdf.format(this.getDutyStartTime(dateTime,startTime));
String end = sdf.format(this.getDutyEndTime(dateTime,startTime,endTime));
XxlJobLogger.log("当班值班情况传参为:"+start+","+end+","+createDept);
// 日常维护
exe.execute(()->{
MaintainVo maintainVo = mainTaskStatisticService.getMaintain(start,end,list);
int maintainSum = maintainVo.getMaintain();
int maintainFinish = maintainVo.getMaintainFinish();
task.setMaintainSum(maintainSum);
task.setMaintainFinish(maintainFinish);
countDownLatch.countDown();
});
// 消缺
exe.execute(()->{
ShortagesVo shortagesVo = mainTaskStatisticService.getShortage(start,end,list);
int shortagesSum = shortagesVo.getShortagesSum();
int shortages = shortagesVo.getShortages();
task.setShortagesSum(shortagesSum);
task.setShortages(shortages);
countDownLatch.countDown();
});
// 检修
exe.execute(()->{
OverhaulVo overhaulVo = mainTaskStatisticService.getOverhaul(start,end,list);
int overhaul = overhaulVo.getOverhaul();
int overhaulFinish = overhaulVo.getOverhaulFinish();
task.setOverhaul(overhaul);
task.setOverhaulFinish(overhaulFinish);
countDownLatch.countDown();
});
// 巡检
exe.execute(()->{
// 巡检任务
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("startDate",start);
paramMap.put("endDate",end);
paramMap.put("deptList",list);
R<DutyInspectTaskVO> R = inspectTaskReportClient.getDutyInspectTask(paramMap);
if(R.isSuccess() && ObjectUtil.isNotEmpty(R.getData())){
int inspect = R.getData().getInspectTaskSum();
int inspectFinish = R.getData().getInspectTaskFinish();
task.setInspect(inspect);
task.setInspectFinish(inspectFinish);
}else{
task.setInspect(0);
task.setInspectFinish(0);
}
countDownLatch.countDown();
});
// 等待所有线程执行完成
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
exe.shutdown();
XxlJobLogger.log("当班运行任务情况为:maintenance -> sum:"+task.getMaintainSum()+",finish:"+task.getMaintainFinish());
XxlJobLogger.log("当班运行任务情况为:shortages -> sum:"+task.getShortagesSum()+",finish:"+task.getShortages());
XxlJobLogger.log("当班运行任务情况为:overhaul -> sum:"+task.getOverhaul()+",finish:"+task.getOverhaulFinish());
XxlJobLogger.log("当班运行任务情况为:inspect -> sum:"+task.getInspect()+",finish:"+task.getInspectFinish());
return (task.getMaintainSum() + task.getShortagesSum() + task.getOverhaul() + task.getInspect()) + "|" +
(task.getMaintainFinish() + task.getShortages() + task.getOverhaulFinish() + task.getInspectFinish());
}
/**
* 设备分类
*
* @param param
*/
@Override
public void deviceClassify(String param) {
// 获取所有设备
List<EminfoAndEmParamVo> deviceList = maintenanceTaskService.getEmInfoList();
if(CollectionUtil.isEmpty(deviceList)){
return;
}
// 实时数据
String json = (String) redisTemplate.opsForValue().get(real_id_key);
Map<String, String> realMap = null;
if (StringUtil.isNotBlank(json)) {
realMap = JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {});
}
Map<String,List<String>> deviceClassifyMap = new HashMap<>();
List<String> deviceCodeList = deviceList.stream().map(EminfoAndEmParamVo::getEmCode).collect(Collectors.toList());
// 故障
List<OperPhenomenonEntity> operPhenomenonEntityList = operPhenomenonService.list(new QueryWrapper<OperPhenomenonEntity>() {{
in("EM_CODE", deviceCodeList);
ne("IS_DEFECT",DefectConstant.IsDefectStatusEnum.IS_DEFECT.getStatus());
ne("CONCLUSION_STATUS", DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus());
}});
List<String> faultList = operPhenomenonEntityList.stream().map(OperPhenomenonEntity::getEmCode).distinct().collect(Collectors.toList());
deviceClassifyMap.put(HomePageConstant.FAULT,faultList);
// 检修
List<OperAccessTaskEntity> operAccessTaskEntityList = operAccessTaskService.list(new QueryWrapper<OperAccessTaskEntity>() {{
in("EM_CODE", deviceCodeList);
ne("STATUS", AccessConstants.ACCESS_TASK_STATUS_4);
}});
List<String> overhaulList = operAccessTaskEntityList.stream().map(OperAccessTaskEntity::getEmCode).distinct().collect(Collectors.toList());
List<String> overhaulOldList = deviceList.stream().filter(o-> !faultList.contains(o.getEmCode()) && !overhaulList.contains(o.getEmCode()) && (Func.isNotEmpty(o.getRunStatus()) && EquipmentConstants.RunStatus.access.getStatus().equals(o.getRunStatus())))
.map(EminfoAndEmParamVo::getEmCode).collect(Collectors.toList());
overhaulList.addAll(overhaulOldList);
deviceClassifyMap.put(HomePageConstant.OVERHAUL,overhaulList);
// 运行
List<EminfoAndEmParamVo> runDeviceList = deviceList.stream().filter(o-> !faultList.contains(o.getEmCode()) && !overhaulList.contains(o.getEmCode())).distinct().collect(Collectors.toList());
List<String> runList = this.getRunDeviceList(runDeviceList,realMap);
deviceClassifyMap.put(HomePageConstant.RUN,runList);
// 备用
List<String> spareList = deviceList.stream().filter(o-> !faultList.contains(o.getEmCode()) && !overhaulList.contains(o.getEmCode()) && !runList.contains(o.getEmCode()) && Func.isNotEmpty(o.getRunStatus())
&& EquipmentConstants.RunStatus.spare.getStatus().equals(o.getRunStatus()))
.map(EminfoAndEmParamVo::getEmCode).distinct().collect(Collectors.toList());
deviceClassifyMap.put(HomePageConstant.SPARE,spareList);
redisTemplate.opsForValue().set(deviceClassifyKey, deviceClassifyMap);
}
/**
* 获取运行设备列表
* @param runDeviceList
* @param realMap
* @return
*/
private List<String> getRunDeviceList(List<EminfoAndEmParamVo> runDeviceList, Map<String, String> realMap) {
return runDeviceList.stream().map(o ->{
Map<String,String> points = o.getPoint();
if(CollectionUtil.isEmpty(points)){
return "0";
}
String realId = points.get(HomePageConstant.JOINT_RELAY);
if(StringUtil.isEmpty(realId)){
return "0";
}
if(MapUtils.isEmpty(realMap)){
return "0";
}
String value = realMap.get(realId);
if(StringUtil.isEmpty(value)){
return "0";
}
if (value.contains("1") || "1.0".equals(value)) {
return o.getEmCode();
}
return "0";
}).distinct().collect(Collectors.toList());
}
/**
* 值班情况
*
* @param dutyInfoVoList
* @param dept
* @param areaDutyVo
*/
private void dutySituation(List<DutyInfoVo> dutyInfoVoList, Dept dept, AreaDutyVo areaDutyVo) {
if (CollectionUtil.isEmpty(dutyInfoVoList) || ObjectUtil.isEmpty(dept)) {
return;
}
Long deptId = dept.getId();
List<DutyInfoVo> filterList = dutyInfoVoList.stream().filter(o -> o.getCreateDept().equals(deptId)).collect(Collectors.toList());
if (CollectionUtil.isEmpty(filterList)) {
return;
}
DutyInfoVo dutyInfoVo = filterList.get(0);
areaDutyVo.setGeneratingCapacity(dutyInfoVo.getGeneratingCapacity());
areaDutyVo.setOnlineCapacity(dutyInfoVo.getOnlineCapacity());
areaDutyVo.setClassName(dutyInfoVo.getClassName());
areaDutyVo.setGroupName(dutyInfoVo.getGroupName());
areaDutyVo.setManagerName(dutyInfoVo.getManagerName());
areaDutyVo.setManagerPhone(dutyInfoVo.getManagerPhone());
areaDutyVo.setNextDutyInfoVo(dutyInfoVo.getNextDutyInfoVo());
// 当班任务
String taskCount = this.getTaskCount(dutyInfoVo.getDateTime(),dutyInfoVo.getStartTime(),dutyInfoVo.getEndTime(),dutyInfoVo.getCreateDept());
String[] task = taskCount.split("\\|");
areaDutyVo.setTaskCount(Integer.valueOf(task[0]));
areaDutyVo.setFinishTaskCount(Integer.valueOf(task[1]));
NextDutyInfoVo upDutyInfoVo = dutyInfoVo.getUpDutyInfoVo();
if(ObjectUtil.isEmpty(upDutyInfoVo)){
return;
}
// 上一班组当班任务
String upTaskCount = this.getTaskCount(upDutyInfoVo.getDateTime(),upDutyInfoVo.getStartTime(),upDutyInfoVo.getEndTime(),dutyInfoVo.getCreateDept());
String[] upTask = upTaskCount.split("\\|");
upDutyInfoVo.setTaskCount(Integer.valueOf(upTask[0]));
upDutyInfoVo.setFinishTaskCount(Integer.valueOf(upTask[1]));
areaDutyVo.setUpDutyInfoVo(upDutyInfoVo);
}
/**
* 厂站运行情况
*
* @param list
* @param areaDutyVo
*/
private void factoryStationRun(List<EminfoAndEmParamVo> deviceList,List<StationEntity> list, AreaDutyVo areaDutyVo) {
areaDutyVo.setStationSum(0);
areaDutyVo.setStationRun(0);
if (CollectionUtil.isEmpty(list) || CollectionUtil.isEmpty(deviceList)) {
return;
}
areaDutyVo.setStationSum(list.size());
List<Long> deptList = list.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtil.isEmpty(deptList)){
log.info("run_station_dept_list_null : {}",areaDutyVo.getDepartName());
return;
}
// 过滤未绑定设备
List<String> codes = deviceList.stream().filter(o->deptList.contains(o.getCreateDept())).map(EminfoAndEmParamVo::getEmCode).collect(Collectors.toList());
R<List<String>> R = instanceClient.getListAnalyseCode(codes);
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) {
log.info("run_station_valid_device_null : {}",areaDutyVo.getDepartName());
return;
}
// 根据机构分组
Map<Long, List<EminfoAndEmParamVo>> map = deviceList.stream().filter(o->R.getData().contains(o.getEmCode())).collect(Collectors.groupingBy(EminfoAndEmParamVo::getCreateDept));
if(CollectionUtil.isEmpty(map)){
log.info("run_station_group_by_valid_null : {}",areaDutyVo.getDepartName());
return;
}
int runCount = 0;
// 遍历分组设备
for(Map.Entry<Long, List<EminfoAndEmParamVo>> entry : map.entrySet()){
// 运行设备code集合
List<String> runCodes = entry.getValue().stream().filter(o -> (Func.isEmpty(o.getRunStatus()) || "1".equals(o.getRunStatus()))).map(EminfoAndEmParamVo::getEmCode).collect(Collectors.toList());
if(CollectionUtil.isEmpty(runCodes)){
return;
}
runCount++;
}
areaDutyVo.setStationRun(runCount);
areaDutyVo.setStationSum(list.size());
}
/**
* 上一班组发电量
* @param dutyList
* @param deviceList
* @param value
* @param areaDutyVo
*/
private void getUpDutyPower(List<DutyInfoVo> dutyList, List<EminfoAndEmParamVo> deviceList,Long deptId, List<StationEntity> value, AreaDutyVo areaDutyVo) {
List<DutyInfoVo> list = dutyList.stream().filter(o -> deptId.equals(o.getCreateDept())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(list)) {
return;
}
NextDutyInfoVo upDutyInfoVo = dutyList.get(0).getUpDutyInfoVo();
if(ObjectUtil.isEmpty(upDutyInfoVo)){
return;
}
// 上一班组开始时间、结束时间
Date startDate = getDutyStartTime(upDutyInfoVo.getDateTime(),upDutyInfoVo.getStartTime());
Date endDate = getDutyEndTime(upDutyInfoVo.getDateTime(),upDutyInfoVo.getStartTime(),upDutyInfoVo.getEndTime());
// 获取时间断内发电量
this.getDutyPower(startDate,endDate,deviceList,value,areaDutyVo,true);
}
/**
* 班组实时发电量
* @param startDate
* @param endDate
* @param deviceList
* @param list
* @param areaDutyVo
*/
private void getDutyPower(Date startDate, Date endDate, List<EminfoAndEmParamVo> deviceList,List<StationEntity> list,AreaDutyVo areaDutyVo,boolean flag) {
areaDutyVo.setGeneratingCapacity(0);
List<Long> deptList = list.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtil.isEmpty(deptList)){
return;
}
// 区域站点下设备
List<EminfoAndEmParamVo> devices = deviceList.stream().filter(o->deptList.contains(o.getCreateDept())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(devices)){
return;
}
// 获取当班时间内发电量
float generatingCapacity = this.generateByDuty(devices,startDate,endDate);
// 是否为查询上一班组发电量
if(flag){
NextDutyInfoVo upDutyInfoVo = areaDutyVo.getUpDutyInfoVo();
upDutyInfoVo.setGeneratingCapacity(generatingCapacity);
areaDutyVo.setUpDutyInfoVo(upDutyInfoVo);
return;
}
areaDutyVo.setGeneratingCapacity(generatingCapacity);
}
/***
* 根据当班时间查询发电量
* @param devices
* @param start
* @param end
* @return
*/
private float generateByDuty(List<EminfoAndEmParamVo> devices, Date start, Date end) {
float generate = 0f;
if(CollectionUtil.isEmpty(devices)){
return generate;
}
for(EminfoAndEmParamVo device : devices ){
generate += analyseDataService.periodTargetFloat(DateUtil.format(start,DateUtil.PATTERN_DATETIME),DateUtil.format(end,DateUtil.PATTERN_DATETIME),5,3,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
}
return generate;
}
/**
* 当班双票
* @param start
* @param end
* @param list
* @param areaDutyVo
*/
private void dutyDoubleTicket(Date start,Date end, List<Long> list,AreaDutyVo areaDutyVo) {
SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATETIME);
if (CollectionUtil.isEmpty(list)) {
areaDutyVo.setWorkTicketCount(0);
areaDutyVo.setHandoverTicketCount(0);
areaDutyVo.setVoidTicketCount(0);
areaDutyVo.setDeferredTicketCount(0);
areaDutyVo.setCloseTicketCount(0);
areaDutyVo.setOperationTicketCount(0);
return;
}
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("startDate", sdf.format(start));
paramMap.put("endDate", sdf.format(end));
paramMap.put("deptList", list);
R<WorkTicketStatisticVO> workR = ticketInfoClient.getWorkTicketStatistic(paramMap);
if (!workR.isSuccess() || ObjectUtil.isEmpty(workR.getData())) {
areaDutyVo.setWorkTicketCount(0);
areaDutyVo.setHandoverTicketCount(0);
areaDutyVo.setVoidTicketCount(0);
areaDutyVo.setDeferredTicketCount(0);
areaDutyVo.setCloseTicketCount(0);
}
WorkTicketStatisticVO workTicketStatisticVO = workR.getData();
areaDutyVo.setWorkTicketCount(workTicketStatisticVO.getTotal());
areaDutyVo.setHandoverTicketCount(workTicketStatisticVO.getTransfer());
areaDutyVo.setVoidTicketCount(workTicketStatisticVO.getInvalid());
areaDutyVo.setDeferredTicketCount(workTicketStatisticVO.getDelay());
areaDutyVo.setCloseTicketCount(workTicketStatisticVO.getComplete());
// 查询操作票
R<Integer> operateR = ticketInfoClient.getOperateTicketStatistic(paramMap);
if (ObjectUtil.isEmpty(operateR) || !operateR.isSuccess()) {
areaDutyVo.setOperationTicketCount(0);
return;
}
areaDutyVo.setOperationTicketCount(operateR.getData());
}
/**
* 获取开始时间
* @param date
* @param time
* @return
*/
private Date getDutyStartTime(Date date, Time time){
Calendar dateCal = Calendar.getInstance();
dateCal.setTime(date);
Calendar timeCal = Calendar.getInstance();
timeCal.setTime(time);
dateCal.set(Calendar.HOUR_OF_DAY, timeCal.get(Calendar.HOUR_OF_DAY));
dateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE));
dateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND));
return dateCal.getTime();
}
/**
* 获取结束时间
* @param date
* @param time
* @return
*/
private Date getDutyEndTime(Date date, Time time,Time endTime){
Calendar dateCal = Calendar.getInstance();
dateCal.setTime(date);
Calendar timeCal = Calendar.getInstance();
timeCal.setTime(time);
Calendar endCal = Calendar.getInstance();
endCal.setTime(endTime);
// 结束时间 < 开始时间
if(timeCal.after(endCal)){
dateCal.set(Calendar.DAY_OF_MONTH, dateCal.get(Calendar.DAY_OF_MONTH) + 1 );
}
dateCal.set(Calendar.HOUR_OF_DAY, endCal.get(Calendar.HOUR_OF_DAY));
dateCal.set(Calendar.MINUTE, endCal.get(Calendar.MINUTE));
dateCal.set(Calendar.SECOND, endCal.get(Calendar.SECOND));
return dateCal.getTime();
}
/**
* 当班运行数据
* @param start
* @param end
* @param childList
* @param areaDutyVo
*/
private void dutyRunCondition(Date start, Date end, List<Long> childList,AreaDutyVo areaDutyVo) {
String startTime = sdf.format(start);
String endTime = sdf.format(end);
// 巡检任务
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("startDate",startTime);
paramMap.put("endDate",endTime);
paramMap.put("deptList",childList);
R<DutyInspectTaskVO> R = inspectTaskReportClient.getDutyInspectTask(paramMap);
areaDutyVo.setInspectionSum(0);
areaDutyVo.setInspectionFinish(0);
if(R.isSuccess() && ObjectUtil.isNotEmpty(R.getData())){
areaDutyVo.setInspectionSum(R.getData().getInspectTaskSum());
areaDutyVo.setInspectionFinish(R.getData().getInspectTaskFinish());
if(Math.abs(R.getData().getInspectTaskSum()) <= 0){
areaDutyVo.setInspectionFinishRate(0.0);
}else{
double inspectionFinishRate = BigDecimal.valueOf(R.getData().getInspectTaskFinish() / (double)R.getData().getInspectTaskSum() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
areaDutyVo.setInspectionFinishRate(inspectionFinishRate);
}
areaDutyVo.setInspectTaskIds(R.getData().getInspectTaskIds());
}
// 消缺
DutyDefectVO defectVO = operPhenomenonService.getDutyDefect(startTime,endTime,childList);
areaDutyVo.setShortagesSum(0);
areaDutyVo.setShortages(0);
if(ObjectUtil.isNotEmpty(defectVO)){
areaDutyVo.setShortagesSum(defectVO.getDefectSum());
areaDutyVo.setShortages(defectVO.getDefect());
areaDutyVo.setPhenomenonIds(defectVO.getTotalIds());
if(Math.abs(defectVO.getDefectSum()) <= 0){
areaDutyVo.setShortagesRate(0.0);
}else{
double shortagesRate = BigDecimal.valueOf(defectVO.getDefect() / (double)defectVO.getDefectSum() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
areaDutyVo.setShortagesRate(shortagesRate);
}
}
// 定期工作
RegularWorkVO regularWorkVO = operMaintenanceTaskService.getDutyRegularWork(startTime,endTime,childList);
areaDutyVo.setWorkRegularlySum(0);
areaDutyVo.setWorkRegularly(0);
if(ObjectUtil.isNotEmpty(defectVO)){
areaDutyVo.setWorkRegularlySum(regularWorkVO.getRegularWorkSum());
areaDutyVo.setWorkRegularly(regularWorkVO.getRegularWork());
areaDutyVo.setMainTaskIds(regularWorkVO.getMainTaskIds());
if(Math.abs(areaDutyVo.getWorkRegularlySum()) <= 0){
areaDutyVo.setWorkRegularlyRate(0.0);
}else{
double workRegularlyRate = BigDecimal.valueOf(areaDutyVo.getWorkRegularly() / (double)areaDutyVo.getWorkRegularlySum() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue();
areaDutyVo.setWorkRegularlyRate(workRegularlyRate);
}
}
}
/**
* 当月任务执行情况
*
* @param list
* @param areaDutyVo
*/
private void executeTaskMonth(List<Long> list, AreaDutyVo areaDutyVo) {
if (CollectionUtil.isEmpty(list)) {
areaDutyVo.setMaintainSumMoth(0);
areaDutyVo.setMaintainFinishSumMoth(0);
areaDutyVo.setMaintainRateMoth("0");
areaDutyVo.setShortagesSumMoth(0);
areaDutyVo.setShortagesMoth(0);
areaDutyVo.setShortagesRateMoth("0");
areaDutyVo.setOverhaulSumMoth(0);
areaDutyVo.setOverhaulFinishSumMoth(0);
areaDutyVo.setOverhaulRateMoth("0");
areaDutyVo.setOperateSumMoth(0);
areaDutyVo.setOperateQualifySumMoth(0);
areaDutyVo.setOperateRateMoth("0");
areaDutyVo.setWorkSumMoth(0);
areaDutyVo.setWorkQualifySumMoth(0);
areaDutyVo.setWorkRateMoth("0");
return;
}
LocalDate firstDay = LocalDate.now().withDayOfMonth(1);
LocalDateTime startTime = LocalDateTime.of(firstDay, LocalTime.MIN);
LocalDateTime endTime = LocalDateTime.now();
areaDutyVo.setStartTimeMoth(dtf.format(startTime));
areaDutyVo.setEndTimeMoth(dtf.format(endTime));
//通过线程池异步获取月报各模块内容 主要分为五块内容
ExecutorService exe = Executors.newFixedThreadPool(POOL_QUANTITY);
//监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY);
// 日常维护
exe.execute(()->{
MaintainVo maintainVo = mainTaskStatisticService.getMaintain(dtf.format(startTime),dtf.format(endTime),list);
int maintainSum = maintainVo.getMaintain();
int maintainFinish = maintainVo.getMaintainFinish();
areaDutyVo.setMaintainSumMoth(maintainSum);
areaDutyVo.setMaintainFinishSumMoth(maintainFinish);
if (maintainFinish == 0) {
areaDutyVo.setMaintainRateMoth("0");
} else {
double maintainRate = BigDecimal.valueOf(maintainFinish / (double)maintainSum * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue();
areaDutyVo.setMaintainRateMoth(String.valueOf(maintainRate));
}
countDownLatch.countDown();
});
// 消缺
exe.execute(()->{
ShortagesVo shortagesVo = mainTaskStatisticService.getShortages(list);
int shortagesSum = shortagesVo.getShortagesSum();
int shortages = shortagesVo.getShortages();
areaDutyVo.setShortagesSumMoth(shortagesSum);
areaDutyVo.setShortagesMoth(shortages);
if (Math.abs(shortagesSum) <= 0) {
areaDutyVo.setShortagesRateMoth("0");
} else {
double shortagesRate = BigDecimal.valueOf(shortages / (double)shortagesSum * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue();
areaDutyVo.setShortagesRateMoth(String.valueOf(shortagesRate));
}
countDownLatch.countDown();
});
// 检修
exe.execute(()->{
OverhaulVo overhaulVo = mainTaskStatisticService.getOverhaul(dtf.format(startTime),dtf.format(endTime),list);
int overhaul = overhaulVo.getOverhaul();
int overhaulFinish = overhaulVo.getOverhaulFinish();
areaDutyVo.setOverhaulSumMoth(overhaul);
areaDutyVo.setOverhaulFinishSumMoth(overhaulFinish);
if (overhaulFinish == 0) {
areaDutyVo.setOverhaulRateMoth("0");
} else {
double overhaulRate = BigDecimal.valueOf(overhaulFinish / (double)overhaul * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue();
areaDutyVo.setOverhaulRateMoth(String.valueOf(overhaulRate));
}
countDownLatch.countDown();
});
// 操作票&工作票
exe.execute(()->{
Map<String,Object> map = new HashMap<>();
map.put("startDate",dtf.format(startTime));
map.put("endDate",dtf.format(endTime));
map.put("deptList",list);
R<TicketMonthVO> R = ticketInfoClient.getOperateWorkStatistic(map);
if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) {
areaDutyVo.setOperateSumMoth(0);
areaDutyVo.setOperateQualifySumMoth(0);
areaDutyVo.setOperateRateMoth("0");
areaDutyVo.setWorkSumMoth(0);
areaDutyVo.setWorkQualifySumMoth(0);
areaDutyVo.setWorkRateMoth("0");
countDownLatch.countDown();
return;
}
TicketMonthVO ticketMonthVO = R.getData();
// 操作票
int operate = ticketMonthVO.getOperate();
int operateQualify = ticketMonthVO.getOperateQualify();
areaDutyVo.setOperateSumMoth(operate);
areaDutyVo.setOperateQualifySumMoth(operateQualify);
if (operateQualify == 0) {
areaDutyVo.setOperateRateMoth("0");
} else {
double operateRate = BigDecimal.valueOf(operateQualify / (double)operate * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue();
areaDutyVo.setOperateRateMoth(String.valueOf(operateRate));
}
// 工作票
int work = ticketMonthVO.getWork();
int workQualify = ticketMonthVO.getWorkQualify();
areaDutyVo.setWorkSumMoth(work);
areaDutyVo.setWorkQualifySumMoth(workQualify);
if (workQualify == 0) {
areaDutyVo.setWorkRateMoth("0");
} else {
double workRate = BigDecimal.valueOf(workQualify / (double)work * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue();
areaDutyVo.setWorkRateMoth(String.valueOf(workRate));
}
countDownLatch.countDown();
});
// 等待所有线程执行完成
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
exe.shutdown();
}
/** /**
* 区域值班信息统计 * 区域值班信息统计

791
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java

@ -1,39 +1,18 @@
package com.hnac.hzims.operational.main.service.impl; package com.hnac.hzims.operational.main.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse;
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo;
import com.hnac.hzims.operational.fill.service.UseService;
import com.hnac.hzims.operational.home.wind.RainMon; import com.hnac.hzims.operational.home.wind.RainMon;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.service.AreaService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.main.service.IWaterService;
import com.hnac.hzims.operational.main.service.IWeatherService;
import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.station.StationConstants;
import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity;
import com.hnac.hzims.operational.station.entity.StationEntity; 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.hzims.operational.station.service.IStationService;
import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;
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.history.IHistoryDataSearchClient;
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO;
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 lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
@ -65,26 +44,16 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class WaterServiceImpl implements IWaterService { public class WaterServiceImpl implements IWaterService {
private final UseService useService;
private final AreaService areaService; private final AreaService areaService;
private final IStationService stationService; private final IStationService stationService;
private final IWeatherService weatherService; private final IWeatherService weatherService;
private final IAnalyseDataService analyseDataService;
private final IMainSystemMonitoringService maintenanceTaskService; private final IMainSystemMonitoringService maintenanceTaskService;
private final IHzimsAnalyzeModelStationService modelStationService;
private final ISysClient sysClient; private final ISysClient sysClient;
private final IAnalyseDataSearchClient analyseDataSearchClient;
private final IHistoryDataSearchClient historyDataSearchClient;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
@Value("${hzims.operation.realIdKey}") @Value("${hzims.operation.realIdKey}")
@ -94,730 +63,6 @@ public class WaterServiceImpl implements IWaterService {
private final static String loadwaterpump_rain_key = "hzims:operation:loadwaterpump:rain:key"; private final static String loadwaterpump_rain_key = "hzims:operation:loadwaterpump:rain:key";
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; private final static String loadwater_level_key = "hzims:operation:loadwater:level:key";
/**
* 水利-泵组实时加载
* @param param
*/
@Override
public void loadWaterPumpReal(String param) {
// 水利站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.in(StationEntity::getType,HomePageConstant.waterList)
);
if(CollectionUtil.isEmpty(stations)){
return;
}
// 泵站设备
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
if(CollectionUtil.isEmpty(devices)){
return;
}
// 实时数据
Map<String, String> map = this.getRealMap();
List<WaterPumpRealVo> list = devices.stream().map(device->{
WaterPumpRealVo real = new WaterPumpRealVo();
real.setDeptId(device.getCreateDept());
real.setDeviceCode(device.getEmCode());
real.setDeptName(device.getName());
// 装机容量
real.setInstalledCapacity(device.getInstalledCapacity());
// 开机状态
real.setState(this.getPumpState(device,map));
// 功率因数
real.setPowerFactor(this.getPowerFactor(device,map));
// 有功功率
real.setActivePower(this.getActivePower(device,map));
// 无功功率
real.setReactivePower(this.getReactivePower(device,map));
// 电压
real.setVoltage(this.getVoltage(device,map));
// 电流
real.setCurrent(this.getCurrent(device,map));
return real;
}).collect(Collectors.toList());
redisTemplate.opsForValue().set(loadwaterpump_real_key,list);
}
/**
* 水利-泵组指标加载
* @param param
*/
@Override
public void loadWaterPumpTarget(String param) {
// 水利站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.in(StationEntity::getType,HomePageConstant.waterList)
);
if(CollectionUtil.isEmpty(stations)){
return;
}
// 泵站设备
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()));
// 补充站点填报发电量
List<WaterPumpTargetVo> list = this.useFill(stations);
// 站点设备数据统计
if(CollectionUtil.isNotEmpty(devices)){
list.addAll(devices.stream().map(device->{
WaterPumpTargetVo target = new WaterPumpTargetVo();
target.setDeptId(device.getCreateDept());
target.setDeviceCode(device.getEmCode());
target.setDeptName(device.getName());
// 当年用电量
target.setUsrPowerYear(this.getUsrPowerYear(device));
// 当月用电量
target.setUsrPowerMon(this.getUsrPowerMon(device));
// 当日用电量
target.setUsrPowerDay(this.getUsrPowerDay(device));
// 当日机组有功功率
target.setActivePowerVoList(this.getActivePowerVoList(device));
// 近30天用电量
target.setUsrPowerVoList(this.getUsrPowerVoList(device));
// 近3年用电量
target.setUsrYearMap(this.getUsrYearMap(device));
// 月运行次数、时长
WaterRunVo runMon = this.getRunData(device,1);
target.setRunCountMon(runMon.getCount());
target.setRunDurationMon(runMon.getHour());
// 年运行次数、时长
WaterRunVo runYear = this.getRunData(device,0);
target.setRunCountYear(runYear.getCount());
target.setRunDurationYear(runYear.getHour());
return target;
}).collect(Collectors.toList()));
}
redisTemplate.opsForValue().set(loadwaterpump_target_key,list);
}
/**
* 水利-站点水位数据
* @param param
*/
@Override
public void loadWaterLevel(String param) {
// 有效站点模型
List<HzimsAnalyzeModelStationEntity> modelList = getModelStationList();
if(CollectionUtil.isEmpty(modelList)){
return;
}
List<WaterLevelVo> list = new ArrayList<>();
modelList.forEach(item -> {
List<MultiAnalyzeCodePO> multiAnalyzeCodePOList = new ArrayList<>();
MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO();
multiAnalyzeCodePO.setDeviceCode(item.getInstanceCode());
multiAnalyzeCodePO.setSignages(Collections.singletonList(HomePageConstant.FRONT_WATER_LEVEL));
multiAnalyzeCodePOList.add(multiAnalyzeCodePO);
R<List<AnalyzeCodeBySignagesVO>> result = analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return;
}
WaterLevelVo waterLevelVo = new WaterLevelVo();
waterLevelVo.setStationCode(item.getStationId());
// 前水位
double frontWaterLevel = this.getWaterLevel(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL);
waterLevelVo.setFrontWaterLevel(frontWaterLevel);
// 后水位
double rearWaterLevel = this.getWaterLevel(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL);
waterLevelVo.setRearWaterLevel(rearWaterLevel);
// 下泄流量
double dischargeFlow = this.getWaterLevel(item.getInstanceCode(),HomePageConstant.DISCHARGE_FLOW);
waterLevelVo.setDischargeFlow(dischargeFlow);
// 前水位当日曲线
Map<Integer,String> frontCurveMap = this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL);
waterLevelVo.setFrontCurveMap(frontCurveMap);
// 后水位当日曲线
Map<Integer,String> rearCurveMap = this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL);
waterLevelVo.setRearCurveMap(rearCurveMap);
list.add(waterLevelVo);
});
redisTemplate.opsForValue().set(loadwater_level_key,list);
}
/**
* 泵站设备
* @param stations
* @return
*/
private List<EminfoAndEmParamVo> pumpDevices(List<Long> stations){
if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>();
}
List<EminfoAndEmParamVo> devices = maintenanceTaskService.getEmInfoList();
if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>();
}
return devices.stream().filter(device->stations.contains(device.getCreateDept())).collect(Collectors.toList());
}
/**
* 获取水位实时数据
* @param instanceCode
* @param signage
* @return
*/
private double getWaterLevel(String instanceCode, String signage) {
RealDataSearchPO realData = new RealDataSearchPO();
realData.setAnalyzeCode(instanceCode);
List<String> signages = Collections.singletonList(signage);
realData.setSignages(signages);
// 调用fegin接口查询实时数据
R<List<FieldsData>> R = analyseDataSearchClient.getRealDataByAnalyzeCode(realData);
if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){
return 0.0;
}
// 时间限制
String time = R.getData().get(0).getTime();
if(StringUtil.isEmpty(time) || "-".equals(time)){
return 0.0;
}
Date date = DateUtil.parse(time, "yyyy-MM-dd HH:mm:ss.sss");
if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){
return 0.0;
}
return Double.parseDouble(R.getData().get(0).getValue());
}
/**
* 获取水位当年数据
* @param instanceCode
* @param signage
* @return
*/
private Map<Integer, String> getWaterLevelMap(String instanceCode, String signage) {
LocalDateTime beginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"), DateUtil.DATETIME_FORMATTER);
LocalDateTime endTime = LocalDateTime.now();
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
analyzeDataConditionPO.setFull(1);
analyzeDataConditionPO.setSignages(signage);
// 取数规则: 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值
analyzeDataConditionPO.setAccessRules(EquipmentConstants.AccessRulesEnum.FINAL_CYCLE.getType());
// 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时)3->、d(天)4->、w(周)5->、n(自然月)、6->y(自然年)
analyzeDataConditionPO.setSaveTimeType(2);
// 间隔
analyzeDataConditionPO.setTimeInterval(1);
analyzeDataConditionPO.setBeginTime(beginTime);
analyzeDataConditionPO.setEndTime(endTime);
signboardConditions.add(analyzeDataConditionPO);
po.setDeviceCode(instanceCode);
po.setSignboardConditions(signboardConditions);
R<List<AnalyzeDataConditionVO>> R = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){
return null;
}
if(CollectionUtil.isEmpty(R.getData().get(0).getList())){
return null;
}
return R.getData().get(0).getList().stream().collect(Collectors.toMap(key-> {
Date dateTime = DateUtil.parse(key.getTs(), "yyyy-MM-dd HH:mm:ss.s");
return dateTime.getHours();
}, value -> {
if(StringUtil.isBlank(value.getVal())){
return "0";
}
return value.getVal();
}));
}
/**
* 获取有效站点模型
* @return
*/
private List<HzimsAnalyzeModelStationEntity> getModelStationList() {
// 水利站点(All)
List<StationEntity> stationList = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, null, null,false);
if(CollectionUtil.isEmpty(stationList)){
return null;
}
// 站点code集合
List<String> codes = stationList.stream().map(StationEntity::getCode).collect(Collectors.toList());
if(CollectionUtil.isEmpty(codes)){
return null;
}
// 查询站点模型列表
List<HzimsAnalyzeModelStationEntity> list = modelStationService.list(new LambdaQueryWrapper<HzimsAnalyzeModelStationEntity>() {{
in(HzimsAnalyzeModelStationEntity::getStationId, codes);
}});
if(CollectionUtil.isEmpty(list)){
return null;
}
return list;
}
/**
* 获取实时数据
* @return
*/
private Map<String, String> getRealMap() {
String json = (String) redisTemplate.opsForValue().get(real_id_key);
if(StringUtil.isBlank(json)){
return null;
}
return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {});
}
/**
* 获取运行数据
* @param device
* @param type
* @return
*/
private WaterRunVo getRunData(EminfoAndEmParamVo device, int type) {
// 默认返回运行数据
WaterRunVo waterRunVo = new WaterRunVo();
waterRunVo.setCount(0);
waterRunVo.setHour(0.0);
Map<String,String> point = device.getPoint();
if(MapUtils.isEmpty(point)){
return waterRunVo;
}
// 监测点
String realId = point.get(HomePageConstant.SWITCH_ON_OFF);
if(StringUtil.isBlank(realId)){
return waterRunVo;
}
// 确定查询时间范围: 年、月
Date startDate,endDate;
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
switch (type){
case 0:
endDate = calendar.getTime();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
startDate = calendar.getTime();
break;
case 1:
endDate = calendar.getTime();
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 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));
startDate = calendar.getTime();
break;
default:
throw new IllegalStateException("Unexpected value: " + type);
}
return this.getRunConvertData(realId,startDate,endDate,waterRunVo);
}
/**
* 获取时间范围内开机次数运行时长
* @param realId
* @param startDate
* @param endDate
* @param waterRunVo
* @return
*/
private WaterRunVo getRunConvertData(String realId, Date startDate, Date endDate, WaterRunVo waterRunVo) {
OriginalDataQuery originalDataQuery = new OriginalDataQuery();
originalDataQuery.setRealId(realId);
originalDataQuery.setBeginTime(startDate);
originalDataQuery.setEndTime(endDate);
originalDataQuery.setLimit(100000);
originalDataQuery.setPage(1);
// 查询时间范围开关机监测点历史数据
Result<HzPage<PointData>> R = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery);
if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){
return waterRunVo;
}
// 过滤相邻开关机状态相同数据
List<PointData> result = this.getFilterList(R.getData().getRecords());
if(CollectionUtil.isEmpty(result)){
return waterRunVo;
}
// 开机次数
int count = (int) result.stream().filter(o->HomePageConstant.OFF.equals(o.getValue())).count();
waterRunVo.setCount(count);
// 开机运行时长
long time = this.getRunTime(result,startDate,endDate);
waterRunVo.setHour(BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue());
return waterRunVo;
}
/**
* 过滤相邻开关机状态相同数据
* @param list
* @return
*/
private List<PointData> getFilterList(List<PointData> list) {
if(CollectionUtil.isEmpty(list)){
return null;
}
List<PointData> result = new ArrayList<>();
// 遍历数据
for(int i = 0; i< list.size() ; i++){
// 第一个数据保存下来
if(i == 0){
result.add(list.get(i));
continue;
}
// 遍历数据状态
String value = list.get(i).getValue();
if(StringUtil.isBlank(value)){
continue;
}
// 上一条数据状态
String up_value = list.get(i-1).getValue();
if(value.equals(up_value)){
continue;
}
result.add(list.get(i));
}
return result;
}
/**
* 获取运行时长
* @param result
* @return
*/
private long getRunTime(List<PointData> result,Date startDate,Date endDate) {
if(result.size() == 1){
// 一直开机
if(HomePageConstant.OFF.equals(result.get(0).getValue())){
return endDate.getTime() - startDate.getTime();
}
// 一直关机
return 0;
}
long time=0;
// 遍历累计开机时长
for(int i = 0; i< result.size() ; i++){
// 记录为开机状态 就计算到下次关机的时间差
if(HomePageConstant.ON.equals(result.get(i).getValue())){
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 em
* @param map
* @param targets
* @return
*/
private String getSignageValue(EminfoAndEmParamVo em,Map<String,String> map, String targets) {
if(ObjectUtil.isEmpty(em) || MapUtils.isEmpty(map)){
return "0";
}
Map<String,String> point = em.getPoint();
if(MapUtils.isEmpty(point)){
return "0";
}
String realId = point.get(targets);
if(StringUtil.isBlank(realId)){
return "0";
}
String value = map.get(realId);
if(StringUtil.isBlank(value)){
return "0";
}
// 获取value
return value;
}
/**
* 当年用电量
* @param device
* @return
*/
private float getUsrPowerYear(EminfoAndEmParamVo device) {
Calendar calendar = Calendar.getInstance();
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
// 当年用电量
return analyseDataService.periodTargetFloat(start,end,5,6,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION);
}
/**
* 当月用电量
* @param device
* @return
*/
private float getUsrPowerMon(EminfoAndEmParamVo device) {
String start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00";
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
// 当月用电量
return analyseDataService.periodTargetFloat(start,end,5,5,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION);
}
/**
* 当日用电量
* @param device
* @return
*/
private float getUsrPowerDay(EminfoAndEmParamVo device) {
String time = DateUtil.format(new Date(),DateUtil.PATTERN_DATE);
// 当日用电量
return analyseDataService.periodTargetFloat(time + " 00:00:00",time + " 23:59:59",5,3,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION);
}
/**
* 获取开机状态
* @param device
* @return
*/
private int getPumpState(EminfoAndEmParamVo device,Map<String,String> map) {
// 获取开关机监测点实时数据
String value = this.getSignageValue(device,map,HomePageConstant.SWITCH_ON_OFF);
// 开机状态
if (HomePageConstant.OFF.equals(value)) {
return 0;
}
return 1;
}
/**
* 获取功率因数
* @param device
* @return
*/
private double getPowerFactor(EminfoAndEmParamVo device,Map<String,String> map) {
// 获取开关机监测点实时数据
String value = this.getSignageValue(device,map,HomePageConstant.POWER_FACTOR);
if(StringUtil.isBlank(value)){
return 0.0;
}
// 开机状态
return Double.parseDouble(value);
}
/**
* 有功功率
* @param device
* @return
*/
private float getActivePower(EminfoAndEmParamVo device,Map<String,String> map) {
// 获取有功功率监测点实时数据
String value = this.getSignageValue(device,map,HomePageConstant.ACTIVE_POWER);
if(StringUtil.isBlank(value)){
return 0f;
}
// 有功功率
return Float.parseFloat(value);
}
/**
* 无功功率
* @param device
* @return
*/
private float getReactivePower(EminfoAndEmParamVo device,Map<String,String> map) {
// 获取无功功率监测点实时数据
String value = this.getSignageValue(device,map,HomePageConstant.REACTIVE_POWER);
if(StringUtil.isBlank(value)){
return 0f;
}
// 无功功率
return Float.parseFloat(value);
}
/**
* 电压
* @param device
* @return
*/
private double getVoltage(EminfoAndEmParamVo device,Map<String,String> map) {
// 获取电压监测点实时数据
String value = this.getSignageValue(device,map,HomePageConstant.VOLTAGE);
if(StringUtil.isBlank(value)){
return 0.0;
}
// 电压
return Double.parseDouble(value);
}
/**
* 电流
* @param device
* @return
*/
private double getCurrent(EminfoAndEmParamVo device,Map<String,String> map) {
// 获取电流监测点实时数据
String value = this.getSignageValue(device,map,HomePageConstant.CURRENT);
if(StringUtil.isBlank(value)){
return 0.0;
}
// 电流
return Double.parseDouble(value);
}
/**
* 当日机组有功功率
* @param device
* @return
*/
@Override
public List<ActivePowerVo> getActivePowerVoList(EminfoAndEmParamVo device) {
String startTime = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00");
String endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
analyzeDataConditionPO.setFull(0);
analyzeDataConditionPO.setSignages(HomePageConstant.ACTIVE_POWER);
// 取数规则: 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值
analyzeDataConditionPO.setAccessRules(EquipmentConstants.AccessRulesEnum.AVG_CYCLE.getType());
// 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时)3->、d(天)4->、w(周)5->、n(自然月)、6->y(自然年)
analyzeDataConditionPO.setSaveTimeType(EquipmentConstants.CycleTypeEnum.H_CYCLE.getType());
// 间隔
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.setDeviceCode(device.getEmCode());
po.setSignboardConditions(signboardConditions);
R<List<AnalyzeDataConditionVO>> R = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){
return null;
}
List<ActivePowerVo> list = new ArrayList<>();
// 遍历添加机组功率
for(AnalyzeDataConditionVO data : R.getData()){
if(CollectionUtil.isEmpty(data.getList())){
continue;
}
for(AnalyseDataTaosVO item : data.getList()){
ActivePowerVo vo = new ActivePowerVo();
Date dateTime = DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s");
vo.setHour(dateTime.getHours());
if (StringUtil.isBlank(item.getVal())) {
vo.setActivePower("0");
}else {
vo.setActivePower(item.getVal());
}
list.add(vo);
}
}
return list;
}
/**
* 近30天用电量
* @param device
* @return
*/
private List<UsrPowerVo> getUsrPowerVoList(EminfoAndEmParamVo device) {
String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00";
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-29);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION);
if(CollectionUtil.isEmpty(records)){
return new ArrayList<>();
}
return records.stream().map(record -> {
UsrPowerVo usr = new UsrPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
usr.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE));
usr.setUsrPower(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0")));
return usr;
}).collect(Collectors.toList());
}
/**
* 近3年发电量
*
* @param device
* @return
*/
private Map<String, Float> getUsrYearMap(EminfoAndEmParamVo device) {
// 开始时间
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 结束日期
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 3);
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 查询数据
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION);
if(CollectionUtil.isEmpty(records)){
return new HashMap<>();
}
return records.stream().map(record -> {
PowerMonthVo generate = new PowerMonthVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrMonth(DateUtil.format(time, DateUtil.PATTERN_DATE));
generate.setPower(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount());
return generate;
}).collect(Collectors.toMap(PowerMonthVo::getStrMonth,PowerMonthVo::getPower));
}
/**
* 获取填报用电量
* @param stations
* @return
*/
private List<WaterPumpTargetVo> useFill(List<StationEntity> stations) {
Calendar calendar = Calendar.getInstance();
String day = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
String mon = DateUtil.format(calendar.getTime(),"yyyy-MM");
String year = String.valueOf(calendar.get(Calendar.YEAR));
return stations.stream().map(station ->{
WaterPumpTargetVo target = new WaterPumpTargetVo();
target.setDeptId(station.getRefDept());
target.setDeptName(station.getName());
// 月运行次数、时长
target.setRunCountMon(0);
target.setRunDurationMon(0.0);
// 年运行次数、时长
target.setRunCountYear(0);
target.setRunDurationYear(0.0);
// 当年用电量
target.setUsrPowerYear(useService.use(year,station.getCode()));
// 当月用电量
target.setUsrPowerMon(useService.use(mon,station.getCode()));
// 当日用电量
target.setUsrPowerDay(useService.use(day,station.getCode()));
if(StationConstants.DATA_ORIGIN_FILL.equals(station.getDataOrigin())){
// 30天用电量
target.setUsrPowerVoList(useService.use30Day(day,station.getCode()));
}
// 近3年用电量
target.setUsrYearMap(this.useThreeYear(station.getCode()));
return target;
}).collect(Collectors.toList());
}
/**
* 填报近3年发电量
* @param station
* @return
*/
private Map<String, Float> useThreeYear(String station) {
// 开始时间
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
String end = DateUtil.format(calendar.getTime(),"yyyy-MM");
// 结束日期
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 3);
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE);
return useService.generateThreeYear(start,end,station);
}
/** /**
* 水利首页-指标数据 * 水利首页-指标数据
@ -1098,34 +343,6 @@ public class WaterServiceImpl implements IWaterService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
/**
* 获取降水数据
* @param year
* @return
*/
private Map<String,List<RainFallCountByMonthVo>> getYearRain(List<String> codes,int year) {
List<RainFallCountByMonthVo> list = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
// 查询当年降雨
Map<String,List<RainFallCountByMonthVo>> map = this.weatherService.getRainFallMonthCount(String.valueOf(calendar.get(Calendar.YEAR)),codes);
if(MapUtils.isEmpty(map)){
return null;
}
// 添加至list
map.values().forEach(list::addAll);
calendar.setTime(new Date());
// 遍历添加年份降雨
for(int i=1 ; i <= year ; i++){
calendar.add(Calendar.YEAR,-i);
Map<String,List<RainFallCountByMonthVo>> old = this.weatherService.getRainFallMonthCount(String.valueOf(calendar.get(Calendar.YEAR)),codes);
if(MapUtils.isEmpty(old)){
continue;
}
// 添加至list
old.values().forEach(list::addAll);
}
return list.stream().collect(Collectors.groupingBy(RainFallCountByMonthVo::getYearAndMonth));
}
/** /**
* 用电量根据月份分组 * 用电量根据月份分组

20
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java

@ -1,14 +1,10 @@
package com.hnac.hzims.operational.station.service; package com.hnac.hzims.operational.station.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.operational.main.vo.StationCountVo; import com.hnac.hzims.operational.main.vo.StationCountVo;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.vo.HzimsStationCountVo;
import com.hnac.hzims.operational.station.vo.StationAndDeptVo; import com.hnac.hzims.operational.station.vo.StationAndDeptVo;
import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVO;
import com.hnac.hzims.operational.station.vo.StationsQueryVo;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.BladeUser;
@ -54,7 +50,7 @@ public interface IStationService extends BaseService<StationEntity> {
StationVO getStationByCode(String code); StationVO getStationByCode(String code);
List<StationEntity> getInRefDept(List<Long> depeIds,String stationType,List<String> types); List<StationEntity> getInRefDept(List<Long> deptIds,String stationType,List<String> types);
List<StationEntity> getLikeRefDept(Long deptId,String stationType,List<String> types); List<StationEntity> getLikeRefDept(Long deptId,String stationType,List<String> types);
@ -72,13 +68,13 @@ public interface IStationService extends BaseService<StationEntity> {
StationEntity getStationByCodeOrRefDept(String stationId,Long deptId); StationEntity getStationByCodeOrRefDept(String stationId,Long deptId);
int getInRefDeptStationCount(List<Long> perSeDepeIds,String refDomain,String type,List<Long> deptIds); int getInRefDeptStationCount(List<Long> perSeDeptIds,String refDomain,String type,List<Long> deptIds);
int getLikeRefDeptStationCount(Long deptId,String refDomain,String type,List<Long> deptIds); int getLikeRefDeptStationCount(Long deptId,String refDomain,String type,List<Long> deptIds);
int getEqualToRefDeptStationCount(Long deptId, String refDomain,String type,List<Long> deptIds); int getEqualToRefDeptStationCount(Long deptId, String refDomain,String type,List<Long> deptIds);
int getForEachRefDeptStationCount(List<Long> perSeDepeIds,String refDomain,String type,List<Long> deptIds); int getForEachRefDeptStationCount(List<Long> perSeDeptIds,String refDomain,String type,List<Long> deptIds);
List<StationEntity> getAll(); List<StationEntity> getAll();
@ -105,8 +101,6 @@ public interface IStationService extends BaseService<StationEntity> {
List<StationEntity> getStationType(Integer serveType,List<Integer> typeList,List<Long> departIdList,boolean make); List<StationEntity> getStationType(Integer serveType,List<Integer> typeList,List<Long> departIdList,boolean make);
List<StationEntity> getStationByServerTypeAndIsType(Integer serverType,Boolean isType);
List<StationEntity> getStationList(List<Dept> authList, Long deptId, List<Integer> types, Integer serveType,boolean make); List<StationEntity> getStationList(List<Dept> authList, Long deptId, List<Integer> types, Integer serveType,boolean make);
List<StationEntity> getHomeStationList(Long deptId, List<Integer> types, Integer serveType,boolean make); List<StationEntity> getHomeStationList(Long deptId, List<Integer> types, Integer serveType,boolean make);
@ -115,10 +109,6 @@ public interface IStationService extends BaseService<StationEntity> {
List<StationEntity> getStationByRefDept(List<Long> refDeptList); List<StationEntity> getStationByRefDept(List<Long> refDeptList);
Integer getStationMaxOrder();
List<HzimsStationCountVo> getStationCount();
List<StationEntity> select(Integer type, Integer serveType); List<StationEntity> select(Integer type, Integer serveType);
/** /**
@ -134,10 +124,6 @@ public interface IStationService extends BaseService<StationEntity> {
List<StationEntity> accessHydropower(); List<StationEntity> accessHydropower();
@Override @Override
@Deprecated
boolean removeByMap(Map<String, Object> columnMap);
@Override
boolean save(StationEntity entity); boolean save(StationEntity entity);
Boolean createStation(StationEntity station); Boolean createStation(StationEntity station);

169
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.hnac.hzims.fdp.feign.IQuestionClient; import com.hnac.hzims.fdp.feign.IQuestionClient;
import com.hnac.hzims.hzimsweather.response.air.Station;
import com.hnac.hzims.operational.OperationalConstants; import com.hnac.hzims.operational.OperationalConstants;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.entity.UserDeptEntity; import com.hnac.hzims.operational.main.entity.UserDeptEntity;
@ -26,7 +25,6 @@ import com.hnac.hzims.operational.station.mapper.StationMapper;
import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationAttributeService;
import com.hnac.hzims.operational.station.service.IStationPushConfigService; import com.hnac.hzims.operational.station.service.IStationPushConfigService;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.HzimsStationCountVo;
import com.hnac.hzims.operational.station.vo.StationAndDeptVo; import com.hnac.hzims.operational.station.vo.StationAndDeptVo;
import com.hnac.hzims.operational.station.vo.StationPushConfigVO; import com.hnac.hzims.operational.station.vo.StationPushConfigVO;
import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVO;
@ -58,8 +56,6 @@ import org.springframework.util.Assert;
import java.io.Serializable; import java.io.Serializable;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -90,59 +86,8 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
else { else {
this.updateStation(req); this.updateStation(req);
} }
// // 新建站点的所属机构
// Assert.isTrue(this.buildDept(req), () -> {
// throw new ServiceException("创建/修改机构失败!");
// });
// Optional<Integer> sort = Optional.ofNullable(this.getStationMaxOrder());
// req.setSort(sort.isPresent() ? sort.get() + 1 : 1);
// this.pushStation(req);
// boolean updateResult = this.saveOrUpdate(req);
// Assert.isTrue(updateResult, () -> {
// throw new ServiceException("创建/修改站点信息失败!");
// });
} }
/**
* 推送站点
*
* @param req 推送站点内容
*/
private void pushStation(StationEntity req) {
// 读取站点类型配置确定是否推送FDP
FutureTask<R> fdpPush = new FutureTask<>(() -> {
StationPushConfigEntity config = StationPushConfigEntity.builder().stationType(req.getType()).build();
StationPushConfigVO configVO = stationPushConfigService.getOne(BeanUtil.copy(config, StationPushConfigDTO.class));
if (ObjectUtil.isNotEmpty(configVO) && configVO.getIsPush()) {
log.info("{}站点开始智能诊断站点推送", req.getCode());
return questionClient.submitStationInfo(configVO.getFdpStationType(), req.getCode(), "运维平台推送");
}
return R.success("推送配置未找到相应配置,暂不推送至FDP");
});
// 如果设备数据来源未选定其他 则进行站点初始化操作
FutureTask<R> dataPush = new FutureTask<>(() -> {
if (StationConstants.GATHER.equals(req.getDataOrigin()) && !StationConstants.HZ3000_OTHER.equals(req.getDataSource())) {
log.info("{}站点开始数据平台新建项目", req.getCode());
return R.status(this.instanceProject(req));
}
return R.success("不满足数据平台推送要求,暂不推送至数据平台");
});
new Thread(fdpPush,"智能诊断站点推送").start();
new Thread(dataPush,"数据平台站点推送").start();
boolean flag;
try {
log.error("pushStationsend : {},{}",fdpPush.get(),dataPush.get());
flag = fdpPush.get().isSuccess() && dataPush.get().isSuccess();
}
catch (ExecutionException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Assert.isTrue(flag,() -> {
throw new ServiceException("站点推送数据平台/FDP失败!");
});
}
@Override @Override
public boolean removeById(Serializable id) { public boolean removeById(Serializable id) {
@ -238,8 +183,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
queryWrapper.orderByDesc(StationEntity::getSort); queryWrapper.orderByDesc(StationEntity::getSort);
queryWrapper.orderByDesc(StationEntity::getUpdateTime); queryWrapper.orderByDesc(StationEntity::getUpdateTime);
IPage<StationEntity> pages = super.page(Condition.getPage(query), queryWrapper); IPage<StationEntity> pages = super.page(Condition.getPage(query), queryWrapper);
IPage<StationVO> vos = StationWrapper.builder().pageVO(pages); return StationWrapper.builder().pageVO(pages);
return vos;
} }
@Override @Override
@ -256,34 +200,6 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
return userList; return userList;
} }
// @Override
// public boolean updateById(StationEntity req) {
// return super.update(Wrappers.<StationEntity>lambdaUpdate()
// .set(StationEntity::getCode, req.getCode())
// .set(StationEntity::getName, req.getName())
// .set(StationEntity::getType, req.getType())
// .set(StationEntity::getCommissionTime, req.getCommissionTime())
// .set(StationEntity::getEnableControl, req.getEnableControl())
// .set(StationEntity::getLgtd, req.getLgtd())
// .set(StationEntity::getLttd, req.getLttd())
// .set(StationEntity::getRefDept, req.getRefDept())
// .set(StationEntity::getAreaCode, req.getAreaCode())
// .set(StationEntity::getRefDomain, req.getRefDomain())
// .set(StationEntity::getRefBasin, req.getRefBasin())
// .set(StationEntity::getRefArea, req.getRefArea())
// .set(StationEntity::getRemark, req.getRemark())
// .set(StationEntity::getPic, req.getPic())
// .set(StationEntity::getContact, req.getContact())
// .set(StationEntity::getContactor, req.getContactor())
// .set(StationEntity::getAddress, req.getAddress())
// .set(StationEntity::getCompany, req.getCompany())
// .set(StationEntity::getCreateDept, req.getCreateDept())
// .set(StationEntity::getServeType, req.getServeType())
// .set(StationEntity::getLimitWaterLevel, req.getLimitWaterLevel())
// .eq(StationEntity::getId, req.getId()));
// }
@Override @Override
public List<StationEntity> getInRefDept(List<Long> depeIds, String stationType, List<String> types) { public List<StationEntity> getInRefDept(List<Long> depeIds, String stationType, List<String> types) {
return this.baseMapper.selectInRefDept(depeIds, stationType, types); return this.baseMapper.selectInRefDept(depeIds, stationType, types);
@ -317,10 +233,8 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
throw new ServiceException("未查询到相关站点"); throw new ServiceException("未查询到相关站点");
}); });
if (CollectionUtil.isNotEmpty(controlUsersEntities)) { if (CollectionUtil.isNotEmpty(controlUsersEntities)) {
List<ControlUsersEntity> codeList = controlUsersEntities.stream().filter(c -> stationId.equals(c.getStationId())).filter(c -> { List<ControlUsersEntity> codeList = controlUsersEntities.stream().filter(c -> stationId.equals(c.getStationId())).filter(c -> Func.toLongList(c.getUserIds()).contains(userId)).collect(Collectors.toList());
return Func.toLongList(c.getUserIds()).contains(userId); ControlUsersEntity object = !codeList.isEmpty() ? codeList.get(0) : null;
}).collect(Collectors.toList());
ControlUsersEntity object = codeList.size() > 0 ? codeList.get(0) : null;
if (ObjectUtil.isNotEmpty(object)) { if (ObjectUtil.isNotEmpty(object)) {
StationEntity result = new StationEntity(); StationEntity result = new StationEntity();
result.setCode(stationId); result.setCode(stationId);
@ -345,8 +259,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
if (Func.isEmpty(AuthUtil.getUserId())) { if (Func.isEmpty(AuthUtil.getUserId())) {
return this.baseMapper.getStationByCode(stationId, null, null); return this.baseMapper.getStationByCode(stationId, null, null);
} }
StationEntity stationEntity = this.getStationByCodeAndUser(stationId, AuthUtil.getUserId()); return this.getStationByCodeAndUser(stationId, AuthUtil.getUserId());
return stationEntity;
} }
@Override @Override
@ -390,13 +303,17 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
@Override @Override
public List<StationEntity> getStationByUserAuth(BladeUser user) { public List<StationEntity> getStationByUserAuth(BladeUser user) {
List<StationEntity> list = new ArrayList<>(); List<StationEntity> list = new ArrayList<>();
if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.EMPLOYER_VISIBLE.getVal()) && StringUtil.isNotBlank(user.getDeptId())) {//所属机构 //所属机构
if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.EMPLOYER_VISIBLE.getVal()) && StringUtil.isNotBlank(user.getDeptId())) {
list = this.baseMapper.selectEqualToRefDeptStationData(Long.valueOf(user.getDeptId())); list = this.baseMapper.selectEqualToRefDeptStationData(Long.valueOf(user.getDeptId()));
} else if ((user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.EMPLOYER_SUBORDINATE_BODY.getVal()) || user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.SELT_SUBORDINATE_BODY.getVal())) && ObjectUtil.isNotEmpty(user.getDeptId()) && StringUtil.isNotBlank(user.getDeptId())) {//所属机构及下属机构 || 个人及下属机构 //所属机构及下属机构 || 个人及下属机构
} else if ((user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.EMPLOYER_SUBORDINATE_BODY.getVal()) || user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.SELT_SUBORDINATE_BODY.getVal())) && ObjectUtil.isNotEmpty(user.getDeptId()) && StringUtil.isNotBlank(user.getDeptId())) {
list = this.baseMapper.selectLikeRefDeptStationData(Long.valueOf(user.getDeptId())); list = this.baseMapper.selectLikeRefDeptStationData(Long.valueOf(user.getDeptId()));
} else if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.AFFILIATE.getVal()) && StringUtil.isNotBlank(user.getDeptIds())) {//附属机构 //附属机构
} else if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.AFFILIATE.getVal()) && StringUtil.isNotBlank(user.getDeptIds())) {
list = this.baseMapper.selectInRefDeptStationData(Func.toLongList(user.getDeptIds())); list = this.baseMapper.selectInRefDeptStationData(Func.toLongList(user.getDeptIds()));
} else if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.AFFILIATE_SUBORDINATE_BODY.getVal()) && StringUtil.isNotBlank(user.getDeptIds())) {//附属机构及下属 //附属机构及下属
} else if (user.getDataScopeType().equals(OperationalConstants.UserDataScopeTypeEnum.AFFILIATE_SUBORDINATE_BODY.getVal()) && StringUtil.isNotBlank(user.getDeptIds())) {
list = this.baseMapper.selectForEachRefDeptStationData(Func.toLongList(user.getDeptIds())); list = this.baseMapper.selectForEachRefDeptStationData(Func.toLongList(user.getDeptIds()));
} }
return list; return list;
@ -510,17 +427,6 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
}}); }});
} }
/**
* 根据条件 服务类型及站点类型查询站点数据
*
* @param serverType
* @param isType true is not null \ false is null
* @return
*/
@Override
public List<StationEntity> getStationByServerTypeAndIsType(Integer serverType, Boolean isType) {
return this.baseMapper.getStationByTypeAndIsType(serverType, isType);
}
/** /**
* 获取机构下站点集合 * 获取机构下站点集合
@ -645,51 +551,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
return this.baseMapper.getStationByRefDept(refDeptList); return this.baseMapper.getStationByRefDept(refDeptList);
} }
@Override
public Integer getStationMaxOrder() {
return this.baseMapper.getStationMaxOrder();
}
/**
* @return
*/
@Override
public List<HzimsStationCountVo> getStationCount() {
return this.baseMapper.getStationCount();
}
/**
* 通过站点编辑所属机构
*
* @param stationEntity 站点信息
* @return
*/
private boolean buildDept(StationEntity stationEntity) {
//若所属机构不为空 则说明机构已建 获取所属机构
Dept request = new Dept();
if (Func.isNotEmpty(stationEntity.getRefDept())) {
R<Dept> deptResult = sysClient.getDept(stationEntity.getRefDept());
if (deptResult.isSuccess() && Func.isNotEmpty(deptResult.getData())) {
request = deptResult.getData();
}
}
request.setStationId(stationEntity.getCode());
request.setTenantId(AuthUtil.getTenantId());
request.setFullName(stationEntity.getName());
request.setDeptName(stationEntity.getName());
request.setParentId(Func.isNotEmpty(stationEntity.getHigherDept()) ? stationEntity.getHigherDept() : request.getParentId());
request.setDeptCategory(StationConstants.DeptCategoryEnum.STATION.getValue());
request.setSort(1);
R<Void> buildResult = deptClient.createOrUpdateDept(request);
if (buildResult.isSuccess()) {
// 所属机构回传
R<Dept> deptByStation = sysClient.getDeptByStation(request.getStationId(), AuthUtil.getTenantId());
Long deptId = Optional.ofNullable(deptByStation).map(R::getData).map(Dept::getId).orElse(null);
stationEntity.setRefDept(deptId);
stationEntity.setCreateDept(deptId);
}
return buildResult.isSuccess();
}
/** /**
* 查询下拉列表站点 * 查询下拉列表站点
@ -730,7 +592,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
if (CollectionUtil.isNotEmpty(list) && list.size() > 1) { if (CollectionUtil.isNotEmpty(list) && list.size() > 1) {
throw new ServiceException("获取站点数量超过一条"); throw new ServiceException("获取站点数量超过一条");
} }
return list.size() > 0 ? list.get(0) : null; return !list.isEmpty() ? list.get(0) : null;
} }
/** /**
@ -747,11 +609,6 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
} }
@Override @Override
public boolean removeByMap(Map<String, Object> columnMap) {
throw new UnsupportedOperationException("该方法已被禁止使用");
}
@Override
public boolean instanceFdpStation(StationEntity req) { public boolean instanceFdpStation(StationEntity req) {
StationPushConfigEntity config = StationPushConfigEntity.builder().stationType(req.getType()).build(); StationPushConfigEntity config = StationPushConfigEntity.builder().stationType(req.getType()).build();
StationPushConfigVO configVO = stationPushConfigService.getOne(BeanUtil.copy(config, StationPushConfigDTO.class)); StationPushConfigVO configVO = stationPushConfigService.getOne(BeanUtil.copy(config, StationPushConfigDTO.class));

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SpecialDeviceInspectionServiceImpl.java

@ -48,6 +48,9 @@ public class SpecialDeviceInspectionServiceImpl extends ServiceImpl<SpecialDevic
specialDeviceInspectionEntity.setNextInspectionTime(nextInspectDate); specialDeviceInspectionEntity.setNextInspectionTime(nextInspectDate);
specialDeviceEntity.setInspectionNextTime(nextInspectDate); specialDeviceEntity.setInspectionNextTime(nextInspectDate);
// 获取上一次检验时间 // 获取上一次检验时间
if (specialDeviceInspectionEntity.getLastInspectionTime() != null) {
specialDeviceEntity.setInspectionLastTime(specialDeviceInspectionEntity.getLastInspectionTime());
} else {
QueryWrapper<SpecialDeviceInspectionEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<SpecialDeviceInspectionEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SpecialDeviceInspectionEntity::getDeviceId, deviceId) queryWrapper.lambda().eq(SpecialDeviceInspectionEntity::getDeviceId, deviceId)
.orderByDesc(SpecialDeviceInspectionEntity::getInspectionTime); .orderByDesc(SpecialDeviceInspectionEntity::getInspectionTime);
@ -58,6 +61,7 @@ public class SpecialDeviceInspectionServiceImpl extends ServiceImpl<SpecialDevic
specialDeviceInspectionEntity.setLastInspectionTime(lastInspectionTime); specialDeviceInspectionEntity.setLastInspectionTime(lastInspectionTime);
specialDeviceEntity.setInspectionLastTime(lastInspectionTime); specialDeviceEntity.setInspectionLastTime(lastInspectionTime);
} }
}
// 本次检验时间 // 本次检验时间
specialDeviceEntity.setInspectionCurrentTime(specialDeviceInspectionEntity.getInspectionTime()); specialDeviceEntity.setInspectionCurrentTime(specialDeviceInspectionEntity.getInspectionTime());
boolean save = this.save(specialDeviceInspectionEntity); boolean save = this.save(specialDeviceInspectionEntity);

Loading…
Cancel
Save