add: 木箱入库、装箱入库、空木箱出库驱动开发(后端)

This commit is contained in:
2024-01-16 13:42:10 +08:00
parent 2fad2071b3
commit 0ca256d734
10 changed files with 81 additions and 21 deletions

View File

@@ -1367,6 +1367,7 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
@Override
public JSONObject queryDriverConfigByDeviceId(String device_id, String driver_code) {
final JSONObject extraObj = new JSONObject();
DeviceDto dto = this.findById(device_id);
if (ObjectUtil.isNull(dto)) {
return new JSONObject();
@@ -1386,7 +1387,6 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
}
// JSONArray arr = WQLObject.getWQLObject("acs_device_extra").query("filed_type ='01' and device_id = '" + device_id + "'").getResultJSONArray(0);
List<DeviceExtra> deviceExtraList = new LambdaQueryChainWrapper<>(deviceExtraMapper)
.eq(DeviceExtra::getDevice_id, device_id)
.eq(DeviceExtra::getFiled_type, "01")

View File

@@ -1,4 +1,4 @@
package org.nl.acs.device_driver.one_conveyor.box_out_subvolumes_conveyor;
package org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device.domain.Device;
@@ -16,7 +16,7 @@ import java.util.List;
*
*/
@Service
public class BoxOutSubvolumesConveyorDefination implements OpcDeviceDriverDefination {
public class BoxSubvolumesConveyorDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "box_out_subvolumes_conveyor";
@@ -34,13 +34,13 @@ public class BoxOutSubvolumesConveyorDefination implements OpcDeviceDriverDefina
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new BoxOutSubvolumesConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
return (new BoxSubvolumesConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return BoxOutSubvolumesConveyorDeviceDriver.class;
return BoxSubvolumesConveyorDeviceDriver.class;
}
@Override

View File

@@ -1,4 +1,4 @@
package org.nl.acs.device_driver.one_conveyor.box_out_subvolumes_conveyor;
package org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
@@ -20,7 +20,6 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService;
@@ -44,7 +43,7 @@ import java.util.concurrent.ThreadPoolExecutor;
@Slf4j
@Data
@RequiredArgsConstructor
public class BoxOutSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
protected ItemProtocol itemProtocol = new ItemProtocol(this);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);

View File

@@ -1,4 +1,4 @@
package org.nl.acs.device_driver.one_conveyor.box_out_subvolumes_conveyor;
package org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
@@ -72,14 +72,14 @@ public class ItemProtocol {
private BoxOutSubvolumesConveyorDeviceDriver driver;
private BoxSubvolumesConveyorDeviceDriver driver;
public int getContainer_type() {
return this.getOpcIntegerValue(item_container_type);
}
public ItemProtocol(BoxOutSubvolumesConveyorDeviceDriver driver) {
public ItemProtocol(BoxSubvolumesConveyorDeviceDriver driver) {
this.driver = driver;
}

View File

@@ -4,6 +4,7 @@ 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 cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@@ -18,6 +19,8 @@ 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.enums.StorageTypeEnum;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
@@ -59,6 +62,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
//工作模式
int mode = 0;
int last_mode = 0;
@@ -224,6 +229,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
if (error != last_error) {
//存在报警信号,则下发去异常处理位的任务
applyErrorTask();
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);
@@ -259,7 +265,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
List toInstructions;
//木箱入库申请入库任务
if (mode == 6 && !requireSucess){
applyIn();
}
//申请任务
@@ -312,6 +318,38 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
last_barcode = barcode;
}
private void applyErrorTask() {
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
param.put("vehicle_code", barcode);
param.put("type", StorageTypeEnum.ERROR.getType());
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请入库任务,参数:" + param);
HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) {
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请入库任务,接口返回:" + response.body());
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void applyIn() {
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
param.put("vehicle_code", barcode);
param.put("type", StorageTypeEnum.STORAGE.getType());
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请入库任务,参数:" + param);
HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) {
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请入库任务,接口返回:" + response.body());
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void updateInstruct() {
if (mode == 3 && task > 0) {
Date date = new Date();
@@ -333,6 +371,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
}
}
}
}

View File

@@ -16,10 +16,9 @@ import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.FeedLmsRealFailed;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.box_manipulator_site.BoxManipulatorSiteDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.device_driver.one_conveyor.box_out_subvolumes_conveyor.BoxOutSubvolumesConveyorDeviceDriver;
import org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor.BoxSubvolumesConveyorDeviceDriver;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
@@ -369,7 +368,7 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
} else {
this.instruction_require_time = date;
//找符合条件的任务
BoxOutSubvolumesConveyorDeviceDriver boxOutSubvolumesConveyorDeviceDriver = new BoxOutSubvolumesConveyorDeviceDriver();
BoxSubvolumesConveyorDeviceDriver boxOutSubvolumesConveyorDeviceDriver = new BoxSubvolumesConveyorDeviceDriver();
String deviceCode = boxOutSubvolumesConveyorDeviceDriver.getDevice_code();
TaskDto taskDto = taskserver.findByEndCodeAndReady(deviceCode, TaskTypeEnum.Box_Package.getIndex());
if (ObjectUtil.isNotEmpty(taskDto)) {

View File

@@ -14,7 +14,7 @@ import java.util.List;
public class BoxStorageManipulatorDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "box_storage";
return "box_storage_manipulator";
}
@Override

View File

@@ -18,8 +18,7 @@ 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.device_driver.one_conveyor.box_out_subvolumes_conveyor.BoxOutSubvolumesConveyorDeviceDriver;
import org.nl.acs.device_driver.one_conveyor.box_storage_out_conveyor.BoxStorageOutConveyorDeviceDriver;
import org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor.BoxSubvolumesConveyorDeviceDriver;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
@@ -324,7 +323,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
} else {
this.instruction_require_time = date;
//找终点为入库输送线工位任务类型为行架的任务
BoxOutSubvolumesConveyorDeviceDriver boxOutSubvolumesConveyorDeviceDriver = new BoxOutSubvolumesConveyorDeviceDriver();
BoxSubvolumesConveyorDeviceDriver boxOutSubvolumesConveyorDeviceDriver = new BoxSubvolumesConveyorDeviceDriver();
String deviceCode = boxOutSubvolumesConveyorDeviceDriver.getDevice_code();
TaskDto taskDto = taskserver.findByEndCodeAndReady(deviceCode, TaskTypeEnum.Box_Storage.getIndex());
if (ObjectUtil.isNotEmpty(taskDto)) {

View File

@@ -1,2 +1,26 @@
package org.nl.acs.enums;public enum StorageTypeEnum {
package org.nl.acs.enums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum StorageTypeEnum {
STORAGE("1", "入库任务"),
DISKS_IN("2", "空盘入库"),
DISKS_OUT("3", "空盘出库"),
ERROR("4", "异常处理位");
/**
* 索引
*/
private String type;
/**
* 编码
*/
private String value;
}

View File

@@ -490,7 +490,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
task_code = CodeUtil.getNewCode("TASK_NO");
task_code = CommonFinalParam.HYPHEN_ + task_code;
}
String start_point_code = dto.getStart_point_code();
String start_point_code;
String next_point_code = dto.getNext_point_code();
String start_device_code = dto.getStart_device_code();
String next_device_code = dto.getNext_device_code();