Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

zhongwei
yang_shj 3 months ago
parent
commit
b542238a02
  1. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java
  2. 18
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/SyncDTO.java
  3. 4
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/VideoSyncDTO.java
  4. 16
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/ISyncClient.java
  5. 7
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IVideoSyncClient.java
  6. 28
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/constants/SyncTableEnum.java
  7. 24
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/VideoSyncClient.java
  8. 51
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/service/SyncService.java
  9. 40
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoAddConsumer.java
  10. 36
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/business/consumer/VideoRemoveConsumer.java
  11. 16
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeApi.java
  12. 4
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/utils/HiKUtil.java
  13. 4
      hzims-service/operational/pom.xml
  14. 76
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/AddVideoAspect.java
  15. 56
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/aspect/RemoveVideoAspect.java
  16. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java

20
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";
}

18
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;
}

4
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;
}

16
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<T extends SyncDTO> {
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<T extends SyncDTO> {
R saveBatch(List<T> syncDTO);
/**
* 同步 - 更新对象
* @param syncDTO 同步对象
* @return 同步结果
*/
R updateById(T syncDTO);
/**
* 同步 - 删除对象
* @param ids 主键id按逗号分隔
* @return 删除结果
*/
R deleteByIds(String ids);
/**
* 同步 - 根据站点删除对象
* @param stationId 站点ID
* @return 删除结果
*/
R deleteByStationId(String stationId);
}

7
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<VideoSyncDTO> {
R saveBatch(@RequestBody List<VideoSyncDTO> 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);
}

28
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;
}

24
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<VideoSyncDTO> 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<String> 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));
}
}

51
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<String,String> params = new HashMap<>(2);
params.put("station_id",stationId);
params.put("table_name", syncTableEnum.getTableName());
return RequestClientUtil.postCall(bigModelInvokeApi.getDeleteByStationId(),params,new TypeReference<Integer>(){});
}
/**
* 通过id删除数据
* @param id 数据表主键ID
* @param syncTableEnum 同步表枚举类
* @return 删除条数
*/
public Integer deleteById(String id, SyncTableEnum syncTableEnum) {
Integer result = null;
Map<String,String> params = new HashMap<>(2);
params.put("id",id);
params.put("table_name", syncTableEnum.getTableName());
// result = RequestClientUtil.postCall(bigModelInvokeApi.getDeleteById(),params,new TypeReference<Integer>(){});
return result;
}
/***
* 添加数据
* @param api 调用接口
* @param data 同步数据
*/
public void insert(String api, List<? extends SyncDTO> data) {
Map<String, Object> params = BeanUtil.toMap(data);
// RequestClientUtil.postCall(api,params);
}
}

40
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<VideoSyncDTO> videoSyncDTOS = JSONArray.parseArray(message, VideoSyncDTO.class);
if(Func.isNotEmpty(videoSyncDTOS)) {
videoSyncClient.saveBatch(videoSyncDTOS);
}
}
}

36
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));
}
}
}

16
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;
}

4
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

4
hzims-service/operational/pom.xml

@ -213,6 +213,10 @@
<version>3.9.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>big-model-api</artifactId>
</dependency>
</dependencies>
<build>

76
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<VideoSyncDTO> videoSyncDTOS = Lists.newArrayList(this.convert((StationVideoTypeEntity) arg));
mqttSender.sendToMqtt(MqttTopicConstants.TOPIC_VIDEO_INSERT, JSON.toJSONString(videoSyncDTOS));
}
else if(arg instanceof List) {
List<StationVideoTypeEntity> videoList = (List<StationVideoTypeEntity>) args[0];
List<VideoSyncDTO> 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;
}
}

56
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));
}
}
}
}

8
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("操作成功!");
}

Loading…
Cancel
Save