|
|
|
|
@ -47,6 +47,8 @@ import java.util.UUID;
|
|
|
|
|
import java.util.concurrent.*;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.module.camera.framework.netty.streetAlgorithm.executor.GetPhotoDelayExecutor.formatNumber;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class PLCServiceImpl implements PLCService {
|
|
|
|
|
@ -320,7 +322,7 @@ public class PLCServiceImpl implements PLCService {
|
|
|
|
|
// getPhotoDelayExecutor.communicationFactory(algorithmDelayTask);
|
|
|
|
|
}
|
|
|
|
|
// 玉溪check
|
|
|
|
|
public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
|
@ -372,58 +374,67 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
// 默认正确
|
|
|
|
|
AtomicReference<String> status = new AtomicReference<>("2");
|
|
|
|
|
StockDO finalStock = stock;
|
|
|
|
|
List<CompletableFuture<ScanData>> futures = dictDataList.values().stream()
|
|
|
|
|
.filter(dictDataDO -> !dictDataDO.getValue().equals("0"))
|
|
|
|
|
.map(dictDataDO -> CompletableFuture.supplyAsync(() ->
|
|
|
|
|
// 调用扫码服务,包含图片保存等不进行修改finalStock
|
|
|
|
|
scanServiceFactory.scan(dictDataDO.getValue(), street, dataInfo, finalStock)
|
|
|
|
|
).thenApply(result -> {
|
|
|
|
|
// 任务完成后,基于返回的结果进行操作
|
|
|
|
|
// 如果有扫码结果,并且扫码结果为假,则修改状态为错误
|
|
|
|
|
// 获取字段对象
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String wmsType = "wms" + capitalize(dictDataDO.getLabel());
|
|
|
|
|
Field stockField = finalStock.getClass().getDeclaredField(dictDataDO.getLabel());
|
|
|
|
|
Field wmsField = KsecDataInfo.class.getDeclaredField(dictDataDO.getLabel());
|
|
|
|
|
|
|
|
|
|
Field stockWmsField = finalStock.getClass().getDeclaredField(wmsType);
|
|
|
|
|
wmsField.setAccessible(true);
|
|
|
|
|
stockField.setAccessible(true);
|
|
|
|
|
stockWmsField.setAccessible(true);
|
|
|
|
|
String wmsCode = (String) wmsField.get(dataInfo);
|
|
|
|
|
|
|
|
|
|
if (!result.getCode().equals(wmsCode)) {
|
|
|
|
|
status.set("1");
|
|
|
|
|
}
|
|
|
|
|
stockField.set(finalStock, result.getCode());
|
|
|
|
|
stockWmsField.set(finalStock, wmsCode);
|
|
|
|
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
status.set("1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
).orTimeout(10, TimeUnit.SECONDS)
|
|
|
|
|
.exceptionally(ex -> {
|
|
|
|
|
if (ex instanceof TimeoutException) {
|
|
|
|
|
status.set("1");
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
// 等待所有异步任务完成
|
|
|
|
|
CompletableFuture<Void> allOf = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
|
|
|
|
try {
|
|
|
|
|
allOf.get(); // 阻塞直到所有任务完成
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
} catch (ExecutionException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
// 扫码枪扫描
|
|
|
|
|
ScanData trayCode = scanServiceFactory.scan("1", street, dataInfo, finalStock);
|
|
|
|
|
stock.setWmsTrayCode(trayCode.getCode());
|
|
|
|
|
stock.setTrayCode(dataInfo.getTrayCode());
|
|
|
|
|
if (!stock.getWmsTrayCode().equals(stock.getTrayCode())){
|
|
|
|
|
status.set("1");
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// List<CompletableFuture<ScanData>> futures = dictDataList.values().stream()
|
|
|
|
|
// .filter(dictDataDO -> !dictDataDO.getValue().equals("0"))
|
|
|
|
|
// .map(dictDataDO -> CompletableFuture.supplyAsync(() ->
|
|
|
|
|
//// 调用扫码服务,包含图片保存等不进行修改finalStock
|
|
|
|
|
//
|
|
|
|
|
// ).thenApply(result -> {
|
|
|
|
|
// // 任务完成后,基于返回的结果进行操作
|
|
|
|
|
//// 如果有扫码结果,并且扫码结果为假,则修改状态为错误
|
|
|
|
|
// // 获取字段对象
|
|
|
|
|
//
|
|
|
|
|
// try {
|
|
|
|
|
// String wmsType = "wms" + capitalize(dictDataDO.getLabel());
|
|
|
|
|
// Field stockField = finalStock.getClass().getDeclaredField(dictDataDO.getLabel());
|
|
|
|
|
// Field wmsField = KsecDataInfo.class.getDeclaredField(dictDataDO.getLabel());
|
|
|
|
|
//
|
|
|
|
|
// Field stockWmsField = finalStock.getClass().getDeclaredField(wmsType);
|
|
|
|
|
// wmsField.setAccessible(true);
|
|
|
|
|
// stockField.setAccessible(true);
|
|
|
|
|
// stockWmsField.setAccessible(true);
|
|
|
|
|
// String wmsCode = (String) wmsField.get(dataInfo);
|
|
|
|
|
//
|
|
|
|
|
// if (!result.getCode().equals(wmsCode)) {
|
|
|
|
|
// status.set("1");
|
|
|
|
|
// }
|
|
|
|
|
// stockField.set(finalStock, result.getCode());
|
|
|
|
|
// stockWmsField.set(finalStock, wmsCode);
|
|
|
|
|
// } catch (NoSuchFieldException | IllegalAccessException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// status.set("1");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return result;
|
|
|
|
|
// }
|
|
|
|
|
// ).orTimeout(10, TimeUnit.SECONDS)
|
|
|
|
|
// .exceptionally(ex -> {
|
|
|
|
|
// if (ex instanceof TimeoutException) {
|
|
|
|
|
// status.set("1");
|
|
|
|
|
// }
|
|
|
|
|
// return null;
|
|
|
|
|
// })
|
|
|
|
|
// )
|
|
|
|
|
// .toList();
|
|
|
|
|
//
|
|
|
|
|
// // 等待所有异步任务完成
|
|
|
|
|
// CompletableFuture<Void> allOf = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
|
|
|
|
// try {
|
|
|
|
|
// allOf.get(); // 阻塞直到所有任务完成
|
|
|
|
|
// } catch (InterruptedException e) {
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
// } catch (ExecutionException e) {
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 打印修改后的对象
|
|
|
|
|
|
|
|
|
|
@ -440,13 +451,24 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
AlgorithmDelayTask algorithmDelayTask = new AlgorithmDelayTask(dataInfo.getFromDirection(),street.getPlcId()
|
|
|
|
|
,dataInfo.getTaskId(),10000,finalStock.getTrayCode(),"E1",dataInfo.getFromRow(),dataInfo.getFromColumn());
|
|
|
|
|
|
|
|
|
|
String picPath = algorithmDelayTask.getSRMNumber() + "-" + algorithmDelayTask.getCmdName() + "-" + algorithmDelayTask.getDirection() + "-" + "up";
|
|
|
|
|
String picPath = algorithmDelayTask.getSRMNumber() + "-" + algorithmDelayTask.getCmdName() + "-" + algorithmDelayTask.getDirection() + "-" + "up";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String pathSrc = "http://"+ dictDataService.parseDictData("base_conf", "local_path").getValue() + ":9007/pic"+street.getPlcId()+"/" + dataInfo.getTaskId() + "_" + picPath + ".JPEG";
|
|
|
|
|
urlResourcesService.save(URLResourcesDo.builder().url(pathSrc).uuid(uuid).type("1").little("拍照").build());
|
|
|
|
|
algorithmDelayTask.setPath(pathSrc);
|
|
|
|
|
String pathSrc = "http://"+ dictDataService.parseDictData("base_conf", "local_path").getValue() + ":9007/pic"+street.getPlcId()+"/" + dataInfo.getTaskId() + "_" + picPath + ".JPEG";
|
|
|
|
|
urlResourcesService.save(URLResourcesDo.builder().url(pathSrc).uuid(uuid).type("1").little("拍照").build());
|
|
|
|
|
algorithmDelayTask.setPath(pathSrc);
|
|
|
|
|
String storageCode = "F"
|
|
|
|
|
+ dictDataService.parseDictData("base_conf", "library_code").getValue()
|
|
|
|
|
+formatNumber((Integer.parseInt(algorithmDelayTask.getSRMNumber())-1)*2+algorithmDelayTask.getDirection(),2)
|
|
|
|
|
+formatNumber(algorithmDelayTask.getRow(),2)
|
|
|
|
|
+formatNumber(algorithmDelayTask.getColumn(),2);
|
|
|
|
|
if (algorithmDelayTask.getRow()!=0 && algorithmDelayTask.getColumn()!=0) {
|
|
|
|
|
algorithmDelayTask.setStorageCode(storageCode);
|
|
|
|
|
}
|
|
|
|
|
algorithmDelayTask.setUuid(uuid);
|
|
|
|
|
getPhotoDelayExecutor.communicationFactory(algorithmDelayTask);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public static String capitalize(String str) {
|
|
|
|
|
if (str == null || str.isEmpty()) {
|
|
|
|
|
@ -508,7 +530,7 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
.row(ksecDataInfo.getFromRow())
|
|
|
|
|
.column(ksecDataInfo.getFromColumn())
|
|
|
|
|
.status("0")
|
|
|
|
|
.checkPic("http://" + streetDO.getPlcIp() + ":9007/pic"+streetDO.getPlcId()+"/" + ksecDataInfo.getTaskId() + "_" + cameraType + ".JPEG;")
|
|
|
|
|
.checkPic("http://" + dictDataService.parseDictData("base_conf", "local_path").getValue() + ":9007/pic"+streetDO.getPlcId()+"/"+ ksecDataInfo.getTaskId() + "_" + cameraType + ".JPEG")
|
|
|
|
|
.exportTime(LocalDateTime.now()).build();
|
|
|
|
|
stockService.save(stockDO);
|
|
|
|
|
} else {
|
|
|
|
|
@ -549,6 +571,12 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
stockDO.setCode(algorithmDelayTask.getStorageCode());
|
|
|
|
|
stockDO.setWmsCode(algorithmDelayTask.getStorageCode());
|
|
|
|
|
stockDO.setTrayCode(algorithmDelayTask.getTrayCode());
|
|
|
|
|
if (algorithmDelayTask.getUuid()!=null){
|
|
|
|
|
stockDO.setCheckPic(algorithmDelayTask.getUuid());
|
|
|
|
|
}
|
|
|
|
|
if (algorithmDelayTask.getStatus()!=null){
|
|
|
|
|
stockDO.setStatus(String.valueOf(algorithmDelayTask.getStatus()));
|
|
|
|
|
}
|
|
|
|
|
stockService.updateById(stockDO);
|
|
|
|
|
}
|
|
|
|
|
CheckLogDO checkLogDO = checkLogService.getOne(new QueryWrapper<CheckLogDO>().eq("task_Id", algorithmDelayTask.getTaskId()).last("limit 1"));
|
|
|
|
|
@ -557,6 +585,13 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
checkLogDO.setTrayCode(algorithmDelayTask.getTrayCode());
|
|
|
|
|
checkLogDO.setCode(algorithmDelayTask.getStorageCode());
|
|
|
|
|
checkLogDO.setWmsCode(algorithmDelayTask.getStorageCode());
|
|
|
|
|
if (algorithmDelayTask.getUuid()!=null){
|
|
|
|
|
checkLogDO.setPic(algorithmDelayTask.getUuid());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (algorithmDelayTask.getStatus()!=null){
|
|
|
|
|
checkLogDO.setStatus((algorithmDelayTask.getStatus()));
|
|
|
|
|
}
|
|
|
|
|
checkLogService.updateById(checkLogDO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -702,6 +737,8 @@ public void checkYx(KsecDataInfo dataInfo){
|
|
|
|
|
stockSave(ksecDataInfo, street, sensorGunCode);
|
|
|
|
|
String path = "http://" + dictDataService.parseDictData("base_conf", "local_path").getValue() + ":9007/pic"+street.getPlcId()+"/"+ kescEntity.getData().getTaskId() + "_" + picPath + ".JPEG";
|
|
|
|
|
algorithmDelayTask.setPath(path);
|
|
|
|
|
algorithmDelayTask.setUuid(uuid);
|
|
|
|
|
algorithmDelayTask.setStatus(2);
|
|
|
|
|
getPhotoDelayExecutor.communicationFactory(algorithmDelayTask);
|
|
|
|
|
|
|
|
|
|
urlResourcesService.save(URLResourcesDo.builder().url(path).uuid(uuid).type("1").little("球机拍照").build());
|
|
|
|
|
|