Browse Source

Merge remote-tracking branch 'origin/prod'

# Conflicts:
#	hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java
#	hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java
#	hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java
#	hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyEmergencyServiceImpl.java
zhongwei
yang_shj 1 year ago
parent
commit
00f369472d
  1. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java
  2. 7
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/DeviceVo.java
  3. 8
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/StationVo.java
  4. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/WaterVo.java
  5. 33
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/entity/UserDeptEntity.java
  6. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java
  7. 1
      hzims-service/operational/pom.xml
  8. 168
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java
  9. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyEmergencyServiceImpl.java
  10. 38
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java
  11. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.java
  12. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.xml
  13. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/ISideHustleService.java
  14. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/UserDeptService.java
  15. 21
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaServiceImpl.java
  16. 26
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  17. 85
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java
  18. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/UserDeptServiceImpl.java

4
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java

@ -8,11 +8,13 @@ import java.util.List;
*/
public interface AbnormalAlarmConstant {
List<String> INTERRUPT_LIST = Arrays.asList("13","14");
List<String> TYPE_LIST = Arrays.asList("3","2","5","10","13","14");
List<Long> LONG_TYPE_LIST = Arrays.asList(3L,2L,5L,10L,13L,14L);
List<String> SEND_MESSSAGE_TYPE_LIST = Arrays.asList("2","13","14");
List<String> SEND_MESSSAGE_TYPE_LIST = Arrays.asList("3","13","14");
String LEVEL_TYPE_LIST = "3,2,5,10,13,14";

7
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/DeviceVo.java

@ -19,6 +19,9 @@ public class DeviceVo {
@ApiModelProperty(value = "设备状态")
private Boolean state;
@ApiModelProperty(value = "容量")
private Double capacity;
@ApiModelProperty(value = "有功功率")
private Double active;
@ -31,8 +34,8 @@ public class DeviceVo {
@ApiModelProperty(value = "下泄流量")
private Double discharge;
@ApiModelProperty(value = "发电流量")
private Double generate;
@ApiModelProperty(value = "发电效率")
private Double generateRate;
@ApiModelProperty(value = "建议有功调整")
private Double adjust;

8
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/StationVo.java

@ -27,9 +27,15 @@ public class StationVo {
@ApiModelProperty(value = "下泄流量")
private Double dischargeFlow;
@ApiModelProperty(value = "平均效率")
private Double generateRate;
@ApiModelProperty(value = "设备集合")
private List<DeviceVo> devices;
@ApiModelProperty(value = "设备集合")
@ApiModelProperty(value = "水位曲线集合")
private List<WaterVo> waters;
@ApiModelProperty(value = "下泄流量集合")
List<WaterVo> discharges;
}

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/WaterVo.java

@ -15,4 +15,7 @@ public class WaterVo {
@ApiModelProperty(value = "水位")
private Double water;
@ApiModelProperty(value = "下泄流量")
private Double discharge;
}

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

@ -0,0 +1,33 @@
package com.hnac.hzims.operational.main.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable;
/**
* @author ysj
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("hzims_user_dept")
public class UserDeptEntity extends TenantEntity implements Serializable {
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("用户ID")
private Long userId;
@ApiModelProperty("机构Id")
private Long deptId;
}

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java

@ -17,7 +17,7 @@ public class HydropowerUnitVo {
@ApiModelProperty(value = "水电站机组名称")
private String deivceName;
@ApiModelProperty(value = "排序")
@ApiModelProperty(value = "水电站机组名称")
private Integer ord;
@ApiModelProperty(value = "水电站机组实时数据")

1
hzims-service/operational/pom.xml

@ -139,6 +139,7 @@
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-user-api</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
<dependency>

168
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java

@ -1,7 +1,8 @@
package com.hnac.hzims.operational.alert.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.MessagePushRecordDto;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant;
import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity;
@ -24,6 +25,7 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
@ -31,8 +33,6 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -57,39 +57,57 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
private final IMessageClient messageClient;
/**
* 数据中断数据异常告警
* 故障中断异常告警数据处理
* @param param
*/
@Override
public void alarmDataHandle(String param) {
// 查询代运维站点
// 查询站点站点
List<StationEntity> stations = stationService.list();
if(CollectionUtil.isEmpty(stations)){
return;
}
// 查询告警数据: 间隔3分钟
SoeQueryConditionByStation query = new SoeQueryConditionByStation();
query.setTypes(AbnormalAlarmConstant.SEND_MESSSAGE_TYPE_LIST);
query.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
Calendar calendar = Calendar.getInstance();
query.setEndTime(LocalDateTime.parse(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER));
calendar.add(Calendar.MINUTE,-2);
calendar.add(Calendar.MINUTE,-3);
query.setBeginTime(LocalDateTime.parse(DateUtil.format(calendar.getTime() , DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER));
query.setNeedPage(false);
log.error("alarm_data_handle_param : {}",query);
query.setPage(1);
query.setLimit(100000);
Result<HzPage<SoeData>> result = soeClient.getByStationsAndTime(query);
// 未查询到告警信息
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData().getRecords())){
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())) {
return;
}
log.error("alarm_data_handle_begin_result : {}",result.getData().getRecords());
// 遍历告警信息
List<SoeData> list = new ArrayList<>(result.getData().getRecords().stream().sorted(Comparator.comparing(SoeData::getTs).reversed())
.collect(Collectors.toMap(o -> o.getStation() + o.getSoeType(), Function.identity(), (o1, o2) -> o1)).values());
log.error("alarm_data_handle_end_result : {}",list);
list.forEach(item -> {
result.getData().getRecords().forEach(item -> {
if(!AbnormalAlarmConstant.INTERRUPT_LIST.contains(item.getSoeType())){
return;
}
this.interrupt(stations,item);
});
// 历史数据处理
this.saveHistoryAlarm(stations,result.getData().getRecords());
}
/**
* 中断异常数据处理
* @param stations
* @param item
*/
private void interrupt(List<StationEntity> stations,SoeData item) {
// 查询中断数据
AbnormalAlarmEntity queryEntity = this.baseMapper.getAbnormalAlarm(item.getStation(),item.getSoeType());
// 是否为中断恢复
boolean flag = AbnormalAlarmConstant.ABNORMAL_STATUS.equals(item.getSoeAlarmType());
// 站点名称
String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null);
// 不存在记录进行保存
if(ObjectUtil.isEmpty(queryEntity)){
AbnormalAlarmEntity entity = new AbnormalAlarmEntity();
entity.setStationId(item.getStation());
@ -107,11 +125,9 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
}
// 保存告警信息
this.save(entity);
return;
}
// 存在记录进行修改
}else{
queryEntity.setSoeExplain(item.getSoeExplain());
queryEntity.setStationName(stationName);
queryEntity.setType(item.getSoeType());
queryEntity.setStartTime(queryEntity.getStartTime());
queryEntity.setUpdateTime(new Date());
queryEntity.setEndTime(null);
@ -121,60 +137,46 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
queryEntity.setStatus(1);
}
this.updateById(queryEntity);
});
// 异步保存历史告警
CompletableFuture.supplyAsync(()-> this.saveHistoryAlarm(result.getData().getRecords(),stations));
}
/**
* 查询实时告警数据
* @return
*/
@Override
public List<String> getAbnormalAlarmList() {
List<String> alarmList = this.baseMapper.getAbnormalAlarmList();
if(CollectionUtil.isEmpty(alarmList)){
return new ArrayList<>();
}
return alarmList;
}
/**
* 保存告警历史信息
* 历史数据处理
*
* @param stations
* @param list
* @return
*/
private String saveHistoryAlarm(List<SoeData> list,List<StationEntity> stations) {
list.forEach(item -> {
Date ts = DateUtil.parse(DateUtil.format(item.getTs(),DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMAT);
// 历史数据异常查询
HistoryAbnormalAlarmEntity queryEntity = this.historyAbnormalAlarmService.getAbnormalAlarm(item.getStation(),item.getSoeType());
// 数据中断恢复
boolean flag = AbnormalAlarmConstant.ABNORMAL_STATUS.equals(item.getSoeAlarmType());
String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null);
if(ObjectUtil.isEmpty(queryEntity) || !flag){
private void saveHistoryAlarm(List<StationEntity> stations, List<SoeData> list) {
List<HistoryAbnormalAlarmEntity> historys = historyAbnormalAlarmService.list(Wrappers.<HistoryAbnormalAlarmEntity>lambdaQuery()
.in(HistoryAbnormalAlarmEntity::getAlarmId,list.stream().map(SoeData::getId).collect(Collectors.toList()))
);
Set<String> explainSet = new HashSet<>();
list.forEach(item->{
if(CollectionUtil.isNotEmpty(historys) && historys.stream().map(HistoryAbnormalAlarmEntity::getAlarmId).collect(Collectors.toList()).contains(item.getId())){
return;
}
if(explainSet.contains(item.getSoeExplain())){
return;
}
HistoryAbnormalAlarmEntity entity = new HistoryAbnormalAlarmEntity();
String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null);
entity.setAlarmId(item.getId());
entity.setStationId(item.getStation());
entity.setStationName(stationName);
entity.setRealId(item.getRealId());
entity.setSoeExplain(item.getSoeExplain());
entity.setType(item.getSoeType());
entity.setStartTime(ts);
entity.setStatus(0);
entity.setStartTime(item.getTs());
if(AbnormalAlarmConstant.ABNORMAL_STATUS.equals(item.getSoeAlarmType())){
entity.setStatus(1);
}else{
entity.setStatus(1);
}
this.historyAbnormalAlarmService.save(entity);
// 消息推送
// 相同告警只允许添加一次,发送一次消息
explainSet.add(item.getSoeExplain());
this.sendAlarmMessage(Collections.singletonList(entity),stations);
return;
}
queryEntity.setSoeExplain(item.getSoeExplain());
queryEntity.setUpdateTime(new Date());
queryEntity.setEndTime(ts);
queryEntity.setStatus(1);
this.historyAbnormalAlarmService.updateById(queryEntity);
});
return "success";
}
/**
@ -199,34 +201,62 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
if(CollectionUtil.isEmpty(depts)){
return;
}
// 获取站点用户
R<List<User>> result = userClient.userListByDeptId(depts.get(0));
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
List<User> users = this.parentAuthUser(depts.get(0));
if(CollectionUtil.isEmpty(users)){
log.error("alarmmessagestation {} user is null",entity.getStationId());
return;
}
MessagePushRecordDto message = new MessagePushRecordDto();
BusinessMessageDTO message = new BusinessMessageDTO();
message.setDeptId(depts.get(0));
message.setBusinessClassify("warning");
message.setUserIds(users.stream().map(o->String.valueOf(o.getId())).distinct().collect(Collectors.joining(",")));
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey());
message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription());
message.setTaskId(entity.getId());
message.setTenantId("200000");
message.setContent(entity.getSoeExplain());
message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
message.setPushType(MessageConstants.IMMEDIATELY);
message.setDeptId(depts.get(0));
message.setCreateDept(depts.get(0));
R<String> deptName = sysClient.getDeptName(depts.get(0));
if (deptName.isSuccess()) {
message.setDeptName(deptName.getData());
}
User admin = userClient.userByAccount("200000", "admin").getData();
message.setCreateUser(admin.getId());
result.getData().forEach(user->{
message.setPusher(String.valueOf(user.getId()));
message.setPusherName(user.getName());
message.setAccount(String.valueOf(user.getId()));
messageClient.sendMessage(message);
});
messageClient.sendAppAndWsMsgByUsers(message);
});
}
/**
* 获取本级机构或者上级机构用户
* @param deptId
* @return
*/
private List<User> parentAuthUser(Long deptId) {
List<User> users = new ArrayList<>();
R<List<User>> selfs = userClient.userListByDeptId(deptId);
if(selfs.isSuccess() && CollectionUtil.isNotEmpty(selfs.getData())){
users.addAll(selfs.getData());
}
R<Dept> dept = sysClient.getDept(deptId);
if(dept.isSuccess() && ObjectUtil.isNotEmpty(dept.getData())){
R<List<User>> parents = userClient.userByDeptId("200000",deptId);
if(parents.isSuccess() && CollectionUtil.isNotEmpty(parents.getData())){
users.addAll(parents.getData());
}
}
return users;
}
/**
* 查询实时告警数据
* @return
*/
@Override
public List<String> getAbnormalAlarmList() {
List<String> alarmList = this.baseMapper.getAbnormalAlarmList();
if(CollectionUtil.isEmpty(alarmList)){
return new ArrayList<>();
}
return alarmList;
}
}

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyEmergencyServiceImpl.java

@ -80,12 +80,13 @@ public class ImsDutyEmergencyServiceImpl extends BaseServiceImpl<ImsDutyEmergenc
if (CollectionUtils.isNotEmpty(records)){
collect= records.stream().map(sig -> {
R<User> user = userClient.userInfoById(sig.getRegistrant());
if (!user.isSuccess()&&ObjectUtils.isNotEmpty(user)){
}
if (user.isSuccess()&&ObjectUtils.isNotEmpty(user.getData())){
sig.setRegistrantName(user.getData().getName());
}
R<User> userR = userClient.userInfoById(sig.getChargePerson());
if (userR.isSuccess()&&ObjectUtils.isNotEmpty(userR.getData())){
sig.setChargePersonName(userR.getData().getName());
}
ImsDutyClassEntity classEntity = imsDutyClassService.getById(sig.getDutyClass());
sig.setDutyClassName(classEntity.getClassName());
return sig;

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

@ -204,19 +204,43 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
// 实时水位
this.handleWaterLeve(item.getCode(),station);
station.setDevices(this.devices(item,station.getDischargeFlow(),realList,targetList));
// 站点平均效率
this.generateRate(station);
// 查询站点模型列表
HzimsAnalyzeModelStationEntity model = modelStationService.getOne(new LambdaQueryWrapper<HzimsAnalyzeModelStationEntity>() {{
eq(HzimsAnalyzeModelStationEntity::getStationId, item.getCode());
}});
// 水位曲线
if(ObjectUtil.isNotEmpty(model)){
station.setWaters(this.water(model.getInstanceCode()));
List<WaterVo> waters = this.water(model.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL);
List<WaterVo> discharges = this.water(model.getInstanceCode(),HomePageConstant.DISCHARGE_FLOW);
station.setWaters(waters.stream().peek(water->{
water.setDischarge(0.0);
List<WaterVo> filter = discharges.stream().filter(discharge->water.getTime().equals(discharge.getTime())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(filter)){
water.setDischarge(filter.get(0).getWater());
}
}).collect(Collectors.toList()));
station.setDischarges(discharges);
}
return station;
}).collect(Collectors.toList());
}
/**
* 站点平均发电效率
*/
private void generateRate(StationVo station) {
double capacitySum = station.getDevices().stream().mapToDouble(DeviceVo::getCapacity).sum();
double activeSum = station.getDevices().stream().mapToDouble(DeviceVo::getActive).sum();
if(Math.abs(capacitySum) <=0 || Math.abs(activeSum) <= 0){
station.setGenerateRate(0.0);
}else{
station.setGenerateRate(BigDecimal.valueOf(activeSum / capacitySum * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
}
/**
* 获取站点设备信息
* @param station
* @return
@ -233,6 +257,7 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
for(HydropowerUnitRealVo real : validRealList){
DeviceVo device= new DeviceVo();
// 设备编号
device.setCapacity(real.getInstalledCapacity());
device.setDeviceCode(real.getDeviceCode());
device.setDeviceName(real.getDeviceName());
device.setOrd(real.getOrd());
@ -242,7 +267,11 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
device.setDischarge(dischargeFlow);
device.setEcology(0.0);
device.setAdjust(0.0);
device.setGenerate(0.0);
if(Math.abs(device.getActive()) <=0 || Math.abs(device.getCapacity()) <= 0){
device.setGenerateRate(0.0);
}else{
device.setGenerateRate(BigDecimal.valueOf(device.getActive() / device.getCapacity() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
list.add(device);
}
return list.stream().sorted(Comparator.comparing(DeviceVo::getOrd)).collect(Collectors.toList());
@ -275,7 +304,7 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
* @param code
* @return
*/
private List<WaterVo> water(String code) {
private List<WaterVo> water(String code,String signages) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-7);
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY));
@ -283,8 +312,7 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME);
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,3,3,code,HomePageConstant.FRONT_WATER_LEVEL);
Random random = new Random();
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,3,3,code,signages);
if(CollectionUtil.isEmpty(records)){
return new ArrayList<>();
}

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.java

