|
|
|
|
@ -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);
|
|
|
|
|
|