|
@ -7,12 +7,14 @@ import lombok.extern.slf4j.Slf4j; |
|
|
import net.sf.json.JSONArray; |
|
|
import net.sf.json.JSONArray; |
|
|
import net.sf.json.JSONObject; |
|
|
import net.sf.json.JSONObject; |
|
|
import org.nl.acs.agv.server.AgvService; |
|
|
import org.nl.acs.agv.server.AgvService; |
|
|
|
|
|
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; |
|
|
import org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver; |
|
|
import org.nl.acs.device_driver.xg_agv.XgagvDeviceDriver; |
|
|
import org.nl.acs.ext.wms.service.AcsToWmsZDService; |
|
|
import org.nl.acs.ext.wms.service.AcsToWmsZDService; |
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
import org.nl.acs.instruction.service.dto.Instruction; |
|
|
import org.nl.acs.instruction.service.dto.Instruction; |
|
|
import org.nl.acs.opc.Device; |
|
|
import org.nl.acs.opc.Device; |
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
|
|
|
import org.nl.acs.opc.DeviceAppServiceImpl; |
|
|
import org.nl.acs.opc.DeviceType; |
|
|
import org.nl.acs.opc.DeviceType; |
|
|
import org.nl.acs.task.service.TaskService; |
|
|
import org.nl.acs.task.service.TaskService; |
|
|
import org.nl.acs.task.service.dto.TaskDto; |
|
|
import org.nl.acs.task.service.dto.TaskDto; |
|
@ -55,6 +57,8 @@ public class XgInstUpdate { |
|
|
if (!StrUtil.equals(inst.getSend_status(), "1")) { |
|
|
if (!StrUtil.equals(inst.getSend_status(), "1")) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; |
|
|
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
Device device = deviceAppService.findDeviceByCode(inst.getCarno()); |
|
|
Device device = deviceAppService.findDeviceByCode(inst.getCarno()); |
|
|
xgagvDeviceDriver = (XgagvDeviceDriver) device.getDeviceDriver(); |
|
|
xgagvDeviceDriver = (XgagvDeviceDriver) device.getDeviceDriver(); |
|
|
String ip = (String) xgagvDeviceDriver.getDevice().getExtraValue().get("agv_ip"); |
|
|
String ip = (String) xgagvDeviceDriver.getDevice().getExtraValue().get("agv_ip"); |
|
@ -80,21 +84,23 @@ public class XgInstUpdate { |
|
|
} |
|
|
} |
|
|
if (execute_status.equals("1")){ |
|
|
if (execute_status.equals("1")){ |
|
|
//判断AGV是否到达A点,1100接口 task_status = 4 target_id = inst_code+execute_status
|
|
|
//判断AGV是否到达A点,1100接口 task_status = 4 target_id = inst_code+execute_status
|
|
|
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204, "044C", null); |
|
|
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204, "5A01000000000000044C044C00000000", null); |
|
|
String task_status = jsonObject.getString("task_status"); |
|
|
String task_status = jsonObject.getString("task_status"); |
|
|
String target_id = jsonObject.getString("target_id"); |
|
|
String target_id = jsonObject.getString("target_id"); |
|
|
if (task_status.equals("4")&&target_id.equals(inst.getStart_point_code())){ |
|
|
if (task_status.equals("4")&&target_id.equals(inst.getStart_point_code())){ |
|
|
//调用中鼎接口查询A点输送线的状态是否正常是否有货
|
|
|
//如果起点输送线待机,给输送线下发滚筒滚动指令
|
|
|
JSONObject device_info = new JSONObject(); |
|
|
String start_device = inst.getStart_device_code(); |
|
|
device_info.put("device_code",inst.getStart_point_code()); |
|
|
Device startdevice = appService.findDeviceByCode(start_device); |
|
|
HttpResponse httpResponse = acsToWmsZDService.deviceStatusQuery(device_info); |
|
|
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){ |
|
|
if (httpResponse.getStatus() == 200){ |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); |
|
|
JSONObject jo = JSONObject.fromObject(httpResponse.body()); |
|
|
if (standardInspectSiteDeviceDriver.getMode() == 2){ |
|
|
if (jo.getString("responseCode").equals("1")&&jo.getString("status").equals("1")&&jo.getBoolean("hasGoods")){ |
|
|
standardInspectSiteDeviceDriver.writing(1); |
|
|
|
|
|
} |
|
|
|
|
|
if (standardInspectSiteDeviceDriver.getHasGoods() == 1){ |
|
|
//下发A的取货动作
|
|
|
//下发A的取货动作
|
|
|
JSONObject order = new JSONObject(); |
|
|
JSONObject order = new JSONObject(); |
|
|
order.put("load",true); |
|
|
order.put("load",true); |
|
|
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, "0BEB", order); |
|
|
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, "5A010000000000000BEB0BEB00000000", order); |
|
|
if (result.getString("ret_code").equals("0")){ |
|
|
if (result.getString("ret_code").equals("0")){ |
|
|
inst.setExecute_status("2"); |
|
|
inst.setExecute_status("2"); |
|
|
instructionService.update(inst); |
|
|
instructionService.update(inst); |
|
@ -108,7 +114,7 @@ public class XgInstUpdate { |
|
|
if (execute_status.equals("2")){ |
|
|
if (execute_status.equals("2")){ |
|
|
boolean is_ok = false; |
|
|
boolean is_ok = false; |
|
|
//查询是否取货完成,通过查询DO状态是否低电平
|
|
|
//查询是否取货完成,通过查询DO状态是否低电平
|
|
|
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"044C", null); |
|
|
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"5A01000000000000044C044C00000000", null); |
|
|
JSONArray do_arr = jsonObject.getJSONArray("DO"); |
|
|
JSONArray do_arr = jsonObject.getJSONArray("DO"); |
|
|
for (int j = 0; j <do_arr.size(); j++) { |
|
|
for (int j = 0; j <do_arr.size(); j++) { |
|
|
JSONObject do_jo = do_arr.getJSONObject(j); |
|
|
JSONObject do_jo = do_arr.getJSONObject(j); |
|
@ -136,22 +142,24 @@ public class XgInstUpdate { |
|
|
} |
|
|
} |
|
|
if (execute_status.equals("3")){ |
|
|
if (execute_status.equals("3")){ |
|
|
//判断AGV是否到达B点,1100接口 task_status = 4 target_id = inst_code+execute_status
|
|
|
//判断AGV是否到达B点,1100接口 task_status = 4 target_id = inst_code+execute_status
|
|
|
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"044C", null); |
|
|
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"5A01000000000000044C044C00000000", null); |
|
|
String task_status = jsonObject.getString("task_status"); |
|
|
String task_status = jsonObject.getString("task_status"); |
|
|
String target_id = jsonObject.getString("target_id"); |
|
|
String target_id = jsonObject.getString("target_id"); |
|
|
if (task_status.equals("4")&&target_id.equals(inst.getNext_point_code())){ |
|
|
if (task_status.equals("4")&&target_id.equals(inst.getNext_point_code())){ |
|
|
//查询B点输送线的状态,下发B的放货动作
|
|
|
//查询B点输送线的状态,下发B的放货动作
|
|
|
//调用中鼎接口查询A点输送线的状态是否正常是否有货
|
|
|
//如果起点输送线待机,给输送线下发滚筒滚动指令
|
|
|
JSONObject device_info = new JSONObject(); |
|
|
String next_device = inst.getNext_device_code(); |
|
|
device_info.put("device_code",inst.getStart_point_code()); |
|
|
Device nextdevice = appService.findDeviceByCode(next_device); |
|
|
HttpResponse httpResponse = acsToWmsZDService.deviceStatusQuery(device_info); |
|
|
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){ |
|
|
if (httpResponse.getStatus() == 200){ |
|
|
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); |
|
|
JSONObject jo = JSONObject.fromObject(httpResponse.body()); |
|
|
if (standardInspectSiteDeviceDriver.getMode() == 2){ |
|
|
if (jo.getString("responseCode").equals("1")&&jo.getString("status").equals("1")&&!jo.getBoolean("hasGoods")){ |
|
|
standardInspectSiteDeviceDriver.writing(1); |
|
|
|
|
|
} |
|
|
|
|
|
if (standardInspectSiteDeviceDriver.getHasGoods() == 0){ |
|
|
//下发B的放货动作
|
|
|
//下发B的放货动作
|
|
|
JSONObject order = new JSONObject(); |
|
|
JSONObject order = new JSONObject(); |
|
|
order.put("unload",true); |
|
|
order.put("unload",true); |
|
|
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, "0BEB", order); |
|
|
JSONObject result = xgagvDeviceDriver.applyAgv(ip, 19206, "5A010000000000000BEB0BEB00000000", order); |
|
|
if (result.getString("ret_code").equals("0")){ |
|
|
if (result.getString("ret_code").equals("0")){ |
|
|
inst.setExecute_status("4"); |
|
|
inst.setExecute_status("4"); |
|
|
instructionService.update(inst); |
|
|
instructionService.update(inst); |
|
@ -166,7 +174,7 @@ public class XgInstUpdate { |
|
|
//查询是否放货完成
|
|
|
//查询是否放货完成
|
|
|
boolean is_ok = false; |
|
|
boolean is_ok = false; |
|
|
//查询是否取货完成,通过查询DO状态是否低电平
|
|
|
//查询是否取货完成,通过查询DO状态是否低电平
|
|
|
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"044C", null); |
|
|
JSONObject jsonObject = xgagvDeviceDriver.applyAgv(ip,19204 ,"5A01000000000000044C044C00000000", null); |
|
|
JSONArray do_arr = jsonObject.getJSONArray("DO"); |
|
|
JSONArray do_arr = jsonObject.getJSONArray("DO"); |
|
|
for (int j = 0; j <do_arr.size(); j++) { |
|
|
for (int j = 0; j <do_arr.size(); j++) { |
|
|
JSONObject do_jo = do_arr.getJSONObject(j); |
|
|
JSONObject do_jo = do_arr.getJSONObject(j); |
|
|