72 changed files with 2826 additions and 1666 deletions
@ -0,0 +1,130 @@ |
|||
package org.nl.acs.device_driver; |
|||
|
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
|
|||
/** |
|||
* 驱动类型 |
|||
* https://blog.csdn.net/moneyshi/article/details/82978073
|
|||
*/ |
|||
public enum RequestMethodEnum { |
|||
order_verify(1, "order_verify", "人工排产确认"), |
|||
|
|||
order_finish(2, "order_finish", "工单完成"), |
|||
|
|||
apply_put_full_vehicle(3, "apply_put_full_vehicle", "申请补满料盅托盘(叫料)"), |
|||
|
|||
apply_put_empty_vehicle(4, "apply_put_empty_vehicle", "申请补空料盅托盘(叫空盘)"), |
|||
|
|||
apply_take_empty_vehicle(5, "apply_take_empty_vehicle", "申请取走空料盅托盘(取空盘)"), |
|||
|
|||
apply_take_full_vehicle(6, "apply_take_full_vehicle", "申请取走满料盅托盘(入库)"), |
|||
|
|||
apply_force_take_full_vehicle(7, "apply_force_take_full_vehicle", "申请强制取走满料盅托盘(强制入库)"), |
|||
|
|||
apply_force_take_full_vehicle_in_storage(8, "apply_force_take_full_vehicle_in_storage", "申请强制满托入缓存"), |
|||
|
|||
barcode_sucess_apply(9, "barcode_sucess_apply", "扫码成功申请"), |
|||
|
|||
get_vehicle_info(10, "get_vehicle_info", "获取组盘信息"), |
|||
|
|||
force_no_package(11, "force_no_package", "强制去包装位-不包装"), |
|||
|
|||
apply_labelling(12, "apply_labelling", "申请贴标"), |
|||
|
|||
apply_one_grab(13, "apply_one_grab", "单次放置完成"); |
|||
|
|||
|
|||
//驱动索引
|
|||
private int index; |
|||
//驱动编码
|
|||
private String code; |
|||
// 驱动名字
|
|||
private String name; |
|||
//驱动描述
|
|||
private String desc; |
|||
//设备驱动类型
|
|||
private String type; |
|||
|
|||
// 构造方法
|
|||
RequestMethodEnum(int index, String code, String name) { |
|||
this.index = index; |
|||
this.code = code; |
|||
this.name = name; |
|||
} |
|||
|
|||
|
|||
public static JSONArray getList() { |
|||
JSONArray arr = new JSONArray(); |
|||
for (RequestMethodEnum em : RequestMethodEnum.values()) { |
|||
JSONObject json = new JSONObject(); |
|||
json.put("code", em.getCode()); |
|||
json.put("name", em.getName()); |
|||
arr.add(json); |
|||
} |
|||
return arr; |
|||
} |
|||
|
|||
public static JSONArray getListByType(String type) { |
|||
JSONArray arr = new JSONArray(); |
|||
for (RequestMethodEnum em : RequestMethodEnum.values()) { |
|||
if (em.getType().equals(type)) { |
|||
JSONObject json = new JSONObject(); |
|||
json.put("code", em.getCode()); |
|||
json.put("name", em.getName()); |
|||
arr.add(json); |
|||
} |
|||
} |
|||
return arr; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public String getType() { |
|||
return type; |
|||
} |
|||
|
|||
public void setType(String type) { |
|||
this.type = type; |
|||
} |
|||
|
|||
public static String getName(String code) { |
|||
for (RequestMethodEnum c : RequestMethodEnum.values()) { |
|||
if (c.code == code) { |
|||
return c.name; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public int getIndex() { |
|||
return index; |
|||
} |
|||
|
|||
public void setIndex(int index) { |
|||
this.index = index; |
|||
} |
|||
} |
@ -0,0 +1,103 @@ |
|||
package org.nl.acs.device_driver; |
|||
|
|||
public interface StandardRequestMethod { |
|||
|
|||
/** |
|||
* 人工排产确认 |
|||
* @return |
|||
*/ |
|||
public default boolean order_verify() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
/** |
|||
* 工单完成 |
|||
* @return |
|||
*/ |
|||
public default boolean order_finish() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
/** |
|||
* 申请补满料盅托盘 |
|||
* @return |
|||
*/ |
|||
public default boolean apply_put_full_vehicle() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
/** |
|||
* 申请补空料盅托盘 |
|||
* @return |
|||
*/ |
|||
public default boolean apply_put_empty_vehicle() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
/** |
|||
* 申请取走空料盅托盘 |
|||
* @return |
|||
*/ |
|||
public default boolean apply_take_empty_vehicle() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
/** |
|||
* 申请取走满料盅托盘(入库) |
|||
* @return |
|||
*/ |
|||
public default boolean apply_take_full_vehicle() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
/** |
|||
* 申请强制取走满料盅托盘 |
|||
* @return |
|||
*/ |
|||
public default boolean apply_force_take_full_vehicle() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
/** |
|||
* 申请强制满托入缓存 |
|||
* @return |
|||
*/ |
|||
public default boolean apply_force_take_full_vehicle_in_storage() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
/** |
|||
* 扫码成功申请 |
|||
* @return |
|||
*/ |
|||
public default boolean barcode_sucess_apply() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
/** |
|||
* 获取组盘信息 |
|||
* @return |
|||
*/ |
|||
public default boolean get_vehicle_info() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
/** |
|||
* 强制去包装位-不包装 |
|||
* @return |
|||
*/ |
|||
public default boolean force_no_package() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
|
|||
/** |
|||
* 申请贴标 |
|||
* @return |
|||
*/ |
|||
public default boolean apply_labelling() { |
|||
throw new RuntimeException("未实现"); |
|||
}; |
|||
|
|||
|
|||
} |
@ -0,0 +1,49 @@ |
|||
package org.nl.acs.device_driver.basedriver.agv.ndcone; |
|||
|
|||
import org.nl.acs.device_driver.DeviceDriver; |
|||
import org.nl.acs.device_driver.DeviceDriverDefination; |
|||
import org.nl.acs.opc.Device; |
|||
import org.nl.acs.opc.DeviceType; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.LinkedList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* NDC单工位AGV |
|||
*/ |
|||
@Service |
|||
public class AgvNdcOneDefination implements DeviceDriverDefination { |
|||
@Override |
|||
public String getDriverCode() { |
|||
return "agv_ndc_one"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverName() { |
|||
return "NDC1楼AGV"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverDescription() { |
|||
return "NDC1楼AGV"; |
|||
} |
|||
|
|||
@Override |
|||
public DeviceDriver getDriverInstance(Device device) { |
|||
return (new AgvNdcOneDeviceDriver()).setDevice(device).setDriverDefination(this); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Class<? extends DeviceDriver> getDeviceDriverType() { |
|||
return AgvNdcOneDeviceDriver.class; |
|||
} |
|||
|
|||
@Override |
|||
public List<DeviceType> getFitDeviceTypes() { |
|||
List<DeviceType> types = new LinkedList(); |
|||
types.add(DeviceType.agv); |
|||
return types; |
|||
} |
|||
} |
@ -0,0 +1,426 @@ |
|||
package org.nl.acs.device_driver.basedriver.agv.ndcone; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.Data; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.mvel2.util.ErrorUtil; |
|||
import org.nl.acs.agv.server.NDCAgvService; |
|||
import org.nl.acs.device.service.DeviceService; |
|||
import org.nl.acs.device_driver.DeviceDriver; |
|||
import org.nl.acs.device_driver.basedriver.agv.utils.OneAgvPhase; |
|||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; |
|||
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver; |
|||
import org.nl.acs.device_driver.driver.AbstractDeviceDriver; |
|||
import org.nl.acs.ext.wms.service.AcsToWmsService; |
|||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; |
|||
import org.nl.acs.instruction.service.InstructionService; |
|||
import org.nl.acs.instruction.service.dto.Instruction; |
|||
import org.nl.acs.instruction.service.impl.InstructionServiceImpl; |
|||
import org.nl.acs.log.service.DeviceExecuteLogService; |
|||
import org.nl.acs.monitor.DeviceStageMonitor; |
|||
import org.nl.acs.opc.Device; |
|||
import org.nl.acs.opc.DeviceAppService; |
|||
import org.nl.modules.system.service.ParamService; |
|||
import org.nl.modules.system.service.impl.ParamServiceImpl; |
|||
import org.nl.modules.wql.util.SpringContextHolder; |
|||
import org.nl.start.auto.run.NDCSocketConnectionAutoRun; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* NDC单工位AGV |
|||
*/ |
|||
@Slf4j |
|||
@Data |
|||
@RequiredArgsConstructor |
|||
public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor { |
|||
|
|||
ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); |
|||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); |
|||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); |
|||
NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class); |
|||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); |
|||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); |
|||
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); |
|||
|
|||
OneAgvPhase oneAgvPhase = new OneAgvPhase(); |
|||
|
|||
int agvaddr = 0; |
|||
int agvaddr_copy = 0; |
|||
int weight = 0; |
|||
String device_code = ""; |
|||
int phase = 0; |
|||
String error_type = "agv_error_type"; |
|||
String error_code = "0"; |
|||
int x = 0; //x坐标
|
|||
int y = 0; //y坐标
|
|||
int angle = 0; //角度
|
|||
int electric_qty = 0; //电量
|
|||
int status = 0; //三色灯状态
|
|||
int error = 0; |
|||
int last_error = 0; |
|||
String error_message = ""; |
|||
|
|||
private synchronized void setErrorInfo(int error, String error_code, String error_message) { |
|||
this.error = error; |
|||
this.error_code = error_code; |
|||
this.error_message = error_message; |
|||
} |
|||
|
|||
private Instruction instruction; |
|||
|
|||
int mode = 2; |
|||
|
|||
// @LokiLog(type = LokiLogType.AGV)
|
|||
public synchronized void processSocket(int[] arr) throws Exception { |
|||
device_code = this.getDeviceCode(); |
|||
byte[] data = null; |
|||
phase = arr[16] * 256 + arr[17]; |
|||
// agv任务号
|
|||
int index = arr[12] * 256 + arr[13]; |
|||
//任务号
|
|||
int ikey = arr[26] * 256 + arr[27]; |
|||
//站点号
|
|||
agvaddr = arr[18] * 256 + arr[19]; |
|||
//车号
|
|||
int carno = arr[20]; |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "接收agv上报信息:" + "phase--" + phase + " index--" + index + " 指令号--" + ikey + " 站点号--" + agvaddr + " 车号--" + carno); |
|||
Instruction link_inst = null; |
|||
List<Instruction> insts = null; |
|||
Instruction inst = null; |
|||
boolean link_flag = false; |
|||
Device agv_device = null; |
|||
if (carno != 0) { |
|||
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); |
|||
} |
|||
if (ikey != 0) { |
|||
if (phase != 0x67 && phase != 0x71 && phase != 0x72 && phase != 0x73 && phase != 0x74 && phase != 0x75) { |
|||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); |
|||
this.instruction = inst; |
|||
} |
|||
// if (ObjectUtil.isEmpty(inst)){
|
|||
// inst = instructionService.findByCode(String.valueOf(ikey));
|
|||
// }
|
|||
} |
|||
if (!ObjectUtil.isEmpty(link_inst)) { |
|||
link_flag = true; |
|||
} |
|||
|
|||
Device device = null; |
|||
String old_device_code = null; |
|||
String emptyNum = null; |
|||
String device_code = null; |
|||
|
|||
// if (phase == 0x67) {
|
|||
// //故障信息
|
|||
// if (arr[18] * 256 + arr[19] == 0) {
|
|||
//
|
|||
// }
|
|||
// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
|||
// }
|
|||
|
|||
//普通站点
|
|||
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; |
|||
//货架
|
|||
StandardStorageDeviceDriver standardStorageDeviceDriver; |
|||
|
|||
|
|||
//分配 车id
|
|||
//(不需要WCS反馈)
|
|||
if (phase == 0x02) { |
|||
inst.setCarno(String.valueOf(carno)); |
|||
instructionService.update(inst); |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈车号:" + carno + ",指令号:" + ikey); |
|||
|
|||
//到达取货点
|
|||
//(需要WCS反馈)
|
|||
} else if (phase == 0x03) { |
|||
if (agvaddr == 0) { |
|||
agvaddr = agvaddr_copy; |
|||
} |
|||
if (agvaddr < 1) { |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); |
|||
return; |
|||
} |
|||
device_code = deviceService.queryDeviceCodeByAddress(agvaddr); |
|||
if (agvaddr != 0) { |
|||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); |
|||
if (StrUtil.contains(old_device_code, "-")) { |
|||
String[] point = old_device_code.split("-"); |
|||
device_code = point[0]; |
|||
} else if (StrUtil.contains(old_device_code, ".")) { |
|||
String[] point = old_device_code.split("\\."); |
|||
device_code = point[0]; |
|||
emptyNum = point[1]; |
|||
} else { |
|||
device_code = old_device_code; |
|||
} |
|||
} |
|||
|
|||
device = deviceAppService.findDeviceByCode(device_code); |
|||
if (ObjectUtil.isEmpty(device_code)) { |
|||
log.info(agvaddr + "对应设备号为空!"); |
|||
logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空"); |
|||
return; |
|||
} |
|||
//校验agv上报站点编号与指令起始点相同
|
|||
if (ObjectUtil.isEmpty(inst)) { |
|||
log.info("未找到编号{}对应的指令", ikey); |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); |
|||
return; |
|||
} |
|||
|
|||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
|||
standardOrdinarySiteDeviceDriver.setAgvphase(phase); |
|||
standardOrdinarySiteDeviceDriver.setIndex(index); |
|||
standardOrdinarySiteDeviceDriver.setInst(inst); |
|||
} |
|||
|
|||
|
|||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|||
} |
|||
//取货完毕
|
|||
//(需要WCS反馈)
|
|||
} else if (phase == 0x05) { |
|||
if (agvaddr == 0) { |
|||
agvaddr = agvaddr_copy; |
|||
} |
|||
if (agvaddr < 1) { |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); |
|||
return; |
|||
} |
|||
if (agvaddr != 0) { |
|||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); |
|||
if (StrUtil.contains(old_device_code, "-")) { |
|||
String[] point = old_device_code.split("-"); |
|||
device_code = point[0]; |
|||
} else if (StrUtil.contains(old_device_code, ".")) { |
|||
String[] point = old_device_code.split("\\."); |
|||
device_code = point[0]; |
|||
emptyNum = point[1]; |
|||
} else { |
|||
device_code = old_device_code; |
|||
} |
|||
} |
|||
device = deviceAppService.findDeviceByCode(device_code); |
|||
|
|||
if (ObjectUtil.isEmpty(device_code)) { |
|||
log.info(agvaddr + "对应设备号为空!"); |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code); |
|||
return; |
|||
} |
|||
//校验agv上报站点编号与指令起始点相同
|
|||
if (ObjectUtil.isEmpty(inst)) { |
|||
log.info("未找到关联编号{}对应的指令", ikey); |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); |
|||
return; |
|||
} |
|||
|
|||
if (StrUtil.equals(inst.getStart_device_code(), device_code)) { |
|||
|
|||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
|||
standardOrdinarySiteDeviceDriver.setAgvphase(phase); |
|||
standardOrdinarySiteDeviceDriver.setIndex(index); |
|||
standardOrdinarySiteDeviceDriver.setInst(inst); |
|||
} |
|||
|
|||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|||
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); |
|||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|||
} |
|||
|
|||
} |
|||
if (ObjectUtil.isNotEmpty(data)) { |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data)); |
|||
} |
|||
//到达放货点
|
|||
//(需要WCS反馈)
|
|||
} else if (phase == 0x07) { |
|||
if (agvaddr == 0) { |
|||
agvaddr = agvaddr_copy; |
|||
} |
|||
if (agvaddr < 1) { |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); |
|||
return; |
|||
} |
|||
if (agvaddr != 0) { |
|||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); |
|||
if (StrUtil.contains(old_device_code, "-")) { |
|||
String[] point = old_device_code.split("-"); |
|||
device_code = point[0]; |
|||
} else if (StrUtil.contains(old_device_code, ".")) { |
|||
String[] point = old_device_code.split("\\."); |
|||
device_code = point[0]; |
|||
emptyNum = point[1]; |
|||
} else { |
|||
device_code = old_device_code; |
|||
} |
|||
} |
|||
device = deviceAppService.findDeviceByCode(device_code); |
|||
if (ObjectUtil.isEmpty(device_code)) { |
|||
log.info(agvaddr + "对应设备号为空!"); |
|||
return; |
|||
} |
|||
//校验agv上报站点编号与指令起始点相同
|
|||
if (ObjectUtil.isEmpty(inst)) { |
|||
log.info("未找到关联编号{}对应的指令", ikey); |
|||
return; |
|||
} |
|||
if (StrUtil.equals(inst.getNext_device_code(), device_code)) { |
|||
|
|||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
|||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|||
} |
|||
|
|||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|||
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); |
|||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|||
} |
|||
|
|||
} |
|||
//放货完毕
|
|||
//(需要WCS反馈)
|
|||
} else if (phase == 0x09) { |
|||
if (agvaddr == 0) { |
|||
agvaddr = agvaddr_copy; |
|||
} |
|||
if (agvaddr < 1) { |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); |
|||
return; |
|||
} |
|||
if (agvaddr != 0) { |
|||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); |
|||
if (StrUtil.contains(old_device_code, "-")) { |
|||
String[] point = old_device_code.split("-"); |
|||
device_code = point[0]; |
|||
} else if (StrUtil.contains(old_device_code, ".")) { |
|||
String[] point = old_device_code.split("\\."); |
|||
device_code = point[0]; |
|||
emptyNum = point[1]; |
|||
} else { |
|||
device_code = old_device_code; |
|||
} |
|||
} |
|||
|
|||
device = deviceAppService.findDeviceByCode(device_code); |
|||
if (ObjectUtil.isEmpty(device_code)) { |
|||
log.info(agvaddr + "对应设备号为空!"); |
|||
return; |
|||
} |
|||
//校验agv上报站点编号与指令起始点相同
|
|||
if (ObjectUtil.isEmpty(inst)) { |
|||
log.info("未找到编号{}对应的指令", ikey); |
|||
return; |
|||
} |
|||
if (StrUtil.equals(inst.getNext_device_code(), device_code)) { |
|||
|
|||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { |
|||
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); |
|||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|||
} |
|||
|
|||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { |
|||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); |
|||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|||
} |
|||
|
|||
} |
|||
} |
|||
//到达位置点
|
|||
//(需要WCS反馈)
|
|||
else if (phase == 0x64) {//param,agv货位id待定
|
|||
//1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备
|
|||
agvaddr = arr[18] * 256 + arr[19]; |
|||
agvaddr_copy = agvaddr; |
|||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|||
} else if (phase == 0x50) {//进入交通灯区域
|
|||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|||
} else if (phase == 0x51) {//离开交通灯区域
|
|||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|||
} else if (phase == 0x67) {//agv异常
|
|||
if (ikey == 0) { |
|||
this.setErrorInfo(ikey, "0", "正常"); |
|||
} else { |
|||
|
|||
} |
|||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|||
last_error = error; |
|||
} else if (phase == 0x70) { |
|||
//x坐标
|
|||
x = ikey; |
|||
} else if (phase == 0x71) { |
|||
//y坐标
|
|||
y = ikey; |
|||
} else if (phase == 0x72) { |
|||
//车辆角度
|
|||
angle = ikey; |
|||
} else if (phase == 0x73) { |
|||
//agv电量
|
|||
electric_qty = ikey; |
|||
} else if (phase == 0x74) { |
|||
//三色灯状态
|
|||
status = ikey; |
|||
} |
|||
if (!ObjectUtil.isEmpty(data)) { |
|||
phase = 0; |
|||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data)); |
|||
NDCSocketConnectionAutoRun.write(data); |
|||
} |
|||
|
|||
} |
|||
|
|||
public static String Bytes2HexString(byte[] b) { |
|||
String ret = ""; |
|||
for (int i = 0; i < b.length; i++) { |
|||
String hex = Integer.toHexString(b[i] & 0xFF); |
|||
if (hex.length() == 1) { |
|||
hex = '0' + hex; |
|||
} |
|||
ret += hex.toUpperCase(); |
|||
} |
|||
return ret; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public JSONObject getDeviceStatusName() { |
|||
JSONObject jo = new JSONObject(); |
|||
//agv编码
|
|||
jo.put("car_no", this.getDevice().getDevice_code()); |
|||
//agv名称
|
|||
jo.put("device_name", this.getDevice().getDevice_name()); |
|||
//x坐标
|
|||
jo.put("x", this.getX()); |
|||
//y坐标
|
|||
jo.put("y", this.getY()); |
|||
//角度
|
|||
jo.put("angle", this.getAngle()); |
|||
jo.put("phase", phase); |
|||
jo.put("phase_name", oneAgvPhase.getPhaseName(phase)); |
|||
//电量
|
|||
jo.put("electricity", this.getElectric_qty()); |
|||
String status_name = this.status == 1 ? "关机" : this.status == 2 ? "工作中" : this.status == 3 ? "交通管制" : this.status == 4 ? "任务等待" : this.status == 5 ? "充电中" : this.status == 6 ? "故障中" : this.status == 7 ? "电量低" : "正常"; |
|||
//agv状态
|
|||
jo.put("status_name", status_name); |
|||
//任务号
|
|||
jo.put("task_code", ObjectUtil.isEmpty(instruction) ? "0" : instruction.getTask_code()); |
|||
//异常
|
|||
jo.put("fault", this.getError_message()); |
|||
return jo; |
|||
} |
|||
|
|||
@Override |
|||
public void setDeviceStatus(JSONObject data) { |
|||
|
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,50 @@ |
|||
|
|||
package org.nl.acs.ext.wms; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.http.HttpRequest; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.log.LokiLog; |
|||
import org.nl.acs.log.LokiLogType; |
|||
import org.nl.acs.log.service.DeviceExecuteLogService; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.system.service.ParamService; |
|||
import org.nl.modules.system.service.impl.ParamServiceImpl; |
|||
import org.nl.modules.wql.util.SpringContextHolder; |
|||
|
|||
/** |
|||
* ACS连接外部系统工具类: |
|||
*/ |
|||
@Slf4j |
|||
public class LmsUtil { |
|||
|
|||
public static <W> String notifyAcs(String api, W requestParam) { |
|||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);; |
|||
ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); |
|||
//判断是否连接立库WCS系统
|
|||
String isConnect = paramService.findByCode("hasWms").getValue(); |
|||
if (StrUtil.equals("0", isConnect)) { |
|||
throw new BadRequestException("参数配置表中-hasWms为:0"); |
|||
} |
|||
String liKu_wcs_url = paramService.findByCode("wmsurl").getValue(); |
|||
try { |
|||
log.info("请求LMS参数:{}", JSON.toJSONString(requestParam)); |
|||
String body = HttpRequest |
|||
.post(liKu_wcs_url + api).setConnectionTimeout(3000) |
|||
.body(JSON.toJSONString(requestParam)) |
|||
.execute() |
|||
.body(); |
|||
log.info("请求LMS参数返回参数:{}", body); |
|||
return body; |
|||
} catch (Exception e) { |
|||
JSONObject result = new JSONObject(); |
|||
result.put("result", "false"); |
|||
result.put("code", "1"); |
|||
result.put("comment", e.getMessage()); |
|||
log.info("请求LMS异常返回参数:{}", String.valueOf(result)); |
|||
return String.valueOf(result); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
package org.nl.acs.ext.wms; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.nl.acs.ext.wms.data.Resp; |
|||
|
|||
/** |
|||
* @author: geng by |
|||
* @createDate: 2022/11/24 |
|||
*/ |
|||
public class RespUtil { |
|||
public static <T> Resp getResp(String result, T t) { |
|||
JSONObject jsonObject = JSONObject.parseObject(result); |
|||
Resp<T> resp = new Resp<>(); |
|||
resp.setData(t); |
|||
resp = JSONObject.toJavaObject(jsonObject, Resp.class); |
|||
return resp; |
|||
} |
|||
} |
@ -0,0 +1,42 @@ |
|||
package org.nl.acs.ext.wms.data; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@Data |
|||
public class BaseRequest { |
|||
|
|||
/** |
|||
* 请求号:uuid 唯一,LMS需要返回对应值 |
|||
*/ |
|||
private String requestNo; |
|||
|
|||
/** |
|||
* 请求时间 |
|||
*/ |
|||
private String requestDate; |
|||
|
|||
/** |
|||
* 请求方法编号 |
|||
*/ |
|||
private String request_medthod_code; |
|||
|
|||
/** |
|||
* 请求方法名称 |
|||
*/ |
|||
private String request_medthod_name; |
|||
|
|||
|
|||
/** |
|||
* 系统编号 |
|||
*/ |
|||
private String systemCode; |
|||
|
|||
/** |
|||
* 扩展参数:砖型等 |
|||
*/ |
|||
private Map<String, String> parameters = new HashMap(); |
|||
|
|||
} |
@ -0,0 +1,36 @@ |
|||
package org.nl.acs.ext.wms.data; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@Data |
|||
public class BaseResponse { |
|||
|
|||
/** |
|||
* 请求号 |
|||
*/ |
|||
private String requestNo; |
|||
|
|||
/** |
|||
* 响应时间 |
|||
*/ |
|||
private String responseDate; |
|||
|
|||
/** |
|||
* 结果 200成功 |
|||
*/ |
|||
private int code; |
|||
|
|||
/** |
|||
* 信息 |
|||
*/ |
|||
private String message; |
|||
|
|||
|
|||
private Map<String, String> parameters = new HashMap(); |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,32 @@ |
|||
package org.nl.acs.ext.wms.data; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 调用立库接口统一返回参数类 |
|||
* |
|||
* @author: geng by |
|||
* @createDate: 2022/11/24 |
|||
*/ |
|||
@Data |
|||
public class Resp<T> { |
|||
/** |
|||
* 成功返回true,失败返回false |
|||
*/ |
|||
public String result; |
|||
|
|||
/** |
|||
* 错误码(0表示成功)1代表入库目的位置有货,其他更多情况待定 |
|||
*/ |
|||
public String code; |
|||
|
|||
/** |
|||
* 错误信息,如果成功则为null |
|||
*/ |
|||
public String comment; |
|||
|
|||
/** |
|||
* 报文携带的数据 |
|||
*/ |
|||
public T data; |
|||
} |
@ -0,0 +1,39 @@ |
|||
package org.nl.acs.ext.wms.data.applyTask; |
|||
|
|||
import lombok.Data; |
|||
import org.nl.acs.ext.wms.data.BaseRequest; |
|||
|
|||
@Data |
|||
public class ApplyTaskRequest extends BaseRequest { |
|||
|
|||
/** |
|||
* 请求设备 |
|||
*/ |
|||
private String device_code; |
|||
|
|||
/** |
|||
* 载具号 |
|||
*/ |
|||
private String vehicle_code; |
|||
|
|||
/** |
|||
* 重量 |
|||
*/ |
|||
private String weight; |
|||
|
|||
/** |
|||
* 工单号 |
|||
*/ |
|||
private String order_code; |
|||
|
|||
/** |
|||
* 物料 |
|||
*/ |
|||
private String material_code; |
|||
|
|||
/** |
|||
* 数量 |
|||
*/ |
|||
private String qty; |
|||
|
|||
} |
@ -0,0 +1,6 @@ |
|||
package org.nl.acs.ext.wms.data.applyTask; |
|||
|
|||
import org.nl.acs.ext.wms.data.BaseResponse; |
|||
|
|||
public class ApplyTaskResponse extends BaseResponse { |
|||
} |
@ -0,0 +1,45 @@ |
|||
package org.nl.acs.ext.wms.data.feedBackTaskStatus; |
|||
|
|||
import lombok.Data; |
|||
import org.nl.acs.ext.wms.data.BaseRequest; |
|||
|
|||
@Data |
|||
public class FeedBackTaskStautsRequest extends BaseRequest { |
|||
|
|||
/** |
|||
* 任务id |
|||
*/ |
|||
private String task_id; |
|||
|
|||
/** |
|||
* 任务code |
|||
*/ |
|||
private String task_code; |
|||
|
|||
/** |
|||
* 任务状态 |
|||
*/ |
|||
private String task_status; |
|||
|
|||
/** |
|||
* 任务类型 |
|||
*/ |
|||
private String task_type; |
|||
|
|||
/** |
|||
* 车号 |
|||
*/ |
|||
private String car_no; |
|||
|
|||
/** |
|||
* 载具号 |
|||
*/ |
|||
private String vehicle_code; |
|||
|
|||
/** |
|||
* 动作 1请求取货 2取货完成 3请求放货 4放货完成 |
|||
*/ |
|||
private String action; |
|||
|
|||
|
|||
} |
@ -0,0 +1,6 @@ |
|||
package org.nl.acs.ext.wms.data.feedBackTaskStatus; |
|||
|
|||
import org.nl.acs.ext.wms.data.BaseResponse; |
|||
|
|||
public class FeedBackTaskStautsResponse extends BaseResponse { |
|||
} |
Loading…
Reference in new issue