diff --git a/src/main/java/com/hisense/monitormanage/entity/Booth.java b/src/main/java/com/hisense/monitormanage/entity/Booth.java new file mode 100644 index 0000000..76bc7c6 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/entity/Booth.java @@ -0,0 +1,19 @@ +package com.hisense.monitormanage.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName("t_booth") +public class Booth { + private String serial; + private String area; + private String boothName; + private String location; + private String manageTime; + private String captureTime; + private String channelCode; + private String gpsX; + private String gpsY; + private String channelName; +} diff --git a/src/main/java/com/hisense/monitormanage/mapper/BoothMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BoothMapper.java new file mode 100644 index 0000000..977bc33 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/mapper/BoothMapper.java @@ -0,0 +1,13 @@ +package com.hisense.monitormanage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hisense.monitormanage.entity.Booth; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +public interface BoothMapper extends BaseMapper { + + @Select("select * from t_booth where capture_time = #{captureTime}") + List selectBooth(String captureTime); +} diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java index 03865a8..6f35388 100644 --- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java +++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java @@ -67,6 +67,9 @@ public class MonitorService { @Autowired private ChannelPictureMapper channelPictureMapper; + @Autowired + private BoothMapper boothMapper; + @Value("${hwx.file.work-path}") private String fileDir; @Value("${hwx.file.pic-host}") @@ -208,6 +211,318 @@ public class MonitorService { } } + @Scheduled(cron = "0 20 8 * * ? ") + public void screenShot3() { + try { + log.info("[monitor-capture]: start capture1"); + + List labels = boothMapper.selectBooth("8:20"); + labels.forEach(label -> { + String channelCode = label.getChannelCode(); + try { + BufferedImage bufferedImage = capturecreenshot(channelCode); + String fileName = channelCode + ".jpg"; + ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName)); + + String picUrl = picHost + "/images/" + fileName; + + ChannelPicture picture = new ChannelPicture(); + picture.setChannelCode(channelCode); + picture.setPicUrl(picUrl); + /*picture.setInsertTime(new Date()); + channelPictureMapper.insert(picture);*/ + if (channelCode == null){ + channelPictureMapper.insert(picture); + }else { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("channel_code", channelCode); + picture.setInsertTime(new Date()); + channelPictureMapper.update(picture, queryWrapper); + } + }catch (Exception e){ + + log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); + } + }); + + log.info("[monitor-capture]: end capture1"); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + @Scheduled(cron = "0 50 8 * * ? ") + public void screenShot4() { + try { + log.info("[monitor-capture]: start capture1"); + + List labels = boothMapper.selectBooth("8:50"); + labels.forEach(label -> { + String channelCode = label.getChannelCode(); + try { + BufferedImage bufferedImage = capturecreenshot(channelCode); + String fileName = channelCode + ".jpg"; + ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName)); + + String picUrl = picHost + "/images/" + fileName; + + ChannelPicture picture = new ChannelPicture(); + picture.setChannelCode(channelCode); + picture.setPicUrl(picUrl); + /*picture.setInsertTime(new Date()); + channelPictureMapper.insert(picture);*/ + if (channelCode == null){ + channelPictureMapper.insert(picture); + }else { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("channel_code", channelCode); + picture.setInsertTime(new Date()); + channelPictureMapper.update(picture, queryWrapper); + } + }catch (Exception e){ + + log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); + } + }); + + log.info("[monitor-capture]: end capture1"); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + @Scheduled(cron = "0 50 9 * * ? ") + public void screenShot5() { + try { + log.info("[monitor-capture]: start capture1"); + + List labels = boothMapper.selectBooth("9:50"); + labels.forEach(label -> { + String channelCode = label.getChannelCode(); + try { + BufferedImage bufferedImage = capturecreenshot(channelCode); + String fileName = channelCode + ".jpg"; + ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName)); + + String picUrl = picHost + "/images/" + fileName; + + ChannelPicture picture = new ChannelPicture(); + picture.setChannelCode(channelCode); + picture.setPicUrl(picUrl); + /*picture.setInsertTime(new Date()); + channelPictureMapper.insert(picture);*/ + if (channelCode == null){ + channelPictureMapper.insert(picture); + }else { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("channel_code", channelCode); + picture.setInsertTime(new Date()); + channelPictureMapper.update(picture, queryWrapper); + } + }catch (Exception e){ + + log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); + } + }); + + log.info("[monitor-capture]: end capture1"); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + @Scheduled(cron = "0 20 11 * * ? ") + public void screenShot6() { + try { + log.info("[monitor-capture]: start capture1"); + + List labels = boothMapper.selectBooth("11:20"); + labels.forEach(label -> { + String channelCode = label.getChannelCode(); + try { + BufferedImage bufferedImage = capturecreenshot(channelCode); + String fileName = channelCode + ".jpg"; + ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName)); + + String picUrl = picHost + "/images/" + fileName; + + ChannelPicture picture = new ChannelPicture(); + picture.setChannelCode(channelCode); + picture.setPicUrl(picUrl); + /*picture.setInsertTime(new Date()); + channelPictureMapper.insert(picture);*/ + if (channelCode == null){ + channelPictureMapper.insert(picture); + }else { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("channel_code", channelCode); + picture.setInsertTime(new Date()); + channelPictureMapper.update(picture, queryWrapper); + } + }catch (Exception e){ + + log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); + } + }); + + log.info("[monitor-capture]: end capture1"); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + @Scheduled(cron = "0 20 11 * * ? ") + public void screenShot7() { + try { + log.info("[monitor-capture]: start capture1"); + + List labels = boothMapper.selectBooth("11:20"); + labels.forEach(label -> { + String channelCode = label.getChannelCode(); + try { + BufferedImage bufferedImage = capturecreenshot(channelCode); + String fileName = channelCode + ".jpg"; + ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName)); + + String picUrl = picHost + "/images/" + fileName; + + ChannelPicture picture = new ChannelPicture(); + picture.setChannelCode(channelCode); + picture.setPicUrl(picUrl); + /*picture.setInsertTime(new Date()); + channelPictureMapper.insert(picture);*/ + if (channelCode == null){ + channelPictureMapper.insert(picture); + }else { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("channel_code", channelCode); + picture.setInsertTime(new Date()); + channelPictureMapper.update(picture, queryWrapper); + } + }catch (Exception e){ + + log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); + } + }); + + log.info("[monitor-capture]: end capture1"); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + @Scheduled(cron = "0 20 12 * * ? ") + public void screenShot8() { + try { + log.info("[monitor-capture]: start capture1"); + + List labels = boothMapper.selectBooth("12:20"); + labels.forEach(label -> { + String channelCode = label.getChannelCode(); + try { + BufferedImage bufferedImage = capturecreenshot(channelCode); + String fileName = channelCode + ".jpg"; + ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName)); + + String picUrl = picHost + "/images/" + fileName; + + ChannelPicture picture = new ChannelPicture(); + picture.setChannelCode(channelCode); + picture.setPicUrl(picUrl); + /*picture.setInsertTime(new Date()); + channelPictureMapper.insert(picture);*/ + if (channelCode == null){ + channelPictureMapper.insert(picture); + }else { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("channel_code", channelCode); + picture.setInsertTime(new Date()); + channelPictureMapper.update(picture, queryWrapper); + } + }catch (Exception e){ + + log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); + } + }); + + log.info("[monitor-capture]: end capture1"); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + @Scheduled(cron = "0 20 19 * * ? ") + public void screenShot9() { + try { + log.info("[monitor-capture]: start capture1"); + + List labels = boothMapper.selectBooth("19:20"); + labels.forEach(label -> { + String channelCode = label.getChannelCode(); + try { + BufferedImage bufferedImage = capturecreenshot(channelCode); + String fileName = channelCode + ".jpg"; + ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName)); + + String picUrl = picHost + "/images/" + fileName; + + ChannelPicture picture = new ChannelPicture(); + picture.setChannelCode(channelCode); + picture.setPicUrl(picUrl); + /*picture.setInsertTime(new Date()); + channelPictureMapper.insert(picture);*/ + if (channelCode == null){ + channelPictureMapper.insert(picture); + }else { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("channel_code", channelCode); + picture.setInsertTime(new Date()); + channelPictureMapper.update(picture, queryWrapper); + } + }catch (Exception e){ + + log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); + } + }); + + log.info("[monitor-capture]: end capture1"); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + @Scheduled(cron = "0 20 20 * * ? ") + public void screenShot10() { + try { + log.info("[monitor-capture]: start capture1"); + + List labels = boothMapper.selectBooth("20:20"); + labels.forEach(label -> { + String channelCode = label.getChannelCode(); + try { + BufferedImage bufferedImage = capturecreenshot(channelCode); + String fileName = channelCode + ".jpg"; + ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName)); + + String picUrl = picHost + "/images/" + fileName; + + ChannelPicture picture = new ChannelPicture(); + picture.setChannelCode(channelCode); + picture.setPicUrl(picUrl); + /*picture.setInsertTime(new Date()); + channelPictureMapper.insert(picture);*/ + if (channelCode == null){ + channelPictureMapper.insert(picture); + }else { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("channel_code", channelCode); + picture.setInsertTime(new Date()); + channelPictureMapper.update(picture, queryWrapper); + } + }catch (Exception e){ + + log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); + } + }); + + log.info("[monitor-capture]: end capture1"); + }catch (Exception exception){ + exception.printStackTrace(); + } + } @Scheduled(cron = "0 0 8 1/1 * ?") public void screenShot1() { @@ -215,7 +530,7 @@ public class MonitorService { log.info("[monitor-capture]: start capture1"); - List labels = cameraChannelMapper.selectLabelAndChannel("1009,1008"); + List labels = cameraChannelMapper.selectLabelAndChannel("'',1008"); labels.forEach(label -> { String channelCode = label.getChannelCode(); try { @@ -444,9 +759,9 @@ public class MonitorService { Boolean isParent = (Boolean) result.get("isParent"); if (isParent){ - CameraOrganization cameraOrganization = JSONObject.parseObject(JSONObject.toJSONString(result), CameraOrganization.class); + /*CameraOrganization cameraOrganization = JSONObject.parseObject(JSONObject.toJSONString(result), CameraOrganization.class); - cameraOrgenMapper.insert(cameraOrganization); + cameraOrgenMapper.insert(cameraOrganization);*/ videoService((String) result.get("id"),path + sep + result.get("name")); }else { diff --git a/src/main/resources/mapper/BoothMapper.xml b/src/main/resources/mapper/BoothMapper.xml new file mode 100644 index 0000000..b93967a --- /dev/null +++ b/src/main/resources/mapper/BoothMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file