|
|
@ -19,6 +19,7 @@ import org.nl.acs.opc.Device; |
|
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
|
import org.nl.acs.task.service.TaskService; |
|
|
|
import org.nl.acs.task.service.dto.TaskDto; |
|
|
|
import org.nl.modules.common.exception.BadRequestException; |
|
|
|
import org.nl.modules.wql.core.bean.WQLObject; |
|
|
|
import org.nl.modules.wql.util.SpringContextHolder; |
|
|
|
|
|
|
@ -102,6 +103,7 @@ public class NL4StationDeviceDriver extends AbstractOpcDeviceDriver implements D |
|
|
|
if (mode == 2) { |
|
|
|
this.writing("to_command", "0"); |
|
|
|
} |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", "mode信号发生变化,进行复位标记,此时标记值:" + requireSuccess); |
|
|
|
this.deviceExecuteLogService.deviceItemValue(this.currentDeviceCode, ItemProtocol.ITEM_MODE, String.valueOf(mode)); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", ItemProtocol.ITEM_MODE + " " + this.lastMode + " -> " + this.mode); |
|
|
|
} |
|
|
@ -223,6 +225,19 @@ public class NL4StationDeviceDriver extends AbstractOpcDeviceDriver implements D |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void unLock(Device device1, Device device2, Device device3, Device device4) { |
|
|
|
JSONObject rpUpdate = new JSONObject(); |
|
|
|
rpUpdate.put("islock", "0"); |
|
|
|
rpUpdate.put("update_by", "auto"); |
|
|
|
rpUpdate.put("update_time", DateUtil.now()); |
|
|
|
WQLObject.getWQLObject("acs_device_runpoint").update(rpUpdate, "device_code IN ('" + device1.getDevice_code() + "', '" + device2.getDevice_code() + "', '" + device3.getDevice_code() + "', '" + device4.getDevice_code() + "')"); |
|
|
|
|
|
|
|
device1.setIslock("0"); |
|
|
|
device2.setIslock("0"); |
|
|
|
device3.setIslock("0"); |
|
|
|
device4.setIslock("0"); |
|
|
|
} |
|
|
|
|
|
|
|
@NotNull |
|
|
|
private TaskDto creatTask(Device device1, Device device2, Device device3, Device device4, RequestMethodEnum method) { |
|
|
|
JSONObject rpUpdate = new JSONObject(); |
|
|
@ -273,37 +288,79 @@ public class NL4StationDeviceDriver extends AbstractOpcDeviceDriver implements D |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean findHasGoodsIsFull(JSONArray deviceCodes) { |
|
|
|
for (int i = 0; i < deviceCodes.size(); i++) { |
|
|
|
Device device = this.deviceAppService.findDeviceByCode(deviceCodes.getString(i)); |
|
|
|
if (device != null && device.getHas_goods() == 0) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 门架上料完成 |
|
|
|
* 其余物料上料完成 |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unused") |
|
|
|
public void gantryMaterialFinished() throws Exception { |
|
|
|
synchronized (NL4StationDeviceDriver.class) { |
|
|
|
Device currentDevice = this.deviceAppService.findDeviceByCode(this.currentDeviceCode); |
|
|
|
if ("0".equals(currentDevice.getIslock())) { |
|
|
|
// 门架上料完成放空设备
|
|
|
|
Object gantryDeviceCode1 = this.getDevice().getExtraValue().get("gantry_device_code1"); |
|
|
|
if (ObjectUtil.isEmpty(gantryDeviceCode1)) { |
|
|
|
String message = "门架上料完成放空设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray emptyDeviceCodes = JSONArray.parseArray(gantryDeviceCode1.toString()); |
|
|
|
// 门架上料完成取满设备
|
|
|
|
Object gantryDeviceCode2 = this.getDevice().getExtraValue().get("gantry_device_code2"); |
|
|
|
|
|
|
|
// 其余物料上料完成放空设备
|
|
|
|
Object gantryDeviceCode2 = this.getDevice().getExtraValue().get("gantry_device_code1"); |
|
|
|
if (ObjectUtil.isEmpty(gantryDeviceCode2)) { |
|
|
|
String message = "门架上料完成取满设备未配置。"; |
|
|
|
String message = "其余物料上料完成放空设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray materialDeviceCodes = JSONArray.parseArray(gantryDeviceCode2.toString()); |
|
|
|
JSONArray emptyDeviceCodes = JSONArray.parseArray(gantryDeviceCode2.toString()); |
|
|
|
|
|
|
|
Object gantryDeviceCode3 = null; |
|
|
|
JSONArray materialDeviceCodes = null; |
|
|
|
//查询其余物料上料对接位关联的所有上料对接位
|
|
|
|
Object link_device_code = this.getDevice().getExtraValue().get("link_device_code"); |
|
|
|
if (ObjectUtil.isNotEmpty(link_device_code)) { |
|
|
|
JSONArray linkDeviceCodes = JSONArray.parseArray(link_device_code.toString()); |
|
|
|
boolean flag = this.findHasGoodsIsFull(linkDeviceCodes); |
|
|
|
if (!flag) { |
|
|
|
//否则查询特殊的取满设备
|
|
|
|
gantryDeviceCode3 = this.getDevice().getExtraValue().get("gantry_device_code3"); |
|
|
|
if (ObjectUtil.isEmpty(gantryDeviceCode3)) { |
|
|
|
String message = "其余物料上料完成特殊取满设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
materialDeviceCodes = JSONArray.parseArray(gantryDeviceCode3.toString()); |
|
|
|
} else { |
|
|
|
// 其余物料上料完成取满设备
|
|
|
|
gantryDeviceCode3 = this.getDevice().getExtraValue().get("gantry_device_code2"); |
|
|
|
if (ObjectUtil.isEmpty(gantryDeviceCode3)) { |
|
|
|
String message = "其余物料上料完成取满设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
materialDeviceCodes = JSONArray.parseArray(gantryDeviceCode3.toString()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 其余物料上料完成取满设备
|
|
|
|
gantryDeviceCode3 = this.getDevice().getExtraValue().get("gantry_device_code2"); |
|
|
|
if (ObjectUtil.isEmpty(gantryDeviceCode3)) { |
|
|
|
String message = "其余物料上料完成取满设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
materialDeviceCodes = JSONArray.parseArray(gantryDeviceCode3.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
// 查找合适的放空设备
|
|
|
|
Device emptyDevice = this.findNotHasGoodsDevice(emptyDeviceCodes); |
|
|
|
if (ObjectUtil.isEmpty(emptyDevice)) { |
|
|
|
String message = "未找到合适的门架上料完成放空设备。"; |
|
|
|
String message = "未找到合适的其余物料上料完成放空设备。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
@ -313,14 +370,18 @@ public class NL4StationDeviceDriver extends AbstractOpcDeviceDriver implements D |
|
|
|
// 查找合适的取满设备
|
|
|
|
Device materialDevice = this.findHasGoodsDevice(materialDeviceCodes); |
|
|
|
if (ObjectUtil.isEmpty(materialDevice)) { |
|
|
|
String message = "未找到合适的门架上料完成取满设备。"; |
|
|
|
String message = "未找到合适的其余物料上料完成取满设备。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
assert materialDevice != null; |
|
|
|
|
|
|
|
this.taskService.create(this.creatTask(currentDevice, emptyDevice, materialDevice, currentDevice, RequestMethodEnum.GANTRY_MATERIAL_FINISHED)); |
|
|
|
try { |
|
|
|
this.taskService.create(this.creatTask(currentDevice, emptyDevice, materialDevice, currentDevice, RequestMethodEnum.GANTRY_MATERIAL_FINISHED)); |
|
|
|
} catch (Exception e) { |
|
|
|
this.unLock(currentDevice, emptyDevice, materialDevice, currentDevice); |
|
|
|
throw new BadRequestException(e.getMessage()); |
|
|
|
} |
|
|
|
this.requireSuccess = true; |
|
|
|
this.writing("to_command", this.mode); |
|
|
|
} |
|
|
@ -335,195 +396,58 @@ public class NL4StationDeviceDriver extends AbstractOpcDeviceDriver implements D |
|
|
|
synchronized (NL4StationDeviceDriver.class) { |
|
|
|
Device currentDevice = this.deviceAppService.findDeviceByCode(this.currentDeviceCode); |
|
|
|
if ("0".equals(currentDevice.getIslock())) { |
|
|
|
// 槽钢上料完成取满设备
|
|
|
|
Object channelSteelDeviceCode1 = this.getDevice().getExtraValue().get("channel_steel_device_code1"); |
|
|
|
if (ObjectUtil.isEmpty(channelSteelDeviceCode1)) { |
|
|
|
String message = "槽钢上料完成取满设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray deviceCodes1 = JSONArray.parseArray(channelSteelDeviceCode1.toString()); |
|
|
|
// 槽钢上料完成放满设备
|
|
|
|
Object channelSteelDeviceCode2 = this.getDevice().getExtraValue().get("channel_steel_device_code2"); |
|
|
|
if (ObjectUtil.isEmpty(channelSteelDeviceCode2)) { |
|
|
|
String message = "槽钢上料完成放满设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray deviceCodes2 = JSONArray.parseArray(channelSteelDeviceCode2.toString()); |
|
|
|
// 槽钢上料完成放空设备
|
|
|
|
Object channelSteelDeviceCode4 = this.getDevice().getExtraValue().get("channel_steel_device_code4"); |
|
|
|
if (ObjectUtil.isEmpty(channelSteelDeviceCode4)) { |
|
|
|
Object channelSteelDeviceCode2 = this.getDevice().getExtraValue().get("channel_steel_device_code1"); |
|
|
|
if (ObjectUtil.isEmpty(channelSteelDeviceCode2)) { |
|
|
|
String message = "槽钢上料完成放空设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray deviceCodes4 = JSONArray.parseArray(channelSteelDeviceCode4.toString()); |
|
|
|
JSONArray deviceCodes2 = JSONArray.parseArray(channelSteelDeviceCode2.toString()); |
|
|
|
|
|
|
|
// 查找合适的取满设备
|
|
|
|
Device device1 = this.findHasGoodsDevice(deviceCodes1); |
|
|
|
if (ObjectUtil.isEmpty(device1)) { |
|
|
|
String message = "未找到合适的槽钢上料完成取满设备。"; |
|
|
|
// 槽钢上料完成取满设备
|
|
|
|
Object channelSteelDeviceCode3 = this.getDevice().getExtraValue().get("channel_steel_device_code2"); |
|
|
|
if (ObjectUtil.isEmpty(channelSteelDeviceCode3)) { |
|
|
|
String message = "槽钢上料完成取满设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
assert device1 != null; |
|
|
|
JSONArray deviceCodes3 = JSONArray.parseArray(channelSteelDeviceCode3.toString()); |
|
|
|
|
|
|
|
// 查找合适的放满设备
|
|
|
|
Device device2 = this.findNotHasGoodsDevice(deviceCodes2); |
|
|
|
if (ObjectUtil.isEmpty(device2)) { |
|
|
|
String message = "未找到合适的槽钢上料完成放满设备。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
assert device2 != null; |
|
|
|
|
|
|
|
// 查找合适的放空设备
|
|
|
|
Device device4 = this.findNotHasGoodsDevice(deviceCodes4); |
|
|
|
if (ObjectUtil.isEmpty(device4)) { |
|
|
|
Device device2 = this.findNotHasGoodsDevice(deviceCodes2); |
|
|
|
if (ObjectUtil.isEmpty(device2)) { |
|
|
|
String message = "未找到合适的槽钢上料完成放空设备。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
assert device4 != null; |
|
|
|
|
|
|
|
this.taskService.create(this.creatTask(device1, device2, currentDevice, device4, RequestMethodEnum.CHANNEL_STEEL_MATERIAL_FINISHED)); |
|
|
|
this.requireSuccess = true; |
|
|
|
this.writing("to_command", this.mode); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 槽钢呼叫满料 |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unused") |
|
|
|
public void channelSteelCallMaterial() throws Exception { |
|
|
|
synchronized (NL4StationDeviceDriver.class) { |
|
|
|
Device currentDevice = this.deviceAppService.findDeviceByCode(this.currentDeviceCode); |
|
|
|
if ("0".equals(currentDevice.getIslock())) { |
|
|
|
// 槽钢呼叫满料取满设备
|
|
|
|
Object channelSteelCallMaterialDeviceCode1 = this.getDevice().getExtraValue().get("channel_steel_call_material_device_code1"); |
|
|
|
if (ObjectUtil.isEmpty(channelSteelCallMaterialDeviceCode1)) { |
|
|
|
String message = "槽钢呼叫满料取满设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray deviceCodes1 = JSONArray.parseArray(channelSteelCallMaterialDeviceCode1.toString()); |
|
|
|
// 槽钢呼叫满料取空设备
|
|
|
|
Object channelSteelCallMaterialDeviceCode3 = this.getDevice().getExtraValue().get("channel_steel_call_material_device_code3"); |
|
|
|
if (ObjectUtil.isEmpty(channelSteelCallMaterialDeviceCode3)) { |
|
|
|
String message = "槽钢呼叫满料取空设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray deviceCodes3 = JSONArray.parseArray(channelSteelCallMaterialDeviceCode3.toString()); |
|
|
|
// 槽钢呼叫满料放空设备
|
|
|
|
Object channelSteelCallMaterialDeviceCode4 = this.getDevice().getExtraValue().get("channel_steel_call_material_device_code4"); |
|
|
|
if (ObjectUtil.isEmpty(channelSteelCallMaterialDeviceCode4)) { |
|
|
|
String message = "槽钢呼叫满料放空设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray deviceCodes4 = JSONArray.parseArray(channelSteelCallMaterialDeviceCode4.toString()); |
|
|
|
assert device2 != null; |
|
|
|
|
|
|
|
// 查找合适的取满设备
|
|
|
|
Device device1 = this.findHasGoodsDevice(deviceCodes1); |
|
|
|
if (ObjectUtil.isEmpty(device1)) { |
|
|
|
String message = "未找到合适的槽钢呼叫满料取满设备。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
assert device1 != null; |
|
|
|
|
|
|
|
// 查找合适的取空设备
|
|
|
|
Device device3 = this.findHasGoodsDevice(deviceCodes3); |
|
|
|
if (ObjectUtil.isEmpty(device3)) { |
|
|
|
String message = "未找到合适的槽钢呼叫满料取空设备。"; |
|
|
|
String message = "未找到合适的槽钢上料完成取满设备。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
assert device3 != null; |
|
|
|
|
|
|
|
// 查找合适的放空设备
|
|
|
|
Device device4 = this.findNotHasGoodsDevice(deviceCodes4); |
|
|
|
if (ObjectUtil.isEmpty(device4)) { |
|
|
|
String message = "未找到合适的槽钢呼叫满料放空设备。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
try { |
|
|
|
this.taskService.create(this.creatTask(currentDevice, device2, device3, currentDevice, RequestMethodEnum.CHANNEL_STEEL_MATERIAL_FINISHED)); |
|
|
|
} catch (Exception e) { |
|
|
|
this.unLock(currentDevice, device2, device3, currentDevice); |
|
|
|
throw new BadRequestException(e.getMessage()); |
|
|
|
} |
|
|
|
assert device4 != null; |
|
|
|
|
|
|
|
this.taskService.create(this.creatTask(device1, currentDevice, device3, device4, RequestMethodEnum.CHANNEL_STEEL_CALL_MATERIAL)); |
|
|
|
this.requireSuccess = true; |
|
|
|
this.writing("to_command", this.mode); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 下料完成 |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unused") |
|
|
|
public void productionCompleted() throws Exception { |
|
|
|
synchronized (NL4StationDeviceDriver.class) { |
|
|
|
Device currentDevice = this.deviceAppService.findDeviceByCode(this.currentDeviceCode); |
|
|
|
if ("0".equals(currentDevice.getIslock())) { |
|
|
|
// 下料完成放满设备
|
|
|
|
Object productionCompletedDeviceCode2 = this.getDevice().getExtraValue().get("production_completed_device_code2"); |
|
|
|
if (ObjectUtil.isEmpty(productionCompletedDeviceCode2)) { |
|
|
|
String message = "下料完成放满设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray deviceCodes2 = JSONArray.parseArray(productionCompletedDeviceCode2.toString()); |
|
|
|
// 下料完成取空设备
|
|
|
|
Object productionCompletedDeviceCode3 = this.getDevice().getExtraValue().get("production_completed_device_code3"); |
|
|
|
if (ObjectUtil.isEmpty(productionCompletedDeviceCode3)) { |
|
|
|
String message = "下料完成取空设备未配置。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
JSONArray deviceCodes3 = JSONArray.parseArray(productionCompletedDeviceCode3.toString()); |
|
|
|
|
|
|
|
// 查找合适的放满设备
|
|
|
|
Device device2 = this.findNotHasGoodsDevice(deviceCodes2); |
|
|
|
if (ObjectUtil.isEmpty(device2)) { |
|
|
|
String message = "未找到合适的下料完成放满设备。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
assert device2 != null; |
|
|
|
|
|
|
|
// 查找合适的取空设备
|
|
|
|
Device device3 = this.findHasGoodsDevice(deviceCodes3); |
|
|
|
if (ObjectUtil.isEmpty(device3)) { |
|
|
|
String message = "未找到合适的下料完成取空设备。"; |
|
|
|
this.message = message; |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", message); |
|
|
|
return; |
|
|
|
} |
|
|
|
assert device3 != null; |
|
|
|
|
|
|
|
this.taskService.create(this.creatTask(currentDevice, device2, device3, currentDevice, RequestMethodEnum.PRODUCTION_COMPLETED)); |
|
|
|
this.requireSuccess = true; |
|
|
|
this.writing("to_command", this.mode); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|