@ -0,0 +1,11 @@
package com.hnac.hzims.operational.main.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.operational.main.entity.UserDeptEntity;
/**
* @author ysj
*/
public interface UserDeptMapper extends BaseMapper<UserDeptEntity> {
}

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.operational.main.mapper.UserDeptMapper">
</mapper>

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

@ -29,6 +29,4 @@ public interface ISideHustleService {
List<MapMarkerVo> getMapMarker(Long deptId,List<Integer> types);
List<PlanGenerationEntity> getStaionPlanPower(Map<Dept, List<StationEntity>> map);
Map<Dept, List<StationEntity>> getAreaOrStaion(Long deptId, List<Integer> types);
}

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/UserDeptService.java

@ -0,0 +1,11 @@
package com.hnac.hzims.operational.main.service;
import com.hnac.hzims.operational.main.entity.UserDeptEntity;
import org.springblade.core.mp.base.BaseService;
/**
* @author ysj
*/
public interface UserDeptService extends BaseService<UserDeptEntity> {
}

21
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaServiceImpl.java

@ -1,10 +1,14 @@
package com.hnac.hzims.operational.main.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hnac.hzims.operational.main.entity.UserDeptEntity;
import com.hnac.hzims.operational.main.service.AreaService;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.UserDeptService;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import lombok.RequiredArgsConstructor;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
@ -25,7 +29,10 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class AreaServiceImpl implements AreaService {
private final UserDeptService userDeptService;
private final IStationService stationService;
private final ISysClient sysClient;
/**
@ -97,7 +104,19 @@ public class AreaServiceImpl implements AreaService {
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) {
return null;
}
if(ObjectUtil.isNotEmpty(deptId)){
List<UserDeptEntity> configs = userDeptService.list(new LambdaQueryWrapper<UserDeptEntity>(){{
eq(UserDeptEntity::getUserId, AuthUtil.getUserId());
}});
if(CollectionUtil.isNotEmpty(configs)){
List<StationEntity> stations =stationService.list(new LambdaQueryWrapper<StationEntity>(){{
eq(StationEntity::getType,HomePageConstant.HYDROPOWER);
eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
}});
if(CollectionUtil.isEmpty(stations)){
return new HashMap<>();
}
return stations.stream().collect(Collectors.toMap(m->R.getData().stream().filter(dept->m.getRefDept().equals(dept.getId())).collect(Collectors.toList()).get(0), Collections::singletonList));
}else if(ObjectUtil.isNotEmpty(deptId)){
List<Dept> list = R.getData().stream().filter(o->deptId.equals(o.getId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(list)){
return null;

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

@ -23,6 +23,7 @@ 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.entity.UserDeptEntity;
import com.hnac.hzims.operational.main.service.*;
import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant;
@ -42,6 +43,7 @@ import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
@ -82,6 +84,8 @@ public class HydropowerServiceImpl implements HydropowerService {
private final GenerateService generateService;
private final UserDeptService userDeptService;
private final PowerService photovoltaicService;
private final IImsDutyMainService dutyMainService;
@ -1000,7 +1004,7 @@ public class HydropowerServiceImpl implements HydropowerService {
@Override
public HydropowerScoreVo KPIs(Long deptId) {
// 查询水电站站点
List<StationEntity> stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), HomePageConstant.HYDROPOWER_SERVETYPE);
List<StationEntity> stations = this.getStations(deptId);
if (CollectionUtil.isEmpty(stations)) {
return new HydropowerScoreVo();
}
@ -1161,6 +1165,24 @@ public class HydropowerServiceImpl implements HydropowerService {
/**
* 获取站点
* @param deptId
* @return
*/
private List<StationEntity> getStations(Long deptId) {
List<UserDeptEntity> configs = userDeptService.list(new LambdaQueryWrapper<UserDeptEntity>(){{
eq(UserDeptEntity::getUserId, AuthUtil.getUserId());
}});
if(CollectionUtil.isNotEmpty(configs)){
return stationService.list(new LambdaQueryWrapper<StationEntity>(){{
eq(StationEntity::getType,HomePageConstant.HYDROPOWER);
eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
}});
}
return stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), HomePageConstant.HYDROPOWER_SERVETYPE);
}
/**
* 区域天气
* @param scale
* @param nowWeather
@ -1510,7 +1532,7 @@ public class HydropowerServiceImpl implements HydropowerService {
@Override
public List<AppHydropowerStationVo> area(Long deptId) {
// 查询水电站站点
List<StationEntity> stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), HomePageConstant.HYDROPOWER_SERVETYPE);
List<StationEntity> stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), null);
if (CollectionUtil.isEmpty(stations)) {
return new ArrayList<>();
}

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

@ -3,6 +3,7 @@ package com.hnac.hzims.operational.main.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
@ -24,6 +25,7 @@ import com.hnac.hzims.operational.duty.vo.DutyInfoVo;
import com.hnac.hzims.operational.duty.vo.DutyTaskVo;
import com.hnac.hzims.operational.duty.vo.NextDutyInfoVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.entity.UserDeptEntity;
import com.hnac.hzims.operational.main.service.*;
import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant;
@ -43,6 +45,7 @@ import com.xxl.job.core.log.XxlJobLogger;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springblade.system.entity.Dept;
@ -66,6 +69,8 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import static org.springblade.system.user.UserConstants.UserDataScopeTypeEnum.dept;
/**
* @author ysj
*/
@ -81,6 +86,8 @@ public class SideHustleServiceImpl implements ISideHustleService {
@NotNull
private final IStationService stationService;
@NotNull
private final UserDeptService userDeptService;
@NotNull
private final IPlanGenertionClient planGenertionClient;
@NotNull
private final IOperPhenomenonService operPhenomenonService;
@ -838,7 +845,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
@Override
public List<AreaPowerScaleVo> areaPowerScale(Long deptId) {
// 获取区域或者站点map结构
Map<Dept,List<StationEntity>> map = this.getAreaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER));
Map<Dept,List<StationEntity>> map = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER));
if(MapUtils.isEmpty(map)){
return null;
}
@ -872,7 +879,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
@Override
public List<OldAreaScaleVo> areaScale(Long deptId) {
// 获取区域或者站点map结构
Map<Dept,List<StationEntity>> map = this.getAreaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER));
Map<Dept,List<StationEntity>> map = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER));
if(MapUtils.isEmpty(map)){
return null;
}
@ -941,7 +948,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
types = Collections.singletonList(HomePageConstant.HYDROPOWER);
}
// 获取集团/区域map结构数据
Map<Dept, List<StationEntity>> deptMap = this.getAreaOrStaion(deptId,types);
Map<Dept, List<StationEntity>> deptMap = areaService.areaOrStaion(deptId,types);
if (MapUtils.isEmpty(deptMap)) {
return null;
}
@ -1193,7 +1200,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
List<String> runtList = deviceClassifyMap.get(HomePageConstant.RUN);
// 获取部门
Map<Dept, List<StationEntity>> deptMap = this.getAreaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER));
Map<Dept, List<StationEntity>> deptMap = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER));
if (MapUtils.isEmpty(deptMap)) {
return null;
}
@ -1282,45 +1289,6 @@ public class SideHustleServiceImpl implements ISideHustleService {
}
/**
* 获取区域或者站点map结构
* @param deptId
* @return
*/
@Override
public Map<Dept, List<StationEntity>> getAreaOrStaion(Long deptId,List<Integer> types) {
//根据用户权限获取机构
R<List<Dept>> R = sysClient.getDeptByCurrentUser();
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) {
return null;
}
if(ObjectUtil.isNotEmpty(deptId)){
List<Dept> list = R.getData().stream().filter(o->deptId.equals(o.getId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(list)){
return null;
}
Dept dept = list.get(0);
// 机构为站点 key-站点机构 value-站点
if(HomePageConstant.AREA.equals(dept.getDeptCategory())){
List<StationEntity> stationList = stationService.getStationList(R.getData(),dept.getId(),types,HomePageConstant.HYDROPOWER_SERVETYPE);
if(CollectionUtil.isEmpty(stationList)){
return null;
}
Map<Dept, List<StationEntity>> map = new HashMap<>();
stationList.forEach(item->{
List<Dept> stationDeptList = R.getData().stream().filter(o->o.getId().equals(item.getRefDept())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(stationDeptList)){
return;
}
// 站点机构
Dept station = stationDeptList.get(0);
map.put(station,Collections.singletonList(item));
});
return map;
}
}
return areaService.getAuthArea(R.getData(),deptId,types,HomePageConstant.HYDROPOWER_SERVETYPE);
}
/**
* 设备信息设置
@ -1544,7 +1512,6 @@ public class SideHustleServiceImpl implements ISideHustleService {
*/
@Override
public PowerFinishVo powerFinishMonth(Long deptId) {
// 获取用户权限机构
R<List<Dept>> R = sysClient.getDeptByCurrentUser();
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) {
return null;
@ -1555,8 +1522,32 @@ public class SideHustleServiceImpl implements ISideHustleService {
return null;
}
Dept area = list.get(0);
// 获取用户权限机构
List<StationEntity> stations = this.getPowerStation(R.getData(),area,deptId);
if(CollectionUtil.isEmpty(stations)){
return null;
}
List<String> dayList = this.getCurrentDayList();
// 获取区域月发电数据
return this.getPowerMonth(area,dayList,stations);
}
/**
* 智能生产-水电站获取
* @param deptId
*/
private List<StationEntity> getPowerStation(List<Dept> depts,Dept area,Long deptId) {
List<UserDeptEntity> configs = userDeptService.list(new LambdaQueryWrapper<UserDeptEntity>(){{
eq(UserDeptEntity::getUserId, AuthUtil.getUserId());
}});
if(CollectionUtil.isNotEmpty(configs)){
return stationService.list(new LambdaQueryWrapper<StationEntity>(){{
eq(StationEntity::getType,HomePageConstant.HYDROPOWER);
eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE);
}});
}
// 获取区域下站点级机构集合
List<Long> stationDeprList = homePageService.getChildDept(R.getData(), area.getId(), new ArrayList<>());
List<Long> stationDeprList = homePageService.getChildDept(depts, area.getId(), new ArrayList<>());
if (CollectionUtil.isEmpty(stationDeprList)) {
return null;
}
@ -1565,9 +1556,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
if(CollectionUtil.isEmpty(stationList)){
return null;
}
List<String> dayList = this.getCurrentDayList();
// 获取区域月发电数据
return this.getPowerMonth(area,dayList,stationList);
return stationList;
}
/**

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

@ -0,0 +1,18 @@
package com.hnac.hzims.operational.main.service.impl;
import com.hnac.hzims.operational.main.entity.UserDeptEntity;
import com.hnac.hzims.operational.main.mapper.UserDeptMapper;
import com.hnac.hzims.operational.main.service.UserDeptService;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* @author Lch
*/
@Service
@Slf4j
public class UserDeptServiceImpl extends BaseServiceImpl<UserDeptMapper, UserDeptEntity> implements UserDeptService {
}
Loading…
Cancel
Save