diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java new file mode 100644 index 0000000..bee063e --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.alarm.show.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author ysj + * @date 2023/03/17 10:02:33 + * @version 4.0.0 + */ +@Data +public class ShowQueryVo { + + @ApiModelProperty(value = "站点编号") + private String stationId; + + @ApiModelProperty(value = "站点类型") + private Integer serveType; + + @ApiModelProperty(value = "告警类型 :0- HZ3000告警 1 -等级告警 2 -条件告警 3-FDP智能预警 4-视频预警 5-开关机告警") + private Integer alarmSource; + + @ApiModelProperty(value = "告警子类") + private Integer alarmType; +} + diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java new file mode 100644 index 0000000..06123de --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.business.ws.alart.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "告警弹框参数", description = "") +public class AlartParamVo { + + @ApiModelProperty("站点类型: 2-云服务 1-代运维") + private Integer serveType; + + @ApiModelProperty("用户权限机构集合") + private List depts; +} \ No newline at end of file diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java index c73f78e..b9355a2 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMilesYearVO.java @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; +import java.util.Date; /** * @author liwen @@ -78,4 +79,7 @@ public class CarMilesYearVO { @ExcelProperty(value = "合计里程/km", order = 15) @ApiModelProperty("合计里程数") private BigDecimal sumMiles; + + @ApiModelProperty("创建时间") + private Date createTime; } 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 8deca55..b8aec8c 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 @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; +import com.hnac.hzims.alarm.show.vo.ShowQueryVo; import com.hnac.hzims.alarm.source.service.SystemAlarmService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; @@ -37,31 +38,33 @@ public class ShowAlarmController extends BladeController { @ApiOperationSupport(order = 1) @ApiOperation(value = "播报告警", notes = "传入:时间区间") public R> broadcast(@ApiParam(value = "开始时间") String startTime, - @ApiParam(value = "结束时间", required = true) String endTime) { - return R.data(alarmService.broadcast(startTime,endTime)); + @ApiParam(value = "结束时间", required = true) String endTime, + @ApiParam(value = "站点类型") Integer serveType) { + return R.data(alarmService.broadcast(startTime,endTime,serveType)); } @PostMapping("/show") @ApiOperationSupport(order = 2) @ApiOperation(value = "告警列表分页", notes = "传入: AlarmConfigEntity对象,分页参数") - public R> alarms(AlarmEntity alarm, Query query) { - return R.data(alarmService.alarms(alarm,Condition.getPage(query))); + public R> alarms(ShowQueryVo showQuery, Query query) { + return R.data(alarmService.alarms(showQuery,Condition.getPage(query))); } @PostMapping("/count") @ApiOperationSupport(order = 3) @ApiOperation(value = "告警分类数量", notes = "不需要传入参数") - public R> counts(@RequestBody AlarmEntity alarm) { - return R.data(alarmService.counts(alarm)); + public R> counts(@RequestBody ShowQueryVo showCount) { + return R.data(alarmService.counts(showCount)); } @GetMapping("/alarmVideos") @ApiOperationSupport(order = 4) @ApiOperation(value = "站点") - public R> alarmVideos(@ApiParam("站点编号") @RequestParam String stationCode, - @ApiParam("设备编号") @RequestParam String deviceCode, - @ApiParam("监测点ID") @RequestParam String realId) { - return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId)); + public R> alarmVideos(@ApiParam("站点编号") @RequestParam(required = false) String stationCode, + @ApiParam("设备编号") @RequestParam(required = false) String deviceCode, + @ApiParam("监测点ID") @RequestParam(required = false) String realId, + @ApiParam("告警类型") @RequestParam Integer alarmType) { + return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId,alarmType)); } } \ 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 0bc7f77..064489d 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 @@ -4,6 +4,8 @@ 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.alarm.show.vo.AlarmVideoVo; +import com.hnac.hzims.alarm.show.vo.ShowQueryVo; +import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import org.springblade.core.mp.base.BaseService; import org.springframework.web.socket.TextMessage; @@ -15,13 +17,13 @@ import java.util.List; */ public interface AlarmService extends BaseService { - IPage alarms(AlarmEntity alarm, IPage page); + IPage alarms(ShowQueryVo showQuery, IPage page); - List counts(AlarmEntity alarm); + List counts(ShowQueryVo showCount); - List broadcast(String startTime, String endTime); + List broadcast(String startTime, String endTime,Integer serveType); - TextMessage majorAlarm(List depts); + TextMessage majorAlarm(AlartParamVo param); - List alarmVideos(String stationCode, String deviceCode, String realId); + List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType); } \ 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 f822a0a..2e69bc6 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 @@ -1,6 +1,7 @@ package com.hnac.hzims.alarm.show.service.impl; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.config.constants.AlarmConstants; @@ -12,29 +13,37 @@ import com.hnac.hzims.alarm.show.mapper.AlarmMapper; import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; +import com.hnac.hzims.alarm.show.vo.ShowQueryVo; import com.hnac.hzims.alarm.source.service.MessageService; +import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; 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.fdp.util.HttpRequestUtil; 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.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; -import lombok.AllArgsConstructor; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceEventVO; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; 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.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import org.springframework.util.Assert; import org.springframework.web.socket.TextMessage; import java.util.*; @@ -43,7 +52,7 @@ import java.util.stream.Collectors; /** * @author ysj */ -@AllArgsConstructor +@RequiredArgsConstructor @Service @Slf4j public class AlarmServiceImpl extends BaseServiceImpl implements AlarmService { @@ -59,19 +68,27 @@ 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; + private final IStationVideoTypeClient stationVideoTypeClient; + + @Value("${hzims.url.getFaultGraphInfo}") + private String FAULTGRAPH_INFO_PATH; + /** * 查询告警列表 - * @param alarm + * @param showQuery * @param page * @return */ @Override - public IPage alarms(AlarmEntity alarm, IPage page) { - List stations = this.stations(); + public IPage alarms(ShowQueryVo showQuery, IPage page) { + List stations = this.stations(showQuery.getServeType()); if(CollectionUtil.isEmpty(stations)){ return page; } @@ -82,14 +99,14 @@ public class AlarmServiceImpl extends BaseServiceImpl wrapper.eq("IS_RIGHT_TABULATION",0); wrapper.eq("STATUS",0); wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - if(!StringUtil.isEmpty(alarm.getStationId())){ - wrapper.eq("STATION_ID",alarm.getStationId()); + if(!StringUtil.isEmpty(showQuery.getStationId())){ + wrapper.eq("STATION_ID",showQuery.getStationId()); } - if(!StringUtil.isEmpty(alarm.getAlarmSource())){ - wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource()); + if(!StringUtil.isEmpty(showQuery.getAlarmSource())){ + wrapper.eq("ALARM_SOURCE",showQuery.getAlarmSource()); } - if(!StringUtil.isEmpty(alarm.getAlarmType())){ - wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); + if(!StringUtil.isEmpty(showQuery.getAlarmType())){ + wrapper.eq("ALARM_TYPE",showQuery.getAlarmType()); } // 处理告警过滤 :当天处理告警 @@ -106,9 +123,11 @@ public class AlarmServiceImpl extends BaseServiceImpl * 获取权限站点 * @return */ - private List stations() { + private List stations(Integer serveType) { StationEntity station = new StationEntity(); - station.setServeType("2"); + if(ObjectUtil.isNotEmpty(serveType)){ + station.setServeType(String.valueOf(serveType)); + } station.setType(0); R> result = stationClient.list(station); if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ @@ -122,9 +141,9 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - public List counts(AlarmEntity alarm) { + public List counts(ShowQueryVo showCount) { // 站点查询 - List stations = this.stations(); + List stations = this.stations(showCount.getServeType()); if(CollectionUtil.isEmpty(stations)){ return AlarmConstants.ALARAM_SOURCE.stream().map(source->{ AlarmCountVo count = new AlarmCountVo(); @@ -139,14 +158,14 @@ public class AlarmServiceImpl extends BaseServiceImpl wrapper.eq("IS_RIGHT_TABULATION",0); wrapper.eq("STATUS",0); wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); - if(!StringUtil.isEmpty(alarm.getStationId())){ - wrapper.eq("STATION_ID",alarm.getStationId()); + if(!StringUtil.isEmpty(showCount.getStationId())){ + wrapper.eq("STATION_ID",showCount.getStationId()); } - if(!StringUtil.isEmpty(alarm.getAlarmSource())){ - wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource()); + if(!StringUtil.isEmpty(showCount.getAlarmSource())){ + wrapper.eq("ALARM_SOURCE",showCount.getAlarmSource()); } - if(!StringUtil.isEmpty(alarm.getAlarmType())){ - wrapper.eq("ALARM_TYPE",alarm.getAlarmType()); + if(!StringUtil.isEmpty(showCount.getAlarmType())){ + wrapper.eq("ALARM_TYPE",showCount.getAlarmType()); } // 处理告警过滤 :当天处理告警 List handles = alarmHandleService.handles(); @@ -176,9 +195,9 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - public List broadcast(String startTime, String endTime) { + public List broadcast(String startTime, String endTime,Integer serveType) { // 站点查询 - List stations = this.stations(); + List stations = this.stations(serveType); if(CollectionUtil.isEmpty(stations)){ return new ArrayList<>(); } @@ -196,17 +215,17 @@ public class AlarmServiceImpl extends BaseServiceImpl /** * 弹框告警 - * @param depts + * @param param * @return */ @Override - public TextMessage majorAlarm(List depts) { + public TextMessage majorAlarm(AlartParamVo param) { // 站点查询 - List stations = this.stations(); - if(CollectionUtil.isEmpty(stations)){ + List stations = this.stations(param.getServeType()); + if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(param.getDepts())){ return new TextMessage(new ArrayList().toString()); } - List effectives = stations.stream().filter(station->depts.contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); + List effectives = stations.stream().filter(station->param.getDepts().contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); if(CollectionUtil.isEmpty(effectives)){ return new TextMessage(new ArrayList().toString()); } @@ -274,9 +293,20 @@ public class AlarmServiceImpl extends BaseServiceImpl * @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())); + // 属性 + R> attrs = deviceClient.getOnlineAttr(emCode); + if(attrs.isSuccess() && CollectionUtil.isNotEmpty(attrs.getData())) { + return attrs.getData().stream().anyMatch(attr -> realId.equals(attr.getFacDeviceAttrId())); + } + // 事件 + R> events = deviceClient.getOnlineEvent(emCode); + if(events.isSuccess() && CollectionUtil.isNotEmpty(events.getData())) { + return events.getData().stream().anyMatch(event -> realId.equals(event.getFacDeviceEventId())); + } + // 功能 + R> funcs = deviceClient.getOnlineFunc(emCode); + if(funcs.isSuccess() && CollectionUtil.isNotEmpty(funcs.getData())) { + return funcs.getData().stream().anyMatch(func -> realId.equals(func.getSourceAttrSignage())); } return false; } @@ -406,19 +436,155 @@ public class AlarmServiceImpl extends BaseServiceImpl * @return */ @Override - public List alarmVideos(String stationCode, String deviceCode, String realId) { - // 根据realId查找 + public List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType) { + // 步骤1、根据设备编号查询视频信息 + if(StringUtil.isNotBlank(deviceCode)){ + return this.deviceVideos(stationCode,deviceCode); + } + // 步骤2、根据采集点查询视频信息 if(StringUtil.isNotBlank(realId)){ + // 智能预警 + if(AlarmConstants.EARLY.equals(alarmType)){ + return this.earlyVideos(stationCode,realId); + // 通讯中断、通讯异常查询站点视频 + }else if(AlarmConstants.INTERRUPT.equals(alarmType) || AlarmConstants.ABNORMAL.equals(alarmType)){ + return this.stationVideos(stationCode); + // 其他告警 + }else{ + return this.realIdVideos(stationCode,realId); + } + } + // 步骤3.根据站点编号查询视频信息 + if(StringUtil.isNotBlank(stationCode)){ + return this.stationVideos(stationCode); + } + throw new ServiceException("未查询到告警视频信息!"); + } + + /** + *查询站点绑定视频信息 + * @param stationCode + */ + private List stationVideos(String stationCode) { + List videos = stationVideoTypeClient.listByStationId(stationCode); + if(CollectionUtil.isEmpty(videos)){ + throw new ServiceException("站点暂无视频信息!"); } - // 根据设备编号查找 - if(StringUtil.isNotBlank(deviceCode)){ + return videos.stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getName()); + alarmVideo.setVideoAppKey(video.getAppKey()); + alarmVideo.setVideoAppSecret(video.getAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); + } + + + /** + * 查询设备绑定视频信息 + * @param deviceCode + * @return + */ + private List deviceVideos(String stationCode,String deviceCode) { + // 查询设备绑定视频点位 + R> videos = emVideoClient.getEmBandingVideos(deviceCode); + if(!videos.isSuccess() || CollectionUtil.isEmpty(videos.getData())){ + // 查询站点 + R station = stationClient.getStationByCode(stationCode); + if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ + throw new ServiceException("未查询到设备绑定视频信息!"); + } + // 查询设备 + R device = emInfoClient.getEmInfoByEmCode(deviceCode); + if(!device.isSuccess() || ObjectUtil.isEmpty(device.getData())){ + throw new ServiceException("未查询到设备绑定视频信息!"); + } + throw new ServiceException("请在设备信息菜单绑定" + station.getData().getName() + "-" + device.getData().getName() + "视频信息!"); + } + return videos.getData().stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getVideoName()); + alarmVideo.setVideoAppKey(video.getVideoAppKey()); + alarmVideo.setVideoAppSecret(video.getVideoAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); + } + /** + * 查询智能预警视频信息 + * @param stationCode + * @param faultId + */ + private List earlyVideos(String stationCode, String faultId) { + // 调用FDP接口查询设备编号 + Map param = new HashMap<>(); + param.put("faultId", faultId); + String result = HttpRequestUtil.postCall(param, FAULTGRAPH_INFO_PATH, "POST"); + if (StringUtil.isBlank(result)) { + throw new ServiceException("未查询到智能预警设备信息!"); } - // 根据站点编号查找 - if(StringUtil.isNotBlank(stationCode)){ + HashMap map = JSONObject.parseObject(result, new TypeReference>() { + }); + if (ObjectUtil.isEmpty(map)) { + throw new ServiceException("未查询到智能预警设备信息!"); + } + List> data = JSONObject.parseObject(MapUtils.getString(map, "data"), new TypeReference>>() { + }); + if (CollectionUtil.isEmpty(data)) { + throw new ServiceException("未查询到智能预警设备信息!"); + } + String deviceCode = (String) data.get(0).get("TAOS_INSTANCE"); + if(StringUtil.isBlank(deviceCode)){ + throw new ServiceException("未查询到智能预警设备信息!"); + } + return this.deviceVideos(stationCode,deviceCode); + } + /** + * 查询采集点绑定视频信息 + * @param stationCode + * @param realId + */ + private List realIdVideos(String stationCode, String realId) { + // 查询站点 + R station = stationClient.getStationByCode(stationCode); + if(!station.isSuccess() || ObjectUtil.isEmpty(station)){ + throw new ServiceException("未查询到告警采集点绑定视频信息!"); } - return new ArrayList<>(); + EmInfoEntity param = new EmInfoEntity(); + param.setDepartment(station.getData().getRefDept()); + // 查询设备 + R> devices = emInfoClient.emInfoList(param); + if(!devices.isSuccess() || CollectionUtil.isEmpty(devices.getData())){ + throw new ServiceException("未查询到告警采集点绑定视频信息!"); + } + String deviceCodes = devices.getData().stream().parallel() + .filter(this::isBandingVideoByEmCode) + .filter(this::isDeviceCodeExist) + .map(EmInfoEntity::getNumber) + .filter(number -> this.isRealIdBanding(realId, number)) + .collect(Collectors.joining(",")); + if(StringUtil.isEmpty(deviceCodes)){ + throw new ServiceException("未查询到告警采集点绑定视频信息!"); + } + // 查询设备绑定视频点位 + R> videos = emVideoClient.getEmBandingVideos(deviceCodes); + if(!videos.isSuccess() || CollectionUtil.isEmpty(videos.getData())){ + throw new ServiceException("请在设备信息菜单绑定" + station.getData().getName() + "的设备视频绑定信息!"); + } + return videos.getData().stream().distinct().map(video->{ + AlarmVideoVo alarmVideo = new AlarmVideoVo(); + alarmVideo.setVideoHost(video.getVideoHost()); + alarmVideo.setVideoName(video.getVideoName()); + alarmVideo.setVideoAppKey(video.getVideoAppKey()); + alarmVideo.setVideoAppSecret(video.getVideoAppSecret()); + alarmVideo.setPointCode(video.getPointCode()); + return alarmVideo; + }).collect(Collectors.toList()); } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java index 373ef43..f6052a0 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java @@ -2,8 +2,8 @@ package com.hnac.hzims.alarm.ws.alart; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -13,7 +13,6 @@ import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.handler.TextWebSocketHandler; import java.io.IOException; -import java.util.List; /** * @author ysj @@ -57,11 +56,11 @@ public class AlarmHandler extends TextWebSocketHandler { if(StringUtil.isBlank(message)){ return; } - List depts = JSONObject.parseArray(message,Long.class); - if(CollectionUtil.isEmpty(depts)){ + AlartParamVo param = JSONObject.parseObject(message,AlartParamVo.class); + if(ObjectUtil.isEmpty(param)){ return; } - TextMessage sendMessage = alarmService.majorAlarm(depts); + TextMessage sendMessage = alarmService.majorAlarm(param); session.sendMessage(sendMessage); } } 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 dfca1da..834ec1c 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 @@ -127,7 +127,7 @@ public class RealTargetServiceImpl implements RealTargetService { private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; // 创建线程池 - private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); + private static final ExecutorService pool = new ThreadPoolExecutor(20, 20, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); @Override public void loadEmInfo(String param) { @@ -281,24 +281,38 @@ public class RealTargetServiceImpl implements RealTargetService { // 水电站设备 List devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); if(CollectionUtil.isNotEmpty(devices)){ - targets.addAll(devices.stream().map(device->{ - HydropowerUnitTargetVo target = new HydropowerUnitTargetVo(); - target.setDeptId(device.getCreateDept()); - target.setDeviceCode(device.getEmCode()); - target.setDeviceName(device.getName()); - target.setDeptName(device.getName()); - // 当年发电量 - target.setPowerYear(this.getGenerationPower(device,0)); - // 当月发电量 - target.setPowerMon(this.getGenerationPower(device,1)); - // 当日发电量 - target.setPowerDay(this.getGenerationPower(device,2)); - // 当天有功功率 - target.setActivePowerVoList(this.getLoadsByDay(device)); - // 30天发电量 - target.setGenerationPowerVoList(this.getGenerationPowerList(device)); - return target; - }).collect(Collectors.toList())); + CountDownLatch countDownLatch = new CountDownLatch(devices.size()); + for(EminfoAndEmParamVo device : devices) { + pool.submit(() -> { + try{ + HydropowerUnitTargetVo target = new HydropowerUnitTargetVo(); + target.setDeptId(device.getCreateDept()); + target.setDeviceCode(device.getEmCode()); + target.setDeviceName(device.getName()); + target.setDeptName(device.getName()); + // 当年发电量 + target.setPowerYear(this.getGenerationPower(device, 0)); + // 当月发电量 + target.setPowerMon(this.getGenerationPower(device, 1)); + // 当日发电量 + target.setPowerDay(this.getGenerationPower(device, 2)); + // 当天有功功率 + target.setActivePowerVoList(this.getLoadsByDay(device)); + // 30天发电量 + target.setGenerationPowerVoList(this.getGenerationPowerList(device)); + targets.add(target); + countDownLatch.countDown(); + }catch (Exception exception){ + countDownLatch.countDown(); + } + }); + } + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } } // 站点指标数据为空 if(CollectionUtil.isEmpty(targets)){ @@ -1253,16 +1267,20 @@ public class RealTargetServiceImpl implements RealTargetService { CountDownLatch countDownLatch = new CountDownLatch(limits.size()); for(List item : limits){ pool.submit(()->{ - item.forEach(station->{ - // 站点设备集合 - List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); - Map generateMap = this.getGenerateYear(station,stationDevices,start,end); - if(MapUtils.isEmpty(generateMap)){ - return; - } - powerMap.put(station.getId(),generateMap); - }); - countDownLatch.countDown(); + try{ + item.forEach(station->{ + // 站点设备集合 + List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + Map generateMap = this.getGenerateYear(station,stationDevices,start,end); + if(MapUtils.isEmpty(generateMap)){ + return; + } + powerMap.put(station.getId(),generateMap); + }); + countDownLatch.countDown(); + }catch (Exception exception){ + countDownLatch.countDown(); + } log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); }); diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java index 378ce44..a2266d6 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java @@ -334,9 +334,12 @@ public class InspectOfflineServiceImpl implements IOfflineDataService { List fileJson = new ArrayList<>(); // 查询当天数据(条件) String currentDate = DateUtil.formatDateTime(DateUtil.now()); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH,-1); // 巡检任务ID集合 List taskUsers = this.taskUserService.list(new LambdaQueryWrapper() {{ eq(TaskUserEntity::getUserId, user.getUserId()); + ge(TaskUserEntity::getCreateTime, DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE)); }}); if(CollectionUtil.isEmpty(taskUsers)){ throw new ServiceException("巡检用户数据不存在!"); @@ -398,10 +401,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService { // 离线任务任务 List offlines = this.tasksData(taskId,fileList); fileJson.add(JsonUtil.toJson(offlines)); - if(fileJson.isEmpty()){ - return; - } - // 文件写入 + // 文件写入 for (int i=0; i < fileJson.size();i++){ TableJsonUtils.createJsonFile(fileJson.get(i), download, tableNames.get(i)); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml index 6080ea6..61bea9f 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml @@ -4,7 +4,7 @@ SELECT - t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles, - t1.create_user, t1.create_dept + t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles FROM hzims_car t1 LEFT JOIN hzims_car_used_record t2 ON t1.id = t2.car_id diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java index a46457a..90fadf4 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java @@ -15,6 +15,7 @@ import com.hnac.hzims.safeproduct.entity.CarEntity; import com.hnac.hzims.safeproduct.mapper.CarMapper; import com.hnac.hzims.safeproduct.service.*; import com.hnac.hzims.safeproduct.vo.CarMilesYearVO; +import org.apache.commons.collections4.map.HashedMap; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -29,6 +30,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -71,7 +73,7 @@ public class CarServiceImpl extends ServiceImpl implements } List carList = records.stream().map(CarMilesYearVO::getPlateNumber).collect(Collectors.toList()); List milesList = baseMapper.selectMilesByCar(carList, year); - List res = new ArrayList<>(); + HashedMap map = new HashedMap<>(); milesList.forEach(data -> { CarMilesYearVO carMilesYearVO = records.stream().filter(x -> x.getPlateNumber().equals(data.getPlateNumber())) .collect(Collectors.toList()).get(0); @@ -127,11 +129,14 @@ public class CarServiceImpl extends ServiceImpl implements carMilesYearVO.setSumMiles(sum.add(data.getMiles())); } if (!carMilesYearVO.getSumMiles().equals(new BigDecimal(0))) { - res.add(carMilesYearVO); + map.put(carMilesYearVO.getPlateNumber(), carMilesYearVO); } }); + List list = new ArrayList<>(map.values()); + List res = list.stream().sorted(Comparator.comparing(CarMilesYearVO::getCreateTime).reversed()) + .collect(Collectors.toList()); page.setRecords(res); - page.setTotal(res.size()); + page.setTotal(carPage.getTotal()); return page; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java index c80b1ba..2c1755e 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java @@ -144,10 +144,10 @@ public class BaseUtil { } } // 表格处理 - if (templatePath.equals("template/卫生自查表.docx")) { + if ("template/卫生自查表.docx".equals(templatePath)) { formatHygieneRecordTable(xwpfDocument); } - if (templatePath.equals("template/车辆检查表.docx")) { + if ("template/车辆检查表.docx".equals(templatePath)) { formatCarCheckRecordTable(xwpfDocument); } } catch (Exception e) { @@ -225,13 +225,18 @@ public class BaseUtil { List rows = table.getRows(); // 第三行到倒数第二行为需合并区域 for (int row = 3; row < rows.size() - 1;) { - XWPFTableCell startCell = rows.get(row).getCell(0); - String startText = startCell.getText(); + // 判断责任区和责任人是否完全一致,一致则合并 + XWPFTableCell startFirstCell = rows.get(row).getCell(0); + String startFirstText = startFirstCell.getText(); + XWPFTableCell startSecondCell = rows.get(row).getCell(1); + String startSecondText = startSecondCell.getText(); int index = row + 1; for (; index < rows.size(); index++) { - XWPFTableCell endCell = rows.get(index).getCell(0); - String endText = endCell.getText(); - if (!startText.equals(endText)) { + XWPFTableCell endFirstCell = rows.get(index).getCell(0); + String endFirstText = endFirstCell.getText(); + XWPFTableCell endSecondCell = rows.get(index).getCell(1); + String endSecondText = endSecondCell.getText(); + if (!startFirstText.equals(endFirstText) || !startSecondText.equals(endSecondText)) { break; } }