重点区域事件30天时间趋势

重点区域场景添加根据区域类型查询区域的最新时间的人数
优化重点区域场景事件接口
工地场景注释优化
This commit is contained in:
wuweida 2022-08-19 16:20:07 +08:00
parent e8e096719f
commit e3264d71c5
6 changed files with 206 additions and 46 deletions

View File

@ -412,11 +412,11 @@ public class BuildingController {
} }
/** /**
* 查询近30天视频感知事件时间趋势 * 查询近30天工地视频感知事件时间趋势
* @return * @return
*/ */
@GetMapping("selectMonthCurrentByEvent") @GetMapping("selectMonthCurrentByEvent")
@ApiOperation("查询近30天视频感知事件时间趋势") @ApiOperation("查询近30天工地视频感知事件时间趋势")
public Result selectMonthCurrentByEvent(){ public Result selectMonthCurrentByEvent(){
List<BuildingRecordsDtos> buildingRecordsDtos = buildingRecordsMapper.selectMonthCurrentByEvent(); List<BuildingRecordsDtos> buildingRecordsDtos = buildingRecordsMapper.selectMonthCurrentByEvent();
buildingRecordsDtos.forEach(buildingRecordsDto -> { buildingRecordsDtos.forEach(buildingRecordsDto -> {

View File

@ -1,7 +1,9 @@
package com.hisense.monitormanage.controller; package com.hisense.monitormanage.controller;
import com.hisense.monitormanage.dto.BuildingRecordsDtos;
import com.hisense.monitormanage.dto.EventDto; import com.hisense.monitormanage.dto.EventDto;
import com.hisense.monitormanage.dto.KeyAreaDto; import com.hisense.monitormanage.dto.KeyAreaDto;
import com.hisense.monitormanage.dto.KeyAreaDtos;
import com.hisense.monitormanage.entity.KeyArea; import com.hisense.monitormanage.entity.KeyArea;
import com.hisense.monitormanage.entity.KeyAreaLocation; import com.hisense.monitormanage.entity.KeyAreaLocation;
import com.hisense.monitormanage.entity.PassengerFlow; import com.hisense.monitormanage.entity.PassengerFlow;
@ -36,17 +38,37 @@ public class KeyAreaController {
@Autowired @Autowired
private EventMapper eventMapper; private EventMapper eventMapper;
/**
* 根据区域类型查询全部区域列表的最新时间的人数
* @param type1
* @param type2
* @param type3
* @return
*/
@GetMapping("selectKeyAreaList")
@ApiOperation("根据区域类型查询全部区域列表的最新时间的人数")
public Result selectKeyAreaList(String type1,String type2,String type3){
PassengerFlow maxId = passengerFlowMapper.getByMaxId();
String timeId = maxId.getTimeId();
List<KeyAreaDto> keyAreaDtos = keyAreaMapper.selectKeyAreaList(type1,type2,type3,timeId);
keyAreaDtos.forEach(keyAreaDto -> {
keyAreaDto.setTimeId(timeId);
});
Result success = Result.success(keyAreaDtos);
return success;
}
/** /**
* 根据区域类型查询区域的最新时间的人数 * 根据区域类型查询区域的最新时间的人数
* @param type * @param type
* @return * @return
*/ */
@GetMapping("selectKeyAreaList") @GetMapping("selectKeyArea")
@ApiOperation("根据区域类型查询区域的最新时间的人数") @ApiOperation("根据区域类型查询区域的最新时间的人数")
public Result selectKeyAreaList(String type){ public Result selectKeyArea(String type){
PassengerFlow maxId = passengerFlowMapper.getByMaxId(); PassengerFlow maxId = passengerFlowMapper.getByMaxId();
String timeId = maxId.getTimeId(); String timeId = maxId.getTimeId();
List<KeyAreaDto> keyAreaDtos = keyAreaMapper.selectKeyAreaList(type,timeId); List<KeyAreaDto> keyAreaDtos = keyAreaMapper.selectKeyArea(type,timeId);
keyAreaDtos.forEach(keyAreaDto -> { keyAreaDtos.forEach(keyAreaDto -> {
keyAreaDto.setTimeId(timeId); keyAreaDto.setTimeId(timeId);
}); });
@ -121,10 +143,10 @@ public class KeyAreaController {
* 重点区域场景查询当天事件 * 重点区域场景查询当天事件
* @return * @return
*/ */
@GetMapping("selectAreaByTime") @GetMapping("selectByDayAreaEvent")
@ApiOperation("重点区域场景查询当天事件") @ApiOperation("重点区域场景查询当天事件")
public Result selectAreaByTime(){ public Result selectByDayAreaEvent(){
List<EventDto> events = eventMapper.selectByTime(); List<EventDto> events = keyAreaMapper.selectByDayAreaEvent();
events.forEach(event -> { events.forEach(event -> {
if (event.getEventCnName().equals("街头伞篷") || event.getEventCnName().equals("水果和食品摊") if (event.getEventCnName().equals("街头伞篷") || event.getEventCnName().equals("水果和食品摊")
|| event.getEventCnName().equals("地摊")|| event.getEventCnName().equals("户外桌椅")){ || event.getEventCnName().equals("地摊")|| event.getEventCnName().equals("户外桌椅")){
@ -140,9 +162,10 @@ public class KeyAreaController {
event.setEventNewName(event.getEventCnName()); event.setEventNewName(event.getEventCnName());
} }
}); });
Map<String,Object> map = new HashMap<>();
Result success = Result.success(events); map.put("sum",events.size());
map.put("events",events);
Result success = Result.success(map);
return success; return success;
} }
@ -152,53 +175,31 @@ public class KeyAreaController {
* @param eventNewName * @param eventNewName
* @return * @return
*/ */
@GetMapping("selectAreaByName") @GetMapping("selectByNameAreaEvent")
@ApiOperation("重点区域场景根据事件名称查询事件") @ApiOperation("重点区域场景根据事件名称查询事件")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "eventNewName",value = "事件名称",required = true,dataType = "String"), @ApiImplicitParam(name = "eventNewName",value = "事件名称",required = true,dataType = "String"),
@ApiImplicitParam(name = "page", value = "页码", required = false, dataType = "Integer"), @ApiImplicitParam(name = "page", value = "页码", required = false, dataType = "Integer"),
@ApiImplicitParam(name = "pageSize", value = "页码大小", required = false, dataType = "Integer") @ApiImplicitParam(name = "pageSize", value = "页码大小", required = false, dataType = "Integer")
}) })
public Result selectAreaByName(String eventNewName,Integer page,Integer pageSize){ public Result selectByNameAreaEvent(String eventNewName,Integer page,Integer pageSize){
if (eventNewName.equals("环境卫生")){ if (eventNewName.equals("环境卫生")){
List<EventDto> lists = eventMapper.selectByName("'塑料篮子','纸箱','街头散落垃圾'",page,pageSize); List<EventDto> lists = keyAreaMapper.selectByNameAreaEvent("'塑料篮子','纸箱','街头散落垃圾'",page,pageSize);
lists.forEach(list ->{ lists.forEach(list ->{
list.setEventNewName("环境卫生"); list.setEventNewName("环境卫生");
}); });
Integer integer = eventMapper.selectCountByName("'塑料篮子','纸箱','街头散落垃圾'"); Integer integer = keyAreaMapper.selectCountByNameAreaEvent("'塑料篮子','纸箱','街头散落垃圾'");
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("sum",integer); map.put("sum",integer);
map.put("events",lists); map.put("events",lists);
Result success = Result.success(map); Result success = Result.success(map);
return success; return success;
}else if (eventNewName.equals("占道经营")){ }else if (eventNewName.equals("占道经营")){
List<EventDto> lists = eventMapper.selectByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'",page,pageSize); List<EventDto> lists = keyAreaMapper.selectByNameAreaEvent("'街头伞篷','水果和食品摊','地摊','户外桌椅'",page,pageSize);
lists.forEach(list ->{ lists.forEach(list ->{
list.setEventNewName("占道经营"); list.setEventNewName("占道经营");
}); });
Integer integer = eventMapper.selectCountByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'"); Integer integer = keyAreaMapper.selectCountByNameAreaEvent("'街头伞篷','水果和食品摊','地摊','户外桌椅'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("沿街晾晒")){
List<EventDto> lists = eventMapper.selectByName("'沿街晾晒衣物被单'",page,pageSize);
lists.forEach(list ->{
list.setEventNewName("沿街晾晒");
});
Integer integer = eventMapper.selectCountByName("'沿街晾晒衣物被单'");
Map<String,Object> map = new HashMap<>();
map.put("sum",integer);
map.put("events",lists);
Result success = Result.success(map);
return success;
}else if (eventNewName.equals("违章停车")){
List<EventDto> lists = eventMapper.selectByName("'机动车违停'",page,pageSize);
lists.forEach(list ->{
list.setEventNewName("违章停车");
});
Integer integer = eventMapper.selectCountByName("'机动车违停'");
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("sum",integer); map.put("sum",integer);
map.put("events",lists); map.put("events",lists);
@ -207,11 +208,11 @@ public class KeyAreaController {
}else { }else {
StringBuilder str = new StringBuilder(eventNewName); StringBuilder str = new StringBuilder(eventNewName);
String s = str.insert(0, "'").append("'").toString(); String s = str.insert(0, "'").append("'").toString();
List<EventDto> lists = eventMapper.selectByName(s, page, pageSize); List<EventDto> lists = keyAreaMapper.selectByNameAreaEvent(s, page, pageSize);
lists.forEach(list ->{ lists.forEach(list ->{
list.setEventNewName(list.getEventCnName()); list.setEventNewName(list.getEventCnName());
}); });
Integer integer = eventMapper.selectCountByName(s); Integer integer = keyAreaMapper.selectCountByNameAreaEvent(s);
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("sum",integer); map.put("sum",integer);
map.put("events",lists); map.put("events",lists);
@ -220,5 +221,22 @@ public class KeyAreaController {
} }
} }
/**
* 查询近30天重点区域视频感知事件时间趋势
* @return
*/
@GetMapping("selectMonthAreaEvent")
@ApiOperation("查询近30天重点区域视频感知事件时间趋势")
public Result selectMonthAreaEvent(){
List<KeyAreaDtos> keyAreaDtos = keyAreaMapper.selectMonthAreaEvent();
keyAreaDtos.forEach(keyAreaDtos1 -> {
if (keyAreaDtos1.getNumber() == null){
keyAreaDtos1.setNumber(0);
}
});
Result success = Result.success(keyAreaDtos);
return success;
}
} }

View File

@ -0,0 +1,11 @@
package com.hisense.monitormanage.dto;
import lombok.Data;
@Data
public class KeyAreaDtos {
private String pushTime;
private Integer number;
}

View File

@ -3,6 +3,7 @@ package com.hisense.monitormanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisense.monitormanage.dto.EventDto; import com.hisense.monitormanage.dto.EventDto;
import com.hisense.monitormanage.dto.KeyAreaDto; import com.hisense.monitormanage.dto.KeyAreaDto;
import com.hisense.monitormanage.dto.KeyAreaDtos;
import com.hisense.monitormanage.entity.KeyArea; import com.hisense.monitormanage.entity.KeyArea;
import com.hisense.monitormanage.entity.KeyAreaLocation; import com.hisense.monitormanage.entity.KeyAreaLocation;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -14,7 +15,9 @@ import java.util.List;
@Repository @Repository
public interface KeyAreaMapper extends BaseMapper<KeyArea> { public interface KeyAreaMapper extends BaseMapper<KeyArea> {
List<KeyAreaDto> selectKeyAreaList(@Param("type") String type,@Param("timeId") String timeId); List<KeyAreaDto> selectKeyAreaList(@Param("type1") String type1,@Param("type2") String type2,@Param("type3") String type3,@Param("timeId") String timeId);
List<KeyAreaDto> selectKeyArea(@Param("type") String type,@Param("timeId") String timeId);
@Select("SELECT * FROM t_key_area_location kal JOIN t_key_area ka ON kal.area_id = ka.area_id WHERE ka.area_name = #{areaName}") @Select("SELECT * FROM t_key_area_location kal JOIN t_key_area ka ON kal.area_id = ka.area_id WHERE ka.area_name = #{areaName}")
List<KeyAreaLocation> selectByAreaName(String areaName); List<KeyAreaLocation> selectByAreaName(String areaName);
@ -27,6 +30,16 @@ public interface KeyAreaMapper extends BaseMapper<KeyArea> {
@Select("SELECT COUNT(*) FROM t_event te JOIN t_scene_event tse ON te.camera_name = tse.channel_name WHERE te.track_event = 'START' AND tse.scene_id = 2") @Select("SELECT COUNT(*) FROM t_event te JOIN t_scene_event tse ON te.camera_name = tse.channel_name WHERE te.track_event = 'START' AND tse.scene_id = 2")
Integer selectCountAreaEvent(); Integer selectCountAreaEvent();
@Select("SELECT * FROM t_event te JOIN t_scene_event tse ON te.camera_name = tse.channel_name WHERE te.track_event = 'START' AND tse.scene_id = 2 AND TO_DAYS(te.capture_time) = TO_DAYS(NOW())")
List<EventDto> selectByDayAreaEvent();
List<EventDto> selectByNameAreaEvent(@Param("eventNewName") String eventNewName,@Param("page") Integer page,@Param("pageSize") Integer pageSize);
@Select("SELECT COUNT(*) FROM t_event te JOIN t_scene_event tse ON te.camera_name = tse.channel_name WHERE te.track_event = 'START' AND tse.scene_id = 2 AND event_cn_name IN (${eventNewName})")
Integer selectCountByNameAreaEvent(@Param("eventNewName")String eventNewName);
List<KeyAreaDtos> selectMonthAreaEvent();
} }

View File

@ -337,7 +337,7 @@ public class MonitorService{
/** /**
* 所有摄像头抓图 sql持续更新 * 所有摄像头抓图 sql持续更新
*/ */
@Scheduled(cron = "0 15 9 * * ?") @Scheduled(cron = "0 0 6 * * ?")
public void CameraScreenshot() { public void CameraScreenshot() {
try { try {
log.info("[monitor-capture]: start capture"); log.info("[monitor-capture]: start capture");

View File

@ -4,23 +4,141 @@
<select id="selectKeyAreaList" resultType="com.hisense.monitormanage.dto.KeyAreaDto"> <select id="selectKeyAreaList" resultType="com.hisense.monitormanage.dto.KeyAreaDto">
SELECT * FROM SELECT * FROM
(SELECT ka.type,ka.location,ka.service_time,ka.management,ka.scenic_level, (SELECT ka.type,ka.location,ka.service_time,ka.management,ka.scenic_level,
ka.about,ka.area_id,ss.area_name,ss.allNums,ss.localNums,ss.nonlocalNums ka.about,ka.area_id,ka.area_name,ss.allNums,ss.localNums,ss.nonlocalNums
FROM t_key_area ka LEFT JOIN FROM t_key_area ka LEFT JOIN
(SELECT pt.area_name,SUM(pf.all_nums) AS allNums,SUM(pf.local_nums) AS localNums, (SELECT pt.area_name,SUM(pf.all_nums) AS allNums,SUM(pf.local_nums) AS localNums,
SUM(pf.nonlocal_nums) AS nonlocalNums SUM(pf.nonlocal_nums) AS nonlocalNums
FROM t_passenger_flow pf JOIN t_passenger_test pt FROM t_passenger_flow pf JOIN t_passenger_test pt
ON pf.longitude = pt.longitude AND pf.latitude = pt.latitude ON pf.longitude = pt.longitude AND pf.latitude = pt.latitude
WHERE pf.time_id = #{timeId} AND pt.type IN (${type}) GROUP BY pt.area_name) WHERE pf.time_id = #{timeId} AND pt.type IN (${type1}) GROUP BY pt.area_name)
ss ON ka.area_name = ss.area_name WHERE ka.type IN (${type})) a ss ON ka.area_name = ss.area_name WHERE ka.type IN (${type1})) a
LEFT JOIN t_key_area_location kal ON kal.area_id = a.area_id LEFT JOIN t_key_area_location kal ON kal.area_id = a.area_id
UNION
SELECT * FROM
(SELECT ka.type,ka.location,ka.service_time,ka.management,ka.scenic_level,
ka.about,ka.area_id,ka.area_name,ss.allNums,ss.localNums,ss.nonlocalNums
FROM t_key_area ka LEFT JOIN
(SELECT pt.area_name,SUM(pf.all_nums) AS allNums,SUM(pf.local_nums) AS localNums,
SUM(pf.nonlocal_nums) AS nonlocalNums
FROM t_passenger_flow pf JOIN t_passenger_test pt
ON pf.longitude = pt.longitude AND pf.latitude = pt.latitude
WHERE pf.time_id = #{timeId} AND pt.type IN (${type2}) GROUP BY pt.area_name)
ss ON ka.area_name = ss.area_name WHERE ka.type IN (${type2})) a
LEFT JOIN t_key_area_location kal ON kal.area_id = a.area_id
UNION
SELECT * FROM
(SELECT ka.type,ka.location,ka.service_time,ka.management,ka.scenic_level,
ka.about,ka.area_id,ka.area_name,ss.allNums,ss.localNums,ss.nonlocalNums
FROM t_key_area ka LEFT JOIN
(SELECT pt.area_name,SUM(pf.all_nums) AS allNums,SUM(pf.local_nums) AS localNums,
SUM(pf.nonlocal_nums) AS nonlocalNums
FROM t_passenger_flow pf JOIN t_passenger_test pt
ON pf.longitude = pt.longitude AND pf.latitude = pt.latitude
WHERE pf.time_id = #{timeId} AND pt.type IN (${type3}) GROUP BY pt.area_name)
ss ON ka.area_name = ss.area_name WHERE ka.type IN (${type3})) a
LEFT JOIN t_key_area_location1 kal1 ON kal1.area_id = a.area_id
</select>
<select id="selectKeyArea" resultType="com.hisense.monitormanage.dto.KeyAreaDto">
SELECT * FROM
(SELECT ka.type,ka.location,ka.service_time,ka.management,ka.scenic_level,
ka.about,ka.area_id,ka.area_name,ss.allNums,ss.localNums,ss.nonlocalNums
FROM t_key_area ka LEFT JOIN
(SELECT pt.area_name,SUM(pf.all_nums) AS allNums,SUM(pf.local_nums) AS localNums,
SUM(pf.nonlocal_nums) AS nonlocalNums
FROM t_passenger_flow pf JOIN t_passenger_test pt
ON pf.longitude = pt.longitude AND pf.latitude = pt.latitude
WHERE pf.time_id = #{timeId} AND pt.type = #{type} GROUP BY pt.area_name)
ss ON ka.area_name = ss.area_name WHERE ka.type = #{type}) a
LEFT JOIN t_key_area_location kal ON kal.area_id = a.area_id
</select> </select>
<select id="selectByAreaEvent" resultType="com.hisense.monitormanage.dto.EventDto"> <select id="selectByAreaEvent" resultType="com.hisense.monitormanage.dto.EventDto">
SELECT * FROM t_event te SELECT * FROM t_event te
JOIN t_scene_event tse ON te.camera_name = tse.channel_name JOIN t_scene_event tse ON te.camera_name = tse.channel_name
WHERE te.track_event = 'START' AND tse.scene_id = 2 WHERE te.track_event = 'START' AND tse.scene_id = 2
ORDER BY te.capture_time DESC
<if test="page!=null and '' != page and pageSize != null and '' != pageSize"> <if test="page!=null and '' != page and pageSize != null and '' != pageSize">
<bind name="page" value="(page-1)*pageSize"/> <bind name="page" value="(page-1)*pageSize"/>
limit #{page},#{pageSize} limit #{page},#{pageSize}
</if> </if>
</select> </select>
<select id="selectByNameAreaEvent" resultType="com.hisense.monitormanage.dto.EventDto">
SELECT * FROM t_event te
JOIN t_scene_event tse ON te.camera_name = tse.channel_name
WHERE te.track_event = 'START' AND tse.scene_id = 2 AND event_cn_name IN (${eventNewName})
ORDER BY te.capture_time DESC
<if test="page!=null and '' != page and pageSize != null and '' != pageSize">
<bind name="page" value="(page-1)*pageSize"/>
limit #{page},#{pageSize}
</if>
</select>
<select id="selectMonthAreaEvent" resultType="com.hisense.monitormanage.dto.KeyAreaDtos">
SELECT b.pushTime,a.number FROM (
SELECT date_sub(curdate(), INTERVAL 1 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 2 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 3 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 4 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 5 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 6 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 7 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 8 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 9 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 10 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 11 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 12 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 13 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 14 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 15 day) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 16 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 17 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 18 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 19 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 20 DAY) as pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 21 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 22 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 23 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 24 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 25 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 26 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 27 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 28 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 29 DAY) AS pushTime
UNION ALL
SELECT date_sub(curdate(), INTERVAL 30 DAY) AS pushTime
) b LEFT JOIN (
SELECT DATE_FORMAT(te.capture_time,'%Y%-%m-%d') AS pushTime,COUNT(1) AS number
FROM t_event te
JOIN t_scene_event tse ON te.camera_name = tse.channel_name
WHERE te.track_event = 'START' AND tse.scene_id = 2
AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= DATE(te.capture_time)
GROUP BY pushTime) a
ON b.pushTime = a.pushTime ORDER BY b.pushTime
</select>
</mapper> </mapper>