From 18c5378d9a41273424ae76e64042f6c6cb89db71 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 29 Aug 2023 15:13:18 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=96=B0=E5=8C=BA=E5=9F=9F=E5=80=BC=E7=8F=AD?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/census/vo/AreaAssetDeviceVo.java | 24 +++++ .../hzims/operational/census/vo/AreaAssetVo.java | 24 +++++ .../hzims/operational/census/vo/AreaTimelyVo.java | 13 +++ .../operation/home/impl/ShowServiceImpl.java | 2 +- .../census/controller/AreaDutyController.java | 57 +++++++++++ .../census/service/AreaDutyService.java | 20 ++++ .../census/service/impl/AreaDutyServiceImpl.java | 114 +++++++++++++++++++++ 7 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetDeviceVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaTimelyVo.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/AreaDutyController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/AreaDutyService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/AreaDutyServiceImpl.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetDeviceVo.java new file mode 100644 index 0000000..a72d479 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetDeviceVo.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + * @date 2023/8/29 11:22:22 + * @version 4.0.0 + */ +@Data +public class AreaAssetDeviceVo { + + @ApiModelProperty(value = "机构Id") + private Long deptId; + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "状态") + private String status; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetVo.java new file mode 100644 index 0000000..e6eead2 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaAssetVo.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + * @date 2023/8/29 11:22:22 + * @version 4.0.0 + */ +@Data +public class AreaAssetVo { + + @ApiModelProperty(value = "机构Id") + private Long deptId; + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "设备集合") + private List devices; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaTimelyVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaTimelyVo.java new file mode 100644 index 0000000..2490ab8 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/AreaTimelyVo.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.operational.census.vo; + +import lombok.Data; + +/** + * @author ysj + * @date 2023/8/29 11:22:22 + * @version 4.0.0 + */ +@Data +public class AreaTimelyVo { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java index 9d573a6..3864151 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java @@ -105,7 +105,7 @@ public class ShowServiceImpl implements ShowService { @Value("${hzims.equipment.emInfo.emInfoList}") public String device_cache_cofig_final; - @Value("${hzims.operation.region.areaDutyInfoKey}") + @Value("${hzims.operation.region.areaDutyInfoKey}") private String area_duty_cache_final; @Value("${hzims.operation.region.deviceClassifyKey}") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/AreaDutyController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/AreaDutyController.java new file mode 100644 index 0000000..859dd14 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/AreaDutyController.java @@ -0,0 +1,57 @@ +package com.hnac.hzims.operational.census.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.census.service.AreaDutyService; +import com.hnac.hzims.operational.census.vo.AreaAssetVo; +import com.hnac.hzims.operational.census.vo.AreaTimelyVo; +import com.hnac.hzims.operational.main.vo.AreaDutyVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.log.annotation.ApiLog; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/area_duty") +@Api(value = "区域值班统计", tags = "区域值班统计") +public class AreaDutyController { + + private final AreaDutyService service; + + @ApiLog + @ApiOperation("值班数据") + @PostMapping("/duty") + @ApiOperationSupport(order = 1) + public R duty(@ApiParam(value = "机构Id", required = true) @RequestParam Long deptId) { + return R.data(service.duty(deptId)); + } + + @ApiLog + @ApiOperation("资产信息") + @PostMapping("/asset") + @ApiOperationSupport(order = 1) + public R> asset(@ApiParam(value = "机构Id", required = true) @RequestParam Long deptId) { + return R.data(service.asset(deptId)); + } + + @ApiLog + @ApiOperation("及时提醒消息") + @PostMapping("/timely") + @ApiOperationSupport(order = 1) + public R timely(@ApiParam(value = "机构Id", required = true) @RequestParam Long deptId) { + return R.data(service.timely(deptId)); + } + + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/AreaDutyService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/AreaDutyService.java new file mode 100644 index 0000000..6a4dbfe --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/AreaDutyService.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.operational.census.service; + + +import com.hnac.hzims.operational.census.vo.AreaAssetVo; +import com.hnac.hzims.operational.census.vo.AreaTimelyVo; +import com.hnac.hzims.operational.main.vo.AreaDutyVo; + +import java.util.List; + +/** + * @author ysj + */ +public interface AreaDutyService { + + AreaDutyVo duty(Long deptId); + + AreaTimelyVo timely(Long deptId); + + List asset(Long deptId); +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/AreaDutyServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/AreaDutyServiceImpl.java new file mode 100644 index 0000000..d477c31 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/AreaDutyServiceImpl.java @@ -0,0 +1,114 @@ +package com.hnac.hzims.operational.census.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.operational.census.service.AreaDutyService; +import com.hnac.hzims.operational.census.vo.AreaAssetVo; +import com.hnac.hzims.operational.census.vo.AreaTimelyVo; +import com.hnac.hzims.operational.main.vo.AreaDutyVo; +import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author ysj + * @date 2023/02/23 13:37:22 + * @version 4.0.0 + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class AreaDutyServiceImpl implements AreaDutyService { + + @Value("${hzims.equipment.emInfo.emInfoList}") + public String device_cache_cofig_final; + + @Value("${hzims.operation.region.areaDutyInfoKey}") + private String area_duty_cache_final; + + private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; + + private final IStationService stationService; + + private final ISysClient sysClient; + + private final RedisTemplate redisTemplate; + + + /** + * 区域值班数据 + * @param deptId + * @return + */ + @Override + public AreaDutyVo duty(Long deptId) { + List dutys = (List) redisTemplate.opsForValue().get(area_duty_cache_final);; + if(CollectionUtil.isEmpty(dutys)){ + return new AreaDutyVo(); + } + return dutys.stream().filter(o->o.getDepartId().equals(deptId)).min(Comparator.comparing(AreaDutyVo::getDepartId)).get(); + } + + /** + * 区域及时提醒消息 + * @param deptId + * @return + */ + @Override + public AreaTimelyVo timely(Long deptId) { + return null; + } + + /** + * 资产信息 + * @param deptId + * @return + */ + @Override + public List asset(Long deptId) { + // 查询子部门 + R> result = sysClient.getDeptChild(deptId); + if(!result.isSuccess() && CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + List depts = result.getData().stream().map(Dept::getId).collect(Collectors.toList()); + // 查询站点 + List stations = stationService.list(Wrappers.lambdaQuery() + .in(StationEntity::getRefDept,depts)); + if(CollectionUtil.isEmpty(stations)){ + return new ArrayList<>(); + } + try{ + // 查询设备 + List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(),new TypeReference>() {}); + // 水电站设备实时数据 + List reals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); + return devices.stream().filter(device -> depts.contains(device.getCreateDept())).collect(Collectors.groupingBy(EminfoAndEmParamVo::getCreateDept)).entrySet().stream().map(entry->{ + AreaAssetVo asset = new AreaAssetVo(); + + return asset; + }).collect(Collectors.toList()); + }catch (Exception ex){ + log.error("duty_asset_error: {}",ex); + return new ArrayList<>(); + } + } +} \ No newline at end of file