dac513da 张雷

设备及摄像头绑定功能接口

1 个父辈 49941451
......@@ -2,6 +2,7 @@
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
......
......@@ -4,12 +4,11 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.modules.twin.entity.FmTwinCamera;
import com.skua.modules.twin.entity.FmTwinEquip;
import com.skua.modules.twin.entity.FmTwinManage;
import com.skua.modules.twin.service.IFmTwinService;
import com.skua.modules.twin.vo.FmTwinLocationEntity;
import com.skua.modules.twin.vo.FmTwinQueryVO;
import com.skua.modules.twin.vo.FmTwinResultVO;
import com.skua.modules.twin.vo.FmTwinVO;
import com.skua.modules.twin.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -90,20 +89,54 @@ public class FmTwinController {
return result;
}
@AutoLog(value = "孪生体绑定视频")
@ApiOperation(value="孪生体绑定视频", notes="孪生体绑定视频")
@PostMapping(value = "/boundCamera")
public Result<FmTwinCamera> boundCamera(@RequestBody FmTwinCamera fmTwinCamera) {
Result<FmTwinCamera> result = new Result<FmTwinCamera>();
boolean ok = fmTwinService.boundCamera(fmTwinCamera);
if(ok) {
result.setResult(fmTwinCamera);
result.success("绑定成功!");
} else {
result.error500("绑定失败");
}
return result;
}
@AutoLog(value = "获取孪生体绑定的摄像头信息")
@ApiOperation(value="获取孪生体绑定的摄像头信息", notes="获取孪生体绑定的摄像头信息")
@GetMapping(value = "/getCameraInfo")
public Result<?> getCameraInfo(String twinId) {
Result result = new Result();
public Result<FmTwinCameraResultVO> getCameraInfo(String twinId) {
Result<FmTwinCameraResultVO> result = new Result<FmTwinCameraResultVO>();
FmTwinCameraResultVO twinCameraResultVO = fmTwinService.getCameraInfoByTwinId(twinId);
result.setResult(twinCameraResultVO);
result.success("获取成功!");
return result;
}
@AutoLog(value = "孪生体绑定设备")
@ApiOperation(value="孪生体绑定设备", notes="孪生体绑定设备")
@PostMapping(value = "/boundEquip")
public Result<FmTwinEquip> boundEquip(@RequestBody FmTwinEquip fmTwinEquip) {
Result<FmTwinEquip> result = new Result<FmTwinEquip>();
boolean ok = fmTwinService.boundEquip(fmTwinEquip);
if(ok) {
result.setResult(fmTwinEquip);
result.success("绑定成功!");
} else {
result.error500("绑定失败");
}
return result;
}
@AutoLog(value = "获取孪生体绑定的设备信息")
@ApiOperation(value="获取孪生体绑定的设备信息", notes="获取孪生体绑定的设备信息")
@GetMapping(value = "/getEquipInfo")
public Result<?> getEquipInfo(String twinId) {
Result result = new Result();
public Result<FmTwinEquipResultVO> getEquipInfo(String twinId) {
Result<FmTwinEquipResultVO> result = new Result<FmTwinEquipResultVO>();
FmTwinEquipResultVO twinEquipResultVO = fmTwinService.getEquipInfoByTwinId(twinId);
result.setResult(twinEquipResultVO);
result.success("获取成功!");
return result;
}
......
......@@ -2,6 +2,7 @@ package com.skua.modules.twin.mapper;
import java.util.List;
import com.skua.modules.twin.vo.FmTwinCameraSqlResult;
import org.apache.ibatis.annotations.Param;
import com.skua.modules.twin.entity.FmTwinCamera;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -11,4 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface FmTwinCameraMapper extends BaseMapper<FmTwinCamera> {
FmTwinCameraSqlResult getCameraInfoByTwinId(@Param("twinId") String twinId);
FmTwinCamera getOneCameraByTwinId(@Param("twinId") String twinId);
}
......
......@@ -2,6 +2,7 @@ package com.skua.modules.twin.mapper;
import java.util.List;
import com.skua.modules.twin.vo.FmTwinEquipSqlResult;
import org.apache.ibatis.annotations.Param;
import com.skua.modules.twin.entity.FmTwinEquip;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -11,4 +12,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface FmTwinEquipMapper extends BaseMapper<FmTwinEquip> {
FmTwinEquipSqlResult getEquipInfoByTwinId(@Param("twinId") String twinId);
FmTwinEquip getOneEquipByTwinId(@Param("twinId") String twinId);
}
......
......@@ -2,4 +2,27 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.skua.modules.twin.mapper.FmTwinCameraMapper">
<select id="getCameraInfoByTwinId" resultType="com.skua.modules.twin.vo.FmTwinCameraSqlResult">
SELECT
m.twin_id,
m.twin_name,
m.twin_type,
m.project_id,
c.camera_name,
c.camera_type,
c.camera_rtsp,
c.camera_index,
c.camera_ip_port
FROM
fm_twin_manage m
LEFT JOIN fm_twin_camera c ON m.twin_id = c.twin_id
WHERE
m.twin_id = #{twinId}
LIMIT 1
</select>
<select id="getOneCameraByTwinId" resultType="com.skua.modules.twin.entity.FmTwinCamera">
select * from fm_twin_camera where twin_id = #{twinId}
</select>
</mapper>
\ No newline at end of file
......
......@@ -2,4 +2,26 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.skua.modules.twin.mapper.FmTwinEquipMapper">
<select id="getEquipInfoByTwinId" resultType="com.skua.modules.twin.vo.FmTwinEquipSqlResult">
SELECT
m.twin_id,
m.twin_name,
m.twin_type,
m.project_id,
e.equip_name,
e.equip_id,
e.equip_type,
e.equip_voice
FROM
fm_twin_manage m
LEFT JOIN fm_twin_equip e ON m.twin_id = e.twin_id
WHERE
m.twin_id = #{twinId}
LIMIT 1
</select>
<select id="getOneEquipByTwinId" resultType="com.skua.modules.twin.entity.FmTwinEquip">
select * from fm_twin_equip where twin_id = #{twinId}
</select>
</mapper>
\ No newline at end of file
......
package com.skua.modules.twin.service;
import com.skua.modules.twin.entity.FmTwinCamera;
import com.skua.modules.twin.entity.FmTwinEquip;
import com.skua.modules.twin.entity.FmTwinManage;
import com.skua.modules.twin.vo.FmTwinLocationEntity;
import com.skua.modules.twin.vo.FmTwinQueryVO;
import com.skua.modules.twin.vo.FmTwinResultVO;
import com.skua.modules.twin.vo.FmTwinVO;
import com.skua.modules.twin.vo.*;
import java.util.List;
......@@ -20,4 +19,12 @@ public interface IFmTwinService {
boolean savePosition(String twinId, FmTwinLocationEntity fmTwinLocation);
boolean saveNameAndType(FmTwinManage fmTwinManage);
FmTwinCameraResultVO getCameraInfoByTwinId(String twinId);
FmTwinEquipResultVO getEquipInfoByTwinId(String twinId);
boolean boundCamera(FmTwinCamera fmTwinCamera);
boolean boundEquip(FmTwinEquip fmTwinEquip);
}
......
package com.skua.modules.twin.service.impl;
import com.skua.modules.twin.entity.FmTwinCamera;
import com.skua.modules.twin.entity.FmTwinEquip;
import com.skua.modules.twin.entity.FmTwinManage;
import com.skua.modules.twin.mapper.FmTwinCameraMapper;
import com.skua.modules.twin.mapper.FmTwinEquipMapper;
import com.skua.modules.twin.mapper.FmTwinLocationMapper;
import com.skua.modules.twin.mapper.FmTwinManageMapper;
import com.skua.modules.twin.service.IFmTwinService;
......@@ -22,6 +26,10 @@ public class FmTwinServiceImpl implements IFmTwinService {
private FmTwinManageMapper fmTwinManageMapper;
@Autowired
private FmTwinLocationMapper fmTwinLocationMapper;
@Autowired
private FmTwinCameraMapper fmTwinCameraMapper;
@Autowired
private FmTwinEquipMapper fmTwinEquipMapper;
@Override
public boolean updateAndSave(String projectId,List<FmTwinVO> list) {
......@@ -88,7 +96,6 @@ public class FmTwinServiceImpl implements IFmTwinService {
}else{
return false;
}
}
@Override
......@@ -103,4 +110,75 @@ public class FmTwinServiceImpl implements IFmTwinService {
return false;
}
}
@Override
public FmTwinCameraResultVO getCameraInfoByTwinId(String twinId) {
FmTwinCameraSqlResult twinCameraSqlResult = fmTwinCameraMapper.getCameraInfoByTwinId(twinId);
FmTwinCameraResultVO twinCameraResultVO = new FmTwinCameraResultVO();
CameraEntity twinCameraEntity = new CameraEntity();
twinCameraResultVO.setTwinId(twinCameraSqlResult.getTwinId());
twinCameraResultVO.setTwinName(twinCameraSqlResult.getTwinName());
twinCameraResultVO.setTwinType(twinCameraSqlResult.getTwinType());
twinCameraResultVO.setProjectId(twinCameraSqlResult.getProjectId());
twinCameraEntity.setCameraName(twinCameraSqlResult.getCameraName());
twinCameraEntity.setCameraType(twinCameraSqlResult.getCameraType());
twinCameraEntity.setCameraRtsp(twinCameraSqlResult.getCameraRtsp());
twinCameraEntity.setCameraIndex(twinCameraSqlResult.getCameraIndex());
twinCameraEntity.setCameraIpPort(twinCameraSqlResult.getCameraIpPort());
twinCameraResultVO.setTwinCamera(twinCameraEntity);
return twinCameraResultVO;
}
@Override
public FmTwinEquipResultVO getEquipInfoByTwinId(String twinId) {
FmTwinEquipSqlResult twinEquipSqlResult = fmTwinEquipMapper.getEquipInfoByTwinId(twinId);
FmTwinEquipResultVO twinEquipResultVO = new FmTwinEquipResultVO();
twinEquipResultVO.setTwinId(twinEquipSqlResult.getTwinId());
twinEquipResultVO.setTwinName(twinEquipSqlResult.getTwinName());
twinEquipResultVO.setTwinType(twinEquipSqlResult.getTwinType());
twinEquipResultVO.setProjectId(twinEquipSqlResult.getProjectId());
EquipEntity twinEquipEntity = new EquipEntity();
twinEquipEntity.setEquipId(twinEquipSqlResult.getEquipId());
twinEquipEntity.setEquipName(twinEquipSqlResult.getEquipName());
twinEquipEntity.setEquipType(twinEquipSqlResult.getEquipType());
twinEquipEntity.setEquipVoice(twinEquipSqlResult.getEquipVoice());
twinEquipResultVO.setTwinEquip(twinEquipEntity);
return twinEquipResultVO;
}
@Override
public boolean boundCamera(FmTwinCamera fmTwinCamera) {
int count = 0;
String twinId = fmTwinCamera.getTwinId();
FmTwinCamera fmTwinCameraEntity = fmTwinCameraMapper.getOneCameraByTwinId(twinId);
if(fmTwinCameraEntity!=null){
fmTwinCamera.setId(fmTwinCameraEntity.getId());
count = fmTwinCameraMapper.updateById(fmTwinCamera);
}else{
count = fmTwinCameraMapper.insert(fmTwinCamera);
}
if(count == 1){
return true;
}else{
return false;
}
}
@Override
public boolean boundEquip(FmTwinEquip fmTwinEquip) {
int count = 0;
String twinId = fmTwinEquip.getTwinId();
FmTwinEquip fmTwinEquipEntity = fmTwinEquipMapper.getOneEquipByTwinId(twinId);
if(fmTwinEquipEntity!=null){
fmTwinEquip.setId(fmTwinEquipEntity.getId());
count = fmTwinEquipMapper.updateById(fmTwinEquip);
}else{
count = fmTwinEquipMapper.insert(fmTwinEquip);
}
if(count == 1){
return true;
}else{
return false;
}
}
}
......
package com.skua.modules.twin.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 孪生体绑定视频
*/
@Data
public class CameraEntity {
/**摄像头名称*/
private String cameraName;
/**摄像头类型(rtsp/isc)*/
private String cameraType;
/**rtsp路径*/
private String cameraRtsp;
/**摄像头UUID*/
private String cameraIndex;
/**安防平台IP端口*/
private String cameraIpPort;
}
package com.skua.modules.twin.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 孪生体绑定设备
*/
@Data
public class EquipEntity {
/**设备ID*/
private String equipId;
/**设备名称*/
private String equipName;
/**设备类型*/
private String equipType;
/**设备音频*/
private String equipVoice;
}
package com.skua.modules.twin.vo;
import lombok.Data;
/**
* 孪生体返回结果
*/
@Data
public class FmTwinCameraResultVO {
/** 孪生体id */
private String twinId;
/** 孪生体别名 */
private String twinName;
/** 类型 */
private String twinType;
/** 所属项目 */
private String projectId;
/** 摄像头绑定信息 */
private CameraEntity twinCamera;
}
package com.skua.modules.twin.vo;
import lombok.Data;
/**
* 孪生体管理
*/
@Data
public class FmTwinCameraSqlResult {
/** 孪生体id */
private String twinId;
/** 孪生体别名 */
private String twinName;
/** 类型 */
private String twinType;
/** 所属项目 */
private String projectId;
/**摄像头名称*/
private String cameraName;
/**摄像头类型(rtsp/isc)*/
private String cameraType;
/**rtsp路径*/
private String cameraRtsp;
/**摄像头UUID*/
private String cameraIndex;
/**安防平台IP端口*/
private String cameraIpPort;
}
package com.skua.modules.twin.vo;
import lombok.Data;
/**
* 孪生体返回结果
*/
@Data
public class FmTwinEquipResultVO {
/** 孪生体id */
private String twinId;
/** 孪生体别名 */
private String twinName;
/** 类型 */
private String twinType;
/** 所属项目 */
private String projectId;
/** 位置信息 */
private EquipEntity twinEquip;
}
package com.skua.modules.twin.vo;
import lombok.Data;
/**
* 孪生体管理
*/
@Data
public class FmTwinEquipSqlResult {
/** 孪生体id */
private String twinId;
/** 孪生体别名 */
private String twinName;
/** 类型 */
private String twinType;
/** 所属项目 */
private String projectId;
/**设备ID*/
private String equipId;
/**设备名称*/
private String equipName;
/**设备类型*/
private String equipType;
/**设备音频*/
private String equipVoice;
}
package com.skua.modules.twin.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
......
......@@ -5,7 +5,9 @@
<configuration>
<setting name="validation-enabled" value="true" />
<setting name="provider-name" value="Hibernate" />
<datasource-mapping />
<datasource-mapping>
<factory-entry name="fm-system" />
</datasource-mapping>
<naming-strategy-map />
</configuration>
</facet>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!