From 891a092cbeee9d4720e22e3ba752336466bbd402 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 5 Feb 2024 15:51:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?#=E6=BC=94=E7=A4=BA=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduled/scheduled/MonitorScheduledTask.java | 21 +- .../scheduled/RealTargetScheduledTask.java | 9 +- .../scheduled/scheduled/ReportScheduledTask.java | 7 +- .../operation/home/impl/RealTargetServiceImpl.java | 4 +- .../operation/monitor/impl/MonitorServiceImpl.java | 4 +- .../data/controller/HzimsDataController.java | 19 +- .../operational/data/service/HzimsDataService.java | 4 + .../data/service/impl/HzimsDataServiceImpl.java | 297 ++++++++++++++++++++- 8 files changed, 322 insertions(+), 43 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java index c092e7b..15e3cf7 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java @@ -29,10 +29,9 @@ public class MonitorScheduledTask { /** * realId刷新 */ - //@XxlJob(REAL_ID_DATA) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadRealId() { - String param = ""; + @XxlJob(REAL_ID_DATA) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadRealId(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -44,10 +43,9 @@ public class MonitorScheduledTask { * 实时数据刷新 * @return ReturnT */ - //@XxlJob(REAL_TIME_DATA) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadRealData() { - String param = ""; + @XxlJob(REAL_TIME_DATA) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadRealData(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -59,10 +57,9 @@ public class MonitorScheduledTask { * 集中监控数据处理 * @return ReturnT */ - //@XxlJob(CENTRALIZED_MONITORING) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadMonitoring() { - String param = ""; + @XxlJob(CENTRALIZED_MONITORING) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadMonitoring(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java index ed2e703..641f775 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java @@ -33,10 +33,9 @@ public class RealTargetScheduledTask { * @return * @throws Exception */ - //@XxlJob(LOAD_EM_INFO) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadEmInfo() { - String param = ""; + @XxlJob(LOAD_EM_INFO) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadEmInfo(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -61,6 +60,7 @@ public class RealTargetScheduledTask { * 水电站-机组指标加载 */ @XxlJob(LOAD_HYDROPOWER_UNIT_TARGET) + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadHydropowerTarget(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); @@ -98,6 +98,7 @@ public class RealTargetScheduledTask { * 水利-站点水位数据 */ @XxlJob(LOAD_WATER_LEVEL) + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadWaterLevel(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ReportScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ReportScheduledTask.java index bd15fb8..8ac3029 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ReportScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ReportScheduledTask.java @@ -77,10 +77,9 @@ public class ReportScheduledTask { * 站点运行月报 * @return ReturnT */ - //@XxlJob(RUM_MONTH_REPORT) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT runMonthReport() { - String param = ""; + @XxlJob(RUM_MONTH_REPORT) + // @Scheduled(cron = "0/40 * * * * ? ") + public ReturnT runMonthReport(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index fe8812d..79b3e3a 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -184,6 +184,7 @@ public class RealTargetServiceImpl implements RealTargetService { // 水电站站点 List stations = stationService.list(Wrappers.lambdaQuery() .eq(StationEntity::getType,HomePageConstant.HYDROPOWER) + .eq(StationEntity::getDataOrigin,"0") ); if(CollectionUtil.isEmpty(stations)){ return; @@ -241,8 +242,8 @@ public class RealTargetServiceImpl implements RealTargetService { public void loadHydropowerTarget(String param) { // 水电站站点 List stations = stationService.list(Wrappers.lambdaQuery() - //.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) .eq(StationEntity::getType,HomePageConstant.HYDROPOWER) + .eq(StationEntity::getDataOrigin,"0") ); if(CollectionUtil.isEmpty(stations)){ return; @@ -1076,6 +1077,7 @@ public class RealTargetServiceImpl implements RealTargetService { public void loadPowerData(String param, List types, Integer serveType, int year) { // 站点查询 List stationList = stationService.list(new LambdaQueryWrapper() {{ + eq(StationEntity::getDataOrigin,"0"); if (ObjectUtil.isNotEmpty(serveType)) { eq(StationEntity::getServeType, serveType); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index e7e3558..53b2c88 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -104,7 +104,9 @@ public class MonitorServiceImpl implements MonitorService { @Override public void loadRealId(String param) { // 所有站点 - List stationList = stationService.list(); + List stationList = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getDataOrigin,"0") + ); if(CollectionUtil.isEmpty(stationList)){ return; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java index 25b89c9..a12dc75 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java @@ -8,9 +8,10 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.annotation.ApiLog; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.*; - -import java.util.Map; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; /** @@ -47,15 +48,11 @@ public class HzimsDataController { return R.data(service.saveStation()); } - /** - * 测试动作模板回调接口 - */ @ApiLog - @PostMapping("/test") + @GetMapping("/station") @ApiOperationSupport(order = 1) - @ApiOperation(value = "测试动作模板回调接口", notes = "map接收参数") - public R test(@RequestBody Map params) { - log.error("动作模板回调接口参数: {}",params.toString()); - return R.data(params); + @ApiOperation(value = "站点数据获取", notes = "传入站点code") + public R station(@RequestParam("stationCode") String stationCode) { + return R.data(service.station(stationCode)); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java index 906bad5..11c6878 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/HzimsDataService.java @@ -1,5 +1,7 @@ package com.hnac.hzims.operational.data.service; +import com.hnac.hzims.operational.main.vo.HydropowerStationVo; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -16,4 +18,6 @@ public interface HzimsDataService { boolean saveArea(); boolean saveStation(); + + HydropowerStationVo station(String stationCode); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java index 986e74c..dac8435 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java @@ -1,12 +1,16 @@ package com.hnac.hzims.operational.data.service.impl; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.entity.PlanGenerationEntity; +import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.operational.data.service.HzimsDataService; import com.hnac.hzims.operational.data.vo.AreaVo; +import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.service.AreaService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; -import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.vo.HzimsStationCountVo; @@ -16,19 +20,26 @@ import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; 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.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; -import javax.validation.constraints.NotNull; import java.io.InputStream; import java.io.OutputStream; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.net.HttpURLConnection; import java.net.URL; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; import java.util.stream.Collectors; @@ -40,20 +51,33 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class HzimsDataServiceImpl implements HzimsDataService { - @NotNull private final AreaService areaService; - @NotNull + private final IMainSystemMonitoringService emService; - @NotNull - private final ISysClient sysClient; - @NotNull + private final IStationService stationService; + private final IMainSystemMonitoringService maintenanceTaskService; + + private final ISysClient sysClient; + + private final IPlanGenertionClient planGenertionClient; + + private final RedisTemplate redisTemplate; + @Value("${hzims.operation.save.area.url}") public String AREA_URL; @Value("${hzims.operation.save.station.url}") public String STATION_URL; + private final static String recent_year_power_data = "hzims:operation:key:power:data"; + + private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; + + private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; + + private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; + @Override public boolean saveArea() { R> result = sysClient.getDeptList(); @@ -103,6 +127,7 @@ public class HzimsDataServiceImpl implements HzimsDataService { return this.sendMessage(JSONObject.toJSONBytes(list),STATION_URL); } + /** * 发送请求 * @param params @@ -135,4 +160,256 @@ public class HzimsDataServiceImpl implements HzimsDataService { } return true; } + + /** + * 水电站-站点信息 + * @param stationCode + * @return + */ + @Override + public HydropowerStationVo station(String stationCode) { + if(StringUtil.isEmpty(stationCode)){ + return new HydropowerStationVo(); + } + // 站点 + StationEntity station = stationService.getOne(Wrappers.lambdaQuery() + .eq(StationEntity::getCode,stationCode) + .eq(StationEntity::getDataOrigin,"0") + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType,HomePageConstant.HYDROPOWER) + ); + if(ObjectUtil.isEmpty(station)){ + return new HydropowerStationVo(); + } + // 实时监测点数据 + List realList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); + // 获取站点机组指标数据 + List targetList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + // 所有设备 + List deviceList = maintenanceTaskService.getEmInfoList(); + HydropowerStationVo response = new HydropowerStationVo(); + // 近年发电量数据 + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + response.setDeptId(station.getRefDept()); + response.setDeptName(station.getName()); + response.setStationCode(station.getCode()); + // 限制水位 + response.setLimitWaterLevel(station.getLimitWaterLevel()); + // 运行天数 + response.setRunDay(this.getRunDay(station)); + // 装机容量 + response.setInstalledCapacity(this.getInstalledCapacity(deviceList,station.getRefDept())); + // 总有功功率(总发电负荷) + response.setPowerSum(this.getPowerSum(realList,station.getRefDept())); + // 总有功单位 + response.setPowerUnit("kW"); + // 月计划发电量 + response.setPlanPowerMon(this.getPlanPowerrMon(station.getCode())); + // 年计划发电量 + response.setPlanPowerYear(this.getPlanPowerYear(station.getCode())); + // 月发电量、年发电量、年发电完成率 + this.handleStationInfo(station.getRefDept(),response); + // 水位、水位曲线 + this.handleWaterLeve(station.getCode(),response); + // 年发电量完成百分比 + response.setPowerYearMap(this.handlePowerFinish(Collections.singletonList(station),map)); + return response; + } + + /** + * 获取站点运行天数 + * @param station + * @return + */ + private int getRunDay(StationEntity station) { + if (ObjectUtil.isEmpty(station.getCommissionTime())) { + return 0; + } + // 计算投运时间与当前时间相隔天数 + Duration dur = Duration.between(station.getCommissionTime(), LocalDateTime.now()); + return (int) dur.toDays(); + } + + /** + * 获取设备装机容量 + * @param list + * @param refDept + * @return + */ + private double getInstalledCapacity(List list, Long refDept) { + if(CollectionUtil.isEmpty(list) || ObjectUtil.isEmpty(refDept)){ + return 0.0; + } + return list.stream().filter(o -> refDept.equals(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum(); + } + + + /** + * 获取总发电负荷 + * @param deptId + * @return + */ + private Double getPowerSum(List realList,Long deptId) { + if(ObjectUtil.isEmpty(deptId)){ + return 0.0; + } + // 获取站点机组实时数据 + if(CollectionUtil.isEmpty(realList)){ + return 0.0; + } + return realList.stream().filter(o->deptId.equals(o.getDeptId())).mapToDouble(o->{ + if("MW".equalsIgnoreCase(o.getPowerUnit())){ + return o.getActivePower() * 1000; + } + return o.getActivePower(); + }).sum(); + } + + /** + * 获取月计划发电量 + * @param code + * @return + */ + private float getPlanPowerrMon(String code) { + R R = planGenertionClient.planGenerationMonthCount(code, DateUtil.format(new Date(), "yyyy-MM")); + if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){ + return 0f; + } + return R.getData(); + } + + /** + * 获取年计划发电量 + * @param code + * @return + */ + private float getPlanPowerYear(String code) { + R R = planGenertionClient.planGenerationYearCount(code); + if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){ + return 0f; + } + // 查询年计划发电量 + return R.getData(); + } + + /** + * 站点信息处理 + * @param deptId + * @param response + */ + private void handleStationInfo(Long deptId, HydropowerStationVo response) { + response.setPowerMon(0f); + response.setPowerYear(0f); + response.setPowerRateYear(0.0); + List targetList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + if(CollectionUtil.isEmpty(targetList)){ + return; + } + // 月发电量 + float powerMont = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum(); + response.setPowerMon(powerMont); + // 年发电量 + float powerYear = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); + response.setPowerYear(powerYear); + // 年发电完成率 + float planPowerYear = response.getPlanPowerYear(); + if(Math.abs(planPowerYear) <= 0){ + response.setPowerRateYear(0.0); + } else { + double powerRateYear = BigDecimal.valueOf(powerYear / planPowerYear * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); + response.setPowerRateYear(powerRateYear); + } + } + + /** + * 站点水位数据处理 + * @param code + * @param response + */ + private void handleWaterLeve(String code, HydropowerStationVo response) { + response.setFrontWaterLevel(0.0); + List levelList = (List) redisTemplate.opsForValue().get(loadwater_level_key); + if(CollectionUtil.isEmpty(levelList)){ + return; + } + List validList = levelList.stream().filter(o-> code.equals(o.getStationCode())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(validList)){ + return; + } + WaterLevelVo level = validList.get(0); + // 前池水位、当日水位曲线 + response.setFrontWaterLevel(level.getFrontWaterLevel()); + response.setFrontCurveMap(level.getFrontCurveMap()); + } + + /** + * 年发电量完成百分比 + * @param stations + */ + private List handlePowerFinish(List stations, Map> map) { + if (CollectionUtil.isEmpty(stations)) { + return null; + } + // 查询计划发电量 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + List plans = planGenertionClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null, String.valueOf(calendar.get(Calendar.YEAR))); + // 获取月份集合 + List monList = this.mons(0, 12, false); + return monList.stream().map(o -> { + PowerMonthVo vo = new PowerMonthVo(); + LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), o), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + vo.setStrMonth(o); + vo.setYear(localDate.getYear()); + vo.setMonth(localDate.getMonthValue()); + // 实际发电量 + if (CollectionUtil.isEmpty(map)) { + vo.setPower(0f); + } else { + float generate = (float) map.entrySet().stream(). + filter(entry -> stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(entry.getKey())). + mapToDouble(valueMap -> valueMap.getValue().entrySet().stream().filter(entry -> entry.getKey().equals(o)) + .mapToDouble(Map.Entry::getValue).sum()).sum(); + vo.setPower(generate); + } + // 计划发电量 + if (CollectionUtil.isEmpty(plans)) { + vo.setPlanPower(0f); + } else { + String mon = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); + vo.setPlanPower((float) plans.stream().filter(plan -> mon.equals(plan.getDateTime())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); + } + return vo; + }).collect(Collectors.toList()); + } + + /** + * 获取近年月份集合 + * @param year + * @return + */ + public List mons(int year, int endMoth, boolean nextMon) { + List list = new ArrayList<>(); + // 开始日期 + Calendar endCal = Calendar.getInstance(); + endCal.setTime(new Date()); + endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + endMoth); + endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1); + + // 结束日期 + Calendar startCal = Calendar.getInstance(); + startCal.setTime(new Date()); + startCal.set(Calendar.YEAR, startCal.get(Calendar.YEAR) - year); + startCal.add(Calendar.MONTH, -startCal.get(Calendar.MONTH)); + startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1); + // 获取日期之间的月份 + while (endCal.after(startCal)) { + list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE)); + startCal.add(Calendar.MONTH, 1); + } + if(nextMon){ + list.add(DateUtil.format(endCal.getTime(),DateUtil.PATTERN_DATE)); + } + return list; + } } From 6d9d984da2f2ff833678943220becf060e511964 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Mon, 5 Feb 2024 17:35:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?#=20=E8=A7=86=E9=A2=91=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../station/constants/HikApiConstants.java | 15 +++ .../station/controller/HikVideoController.java | 48 ++++++++++ .../controller/StationVideoTypeController.java | 15 +++ .../station/service/IHikVideoService.java | 23 +++++ .../station/service/IStationVideoTypeService.java | 5 + .../station/service/impl/HikVideoServiceImpl.java | 102 +++++++++++++++++++++ .../service/impl/StationVideoTypeServiceImpl.java | 39 ++++++++ .../operational/station/vo/HikVideoAreaTreeVO.java | 20 ++++ .../operational/station/vo/HikVideoAreaVO.java | 28 ++++++ 9 files changed, 295 insertions(+) create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HikVideoAreaTreeVO.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HikVideoAreaVO.java diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java new file mode 100644 index 0000000..eeef631 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.operational.station.constants; + +public interface HikApiConstants { + String ARTEMIS_PATH = "/artemis"; + + /**查询区域列表**/ + String NODE_BY_PARAMS = "/api/irds/v1/region/nodesByParams"; + + /**根据区域获取下级编码设备列表**/ + String SUB_RESOURCES = "/api/resource/v1/encodeDevice/subResources"; + + /**根据区域编号获取下级监控点列表**/ + String CAMERAS = "/api/resource/v1/regions/regionIndexCode/cameras"; + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java new file mode 100644 index 0000000..4dc814a --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java @@ -0,0 +1,48 @@ +package com.hnac.hzims.operational.station.controller; + + +import com.hnac.hzims.operational.station.service.IHikVideoService; +import com.hnac.hzims.operational.station.vo.HikVideoAreaVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiOperationSupport; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +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; + +@RestController +@RequestMapping("/hik/video") +@Api(value = "海康API管理",tags = "海康API管理") +@AllArgsConstructor +public class HikVideoController extends BladeController { + + private final IHikVideoService hikVideoService; + + @ApiOperation("查询区域列表") + @ApiOperationSupport(order = 1) + @GetMapping("/nodesByParams") + public R> nodesByParams(@ApiParam("区域父级编号")@RequestParam(required = false) String parentIndexCode) { + return R.data(hikVideoService.nodesByParams(parentIndexCode)); + } + + @ApiOperation("根据区域获取下级编码设备列表") + @ApiOperationSupport(order = 2) + @GetMapping("/subResources") + public R subResources(@ApiParam("区域父级编号")@RequestParam String regionIndexCode) { + return R.data(hikVideoService.subResources(regionIndexCode)); + } + + @ApiOperation("查询监控点列表") + @ApiOperationSupport(order = 3) + @GetMapping("/cameras") + public R cameras(@ApiParam("区域父级编号")@RequestParam String regionIndexCode) { + return R.data(hikVideoService.cameras(regionIndexCode)); + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java index 981ab67..ffea1c9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java @@ -19,6 +19,7 @@ import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationVideoTypeService; import com.hnac.hzims.operational.station.service.VideoConfigService; import com.hnac.hzims.operational.station.utils.ArtemisPostUtils; +import com.hnac.hzims.operational.station.vo.HikVideoAreaTreeVO; import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVideoTypeVO; import com.hnac.hzims.operational.station.vo.VideoMonitorVO; @@ -312,4 +313,18 @@ public class StationVideoTypeController extends BladeController { return R.data(stationVideoTypeService.getWsUrlByPointCode(pointCodes,host,appKey,appSecret,streamType)); } + @GetMapping("/getHikVideoAreaTree") + @ApiOperationSupport(order = 150) + @ApiOperation(value = "获取海康区域树", notes = "获取海康区域树") + public R> getHikVideoAreaTree() { + return R.data(stationVideoTypeService.getHikVideoAreaTree()); + } + + @GetMapping("/getVideoPointByRegion") + @ApiOperationSupport(order = 160) + @ApiOperation(value = "获取海康监控点树", notes = "获取海康监控点树") + public R getVideoPointByRegion(@RequestParam @ApiParam("所属机构") Long refDept, @RequestParam @ApiParam("区域唯一标识") String regionCode) { + return R.data(stationVideoTypeService.getVideoPointByRegion(refDept,regionCode)); + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java new file mode 100644 index 0000000..8956ae3 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.operational.station.service; + +import com.hnac.hzims.operational.station.vo.HikVideoAreaVO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.util.List; + +public interface IHikVideoService { + + /** + * 查询区域列表 + * @return 区域列表 + */ + List nodesByParams(String parentIndexCode); + + List subResources(String regionIndexCode); + + List cameras(String regionIndexCode); + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java index 834a7e3..3862dff 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java @@ -7,6 +7,7 @@ import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.response.HikDeviceResp; import com.hnac.hzims.operational.station.response.HikMonitorResp; +import com.hnac.hzims.operational.station.vo.HikVideoAreaTreeVO; import com.hnac.hzims.operational.station.vo.StationVideoTypeVO; import com.hnac.hzims.operational.station.vo.VideoMonitorVO; import org.apache.ibatis.annotations.Param; @@ -76,4 +77,8 @@ public interface IStationVideoTypeService extends BaseService getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret,Integer streamType); + List getHikVideoAreaTree(); + + Map getVideoPointByRegion(Long refDept,String regionCode); + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java new file mode 100644 index 0000000..e61092a --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java @@ -0,0 +1,102 @@ +package com.hnac.hzims.operational.station.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hikvision.artemis.sdk.ArtemisHttpUtil; +import com.hikvision.artemis.sdk.config.ArtemisConfig; +import com.hnac.hzims.operational.station.service.IHikVideoService; +import com.hnac.hzims.operational.station.vo.HikVideoAreaVO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.hnac.hzims.operational.station.constants.HikApiConstants.*; + +@RequiredArgsConstructor +@Slf4j +@Service +public class HikVideoServiceImpl implements IHikVideoService { + + @Value("${hzims.videoProperties.appKey}") + private String videoAppKey; + + @Value("${hzims.videoProperties.videoHost}") + private String videoHost; + + @Value("${hzims.videoProperties.appSecret}") + private String videoAppSecret; + + private void init() { + ArtemisConfig.host = videoHost; + ArtemisConfig.appKey = videoAppKey; + ArtemisConfig.appSecret = videoAppSecret; + } + + private String doPostStringArtemis(Map path,String body) { + String contentType = "application/json"; + String resultStr = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null); + JSONObject resultObj = JSONObject.parseObject(resultStr); + Assert.isTrue("0".equals(resultObj.getString("code")),()-> { + throw new ServiceException(resultObj.getString("msg")); + }); + return resultObj.getString("data"); + } + + @Override + public List nodesByParams(String parentIndexCode) { + init(); + Map path = new HashMap<>(); + path.put("https://", ARTEMIS_PATH + NODE_BY_PARAMS); + HashMap body = new HashMap() {{ + put("pageNo",1); + put("pageSize",999); + put("resourceType","camera"); + if(StringUtil.isNotBlank(parentIndexCode)) { + put("parentIndexCodes", Func.toStrList(",",parentIndexCode)); + } + }}; + String result = doPostStringArtemis(path, JSON.toJSONString(body)); + String list = JSONObject.parseObject(result).getString("list"); + return JSONArray.parseArray(list,HikVideoAreaVO.class); + } + + @Override + public List subResources(String regionIndexCode) { + init(); + Map path = new HashMap<>(); + path.put("https://", ARTEMIS_PATH + SUB_RESOURCES); + HashMap body = new HashMap() {{ + put("pageNo",1); + put("pageSize",999); + put("regionIndexCode", regionIndexCode); + }}; + String result = doPostStringArtemis(path, JSON.toJSONString(body)); + String list = JSONObject.parseObject(result).getString("list"); + return JSONArray.parseArray(list); + } + + @Override + public List cameras(String regionIndexCode) { + init(); + Map path = new HashMap<>(); + path.put("https://", ARTEMIS_PATH + CAMERAS); + HashMap body = new HashMap() {{ + put("pageNo",1); + put("pageSize",999); + put("regionIndexCode", regionIndexCode); + }}; + String result = doPostStringArtemis(path, JSON.toJSONString(body)); + String list = JSONObject.parseObject(result).getString("list"); + return JSONArray.parseArray(list); + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java index f3500bb..b50cb95 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java @@ -18,8 +18,11 @@ import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.mapper.StationVideoTypeMapper; import com.hnac.hzims.operational.station.response.HikDeviceResp; import com.hnac.hzims.operational.station.response.HikMonitorResp; +import com.hnac.hzims.operational.station.service.IHikVideoService; import com.hnac.hzims.operational.station.service.IStationVideoTypeService; import com.hnac.hzims.operational.station.utils.ArtemisPostUtils; +import com.hnac.hzims.operational.station.vo.HikVideoAreaTreeVO; +import com.hnac.hzims.operational.station.vo.HikVideoAreaVO; import com.hnac.hzims.operational.station.vo.StationVideoTypeVO; import com.hnac.hzims.operational.station.vo.VideoMonitorVO; import lombok.RequiredArgsConstructor; @@ -49,6 +52,7 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl getHikVideoAreaTree() { + List hikVideoAreaList = hikVideoService.nodesByParams(null); + Map> videoAreaMapByParent = hikVideoAreaList.stream().collect(Collectors.groupingBy(HikVideoAreaVO::getParentIndexCode)); + List firstLevelArea = videoAreaMapByParent.get("-1"); + List result = firstLevelArea.stream().map(area -> this.generateAreaTree(videoAreaMapByParent, area)).collect(Collectors.toList()); + return result; + } + + @Override + public Map getVideoPointByRegion(Long refDept, String regionCode) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery().select(StationVideoTypeEntity::getPointCode).eq(StationVideoTypeEntity::getDeptId, refDept); + List pointCodes = this.listObjs(queryWrapper, String::valueOf); + List cameras = hikVideoService.cameras(regionCode); + cameras.stream().forEach(camera -> { + if(pointCodes.contains(camera.getString("cameraIndexCode"))) { + camera.put("disabled",true); + } + else { + camera.put("disabled",false); + } + }); + return cameras.stream().collect(Collectors.groupingBy(c -> c.getString("cameraName"))); + } + + private HikVideoAreaTreeVO generateAreaTree(Map> videoAreaMapByParent,HikVideoAreaVO area) { + HikVideoAreaTreeVO parentTree = BeanUtil.copy(area,HikVideoAreaTreeVO.class); + if(CollectionUtil.isNotEmpty(videoAreaMapByParent.get(area.getIndexCode()))) { + List children = videoAreaMapByParent.get(area.getIndexCode()); + List childrenTree = children.stream().map(childrenArea -> this.generateAreaTree(videoAreaMapByParent,childrenArea)).collect(Collectors.toList()); + parentTree.setChildren(childrenTree); + } + return parentTree; + } + + @Override public StationVideoTypeEntity getById(Long id,int streamType){ StationVideoTypeEntity stationVideoTypeEntity = this.getById(id); if(ObjectUtil.isNotEmpty(stationVideoTypeEntity.getIsHikvideo()) && stationVideoTypeEntity.getIsHikvideo() == 1){ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HikVideoAreaTreeVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HikVideoAreaTreeVO.java new file mode 100644 index 0000000..4cd7ccb --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HikVideoAreaTreeVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.operational.station.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; + +@Data +@EqualsAndHashCode +@ApiModel(value = "海康平台区域树结构",description = "海康平台区域树结构") +public class HikVideoAreaTreeVO extends HikVideoAreaVO implements Serializable { + + @ApiModelProperty("子区域") + private List children; + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HikVideoAreaVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HikVideoAreaVO.java new file mode 100644 index 0000000..315b2c6 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HikVideoAreaVO.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.operational.station.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode +@ApiModel("海康区域对象") +public class HikVideoAreaVO implements Serializable { + + @ApiModelProperty("区域名称") + private String name; + + @ApiModelProperty("区域唯一标识码") + private String indexCode; + + @ApiModelProperty("树编号") + private String treeCode; + + @ApiModelProperty("父区域唯一标识码") + private String parentIndexCode; + +} From 824b0e83360f57e5977733c452bdd614ac30003c Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 6 Feb 2024 11:36:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?#=20=E8=A7=86=E9=A2=91=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/station/constants/HikApiConstants.java | 2 ++ .../operational/station/service/IHikVideoService.java | 3 +++ .../station/service/impl/HikVideoServiceImpl.java | 12 ++++++++++++ .../station/service/impl/StationVideoTypeServiceImpl.java | 14 +++++++++++--- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java index eeef631..7517885 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/constants/HikApiConstants.java @@ -9,6 +9,8 @@ public interface HikApiConstants { /**根据区域获取下级编码设备列表**/ String SUB_RESOURCES = "/api/resource/v1/encodeDevice/subResources"; + String GET_DEVICE_SINGLE = "/api/resource/v1/encodeDevice/single/get"; + /**根据区域编号获取下级监控点列表**/ String CAMERAS = "/api/resource/v1/regions/regionIndexCode/cameras"; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java index 8956ae3..48d874b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.station.service; +import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.operational.station.vo.HikVideoAreaVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -18,6 +19,8 @@ public interface IHikVideoService { List subResources(String regionIndexCode); + JSONObject getDeviceSingle(String resourceIndexCode); + List cameras(String regionIndexCode); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java index e61092a..3c8795f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java @@ -86,6 +86,18 @@ public class HikVideoServiceImpl implements IHikVideoService { } @Override + public JSONObject getDeviceSingle(String resourceIndexCode) { + init(); + Map path = new HashMap<>(); + path.put("https://", ARTEMIS_PATH + GET_DEVICE_SINGLE); + HashMap body = new HashMap() {{ + put("resourceIndexCode", resourceIndexCode); + }}; + String result = doPostStringArtemis(path, JSON.toJSONString(body)); + return JSONObject.parseObject(result); + } + + @Override public List cameras(String regionIndexCode) { init(); Map path = new HashMap<>(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java index b50cb95..3d9dc25 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java @@ -40,6 +40,7 @@ import org.springframework.util.Assert; import javax.servlet.http.HttpServletResponse; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -244,8 +245,9 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl queryWrapper = Wrappers.lambdaQuery().select(StationVideoTypeEntity::getPointCode).eq(StationVideoTypeEntity::getDeptId, refDept); - List pointCodes = this.listObjs(queryWrapper, String::valueOf); + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery().select(StationVideoTypeEntity::getPointCode,StationVideoTypeEntity::getCreateDept).eq(StationVideoTypeEntity::getDeptId, refDept); + List> pointCodeList = this.listMaps(queryWrapper); + List pointCodes = pointCodeList.stream().map(m -> m.get("point_code")).map(String::valueOf).collect(Collectors.toList()); List cameras = hikVideoService.cameras(regionCode); cameras.stream().forEach(camera -> { if(pointCodes.contains(camera.getString("cameraIndexCode"))) { @@ -255,7 +257,13 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl c.getString("cameraName"))); + List devIndexCodes = cameras.stream().map(obj -> obj.get("encodeDevIndexCode")).map(String::valueOf).distinct().collect(Collectors.toList()); + Map deviceMap = new HashMap<>(); + devIndexCodes.forEach(devIndexCode -> { + String deviceName = Optional.ofNullable(hikVideoService.getDeviceSingle(devIndexCode)).map(o -> o.getString("name")).orElse(null); + deviceMap.put(devIndexCode,deviceName); + }); + return cameras.stream().collect(Collectors.groupingBy(c -> deviceMap.get(c.getString("encodeDevIndexCode")))); } private HikVideoAreaTreeVO generateAreaTree(Map> videoAreaMapByParent,HikVideoAreaVO area) {