Commit 4db1c305 authored by baoxiaode's avatar baoxiaode

ai数据传输

parent f84476aa
package com.ruoyi.algorithm.controller; package com.ruoyi.algorithm.controller;
import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.lang.hash.Hash;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.algorithm.domain.dto.AlgorithmCameraListDto; import com.ruoyi.algorithm.domain.dto.AlgorithmCameraListDto;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
...@@ -33,6 +42,7 @@ import com.ruoyi.common.core.page.TableDataInfo; ...@@ -33,6 +42,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* @author ruoyi * @author ruoyi
* @date 2023-04-26 * @date 2023-04-26
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/system/algorithm/camera/base") @RequestMapping("/system/algorithm/camera/base")
public class AlgorithmCameraBaseController extends BaseController public class AlgorithmCameraBaseController extends BaseController
...@@ -86,21 +96,50 @@ public class AlgorithmCameraBaseController extends BaseController ...@@ -86,21 +96,50 @@ public class AlgorithmCameraBaseController extends BaseController
{ {
algorithmCameraBase.setCreateBy(getUsername()); algorithmCameraBase.setCreateBy(getUsername());
algorithmCameraBaseService.insertAlgorithmCameraBase(algorithmCameraBase); algorithmCameraBaseService.insertAlgorithmCameraBase(algorithmCameraBase);
//算法平台通知 String belong = algorithmCameraBase.getBelong();
JSONObject param = new JSONObject(); //查询该矿下所有信息
param.put("AllAlgorithmPtype",""); AlgorithmCameraBase algorithmCameraBaseReq = new AlgorithmCameraBase();
JSONArray cameraList = new JSONArray(); algorithmCameraBaseReq.setBelong(belong);
JSONObject camera = new JSONObject(); List<AlgorithmCameraBase> list = algorithmCameraBaseService.selectAlgorithmCameraBaseList(algorithmCameraBaseReq);
camera.put("inputDataPath",algorithmCameraBase.getRtsp()); Executors.newFixedThreadPool(1).execute(() ->{
camera.put("selectalgorithmPtype",algorithmCameraBase.getAlgorithmType()); //算法平台通知
camera.put("cameraName",algorithmCameraBase.getCameraNo()); JSONObject param = new JSONObject();
cameraList.add(camera); param.put("AllAlgorithmPtype","");
param.put("cameraList",cameraList); JSONArray cameraList = new JSONArray();
try{ if(!CollectionUtils.isEmpty(list)){
HttpUtil.createGet(aiCameraUrl).body(param.toJSONString()); list.forEach(base ->{
}catch (Exception e){ if(!StringUtils.isEmpty(base.getRtsp())){
e.printStackTrace(); JSONObject camera = new JSONObject();
} camera.put("inputDataPath",base.getRtsp());
camera.put("selectalgorithmPtype",base.getAlgorithmType());
camera.put("cameraName",base.getCameraNo());
cameraList.add(camera);
}
});
}
JSONObject camera = new JSONObject();
camera.put("inputDataPath",algorithmCameraBase.getRtsp());
camera.put("selectalgorithmPtype",algorithmCameraBase.getAlgorithmType());
camera.put("cameraName",algorithmCameraBase.getCameraNo());
cameraList.add(camera);
param.put("cameraList",cameraList);
try{
String apiUrl = "";
if("乌海矿".equals(belong)){
apiUrl = aiCameraUrl.split(",")[1];
}
if("海南矿".equals(belong)){
apiUrl = aiCameraUrl.split(",")[0];
}
if(!StringUtils.isEmpty(apiUrl)){
log.info("发起通信");
String result = HttpUtil.post(apiUrl,param.toJSONString());
log.info("通信完成"+result);
}
}catch (Exception e){
e.printStackTrace();
}
});
return AjaxResult.success(); return AjaxResult.success();
} }
...@@ -113,21 +152,53 @@ public class AlgorithmCameraBaseController extends BaseController ...@@ -113,21 +152,53 @@ public class AlgorithmCameraBaseController extends BaseController
public AjaxResult edit(@RequestBody AlgorithmCameraBase algorithmCameraBase) public AjaxResult edit(@RequestBody AlgorithmCameraBase algorithmCameraBase)
{ {
algorithmCameraBase.setUpdateBy(getUsername()); algorithmCameraBase.setUpdateBy(getUsername());
//算法平台通知 String belong = algorithmCameraBase.getBelong();
JSONObject param = new JSONObject(); //查询该矿下所有信息
param.put("AllAlgorithmPtype",""); AlgorithmCameraBase algorithmCameraBaseReq = new AlgorithmCameraBase();
JSONArray cameraList = new JSONArray(); algorithmCameraBaseReq.setBelong(belong);
JSONObject camera = new JSONObject(); List<AlgorithmCameraBase> list = algorithmCameraBaseService.selectAlgorithmCameraBaseList(algorithmCameraBaseReq);
camera.put("inputDataPath",algorithmCameraBase.getRtsp()); Executors.newFixedThreadPool(1).execute(() ->{
camera.put("selectalgorithmPtype",algorithmCameraBase.getAlgorithmType()); //算法平台通知
camera.put("cameraName",algorithmCameraBase.getCameraNo()); JSONObject param = new JSONObject();
cameraList.add(camera); param.put("AllAlgorithmPtype","");
param.put("cameraList",cameraList); JSONArray cameraList = new JSONArray();
try{ if(!CollectionUtils.isEmpty(list)){
HttpUtil.createGet(aiCameraUrl).body(param.toJSONString()); list.forEach(base ->{
}catch (Exception e){ if(algorithmCameraBase.getId().equals(base.getId())){
e.printStackTrace(); return;
} }
if(!StringUtils.isEmpty(base.getRtsp())){
JSONObject camera = new JSONObject();
camera.put("inputDataPath",base.getRtsp());
camera.put("selectalgorithmPtype",base.getAlgorithmType());
camera.put("cameraName",base.getCameraNo());
cameraList.add(camera);
}
});
}
JSONObject camera = new JSONObject();
camera.put("inputDataPath",algorithmCameraBase.getRtsp());
camera.put("selectalgorithmPtype",algorithmCameraBase.getAlgorithmType());
camera.put("cameraName",algorithmCameraBase.getCameraNo());
cameraList.add(camera);
param.put("cameraList",cameraList);
try{
String apiUrl = "";
if("乌海矿".equals(belong)){
apiUrl = aiCameraUrl.split(",")[1];
}
if("海南矿".equals(belong)){
apiUrl = aiCameraUrl.split(",")[0];
}
if(!StringUtils.isEmpty(apiUrl)){
log.info("发起通信");
String result = HttpUtil.post(apiUrl,param.toJSONString());
log.info("通信完成"+result);
}
}catch (Exception e){
e.printStackTrace();
}
});
return toAjax(algorithmCameraBaseService.updateAlgorithmCameraBase(algorithmCameraBase)); return toAjax(algorithmCameraBaseService.updateAlgorithmCameraBase(algorithmCameraBase));
} }
......
...@@ -152,8 +152,8 @@ airestapi: ...@@ -152,8 +152,8 @@ airestapi:
#Ai向摄像头发送地址 #Ai向摄像头发送地址
ai: ai:
camera: camera:
url: http://172.16.121.2:8000/conf # 海南:http://172.16.121.3:8001/conf 乌海:http://172.16.21.3:8001/conf
url: http://172.16.121.2:8000/conf,http://172.16.21.3:8001/conf
#大华ICC视频配置 #大华ICC视频配置
icc: icc:
sdk: sdk:
......
...@@ -47,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -47,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sort != null "> and sort = #{sort}</if> <if test="sort != null "> and sort = #{sort}</if>
<if test="status != null and status != ''"> and status = #{status}</if> <if test="status != null and status != ''"> and status = #{status}</if>
<if test="cameraNo != null and cameraNo != ''"> and camera_no = #{cameraNo}</if> <if test="cameraNo != null and cameraNo != ''"> and camera_no = #{cameraNo}</if>
<if test="belong != null and belong != ''"> and belong = #{belong}</if>
<if test="algorithmType != null and algorithmType != ''"> and algorithm_type = #{algorithmType}</if> <if test="algorithmType != null and algorithmType != ''"> and algorithm_type = #{algorithmType}</if>
</where> </where>
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment