积水点图片抓图

积水点接口优化
摄像头抓图sql修改添加定时任务
This commit is contained in:
wuweida 2022-07-13 17:32:50 +08:00
parent 2586f45112
commit f39d0f7165
11 changed files with 107 additions and 19 deletions

View File

@ -92,7 +92,7 @@ public class Controller {
@GetMapping("capture") @GetMapping("capture")
public Object capture(){ public Object capture(){
monitorService.construction(); monitorService.CameraScreenshot();
return "finish capture"; return "finish capture";
} }
@ -106,7 +106,7 @@ public class Controller {
@GetMapping("capture1") @GetMapping("capture1")
public Object capture1(){ public Object capture1(){
monitorService.scenicSpotAndBathing(); monitorService.WaterPointService();
return "finish capture"; return "finish capture";
} }

View File

@ -94,12 +94,16 @@ public class EventController {
} }
} }
JSONObject camera = jsonObject.getJSONObject("camera"); JSONObject camera = jsonObject.getJSONObject("camera");
event.setCameraName(camera.getString("cameraName")); if (camera!=null){
event.setDistrict(camera.getString("district")); event.setCameraName(camera.getString("cameraName"));
event.setLatitude(camera.getBigDecimal("latitude")); event.setDistrict(camera.getString("district"));
event.setLongitude(camera.getBigDecimal("longitude")); event.setLatitude(camera.getBigDecimal("latitude"));
event.setLongitude(camera.getBigDecimal("longitude"));
}
JSONObject image = jsonObject.getJSONObject("image"); JSONObject image = jsonObject.getJSONObject("image");
event.setImageUrl(image.getString("imageUrl")); if (image!=null){
event.setImageUrl(image.getString("imageUrl"));
}
event.setTaskId(jsonObject.getString("taskId")); event.setTaskId(jsonObject.getString("taskId"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
Date date; Date date;

View File

@ -0,0 +1,11 @@
package com.hisense.monitormanage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("t_test_code")
public class TestCode {
private String channelCode;
}

View File

@ -0,0 +1,18 @@
package com.hisense.monitormanage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("w_camera")
public class WCamera {
private Integer waterId;
private String ChannelCode;
private String channelName;
private String gpsX;
private String gpsY;
private String illustrate;
private String videoCapture;
}

View File

@ -58,6 +58,6 @@ public interface CameraChannelMapper extends BaseMapper<CameraChannel> {
List<CameraChannelNLDto> selectNLAll(@Param("page") Integer page,@Param("pageSize") Integer pageSize); List<CameraChannelNLDto> selectNLAll(@Param("page") Integer page,@Param("pageSize") Integer pageSize);
@Select("SELECT * FROM t_camera_channel WHERE channel_code > '404_37020348001325000037' ORDER BY channel_code DESC" ) @Select("SELECT * FROM t_camera_channel WHERE channel_code < '404_37020323541317325139' AND channel_code > '404_37020300001310016729' ORDER BY channel_code DESC" )
List<CameraChannel> selectCameraChannel(); List<CameraChannel> selectCameraChannel();
} }

View File

@ -0,0 +1,9 @@
package com.hisense.monitormanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisense.monitormanage.entity.TestCode;
import org.springframework.stereotype.Repository;
@Repository
public interface TestCodeMapper extends BaseMapper<TestCode> {
}

View File

@ -0,0 +1,9 @@
package com.hisense.monitormanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisense.monitormanage.entity.WCamera;
import org.springframework.stereotype.Repository;
@Repository
public interface WCameraMapper extends BaseMapper<WCamera> {
}

View File

@ -15,7 +15,7 @@ public interface WaterPointMapper extends BaseMapper<WaterPoint> {
@Select("select * from water_point wp LEFT JOIN water_point_report wpr ON wp.water_point_id = wpr.water_point_id WHERE wp.audit_flag = '2' and wp.disp_flag in (0,1)") @Select("select * from water_point wp LEFT JOIN water_point_report wpr ON wp.water_point_id = wpr.water_point_id WHERE wp.audit_flag = '2' and wp.disp_flag in (0,1)")
List<WaterPointDto> selectWaterPoint(); List<WaterPointDto> selectWaterPoint();
@Select("select * from water_point where audit_flag = '2' and disp_flag in (0,1) and report_origin = #{reportOrigin}") @Select("select * from water_point wp LEFT JOIN water_point_report wpr ON wp.water_point_id = wpr.water_point_id where audit_flag = '2' and disp_flag in (0,1) and report_origin = #{reportOrigin}")
List<WaterPointDto> selectReportOrigin(String reportOrigin); List<WaterPointDto> selectReportOrigin(String reportOrigin);
@Select("SELECT * FROM w_camera w RIGHT JOIN water_camera wc ON w.water_id = wc.water_id where wc.water_point_name = #{waterPointName}") @Select("SELECT * FROM w_camera w RIGHT JOIN water_camera wc ON w.water_id = wc.water_id where wc.water_point_name = #{waterPointName}")

View File

@ -70,6 +70,12 @@ public class MonitorService {
@Autowired @Autowired
private PeopleRecognizeMapper peopleRecognizeMapper; private PeopleRecognizeMapper peopleRecognizeMapper;
@Autowired
private TestCodeMapper testCodeMapper;
@Autowired
private WCameraMapper wCameraMapper;
@Value("${hwx.file.work-path}") @Value("${hwx.file.work-path}")
private String fileDir; private String fileDir;
@ -292,6 +298,7 @@ public class MonitorService {
} }
} }
@Scheduled(cron = "0 0 7 * * ?")
public void CameraScreenshot () { public void CameraScreenshot () {
try { try {
log.info("[monitor-capture]: start capture"); log.info("[monitor-capture]: start capture");
@ -317,16 +324,9 @@ public class MonitorService {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
i--; i--;
if (i == 0){ if (i == 0){
QueryWrapper<CameraChannel> queryWrapper = new QueryWrapper(); TestCode testCode = new TestCode();
queryWrapper.eq("channel_code",channelCode); testCode.setChannelCode(channelCode);
CameraChannel cameraChannel = cameraChannelMapper.selectOne(queryWrapper); testCodeMapper.insert(testCode);
cameraChannel.setCheckStatus(0);
cameraChannelMapper.update(cameraChannel,queryWrapper);
}
try {
Thread.sleep(500);
} catch (InterruptedException interruptedException) {
interruptedException.printStackTrace();
} }
} }
} }
@ -1038,6 +1038,33 @@ public class MonitorService {
} }
} }
@Scheduled(cron = "0 0 8 * * ?")
public void WaterPointService() {
try {
log.info("[monitor-capture]: start capture");
QueryWrapper<WCamera> queryWrapper = new QueryWrapper<>();
List<WCamera> wCameras = wCameraMapper.selectList(queryWrapper);
wCameras.forEach(camera -> {
String channelCode = camera.getChannelCode();
try {
BufferedImage bufferedImage = capturecreenshot(channelCode);
String fileName = channelCode + ".jpg";
ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName));
String picUrl = picHost + "/images/" + fileName;
WCamera wCamera = new WCamera();
wCamera.setVideoCapture(picUrl);
QueryWrapper<WCamera> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("channel_code", channelCode);
wCameraMapper.update(wCamera, queryWrapper1);
}catch (Exception e){
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture");
}catch (Exception exception){
exception.printStackTrace();
}
}
} }

View File

@ -0,0 +1,5 @@
<?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="com.hisense.monitormanage.mapper.TestCodeMapper">
</mapper>

View File

@ -0,0 +1,5 @@
<?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="com.hisense.monitormanage.mapper.WCameraMapper">
</mapper>