Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
dinggang 2022-07-18 12:04:52 +08:00
commit 99ee0fa9a8
11 changed files with 310 additions and 153 deletions

View File

@ -11,6 +11,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -639,24 +640,22 @@ public class Controller {
list1 = Arrays.asList(labelCodes); list1 = Arrays.asList(labelCodes);
} }
//查询当前地区及下级地区的id,组成list,2022-07-14,ytl //查询当前地区及下级地区的id,组成list,2022-07-14,ytl
List<Map> orgenIds = monitorService.listChildOrgenIds(new ArrayList<Map>(), queryMap.get("parentId").toString()); List<Map> orgenIds = new ArrayList<>();
String path = "";
if(queryMap.get("parentId") != null && StringUtils.isNotBlank(queryMap.get("parentId").toString())){
//根据parentId获取地区表中的path
Map parentId = cameraOrgenMapper.selectOrgenizationById(queryMap.get("parentId").toString());
path = parentId.get("path").toString();
}
List<Map> list = cameraChannelMapper.selectByParentIdNew(queryMap, list1,path);
List<Map> list = cameraChannelMapper.selectByParentIdNew(queryMap, list1,orgenIds);
Result success = Result.success(list); Result success = Result.success(list);
success.setCount(cameraChannelMapper.selectByParentIdCountNew(queryMap, list1,orgenIds)); success.setCount(cameraChannelMapper.selectByParentIdCountNew(queryMap, list1,path));
return success; return success;
} }
//测试获取某个地区 及旗下的所有地区id
@GetMapping("listChildOrgenIds")
public Result listChildOrgenIds(String id){
List<Map> list = new ArrayList<>();
List<Map> maps = monitorService.listChildOrgenIds(list, id);
return Result.success(maps);
}
/** /**
* 摄像头按照市区进行聚合查询 * 摄像头按照市区进行聚合查询
@ -680,11 +679,13 @@ public class Controller {
cameraOrgenMapper.batchSaveOrgenization(list); cameraOrgenMapper.batchSaveOrgenization(list);
}); });
maps.forEach(map->{ //修改path 信息
monitorService.setOrganizationPath(map,map.get("parentId").toString()); List<Map> maps2 = cameraOrgenMapper.testAll();
maps2.forEach(map->{
monitorService.setOrganizationPath(map,map.get("parent_id").toString());
}); });
//修改path
maps.forEach(m->{ maps2.forEach(m->{
cameraOrgenMapper.updateOrganizationPaht(m.get("path").toString(),m.get("id").toString()); cameraOrgenMapper.updateOrganizationPaht(m.get("path").toString(),m.get("id").toString());
}); });
} }
@ -693,12 +694,13 @@ public class Controller {
} }
/** /**
* 保存通道信息 * 保存通道信息多线程版
* @return * @return
*/ */
@GetMapping("saveChannelInfo") @GetMapping("saveChannelInfoAsync")
public Result saveChannelInfo() throws Exception{ public Result saveChannelInfoAsync() throws Exception{
return monitorService.saveChannelInfo(); monitorService.saveChannelInfoAsync();
return Result.success("成功收到指令,请耐心等待");
} }
/******************************2022/07/13 ytl修改视频资源 end********************************************/ /******************************2022/07/13 ytl修改视频资源 end********************************************/

View File

@ -64,9 +64,9 @@ public interface CameraChannelMapper extends BaseDao<CameraChannel> {
Integer selectChannelCounts(@Param("path") String path); Integer selectChannelCounts(@Param("path") String path);
List<Map> selectByParentIdNew(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes,@Param("orgenIds") List<Map> orgenIds); List<Map> selectByParentIdNew(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes,@Param("path") String path);
Integer selectByParentIdCountNew(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes,@Param("orgenIds") List<Map> orgenIds); Integer selectByParentIdCountNew(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes,@Param("path") String path);
List<Map> selectChannelNumByRegion(); List<Map> selectChannelNumByRegion();
} }

View File

