From 0eeb1931586444f211d7ff8b62323b325f244b9b Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 7 Jul 2023 16:08:37 +0800 Subject: [PATCH 1/7] =?UTF-8?q?#=E9=A3=8E=E7=94=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/ecology/vo/DeviceVo.java | 10 ++++-- .../hzims/operational/ecology/vo/StationVo.java | 8 ++++- .../hnac/hzims/operational/ecology/vo/WaterVo.java | 3 ++ .../impl/EcologyFlowStationServiceImpl.java | 41 ++++++++++++++++++---- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/DeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/DeviceVo.java index 99cd174..24834f6 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/DeviceVo.java +++ b/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,9 +34,12 @@ public class DeviceVo { @ApiModelProperty(value = "下泄流量") private Double discharge; - @ApiModelProperty(value = "发电流量") - private Double generate; + @ApiModelProperty(value = "发电效率") + private Double generateRate; @ApiModelProperty(value = "建议有功调整") private Double adjust; + + @ApiModelProperty(value = "排序") + private Integer ord; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/StationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/StationVo.java index da88113..0fd6dfd 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/StationVo.java +++ b/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 devices; - @ApiModelProperty(value = "设备集合") + @ApiModelProperty(value = "水位曲线集合") private List waters; + + @ApiModelProperty(value = "下泄流量集合") + List discharges; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/WaterVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/WaterVo.java index f112b59..5e348a4 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/ecology/vo/WaterVo.java +++ b/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; } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java index 3f26f45..585f897 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java @@ -196,19 +196,43 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl() {{ eq(HzimsAnalyzeModelStationEntity::getStationId, item.getCode()); }}); // 水位曲线 if(ObjectUtil.isNotEmpty(model)){ - station.setWaters(this.water(model.getInstanceCode())); + List waters = this.water(model.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); + List discharges = this.water(model.getInstanceCode(),HomePageConstant.DISCHARGE_FLOW); + station.setWaters(waters.stream().peek(water->{ + water.setDischarge(0.0); + List 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 @@ -225,18 +249,24 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl water(String code) { + private List 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)); @@ -274,8 +304,7 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl records = analyseDataService.periodTargetData(start,end,3,3,code,HomePageConstant.FRONT_WATER_LEVEL); - Random random = new Random(); + List records = analyseDataService.periodTargetData(start,end,3,3,code,signages); if(CollectionUtil.isEmpty(records)){ return new ArrayList<>(); } From 0fd4b4e84f1fe1c0376ce33825e35f9632c36c37 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 12 Jul 2023 11:21:45 +0800 Subject: [PATCH 2/7] =?UTF-8?q?#=E5=B9=BF=E5=AE=81=E6=B0=B4=E5=88=A9?= =?UTF-8?q?=E5=B1=80=E5=A4=A7=E5=B1=8F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/main/entity/UserDeptEntity.java | 33 +++++++++ .../operational/main/vo/HydropowerUnitVo.java | 3 + .../operational/main/mapper/UserDeptMapper.java | 11 +++ .../operational/main/mapper/UserDeptMapper.xml | 5 ++ .../main/service/ISideHustleService.java | 2 - .../operational/main/service/UserDeptService.java | 11 +++ .../main/service/impl/AreaServiceImpl.java | 21 +++++- .../main/service/impl/HydropowerServiceImpl.java | 27 ++++++- .../main/service/impl/SideHustleServiceImpl.java | 85 ++++++++++------------ .../main/service/impl/UserDeptServiceImpl.java | 18 +++++ 10 files changed, 163 insertions(+), 53 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/entity/UserDeptEntity.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.xml create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/UserDeptService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/UserDeptServiceImpl.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/entity/UserDeptEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/entity/UserDeptEntity.java new file mode 100644 index 0000000..ba35e1f --- /dev/null +++ b/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; + + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java index 33539d9..d02f355 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java @@ -17,6 +17,9 @@ public class HydropowerUnitVo { @ApiModelProperty(value = "水电站机组名称") private String deivceName; + @ApiModelProperty(value = "水电站机组名称") + private Integer ord; + @ApiModelProperty(value = "水电站机组实时数据") private HydropowerUnitRealVo hydropowerPumpRealVo; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.java new file mode 100644 index 0000000..e662bb4 --- /dev/null +++ b/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 { + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.xml new file mode 100644 index 0000000..8bfd4a9 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserDeptMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/ISideHustleService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/ISideHustleService.java index c729404..084660e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/ISideHustleService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/ISideHustleService.java @@ -29,6 +29,4 @@ public interface ISideHustleService { List getMapMarker(Long deptId,List types); List getStaionPlanPower(Map> map); - - Map> getAreaOrStaion(Long deptId, List types); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/UserDeptService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/UserDeptService.java new file mode 100644 index 0000000..7c28df7 --- /dev/null +++ b/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 { + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaServiceImpl.java index 2bdc625..7f41981 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaServiceImpl.java +++ b/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 configs = userDeptService.list(new LambdaQueryWrapper(){{ + eq(UserDeptEntity::getUserId, AuthUtil.getUserId()); + }}); + if(CollectionUtil.isNotEmpty(configs)){ + List stations =stationService.list(new LambdaQueryWrapper(){{ + 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 list = R.getData().stream().filter(o->deptId.equals(o.getId())).collect(Collectors.toList()); if(CollectionUtil.isEmpty(list)){ return null; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index 0c6eaf0..af62210 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/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; @@ -641,6 +645,7 @@ public class HydropowerServiceImpl implements HydropowerService { // 设备编号 hydropowerUnitVo.setDeivceCode(real.getDeviceCode()); hydropowerUnitVo.setDeivceName(real.getDeviceName()); + hydropowerUnitVo.setOrd(real.getOrd()); // 实时数据 hydropowerUnitVo.setHydropowerPumpRealVo(real); // 指标数据 @@ -652,7 +657,7 @@ public class HydropowerServiceImpl implements HydropowerService { } list.add(hydropowerUnitVo); } - return list.stream().sorted(Comparator.comparing(HydropowerUnitVo::getDeivceCode)).collect(Collectors.toList()); + return list.stream().sorted(Comparator.comparing(HydropowerUnitVo::getOrd)).collect(Collectors.toList()); } /** @@ -999,7 +1004,7 @@ public class HydropowerServiceImpl implements HydropowerService { @Override public HydropowerScoreVo KPIs(Long deptId) { // 查询水电站站点 - List stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), HomePageConstant.HYDROPOWER_SERVETYPE); + List stations = this.getStations(deptId); if (CollectionUtil.isEmpty(stations)) { return new HydropowerScoreVo(); } @@ -1160,6 +1165,24 @@ public class HydropowerServiceImpl implements HydropowerService { /** + * 获取站点 + * @param deptId + * @return + */ + private List getStations(Long deptId) { + List configs = userDeptService.list(new LambdaQueryWrapper(){{ + eq(UserDeptEntity::getUserId, AuthUtil.getUserId()); + }}); + if(CollectionUtil.isNotEmpty(configs)){ + return stationService.list(new LambdaQueryWrapper(){{ + 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 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java index adc1d46..d4adeea 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java +++ b/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 areaPowerScale(Long deptId) { // 获取区域或者站点map结构 - Map> map = this.getAreaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); + Map> 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 areaScale(Long deptId) { // 获取区域或者站点map结构 - Map> map = this.getAreaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); + Map> 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> deptMap = this.getAreaOrStaion(deptId,types); + Map> deptMap = areaService.areaOrStaion(deptId,types); if (MapUtils.isEmpty(deptMap)) { return null; } @@ -1193,7 +1200,7 @@ public class SideHustleServiceImpl implements ISideHustleService { List runtList = deviceClassifyMap.get(HomePageConstant.RUN); // 获取部门 - Map> deptMap = this.getAreaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); + Map> 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> getAreaOrStaion(Long deptId,List types) { - //根据用户权限获取机构 - R> R = sysClient.getDeptByCurrentUser(); - if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) { - return null; - } - if(ObjectUtil.isNotEmpty(deptId)){ - List 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 stationList = stationService.getStationList(R.getData(),dept.getId(),types,HomePageConstant.HYDROPOWER_SERVETYPE); - if(CollectionUtil.isEmpty(stationList)){ - return null; - } - Map> map = new HashMap<>(); - stationList.forEach(item->{ - List 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> 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 stations = this.getPowerStation(R.getData(),area,deptId); + if(CollectionUtil.isEmpty(stations)){ + return null; + } + List dayList = this.getCurrentDayList(); + // 获取区域月发电数据 + return this.getPowerMonth(area,dayList,stations); + } + + /** + * 智能生产-水电站获取 + * @param deptId + */ + private List getPowerStation(List depts,Dept area,Long deptId) { + List configs = userDeptService.list(new LambdaQueryWrapper(){{ + eq(UserDeptEntity::getUserId, AuthUtil.getUserId()); + }}); + if(CollectionUtil.isNotEmpty(configs)){ + return stationService.list(new LambdaQueryWrapper(){{ + eq(StationEntity::getType,HomePageConstant.HYDROPOWER); + eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); + }}); + } // 获取区域下站点级机构集合 - List stationDeprList = homePageService.getChildDept(R.getData(), area.getId(), new ArrayList<>()); + List 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 dayList = this.getCurrentDayList(); - // 获取区域月发电数据 - return this.getPowerMonth(area,dayList,stationList); + return stationList; } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/UserDeptServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/UserDeptServiceImpl.java new file mode 100644 index 0000000..4d1b7df --- /dev/null +++ b/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 implements UserDeptService { + +} From f1b15ed9442c24b28af0dc9624ab6d61d16d51dd Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 26 Jul 2023 08:38:01 +0800 Subject: [PATCH 3/7] =?UTF-8?q?#=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java index c80cfdf..88e8312 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java @@ -67,7 +67,7 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl stations = stationService.getStationByType(null,HomePageConstant.HYDROPOWER_SERVETYPE); + List stations = stationService.list(); if(CollectionUtil.isEmpty(stations)){ return; } From 28c3776f99a209306f2f4d4b68a6dae9a906b5a7 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 26 Jul 2023 14:48:06 +0800 Subject: [PATCH 4/7] =?UTF-8?q?#=E6=B6=88=E6=81=AF=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-biz-common/pom.xml | 4 + .../logs/constant/TicketProcessConstant.java | 32 ------- .../com/hnac/hzims/common/utils/Condition.java | 61 ++++++++++++ .../alert/constants/AbnormalAlarmConstant.java | 2 +- .../com/hnac/hzims/message/MessageConstants.java | 8 +- .../hnac/hzims/message/dto/BusinessMessageDTO.java | 66 +++++++++++++ .../hnac/hzims/message/fegin/IMessageClient.java | 15 ++- .../hzims/message/fegin/MessageClientFallback.java | 10 +- .../vo/msgpushrecord/PushStatResponseVo.java | 33 +++++++ .../vo/msgpushrecord/UserPushStatResponseVo.java | 33 +++++++ .../msgpushrecord/UserPushStatTypeResponseVo.java | 28 ++++++ .../vo/msgpushrecord/UserPushStatTypeVo.java | 4 + .../hzims/message/config/ThreadPoolConfig.java | 6 +- .../message/controller/MessageController.java | 20 +++- .../controller/MessagePushRecordController.java | 2 - .../web/MessageStatisticsController.java | 14 ++- .../hnac/hzims/message/fegin/MessageClient.java | 49 ++++++++-- .../message/mapper/MessagePushRecordMapper.java | 8 ++ .../message/mapper/MessagePushRecordMapper.xml | 34 +++++++ .../message/service/IMessagePushRecordService.java | 14 +++ .../service/impl/MessagePushRecordServiceImpl.java | 106 ++++++++++++++++++--- .../service/impl/PushMessageServiceImpl.java | 79 +++++++++------ .../message/service/impl/WebsocketServiceImpl.java | 1 + .../service/impl/AbnormalAlarmServiceImpl.java | 46 +++++---- 24 files changed, 554 insertions(+), 121 deletions(-) delete mode 100644 hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/constant/TicketProcessConstant.java create mode 100644 hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/BusinessMessageDTO.java create mode 100644 hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatResponseVo.java create mode 100644 hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatResponseVo.java create mode 100644 hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeResponseVo.java diff --git a/hzims-biz-common/pom.xml b/hzims-biz-common/pom.xml index be7e8e8..de9115d 100644 --- a/hzims-biz-common/pom.xml +++ b/hzims-biz-common/pom.xml @@ -22,6 +22,10 @@ blade-core-auto provided + + org.springblade + blade-common + com.alibaba diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/constant/TicketProcessConstant.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/constant/TicketProcessConstant.java deleted file mode 100644 index 466e9e4..0000000 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/constant/TicketProcessConstant.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.common.logs.constant; - -/** - * 开票常量类 - * - * @Author WL - * @Version v1.0 - * @Serial 1.0 - * @Date 2023/4/8 10:53 - */ -public class TicketProcessConstant { - - /** - * 第一种工作票的key - */ - public static final String FIRST_TICKET_KEY = "networking"; - - - /** - * 操作票 - */ - public static final String OPERATION_TICKET_KEY = "moreActionBankDirect"; - - /** - * 水力机械工作票 - */ - public static final String MACHINERY_TICKET_KEY = "machinery"; - /** - * 日常维护 - */ - public static final String MAINTENANCE_KEY = "maintenance"; -} diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/Condition.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/Condition.java index 6b76112..571cb72 100644 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/Condition.java +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/Condition.java @@ -32,6 +32,67 @@ public class Condition extends org.springblade.core.mp.support.Condition { return c; } + public static LambdaQueryWrapper getQueryWrapper(Class clazz, Object query) { + QueryWrapper qw = new QueryWrapper(); + qw.setEntityClass(clazz); + Class queryClass = query.getClass(); + List fieldList = new ArrayList<>(); + while (null != queryClass){ + fieldList.addAll(Arrays.asList(queryClass.getDeclaredFields())); + queryClass = queryClass.getSuperclass(); + } + for(Field field:fieldList){ + field.setAccessible(true); + QueryField queryField = field.getAnnotation(QueryField.class); + if(queryField==null) { + continue; + } + Object value; + try { + value = field.get(query); + } catch (Exception e) { + throw new ServiceException("获取属性性出错"); + } + if(value==null) { + continue; + } + List list = null; + if(value instanceof List){ + list = (List)value; + if(list.size()==0) { + continue; + } + } + String condition = queryField.condition(); + if(Func.isBlank(condition)) { + continue; + } + String fileName = camel2under(field.getName()); + if(SqlCondition.EQUAL.equals(condition)) { + qw.eq(fileName, value); + }else if(SqlCondition.LIKE.equals(condition)){ + qw.like(fileName,value); + }else if(SqlCondition.LIKE_LEFT.equals(condition)){ + qw.likeLeft(fileName,value); + }else if(SqlCondition.LIKE_RIGHT.equals(condition)){ + qw.likeRight(fileName,value); + }else if(SqlCondition.NOT_IN.equals(condition)){ + String columnName = queryField.columnName(); + if(Func.isBlank(columnName)) { + throw new ServiceException("查询不包含条件时需要指定列名"); + } + qw.notIn(camel2under(columnName),list); + }else if(SqlCondition.IN.equals(condition)){ + String columnName = queryField.columnName(); + if(Func.isBlank(columnName)) { + throw new ServiceException("查询包含条件时需要指定列名"); + } + qw.in(camel2under(columnName),list); + } + } + return qw.lambda(); + } + /** * 支持配置化的模糊查询 * @param entity 数据库返回的对象实体 diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java index eab3ee0..1f18d55 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java @@ -12,7 +12,7 @@ public interface AbnormalAlarmConstant { List LONG_TYPE_LIST = Arrays.asList(3L,2L,5L,10L,13L,14L); - List SEND_MESSSAGE_TYPE_LIST = Arrays.asList("2","13","14"); + List SEND_MESSSAGE_TYPE_LIST = Arrays.asList("3","13","14"); String LEVEL_TYPE_LIST = "3,2,5,10,13,14"; diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java index 6741a3f..abe695b 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java @@ -1,7 +1,6 @@ package com.hnac.hzims.message; import lombok.AllArgsConstructor; -import lombok.Data; import lombok.Getter; import lombok.NoArgsConstructor; @@ -53,8 +52,15 @@ public class MessageConstants { DUTY("duty","值班消息"), SAFE("safe","安全消息"), ACCESS("access","检修消息"), + BUSINESS("business","事务消息"), TICKETMESSAGE("ticket-message","工作票消息"), OPERATIONTICKETMESSAGE("operation-ticket-message","操作票消息"), + ROUTINEMAINTENANCE("operation-maintenance-message","日常维护消息"), + OPERATIONDEFECTMESSAGE("operation-defect-message","消缺消息"), + + OVERHAUL_PLAN("overhaul-plan","检修计划"), + + OVERHAUL_TASK("overhaul-task","检修任务"), ; @Getter private String key; diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/BusinessMessageDTO.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/BusinessMessageDTO.java new file mode 100644 index 0000000..b3d8d4c --- /dev/null +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/BusinessMessageDTO.java @@ -0,0 +1,66 @@ +package com.hnac.hzims.message.dto; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +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.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + * @ClassName BusinessMessageDTO + * @description: + * @author: hx + * @create: 2023-06-15 19:10 + * @Version 4.0 + **/ +@Data +@ApiModel("事务消息") +@EqualsAndHashCode +public class BusinessMessageDTO implements Serializable { + @ApiModelProperty(value = "机构ID",required = true) + @NotNull(message = "机构ID不能为空") + private Long deptId; + + @ApiModelProperty("机构名称") + private String deptName; + + @ApiModelProperty(value = "业务关键字",required = true) + @NotNull(message = "业务关键字不能为空") + private String businessKey; + + @ApiModelProperty(value = "业务分类。系统通知:system,事务消息:business,日常提醒:dailyRemind,巡检消息:inspect",required = true) + @NotNull(message = "业务分类不能为空") + private String businessClassify; + + @ApiModelProperty("业务任务ID") + @QueryField(condition = SqlCondition.EQUAL) + private Long taskId; + + @NotNull + @ApiModelProperty(value = "内容") + private String content; + + @NotNull + @ApiModelProperty(value = "主题") + private String subject; + + @NotNull + @ApiModelProperty(value = "推送用户") + private String userIds; + + @ApiModelProperty(value = "创建用户") + private Long createUser; + + @ApiModelProperty(value = "租户ID") + private String tenantId; +} diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java index be87e27..887e97c 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java @@ -1,10 +1,7 @@ package com.hnac.hzims.message.fegin; import com.hnac.hzims.message.MessageConstants; -import com.hnac.hzims.message.dto.MessagePushRecordDto; -import com.hnac.hzims.message.dto.PlanMsgRecordDto; -import com.hnac.hzims.message.dto.PushDto; -import com.hnac.hzims.message.dto.SmsPushDto; +import com.hnac.hzims.message.dto.*; import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.entity.config.MessageTemplateEntity; import org.springblade.core.tool.api.R; @@ -29,6 +26,7 @@ public interface IMessageClient { String SEND_MESSAGE = API_PREFIX + "/sendMessage"; String GET_TEMPLATE_BY_ID = API_PREFIX + "/getMsgTemplateById"; String PLAN_SEND_MESSAGE = API_PREFIX + "/planSendMessage"; + String SEND_APP_AND_WS_MSG = API_PREFIX + "/sendAppAndWsMsgByUsers"; /** * 推送消息(短信) @@ -54,4 +52,13 @@ public interface IMessageClient { **/ @PostMapping(PLAN_SEND_MESSAGE) R planSendMessage(@RequestBody PlanMsgRecordDto request); + + /** + * 发送多人APP、WEB消息 + * @Author hx + * @param request + * @return + */ + @PostMapping(value = SEND_APP_AND_WS_MSG,consumes = "application/json; charset=UTF-8") + R sendAppAndWsMsgByUsers(@RequestBody BusinessMessageDTO request); } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/MessageClientFallback.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/MessageClientFallback.java index e03c604..37f26e4 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/MessageClientFallback.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/MessageClientFallback.java @@ -1,9 +1,6 @@ package com.hnac.hzims.message.fegin; -import com.hnac.hzims.message.dto.MessagePushRecordDto; -import com.hnac.hzims.message.dto.PlanMsgRecordDto; -import com.hnac.hzims.message.dto.PushDto; -import com.hnac.hzims.message.dto.SmsPushDto; +import com.hnac.hzims.message.dto.*; import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.entity.config.MessageTemplateEntity; import org.springblade.core.tool.api.R; @@ -34,4 +31,9 @@ public class MessageClientFallback implements IMessageClient { public R planSendMessage(PlanMsgRecordDto request) { return R.fail("调用失败!"); } + + @Override + public R sendAppAndWsMsgByUsers(BusinessMessageDTO request) { + return R.fail("调用失败!"); + } } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatResponseVo.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatResponseVo.java new file mode 100644 index 0000000..7850b7b --- /dev/null +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatResponseVo.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.message.vo.msgpushrecord; + +import lombok.Data; + +import java.util.List; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/29 14:18 + */ +@Data +public class PushStatResponseVo { + + /** + * 推送人名称 + */ + private String pusherName; + + /** + * 业务分类 + */ + private String businessClassify; + /** + * 业务分类名称 + */ + private String businessClassifyName; + /** + * 统计数量 + */ + private Integer count; +} diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatResponseVo.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatResponseVo.java new file mode 100644 index 0000000..b40af0d --- /dev/null +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatResponseVo.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.message.vo.msgpushrecord; + +import lombok.Data; + +import javax.sound.sampled.Port; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/29 13:58 + */ +@Data +public class UserPushStatResponseVo { + + /** + * 业务分类 + */ + private String businessClassify; + + /** + * 业务分类名称 + */ + private String businessClassifyName; + + /** + * 封装map + */ + private Map params; +} diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeResponseVo.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeResponseVo.java new file mode 100644 index 0000000..1536709 --- /dev/null +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeResponseVo.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.message.vo.msgpushrecord; + +import lombok.Data; + +import java.util.List; +import java.util.Set; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/6/29 13:46 + */ +@Data +public class UserPushStatTypeResponseVo { + + /** + * 封装人员信息 + */ + private List userNames; + + + /** + * 封装业务分类对象 + */ + private List userPushStatResponseVos; + +} diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeVo.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeVo.java index 8ac126f..2ed9570 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeVo.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/UserPushStatTypeVo.java @@ -22,4 +22,8 @@ public class UserPushStatTypeVo { * 推送业务分类数组 */ private List pushStatList; + + + + } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java index d8feb4f..b3e8b1a 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java @@ -18,9 +18,13 @@ public class ThreadPoolConfig { @Bean public ExecutorService logExecutorService() { - return new ThreadPoolExecutor(1, 1, + return new ThreadPoolExecutor(2, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); } + @Bean + public ExecutorService appMessagePushExecutor() { + return new ThreadPoolExecutor(2, 5, 5L, TimeUnit.SECONDS,new LinkedBlockingQueue()); + } } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageController.java index 4b84621..89a171d 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageController.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageController.java @@ -7,6 +7,7 @@ import com.hnac.hzims.message.dto.SmsPushDto; import com.hnac.hzims.message.dto.WsPushDto; import com.hnac.hzims.message.fegin.IPushMsgClient; import com.hnac.hzims.message.service.IMessageService; +import com.hnac.hzims.message.service.IPushMessageService; import com.hnac.hzims.message.service.impl.MailMessageServiceImpl; import com.hnac.hzims.message.service.impl.PushMessageServiceImpl; import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl; @@ -14,16 +15,16 @@ import com.hnac.hzims.message.service.impl.WebsocketServiceImpl; import com.hnac.hzims.message.utils.HtmlModule; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.SpringUtil; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import java.util.List; import java.util.Map; /** @@ -79,4 +80,15 @@ public class MessageController extends BladeController { IMessageService messageService = SpringUtil.getBean(WebsocketServiceImpl.class); return messageService.send(wsPushDto); } + + @GetMapping("/sendByUsers") + @ApiOperation("发送APP消息(多人)") + @ApiOperationSupport(order=5) + public R sendByUsers(@ApiParam("消息主题") String subject, + @ApiParam("消息内容") String content, + @ApiParam("用户ID列表") String userIds, + @ApiParam("租户ID") String tenantId) throws Exception { + PushMessageServiceImpl messageService = SpringUtil.getBean(PushMessageServiceImpl.class); + return R.status(messageService.sendByUsers(subject,content, Func.toStrList(",",userIds),tenantId)); + } } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java index 83fcb29..c5c3958 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java @@ -102,8 +102,6 @@ public class MessagePushRecordController extends BladeController { @GetMapping("/getPersonalUnreadMessage") @ApiOperation("获取当前登录人待办消息") @ApiOperationSupport(order = 8) - @OperationAnnotation(moduleName = "视频集中监控", title = "视频集中监控", action = "获取当前登录人待办消息", - operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE) public R> getPersonalUnreadMessage() { List personalUnreadMessage = messagePushRecordService.getPersonalUnreadMessage(); return R.data(personalUnreadMessage); diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java index 1c43025..154660e 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java @@ -56,10 +56,22 @@ public class MessageStatisticsController { /** * 人员发送统计 */ + @GetMapping("/userPushStatWithMessgae") + public R userPushStatWithMessgae(MessagePushRecordEntityVo vo) { + log.info("人员发送统计"); + List messagePushRecordVos = messagePushRecordService.userPushStat(vo); + log.info("人员发送统计 返回的数据: {}",messagePushRecordVos); + return R.data(messagePushRecordVos); + } + + + /** + * 新人员发送统计 + */ @GetMapping("/userPushStat") public R userPushStat(MessagePushRecordEntityVo vo) { log.info("人员发送统计"); - List messagePushRecordVos = messagePushRecordService.userPushStat(vo); + UserPushStatTypeResponseVo messagePushRecordVos = messagePushRecordService.newUserPushStat(vo); log.info("人员发送统计 返回的数据: {}",messagePushRecordVos); return R.data(messagePushRecordVos); } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java index 57afdb2..0660fdd 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java @@ -2,28 +2,26 @@ package com.hnac.hzims.message.fegin; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; import com.hnac.hzims.message.MessageConstants; -import com.hnac.hzims.message.dto.MessagePushRecordDto; -import com.hnac.hzims.message.dto.PlanMsgRecordDto; -import com.hnac.hzims.message.dto.PushDto; -import com.hnac.hzims.message.dto.SmsPushDto; +import com.hnac.hzims.message.dto.*; import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.entity.config.MessageTemplateEntity; import com.hnac.hzims.message.service.IMessagePushRecordService; import com.hnac.hzims.message.service.IMessageService; import com.hnac.hzims.message.service.IMessageTemplateService; +import com.hnac.hzims.message.service.impl.PushMessageServiceImpl; import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.SpringUtil; +import org.springblade.core.tool.utils.*; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springframework.util.Assert; @@ -33,7 +31,9 @@ import javax.validation.Valid; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Arrays; +import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; /** * @author hx @@ -115,4 +115,37 @@ public class MessageClient extends BladeController implements IMessageClient{ return R.success("推送成功!"); } + @Override + @PostMapping(value = SEND_APP_AND_WS_MSG , produces="application/json; charset=UTF-8") + public R sendAppAndWsMsgByUsers(@RequestBody BusinessMessageDTO request) { + // 保存消息记录 + List pushRecords = Func.toLongList(request.getUserIds()).stream().flatMap(userId -> { + long messageId = IdWorker.getId(); + return Lists.newArrayList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH).stream().map(messageType -> { + MessagePushRecordEntity record = BeanUtil.copy(request, MessagePushRecordEntity.class); + record.setMessageId(messageId); + record.setPusher(userId.toString()); + record.setPusherName(Optional.ofNullable(UserCache.getUser(userId)).map(User::getName).orElse(null)); + record.setPushType(MessageConstants.IMMEDIATELY); + record.setAccount(userId.toString()); + record.setPlanTime(LocalDateTime.now()); + record.setType(messageType); + record.setCreateDept(record.getDeptId()); + return record; + }); + }).collect(Collectors.toList()); + boolean saveResult = recordService.saveBatch(pushRecords); + if(saveResult) { + List appRecords = pushRecords.stream().filter(record -> MessageConstants.APP_PUSH.equals(record.getType())).collect(Collectors.toList()); + // 推送消息 - app + Boolean appFlag = recordService.sendAppMsgByUsers(request, appRecords); + // 推送消息 - web + Boolean wsFlag = recordService.sendWsMsgByUsers(CollectionUtils.subtract(pushRecords, appRecords).stream().collect(Collectors.toList())); + return R.data(appFlag && wsFlag); + } + else { + return R.data(false); + } + } + } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java index c317ec1..4d76dc3 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java @@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import java.util.List; +import java.util.Set; public interface MessagePushRecordMapper extends UserDataScopeBaseMapper { @@ -43,4 +44,11 @@ public interface MessagePushRecordMapper extends UserDataScopeBaseMapper selectByStatus(); + + /** + * 新人员发送统计 + * @param vo + * @return + */ + List selectUserPushStat(@Param("vo") MessagePushRecordEntityVo vo); } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml index 0eb5aa4..a44dbe5 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml @@ -14,6 +14,7 @@ + @@ -50,6 +52,7 @@ and type = #{vo.type} + and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null) group by businessClassify @@ -74,6 +77,7 @@ and type = #{vo.type} + and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null) group by businessClassify, pusherName @@ -107,6 +111,7 @@ and type = #{vo.type} + and (BUSINESS_CLASSIFY != '' and BUSINESS_CLASSIFY is not null) group by businessClassify,status @@ -116,4 +121,33 @@ from hzims_message_push_record group by STATUS + + + + + + + \ No newline at end of file diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java index 40e5e03..56a2974 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java @@ -1,11 +1,14 @@ package com.hnac.hzims.message.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.message.dto.BusinessMessageDTO; import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.vo.UnreadMessageVO; import com.hnac.hzims.message.vo.msgpushrecord.*; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -84,4 +87,15 @@ public interface IMessagePushRecordService extends BaseService getPersonalAppUnreadMessage(); + Boolean sendAppMsgByUsers(BusinessMessageDTO request,List records); + + Boolean sendWsMsgByUsers(List request); + + + /** + * 新人员发送统计 + * @param vo + * @return + */ + UserPushStatTypeResponseVo newUserPushStat(MessagePushRecordEntityVo vo); } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java index 437cacc..909b955 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java @@ -14,6 +14,7 @@ import com.google.common.collect.Lists; import com.hnac.hzims.common.utils.CacheUtil; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.config.MessageFactory; +import com.hnac.hzims.message.dto.BusinessMessageDTO; import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.enums.PushStatEnum; import com.hnac.hzims.message.mapper.MessagePushRecordMapper; @@ -22,29 +23,25 @@ import com.hnac.hzims.message.service.IMessagePushRecordService; import com.hnac.hzims.message.service.IMessageService; import com.hnac.hzims.message.vo.UnreadMessageVO; import com.hnac.hzims.message.vo.msgpushrecord.*; +import io.minio.messages.Item; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.mp.support.Condition; +import com.hnac.hzims.common.utils.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.SpringUtil; import org.springblade.system.cache.DictCache; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import javax.validation.Valid; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.Year; -import java.time.YearMonth; +import java.time.*; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @Service @@ -118,13 +115,14 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl getQueryWrapper(MessagePushRecordEntity request) { - LambdaQueryWrapper lambda = Condition.getQueryWrapper(request).lambda(); - if (Func.isNotEmpty(request.getStartTime())) { - lambda.ge(MessagePushRecordEntity::getPushTime, request.getStartTime()); + LambdaQueryWrapper lambda = Condition.getQueryWrapper(MessagePushRecordEntity.class,request); + if(Func.isNotEmpty(request.getStartTime())) { + lambda.ge(MessagePushRecordEntity::getPushTime, LocalDateTime.of(request.getStartTime(), LocalTime.MIN)); } - if (Func.isNotEmpty(request.getEndTime())) { - lambda.le(MessagePushRecordEntity::getPushTime, request.getEndTime()); + if(Func.isNotEmpty(request.getEndTime())) { + lambda.le(MessagePushRecordEntity::getPushTime, LocalDateTime.of(request.getEndTime(), LocalTime.MAX)); } + lambda.eq(Func.isNotEmpty(request.getStatus()),MessagePushRecordEntity::getStatus,request.getStatus()); lambda.orderByDesc(MessagePushRecordEntity::getPushTime); return lambda; } @@ -234,11 +232,55 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl results = new ArrayList<>(); + List pushStat = baseMapper.selectUserPushStat(vo); + List list = pushStat.stream().map(item -> item.getPusherName()).distinct().collect(Collectors.toList()); + pushStatList.setUserNames(list); + //封装业务分类对象 + Map> collect = pushStat.stream().collect(Collectors.groupingBy(PushStatResponseVo::getBusinessClassify)); + // + for (Map.Entry> entry : collect.entrySet()) { + List arrayList = Lists.newArrayList(list); + UserPushStatResponseVo userPushStatTypeResponseVo = new UserPushStatResponseVo(); + //存储key + userPushStatTypeResponseVo.setBusinessClassify(entry.getKey()); + userPushStatTypeResponseVo.setBusinessClassifyName(this.getBusinessClassifyByName(entry.getKey())); + TreeMap treeMap = new TreeMap<>(); + //存储业务分类 + List pushStatResponseVos = entry.getValue(); + for (PushStatResponseVo pushStatResponseVo : pushStatResponseVos) { + if (arrayList.contains(pushStatResponseVo.getPusherName())){ + arrayList.remove(pushStatResponseVo.getPusherName()); + } + treeMap.put(pushStatResponseVo.getPusherName(),pushStatResponseVo.getCount()); + } + //如果不存在设为0 + for (String name : arrayList) { + treeMap.put(name,0); + } + userPushStatTypeResponseVo.setParams(treeMap); + results.add(userPushStatTypeResponseVo); + } + pushStatList.setUserPushStatResponseVos(results); + + return pushStatList; + } + + /** * 推送成功失败统计 * @@ -321,6 +363,40 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl records) { + PushMessageServiceImpl service = SpringUtil.getBean(PushMessageServiceImpl.class); + try { + boolean sendFlag = service.sendByUsers(request.getSubject(), request.getContent(), Arrays.asList(request.getUserIds().split(",")), request.getTenantId()); + if (sendFlag) { + return this.update(Wrappers.lambdaUpdate() + .set(MessagePushRecordEntity::getPushTime, LocalDateTime.now()) + .set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS) + .in(MessagePushRecordEntity::getId, records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList())) + ); + } + return false; + } catch (Exception e) { + throw new ServiceException(e.getMessage()); + } + } + + @Override + public Boolean sendWsMsgByUsers(List request) { + WebsocketServiceImpl service = SpringUtil.getBean(WebsocketServiceImpl.class); + request.forEach(record -> { + boolean sendFlag = service.send(record); + if (sendFlag) { + this.update(Wrappers.lambdaUpdate() + .set(MessagePushRecordEntity::getPushTime, LocalDateTime.now()) + .set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS) + .in(MessagePushRecordEntity::getId, record.getId()) + ); + } + }); + return true; + } + /** * 状态 ===> 状态名称 diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java index b62134f..9c1d6be 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java @@ -29,6 +29,9 @@ import org.springframework.util.Assert; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.FutureTask; import java.util.concurrent.atomic.AtomicReference; /** @@ -40,6 +43,7 @@ public class PushMessageServiceImpl implements IMessageService { private final IPushClient pushClient; private final BladeLogger logger; + private final ExecutorService appMessagePushExecutor; @Override @SaveLog(type = MessageConstants.APP_NAME) @@ -85,36 +89,51 @@ public class PushMessageServiceImpl implements IMessageService { } @Override - public boolean send(MessagePushRecordEntity request) { - PushInfoVO pushInfoVO = new PushInfoVO(); - pushInfoVO.setTenantId(Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId()); - ArrayList platformTypes = Lists.newArrayList(PlatformType.Android, PlatformType.IOS); - platformTypes.forEach(platformType -> { - PushPlatform platform = PushPlatform.newBuilder().addPlatformType(platformType).build(); - R response; - // 安卓推送 - if(PlatformType.Android.equals(platformType)) { - PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, Lists.newArrayList(request.getPusher())).build(); - PushInfo pushInfo = new PushInfo("ops-push-android", request.getSubject(), request.getContent(), - "", null, platform, pushAudience); - pushInfoVO.setPushInfo(pushInfo); - response = pushClient.tenantPush(pushInfoVO); - } - // IOS推送 - else if(PlatformType.IOS.equals(platformType)) { - PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, Lists.newArrayList(request.getPusher())).build(); - PushInfo pushInfo = new PushInfo("ops-push-ios", request.getSubject(), request.getContent(), - "", null, platform, pushAudience); - pushInfoVO.setPushInfo(pushInfo); - response = pushClient.tenantPush(pushInfoVO); - } else { - response = null; - } - Assert.isTrue(ObjectUtil.isNotEmpty(response) && response.isSuccess(),() -> { - logger.error("hzims-message:PushMessageServiceImpl:send", "请求参数为:"+JSON.toJSONString(pushInfoVO)+"错误信息为:"+response.getMsg()); - throw new ServiceException(response.getMsg()); - }); + public boolean send(MessagePushRecordEntity request) { + String tenantId = Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId(); + try { + return this.sendByUsers(request.getSubject(), request.getContent(), Func.toStrList(",",request.getPusher()),tenantId); + } + catch (Exception e) { + throw new ServiceException(e.getMessage()); + } + } + + /** + * 发送APP消息(多人) + * @param subject 消息主题 + * @param content 消息内容 + * @param userIds 用户ID列表 + * @param tenantId 租户ID + * @return + */ + public boolean sendByUsers(String subject, String content, List userIds,String tenantId) throws Exception { + // 安卓推送 + FutureTask androidPush = new FutureTask<>(() -> { + PushInfoVO pushInfoVO = new PushInfoVO(); + PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.Android).build(); + PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build(); + PushInfo pushInfo = new PushInfo("ops-push-android", subject, content,"", null, pushPlatform, pushAudience); + pushInfoVO.setPushInfo(pushInfo); + pushInfoVO.setTenantId(tenantId); + R pushResult = pushClient.tenantPush(pushInfoVO); + return pushResult.isSuccess(); }); - return true; + appMessagePushExecutor.submit(new Thread(androidPush,"安卓推送")); + + // IOS推送 + FutureTask iosPush = new FutureTask<>(() -> { + PushInfoVO pushInfoVO = new PushInfoVO(); + PushPlatform pushPlatform = PushPlatform.newBuilder().addPlatformType(PlatformType.IOS).build(); + PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, userIds).build(); + PushInfo pushInfo = new PushInfo("ops-push-ios", subject, content,"", null, pushPlatform, pushAudience); + pushInfoVO.setPushInfo(pushInfo); + pushInfoVO.setTenantId(tenantId); + R pushResult = pushClient.tenantPush(pushInfoVO); + return pushResult.isSuccess(); + }); + appMessagePushExecutor.submit(new Thread(iosPush,"ios推送")); + + return androidPush.get() && iosPush.get(); } } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java index 07730aa..419da82 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WebsocketServiceImpl.java @@ -23,6 +23,7 @@ import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; import java.io.IOException; import java.time.LocalDateTime; +import java.util.List; import java.util.concurrent.TimeUnit; /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java index 88e8312..aa406db 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java @@ -1,16 +1,15 @@ package com.hnac.hzims.operational.alert.service.impl; import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.BusinessMessageDTO; import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity; import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; -import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity; import com.hnac.hzims.operational.alert.mapper.AbnormalAlarmMapper; import com.hnac.hzims.operational.alert.service.AbnormalAlarmService; import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService; -import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzinfo.datasearch.soe.ISoeClient; @@ -18,7 +17,6 @@ import com.hnac.hzinfo.datasearch.soe.domian.SoeData; import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation; import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; - import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; @@ -27,13 +25,13 @@ 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; import org.springframework.stereotype.Service; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.function.Function; @@ -203,34 +201,46 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl> result = userClient.userListByDeptId(depts.get(0)); - if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + List users = this.parentAuthUser(depts.get(0)); + if(CollectionUtil.isEmpty(users)){ return; } - MessagePushRecordDto message = new MessagePushRecordDto(); + BusinessMessageDTO message = new BusinessMessageDTO(); + message.setDeptId(depts.get(0)); message.setBusinessClassify("warning"); 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 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 parentAuthUser(Long deptId) { + List users = new ArrayList<>(); + R> selfs = userClient.userListByDeptId(deptId); + if(selfs.isSuccess() && CollectionUtil.isNotEmpty(selfs.getData())){ + users.addAll(selfs.getData()); + } + R dept = sysClient.getDept(deptId); + if(dept.isSuccess() && ObjectUtil.isNotEmpty(dept.getData())){ + R> parents = userClient.userListByDeptId(deptId); + if(parents.isSuccess() && CollectionUtil.isNotEmpty(parents.getData())){ + users.addAll(parents.getData().stream().filter(o->!users.stream().map(User::getId).collect(Collectors.toList()).contains(o.getId())).collect(Collectors.toList())); + } + } + return users; + } } From 106edede40275664cd10939a576eee4b13f53ae8 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 27 Jul 2023 08:07:19 +0800 Subject: [PATCH 5/7] =?UTF-8?q?#=E5=91=8A=E8=AD=A6=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java index aa406db..759feab 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java @@ -208,6 +208,7 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImplString.valueOf(o.getId())).collect(Collectors.joining(","))); message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); message.setTaskId(entity.getId()); @@ -236,7 +237,7 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl dept = sysClient.getDept(deptId); if(dept.isSuccess() && ObjectUtil.isNotEmpty(dept.getData())){ - R> parents = userClient.userListByDeptId(deptId); + R> parents = userClient.userListByDeptId(dept.getData().getParentId()); if(parents.isSuccess() && CollectionUtil.isNotEmpty(parents.getData())){ users.addAll(parents.getData().stream().filter(o->!users.stream().map(User::getId).collect(Collectors.toList()).contains(o.getId())).collect(Collectors.toList())); } From dbdc1b2a5503b1b882f3d4b75ab60ae15d354241 Mon Sep 17 00:00:00 2001 From: tyty Date: Thu, 27 Jul 2023 11:14:55 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=80=BC=E7=8F=AD?= =?UTF-8?q?=E7=AA=81=E5=8F=91=E4=BA=8B=E4=BB=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../duty/service/impl/ImsDutyEmergencyServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyEmergencyServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyEmergencyServiceImpl.java index 8067b69..7e836e0 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyEmergencyServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyEmergencyServiceImpl.java @@ -80,9 +80,13 @@ public class ImsDutyEmergencyServiceImpl extends BaseServiceImpl { R user = userClient.userInfoById(sig.getRegistrant()); - sig.setRegistrantName(user.getData().getName()); + if (user.isSuccess()&&ObjectUtils.isNotEmpty(user.getData())){ + sig.setRegistrantName(user.getData().getName()); + } R userR = userClient.userInfoById(sig.getChargePerson()); - sig.setChargePersonName(userR.getData().getName()); + if (userR.isSuccess()&&ObjectUtils.isNotEmpty(userR.getData())){ + sig.setChargePersonName(userR.getData().getName()); + } ImsDutyClassEntity classEntity = imsDutyClassService.getById(sig.getDutyClass()); sig.setDutyClassName(classEntity.getClassName()); return sig; From ec64e7e8c2c201a2f68deaf8a327309d79a18158 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 1 Aug 2023 19:05:03 +0800 Subject: [PATCH 7/7] =?UTF-8?q?#=E6=95=85=E9=9A=9C=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alert/constants/AbnormalAlarmConstant.java | 2 + hzims-service/operational/pom.xml | 1 + .../service/impl/AbnormalAlarmServiceImpl.java | 181 +++++++++++---------- .../main/service/impl/HydropowerServiceImpl.java | 2 +- 4 files changed, 102 insertions(+), 84 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java index 1f18d55..9ece78b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java @@ -8,6 +8,8 @@ import java.util.List; */ public interface AbnormalAlarmConstant { + List INTERRUPT_LIST = Arrays.asList("13","14"); + List TYPE_LIST = Arrays.asList("3","2","5","10","13","14"); List LONG_TYPE_LIST = Arrays.asList(3L,2L,5L,10L,13L,14L); diff --git a/hzims-service/operational/pom.xml b/hzims-service/operational/pom.xml index e015f6c..13d036a 100644 --- a/hzims-service/operational/pom.xml +++ b/hzims-service/operational/pom.xml @@ -169,6 +169,7 @@ org.springblade blade-user-api + 5.0.1.RELEASE diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java index 759feab..da37623 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java @@ -1,8 +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.BusinessMessageDTO; -import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; import com.hnac.hzims.operational.alert.entity.AbnormalAlarmEntity; @@ -33,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; /** @@ -59,61 +57,77 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl 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> 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 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 -> { - 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()); - entity.setStationName(stationName); - entity.setRealId(item.getRealId()); - entity.setSoeExplain(item.getSoeExplain()); - entity.setType(item.getSoeType()); - entity.setStartTime(item.getTs()); - entity.setEndTime(null); - entity.setStatus(0); - if(flag){ - entity.setStartTime(null); - entity.setEndTime(item.getTs()); - entity.setStatus(1); - } - // 保存告警信息 - this.save(entity); + 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 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()); + entity.setStationName(stationName); + entity.setRealId(item.getRealId()); + entity.setSoeExplain(item.getSoeExplain()); + entity.setType(item.getSoeType()); + entity.setStartTime(item.getTs()); + entity.setEndTime(null); + entity.setStatus(0); + if(flag){ + entity.setStartTime(null); + entity.setEndTime(item.getTs()); + entity.setStatus(1); + } + // 保存告警信息 + this.save(entity); + // 存在记录进行修改 + }else{ queryEntity.setSoeExplain(item.getSoeExplain()); - queryEntity.setStationName(stationName); - queryEntity.setType(item.getSoeType()); queryEntity.setStartTime(queryEntity.getStartTime()); queryEntity.setUpdateTime(new Date()); queryEntity.setEndTime(null); @@ -123,60 +137,46 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl this.saveHistoryAlarm(result.getData().getRecords(),stations)); - } - - /** - * 查询实时告警数据 - * @return - */ - @Override - public List getAbnormalAlarmList() { - List alarmList = this.baseMapper.getAbnormalAlarmList(); - if(CollectionUtil.isEmpty(alarmList)){ - return new ArrayList<>(); } - return alarmList; } /** - * 保存告警历史信息 + * 历史数据处理 + * + * @param stations * @param list - * @return */ - private String saveHistoryAlarm(List list,List 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){ - HistoryAbnormalAlarmEntity entity = new HistoryAbnormalAlarmEntity(); - 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); - this.historyAbnormalAlarmService.save(entity); - // 消息推送 - this.sendAlarmMessage(Collections.singletonList(entity),stations); + private void saveHistoryAlarm(List stations, List list) { + List historys = historyAbnormalAlarmService.list(Wrappers.lambdaQuery() + .in(HistoryAbnormalAlarmEntity::getAlarmId,list.stream().map(SoeData::getId).collect(Collectors.toList())) + ); + Set explainSet = new HashSet<>(); + list.forEach(item->{ + if(CollectionUtil.isNotEmpty(historys) && historys.stream().map(HistoryAbnormalAlarmEntity::getAlarmId).collect(Collectors.toList()).contains(item.getId())){ return; } - queryEntity.setSoeExplain(item.getSoeExplain()); - queryEntity.setUpdateTime(new Date()); - queryEntity.setEndTime(ts); - queryEntity.setStatus(1); - this.historyAbnormalAlarmService.updateById(queryEntity); + 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(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 "success"; } /** @@ -203,12 +203,13 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl users = this.parentAuthUser(depts.get(0)); if(CollectionUtil.isEmpty(users)){ + log.error("alarmmessagestation {} user is null",entity.getStationId()); return; } BusinessMessageDTO message = new BusinessMessageDTO(); message.setDeptId(depts.get(0)); message.setBusinessClassify("warning"); - message.setUserIds(users.stream().map(o->String.valueOf(o.getId())).collect(Collectors.joining(","))); + 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()); @@ -237,11 +238,25 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl dept = sysClient.getDept(deptId); if(dept.isSuccess() && ObjectUtil.isNotEmpty(dept.getData())){ - R> parents = userClient.userListByDeptId(dept.getData().getParentId()); + R> parents = userClient.userByDeptId("200000",deptId); if(parents.isSuccess() && CollectionUtil.isNotEmpty(parents.getData())){ - users.addAll(parents.getData().stream().filter(o->!users.stream().map(User::getId).collect(Collectors.toList()).contains(o.getId())).collect(Collectors.toList())); + users.addAll(parents.getData()); } } return users; } + + /** + * 查询实时告警数据 + * @return + */ + @Override + public List getAbnormalAlarmList() { + List alarmList = this.baseMapper.getAbnormalAlarmList(); + if(CollectionUtil.isEmpty(alarmList)){ + return new ArrayList<>(); + } + return alarmList; + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index af62210..6f1508b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -1532,7 +1532,7 @@ public class HydropowerServiceImpl implements HydropowerService { @Override public List area(Long deptId) { // 查询水电站站点 - List stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), HomePageConstant.HYDROPOWER_SERVETYPE); + List stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), null); if (CollectionUtil.isEmpty(stations)) { return new ArrayList<>(); }