This commit is contained in:
wangliwen 2022-07-15 10:12:52 +08:00
commit 6ba099605d
6 changed files with 90 additions and 24 deletions

View File

@ -638,14 +638,26 @@ public class Controller {
if (null != labelCodes && labelCodes.length > 0) {
list1 = Arrays.asList(labelCodes);
}
List<Map> list = cameraChannelMapper.selectByParentIdNew(queryMap, list1);
//查询当前地区及下级地区的id,组成list,2022-07-14,ytl
List<Map> orgenIds = monitorService.listChildOrgenIds(new ArrayList<Map>(), queryMap.get("parentId").toString());
List<Map> list = cameraChannelMapper.selectByParentIdNew(queryMap, list1,orgenIds);
Result success = Result.success(list);
success.setCount(cameraChannelMapper.selectByParentIdCountNew(queryMap, list1));
success.setCount(cameraChannelMapper.selectByParentIdCountNew(queryMap, list1,orgenIds));
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);
}
/**
* 摄像头按照市区进行聚合查询
*/

View File

@ -0,0 +1,36 @@
package io.renren.modules.monitor.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("t_camera_channel01")
public class CameraChannelNew {
@TableId
private Long idtCameraChannel;
private String channelCode;
private String channelId;
private String channelName;
private String gpsX;
private String gpsY;
private Integer status;//1在线0离线
private String nodeName;
private Integer checkStatus;//1正常0异常
private String parentId;
private String regionCode;
private String regionName;
}

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);
List<Map> selectByParentIdNew(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes,@Param("orgenIds") List<Map> orgenIds);
Integer selectByParentIdCountNew(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes);
Integer selectByParentIdCountNew(@Param("map") Map queryMap, @Param("labelCodes") List labelCodes,@Param("orgenIds") List<Map> orgenIds);
List<Map> selectChannelNumByRegion();
}

View File

@ -17,12 +17,15 @@ public interface CameraOrgenizationMapper extends BaseDao<CameraOrganization> {
@Select("select * from t_camera_organization where parent_id = #{parentId}")
List<CameraOrganization> selectSubOrganization(@Param("parentId") String parentId);
@Select("select * channelCount 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);
@Select("select name,parent_id,id from t_camera_organization02 where parent_id = #{parentId}")
List<Map> selectSubOrganizationMapByPid(@Param("parentId") String parentId);
void batchSaveOrgenization(List<Map> list);
@Select("SELECT name,parent_id FROM t_camera_organization02 WHERE id = #{id}")
@Select("SELECT name,parent_id,id 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}")

View File

@ -1243,6 +1243,18 @@ public class MonitorService {
setNodeName(map,map2.get("parent_id").toString());
}
}
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());
});
}
return list;
}
}

View File

@ -121,9 +121,12 @@
WHERE b.path like concat(#{path},'%')
</select>
<select id="selectByParentIdNew" resultType="java.util.Map">
SELECT
tcc.*
tcc.channel_code as channelCode,tcc.channel_id as channelId,tcc.channel_name as channelName,
tcc.check_status as checkStatus,tcc.gps_x as gpsX,tcc.gps_y as gpsY,tcc.idt_camera_channel as idtCameraChannel,
tcc.node_name as nodeName,tcc.parent_id as parentId,tcc.status as status
<if test = "(map.gpsX != null and map.gpsX != '') and (map.gpsY != null and map.gpsY != '')">
, 6371 * 1000 * acos(cos(radians( ${map.gpsY} ))
* cos(radians( tcc.gps_y ))
@ -138,9 +141,11 @@
JOIN t_label tl ON tl.label_code = tcml.label_code
</if>
WHERE 1 = 1
<if test = "map.parentId != null and map.parentId != ''">
AND tcc.parent_id = #{map.parentId}
</if>
AND tcc.parent_id IN
<foreach collection="orgenIds" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
AND tcc.check_status IN (${map.checkStatus})
AND tcc.gps_x != ''
AND tcc.gps_y != ''
@ -166,8 +171,9 @@
</if>
</select>
<select id="selectByParentIdNew" resultType="java.util.Map">
<select id="selectByParentIdCountNew" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM (
SELECT
tcc.*
<if test = "(map.gpsX != null and map.gpsX != '') and (map.gpsY != null and map.gpsY != '')">
@ -184,14 +190,13 @@
JOIN t_label tl ON tl.label_code = tcml.label_code
</if>
WHERE 1 = 1
<if test = "map.parentId != null and map.parentId != ''">
AND tcc.parent_id = #{map.parentId}
</if>
AND tcc.parent_id IN
<foreach collection="orgenIds" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
AND tcc.check_status IN (${map.checkStatus})
AND tcc.gps_x != ''
AND tcc.gps_y != ''
AND tcc.gps_x IS NOT NULL
AND tcc.gps_y IS NOT NULL
<if test = "map.cameraName != null and map.cameraName != ''">
AND tcc.channel_name LIKE CONCAT('%',#{map.cameraName},'%')
</if>
@ -206,13 +211,11 @@
distance &lt; ${map.radius}
ORDER BY
distance
</if>
<if test = "map.pageNum != null and map.pageSize != null">
LIMIT ${map.pageNum}, ${map.pageSize}
</if>
</if> ) temp
</select>
<select id="selectChannelNumByRegion" resultType="java.util.Map">
SELECT COUNT(idt_camera_channel) AS channelNum,region_code,region_name FROM t_camera_channel01 GROUP BY region_code,region_name
SELECT ROUND(COUNT(idt_camera_channel) /10000,1) AS channelCount,region_code,region_name FROM t_camera_channel01 WHERE region_name is not null GROUP BY region_code,region_name
</select>
</mapper>