@ -20,12 +20,12 @@ public interface CameraOrgenizationMapper extends BaseDao<CameraOrganization> {
@Select("select * from t_camera_organization02 where parent_id = #{parentId}") @Select("select * from t_camera_organization02 where parent_id = #{parentId}")
List<Map> selectSubOrganizationMap(@Param("parentId") String parentId); List<Map> selectSubOrganizationMap(@Param("parentId") String parentId);
@Select("select name,parent_id,id from t_camera_organization02 where parent_id = #{parentId}") @Select("select name,parent_id,id from t_camera_organization02 where path LIKE CONCAT(#{path},'%') ")
List<Map> selectSubOrganizationMapByPid(@Param("parentId") String parentId); List<Map> selectSubOrganizationMapByPath(@Param("path") String path);
void batchSaveOrgenization(List<Map> list); void batchSaveOrgenization(List<Map> list);
@Select("SELECT name,parent_id,id FROM t_camera_organization02 WHERE id = #{id}") @Select("SELECT name,parent_id,id,path FROM t_camera_organization02 WHERE id = #{id}")
Map selectOrgenizationById(@Param("id") String id); Map selectOrgenizationById(@Param("id") String id);
@Update("UPDATE t_camera_organization02 SET path = TRIM( TRAILING '->' FROM #{path}) where id = #{id}") @Update("UPDATE t_camera_organization02 SET path = TRIM( TRAILING '->' FROM #{path}) where id = #{id}")
@ -41,4 +41,28 @@ public interface CameraOrgenizationMapper extends BaseDao<CameraOrganization> {
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_organization02")
List<Map> testAll();
@Update("truncate table ${tableName}")
void truncate(@Param("tableName") String tableName) ;
@Select("select orgaid,id,name,path from t_camera_organization02 order by orgaid")
List<Map> selectAllSubOrganizationMap();
@Update("UPDATE t_camera_organization02 SET channelCount = #{channelCount} where orgaid = #{orgaId}")
void editChannelCount(@Param("channelCount") Integer channelCount,@Param("orgaId") Integer orgaId);
@Update(" UPDATE t_region a inner join \n" +
" (SELECT COUNT(idt_camera_channel) AS channel_count,region_code FROM t_camera_channel01 GROUP BY region_code) b\n" +
" ON a.region_code = b.region_code set a.channel_count = b.channel_count")
void updateRegionChannelCount();
@Select(" SELECT id FROM t_camera_organization02 WHERE orgaid >(SELECT a.orgaid FROM t_camera_organization02 a INNER JOIN \n" +
"\t(\n" +
"\t\tSELECT parent_id FROM t_camera_channel01 ORDER BY idt_camera_channel desc LIMIT 1\n" +
"\t) b ON a.id = b.parent_id \n" +
") ORDER BY orgaid ASC ")
List<Map> listOrgenization2();
} }

View File

