Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-08-03 09:14:14 +08:00
commit e803835bbf
7 changed files with 44 additions and 59 deletions

View File

@ -631,26 +631,6 @@ public class Controller {
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();
}
/**
* 事件版的保存区域组织信息

View File

@ -4,6 +4,7 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.context.ApplicationEvent;
/**
* 保存视频资源组织表cache成功事件
* @author ytl
* @Date 2022/7/27 15:13
**/

View File

@ -64,7 +64,7 @@ public interface CameraChannelMapper extends BaseDao<CameraChannel> {
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);
@ -81,7 +81,7 @@ public interface CameraChannelMapper extends BaseDao<CameraChannel> {
List<Map> selectCameraChannelByPid(@Param("parentId") String parentId);
void batchSaveCameraChannel(@Param("list") List<Map> list);
void batchSaveCameraChannelCache(@Param("list") List<Map> list);
void insertChannelCacheToCameraChannel();

View File

@ -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},'%') ")
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}")
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}")
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")
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}")
// void updateOrganizationCount(@Param("id") String id);
void batchSaveCameraChannel(List<Map> list);
//void batchSaveCameraChannel(List<Map> list);
@Select("select * from t_camera_organization")
List<Map> testAll();
List<Map> selectAll();
List<Map> selectAllFromOrgenizationCache();
@Update("truncate table ${tableName}")
void truncate(@Param("tableName") String tableName) ;
@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}")
void editChannelCount(@Param("channelCount") Integer channelCount,@Param("orgaId") Integer orgaId);
void editChannelCacheCount(@Param("channelCount") Integer channelCount,@Param("orgaId") Integer orgaId);
void updateRegionChannelCount();

View File

