rev:优化退货入库申请任务逻辑

This commit is contained in:
2024-09-09 10:55:17 +08:00
parent b98f4ea401
commit 9de3416685
3 changed files with 47 additions and 25 deletions

View File

@@ -500,20 +500,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
.build(); .build();
logDto.setLog_level(4); logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
HttpResponse httpResponse = acsToWmsService.applyTwo(param); TaskDto dto = taskserver.findByBarcodeFromCache(barcode);
JSONObject jsonObject = null; if (ObjectUtil.isNotEmpty(dto)) {
if(ObjectUtil.isNotEmpty(httpResponse)){
String body = httpResponse.body();
jsonObject = JSONObject.parseObject(body);
}
message = "申请退货入库,返回参数:" + jsonObject;
if (ObjectUtil.isNotNull(jsonObject) && jsonObject.getInteger("status") == 200) {
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("申请退货入库,参数,接口返回:" + jsonObject)
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
List list1 = new ArrayList(); List list1 = new ArrayList();
Map map = new HashMap(); Map map = new HashMap();
map.put("code", "to_command"); map.put("code", "to_command");
@@ -522,14 +510,37 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
this.writing(list1); this.writing(list1);
this.requireSucess = true; this.requireSucess = true;
} else { } else {
this.iserror = true; HttpResponse httpResponse = acsToWmsService.applyTwo(param);
LuceneLogDto logDto2 = LuceneLogDto.builder() JSONObject jsonObject = null;
.device_code(device_code) if (ObjectUtil.isNotEmpty(httpResponse)) {
.content("申请退货入库,返回参数:" + jsonObject) String body = httpResponse.body();
.build(); jsonObject = JSONObject.parseObject(body);
logDto2.setLog_level(4); }
luceneExecuteLogService.deviceExecuteLog(logDto2); message = "申请退货入库,返回参数:" + jsonObject;
message = "申请退货入库报错,返回参数:" + jsonObject; if (ObjectUtil.isNotNull(jsonObject) && jsonObject.getInteger("status") == 200) {
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("申请退货入库,参数,接口返回:" + jsonObject)
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
List list1 = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", mode);
list1.add(map);
this.writing(list1);
this.requireSucess = true;
} else {
this.iserror = true;
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("申请退货入库,返回参数:" + jsonObject)
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
message = "申请退货入库报错,返回参数:" + jsonObject;
}
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -618,7 +629,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
HttpResponse httpResponse = acsToWmsService.applyTwo(param); HttpResponse httpResponse = acsToWmsService.applyTwo(param);
JSONObject jsonObject = null; JSONObject jsonObject = null;
if(ObjectUtil.isNotEmpty(httpResponse)){ if (ObjectUtil.isNotEmpty(httpResponse)) {
String body = httpResponse.body(); String body = httpResponse.body();
jsonObject = JSONObject.parseObject(body); jsonObject = JSONObject.parseObject(body);
} }
@@ -687,12 +698,12 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
HttpResponse httpResponse = acsToWmsService.applyTwo(param); HttpResponse httpResponse = acsToWmsService.applyTwo(param);
JSONObject jsonObject = null; JSONObject jsonObject = null;
if(ObjectUtil.isNotEmpty(httpResponse)){ if (ObjectUtil.isNotEmpty(httpResponse)) {
String body = httpResponse.body(); String body = httpResponse.body();
jsonObject = JSONObject.parseObject(body); jsonObject = JSONObject.parseObject(body);
} }
message = "木箱、子卷入库申请入库任务,返回参数:" + jsonObject; message = "木箱、子卷入库申请入库任务,返回参数:" + jsonObject;
if (ObjectUtil.isNotNull(jsonObject) && jsonObject.getInteger("status") == 200) { if (ObjectUtil.isNotNull(jsonObject) && jsonObject.getInteger("status") == 200) {
LuceneLogDto logDto2 = LuceneLogDto.builder() LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code) .device_code(device_code)
.content("木箱、子卷入库申请入库任务,参数,接口返回:" + jsonObject) .content("木箱、子卷入库申请入库任务,参数,接口返回:" + jsonObject)

View File

@@ -199,6 +199,8 @@ public interface TaskService extends CommonService<Task> {
*/ */
TaskDto findByCode(String code); TaskDto findByCode(String code);
TaskDto findByBarcodeFromCache(String barcode);
/** /**
* 根据设备号查询未执行的任务 * 根据设备号查询未执行的任务
* *

View File

@@ -430,6 +430,15 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
return ConvertUtil.convert(task, TaskDto.class); return ConvertUtil.convert(task, TaskDto.class);
} }
@Override
public TaskDto findByBarcodeFromCache(String barcode) {
Task task = new LambdaQueryChainWrapper<>(taskMapper)
.eq(Task::getVehicle_code, barcode)
.eq(Task::getTask_status,TaskStatusEnum.READY.getIndex())
.one();
return ConvertUtil.convert(task, TaskDto.class);
}
@Override @Override
public List<TaskDto> queryTaskByDeviceCode(String device_code) { public List<TaskDto> queryTaskByDeviceCode(String device_code) {
return Optional return Optional