rev
This commit is contained in:
@@ -372,7 +372,7 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De
|
||||
request.setDevice_code(this.getDevice_code());
|
||||
request.setRequest_medthod_code(Thread.currentThread().getStackTrace()[1].getMethodName());
|
||||
request.setRequest_medthod_name(RequestMethodEnum.getName(Thread.currentThread().getStackTrace()[1].getMethodName()));
|
||||
request.setWeight(String.valueOf(weight));
|
||||
request.setWeight(String.valueOf(unqualified));
|
||||
request.setOrder_code(String.valueOf(order_No));
|
||||
request.setMaterial_code(String.valueOf(material));
|
||||
ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)), ApplyTaskResponse.class);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.nl.acs.device_driver.lnsh.package_site;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -8,9 +10,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RequestMethodEnum;
|
||||
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.AcsToWmsData.applyTask.ApplyTaskRequest;
|
||||
import org.nl.acs.ext.wms.data.AcsToWmsData.applyTask.ApplyTaskResponse;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
@@ -19,9 +24,12 @@ import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -48,6 +56,9 @@ public class PackageSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||
|
||||
LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
|
||||
|
||||
//放货准备锁
|
||||
String putReadyLock = null;
|
||||
//有货标记
|
||||
@@ -136,7 +147,7 @@ public class PackageSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
action = this.itemProtocol.getAction();
|
||||
ioaction = this.itemProtocol.getIoaction();
|
||||
error = this.itemProtocol.getError();
|
||||
vehicle_code = this.itemProtocol.getVehicle_code();
|
||||
vehicle_code = this.itemProtocol.getBarcode();
|
||||
vehicle_type = this.itemProtocol.getVehicle_type();
|
||||
|
||||
if (mode != last_mode) {
|
||||
@@ -188,13 +199,22 @@ public class PackageSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
switch (mode) {
|
||||
case 1:
|
||||
log.debug("设备运转模式:等待工作");
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 5:
|
||||
|
||||
|
||||
if (mode > 2 && !requireSucess) {
|
||||
if (ObjectUtil.isNotEmpty(this.device.getExtraValue().get(String.valueOf(mode)))) {
|
||||
String modethod = this.device.getExtraValue().get(String.valueOf(mode)).toString();
|
||||
try {
|
||||
applyRequest(modethod);
|
||||
} catch (Exception e) {
|
||||
message = "错误:" + e.getMessage();
|
||||
this.setIserror(true);
|
||||
}
|
||||
} else {
|
||||
message = "无效模式请求,驱动未配置此请求方法";
|
||||
}
|
||||
} else {
|
||||
message = "无请求";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,6 +231,58 @@ public class PackageSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
public synchronized boolean applyRequest(String modethod) throws Exception {
|
||||
Object obj1 = this;
|
||||
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);
|
||||
return false;
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
Object obj = this.getClass().getDeclaredConstructor().newInstance();
|
||||
Method method1 = this.getClass().getMethod(modethod, null);
|
||||
method1.invoke(this, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public synchronized boolean apply_labelling() {
|
||||
if(move == 1) {
|
||||
ApplyTaskRequest request = new ApplyTaskRequest();
|
||||
request.setDevice_code(this.getDevice_code());
|
||||
request.setRequest_medthod_code(Thread.currentThread().getStackTrace()[1].getMethodName());
|
||||
request.setRequest_medthod_name(RequestMethodEnum.getName(Thread.currentThread().getStackTrace()[1].getMethodName()));
|
||||
request.setVehicle_code(String.valueOf(vehicle_code));
|
||||
ApplyTaskResponse resp = JSON.toJavaObject(JSONObject.parseObject(acsToWmsService.applyTask(request)),ApplyTaskResponse.class);
|
||||
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 接口请求LMS...";
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request)));
|
||||
|
||||
if (resp.getCode() == 200) {
|
||||
this.writing("to_message",resp.getLabel_message());
|
||||
this.writing(200);
|
||||
this.setRequireSucess(true);
|
||||
} else {
|
||||
this.writing(400);
|
||||
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 接口请求失败" + resp.getMessage();
|
||||
|
||||
}
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "返回参数:" + JSON.toJSONString(resp)));
|
||||
|
||||
return true;
|
||||
} else {
|
||||
message = RequestMethodEnum.getName("apply_labelling") + "apply_labelling 设备无货未请求LMS...";
|
||||
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + org.nl.acs.device_driver.lnsh.lnsh_station.ItemProtocol.item_to_command;
|
||||
|
||||
@@ -23,7 +23,9 @@ public class ApplyTaskResponse extends BaseResponse {
|
||||
|
||||
private String weight;
|
||||
|
||||
|
||||
//private String is_order_finish;
|
||||
/**
|
||||
* 贴标新鲜
|
||||
*/
|
||||
private String label_message;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user