| | |
| | | package com.ycl.task; |
| | | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.ycl.config.PlatformConfig; |
| | | import com.ycl.platform.domain.entity.DeviceInfo; |
| | | import com.ycl.platform.domain.entity.WorkOrderCheckImg; |
| | | import com.ycl.platform.domain.vo.DeviceInfoVO; |
| | |
| | | import com.ycl.platform.mapper.WorkOrderCheckImgMapper; |
| | | import com.ycl.platform.service.WorkOrderService; |
| | | import com.ycl.utils.DateUtils; |
| | | import com.ycl.utils.uuid.IdUtils; |
| | | import constant.Constants; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.bytedeco.javacv.FFmpegFrameGrabber; |
| | | import org.bytedeco.javacv.Frame; |
| | | import org.bytedeco.javacv.Java2DFrameConverter; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | |
| | | // new ThreadPoolExecutor.CallerRunsPolicy() |
| | | // ); |
| | | |
| | | public void run() { |
| | | public void run() throws FFmpegFrameGrabber.Exception { |
| | | // String rtspUrl = "http://www.w3school.com.cn/i/movie.mp4"; |
| | | // if (StringUtils.hasText(rtspUrl)) { |
| | | // FFmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault(rtspUrl); |
| | | // try { |
| | | //// grabber.setOption("rtsp_transport", "tcp"); // 使用tcp的方式,不然会丢包很严重 |
| | | // grabber.setImageWidth(1920); |
| | | // grabber.setImageHeight(1080); |
| | | // grabber.setFrameRate(25); |
| | | // grabber.start(); |
| | | // System.out.println("成功"); |
| | | // Frame frame = grabber.grabImage(); |
| | | // String imgUrl = null; |
| | | // if (frame != null) { |
| | | // System.out.println("成功2"); |
| | | // //转换图像 |
| | | // Java2DFrameConverter converter = new Java2DFrameConverter(); |
| | | // BufferedImage srcImage = converter.getBufferedImage(frame); |
| | | // System.out.println(srcImage); |
| | | // if (srcImage != null) { |
| | | // imgUrl = IdUtils.fastSimpleUUID() + ".png"; |
| | | // // 生成图片路径 |
| | | // String imgPath = "/" + imgUrl; |
| | | // System.out.println("图片保存地址:" + imgPath); |
| | | //// imgUrl = Constants.RESOURCE_PREFIX + "/" + imgUrl; |
| | | // //创建文件 |
| | | // File file = new File("D:\\Codes\\zgyw\\"+imgUrl); |
| | | // //输出文件 |
| | | // ImageIO.write(srcImage, "png", file); |
| | | // } |
| | | // } |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // } finally { |
| | | // grabber.stop(); // 停止捕获 |
| | | //// grabber.close(); // 释放资源 |
| | | // } |
| | | // } |
| | | |
| | | // 查出最近一周的故障的设备 |
| | | Date now = new Date(); |
| | | Calendar ca = Calendar.getInstance(); |
| | |
| | | img.setCreateTime(new Date()); |
| | | workOrderCheckImgMapper.insert(img); |
| | | } |
| | | } |
| | | } |
| | | } } |
| | | |
| | | } |