Pu Zhibing
3 天以前 15766d708c3fe150a71fc0f719c18fbfcb4093f4
添加海康威视实时监控对接功能
3个文件已修改
2个文件已添加
82 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-dataInterchange/src/main/java/com/ruoyi/dataInterchange/api/factory/HaiKangClientFallbackFactory.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-dataInterchange/src/main/java/com/ruoyi/dataInterchange/api/feignClient/HaiKangClient.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-dataInterchange/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CarController.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/RealVideoResp.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-dataInterchange/src/main/java/com/ruoyi/dataInterchange/api/factory/HaiKangClientFallbackFactory.java
New file
@@ -0,0 +1,19 @@
package com.ruoyi.dataInterchange.api.factory;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.dataInterchange.api.feignClient.HaiKangClient;
import org.springframework.cloud.openfeign.FallbackFactory; /**
 * @author zhibing.pu
 * @Date 2025/5/29 9:07
 */
public class HaiKangClientFallbackFactory implements FallbackFactory<HaiKangClient>  {
@Override
    public HaiKangClient create(Throwable cause) {
        return new HaiKangClient() {
        @Override
            public R<String> getCarPreviewURLs(String vehicleLicensePlate) {
                return R.fail("获取预览地址失败:" + cause.getMessage());
            }
        };
    }
}
ruoyi-api/ruoyi-api-dataInterchange/src/main/java/com/ruoyi/dataInterchange/api/feignClient/HaiKangClient.java
New file
@@ -0,0 +1,23 @@
package com.ruoyi.dataInterchange.api.feignClient;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.dataInterchange.api.factory.HaiKangClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; /**
 * @author zhibing.pu
 * @Date 2025/5/29 9:07
 */
@FeignClient(contextId = "PlaybackMsgClient", value = ServiceNameConstants.DATA_INTERCHANGE_SERVICE, fallbackFactory = HaiKangClientFallbackFactory.class)
public interface HaiKangClient {
    /**
     * 获取海康的实时监控预览url
     * @param vehicleLicensePlate
     * @return
     */
    @PostMapping("/haikang/getCarPreviewURLs")
    R<String> getCarPreviewURLs(@RequestParam("vehicleLicensePlate") String vehicleLicensePlate);
}
ruoyi-api/ruoyi-api-dataInterchange/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -4,4 +4,5 @@
com.ruoyi.dataInterchange.api.factory.UPExgMsgRealLocationClientFallbackFactory
com.ruoyi.dataInterchange.api.factory.UPWarnMsgAdptInfoClientFallbackFactory
com.ruoyi.dataInterchange.api.factory.UPExgMsgTakeEwayBillAckClientFallbackFactory
com.ruoyi.dataInterchange.api.factory.PlaybackMsgClientFallbackFactory
com.ruoyi.dataInterchange.api.factory.PlaybackMsgClientFallbackFactory
com.ruoyi.dataInterchange.api.factory.HaiKangClientFallbackFactory
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/CarController.java
@@ -5,6 +5,7 @@
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.dataInterchange.api.feignClient.HaiKangClient;
import com.ruoyi.dataInterchange.api.feignClient.PlaybackMsgClient;
import com.ruoyi.dataInterchange.api.feignClient.RealVideoMsgClient;
import com.ruoyi.dataInterchange.api.feignClient.UPExgMsgRealLocationClient;
@@ -86,6 +87,9 @@
    @Resource
    private RedisTemplate redisTemplate;
    
    @Resource
    private HaiKangClient haiKangClient;
    @GetMapping("/getCarList")
    @ApiOperation(value = "获取车辆列表", tags = {"车辆管理"})
    public R<PageInfo<CarListResp>> getCarList(CarListReq carListReq) {
@@ -129,23 +133,32 @@
        //手动加一次状态数据,避免定时任务结束任务线程
        redisTemplate.opsForValue().set("live:" + id, true, 1, TimeUnit.MINUTES);
        Enterprise enterprise = enterpriseService.getById(car.getEnterpriseId());
        R<UPRealvideoMsgStartupAckVo> msgStartupAckVoR = realVideoMsgClient.startupRealVideo(Integer.valueOf(enterprise.getCode()), car.getVehicleNumber());
        if (200 == msgStartupAckVoR.getCode()) {
            UPRealvideoMsgStartupAckVo data = msgStartupAckVoR.getData();
            RealVideoResp resp = new RealVideoResp();
            //执行拉流和推流
        //富临走协议返回flv格式视频流
        if(enterprise.getCode().equals("17458936")){
            R<UPRealvideoMsgStartupAckVo> msgStartupAckVoR = realVideoMsgClient.startupRealVideo(Integer.valueOf(enterprise.getCode()), car.getVehicleNumber());
            if (200 == msgStartupAckVoR.getCode()) {
                UPRealvideoMsgStartupAckVo data = msgStartupAckVoR.getData();
                RealVideoResp resp = new RealVideoResp();
                resp.setCompanyCode(enterprise.getCode());
                //执行拉流和推流
//            live_hls(data.getUrl(), car);
//            resp.setServerIp(hlsIp);
//            resp.setServerPort(hlsPort);
            resp.setUrl(data.getUrl());
                resp.setUrl(data.getUrl());
//            live_flv(data.getUrl(), car.getId());
            resp.setServerIp(flvIp);
            resp.setServerPort(flvHttpPort);
                resp.setServerIp(flvIp);
                resp.setServerPort(flvHttpPort);
                return R.ok(resp);
            }
        }else if(enterprise.getCode().equals("25439966")){
            //海康走API获取预览url,trsp格式
            String data = haiKangClient.getCarPreviewURLs(car.getVehicleNumber()).getData();
            RealVideoResp resp = new RealVideoResp();
            resp.setUrl(data);
            return R.ok(resp);
        }
        return R.fail(msgStartupAckVoR.getMsg());
        return R.ok();
    }
    
    
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/query/RealVideoResp.java
@@ -9,6 +9,8 @@
@Data
@ApiModel
public class RealVideoResp {
    @ApiModelProperty("企业编号")
    private String companyCode;
    @ApiModelProperty("视频服务器ip")
    private String serverIp;
    @ApiModelProperty("视频服务器端口号")