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.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -639,24 +640,22 @@ public class Controller {
list1 = Arrays.asList(labelCodes);
}
//查询当前地区及下级地区的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,orgenIds);
List<Map> list = cameraChannelMapper.selectByParentIdNew(queryMap, list1,path);
Result success = Result.success(list);
success.setCount(cameraChannelMapper.selectByParentIdCountNew(queryMap, list1,orgenIds));
success.setCount(cameraChannelMapper.selectByParentIdCountNew(queryMap, list1,path));
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);
});
maps.forEach(map->{
monitorService.setOrganizationPath(map,map.get("parentId").toString());
//修改path 信息
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());
});
}
@ -693,12 +694,13 @@ public class Controller {
}
/**
* 保存通道信息
* 保存通道信息多线程版
* @return
*/
@GetMapping("saveChannelInfo")
public Result saveChannelInfo() throws Exception{
return monitorService.saveChannelInfo();
@GetMapping("saveChannelInfoAsync")
public Result saveChannelInfoAsync() throws Exception{
monitorService.saveChannelInfoAsync();
return Result.success("成功收到指令,请耐心等待");
}
/******************************2022/07/13 ytl修改视频资源 end********************************************/

View File

@ -64,9 +64,9 @@ public interface CameraChannelMapper extends BaseDao<CameraChannel> {
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();
}

View File

@ -20,12 +20,12 @@ public interface CameraOrgenizationMapper extends BaseDao<CameraOrganization> {
@Select("select * from t_camera_organization02 where parent_id = #{parentId}")
List<Map> selectSubOrganizationMap(@Param("parentId") String parentId);
@Select("select name,parent_id,id from t_camera_organization02 where parent_id = #{parentId}")
List<Map> selectSubOrganizationMapByPid(@Param("parentId") String parentId);
@Select("select name,parent_id,id from t_camera_organization02 where path LIKE CONCAT(#{path},'%') ")
List<Map> selectSubOrganizationMapByPath(@Param("path") String path);
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);
@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 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.Value;
import org.springframework.http.*;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.Base64Utils;
@ -1244,16 +1245,117 @@ public class MonitorService {
}
}
public List<Map> listChildOrgenIds(List<Map> list,String id){
Map orgenNow = cameraOrgenMapper.selectOrgenizationById(id);
list.add(orgenNow);
List<Map> childs = cameraOrgenMapper.selectSubOrganizationMapByPid(id);
if(childs.size() > 0){
childs.forEach(child->{
listChildOrgenIds(list,child.get("id").toString());
});
//2获取视频通道信息并保存,多线程版
@Async
public void saveChannelInfoAsync() throws Exception {
//1-清空t_camera_channel01
cameraOrgenMapper.truncate("t_camera_channel01");
//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();
}
//单独保存视频通道信息
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);
}
return list;
//修改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
public String getHls(String key) {
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();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
@ -58,7 +58,7 @@ public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService
logger.error("西海岸预览地址获取失败:{}", url);
}
} catch (Exception exception) {
logger.error("西海岸预览地址获取失败:", url, exception);
logger.error("西海岸预览地址获取失败:{}", url, exception);
}
return result.stream().filter(StringUtils::isNotEmpty).findAny().orElse(null);
}

View File

