Commit f84476aa authored by baoxiaode's avatar baoxiaode

算法摄像头新增通知算法端

parent b616ce08
......@@ -3,7 +3,11 @@ package com.ruoyi.algorithm.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.algorithm.domain.dto.AlgorithmCameraListDto;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -33,6 +37,10 @@ import com.ruoyi.common.core.page.TableDataInfo;
@RequestMapping("/system/algorithm/camera/base")
public class AlgorithmCameraBaseController extends BaseController
{
@Value("${ai.camera.url}")
private String aiCameraUrl;
@Autowired
private IAlgorithmCameraBaseService algorithmCameraBaseService;
......@@ -77,7 +85,23 @@ public class AlgorithmCameraBaseController extends BaseController
public AjaxResult add(@RequestBody AlgorithmCameraBase algorithmCameraBase)
{
algorithmCameraBase.setCreateBy(getUsername());
return toAjax(algorithmCameraBaseService.insertAlgorithmCameraBase(algorithmCameraBase));
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();
}
return AjaxResult.success();
}
/**
......@@ -89,6 +113,21 @@ 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();
}
return toAjax(algorithmCameraBaseService.updateAlgorithmCameraBase(algorithmCameraBase));
}
......
package com.ruoyi.algorithm.domain;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
......@@ -11,6 +12,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author ruoyi
* @date 2023-04-26
*/
@Data
public class AlgorithmCameraBase extends BaseEntity
{
private static final long serialVersionUID = 1L;
......@@ -22,6 +24,9 @@ public class AlgorithmCameraBase extends BaseEntity
@Excel(name = "摄像头名")
private String cameraName;
@Excel(name = "摄像头编号")
private String cameraNo;
/** 摄像头视频流地址 */
@Excel(name = "摄像头视频流地址")
private String rtsp;
......@@ -41,83 +46,6 @@ public class AlgorithmCameraBase extends BaseEntity
/** 删除标志(0代表存在 */
private String delFlag;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setCameraName(String cameraName)
{
this.cameraName = cameraName;
}
public String getCameraName()
{
return cameraName;
}
public void setRtsp(String rtsp)
{
this.rtsp = rtsp;
}
public String getRtsp()
{
return rtsp;
}
public void setSort(Long sort)
{
this.sort = sort;
}
public Long getSort()
{
return sort;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getDelFlag()
{
return delFlag;
}
public String getBelong() {
return belong;
}
public void setBelong(String belong) {
this.belong = belong;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("cameraName", getCameraName())
.append("rtsp", getRtsp())
.append("sort", getSort())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
@Excel(name = "摄像头支持的算法类型")
private String algorithmType;
}
......@@ -31,4 +31,8 @@ public class AlgorithmCameraListDto {
/** 状态 */
private String status;
private String algorithmType;
private String cameraNo;
}
......@@ -149,6 +149,10 @@ airestapi:
host: localhost
# 端口,默认为8081
port: 8081
#Ai向摄像头发送地址
ai:
camera:
url: http://172.16.121.2:8000/conf
#大华ICC视频配置
icc:
......
......@@ -17,10 +17,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="cameraNo" column="camera_no" />
<result property="algorithmType" column="algorithm_type" />
</resultMap>
<resultMap type="com.ruoyi.algorithm.domain.dto.AlgorithmCameraListDto" id="AlgorithmCameraListDtoResult">
<result property="id" column="id" />
<result property="cameraNo" column="camera_no" />
<result property="cameraName" column="camera_name" />
<result property="rtsp" column="rtsp" />
<result property="createBy" column="nick_name" />
......@@ -28,10 +31,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="sort" column="sort" />
<result property="status" column="status" />
<result property="belong" column="belong" />
<result property="algorithmType" column="algorithm_type" />
</resultMap>
<sql id="selectAlgorithmCameraBaseVo">
select id, camera_name, rtsp, sort, belong,status, del_flag, create_by, create_time, update_by, update_time, remark from algorithm_camera_base
select id, camera_name, rtsp, sort, belong,status, del_flag, create_by,camera_no,algorithm_type,
create_time, update_by, update_time, remark from algorithm_camera_base
</sql>
<select id="selectAlgorithmCameraBaseList" parameterType="AlgorithmCameraBase" resultMap="AlgorithmCameraBaseResult">
......@@ -41,6 +46,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="rtsp != null and rtsp != ''"> and rtsp = #{rtsp}</if>
<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="algorithmType != null and algorithmType != ''"> and algorithm_type = #{algorithmType}</if>
</where>
</select>
......@@ -57,7 +64,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
acb.create_time,
acb.sort,
acb.belong,
acb.`status`
acb.`status`,
acb.camera_no,
acb.algorithm_type
FROM
algorithm_camera_base acb
LEFT JOIN sys_user su ON su.user_name = acb.create_by
......@@ -94,6 +103,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="cameraNo != null">camera_no,</if>
<if test="algorithmType != null">algorithm_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
......@@ -108,6 +119,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="cameraNo != null">#{cameraNo},</if>
<if test="algorithmType != null">#{algorithmType},</if>
</trim>
</insert>
......@@ -125,6 +138,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="algorithmType != null">algorithm_type = #{algorithmType},</if>
<if test="cameraNo != null">camera_no = #{cameraNo},</if>
</trim>
where id = #{id}
</update>
......
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