fix: 异步更新、入库测试
This commit is contained in:
@@ -54,6 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static redis.clients.jedis.HostAndPort.localhost;
|
||||
|
||||
@@ -255,7 +256,15 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
}
|
||||
|
||||
if (move != 0 && task > 0) {
|
||||
update_instruction_status();
|
||||
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||
// 异步更新指令状态
|
||||
try {
|
||||
update_instruction_status();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
future.thenRun(() -> System.out.println("异步更新任务已完成"));
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
|
||||
@@ -211,7 +211,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
System.out.println("in 开始时间"+ LocalDateTime.now() +this.getDeviceCode());
|
||||
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
@@ -392,7 +391,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
last_height = height;
|
||||
last_weight = weight;
|
||||
last_barcode = barcode;
|
||||
System.out.println("out 开始时间"+ LocalDateTime.now() +this.getDeviceCode());
|
||||
}
|
||||
|
||||
private void applyErrorHeight() {
|
||||
@@ -638,7 +636,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
map.put("value", mode);
|
||||
list1.add(map);
|
||||
this.writing(list1);
|
||||
this.requireSucess = true;
|
||||
}else {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
|
||||
@@ -4,13 +4,13 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
@@ -18,8 +18,6 @@ import org.nl.acs.device_driver.FeedLmsRealFailed;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingRequest;
|
||||
import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingResponse;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.history.ErrorUtil;
|
||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||
@@ -205,26 +203,15 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
message = "universal_message3";
|
||||
}
|
||||
|
||||
List toInstructions;
|
||||
Instruction instruction = instructionService.findByCode(String.valueOf(task));
|
||||
//空箱出库开盖位,申请开盖
|
||||
if (mode == 7 && move == 1 && task > 0) {
|
||||
if (mode == 7 && move == 1 && task > 0 ) {
|
||||
//不允许开盖,完成出库任务,自动去扫码位
|
||||
if (!applyUnbox(instruction)){
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
try {
|
||||
// instructionService.finish(instruction);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
if (StrUtil.isEmpty(instruction.getVehicle_code())){
|
||||
message = "universal_notCreateInstMessage8";
|
||||
}
|
||||
List list1 = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("code", "to_command");
|
||||
map.put("value", 7);
|
||||
list1.add(map);
|
||||
this.writing(list1);
|
||||
applyUnbox(instruction.getVehicle_code());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +232,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
last_to_height =to_height;
|
||||
}
|
||||
|
||||
private Boolean applyUnbox(Instruction instruction) {
|
||||
private Boolean applyUnbox(String vehicleCode) {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.require_apply_strangulation_time.getTime()
|
||||
< (long) this.instruction_require_time_out) {
|
||||
@@ -253,28 +240,45 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
return false;
|
||||
} else {
|
||||
try {
|
||||
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = new ApplyLabelingAndBindingRequest();
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("device_code", device_code);
|
||||
param.put("material_barcode", vehicleCode);
|
||||
param.put("task", task);
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("木箱、子卷入库申请入库任务,参数:" + param)
|
||||
.content("木箱开盖,参数:" + param)
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
ApplyLabelingAndBindingResponse response = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
|
||||
if (response == null || response.getstatus() == 200) {
|
||||
String response = acsToWmsService.getBoxInfo(param);
|
||||
JSONObject jo = JSON.parseObject(response);
|
||||
if (jo.getInteger("status") == 200) {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("木箱、子卷入库申请入库任务,参数,接口返回:" + response)
|
||||
.content("木箱开盖,接口返回:" + response)
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto2);
|
||||
Map datas = response.getData();
|
||||
packagePLCData(datas,instruction);
|
||||
this.setRequireSucess(true);
|
||||
return true;
|
||||
String data = jo.getString("data");
|
||||
JSONObject datas = JSON.parseObject(data);
|
||||
packagePLCData(datas);
|
||||
String isUncap = datas.get("isUncap").toString();
|
||||
if ("1".equals(isUncap)){
|
||||
List list1 = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("code", "to_command");
|
||||
map.put("value", 7);
|
||||
list1.add(map);
|
||||
this.writing(list1);
|
||||
}else {
|
||||
List list1 = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("code", "to_command");
|
||||
map.put("value", 99);
|
||||
list1.add(map);
|
||||
this.writing(list1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -285,36 +289,18 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
return false;
|
||||
}
|
||||
|
||||
private void packagePLCData(Map datas, Instruction instruction) {
|
||||
String length = datas.get("length").toString();
|
||||
String weight = datas.get("weight").toString();
|
||||
String height = datas.get("height").toString();
|
||||
String printQty = datas.get("printQty").toString();
|
||||
String printDevice = datas.get("printDevice").toString();
|
||||
String bundleTimes = datas.get("bundleTimes").toString();
|
||||
String next_device_code = instruction.getNext_device_code();
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
String next_addr = nextDevice.getExtraValue().get("address").toString();
|
||||
|
||||
private void packagePLCData(JSONObject datas) {
|
||||
String length = datas.get("boxLength").toString();
|
||||
String weight = datas.get("boxWidth").toString();
|
||||
String height = datas.get("boxHigh").toString();
|
||||
String desiccant = datas.get("desiccantTemplat").toString();
|
||||
List list = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("code", "to_task");
|
||||
map.put("value", task);
|
||||
list.add(map);
|
||||
Map map2 = new HashMap();
|
||||
map2.put("code", "to_container_type");
|
||||
map2.put("value", instruction.getVehicle_code());
|
||||
list.add(map2);
|
||||
Map map3 = new HashMap();
|
||||
map3.put("code", "to_target");
|
||||
map3.put("value", next_addr);
|
||||
list.add(map3);
|
||||
Map map4 = new HashMap();
|
||||
map4.put("code", "to_leight");
|
||||
map4.put("code", "to_length");
|
||||
map4.put("value", length);
|
||||
list.add(map4);
|
||||
Map map5 = new HashMap();
|
||||
map5.put("code", "to_wedth");
|
||||
map5.put("code", "to_width");
|
||||
map5.put("value", weight);
|
||||
list.add(map5);
|
||||
Map map6 = new HashMap();
|
||||
@@ -322,17 +308,10 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
map6.put("value", height);
|
||||
list.add(map6);
|
||||
Map map7 = new HashMap();
|
||||
map7.put("code", "to_print_qty");
|
||||
map7.put("value", printQty);
|
||||
map7.put("code", "to_desiccant");
|
||||
map7.put("value", desiccant);
|
||||
list.add(map7);
|
||||
Map map9 = new HashMap();
|
||||
map9.put("code", "to_print_device");
|
||||
map9.put("value", printDevice);
|
||||
list.add(map9);
|
||||
Map map11 = new HashMap();
|
||||
map11.put("code", "to_binding_times");
|
||||
map11.put("value", bundleTimes);
|
||||
list.add(map11);
|
||||
|
||||
try {
|
||||
this.writing(list);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -464,4 +464,5 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
|
||||
*/
|
||||
Boolean querySameNextDeviceCodeInstByOut(String nextDeviceCode);
|
||||
|
||||
List<Instruction> findByCodeAndExcute(String nextDeviceCode);
|
||||
}
|
||||
|
||||
@@ -1858,6 +1858,14 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Instruction> findByCodeAndExcute(String next_code) {
|
||||
List<Instruction> instructionList = instructions.stream().filter(item -> item.getNext_device_code().equals(next_code)).collect(Collectors.toList());
|
||||
|
||||
return instructionList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean regional(String start_device_code, String next_device_code) {
|
||||
Device startdevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
|
||||
@@ -215,6 +215,8 @@ public class CreateDDJInst {
|
||||
List<Instruction> byDeviceCodes = instructionService.findByDeviceCodes(instruction, true);
|
||||
Instruction instdto = new Instruction();
|
||||
if (CollUtil.isEmpty(byDeviceCodes)) {
|
||||
//判断有没有DDJ对接位出入库的指令
|
||||
instructionService.findByCodeAndExcute(next_device_code);
|
||||
instdto.setInstruction_type(task_type);
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
|
||||
Reference in New Issue
Block a user