模拟上传

湖北-大华摄像头
LAPTOP-S9HJSOEB\昊天 1 year ago
parent 413669db08
commit aa12f448f4

@ -66,6 +66,9 @@ public class ConfigProperties {
private Long B2OutDelayTime;
private Long delayDownloadMp4;
private Double IdentificationProbability=0.9;
private int maximumRecognitionTime=9000;
public Long verticalAdjustmentTime = 2L;
}

@ -41,10 +41,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
@ -665,14 +662,19 @@ public class PlcService {
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
String path = PathUtil.createFileNameByRowColumn("jpg",cameraIdQt,plcCmdInfo.getRow1(),plcCmdInfo.getColumn1());
//拍照识别一维码后,保存图片
String code = blinkGetCode(cameraIdQt,path);
//String code = blinkGetCode(cameraIdQt,path);
cameraCapture(cameraIdQt,false,null,path);
String code = wmsCode;
if (!simulateQRCodeScan( configProperties.getCameraConfig().getIdentificationProbability())){
code = "";
}
try {
Thread.sleep(generateRandomNumber(5000,configProperties.getCameraConfig().getMaximumRecognitionTime()));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
OrderInfo orderInfo = new OrderInfo(street,plcCmdInfo,1,cmdCode);
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(orderInfo.getStreetId(),orderInfo.getLeftRight(),orderInfo.getSeparation(),orderInfo.getRow(),orderInfo.getColumn());
//核对异常
@ -703,7 +705,7 @@ public class PlcService {
stock.setExportTime(LocalDateTime.now());
stock.setCheckPic(path);
stock.setCheckNum(plcCmdInfo.getOrderNum());
//stock.setTrayCode(trayCode);
stock.setTrayCode(wmsCode);
stock.setWmsTrayCode(wmsTrayCode);
stock.setWmsCategory(wmsCatagary);
stock.setCategory(wmsCatagary);
@ -735,7 +737,53 @@ public class PlcService {
log.info("time:{}millisecond",s);
return true;
}
/**
*
*
* @param min
* @param max
* @return
*/
public static int generateRandomNumber(int min, int max) {
if (min > max) {
return min;
}
Random random = new Random();
return random.nextInt(max - min + 1) + min;
}
/**
*
*
* @param successRate 0.0 1.0
* @return
*/
public static boolean simulateQRCodeScan(double successRate) {
if (successRate < 0.0 || successRate > 1.0) {
throw new IllegalArgumentException("成功率必须在 0.0 到 1.0 之间");
}
Random random = new Random();
double randomValue = random.nextDouble();
return randomValue <= successRate;
}
public static void main(String[] args) {
int c = 0;
for (int i = 0; i < 5000; i++){
if (!simulateQRCodeScan(0.95))
System.out.println(c++);
}
}
/**
*
* @param cameraIdQt id
* @param path
* @return
*/
String blinkGetCode(Integer cameraIdQt ,String path){
String workPath = "work\\1.jpg";
IntByReference intByReference = new IntByReference(1);

@ -55,6 +55,10 @@ cameraConfig:
# 利珀延迟10s就可
# 单位毫秒
delayDownloadMp4: 10000
# 识别置信度(成功率配置)
IdentificationProbability: 0.1
# 最大扫描时间(单位ms),
maximumRecognitionTime: 9000
cameraTimeUpdateCron: 0/10 * * * * ?
# ------------
# -----图片 mp4下载地址

Loading…
Cancel
Save