@ -1140,7 +1140,9 @@ public class MonitorService {
return Result.success(maps);
}
//以此作为获取视频资源的开始获取地区和组织信息
/** ---------------------------------- 获取视频组织和通道资源相关代码 start ------------------------------------------------------------**/
//以此作为获取视频资源的开始获取地区和组织信息,成功后发布事件
public void getAndSaveOrgenization(){
List<JSONObject> orgenizationByPage = this.getOrgenization(new ArrayList<JSONObject>(10000));
if(orgenizationByPage != null && orgenizationByPage.size() > 0){
@ -1149,17 +1151,17 @@ public class MonitorService {
if(maps.size() > 0){
List<List<Map>> lists = Lists.partition(maps,100);
lists.forEach(list->{
cameraOrgenMapper.batchSaveOrgenization(list);
cameraOrgenMapper.batchSaveOrgenizationCache(list);
});
//修改path 信息
List<Map> maps2 = cameraOrgenMapper.selectAll();
List<Map> maps2 = cameraOrgenMapper.selectAllFromOrgenizationCache();
maps2.forEach(map->{
this.setOrganizationPath(map,map.get("parent_id").toString());
});
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 {
RestTemplate restTemplate = this.getRestTemplate();
AtomicInteger faulseCount = new AtomicInteger();//失败的次数
//1-清空t_camera_channel
//1-清空t_camera_channel_cache
cameraOrgenMapper.truncate("t_camera_channel_cache");
Thread.sleep(1500);
//2-查询全部地区
//List<Map> maps = cameraOrgenMapper.testAll();
List<Map> maps = cameraOrgenMapper.selectAll();
List<Map> maps = cameraOrgenMapper.selectAllFromOrgenizationCache();
if (maps != null && maps.size() > 0){
List<List<Map>> lists = Lists.partition(maps, 1000);
//3-创建线程池
@ -1344,7 +1345,7 @@ public class MonitorService {
if(cameraChannels.size() > 0){
List<List<Map>> channelList = Lists.partition(cameraChannels,100);
for(List<Map> ll:channelList){
cameraChannelMapper.batchSaveCameraChannel(ll);
cameraChannelMapper.batchSaveCameraChannelCache(ll);
}
} else {
log.error("根据组织id:{},从正式表中查询视频通道失败,不存在该部门数据",m.get("id").toString());
@ -1432,7 +1433,8 @@ public class MonitorService {
if(needSave.size() > 0){
List<List<Map>> partition = Lists.partition(needSave, 100);
partition.forEach(l->{
cameraOrgenMapper.batchSaveCameraChannel(l);
cameraChannelMapper.batchSaveCameraChannelCache(l);
//cameraOrgenMapper.batchSaveCameraChannelCache(l);
});
}
}
@ -1440,13 +1442,13 @@ public class MonitorService {
//更新完通道信息后查询组织下通道的数量并更新到组织表中
public void editChannelCount() throws Exception{
//更新地区表中的每个地区下channelCount
List<Map> maps = cameraOrgenMapper.selectAllSubOrganizationMap();
List<Map> maps = cameraOrgenMapper.selectAllSubOrganizationCacheMap();
if(maps.size() > 0){
for(int i=0;i< maps.size();i++){
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());
cameraOrgenMapper.editChannelCount(count,orgaid);
cameraOrgenMapper.editChannelCacheCount(count,orgaid);
};
}
}
@ -1502,6 +1504,8 @@ public class MonitorService {
return restTemplate;
}
/** ---------------------------------- 获取视频组织和通道资源相关代码 end ------------------------------------------------------------**/
//测试用的
public List<Map> listChildOrgenIds(String id){
Map orgenNow = cameraOrgenMapper.selectOrgenizationById(id);

View File

@ -116,7 +116,7 @@
</if> ) temp
</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
WHERE b.path like concat(#{path},'%')
</select>
@ -251,7 +251,7 @@
WHERE parent_id = #{parentId}
</select>
<insert id="batchSaveCameraChannel" parameterType="java.util.List">
<insert id="batchSaveCameraChannelCache" parameterType="java.util.List">
INSERT INTO t_camera_channel_cache
(
channel_code,channel_id,channel_name,gps_x,gps_y,status,

View File

@ -1,7 +1,7 @@
<?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">
<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 (
id,name,parent_id,sort,subCount,path,is_parent,is_root
@ -14,21 +14,21 @@
</insert>
<insert id="batchSaveCameraChannel" parameterType="java.util.List">
INSERT INTO t_camera_channel_cache
(
channel_code,channel_id,channel_name,gps_x,gps_y,status,
parent_id,region_code,region_name,node_name
)
VALUES
<foreach collection="list" item="item" separator="," >
(
#{item.channelCode},#{item.channelId},#{item.channelName},#{item.gpsX},#{item.gpsY},#{item.status},
#{item.parentId},#{item.regionCode},#{item.regionName},TRIM(TRAILING '->' FROM #{item.nodeName})
<!-- <insert id="batchSaveCameraChannel" parameterType="java.util.List">-->
<!-- INSERT INTO t_camera_channel_cache-->
<!-- (-->
<!-- channel_code,channel_id,channel_name,gps_x,gps_y,status,-->
<!-- parent_id,region_code,region_name,node_name-->
<!-- )-->
<!-- VALUES-->
<!-- <foreach collection="list" item="item" separator="," >-->
<!-- (-->
<!-- #{item.channelCode},#{item.channelId},#{item.channelName},#{item.gpsX},#{item.gpsY},#{item.status},-->
<!-- #{item.parentId},#{item.regionCode},#{item.regionName},TRIM(TRAILING '->' FROM #{item.nodeName})-->
)
</foreach>
</insert>
<!-- )-->
<!-- </foreach>-->
<!-- </insert>-->
<update id="updateRegionChannelCount">
UPDATE t_region a
@ -50,11 +50,11 @@
<!-- ON a.id = b.parent_id-->
<!-- ) ORDER BY orgaid ASC-->
<!-- </select>-->
<select id="selectAll" resultType="java.util.Map">
<select id="selectAllFromOrgenizationCache" resultType="java.util.Map">
select * from t_camera_organization_cache
</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>