@ -15,6 +15,7 @@ import org.bytedeco.javacv.Java2DFrameConverter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Base64Utils; import org.springframework.util.Base64Utils;
@ -1244,16 +1245,117 @@ public class MonitorService {
} }
} }
public List<Map> listChildOrgenIds(List<Map> list,String id){ //2获取视频通道信息并保存,多线程版
Map orgenNow = cameraOrgenMapper.selectOrgenizationById(id); @Async
list.add(orgenNow); public void saveChannelInfoAsync() throws Exception {
List<Map> childs = cameraOrgenMapper.selectSubOrganizationMapByPid(id); //1-清空t_camera_channel01
if(childs.size() > 0){ cameraOrgenMapper.truncate("t_camera_channel01");
childs.forEach(child->{
listChildOrgenIds(list,child.get("id").toString()); //2-创建线程池
ExecutorService executorService = Executors.newFixedThreadPool(20);//20个线程足够
//3-查询全部地区
List<Map> maps = cameraOrgenMapper.testAll();
List<List<Map>> lists = Lists.partition(maps, 1000);
List<CompletableFuture> completableFutureLis = new ArrayList<>();
lists.forEach(l->{
completableFutureLis.add(
CompletableFuture.runAsync(()->{
l.forEach(m->{
boolean flag = true;
int tryCount = 0;//每个地区重试10次去获取该地区下视频通道信息
while(flag){
if(tryCount >= 9){
flag = false;
}
tryCount++;
//4-根据地区id去查询视频通道信息
List<Map> cameraChannels = new ArrayList<>();
try {
cameraChannels = getChannelInfo(m.get("id").toString());
}catch (Exception e){
log.info("根据地区id:{}查询视频通道失败,这是第{}次重试",m.get("id").toString(),tryCount);
continue;
}
//5-保存视频通道信息
batchSaveChannelInfos(cameraChannels,m.get("id").toString());
//6-更新地区表的count
cameraOrgenMapper.updateOrganizationCount(m.get("id").toString());
flag = false;
}
}); });
},executorService)
);
});
CompletableFuture.allOf(completableFutureLis.toArray(new CompletableFuture[completableFutureLis.size()])).join();
//6-更新完通道信息后查询地区下通道的数量并更新到地区表和市区表中
editChannelCount();
} }
return list;
//单独保存视频通道信息
public void batchSaveChannelInfos(List<Map> list,String parentId){
List<Map> needSave = new ArrayList<>();
if(list.size() > 0){
for(Map j:list){
if(Integer.parseInt(j.get("nodeType").toString()) ==3 && Integer.parseInt(j.get("channelType").toString()) ==1){
if(j.get("sn") == null){
continue;
}
String channelSn = j.get("sn").toString();
String channelOrngin = channelSn.substring(0,6);
String deptName = cameraOrgenMapper.getNameByidPart(channelOrngin);
j.put("regionName",deptName);
j.put("regionCode",channelOrngin);
j.put("parentId",parentId);
j.put("nodeName","");
needSave.add(j);
}
}
}else{//更新count字段
cameraOrgenMapper.updateOrganizationCount(parentId);
}
//修改nodeName
needSave.forEach(map->setNodeName(map,map.get("parentId").toString()));
//保存并更新count字段
if(needSave.size() > 0){
List<List<Map>> partition = Lists.partition(needSave, 100);
partition.forEach(l->{
cameraOrgenMapper.batchSaveCameraChannel(l);
});
cameraOrgenMapper.updateOrganizationCount(parentId);
}
}
//更新完通道信息后查询地区下通道的数量并更新到地区表中和市区表中
public void editChannelCount() throws Exception{
//1-更新地区表中的每个地区下channelCount
List<Map> maps = cameraOrgenMapper.selectAllSubOrganizationMap();
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 orgaid = Integer.parseInt(maps.get(i).get("orgaid").toString());
cameraOrgenMapper.editChannelCount(count,orgaid);
};
}
//2-更新市区表t_region表中的channelCount
cameraOrgenMapper.updateRegionChannelCount();
}
public List<Map> listChildOrgenIds(String id){
Map orgenNow = cameraOrgenMapper.selectOrgenizationById(id);
List<Map> childs = new ArrayList<>();
if(!orgenNow.isEmpty()){
String path = orgenNow.get("path").toString();
childs = cameraOrgenMapper.selectSubOrganizationMapByPath(id);
}
return childs;
} }
} }

View File

@ -46,7 +46,7 @@ public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService
@Override @Override
public String getHls(String key) { public String getHls(String key) {
List<String> result = new CopyOnWriteArrayList<>(); List<String> result = new CopyOnWriteArrayList<>();
String url = String.format(tsingtao_xhaProperties.getCloudhls(), key); String url = String.format(tsingtao_xhaProperties.getCloudhls(), key.replaceAll("\"", ""));
Request request = new Request.Builder().url(url).build(); Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) { try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
@ -58,7 +58,7 @@ public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService
logger.error("西海岸预览地址获取失败:{}", url); logger.error("西海岸预览地址获取失败:{}", url);
} }
} catch (Exception exception) { } catch (Exception exception) {
logger.error("西海岸预览地址获取失败:", url, exception); logger.error("西海岸预览地址获取失败:{}", url, exception);
} }
return result.stream().filter(StringUtils::isNotEmpty).findAny().orElse(null); return result.stream().filter(StringUtils::isNotEmpty).findAny().orElse(null);
} }

View File

@ -7,7 +7,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false url: jdbc:mysql://127.0.0.1:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
username: root username: root
password: 123456 password: root
# driver-class-name: com.mysql.cj.jdbc.Driver # driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://15.2.21.238:3310/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false # url: jdbc:mysql://15.2.21.238:3310/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
# username: root # username: root
@ -40,12 +40,17 @@ spring:
wall: wall:
config: config:
multi-statement-allow: true multi-statement-allow: true
flyway:
enabled: true
validate-on-migrate: false
# 允许乱序执行
out-of-order: true
#上传的静态资源配置 #上传的静态资源配置
resource: resource:
root_url: 15.2.21.238 root_url: 15.2.21.238
path: /home/yth/files/ path: /home/yth/files/
devModelFilePath: /home/yth/files/devModelFile devModelFilePath: /home/yth/files/devModelFile
pic-host: 127.0.0.1
# 大数据部门相关配置 # 大数据部门相关配置
big_date: big_date:
name: 青岛市大数据发展管理局 name: 青岛市大数据发展管理局

