Commit 4db1c305 authored by baoxiaode's avatar baoxiaode

ai数据传输

parent f84476aa
package com.ruoyi.algorithm.controller;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.lang.hash.Hash;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
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.security.access.prepost.PreAuthorize;
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.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
......@@ -33,6 +42,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* @author ruoyi
* @date 2023-04-26
*/
@Slf4j
@RestController
@RequestMapping("/system/algorithm/camera/base")
public class AlgorithmCameraBaseController extends BaseController
......@@ -86,21 +96,50 @@ public class AlgorithmCameraBaseController extends BaseController
{
algorithmCameraBase.setCreateBy(getUsername());
algorithmCameraBaseService.insertAlgorithmCameraBase(algorithmCameraBase);
//算法平台通知
JSONObject param = new JSONObject();
param.put("AllAlgorithmPtype","");
JSONArray cameraList = new JSONArray();
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{
HttpUtil.createGet(aiCameraUrl).body(param.toJSONString());
}catch (Exception e){
e.printStackTrace();
}
String belong = algorithmCameraBase.getBelong();
//查询该矿下所有信息
AlgorithmCameraBase algorithmCameraBaseReq = new AlgorithmCameraBase();
algorithmCameraBaseReq.setBelong(belong);
List<AlgorithmCameraBase> list = algorithmCameraBaseService.selectAlgorithmCameraBaseList(algorithmCameraBaseReq);
Executors.newFixedThreadPool(1).execute(() ->{
//算法平台通知
JSONObject param = new JSONObject();
param.put("AllAlgorithmPtype","");
JSONArray cameraList = new JSONArray();
if(!CollectionUtils.isEmpty(list)){
list.forEach(base ->{
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 AjaxResult.success();
}
......@@ -113,21 +152,53 @@ public class AlgorithmCameraBaseController extends BaseController
public AjaxResult edit(@RequestBody AlgorithmCameraBase algorithmCameraBase)
{
algorithmCameraBase.setUpdateBy(getUsername());
//算法平台通知
JSONObject param = new JSONObject();
param.put("AllAlgorithmPtype","");
JSONArray cameraList = new JSONArray();
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{
HttpUtil.createGet(aiCameraUrl).body(param.toJSONString());
}catch (Exception e){
e.printStackTrace();
}
String belong = algorithmCameraBase.getBelong();
//查询该矿下所有信息
AlgorithmCameraBase algorithmCameraBaseReq = new AlgorithmCameraBase();
algorithmCameraBaseReq.setBelong(belong);
List<AlgorithmCameraBase> list = algorithmCameraBaseService.selectAlgorithmCameraBaseList(algorithmCameraBaseReq);
Executors.newFixedThreadPool(1).execute(() ->{
//算法平台通知
JSONObject param = new JSONObject();
param.put("AllAlgorithmPtype","");
JSONArray cameraList = new JSONArray();
if(!CollectionUtils.isEmpty(list)){
list.forEach(base ->{
if(algorithmCameraBase.getId().equals(base.getId())){
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));
}
......
......@@ -152,8 +152,8 @@ airestapi:
#Ai向摄像头发送地址
ai:
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:
sdk:
......
......@@ -47,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sort != null "> and sort = #{sort}</if>
<if test="status != null and status != ''"> and status = #{status}</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>
</where>
</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