From 1ef7c3070c83fb9231b887603547f7192ca28949 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Mon, 12 Aug 2024 11:57:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=86=E9=A2=91=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=90=91=E9=87=8F=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/api/constants/MqttTopicConstants.java | 20 ++++++ .../com/hnac/hzims/bigmodel/api/dto/SyncDTO.java | 18 ++--- .../hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java | 4 +- .../hnac/hzims/bigmodel/api/feign/ISyncClient.java | 16 ++--- .../hzims/bigmodel/api/feign/IVideoSyncClient.java | 7 +- .../bigmodel/api/constants/SyncTableEnum.java | 28 ++++++++ .../hzims/bigmodel/api/feign/VideoSyncClient.java | 24 +++++-- .../hzims/bigmodel/api/service/SyncService.java | 51 +++++++++++++++ .../business/consumer/VideoAddConsumer.java | 40 ++++++++++++ .../business/consumer/VideoRemoveConsumer.java | 36 ++++++++++ .../bigmodel/configuration/BigModelInvokeApi.java | 16 +++++ .../com/hnac/hzinfo/inspect/utils/HiKUtil.java | 4 ++ hzims-service/operational/pom.xml | 4 ++ .../operational/station/aspect/AddVideoAspect.java | 76 ++++++++++++++++++++++ .../station/aspect/RemoveVideoAspect.java | 56 ++++++++++++++++ .../controller/StationVideoTypeController.java | 8 ++- 16 files changed, 377 insertions(+), 31 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/constants/SyncTableEnum.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoAddConsumer.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoRemoveConsumer.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/AddVideoAspect.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/RemoveVideoAspect.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java new file mode 100644 index 0000000..0c31edb --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.api.constants; + +/** + * @Author: huangxing + * @Date: 2024/08/09 13:48 + */ +public interface MqttTopicConstants { + + /** + * 新增视频主题 + */ + String TOPIC_VIDEO_INSERT = "topic_video_insert"; + + /** + * 删除视频主题 + */ + String TOPIC_VIDEO_DELETE = "topic_video_delete"; + + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java index 19507de..3820364 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java @@ -28,8 +28,8 @@ public class SyncDTO implements Serializable { @JSONField(name = "item_name") private String itemName; - @ApiModelProperty("类型,可为'平台'或'业务'") - private String type; +// @ApiModelProperty("类型,可为'平台'或'业务'") +// private String type; @ApiModelProperty("站点I,平台yk必须有,否则可为null") @JSONField(name = "station_id") @@ -39,12 +39,12 @@ public class SyncDTO implements Serializable { @JSONField(name = "station_name") private String stationName; - @ApiModelProperty("设备ID,平台yk必须有,否则可为null") - @JSONField(name = "device_id") - private String deviceId; - - @ApiModelProperty("设备名称,平台yk必须有,否则可为null") - @JSONField(name = "device_name") - private String deviceName; +// @ApiModelProperty("设备ID,平台yk必须有,否则可为null") +// @JSONField(name = "device_id") +// private String deviceId; +// +// @ApiModelProperty("设备名称,平台yk必须有,否则可为null") +// @JSONField(name = "device_name") +// private String deviceName; } diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java index 3969228..e813d39 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java @@ -1,5 +1,6 @@ package com.hnac.hzims.bigmodel.api.dto; +import com.alibaba.fastjson.annotation.JSONField; import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; @@ -15,6 +16,7 @@ import java.io.Serializable; @EqualsAndHashCode public class VideoSyncDTO extends SyncDTO implements Serializable { - + @JSONField(name = "video_name") + private String name; } diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java index 8744be5..1111715 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java @@ -13,8 +13,8 @@ import java.util.List; public interface ISyncClient { String SAVE_BATCH = "/saveBatch"; - String UPDATE_BY_ID = "/updateById"; String DELETE_BY_IDS = "/deleteByIds"; + String DELETE_BY_STATION_ID = "/deleteByStationId"; /** * 同步 - 新增对象 @@ -24,17 +24,17 @@ public interface ISyncClient { R saveBatch(List syncDTO); /** - * 同步 - 更新对象 - * @param syncDTO 同步对象 - * @return 同步结果 - */ - R updateById(T syncDTO); - - /** * 同步 - 删除对象 * @param ids 主键id按逗号分隔 * @return 删除结果 */ R deleteByIds(String ids); + /** + * 同步 - 根据站点删除对象 + * @param stationId 站点ID + * @return 删除结果 + */ + R deleteByStationId(String stationId); + } diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java index 6ce759c..ea5c254 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java @@ -23,11 +23,10 @@ public interface IVideoSyncClient extends ISyncClient { R saveBatch(@RequestBody List syncDTO); @Override - @PutMapping(PREFIX_API + UPDATE_BY_ID) - R updateById(@RequestBody VideoSyncDTO syncDTO); - - @Override @DeleteMapping(PREFIX_API + DELETE_BY_IDS) R deleteByIds(@RequestParam("ids") String ids); + @Override + @DeleteMapping(PREFIX_API + DELETE_BY_STATION_ID) + R deleteByStationId(@RequestParam("stationId") String stationId); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/constants/SyncTableEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/constants/SyncTableEnum.java new file mode 100644 index 0000000..b2dd6cc --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/constants/SyncTableEnum.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.bigmodel.api.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @Author: huangxing + * @Date: 2024/08/09 09:13 + */ +@AllArgsConstructor +@Getter +public enum SyncTableEnum { + /**视频**/ + VIDEO("video"), + /**实时画面**/ + CANVAS("canvas"), + /**故障**/ + FAULT("fault"), + /**站点**/ + STATION("station"), + /**实时数据属性**/ + RECORD("record"), + /**遥控**/ + REMOTE("yk") + ; + private final String tableName; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java index 58cf420..46a3681 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java @@ -1,8 +1,12 @@ package com.hnac.hzims.bigmodel.api.feign; +import com.hnac.hzims.bigmodel.api.constants.SyncTableEnum; import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; +import com.hnac.hzims.bigmodel.api.service.SyncService; +import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -15,21 +19,27 @@ import java.util.List; @AllArgsConstructor public class VideoSyncClient implements IVideoSyncClient{ + private final SyncService syncService; + private final BigModelInvokeApi bigModelInvokeApi; + @Override @PostMapping(PREFIX_API + SAVE_BATCH) public R saveBatch(@RequestBody List syncDTO) { - return null; + syncService.insert(bigModelInvokeApi.getInsertVideo(),syncDTO); + return R.success("同步数据成功!"); } @Override - @PutMapping(PREFIX_API + UPDATE_BY_ID) - public R updateById(@RequestBody VideoSyncDTO syncDTO) { - return null; + @DeleteMapping(PREFIX_API + DELETE_BY_IDS) + public R deleteByIds(@RequestParam("ids") String ids) { + List idList = Func.toStrList(",", ids); + idList.forEach(id -> syncService.deleteById(id, SyncTableEnum.VIDEO)); + return R.success("同步数据成功!"); } @Override - @DeleteMapping(PREFIX_API + DELETE_BY_IDS) - public R deleteByIds(@RequestParam String ids) { - return null; + @DeleteMapping(PREFIX_API + DELETE_BY_STATION_ID) + public R deleteByStationId(@RequestParam("stationId") String stationId) { + return R.data(syncService.deleteByStationId(stationId,SyncTableEnum.VIDEO)); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java index 422989f..9a0a95c 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java @@ -1,9 +1,21 @@ package com.hnac.hzims.bigmodel.api.service; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.hnac.hzims.bigmodel.api.constants.SyncTableEnum; +import com.hnac.hzims.bigmodel.api.dto.SyncDTO; +import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; +import com.hnac.hzims.bigmodel.configuration.BigModelInvokeApi; +import com.hnac.hzims.bigmodel.utils.RequestClientUtil; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.BeanUtil; import org.springframework.stereotype.Service; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * @Author: huangxing * @Date: 2024/07/10 09:03 @@ -13,4 +25,43 @@ import org.springframework.stereotype.Service; @AllArgsConstructor public class SyncService { + private final BigModelInvokeApi bigModelInvokeApi; + + /** + * 通过站点id删除数据 + * @param stationId 站点ID + * @param syncTableEnum 同步表枚举类 + * @return 删除条数 + */ + public Integer deleteByStationId(String stationId, SyncTableEnum syncTableEnum) { + Map params = new HashMap<>(2); + params.put("station_id",stationId); + params.put("table_name", syncTableEnum.getTableName()); + return RequestClientUtil.postCall(bigModelInvokeApi.getDeleteByStationId(),params,new TypeReference(){}); + } + + /** + * 通过id删除数据 + * @param id 数据表主键ID + * @param syncTableEnum 同步表枚举类 + * @return 删除条数 + */ + public Integer deleteById(String id, SyncTableEnum syncTableEnum) { + Integer result = null; + Map params = new HashMap<>(2); + params.put("id",id); + params.put("table_name", syncTableEnum.getTableName()); +// result = RequestClientUtil.postCall(bigModelInvokeApi.getDeleteById(),params,new TypeReference(){}); + return result; + } + + /*** + * 添加数据 + * @param api 调用接口 + * @param data 同步数据 + */ + public void insert(String api, List data) { + Map params = BeanUtil.toMap(data); +// RequestClientUtil.postCall(api,params); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoAddConsumer.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoAddConsumer.java new file mode 100644 index 0000000..4bf58da --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoAddConsumer.java @@ -0,0 +1,40 @@ +package com.hnac.hzims.bigmodel.business.consumer; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; +import com.hnac.hzims.bigmodel.api.feign.ISyncClient; +import com.hnac.hzims.bigmodel.api.feign.VideoSyncClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.mqtt.customer.IMqttReceive; +import org.springblade.mqtt.customer.annotation.MqttReceive; +import org.springframework.stereotype.Service; +import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/08/09 10:33 + */ +@MqttReceive(topicName = MqttTopicConstants.TOPIC_VIDEO_INSERT) +@Service +@Slf4j +@AllArgsConstructor +public class VideoAddConsumer implements IMqttReceive { + + private final VideoSyncClient videoSyncClient; + + @Override + public void handlerMessage(String message) { + log.info("收到新增视频信息,消息内容体为:{}", message); + List videoSyncDTOS = JSONArray.parseArray(message, VideoSyncDTO.class); + if(Func.isNotEmpty(videoSyncDTOS)) { + videoSyncClient.saveBatch(videoSyncDTOS); + } + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoRemoveConsumer.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoRemoveConsumer.java new file mode 100644 index 0000000..01afc3e --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoRemoveConsumer.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.bigmodel.business.consumer; + +import com.alibaba.fastjson.JSONArray; +import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants; +import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; +import com.hnac.hzims.bigmodel.api.feign.VideoSyncClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.Func; +import org.springblade.mqtt.customer.IMqttReceive; +import org.springblade.mqtt.customer.annotation.MqttReceive; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/08/12 09:29 + */ +@MqttReceive(topicName = MqttTopicConstants.TOPIC_VIDEO_DELETE) +@Service +@Slf4j +@AllArgsConstructor +public class VideoRemoveConsumer implements IMqttReceive { + + private final VideoSyncClient videoSyncClient; + + + @Override + public void handlerMessage(String message) { + log.info("收到删除视频信息,消息内容体为:{}", message); + if(Func.isNotEmpty(message)) { + Func.toStrList(",",message).forEach(id -> videoSyncClient.deleteByIds(id)); + } + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java index b22db97..a61d254 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java @@ -30,4 +30,20 @@ public class BigModelInvokeApi { private String assistantKnowledgeAsk; private String hotQuestion; + + private String deleteByStationId; + + private String deleteById; + + private String insertCanvas; + + private String insertFault; + + private String insertRecord; + + private String insertStation; + + private String insertVideo; + + private String insertYk; } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/utils/HiKUtil.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/utils/HiKUtil.java index 1fd883b..44f44b9 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/utils/HiKUtil.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/utils/HiKUtil.java @@ -100,6 +100,10 @@ public class HiKUtil { .map(JSONObject::parseObject).map(o -> o.getString("picUrl")).orElse(null); } +// public static void main(String[] args) { +// System.out.println(HiKUtil.manualCapture("5e73bfcd8dba40de9be905588aa5b62b")); +// } + /** * 海康视频调用API * @param api 海康API diff --git a/hzims-service/operational/pom.xml b/hzims-service/operational/pom.xml index 6f51eae..802278d 100644 --- a/hzims-service/operational/pom.xml +++ b/hzims-service/operational/pom.xml @@ -213,6 +213,10 @@ 3.9.1 compile + + com.hnac.hzims + big-model-api + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/AddVideoAspect.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/AddVideoAspect.java new file mode 100644 index 0000000..272eda4 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/AddVideoAspect.java @@ -0,0 +1,76 @@ +package com.hnac.hzims.operational.station.aspect; + +import com.alibaba.fastjson.JSON; +import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants; +import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.operational.station.vo.StationVO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.mqtt.producer.IMqttSender; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/08/09 14:02 + */ +@Aspect +@Component +@AllArgsConstructor +@Slf4j +public class AddVideoAspect { + + private final IStationService stationService; + private final IMqttSender mqttSender; + + @Pointcut("execution(* com.hnac.hzims.operational.station.service.IStationVideoTypeService.saveBatch(..)) " + + "|| execution(* com.hnac.hzims.operational.station.service.IStationVideoTypeService.save(..)) " + + "|| execution(* com.hnac.hzims.operational.station.service.IStationVideoTypeService.updateById(..)) " + + "|| execution(* com.hnac.hzims.operational.station.service.IStationVideoTypeService.updateBatchById(..))") + private void pointCut() { + + } + + @After("pointCut()") + public void after(JoinPoint point) { + Object[] args = point.getArgs(); + if(args.length == 1) { + Object arg = args[0]; + if(arg instanceof StationVideoTypeEntity) { + List videoSyncDTOS = Lists.newArrayList(this.convert((StationVideoTypeEntity) arg)); + mqttSender.sendToMqtt(MqttTopicConstants.TOPIC_VIDEO_INSERT, JSON.toJSONString(videoSyncDTOS)); + } + else if(arg instanceof List) { + List videoList = (List) args[0]; + List videoSyncDTOS = videoList.stream().map(this::convert).collect(Collectors.toList()); + mqttSender.sendToMqtt(MqttTopicConstants.TOPIC_VIDEO_INSERT, JSON.toJSONString(videoSyncDTOS)); + } + } + } + + private VideoSyncDTO convert(StationVideoTypeEntity entity) { + VideoSyncDTO videoSyncDTO = BeanUtil.copy(entity,VideoSyncDTO.class); + StationVO station = stationService.getStationByCode(entity.getStationId()); + String stationName = Optional.ofNullable(station).map(StationVO::getName).orElse(""); + videoSyncDTO.setId(String.valueOf(entity.getId())); + videoSyncDTO.setItemId(String.valueOf(entity.getId())); + videoSyncDTO.setStationName(stationName); + videoSyncDTO.setItemName(stationName + " " + videoSyncDTO.getName()); + return videoSyncDTO; + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/RemoveVideoAspect.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/RemoveVideoAspect.java new file mode 100644 index 0000000..6275b7e --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/RemoveVideoAspect.java @@ -0,0 +1,56 @@ +package com.hnac.hzims.operational.station.aspect; + +import com.alibaba.fastjson.JSON; +import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants; +import com.hnac.hzims.bigmodel.api.dto.VideoSyncDTO; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; +import com.hnac.hzims.operational.station.service.IStationService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springblade.mqtt.producer.IMqttSender; +import org.springframework.stereotype.Component; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/08/12 09:17 + */ +@Aspect +@Component +@AllArgsConstructor +@Slf4j +public class RemoveVideoAspect { + + private final IMqttSender mqttSender; + + @Pointcut("execution(* com.hnac.hzims.operational.station.service.IStationVideoTypeService.removeById(..)) " + + "|| execution(* com.hnac.hzims.operational.station.service.IStationVideoTypeService.removeByIds(..)) ") + private void pointCut() { + + } + + @After("pointCut()") + public void after(JoinPoint point) { + Object[] args = point.getArgs(); + if(args.length == 1) { + Object arg = args[0]; + if(arg instanceof Long) { + // 若调用接口为removeById 则传参为long类型 将ID传给大模型进行数据同步 + mqttSender.sendToMqtt(MqttTopicConstants.TOPIC_VIDEO_DELETE, String.valueOf(arg)); + } + else if(arg instanceof Collection) { + // 若调用接口为removeByIds 则传参为String类型 将ID传给大模型进行数据同步 + mqttSender.sendToMqtt(MqttTopicConstants.TOPIC_VIDEO_DELETE, JSON.toJSONString(arg)); + } + } + } + +} 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 c6fed19..8b73cb7 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 @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.api.constants.MqttTopicConstants; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; @@ -36,6 +37,7 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.mqtt.producer.IMqttSender; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springframework.beans.factory.annotation.Value; @@ -59,7 +61,7 @@ public class StationVideoTypeController extends BladeController { private final IStationVideoTypeService stationVideoTypeService; private final ISysClient sysClient; - + private final IMqttSender mqttSender; private final IStationService stationService; private final VideoConfigService videoConfigService; @@ -155,7 +157,9 @@ public class StationVideoTypeController extends BladeController { @ApiOperationSupport(order = 40) @ApiOperation(value = "逻辑删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(stationVideoTypeService.removeByIds(Func.toLongList(ids))); + stationVideoTypeService.removeByIds(Func.toLongList(ids)); + mqttSender.sendToMqtt(MqttTopicConstants.TOPIC_VIDEO_DELETE, ids); + return R.success("操作成功!"); }