File diff suppressed because one or more lines are too long

View File

@ -141,10 +141,9 @@
JOIN t_label tl ON tl.label_code = tcml.label_code JOIN t_label tl ON tl.label_code = tcml.label_code
</if> </if>
WHERE 1 = 1 WHERE 1 = 1
AND tcc.parent_id IN <if test = "map.parentId != null and map.parentId != '' and path != null and path != ''">
<foreach collection="orgenIds" item="item" open="(" separator="," close=")"> AND tcc.node_name LIKE CONCAT(#{path},'%')
#{item.id} </if>
</foreach>
AND tcc.check_status IN (${map.checkStatus}) AND tcc.check_status IN (${map.checkStatus})
AND tcc.gps_x != '' AND tcc.gps_x != ''
@ -190,10 +189,10 @@
JOIN t_label tl ON tl.label_code = tcml.label_code JOIN t_label tl ON tl.label_code = tcml.label_code
</if> </if>
WHERE 1 = 1 WHERE 1 = 1
AND tcc.parent_id IN <if test = "map.parentId != null and map.parentId != '' and path != null and path != ''">
<foreach collection="orgenIds" item="item" open="(" separator="," close=")"> AND tcc.node_name LIKE CONCAT(#{path},'%')
#{item.id} </if>
</foreach>
AND tcc.check_status IN (${map.checkStatus}) AND tcc.check_status IN (${map.checkStatus})

View File

@ -4,11 +4,11 @@
<insert id="batchSaveOrgenization" parameterType="java.util.List"> <insert id="batchSaveOrgenization" parameterType="java.util.List">
INSERT INTO t_camera_organization02 ( INSERT INTO t_camera_organization02 (
id,name,parent_id,sort,subCount,path id,name,parent_id,sort,subCount,path,is_parent,is_root
) VALUES ) VALUES
<foreach collection="list" item="item" separator="," > <foreach collection="list" item="item" separator="," >
( (
#{item.id},#{item.name},#{item.parentId},#{item.sort},#{item.subCount},#{item.name} #{item.id},#{item.name},#{item.parentId},#{item.sort},#{item.subCount},#{item.name},#{item.isParent},#{item.root}
) )
</foreach> </foreach>
</insert> </insert>

View File

@ -286,8 +286,7 @@
IFNULL( trc.collectCount, 0 ) AS "collectCount", IFNULL( trc.collectCount, 0 ) AS "collectCount",
sd.NAME AS "deptName", sd.NAME AS "deptName",
IFNULL( trc2.isCollect, 'false' ) AS "isCollect", IFNULL( trc2.isCollect, 'false' ) AS "isCollect",
IF IF( IFNULL(taa2.approve_status, 0) &lt; 1, '未申请', '已申请' ) AS "applyState"
( taa2.approve_status &lt; 1, '未申请', '已申请' ) AS "applyState"
FROM FROM
tb_data_resource tdr tb_data_resource tdr
LEFT JOIN ( SELECT resource_id, AVG( score ) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 LEFT JOIN ( SELECT resource_id, AVG( score ) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0

View File

@ -12,7 +12,8 @@
<result property="creator" column="creator"/> <result property="creator" column="creator"/>
<result property="updateDate" column="update_date"/> <result property="updateDate" column="update_date"/>
<result property="updater" column="updater"/> <result property="updater" column="updater"/>
<result property="note1" column="note1" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/> <result property="note1" column="note1"
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
<result property="note2" column="note2"/> <result property="note2" column="note2"/>
<result property="note3" column="note3"/> <result property="note3" column="note3"/>
<result property="note4" column="note4"/> <result property="note4" column="note4"/>
@ -100,7 +101,8 @@
AND car.resource_id = res.id AND car.resource_id = res.id
AND res.id = tda.data_resource_id AND res.id = tda.data_resource_id
AND car.resource_id != 8888888880000000001 AND car.resource_id != 8888888880000000001
AND tda.attr_type = '组件类型' AND (tda.attr_type = '组件类型' OR tda.attr_type ='应用状态')
<!-- AND (res.type = '组件服务' OR res.type = '应用资源')-->
AND tda.del_flag = 0 AND tda.del_flag = 0
AND car.user_id = #{userId} AND car.user_id = #{userId}
AND res.dept_id = #{deptId} AND res.dept_id = #{deptId}