@ -7,45 +7,50 @@ spring:
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
username: root
password: 123456
password: root
# 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
# username: root
# password: Hisense2019
#Hisense2019
#上传的静态资源配置
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 10
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
validation-query: SELECT 1
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 10
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
#Oracle需要打开注释
validation-query: SELECT 1
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /druid/*
#login-username: admin
#login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
flyway:
enabled: true
url-pattern: /druid/*
#login-username: admin
#login-password: admin
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true
validate-on-migrate: false
# 允许乱序执行
out-of-order: true
#上传的静态资源配置
resource:
root_url: 15.2.21.238
path: /home/yth/files/
devModelFilePath: /home/yth/files/devModelFile
pic-host: 127.0.0.1
# 大数据部门相关配置
big_date:
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
</if>
WHERE 1 = 1
AND tcc.parent_id IN
<foreach collection="orgenIds" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
<if test = "map.parentId != null and map.parentId != '' and path != null and path != ''">
AND tcc.node_name LIKE CONCAT(#{path},'%')
</if>
AND tcc.check_status IN (${map.checkStatus})
AND tcc.gps_x != ''
@ -190,10 +189,10 @@
JOIN t_label tl ON tl.label_code = tcml.label_code
</if>
WHERE 1 = 1
AND tcc.parent_id IN
<foreach collection="orgenIds" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
<if test = "map.parentId != null and map.parentId != '' and path != null and path != ''">
AND tcc.node_name LIKE CONCAT(#{path},'%')
</if>
AND tcc.check_status IN (${map.checkStatus})

View File

@ -4,11 +4,11 @@
<insert id="batchSaveOrgenization" parameterType="java.util.List">
INSERT INTO t_camera_organization02 (
id,name,parent_id,sort,subCount,path
id,name,parent_id,sort,subCount,path,is_parent,is_root
) VALUES
<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>
</insert>

View File

@ -286,8 +286,7 @@
IFNULL( trc.collectCount, 0 ) AS "collectCount",
sd.NAME AS "deptName",
IFNULL( trc2.isCollect, 'false' ) AS "isCollect",
IF
( taa2.approve_status &lt; 1, '未申请', '已申请' ) AS "applyState"
IF( IFNULL(taa2.approve_status, 0) &lt; 1, '未申请', '已申请' ) AS "applyState"
FROM
tb_data_resource tdr
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="updateDate" column="update_date"/>
<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="note3" column="note3"/>
<result property="note4" column="note4"/>
@ -22,12 +23,12 @@
<update id="deleteByIds">
UPDATE tb_resource_car
SET del_flag = 1 ,
update_date = now()
update_date = now()
WHERE 1 = 1
AND id IN
<foreach collection="ids" item="item" open="(" close=")" separator=",">
AND id IN
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</foreach>
</update>
<update id="delete4Resource">
@ -42,38 +43,38 @@
</update>
<select id="selectPageWithResource" resultType="io.renren.modules.resourceCar.dto.ResourceCarDTO">
SELECT trc.*
FROM tb_resource_car trc
SELECT trc.*
FROM tb_resource_car trc
<if test="(params.type != null and params.type != '') or (params.name != null and params.name != '')">
LEFT JOIN tb_data_resource tdr ON trc.resource_id = tdr.id AND tdr.del_flag != 1
</if>
WHERE 1 = 1
AND trc.del_flag = 0
AND user_id = #{params.userId}
<if test="params.name != null and params.name != ''" >
WHERE 1 = 1
AND trc.del_flag = 0
AND user_id = #{params.userId}
<if test="params.name != null and params.name != ''">
AND tdr.name LIKE CONCAT('%',#{params.name},'%')
</if>
<if test="params.type != null and params.type != ''">
AND tdr.type = #{params.type}
</if>
ORDER BY trc.update_date DESC, trc.create_date DESC
LIMIT ${pageNum}, ${pageSize}
ORDER BY trc.update_date DESC, trc.create_date DESC
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="selectResourceCarGroupByDept" resultType="java.util.Map">
SELECT
res.dept_id AS "deptId",
dept.name AS "deptName",
COUNT(car.id) AS "count"
res.dept_id AS "deptId",
dept.name AS "deptName",
COUNT(car.id) AS "count"
FROM
tb_resource_car car,
tb_data_resource res,
sys_dept dept
tb_resource_car car,
tb_data_resource res,
sys_dept dept
WHERE car.user_id = #{userId}
AND car.resource_id = res.id
AND res.dept_id = dept.id
AND car.del_flag = 0
AND EXISTS (SELECT 1 FROM tb_data_resource WHERE tb_data_resource.id = car.resource_id)
AND car.resource_id = res.id
AND res.dept_id = dept.id
AND car.del_flag = 0
AND EXISTS (SELECT 1 FROM tb_data_resource WHERE tb_data_resource.id = car.resource_id)
<if test="name != null and name != ''">
AND res.name LIKE CONCAT('%',#{name},'%')
</if>
@ -83,74 +84,75 @@
<select id="selectResourceListByDept" resultType="java.util.Map">
SELECT
car.id AS "id",
res.id AS "resourceId",
res.NAME AS "resourceName",
res.description,
res.type,
res.del_flag AS "delFlag",
car.note1,
car.create_date AS "time",
tda.attr_value AS "componentType"
car.id AS "id",
res.id AS "resourceId",
res.NAME AS "resourceName",
res.description,
res.type,
res.del_flag AS "delFlag",
car.note1,
car.create_date AS "time",
tda.attr_value AS "componentType"
FROM
tb_resource_car car,
tb_data_resource res,
tb_data_attr tda
tb_resource_car car,
tb_data_resource res,
tb_data_attr tda
WHERE 1 = 1
AND car.resource_id = res.id
AND res.id = tda.data_resource_id
AND car.resource_id != 8888888880000000001
AND tda.attr_type = '组件类型'
AND tda.del_flag = 0
AND car.user_id = #{userId}
AND res.dept_id = #{deptId}
AND car.del_flag = 0
AND EXISTS (SELECT 1 FROM tb_data_resource WHERE tb_data_resource.id = car.resource_id)
AND car.resource_id = res.id
AND res.id = tda.data_resource_id
AND car.resource_id != 8888888880000000001
AND (tda.attr_type = '组件类型' OR tda.attr_type ='应用状态')
<!-- AND (res.type = '组件服务' OR res.type = '应用资源')-->
AND tda.del_flag = 0
AND car.user_id = #{userId}
AND res.dept_id = #{deptId}
AND car.del_flag = 0
AND EXISTS (SELECT 1 FROM tb_data_resource WHERE tb_data_resource.id = car.resource_id)
UNION (
SELECT
car.id AS "id",
res.id AS "resourceId",
'申请摄像头列表' AS "resourceName",
res.description,
res.type,
0 AS "delFlag",
car.note1,
car.create_date AS "time",
"" AS "componentType"
car.id AS "id",
res.id AS "resourceId",
'申请摄像头列表' AS "resourceName",
res.description,
res.type,
0 AS "delFlag",
car.note1,
car.create_date AS "time",
"" AS "componentType"
FROM
tb_resource_car car,
tb_data_resource res
tb_resource_car car,
tb_data_resource res
WHERE
1 = 1
AND car.resource_id = res.id
AND car.resource_id = 8888888880000000001
AND car.user_id = #{userId}
AND res.dept_id = #{deptId}
AND car.del_flag = 0)
1 = 1
AND car.resource_id = res.id
AND car.resource_id = 8888888880000000001
AND car.user_id = #{userId}
AND res.dept_id = #{deptId}
AND car.del_flag = 0)
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="selectProvideDeptCount" resultType="java.lang.Integer">
SELECT
COUNT(*)
COUNT(*)
FROM
(
SELECT
tdr.dept_id
FROM
tb_resource_car trc
LEFT JOIN tb_data_resource tdr ON trc.resource_id = tdr.id
WHERE
1 = 1
AND trc.user_id = #{userId}
AND trc.del_flag = 0
AND EXISTS (SELECT 1 FROM tb_data_resource WHERE tb_data_resource.id = trc.resource_id)
<if test="name != null and name != ''">
AND tdr.name LIKE CONCAT('%',#{name},'%')
</if>
GROUP BY
tdr.dept_id
) temp
(
SELECT
tdr.dept_id
FROM
tb_resource_car trc
LEFT JOIN tb_data_resource tdr ON trc.resource_id = tdr.id
WHERE
1 = 1
AND trc.user_id = #{userId}
AND trc.del_flag = 0
AND EXISTS (SELECT 1 FROM tb_data_resource WHERE tb_data_resource.id = trc.resource_id)
<if test="name != null and name != ''">
AND tdr.name LIKE CONCAT('%',#{name},'%')
</if>
GROUP BY
tdr.dept_id
) temp
</select>
</mapper>