|
|
@ -3,6 +3,7 @@ package org.nl.acs.device_driver.lnsh.lnsh_press; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.http.HttpResponse; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.Setter; |
|
|
@ -11,9 +12,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.Resp; |
|
|
|
import org.nl.acs.ext.wms.service.AcsToWmsService; |
|
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
|
import org.nl.acs.instruction.service.dto.Instruction; |
|
|
@ -24,12 +28,15 @@ import org.nl.acs.order.service.ProduceshiftorderService; |
|
|
|
import org.nl.acs.order.service.dto.ProduceshiftorderDto; |
|
|
|
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 org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
@ -59,6 +66,8 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De |
|
|
|
|
|
|
|
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean("produceshiftorderServiceImpl"); |
|
|
|
|
|
|
|
LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); |
|
|
|
|
|
|
|
//放货准备锁
|
|
|
|
String putReadyLock = null; |
|
|
|
//有货标记
|
|
|
@ -125,7 +134,7 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De |
|
|
|
mode = this.itemProtocol.getMode(); |
|
|
|
error = this.itemProtocol.getError(); |
|
|
|
status = this.itemProtocol.getStatus(); |
|
|
|
open_time = this.itemProtocol.getOpen_time(); |
|
|
|
//open_time = this.itemProtocol.getOpen_time();
|
|
|
|
standby_time = this.itemProtocol.getStandby_time(); |
|
|
|
production_time = this.itemProtocol.getProduction_time(); |
|
|
|
error_time = this.itemProtocol.getError_time(); |
|
|
@ -191,6 +200,8 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception var17) { |
|
|
|
log.info(var17.getMessage()); |
|
|
|
message = "错误:" + var17.getMessage(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -211,36 +222,24 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De |
|
|
|
message = ""; |
|
|
|
Instruction instruction = null; |
|
|
|
List toInstructions; |
|
|
|
switch (mode) { |
|
|
|
case 1: |
|
|
|
log.debug("设备运转模式:等待工作"); |
|
|
|
return; |
|
|
|
case 2: |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
//排产单确认
|
|
|
|
if (!requireSucess && !"0".equals(order_No) && StrUtil.isNotBlank(order_No)) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("workorder_code", order_No); |
|
|
|
json.put("type", "1"); |
|
|
|
enterProduction(json); |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
//工单完成反馈
|
|
|
|
if (!requireSucess && !"0".equals(order_No) && StrUtil.isNotBlank(order_No)) { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("workorder_code", order_No); |
|
|
|
json.put("qty", qty); |
|
|
|
json.put("unqualified_qty", unqualified); |
|
|
|
json.put("type", "2"); |
|
|
|
enterProduction(json); |
|
|
|
} else { |
|
|
|
message = "无效模式请求,驱动未配置此请求方法"; |
|
|
|
} |
|
|
|
break; |
|
|
|
} else { |
|
|
|
message = "无请求"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
last_mode = mode; |
|
|
|
last_status = status; |
|
|
@ -267,6 +266,72 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 请求 |
|
|
|
* |
|
|
|
* @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 order_verify() { |
|
|
|
if (!"0".equals(order_No) && StrUtil.isNotBlank(order_No)) { |
|
|
|
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.setOrder_code(this.getOrder_No()); |
|
|
|
message = RequestMethodEnum.getName("order_verify") + "order_verify 接口请求LMS..."; |
|
|
|
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request))); |
|
|
|
Resp resp = acsToWmsService.applyTask(request); |
|
|
|
if (resp.getCode() == 200) { |
|
|
|
this.writing(this.mode); |
|
|
|
this.setRequireSucess(true); |
|
|
|
} else { |
|
|
|
this.writing(400); |
|
|
|
message = RequestMethodEnum.getName("order_verify") + "order_verify 接口请求失败" + resp.getMessage(); |
|
|
|
} |
|
|
|
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message)); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
public synchronized boolean order_finish() { |
|
|
|
if (!"0".equals(order_No) && StrUtil.isNotBlank(order_No)) { |
|
|
|
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.setOrder_code(this.getOrder_No()); |
|
|
|
message = RequestMethodEnum.getName("order_finish") + "order_finish 接口请求LMS..."; |
|
|
|
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message + "参数:" + JSON.toJSONString(request))); |
|
|
|
Resp resp = acsToWmsService.applyTask(request); |
|
|
|
if (resp.getCode() == 200) { |
|
|
|
this.writing(this.mode); |
|
|
|
this.setRequireSucess(true); |
|
|
|
} else { |
|
|
|
this.writing(400); |
|
|
|
message = RequestMethodEnum.getName("order_finish") + "order_finish 接口请求失败" + resp.getMessage();; |
|
|
|
} |
|
|
|
lucene.deviceExecuteLog(new LuceneLogDto(this.device_code, message)); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 排产单确认 |
|
|
|
* |
|
|
|