diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index 084f3b0..6e6dec3 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -81,8 +81,8 @@ public interface IEmInfoClient { String GET_CHILDREN_BY_EM_CODE = API_PREFIX + "/getChildrenByEmCode"; String GET_EM_CREATE_TABLE = API_PREFIX + "/getEmCreateTable"; String GET_VIDEO_DEVICE_BY_EM_CODE = API_PREFIX + "/getVideoDeviceByEmCode"; - String DEVICE_BY_PATH = API_PREFIX + "/deviceByPath"; + String EM_INFO_LIST = API_PREFIX + "/emInfoList"; @PostMapping(DETAIL) EmInfoEntity getByCode(@RequestParam("code") String id); @@ -166,4 +166,7 @@ public interface IEmInfoClient { @GetMapping(DEVICE_BY_PATH) List deviceByPath(@RequestParam("emCode") String emCode); + + @GetMapping(EM_INFO_LIST) + R> emInfoList(EmInfoEntity req); } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java index 9239354..c411e7e 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java @@ -109,4 +109,9 @@ public class IEmInfoClientBack implements IEmInfoClient { public List deviceByPath(String emCode) { return new ArrayList<>(); } + + @Override + public R> emInfoList(EmInfoEntity req) { + return R.fail("远程调用失败"); + } } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmVideoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmVideoClient.java new file mode 100644 index 0000000..6b6098c --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmVideoClient.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.equipment.feign; + +import com.hnac.hzims.EquipmentConstants; +import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/04/19 17:00 + */ +@FeignClient(value = EquipmentConstants.APP_NAME) +public interface IEmVideoClient { + + String API_PREFIX = "/feign/em/video"; + String GET_EM_BANDING_VIDEOS = API_PREFIX + "/getEmBandingVideos"; + String IS_BANDING_VIDEO_BY_EM_CODES = API_PREFIX + "/isBandingVideoByEmCode"; + + /** + * 获取设备绑定视频列表 + * @param emCodes 设备编号 + * @return 视频列表 + */ + @GetMapping(GET_EM_BANDING_VIDEOS) + R> getEmBandingVideos(@RequestParam String emCodes); + + /** + * 验证设备编号是否绑定视频 + * @param emCode 设备编号 + * @return 是否绑定视频结果 + */ + @GetMapping(IS_BANDING_VIDEO_BY_EM_CODES) + R isBandingVideoByEmCode(@RequestParam String emCode); + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index ca0e5f3..637da20 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; +import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.vo.DeviceVO; @@ -147,6 +148,13 @@ public class EmInfoClient implements IEmInfoClient { return service.deviceByPath(emCode); } + @Override + @GetMapping(EM_INFO_LIST) + public R> emInfoList(EmInfoEntity req) { + LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(EmInfoEntity.class, req); + return R.data(service.list(queryWrapper)); + } + @PostMapping(GET_EM_CREATE_TABLE) @Override public List getEmCreateTable(List tableNames) { diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmVideoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmVideoClient.java new file mode 100644 index 0000000..f1a6cf8 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmVideoClient.java @@ -0,0 +1,42 @@ +package com.hnac.hzims.equipment.feign; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; +import com.hnac.hzims.equipment.service.IEmVideoBandingService; +import com.hnac.hzims.equipment.service.IEmVideoService; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Collection; +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/04/24 11:21 + */ +@RestController +@AllArgsConstructor +public class EmVideoClient implements IEmVideoClient{ + + private final IEmVideoBandingService emVideoBandingService; + + @Override + @GetMapping(GET_EM_BANDING_VIDEOS) + public R> getEmBandingVideos(@RequestParam String emCodes) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery().in(EmVideoBandingEntity::getEmCode, Func.toStrList(",",emCodes)); + return R.data(emVideoBandingService.list(wrapper)); + } + + @Override + public R isBandingVideoByEmCode(String emCode) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery().eq(EmVideoBandingEntity::getEmCode, emCode); + List videoList = emVideoBandingService.list(wrapper); + return R.status(CollectionUtil.isNotEmpty(videoList)); + } +} diff --git a/hzims-service/equipment/src/main/resources/db/2.0.1.sql b/hzims-service/equipment/src/main/resources/db/2.0.1.sql index 1905851..ff8bdfc 100644 --- a/hzims-service/equipment/src/main/resources/db/2.0.1.sql +++ b/hzims-service/equipment/src/main/resources/db/2.0.1.sql @@ -1,2 +1,2 @@ -- 批量处理设备历史数据,将其设为一级设备 -update hzims_em_info set `path` = CONCAT('/',`NUMBER`) where `path` is null and `is_deleted` = 0 \ No newline at end of file +update hzims_em_info set `path` = CONCAT('/',`NUMBER`) where `path` is null and `is_deleted` = 0; \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java index 625e5b3..162c113 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java @@ -6,6 +6,7 @@ import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.source.service.SystemAlarmService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; +import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -53,4 +54,12 @@ public class ShowAlarmController extends BladeController { return R.data(alarmService.counts(alarm)); } + @GetMapping("/getVideosByStationAndRealId") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "站点") + public R> getVideosByStationAndRealId(@ApiParam("站点编号") @RequestParam String stationCode, + @ApiParam("监测点ID") @RequestParam String realId) { + return R.data(alarmService.getVideosByStationAndRealId(stationCode,realId)); + } + } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index ecc3077..8b62437 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.show.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; +import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import org.springblade.core.mp.base.BaseService; import org.springframework.web.socket.TextMessage; @@ -20,4 +21,12 @@ public interface AlarmService extends BaseService { List broadcast(String startTime, String endTime); TextMessage majorAlarm(List depts); + + /** + * 根据站点、realId 获取视频列表 + * @param stationCode 站点编号 + * @param realId hz3000点位信息 + * @return 视频列表 + */ + List getVideosByStationAndRealId(String stationCode,String realId); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 913e0a1..2b769ec 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -12,19 +12,30 @@ import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.source.service.MessageService; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; import com.hnac.hzims.alarm.config.vo.ChildAlarmCountVo; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.equipment.feign.IEmVideoClient; import com.hnac.hzims.message.dto.MailMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; +import com.hnac.hzinfo.sdk.v5.project.ProjectClient; 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.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; import org.springframework.web.socket.TextMessage; import java.util.*; @@ -49,6 +60,9 @@ public class AlarmServiceImpl extends BaseServiceImpl private final IStationClient stationClient; private final IMessageClient messageClient; + private final IEmInfoClient emInfoClient; + private final DeviceClient deviceClient; + private final IEmVideoClient emVideoClient; /** * 查询告警列表 @@ -215,6 +229,68 @@ public class AlarmServiceImpl extends BaseServiceImpl return new TextMessage(JSONObject.toJSONString(alarms.stream().sorted(Comparator.comparing(AlarmEntity::getAlarmTime).reversed()).collect(Collectors.toList()))); } + @Override + public List getVideosByStationAndRealId(String stationCode, String realId) { + R stationR = stationClient.getStationByCode(stationCode); + Assert.isTrue(stationR.isSuccess() && Func.isNotEmpty(stationR.getData()), () -> { + throw new ServiceException("获取站点信息失败!"); + }); + EmInfoEntity emReq = new EmInfoEntity(); + emReq.setDepartment(stationR.getData().getRefDept()); + R> emListR = emInfoClient.emInfoList(emReq); + Assert.isTrue(emListR.isSuccess() && CollectionUtil.isNotEmpty(emListR.getData()), () -> { + throw new ServiceException("该站点未获取到设备!"); + }); + List emInfoList = emListR.getData(); + String emCodes = emInfoList.stream().parallel() + .filter(this::isBandingVideoByEmCode) + .filter(this::isDeviceCodeExist) + .filter(em -> this.isRealIdBanding(realId, em.getNumber())) + .map(EmInfoEntity::getNumber) + .collect(Collectors.joining(",")); + Assert.isTrue(StringUtil.isNotBlank(emCodes) && Func.isNotEmpty(emCodes), () -> { + throw new ServiceException("未获取到设备!"); + }); + R> videoListR = emVideoClient.getEmBandingVideos(emCodes); + Assert.isTrue(videoListR.isSuccess(), () -> { + throw new ServiceException("获取设备绑定视频列表失败!"); + }); + return videoListR.getData().stream().distinct().collect(Collectors.toList()); + } + + /** + * 验证设备编号是否绑定视频 + * @param emInfo 设备信息 + * @return 是否绑定视频结果 + */ + public Boolean isBandingVideoByEmCode(EmInfoEntity emInfo) { + return emVideoClient.isBandingVideoByEmCode(emInfo.getNumber()).isSuccess(); + } + + /** + * 验证设备实例中的属性是否绑定realId + * @param realId hz3000监测点ID + * @param emCode 设备编号 + * @return 绑定结果 + */ + private Boolean isRealIdBanding(String realId,String emCode) { + R> deviceAttrR = deviceClient.getOnlineAttr(emCode); + if(deviceAttrR.isSuccess() && CollectionUtil.isNotEmpty(deviceAttrR.getData())) { + return deviceAttrR.getData().stream().anyMatch(attr -> realId.equals(attr.getFacDeviceAttrId())); + } + return false; + } + + + /** + * 验证设备code是否存在 (存在是true) + * @param emInfo 设备信息 + * @return 是否存在 + */ + private Boolean isDeviceCodeExist(EmInfoEntity emInfo) { + R isExistResult = deviceClient.isDeviceCodeExist(emInfo.getNumber()); + return Optional.ofNullable(isExistResult).filter(r -> r.isSuccess()).map(R::getData).orElse(false); + } /** * 子类型数量集合 diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/constant/TicketConstant.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/constant/TicketConstant.java index c374b59..db0e96e 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/constant/TicketConstant.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/constant/TicketConstant.java @@ -12,7 +12,7 @@ public class TicketConstant { /** * window操作系统工作票访问路径 */ - public static final String TICKET_WINDOW_PATH = "E:/project/HZIMS/hzims-service/ticket/src/main/resources/template/"; + public static final String TICKET_WINDOW_PATH = "D:/Java/hzims-back/hzims-service/ticket/src/main/resources/template/"; /** * Liunx操作系统工作票访问路径 diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java index 41d0b30..4ff1b08 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java @@ -321,7 +321,7 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl result = new HashMap() {{ - put(prefix + split + "year", dateTime.getYear()); - put(prefix + split + "month", dateTime.getMonthValue()); - put(prefix + split + "day", dateTime.getDayOfMonth()); - put(prefix + split + "hour", dateTime.getHour()); - put(prefix + split + "minuter", dateTime.getMinute()); - put(prefix + split + "second", dateTime.getSecond()); + put(prefix + split + "year",String.format("%02d", dateTime.getYear())); + put(prefix + split + "month",String.format("%02d",dateTime.getMonthValue())); + put(prefix + split + "day",String.format("%02d", dateTime.getDayOfMonth())); + put(prefix + split + "hour",String.format("%02d", dateTime.getHour())); + put(prefix + split + "minuter", String.format("%02d",dateTime.getMinute())); + put(prefix + split + "second",String.format("%02d",dateTime.getSecond())); }}; return result; } diff --git a/hzims-service/ticket/src/main/resources/template/水力机械工作票模版.docx b/hzims-service/ticket/src/main/resources/template/水力机械工作票模版.docx index e5b56d6..4070848 100644 Binary files a/hzims-service/ticket/src/main/resources/template/水力机械工作票模版.docx and b/hzims-service/ticket/src/main/resources/template/水力机械工作票模版.docx differ