package com.genersoft.iot.vmp.policeBodyCamera.mapper;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.policeBodyCamera.entity.DeviceChannelPoliceCamera;
import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 用于存储设备通道信息
* @author zhongrj
* @date 2023-03-04
*/
@Mapper
@Repository
public interface DeviceChannelPoliceCameraMapper {
/**
* 新增执法记录仪信息
* @param channel
* @return
*/
@Insert("INSERT INTO device_channel_police_camera (channelId, deviceId, name, manufacture, model, owner, civilCode, block, " +
"address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
"ipAddress, port, password, PTZType, status, streamId, longitude, latitude, createTime, updateTime) " +
"VALUES ('${channelId}', '${deviceId}', '${name}', '${manufacture}', '${model}', '${owner}', '${civilCode}', '${block}'," +
"'${address}', ${parental}, '${parentId}', ${safetyWay}, ${registerWay}, '${certNum}', ${certifiable}, ${errCode}, '${secrecy}', " +
"'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status}, '${streamId}', ${longitude}, ${latitude},'${createTime}', '${updateTime}')")
int add(DeviceChannel channel);
/**
* 更新执法记录仪信息
* @param channel
* @return
*/
@Update(value = {" "})
int update(DeviceChannel channel);
@Select(value = {" "})
List queryChannelsCar(String deviceId, String parentChannelId, String query, String type, Boolean hasSubChannel, Boolean online);
@Select(value = {" "})
List queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online);
/**
* 查询执法记录仪信息
* @param deviceId
* @param channelId
* @return
*/
@Select("SELECT * FROM device_channel_police_camera_police_camera WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
DeviceChannelPoliceCamera queryChannel(String deviceId, String channelId);
@Delete("DELETE FROM device_channel_police_camera WHERE deviceId=#{deviceId}")
int cleanChannelsByDeviceId(String deviceId);
/**
* 删除执法记录仪信息
* @param deviceId
* @param channelId
* @return
*/
@Delete("DELETE FROM device_channel_police_camera WHERE deviceId=#{deviceId} AND channelId=#{channelId}")
int del(String deviceId, String channelId);
@Update(value = {"UPDATE device_channel_police_camera SET streamId=null WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
void stopPlay(String deviceId, String channelId);
@Update(value = {"UPDATE device_channel_police_camera SET streamId=#{streamId} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
void startPlay(String deviceId, String channelId, String streamId);
@Select(value = {" "})
List queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, String catalogId);
@Select("SELECT * FROM device_channel_police_camera WHERE channelId=#{channelId}")
List queryChannelByChannelId(String channelId);
@Update(value = {"UPDATE device_channel_police_camera SET status=0 WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
void offline(String deviceId, String channelId);
@Update(value = {"UPDATE device_channel_police_camera SET status=1 WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
void online(String deviceId, String channelId);
@Insert("")
int batchAdd(List addChannels);
@Update({""})
int batchUpdate(List updateChannels);
@Select(value = {" "})
List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query,
Boolean hasSubChannel, Boolean online, int start, int limit);
@Select("SELECT * FROM device_channel_police_camera WHERE deviceId=#{deviceId} AND status=1")
List queryOnlineChannelsByDeviceId(String deviceId);
@Select(" SELECT\n" +
" id,\n" +
" channelId,\n" +
" deviceId,\n" +
" parentId,\n" +
" status,\n" +
" name as title,\n" +
" channelId as \"value\",\n" +
" channelId as \"key\",\n" +
" longitude,\n" +
" latitude\n" +
" from device_channel_police_camera\n" +
" where deviceId = #{deviceId}")
List tree(String deviceId);
@Delete(value = {" "})
int cleanChannelsNotInList(String deviceId, List channels);
/**
* 更新是否有子节点
* @param deviceId
* @param channelId
* @return
*/
@Update(" update device_channel_police_camera" +
" set subCount = (select *" +
" from (select count(0)" +
" from device_channel_police_camera" +
" where deviceId = #{deviceId} and parentId = #{channelId}) as temp)" +
" where deviceId = #{deviceId} " +
" and channelId = #{channelId}")
int updateChannelSubCount(String deviceId, String channelId);
/**
* 添加执法记录仪移动位置信息
* @param mobilePosition
* @return
*/
@Insert("INSERT INTO device_mobile_position_police_camera (deviceId,channelId, deviceName, time, longitude, latitude, altitude, speed, direction, reportSource) " +
"VALUES ('${deviceId}','${channelId}', '${deviceName}', '${time}', ${longitude}, ${latitude}, ${altitude}, ${speed}, ${direction}, '${reportSource}')")
int insertNewPositionPoliceCamera(MobilePosition mobilePosition);
}