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] =?UTF-8?q?#=E5=B9=BF=E5=AE=81=E6=B0=B4=E5=88=A9=E5=B1=80?= =?UTF-8?q?=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 { + +}