From 23b9c29b2c7c70a7baecc788ce5b9d0fb9e982b4 Mon Sep 17 00:00:00 2001 From: yiming Date: Thu, 5 May 2022 09:44:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=8C=89=E7=85=A7=E8=A1=8C?= =?UTF-8?q?=E5=88=97=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zhehekeji/common/util/PathUtil.java | 6 ++++++ .../com/zhehekeji/web/service/PlcService.java | 20 +++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/modules/common/src/main/java/com/zhehekeji/common/util/PathUtil.java b/modules/common/src/main/java/com/zhehekeji/common/util/PathUtil.java index 24769dc..01a1e6c 100644 --- a/modules/common/src/main/java/com/zhehekeji/common/util/PathUtil.java +++ b/modules/common/src/main/java/com/zhehekeji/common/util/PathUtil.java @@ -30,6 +30,12 @@ public class PathUtil { return time + "/" + now.format(DateTimeFormatter.ofPattern("HHmmss-"))+getRandomString(10) + "."+fileType; } + public static String createFileNameByRowColumn(String fileType,Integer cameraId,Integer row,Integer column){ + LocalDateTime now = LocalDateTime.now(); + String date = now.format(DateTimeFormatter.ofPattern("yyyy/MM/dd")) + "/"+cameraId; + return row+"-"+column+"/"+date + "/" +date+ now.format(DateTimeFormatter.ofPattern("HHmmss-"))+row+"-"+column + "."+fileType; + } + /** * 检查文件的文件夹是否存在,不存在则新建 * @param url diff --git a/web/src/main/java/com/zhehekeji/web/service/PlcService.java b/web/src/main/java/com/zhehekeji/web/service/PlcService.java index 47f6a7c..939eb7b 100644 --- a/web/src/main/java/com/zhehekeji/web/service/PlcService.java +++ b/web/src/main/java/com/zhehekeji/web/service/PlcService.java @@ -222,7 +222,18 @@ public class PlcService { if(code.startsWith("C1") || code.startsWith("C3")){ delay = true; } - path = cameraCapture(cameraId,delay,configProperties.getCameraConfig().getDelayCaptureTime()); + Integer row = 0; + Integer column = 0; + if(times<=2){ + row = plcCmdInfo.getRow1(); + column = plcCmdInfo.getColumn1(); + }else { + row = plcCmdInfo.getRow2(); + column = plcCmdInfo.getColumn2(); + } + path = PathUtil.createFileNameByRowColumn("jpg",cameraId,row,column); + + path = cameraCapture(cameraId,delay,configProperties.getCameraConfig().getDelayCaptureTime(),path); } //update order info after capture if (path != null && needCapture) { @@ -281,8 +292,8 @@ public class PlcService { * * @Return pic address */ - public String cameraCapture(Integer cameraId,Boolean delay,Long delayTime) { - String path = PathUtil.createFileName("jpg",cameraId); + public String cameraCapture(Integer cameraId,Boolean delay,Long delayTime,String path) { + //String path = PathUtil.createFileName("jpg",cameraId); String realPath = configProperties.getSavePath().getMediaPath() + path; if(delay){ TaskDelayExecutor.addPicDelayTask(cameraId,realPath,delayTime); @@ -522,7 +533,8 @@ public class PlcService { } catch (InterruptedException e) { e.printStackTrace(); } - String path = cameraCapture(cameraId,false,null); + String path = PathUtil.createFileNameByRowColumn("jpg",cameraId,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1()); + cameraCapture(cameraId,false,null,path); //托盘码 String trayCode = null; Boolean trayCheck = Boolean.TRUE;