rev:现场测试优化

This commit is contained in:
2025-01-02 13:11:24 +08:00
parent d8fb4b3873
commit 3b18f47cbf
7 changed files with 147 additions and 135 deletions

View File

@@ -324,8 +324,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
case 4:
//申请出货
if (move == 1 && !requireSucess) {
//request_for_shipment(String.valueOf(mode), item_out_seq_arr, item_out_qty_arr);
}
}
break;

View File

@@ -167,11 +167,23 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
Boolean iserror = false;
private Date instruction_update_time = new Date();
private Date require_apply_strangulation_time = new Date();
//木箱入库申请时间
private Date require_apply_mxrk_time = new Date();
//托盘入库申请时间
private Date require_apply_tprk_time = new Date();
//子卷入库申请时间
private Date require_apply_zjrk_time = new Date();
//退货入库申请时间
private Date require_apply_thrk_time = new Date();
private int instruction_update_time_out = 1000;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private int instruction_require_time_out = 3000;
private int require_apply_mxrk_time_out = 4000;
private int require_apply_tprk_time_out = 4000;
private int require_apply_zjrk_time_out = 4000;
private int require_apply_thrk_time_out = 4000;
//行架机械手申请任务成功标识
boolean requireSucess = false;
@@ -252,29 +264,29 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
}
if (move != last_move) {
if (ObjectUtil.isNotEmpty(inst)) {
if (move == 0) {
Thread.sleep(10000);
led_message = clearMessage();
List<String> deviceCodes = this.getExtraDeviceCodes("link_device_code");
String device = null;
if (ObjectUtil.isNotEmpty(deviceCodes)) {
for (String deviceCode : deviceCodes) {
Device linkDevice = deviceAppService.findDeviceByCode(deviceCode);
if (ObjectUtil.isEmpty(linkDevice)) {
throw new BadRequestException("设备:" + device_code + "关联设备->" + deviceCode + "为空!");
}
if (linkDevice.getDeviceDriver() instanceof LedScreenDeviceDriver) {
device = deviceCode;
}
}
}
taskScreenService.getLedMessage(device);
}
}
requireSucess = false;
}
// if (move != last_move) {
// if (ObjectUtil.isNotEmpty(inst)) {
// if (move == 0) {
// Thread.sleep(10000);
// led_message = clearMessage();
// List<String> deviceCodes = this.getExtraDeviceCodes("link_device_code");
// String device = null;
// if (ObjectUtil.isNotEmpty(deviceCodes)) {
// for (String deviceCode : deviceCodes) {
// Device linkDevice = deviceAppService.findDeviceByCode(deviceCode);
// if (ObjectUtil.isEmpty(linkDevice)) {
// throw new BadRequestException("设备:" + device_code + "关联设备->" + deviceCode + "为空!");
// }
// if (linkDevice.getDeviceDriver() instanceof LedScreenDeviceDriver) {
// device = deviceCode;
// }
// }
// }
// taskScreenService.getLedMessage(device);
// }
// }
// requireSucess = false;
// }
if (move != 0 && task > 0) {
update_instruction_status();
}
@@ -296,12 +308,12 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
//木箱入库申请入库任务
if (mode == 6 && !requireSucess) {
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime()
< (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
if (date.getTime() - this.require_apply_mxrk_time.getTime()
< (long) this.require_apply_mxrk_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.require_apply_mxrk_time_out);
return;
} else {
this.require_apply_strangulation_time = date;
this.require_apply_mxrk_time = date;
if (StrUtil.isNotEmpty(hand_barcode) && StrUtil.isNotEmpty(hand_material_barcode)) {
applyIn(StorageTypeEnum.BOX_IN.getType(), mode);
} else if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) {
@@ -316,12 +328,12 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
//子卷入库申请入库任务
if (mode == 7 && move == 1 && !requireSucess) {
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime()
< (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
if (date.getTime() - this.require_apply_zjrk_time.getTime()
< (long) this.require_apply_zjrk_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.require_apply_zjrk_time_out);
return;
} else {
this.require_apply_strangulation_time = date;
this.require_apply_zjrk_time = date;
if (StrUtil.isNotEmpty(hand_barcode) && StrUtil.isNotEmpty(hand_material_barcode)) {
applyIn(StorageTypeEnum.STORAGE.getType(), mode);
} else if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) {
@@ -336,36 +348,20 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
//申请空托盘入库
if (mode == 9 && move == 1 && !requireSucess) {
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime()
< (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_apply_strangulation_time = date;
if (container_type == 0 || StrUtil.isEmpty(barcode)) {
message = "托盘类型为空";
} else {
applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode);
}
}
}
//申请退货入库
if (mode == 18 && move == 1 && !requireSucess) {
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime()
< (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_apply_strangulation_time = date;
if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) {
message = "托盘条码为空或者木箱号为空";
} else {
applyBoxReturnTask(StorageTypeEnum.BOX_RETURN.getType(), mode);
}
}
}
//申请高度
@@ -511,52 +507,37 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
}
private void applyBoxReturnTask(String type, int mode) {
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
if (StrUtil.isNotEmpty(barcode) && (barcode.startsWith("A") || barcode.startsWith("B"))) {
param.put("vehicle_code", barcode);
}
if (StrUtil.isNotEmpty(material_barcode)) {
param.put("material_barcode", material_barcode);
}
if (StrUtil.isNotEmpty(hand_material_barcode)) {
param.put("material_barcode", hand_material_barcode);
}
param.put("type", type);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("申请退货入库,参数:" + param)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
TaskDto dto = taskserver.findByBarcodeFromCache(barcode);
if (ObjectUtil.isNotEmpty(dto)) {
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 {
HttpResponse httpResponse = acsToWmsService.applyTwo(param);
JSONObject jsonObject = null;
if (ObjectUtil.isNotEmpty(httpResponse)) {
String body = httpResponse.body();
jsonObject = JSONObject.parseObject(body);
Date date = new Date();
if (date.getTime() - this.require_apply_thrk_time.getTime()
< (long) this.require_apply_thrk_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.require_apply_thrk_time_out);
return;
} else {
this.require_apply_thrk_time = date;
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
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);
if (StrUtil.isNotEmpty(barcode) && (barcode.startsWith("A") || barcode.startsWith("B"))) {
param.put("vehicle_code", barcode);
}
if (StrUtil.isNotEmpty(material_barcode)) {
param.put("material_barcode", material_barcode);
}
if (StrUtil.isNotEmpty(hand_material_barcode)) {
param.put("material_barcode", hand_material_barcode);
}
param.put("type", type);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("申请退货入库,参数:" + param)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
TaskDto dto = taskserver.findByBarcodeFromCache(barcode);
if (ObjectUtil.isNotEmpty(dto)) {
List list1 = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
@@ -565,18 +546,41 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
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;
HttpResponse httpResponse = acsToWmsService.applyTwo(param);
JSONObject jsonObject = null;
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();
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) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -636,6 +640,13 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
}
private void applyEmptyTask(String type, int mode) {
Date date = new Date();
if (date.getTime() - this.require_apply_tprk_time.getTime()
< (long) this.require_apply_tprk_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.require_apply_tprk_time_out);
return;
} else {
this.require_apply_tprk_time = date;
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
@@ -688,6 +699,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
e.printStackTrace();
}
}
}
private void applyIn(String type, int mode) {
try {
@@ -721,7 +733,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
String body = httpResponse.body();
jsonObject = JSONObject.parseObject(body);
}
log.error("wms反馈结果:{}",jsonObject);
log.info("wms反馈结果:{}",jsonObject);
message = "木箱、子卷入库申请入库任务,返回参数:" + jsonObject;
LuceneLogDto logDto3 = LuceneLogDto.builder()
.device_code(device_code)

View File

@@ -87,7 +87,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
private RedisUtils redisUtils;
private CustomerStragetyCacheService customerStragetyCacheService = SpringContextHolder.getBean(CustomerStragetyCacheService.class);;
private CustomerStragetyCacheService customerStragetyCacheService = SpringContextHolder.getBean(CustomerStragetyCacheService.class);
;
/**
* 禁止入库
@@ -279,14 +280,14 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
private int instruction_require_time_out = 1000;
private int instruction_update_time_out = 1000;
private int update_point_require_time_out = 3000;
private Date instruction_require_time = new Date();
private Date update_point_require_time = new Date();
private Date instruction_update_time = new Date();
List<String> getDeviceCodeList = null;
List<String> putDeviceCodeList = null;
/**
* 请求成功标记
*/
@@ -357,7 +358,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
clearWrite();
}
}
if (!error.equals(last_error) && error == 0){
if (!error.equals(last_error) && error == 0) {
errorRequireSucess = false;
}
@@ -406,7 +407,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
if (mode != 3 || requireSucess) {
message = "one_message7";
} else {
if (error != 0 && !errorRequireSucess) {
if (error != 0 && !errorRequireSucess) {
erroBlock();
}
List list = new ArrayList();
@@ -710,10 +711,11 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
*/
private void applyUpdatePointCode(String type) {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
if (date.getTime() - this.update_point_require_time.getTime() < (long) this.update_point_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.update_point_require_time_out);
return;
} else {
this.update_point_require_time = new Date();
Instruction instruction = checkInst();
if (ObjectUtil.isEmpty(instruction)) {
message = "one_message9";
@@ -751,7 +753,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
if (type.equals(StandarStirageErroEnum.BLOCK_IN.getType()) || type.equals(StandarStirageErroEnum.FILL.getType())) {
// updateData2(poinCode, point, split, vehicleCode);
updateData2(poinCode, point, split, vehicleCode);
List list = new ArrayList();
String x = point.getExtraValue().get("x").toString();
String y = split[1];
@@ -1059,12 +1061,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
return true;
}
private void stragetySort(StackerStrategyDto stragety, List<Instruction> instructionList, List<Instruction> instructionStragetyList) {
private void stragetySort(StackerStrategyDto stragety, List<Instruction> instructionList, List<Instruction> instructionStragetyList) {
List<StackerInstruction> plan = stragety.getPlan();
Map<String, List<Instruction>> startDeviceCodes = instructionList.stream().collect(Collectors.groupingBy(Instruction::getStart_device_code));
Map<String, List<Instruction>> endDeviceCodes = instructionList.stream().collect(Collectors.groupingBy(Instruction::getNext_device_code));
//初始化队列
if (CollUtil.isNotEmpty(plan)){
if (CollUtil.isNotEmpty(plan)) {
if (tackerInstructionQueue.isEmpty()) {
for (StackerInstruction stackerInstruction : plan) {
tackerInstructionQueue.offer(stackerInstruction);
@@ -1093,11 +1095,11 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
//起点终点都为空根据类型做任务
if (StrUtil.isEmpty(stackerInstruction.getFrom()) && StrUtil.isEmpty(stackerInstruction.getTo())){
if (StrUtil.isEmpty(stackerInstruction.getFrom()) && StrUtil.isEmpty(stackerInstruction.getTo())) {
//入库
if (CustomPolicyTaskTypeEnum.IN.getCode().equals(stackerInstruction.getType())){
if (CustomPolicyTaskTypeEnum.IN.getCode().equals(stackerInstruction.getType())) {
List<Instruction> instIn = instructionList.stream().filter(item -> item.getNext_device_code().contains("L")).collect(Collectors.toList());
if (CollUtil.isNotEmpty(instIn)){
if (CollUtil.isNotEmpty(instIn)) {
instructionStragetyList.add(instIn.get(0));
//从头移除队列
tackerInstructionQueue.poll();
@@ -1105,9 +1107,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
//出库
if (CustomPolicyTaskTypeEnum.OUT.getCode().equals(stackerInstruction.getType())){
if (CustomPolicyTaskTypeEnum.OUT.getCode().equals(stackerInstruction.getType())) {
List<Instruction> instOut = instructionList.stream().filter(item -> item.getStart_device_code().contains("L")).collect(Collectors.toList());
if (CollUtil.isNotEmpty(instOut)){
if (CollUtil.isNotEmpty(instOut)) {
instructionStragetyList.add(instOut.get(0));
//从头移除队列
tackerInstructionQueue.poll();
@@ -1115,9 +1117,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
//移库
if (CustomPolicyTaskTypeEnum.MOVE.getCode().equals(stackerInstruction.getType())){
List<Instruction> instInAndOut = instructionList.stream().filter(item -> item.getStart_device_code().contains("L") && item.getNext_device_code().contains("L") ).collect(Collectors.toList());
if (CollUtil.isNotEmpty(instInAndOut)){
if (CustomPolicyTaskTypeEnum.MOVE.getCode().equals(stackerInstruction.getType())) {
List<Instruction> instInAndOut = instructionList.stream().filter(item -> item.getStart_device_code().contains("L") && item.getNext_device_code().contains("L")).collect(Collectors.toList());
if (CollUtil.isNotEmpty(instInAndOut)) {
instructionStragetyList.add(instInAndOut.get(0));
//从头移除队列
tackerInstructionQueue.poll();

View File

@@ -36,11 +36,10 @@ public class LuceneExecuteLogServiceImpl implements LuceneExecuteLogService {
@Override
public void deviceExecuteLog(LuceneLogDto luceneLogDto) {
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
// ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
luceneLogDto.setLogType(LogTypeEnum.DEVICE_LOG.getDesc());
String logLevel = paramService.findByCode(AcsConfig.LOGLEVEL).getValue();
if(StrUtil.isNotEmpty(logLevel) && isNumeric(logLevel) &&
ObjectUtil.isNotEmpty(luceneLogDto.getLog_level()) && (luceneLogDto.getLog_level() >= Integer.parseInt(logLevel))){
// String logLevel = paramService.findByCode(AcsConfig.LOGLEVEL).getValue();
if(ObjectUtil.isNotEmpty(luceneLogDto.getLog_level()) && (luceneLogDto.getLog_level() >= 3)){
log.info("{}", JSON.toJSONString(luceneLogDto));
}
}
@@ -51,11 +50,10 @@ public class LuceneExecuteLogServiceImpl implements LuceneExecuteLogService {
@Override
public void interfaceExecuteLog(LuceneLogDto luceneLogDto) {
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
// ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
luceneLogDto.setLogType(LogTypeEnum.INTERFACE_LOG.getDesc());
String logLevel = paramService.findByCode(AcsConfig.LOGLEVEL).getValue();
if(StrUtil.isNotEmpty(logLevel) && isNumeric(logLevel) &&
ObjectUtil.isNotEmpty(luceneLogDto.getLog_level()) && (luceneLogDto.getLog_level() >= Integer.parseInt(logLevel))){
// String logLevel = paramService.findByCode(AcsConfig.LOGLEVEL).getValue();
if(ObjectUtil.isNotEmpty(luceneLogDto.getLog_level()) && (luceneLogDto.getLog_level() >= 3)){
log.info("{}", JSON.toJSONString(luceneLogDto));
}
}

View File

@@ -207,6 +207,7 @@ public class CreateDDJInst {
if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
log.error("输送机,{}未联机或执行中", next_device_code);
((BeltConveyorDeviceDriver) nextDevice.getDeviceDriver()).setNotCreateInstMessage("one_message7");
((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("无法创建堆垛机指令的原因DDJ对接位"+next_device_code+"条件不满足!");
continue;
}
}

View File

@@ -15,11 +15,11 @@ spring:
password: ${DB_PWD:123456}
# password: ${DB_PWD:p@ssw0rd}
# 初始连接数
initial-size: 5
initial-size: 20
# 最小连接数
min-idle: 15
min-idle: 20
# 最大连接数
max-active: 30
max-active: 200
# 超时时间(以秒数为单位)
remove-abandoned-timeout: 180
# 获取连接超时时间

View File

@@ -70,7 +70,7 @@ spring:
tryInterrupt: true
allowCoreThreadTimeOut: true # 是否允许核心线程池超时默认false
waitForTasksToCompleteOnShutdown: true # 参考spring线程池设计优雅关闭线程池默认true
awaitTerminationSeconds: 5 # 优雅关闭线程池时阻塞等待线程池中任务执行时间默认3单位s
awaitTerminationSeconds: 15 # 优雅关闭线程池时阻塞等待线程池中任务执行时间默认3单位s
preStartAllCoreThreads: false # 是否预热所有核心线程默认false
runTimeout: 10000 # 任务执行超时阈值单位ms默认0不统计
queueTimeout: 1000 # 任务在队列等待超时阈值单位ms默认0不统计