1、修改获取基础设施-视频资源的相关sql操作的表为cache表
This commit is contained in:
parent
d0df922c62
commit
975d6654ce
|
@ -631,26 +631,6 @@ public class Controller {
|
||||||
return monitorService.selectChannelNumByRegion();
|
return monitorService.selectChannelNumByRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存区域信息
|
|
||||||
*/
|
|
||||||
@GetMapping("/saveOrgenization")
|
|
||||||
public Result saveOrgenization() {
|
|
||||||
List<JSONObject> orgenizationByPage = monitorService.getOrgenization(new ArrayList<>());
|
|
||||||
List<Map> maps = JSON.parseArray(JSON.toJSONString(orgenizationByPage), Map.class);
|
|
||||||
if(!maps.isEmpty()){
|
|
||||||
List<List<Map>> lists = Lists.partition(maps,100);
|
|
||||||
lists.forEach(list-> cameraOrgenMapper.batchSaveOrgenization(list));
|
|
||||||
|
|
||||||
//修改path 信息
|
|
||||||
List<Map> maps2 = cameraOrgenMapper.testAll();
|
|
||||||
maps2.forEach(map-> monitorService.setOrganizationPath(map,map.get("parent_id").toString()));
|
|
||||||
|
|
||||||
maps2.forEach(m-> cameraOrgenMapper.updateOrganizationPaht(m.get("path").toString(),m.get("id").toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 事件版的保存区域组织信息
|
* 事件版的保存区域组织信息
|
||||||
|
|
|
@ -4,6 +4,7 @@ import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.context.ApplicationEvent;
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 保存视频资源组织表cache成功事件
|
||||||
* @author ytl
|
* @author ytl
|
||||||
* @Date 2022/7/27 15:13
|
* @Date 2022/7/27 15:13
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -64,7 +64,7 @@ public interface CameraChannelMapper extends BaseDao<CameraChannel> {
|
||||||
|
|
||||||
Integer selectByParentIdCount(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes);
|
Integer selectByParentIdCount(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes);
|
||||||
|
|
||||||
Integer selectChannelCounts(@Param("path") String path);
|
Integer selectChannelCountsFromCache(@Param("path") String path);
|
||||||
|
|
||||||
List<Map> selectByParentIdNew(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes,@Param("path") String path);
|
List<Map> selectByParentIdNew(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes,@Param("path") String path);
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public interface CameraChannelMapper extends BaseDao<CameraChannel> {
|
||||||
|
|
||||||
List<Map> selectCameraChannelByPid(@Param("parentId") String parentId);
|
List<Map> selectCameraChannelByPid(@Param("parentId") String parentId);
|
||||||
|
|
||||||
void batchSaveCameraChannel(@Param("list") List<Map> list);
|
void batchSaveCameraChannelCache(@Param("list") List<Map> list);
|
||||||
|
|
||||||
void insertChannelCacheToCameraChannel();
|
void insertChannelCacheToCameraChannel();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public interface CameraOrgenizationMapper extends BaseDao<CameraOrganization> {
|
||||||
@Select("select name,parent_id,id from t_camera_organization where path LIKE CONCAT(#{path},'%') ")
|
@Select("select name,parent_id,id from t_camera_organization where path LIKE CONCAT(#{path},'%') ")
|
||||||
List<Map> selectSubOrganizationMapByPath(@Param("path") String path);
|
List<Map> selectSubOrganizationMapByPath(@Param("path") String path);
|
||||||
|
|
||||||
void batchSaveOrgenization(List<Map> list);
|
void batchSaveOrgenizationCache(List<Map> list);
|
||||||
|
|
||||||
@Select("SELECT name,parent_id,id,path FROM t_camera_organization WHERE id = #{id}")
|
@Select("SELECT name,parent_id,id,path FROM t_camera_organization WHERE id = #{id}")
|
||||||
Map selectOrgenizationById(@Param("id") String id);
|
Map selectOrgenizationById(@Param("id") String id);
|
||||||
|
@ -33,7 +33,7 @@ public interface CameraOrgenizationMapper extends BaseDao<CameraOrganization> {
|
||||||
@Update("UPDATE t_camera_organization SET path = TRIM( TRAILING '->' FROM #{path}) where id = #{id}")
|
@Update("UPDATE t_camera_organization SET path = TRIM( TRAILING '->' FROM #{path}) where id = #{id}")
|
||||||
void updateOrganizationPaht(@Param("path") String path,@Param("id") String id);
|
void updateOrganizationPaht(@Param("path") String path,@Param("id") String id);
|
||||||
|
|
||||||
void updateOrganizationPath(@Param("path") String path,@Param("id") String id);
|
void updateOrganizationCachePath(@Param("path") String path,@Param("id") String id);
|
||||||
|
|
||||||
@Select(" SELECT id FROM t_camera_organization")
|
@Select(" SELECT id FROM t_camera_organization")
|
||||||
List<Map> listOrgenization();
|
List<Map> listOrgenization();
|
||||||
|
@ -44,21 +44,21 @@ public interface CameraOrgenizationMapper extends BaseDao<CameraOrganization> {
|
||||||
// @Update("UPDATE t_camera_organization SET COUNT = COUNT + 1 WHERE id = #{id}")
|
// @Update("UPDATE t_camera_organization SET COUNT = COUNT + 1 WHERE id = #{id}")
|
||||||
// void updateOrganizationCount(@Param("id") String id);
|
// void updateOrganizationCount(@Param("id") String id);
|
||||||
|
|
||||||
void batchSaveCameraChannel(List<Map> list);
|
//void batchSaveCameraChannel(List<Map> list);
|
||||||
|
|
||||||
@Select("select * from t_camera_organization")
|
@Select("select * from t_camera_organization")
|
||||||
List<Map> testAll();
|
List<Map> testAll();
|
||||||
|
|
||||||
List<Map> selectAll();
|
List<Map> selectAllFromOrgenizationCache();
|
||||||
|
|
||||||
@Update("truncate table ${tableName}")
|
@Update("truncate table ${tableName}")
|
||||||
void truncate(@Param("tableName") String tableName) ;
|
void truncate(@Param("tableName") String tableName) ;
|
||||||
|
|
||||||
@Select("select orgaid,id,name,path from t_camera_organization_cache order by orgaid")
|
@Select("select orgaid,id,name,path from t_camera_organization_cache order by orgaid")
|
||||||
List<Map> selectAllSubOrganizationMap();
|
List<Map> selectAllSubOrganizationCacheMap();
|
||||||
|
|
||||||
@Update("UPDATE t_camera_organization_cache SET channelCount = #{channelCount} where orgaid = #{orgaId}")
|
@Update("UPDATE t_camera_organization_cache SET channelCount = #{channelCount} where orgaid = #{orgaId}")
|
||||||
void editChannelCount(@Param("channelCount") Integer channelCount,@Param("orgaId") Integer orgaId);
|
void editChannelCacheCount(@Param("channelCount") Integer channelCount,@Param("orgaId") Integer orgaId);
|
||||||
|
|
||||||
void updateRegionChannelCount();
|
void updateRegionChannelCount();
|
||||||
|
|
||||||
|
|
|
@ -1140,7 +1140,9 @@ public class MonitorService {
|
||||||
return Result.success(maps);
|
return Result.success(maps);
|
||||||
}
|
}
|
||||||
|
|
||||||
//以此作为获取视频资源的开始,获取地区和组织信息
|
/** ---------------------------------- 获取视频组织和通道资源相关代码 start ------------------------------------------------------------**/
|
||||||
|
|
||||||
|
//以此作为获取视频资源的开始,获取地区和组织信息,成功后发布事件
|
||||||
public void getAndSaveOrgenization(){
|
public void getAndSaveOrgenization(){
|
||||||
List<JSONObject> orgenizationByPage = this.getOrgenization(new ArrayList<JSONObject>(10000));
|
List<JSONObject> orgenizationByPage = this.getOrgenization(new ArrayList<JSONObject>(10000));
|
||||||
if(orgenizationByPage != null && orgenizationByPage.size() > 0){
|
if(orgenizationByPage != null && orgenizationByPage.size() > 0){
|
||||||
|
@ -1149,17 +1151,17 @@ public class MonitorService {
|
||||||
if(maps.size() > 0){
|
if(maps.size() > 0){
|
||||||
List<List<Map>> lists = Lists.partition(maps,100);
|
List<List<Map>> lists = Lists.partition(maps,100);
|
||||||
lists.forEach(list->{
|
lists.forEach(list->{
|
||||||
cameraOrgenMapper.batchSaveOrgenization(list);
|
cameraOrgenMapper.batchSaveOrgenizationCache(list);
|
||||||
});
|
});
|
||||||
|
|
||||||
//修改path 信息
|
//修改path 信息
|
||||||
List<Map> maps2 = cameraOrgenMapper.selectAll();
|
List<Map> maps2 = cameraOrgenMapper.selectAllFromOrgenizationCache();
|
||||||
maps2.forEach(map->{
|
maps2.forEach(map->{
|
||||||
this.setOrganizationPath(map,map.get("parent_id").toString());
|
this.setOrganizationPath(map,map.get("parent_id").toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
maps2.forEach(m->{
|
maps2.forEach(m->{
|
||||||
cameraOrgenMapper.updateOrganizationPath(m.get("path").toString(),m.get("id").toString());
|
cameraOrgenMapper.updateOrganizationCachePath(m.get("path").toString(),m.get("id").toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
//发布事件
|
//发布事件
|
||||||
|
@ -1305,12 +1307,11 @@ public class MonitorService {
|
||||||
public void saveChannelInfoAsync() throws Exception {
|
public void saveChannelInfoAsync() throws Exception {
|
||||||
RestTemplate restTemplate = this.getRestTemplate();
|
RestTemplate restTemplate = this.getRestTemplate();
|
||||||
AtomicInteger faulseCount = new AtomicInteger();//失败的次数
|
AtomicInteger faulseCount = new AtomicInteger();//失败的次数
|
||||||
//1-清空t_camera_channel
|
//1-清空t_camera_channel_cache
|
||||||
cameraOrgenMapper.truncate("t_camera_channel_cache");
|
cameraOrgenMapper.truncate("t_camera_channel_cache");
|
||||||
Thread.sleep(1500);
|
Thread.sleep(1500);
|
||||||
//2-查询全部地区
|
//2-查询全部地区
|
||||||
//List<Map> maps = cameraOrgenMapper.testAll();
|
List<Map> maps = cameraOrgenMapper.selectAllFromOrgenizationCache();
|
||||||
List<Map> maps = cameraOrgenMapper.selectAll();
|
|
||||||
if (maps != null && maps.size() > 0){
|
if (maps != null && maps.size() > 0){
|
||||||
List<List<Map>> lists = Lists.partition(maps, 1000);
|
List<List<Map>> lists = Lists.partition(maps, 1000);
|
||||||
//3-创建线程池
|
//3-创建线程池
|
||||||
|
@ -1344,7 +1345,7 @@ public class MonitorService {
|
||||||
if(cameraChannels.size() > 0){
|
if(cameraChannels.size() > 0){
|
||||||
List<List<Map>> channelList = Lists.partition(cameraChannels,100);
|
List<List<Map>> channelList = Lists.partition(cameraChannels,100);
|
||||||
for(List<Map> ll:channelList){
|
for(List<Map> ll:channelList){
|
||||||
cameraChannelMapper.batchSaveCameraChannel(ll);
|
cameraChannelMapper.batchSaveCameraChannelCache(ll);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error("根据组织id:{},从正式表中查询视频通道失败,不存在该部门数据",m.get("id").toString());
|
log.error("根据组织id:{},从正式表中查询视频通道失败,不存在该部门数据",m.get("id").toString());
|
||||||
|
@ -1432,7 +1433,8 @@ public class MonitorService {
|
||||||
if(needSave.size() > 0){
|
if(needSave.size() > 0){
|
||||||
List<List<Map>> partition = Lists.partition(needSave, 100);
|
List<List<Map>> partition = Lists.partition(needSave, 100);
|
||||||
partition.forEach(l->{
|
partition.forEach(l->{
|
||||||
cameraOrgenMapper.batchSaveCameraChannel(l);
|
cameraChannelMapper.batchSaveCameraChannelCache(l);
|
||||||
|
//cameraOrgenMapper.batchSaveCameraChannelCache(l);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1440,13 +1442,13 @@ public class MonitorService {
|
||||||
//更新完通道信息后,查询组织下通道的数量并更新到组织表中
|
//更新完通道信息后,查询组织下通道的数量并更新到组织表中
|
||||||
public void editChannelCount() throws Exception{
|
public void editChannelCount() throws Exception{
|
||||||
//更新地区表中的每个地区下channelCount
|
//更新地区表中的每个地区下channelCount
|
||||||
List<Map> maps = cameraOrgenMapper.selectAllSubOrganizationMap();
|
List<Map> maps = cameraOrgenMapper.selectAllSubOrganizationCacheMap();
|
||||||
if(maps.size() > 0){
|
if(maps.size() > 0){
|
||||||
for(int i=0;i< maps.size();i++){
|
for(int i=0;i< maps.size();i++){
|
||||||
String path = maps.get(i).get("path").toString();
|
String path = maps.get(i).get("path").toString();
|
||||||
Integer count = cameraChannelMapper.selectChannelCounts(path);
|
Integer count = cameraChannelMapper.selectChannelCountsFromCache(path);
|
||||||
Integer orgaid = Integer.parseInt(maps.get(i).get("orgaid").toString());
|
Integer orgaid = Integer.parseInt(maps.get(i).get("orgaid").toString());
|
||||||
cameraOrgenMapper.editChannelCount(count,orgaid);
|
cameraOrgenMapper.editChannelCacheCount(count,orgaid);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1502,6 +1504,8 @@ public class MonitorService {
|
||||||
return restTemplate;
|
return restTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** ---------------------------------- 获取视频组织和通道资源相关代码 end ------------------------------------------------------------**/
|
||||||
|
|
||||||
//测试用的
|
//测试用的
|
||||||
public List<Map> listChildOrgenIds(String id){
|
public List<Map> listChildOrgenIds(String id){
|
||||||
Map orgenNow = cameraOrgenMapper.selectOrgenizationById(id);
|
Map orgenNow = cameraOrgenMapper.selectOrgenizationById(id);
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
</if> ) temp
|
</if> ) temp
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectChannelCounts" parameterType="java.lang.String" resultType="integer">
|
<select id="selectChannelCountsFromCache" parameterType="java.lang.String" resultType="integer">
|
||||||
SELECT COUNT(a.idt_camera_channel) FROM t_camera_channel_cache a inner join t_camera_organization_cache b on a.parent_id = b.id
|
SELECT COUNT(a.idt_camera_channel) FROM t_camera_channel_cache a inner join t_camera_organization_cache b on a.parent_id = b.id
|
||||||
WHERE b.path like concat(#{path},'%')
|
WHERE b.path like concat(#{path},'%')
|
||||||
</select>
|
</select>
|
||||||
|
@ -251,7 +251,7 @@
|
||||||
WHERE parent_id = #{parentId}
|
WHERE parent_id = #{parentId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="batchSaveCameraChannel" parameterType="java.util.List">
|
<insert id="batchSaveCameraChannelCache" parameterType="java.util.List">
|
||||||
INSERT INTO t_camera_channel_cache
|
INSERT INTO t_camera_channel_cache
|
||||||
(
|
(
|
||||||
channel_code,channel_id,channel_name,gps_x,gps_y,status,
|
channel_code,channel_id,channel_name,gps_x,gps_y,status,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="io.renren.modules.monitor.mapper.CameraOrgenizationMapper">
|
<mapper namespace="io.renren.modules.monitor.mapper.CameraOrgenizationMapper">
|
||||||
<insert id="batchSaveOrgenization" parameterType="java.util.List">
|
<insert id="batchSaveOrgenizationCache" parameterType="java.util.List">
|
||||||
|
|
||||||
INSERT INTO t_camera_organization_cache (
|
INSERT INTO t_camera_organization_cache (
|
||||||
id,name,parent_id,sort,subCount,path,is_parent,is_root
|
id,name,parent_id,sort,subCount,path,is_parent,is_root
|
||||||
|
@ -14,21 +14,21 @@
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
<insert id="batchSaveCameraChannel" parameterType="java.util.List">
|
<!-- <insert id="batchSaveCameraChannel" parameterType="java.util.List">-->
|
||||||
INSERT INTO t_camera_channel_cache
|
<!-- INSERT INTO t_camera_channel_cache-->
|
||||||
(
|
<!-- (-->
|
||||||
channel_code,channel_id,channel_name,gps_x,gps_y,status,
|
<!-- channel_code,channel_id,channel_name,gps_x,gps_y,status,-->
|
||||||
parent_id,region_code,region_name,node_name
|
<!-- parent_id,region_code,region_name,node_name-->
|
||||||
)
|
<!-- )-->
|
||||||
VALUES
|
<!-- VALUES-->
|
||||||
<foreach collection="list" item="item" separator="," >
|
<!-- <foreach collection="list" item="item" separator="," >-->
|
||||||
(
|
<!-- (-->
|
||||||
#{item.channelCode},#{item.channelId},#{item.channelName},#{item.gpsX},#{item.gpsY},#{item.status},
|
<!-- #{item.channelCode},#{item.channelId},#{item.channelName},#{item.gpsX},#{item.gpsY},#{item.status},-->
|
||||||
#{item.parentId},#{item.regionCode},#{item.regionName},TRIM(TRAILING '->' FROM #{item.nodeName})
|
<!-- #{item.parentId},#{item.regionCode},#{item.regionName},TRIM(TRAILING '->' FROM #{item.nodeName})-->
|
||||||
|
|
||||||
)
|
<!-- )-->
|
||||||
</foreach>
|
<!-- </foreach>-->
|
||||||
</insert>
|
<!-- </insert>-->
|
||||||
|
|
||||||
<update id="updateRegionChannelCount">
|
<update id="updateRegionChannelCount">
|
||||||
UPDATE t_region a
|
UPDATE t_region a
|
||||||
|
@ -50,11 +50,11 @@
|
||||||
<!-- ON a.id = b.parent_id-->
|
<!-- ON a.id = b.parent_id-->
|
||||||
<!-- ) ORDER BY orgaid ASC-->
|
<!-- ) ORDER BY orgaid ASC-->
|
||||||
<!-- </select>-->
|
<!-- </select>-->
|
||||||
<select id="selectAll" resultType="java.util.Map">
|
<select id="selectAllFromOrgenizationCache" resultType="java.util.Map">
|
||||||
select * from t_camera_organization_cache
|
select * from t_camera_organization_cache
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateOrganizationPath" parameterType="java.lang.String">
|
<update id="updateOrganizationCachePath" parameterType="java.lang.String">
|
||||||
UPDATE t_camera_organization_cache SET path = TRIM( TRAILING '->' FROM #{path}) where id = #{id}
|
UPDATE t_camera_organization_cache SET path = TRIM( TRAILING '->' FROM #{path}) where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue