This commit is contained in:
2025-09-15 17:34:57 +08:00
23 changed files with 406 additions and 432 deletions

View File

@@ -12,17 +12,16 @@ import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.CodeUtil;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.dict.ISysDictService;
import org.nl.system.service.dict.dao.Dict;
import org.nl.system.service.param.ISysParamService;
import org.nl.common.utils.CodeUtil;
import org.nl.config.SpringContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -39,7 +38,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
private final DeviceAppService deviceAppService;
private final ISysParamService paramService;
// private final AcsToWmsService acsToWmsService;
// private final AcsToWmsService acsToWmsService;
private final ISysDictService dictService;
private final DeviceExecuteLogService logServer;
@@ -85,187 +84,79 @@ public class NDCAgvServiceImpl implements NDCAgvService {
",priority:" + inst.getPriority() + ",startAddress:" + inst.getStart_point_code() +
",nextAddress:" + inst.getNext_point_code());
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
if (!StrUtil.equals(agv_system_type, "1")) {
String instcode = inst.getInstruction_code();
int type = Integer.parseInt(inst.getAgv_inst_type());
int priority = Integer.parseInt(inst.getPriority()) + 128;
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
int startAddress2 = deviceService.queryAddressBydeviceCode(inst.getStart_point_code2());
int nextAddress2 = deviceService.queryAddressBydeviceCode(inst.getNext_point_code2());
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
byte typehigh = (byte) IntToHexHigh(type);
byte typelow = (byte) IntToHexLow(type);
byte qhdhigh = (byte) IntToHexHigh(startAddress);
byte qhdlow = (byte) IntToHexLow(startAddress);
byte qhdhigh2 = (byte) IntToHexHigh(startAddress2);
byte qhdlow2 = (byte) IntToHexLow(startAddress2);
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
byte fhdlow = (byte) IntToHexLow(nextAddress);
byte fhdhigh2 = (byte) IntToHexHigh(nextAddress2);
byte fhdlow2 = (byte) IntToHexLow(nextAddress2);
byte prioritylow = (byte) IntToHexLow(priority);
String str = "十进制下发:";
String str1 = "十六进制下发:";
str += "任务号 ikey:" + (Integer.parseInt(instcode));
str1 += "任务号 ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
String instcode = inst.getInstruction_code();
int type = Integer.parseInt(inst.getAgv_inst_type());
int priority = Integer.parseInt(inst.getPriority()) + 128;
// 车号。。。
String carno = inst.getCarno();
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
int startAddress2 = deviceService.queryAddressBydeviceCode(inst.getStart_point_code2());
int nextAddress2 = deviceService.queryAddressBydeviceCode(inst.getNext_point_code2());
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
byte typehigh = (byte) IntToHexHigh(type);
byte typelow = (byte) IntToHexLow(type);
byte qhdhigh = (byte) IntToHexHigh(startAddress);
byte qhdlow = (byte) IntToHexLow(startAddress);
byte qhdhigh2 = (byte) IntToHexHigh(startAddress2);
byte qhdlow2 = (byte) IntToHexLow(startAddress2);
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
byte fhdlow = (byte) IntToHexLow(nextAddress);
byte fhdhigh2 = (byte) IntToHexHigh(nextAddress2);
byte fhdlow2 = (byte) IntToHexLow(nextAddress2);
byte prioritylow = (byte) IntToHexLow(priority);
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
byte carlow = (byte) IntToHexLow(Integer.parseInt(carno));
String str = "十进制下发:";
String str1 = "十六进制下发:";
str += "任务号 ikey:" + (Integer.parseInt(instcode));
str1 += "任务号 ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
str += "指令类型 /type:" + (type);
str1 += "指令类型 /type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
str += "指令类型 /type:" + (type);
str1 += "指令类型 /type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
str += "取货点 /qhd:" + (startAddress);
str1 += "取货点 /qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
str += "放货点 /fhd:" + (nextAddress);
str1 += "放货点 /fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
str += "取货点 /qhd:" + (startAddress);
str1 += "取货点 /qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
str += "放货点 /fhd:" + (nextAddress);
str1 += "放货点 /fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
str += "取货点2 /qhd2:" + (startAddress2);
str1 += "取货点2 /qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF);
str += "放货点2 /fhd2:" + (nextAddress2);
str1 += "放货点2 /fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF);
str += "取货点2 /qhd2:" + (startAddress2);
str1 += "取货点2 /qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF);
str += "放货点2 /fhd2:" + (nextAddress2);
str1 += "放货点2 /fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF);
str += "优先级 /priority:" + (priority);
str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF);
str += "优先级 /priority:" + (priority);
str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF);
byte[] b = new byte[]{};
if (type == 1) {
b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X16,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X71,
(byte) 0X00, (byte) 0X12,
(byte) 0X01, prioritylow,
(byte) 0X00, (byte) 0X01,
(byte) ikeyhigh, (byte) ikeylow,
(byte) ikeyhigh, (byte) ikeylow,
(byte) typehigh, (byte) typelow,
(byte) qhdhigh, (byte) qhdlow,
(byte) qhdhigh2, (byte) qhdlow2,
(byte) fhdhigh, (byte) fhdlow,
(byte) fhdhigh2, (byte) fhdlow2
};
} else if (type == 2) {
b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X16,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X71,
(byte) 0X00, (byte) 0X12,
(byte) 0X01, prioritylow,
(byte) 0X00, (byte) 0X01,
(byte) ikeyhigh, (byte) ikeylow,
(byte) ikeyhigh, (byte) ikeylow,
(byte) typehigh, (byte) typelow,
(byte) qhdhigh, (byte) qhdlow,
(byte) 0X00, (byte) 0X00,
(byte) fhdhigh, (byte) fhdlow,
(byte) 0X00, (byte) 0X00
};
} else if (type == 3) {
b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X16,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X71,
(byte) 0X00, (byte) 0X12,
(byte) 0X01, prioritylow,
(byte) 0X00, (byte) 0X01,
(byte) ikeyhigh, (byte) ikeylow,
(byte) ikeyhigh, (byte) ikeylow,
(byte) typehigh, (byte) typelow,
(byte) qhdhigh, (byte) qhdlow,
(byte) qhdhigh2, (byte) qhdlow2,
(byte) fhdhigh, (byte) fhdlow,
(byte) fhdhigh2, (byte) fhdlow2
};
}
log.info("下发AGV作业指令 --{}", str1);
log.info("下发AGV作业指令--{}", str);
log.info("下发agv指令数据--{}", Bytes2HexString(b));
str += "车号 /carno:" + (carno);
str1 += "车号 /carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF);
if (StrUtil.equals(agv_system_type, "2")) {
TwoNDCSocketConnectionAutoRun.write(b);
}
} else {
byte[] b = new byte[]{
(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X18,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X71,
(byte) 0X00, (byte) 0X14,
(byte) 0X01, prioritylow,
(byte) 0X00, (byte) 0X01,
(byte) ikeyhigh, (byte) ikeylow,
(byte) ikeyhigh, (byte) ikeylow,
(byte) typehigh, (byte) typelow,
(byte) qhdhigh, (byte) qhdlow,
(byte) fhdhigh, (byte) fhdlow,
(byte) qhdhigh2, (byte) qhdlow2,
(byte) fhdhigh2, (byte) fhdlow2,
(byte) carhigh, (byte) carlow
};
log.info("下发AGV作业指令 --{}", str1);
log.info("下发AGV作业指令--{}", str);
log.info("下发agv指令数据--{}", Bytes2HexString(b));
String instcode = inst.getInstruction_code();
int startHeight = Integer.parseInt(StrUtil.isEmpty(inst.getStart_height()) ? "0" : inst.getStart_height());
int nextHeight = Integer.parseInt(StrUtil.isEmpty(inst.getNext_height()) ? "0" : inst.getNext_height());
//默认取货放货高度都为0
//int type = Integer.parseInt(inst.getInstruction_type());
int type = 4;
if (startHeight != 0 && nextHeight != 0) {
//取货放货高度都不为0
type = 1;
} else if (startHeight != 0 && nextHeight == 0) {
//取货高度不为0 放货高度为0
type = 2;
} else if (startHeight == 0 && nextHeight != 0) {
//取货高度为0 放货高度不为0
type = 3;
}
int priority = Integer.parseInt(inst.getPriority()) + 128;
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
byte typehigh = (byte) IntToHexHigh(type);
byte typelow = (byte) IntToHexLow(type);
byte qhdhigh = (byte) IntToHexHigh(startAddress);
byte qhdlow = (byte) IntToHexLow(startAddress);
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
byte fhdlow = (byte) IntToHexLow(nextAddress);
byte prioritylow = (byte) IntToHexLow(priority);
byte shhigh = (byte) IntToHexHigh(startHeight);
byte shlow = (byte) IntToHexLow(startHeight);
byte nhhigh = (byte) IntToHexHigh(nextHeight);
byte nhlow = (byte) IntToHexLow(nextHeight);
String str = "十进制下发:";
String str1 = "十六进制下发:";
str += "ikey:" + (Integer.parseInt(instcode));
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
str += "/type:" + (type);
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
str += "/qhd:" + (startAddress);
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
str += "/fhd:" + (nextAddress);
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
str += "/priority:" + (priority);
str1 += "/priority:" + hexToString(prioritylow & 0xFF);
System.out.println(str);
System.out.println(str1);
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X16,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X71,
(byte) 0X00, (byte) 0X12,
(byte) 0X01, prioritylow,
(byte) 0X00, (byte) 0X01,
(byte) ikeyhigh, (byte) ikeylow,
(byte) ikeyhigh, (byte) ikeylow,
(byte) typehigh, (byte) typelow,
(byte) qhdhigh, (byte) qhdlow,
(byte) fhdhigh, (byte) fhdlow,
(byte) shhigh, (byte) shlow,
(byte) nhhigh, (byte) nhlow
};
log.info("下发AGV作业指令 --{}", str1);
log.info("下发AGV作业指令--{}", str);
log.info("下发agv指令数据--{}", Bytes2HexString(b));
if (StrUtil.equals(agv_system_type, "2")) {
OneNDCSocketConnectionAutoRun.write(b);
}
}
@@ -450,18 +341,18 @@ public class NDCAgvServiceImpl implements NDCAgvService {
public void charge(String carno) {
//检查数据字典station为0的参数
//分配车辆
Dict dict = dictService.getDictByName3("station",carno,null);
int satation=0;
if(ObjectUtil.isNotEmpty(dict)){
log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict.getPara1());
Dict dict = dictService.getDictByName3("station", carno, null);
int satation = 0;
if (ObjectUtil.isNotEmpty(dict)) {
log.info("当前车辆{}已分配充电桩{},退出后续判断", carno, dict.getPara1());
return;
}
Dict temp = dictService.getDictByName2("station");
if(ObjectUtil.isNotEmpty(temp)){
if (ObjectUtil.isNotEmpty(temp)) {
satation = Integer.parseInt(temp.getPara1());
}
if(satation!=0){
String instcode =CodeUtil.getNewCode("INSTRUCT_NO");
if (satation != 0) {
String instcode = CodeUtil.getNewCode("INSTRUCT_NO");
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
@@ -492,10 +383,10 @@ public class NDCAgvServiceImpl implements NDCAgvService {
};
log.info("下发AGV充电任务--{}", str1);
try{
try {
OneNDCSocketConnectionAutoRun.write(b);
} catch (Exception e){
log.error("下发充电任务失败{}{}",e,e.getMessage());
} catch (Exception e) {
log.error("下发充电任务失败{}{}", e, e.getMessage());
}
temp.setValue("1");
@@ -503,8 +394,8 @@ public class NDCAgvServiceImpl implements NDCAgvService {
temp.setPara3("下发充电");
dictService.updateDetail(temp);
}else{
log.error("目前暂无可使用充电桩充电桩,暂不分配{}充电任务",carno);
} else {
log.error("目前暂无可使用充电桩充电桩,暂不分配{}充电任务", carno);
}
}
@@ -592,10 +483,10 @@ public class NDCAgvServiceImpl implements NDCAgvService {
Dict temp = dictService.getDictByName2("station", station);
if (ObjectUtil.isNotEmpty(temp)) {
int satation = 0;
if(ObjectUtil.isNotEmpty(temp)){
if (ObjectUtil.isNotEmpty(temp)) {
satation = Integer.parseInt(temp.getPara1());
}
String instcode =CodeUtil.getNewCode("INSTRUCT_NO");
String instcode = CodeUtil.getNewCode("INSTRUCT_NO");
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
@@ -626,13 +517,13 @@ public class NDCAgvServiceImpl implements NDCAgvService {
};
log.info("下发AGV充电任务--{}", str1);
try{
try {
OneNDCSocketConnectionAutoRun.write(b);
temp.setValue("1");
temp.setPara2(String.valueOf(carno));
dictService.updateDetail(temp);
} catch (Exception e){
log.error("下发充电任务失败{}{}",e,e.getMessage());
} catch (Exception e) {
log.error("下发充电任务失败{}{}", e, e.getMessage());
}
} else {

View File

@@ -184,7 +184,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
}
//任务完毕
//无车id及状态
else if (phase == 0x0A) {
else if (phase == 0x14) {
if (!ObjectUtil.isEmpty(inst)) {
instructionService.finish(inst.getInstruction_id());
} else {
@@ -209,28 +209,6 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
}
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
} else if (phase == 0x64) {
log.info("AGV车号{}反馈充电任务下发成功,锁定充电桩{}", agvaddr, station);
Dict dict = dictService.getDictByName3("station", String.valueOf(agvaddr), null);
if (ObjectUtil.isNotEmpty(dict)) {
dict.setValue("1");
dict.setPara2(String.valueOf(agvaddr));
dict.setPara3("下发成功");
dictService.updateDetail(dict);
}
//充电成功
} else if (phase == 0x65) {
log.info("AGV车号{}反馈充电中,充电桩{}", agvaddr, station);
//充电取消上报
} else if (phase == 0x66) {
log.info("AGV车号{}反馈充电任务已取消,释放充电桩{}", agvaddr, station);
Dict dict = dictService.getDictByName3("station", String.valueOf(agvaddr), null);
if (ObjectUtil.isNotEmpty(dict)) {
dict.setValue("0");
dict.setPara2("");
dict.setPara3("充电桩空闲");
dictService.updateDetail(dict);
}
} else {
//上报异常信息
//不需要WCS反馈

View File

@@ -1338,17 +1338,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0);
}
this.setPhase(phase);
}
//到达位置点
//(需要WCS反馈)
//param,agv货位id待定
else if (phase == 0x64) {
//1、根据货位id找到对应三工位设备赋给agv属性地址对应的满料位设备
agvaddr = arr[18] * 256 + arr[19];
agvaddr_copy = agvaddr;
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
//进入交通灯区域
} else if (phase == 0x50) {
// 判断自动门、区域需要向LMS请求、电梯
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
//离开交通灯区域
} else if (phase == 0x51) {

View File

@@ -20,7 +20,7 @@ public class ItemProtocol {
/**
* 心跳
*/
public static String item_heartbeat = "heartbeat";
// public static String item_heartbeat = "heartbeat";
/**
* 工作模式
*/
@@ -54,9 +54,9 @@ public class ItemProtocol {
}
/** =============== 从kep获取plc的值 ================ */
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
// public int getHeartbeat() {
// return this.getOpcIntegerValue(item_heartbeat);
// }
public int getMode() {
return this.getOpcIntegerValue(item_mode);
@@ -125,7 +125,7 @@ public class ItemProtocol {
*/
public static List<ItemDto> getReadableItemDtos() {
ArrayList<ItemDto> list = new ArrayList<>();
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0"));
// list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0"));
list.add(new ItemDto(item_mode, "工作模式", "DB1.B1"));
list.add(new ItemDto(item_action, "动作信号", "DB1.B3"));
list.add(new ItemDto(item_gross_weight, "毛重", "DB1.B4"));

View File

@@ -43,8 +43,8 @@ public class UnpackingMachineDeviceDriver extends AbstractOpcDeviceDriver implem
private int instruction_require_time_out = 3000;
/** 心跳 */
int heartbeat = 0;
int last_heartbeat = 0;
// int heartbeat = 0;
// int last_heartbeat = 0;
/** 工作模式 */
int mode = 0;
int last_mode = 0;
@@ -83,7 +83,7 @@ public class UnpackingMachineDeviceDriver extends AbstractOpcDeviceDriver implem
// 具体业务
try {
device_code = this.getDeviceCode();
heartbeat = itemProtocol.getHeartbeat();
// heartbeat = itemProtocol.getHeartbeat();
mode = itemProtocol.getMode();
action = itemProtocol.getAction();
gross_weight = itemProtocol.getGross_weight();
@@ -107,7 +107,7 @@ public class UnpackingMachineDeviceDriver extends AbstractOpcDeviceDriver implem
}
last_mode = mode;
last_action = action;
last_heartbeat = heartbeat;
// last_heartbeat = heartbeat;
last_gross_weight = gross_weight;
last_net_weight = net_weight;
last_to_command = to_command;

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import org.nl.acs.common.base.CommonFinalParam;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
@@ -226,4 +227,10 @@ public class CreateTaskRequest extends BaseRequest {
* 17 木箱堆叠行架任务
*/
private String class_type;
private String task_group_id;
private BigDecimal task_group_seq;
}

View File

@@ -43,6 +43,21 @@ public class WmsToAcsController {
return new ResponseEntity<>(wmstoacsService.crateTask(whereJson), HttpStatus.OK);
}
@PostMapping("/action")
@Log(value = "WMS下发点位信号")
@SaIgnore
public ResponseEntity<Object> putAction(@RequestBody String whereJson) throws Exception {
return new ResponseEntity<>(wmstoacsService.putAction(whereJson), HttpStatus.OK);
}
@PostMapping("/querydevice")
@Log(value = "WMS查询设备状态")
@SaIgnore
public ResponseEntity<Object> queryDevice(@RequestBody String whereJson) throws Exception {
return new ResponseEntity<>(wmstoacsService.queryDevice(whereJson), HttpStatus.OK);
}
@PostMapping("/cancelTask")
@Log(value = "WMS取消任务")
@SaIgnore
@@ -69,20 +84,6 @@ public class WmsToAcsController {
return new ResponseEntity<>(wmstoacsService.areaControl(whereJson), HttpStatus.OK);
}
@PostMapping("/action")
@Log(value = "WMS下发点位信号")
@SaIgnore
public ResponseEntity<Object> putAction(@RequestBody String whereJson) throws Exception {
return new ResponseEntity<>(wmstoacsService.putAction(whereJson), HttpStatus.OK);
}
@PostMapping("/querydevice")
@Log(value = "WMS查询设备状态")
@SaIgnore
public ResponseEntity<Object> queryDevice(@RequestBody String whereJson) throws Exception {
return new ResponseEntity<>(wmstoacsService.queryDevice(whereJson), HttpStatus.OK);
}
@PostMapping("/queryDeviceDBValue")
@Log(value = "WMS查询设备DB值")
@SaIgnore

View File

@@ -16,6 +16,7 @@ import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.agv.ndctwo.AgvNdcTwoDeviceDriver;
import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver;
import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.zz_driver.unpacking_machine.UnpackingMachineDeviceDriver;
import org.nl.acs.ext.wms.data.*;
import org.nl.acs.ext.wms.service.WmsToAcsService;
@@ -37,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
@Service
@@ -86,6 +88,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
// response.setErrArr(datas);
// return response;
// }
// 将LMS任务转成ACS任务并保存
for (int i = 0; i < datas.size(); i++) {
String data = datas.get(i).toString();
CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class);
@@ -115,6 +118,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
String storage_task_type = request.getDtl_type();
String agv_system_type = request.getAgv_system_type();
String remark = request.getRemark();
String taskGroupId = request.getTask_group_id();
BigDecimal taskGroupSeq = request.getTask_group_seq();
double oven_time = 0.00d;
if (StrUtil.isNotEmpty(request.getOven_time())) {
oven_time = Double.parseDouble(request.getOven_time());
@@ -296,6 +301,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONObject jo = new JSONObject();
jo.put("task_id", IdUtil.simpleUUID());
jo.put("task_code", task_code);
jo.put("task_group_id", taskGroupId);
jo.put("task_group_seq", taskGroupSeq);
jo.put("start_point_code", start_point_code);
jo.put("next_point_code", next_point_code);
jo.put("start_point_code2", start_point_code2);
@@ -586,7 +593,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
//标准版输送线
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
UnpackingMachineDeviceDriver unpackingMachineDeviceDriver;
if (datas.size() == 0) {
throw new BadRequestException("缺少输入参数!");
@@ -614,6 +621,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("move", beltConveyorDeviceDriver.getMove());
jo.put("mode", beltConveyorDeviceDriver.getMode());
jo.put("device_code", parent_device_code);
} else if (device.getDeviceDriver() instanceof UnpackingMachineDeviceDriver) {
unpackingMachineDeviceDriver = (UnpackingMachineDeviceDriver) device.getDeviceDriver();
jo.put("move", unpackingMachineDeviceDriver.getMove());
jo.put("mode", unpackingMachineDeviceDriver.getMode());
jo.put("gross_weight", unpackingMachineDeviceDriver.getGross_weight());
jo.put("net_weight", unpackingMachineDeviceDriver.getNet_weight());
jo.put("device_code", parent_device_code);
} else {
jo.put("device_code", parent_device_code);
}

View File

@@ -244,6 +244,8 @@ public class InstructionMybatis extends CommonModel<InstructionMybatis> implemen
private Integer agv_action_type;
private String task_group_id;
private BigDecimal task_group_seq;
public void copyFrom(Instruction source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));

View File

@@ -4,6 +4,7 @@ import lombok.Data;
import org.nl.acs.common.base.CommonFinalParam;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author ldjun
@@ -380,4 +381,6 @@ public class InstructionDto implements Serializable {
*
*/
// private String to_device_code;
private String task_group_id;
private BigDecimal task_group_seq;
}

View File

@@ -461,6 +461,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
}
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
// hint ----
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
}
//判断是否是仙工AGV

View File

@@ -256,6 +256,8 @@ public class Task extends CommonModel<Task> implements Serializable {
* 15 RGV输送任务
*/
private String class_type;
private String task_group_id;
private BigDecimal task_group_seq;
public void copyFrom(Task source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));

View File

@@ -5,6 +5,7 @@ import lombok.Data;
import org.nl.acs.common.base.CommonFinalParam;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author ldjun
@@ -370,4 +371,6 @@ public class TaskDto implements Serializable {
* 15 RGV输送任务
*/
private String class_type;
private String task_group_id;
private BigDecimal task_group_seq;
}

View File

@@ -1,21 +1,17 @@
package org.nl.system.service.quartz.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device;
import org.nl.acs.instruction.domain.InstructionMybatis;
import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.limit_regional.server.LimitRegionalService;
import org.nl.acs.limit_regional.server.dto.LimitRegionalDto;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
@@ -33,8 +29,11 @@ import org.nl.config.lucene.service.dto.LuceneLogDto;
import org.nl.config.lucene.service.impl.LuceneExecuteLogServiceImpl;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* 自动创建指令
@@ -43,6 +42,16 @@ import java.util.List;
@Component
public class AutoCreateInst {
Map<String, Integer> carTaskCount = new ConcurrentHashMap<>();
@PostConstruct
public void init() {
if (carTaskCount.isEmpty()) {
carTaskCount.put("1", 0);
carTaskCount.put("2", 0);
}
}
/**
* 根据任务状态创建指令、生成下一条指令
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
@@ -55,180 +64,204 @@ public class AutoCreateInst {
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogServiceImpl.class);
List<TaskDto> list = taskserver.queryAllByStatus("0");
for (int i = 0; i < list.size(); i++) {
TaskDto acsTask = list.get(i);
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.AGV_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
continue;
}
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.Truss_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
continue;
}
String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code();
String task_type = acsTask.getTask_type();
String vehiclecode = acsTask.getVehicle_code();
String vehiclecode2 = acsTask.getVehicle_code2();
String storage_task_type = acsTask.getStorage_task_type();
String priority = acsTask.getPriority();
String is_send = acsTask.getIs_send();
String start_device_code = acsTask.getStart_device_code();
String start_point_code = acsTask.getStart_point_code();
String put_device_code = acsTask.getPut_device_code();
String put_point_code = acsTask.getPut_point_code();
String next_device_code = acsTask.getNext_device_code();
String next_point_code = acsTask.getNext_point_code();
String start_point_code2 = acsTask.getStart_point_code2();
String start_device_code2 = acsTask.getStart_device_code2();
String next_point_code2 = acsTask.getNext_point_code2();
String next_device_code2 = acsTask.getNext_device_code2();
String route_plan_code = acsTask.getRoute_plan_code();
String vehicleType = acsTask.getVehicle_type();
String agv_system_type = acsTask.getAgv_system_type();
String start_height = acsTask.getStart_height();
String next_height = acsTask.getNext_height();
Integer agvActionType = acsTask.getAgv_action_type();
if (StrUtil.equals(is_send, "0")) {
continue;
}
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) {
acsTask.setRemark("路由不通无法生成指令");
taskserver.updateByCodeFromCache(acsTask);
continue;
}
if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
continue;
}
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
int index = 0;
boolean flag = false;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
if("1".equals(acsTask.getTask_type()) && !pathlist.get(m+1).equals(next_device_code)){
flag = true;
break;
}
index = m + 1;
break;
// 根据任务组别分组
Map<String, List<TaskDto>> groupTasks = list.stream()
.collect(Collectors.groupingBy(
TaskDto::getTask_group_id,
Collectors.mapping(
task -> task,
Collectors.collectingAndThen(
Collectors.toList(),
tasks -> tasks.stream()
.sorted(Comparator.comparing(TaskDto::getTask_group_seq))
.collect(Collectors.toList())
)
)
));
for (String groupId : groupTasks.keySet()) {
List<TaskDto> taskDtos = groupTasks.get(groupId);
// carTaskCount根据value从小到大排序
List<Map.Entry<String, Integer>> sortedEntries = new ArrayList<>(carTaskCount.entrySet());
sortedEntries.sort(Map.Entry.comparingByValue());
// 获取车号
String carNo = null;
for (Map.Entry<String, Integer> entry : sortedEntries) {
String carKey = entry.getKey();
Device deviceByCode = appService.findDeviceByCode(carKey);
AgvNdcOneDeviceDriver deviceDriver = (AgvNdcOneDeviceDriver) deviceByCode.getDeviceDriver();
if (deviceDriver.getStatus() == 2 || deviceDriver.getStatus() == 4) {
carNo = carKey;
carTaskCount.put(carKey, carTaskCount.get(carKey) + 1);
}
}
if (flag) {
acsTask.setRemark("路由不通无法生成指令");
taskserver.update(acsTask);
taskserver.updateByCodeFromCache(acsTask);
continue;
if (carNo == null) {
return;
}
next_device_code = pathlist.get(index);
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
} else {
next_point_code = next_device_code;
}
Instruction instdto = new Instruction();
instdto.setInstruction_type(task_type);
instdto.setInstruction_id(IdUtil.simpleUUID());
if (acsTask.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())){
instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
}
instdto.setRoute_plan_code(route_plan_code);
instdto.setRemark(acsTask.getRemark());
instdto.setMaterial(acsTask.getMaterial());
instdto.setQuantity(acsTask.getQuantity());
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setVehicle_code(vehiclecode);
instdto.setVehicle_code2(vehiclecode2);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
instdto.setStart_device_code(start_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setPut_device_code(put_device_code);
instdto.setPut_point_code(put_point_code);
instdto.setNext_device_code(next_device_code);
instdto.setNext_point_code(next_point_code);
instdto.setStart_point_code2(start_point_code2);
instdto.setStart_device_code2(start_device_code2);
instdto.setNext_point_code2(next_point_code2);
instdto.setNext_device_code2(next_device_code2);
instdto.setPriority(priority);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(start_point_code);
instdto.setVehicle_type(vehicleType);
instdto.setAgv_system_type(agv_system_type);
instdto.setStart_height(start_height);
instdto.setNext_height(next_height);
instdto.setAgv_action_type(agvActionType);
//判断agv系统
//1、1楼叉车系统
//2、2楼1区域AGV系统
//3、2楼2区域AGV系统 -已废弃
if (StrUtil.equals(agv_system_type, CommonFinalParam.TWO)) {
// task_type
//1、生箔 Itype=1:取空,取满,放空,放满;
//2、分切 Itype=3取满、取空、放满、放空
//3、普通任务 Itype=2:取货、放货;
//4、叉车任务
//5、输送任务
//6、行架
//7、立库
if (StrUtil.equals(task_type, CommonFinalParam.ONE)) {
instdto.setAgv_inst_type(CommonFinalParam.ONE);
} else if (StrUtil.equals(task_type, "3")) {
instdto.setAgv_inst_type("2");
} else if (StrUtil.equals(task_type, "2")) {
instdto.setAgv_inst_type("3");
} else if (StrUtil.equals(task_type, "8")) {
instdto.setAgv_inst_type("2");
} else {
log.info("未找到对应的AGV指令类型任务号:" + acsTask.getTask_code() + ",task_type:" + acsTask.getTask_type());
for (int i = 0; i < taskDtos.size(); i++) {
TaskDto acsTask = taskDtos.get(i);
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.AGV_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
continue;
}
} else {
instdto.setAgv_inst_type("4");
}
try {
instructionService.create(instdto);
} catch (Exception e) {
acsTask.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(acsTask);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("定时创建指令失败")
.content(e.getMessage())
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
continue;
}
//创建指令后修改任务状态
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.Truss_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) {
continue;
}
String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code();
String task_type = acsTask.getTask_type();
String vehiclecode = acsTask.getVehicle_code();
String vehiclecode2 = acsTask.getVehicle_code2();
String storage_task_type = acsTask.getStorage_task_type();
String priority = acsTask.getPriority();
String is_send = acsTask.getIs_send();
String start_device_code = acsTask.getStart_device_code();
String start_point_code = acsTask.getStart_point_code();
String put_device_code = acsTask.getPut_device_code();
String put_point_code = acsTask.getPut_point_code();
String next_device_code = acsTask.getNext_device_code();
String next_point_code = acsTask.getNext_point_code();
String start_point_code2 = acsTask.getStart_point_code2();
String start_device_code2 = acsTask.getStart_device_code2();
String next_point_code2 = acsTask.getNext_point_code2();
String next_device_code2 = acsTask.getNext_device_code2();
String route_plan_code = acsTask.getRoute_plan_code();
String vehicleType = acsTask.getVehicle_type();
String agv_system_type = acsTask.getAgv_system_type();
String start_height = acsTask.getStart_height();
String next_height = acsTask.getNext_height();
Integer agvActionType = acsTask.getAgv_action_type();
String taskGroupId = acsTask.getTask_group_id();
BigDecimal taskGroupSeq = acsTask.getTask_group_seq();
if (StrUtil.equals(is_send, "0")) {
continue;
}
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) {
acsTask.setRemark("路由不通无法生成指令");
taskserver.updateByCodeFromCache(acsTask);
continue;
}
if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
continue;
}
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
int index = 0;
boolean flag = false;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
if("1".equals(acsTask.getTask_type()) && !pathlist.get(m+1).equals(next_device_code)){
flag = true;
break;
}
index = m + 1;
break;
}
}
if (flag) {
acsTask.setRemark("路由不通无法生成指令");
taskserver.update(acsTask);
taskserver.updateByCodeFromCache(acsTask);
continue;
}
next_device_code = pathlist.get(index);
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
} else {
next_point_code = next_device_code;
}
Instruction instdto = new Instruction();
instdto.setInstruction_type(task_type);
instdto.setInstruction_id(IdUtil.simpleUUID());
if (acsTask.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())){
instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
}
instdto.setRoute_plan_code(route_plan_code);
instdto.setRemark(acsTask.getRemark());
instdto.setMaterial(acsTask.getMaterial());
instdto.setQuantity(acsTask.getQuantity());
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setVehicle_code(vehiclecode);
instdto.setVehicle_code2(vehiclecode2);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
instdto.setStart_device_code(start_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setPut_device_code(put_device_code);
instdto.setPut_point_code(put_point_code);
instdto.setNext_device_code(next_device_code);
instdto.setNext_point_code(next_point_code);
instdto.setStart_point_code2(start_point_code2);
instdto.setStart_device_code2(start_device_code2);
instdto.setNext_point_code2(next_point_code2);
instdto.setNext_device_code2(next_device_code2);
instdto.setTask_group_id(taskGroupId);
instdto.setTask_group_seq(taskGroupSeq);
instdto.setPriority(priority);
instdto.setCarno(carNo);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(start_point_code);
instdto.setVehicle_type(vehicleType);
instdto.setAgv_system_type(agv_system_type);
instdto.setStart_height(start_height);
instdto.setNext_height(next_height);
instdto.setAgv_action_type(agvActionType);
//判断agv系统
//1、1楼叉车系统
//2、2楼1区域AGV系统
//3、2楼2区域AGV系统 -已废弃
if (ObjectUtil.isEmpty(task_type)) {
log.info("未找到对应的AGV指令类型任务号:" + acsTask.getTask_code() + ",task_type:" + acsTask.getTask_type());
continue;
} else {
instdto.setAgv_inst_type(task_type);
}
try {
instructionService.create(instdto);
} catch (Exception e) {
acsTask.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(acsTask);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("定时创建指令失败")
.content(e.getMessage())
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
continue;
}
//创建指令后修改任务状态
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
acsTask.setUpdate_time(DateUtil.now());
acsTask.setRemark(" ");
taskserver.update(acsTask);
}
}
}
}

View File

@@ -22,6 +22,11 @@ public class EXTConstant {
*/
public final static String SEND_TASK_ACS_API = "api/wms/task";
/**
* 向ACS查询设备信息
*/
public final static String QUERY_DEVICE_INFO_API = "api/wms/querydevice";
/**
* 回传MES接口地址
*/

View File

@@ -1,6 +1,8 @@
package org.nl.wms.ext_manage.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.ext_manage.service.util.AcsResponse;
import org.nl.wms.sch_manage.service.util.AcsTaskDto;
@@ -22,4 +24,11 @@ public interface WmsToAcsService {
* @return AcsResponse
*/
AcsResponse renotifyAcs(List<AcsTaskDto> list);
/**
* 获取设备状态
*
* @return
*/
AcsResponse getPointStatus(JSONArray whereJson);
}

View File

@@ -1,5 +1,7 @@
package org.nl.wms.ext_manage.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.wms.ext_manage.enums.EXTConstant;
import org.nl.wms.ext_manage.service.WmsToAcsService;
@@ -26,4 +28,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
public AcsResponse renotifyAcs(List<AcsTaskDto> list) {
return AcsUtil.notifyAcs(EXTConstant.SEND_TASK_ACS_API, list);
}
@Override
public AcsResponse getPointStatus(JSONArray whereJson) {
return AcsUtil.notifyAcs(EXTConstant.QUERY_DEVICE_INFO_API, whereJson);
}
}

View File

@@ -17,6 +17,8 @@ import org.nl.common.utils.SecurityUtils;
import org.nl.wms.basedata_manage.enums.BaseDataEnum;
import org.nl.wms.basedata_manage.service.*;
import org.nl.wms.basedata_manage.service.dao.*;
import org.nl.wms.ext_manage.service.WmsToAcsService;
import org.nl.wms.ext_manage.service.util.AcsResponse;
import org.nl.wms.pda_manage.sch_manage.service.GroupInfoPdaVo;
import org.nl.wms.pda_manage.sch_manage.service.PdaJBService;
import org.nl.wms.pda_manage.sch_manage.service.mapper.PdaJBMapper;
@@ -114,6 +116,8 @@ public class PdaJBServiceImpl implements PdaJBService {
private ISchBaseTaskService taskService;
@Resource
private IMdCsSupplierbaseService supplierbaseService;
@Resource
private WmsToAcsService wmsToAcsService;
@Override
public PdaResponse getOrderList(JSONObject whereJson) {
String flag = whereJson.getString("flag");
@@ -270,9 +274,19 @@ public class PdaJBServiceImpl implements PdaJBService {
if (ObjectUtil.isEmpty(param)) {
throw new BadRequestException("请先定义 " + JB_STANDARD_ERROR + " 系统参数!");
}
// todo: 调用acs获取
// 调用acs获取
JSONArray req = new JSONArray();
JSONObject device = new JSONObject();
req.add(device);
device.put("device_code", pointCode);
AcsResponse pointStatus = wmsToAcsService.getPointStatus(req);
if (pointStatus.getCode() != 200) {
throw new BadRequestException("ACS读取重量数据失败, 请手动输入重量!");
}
JSONObject deviceInfo = pointStatus.getData().getJSONObject(0);
String netWeight = deviceInfo.getString("net_weight");
JSONObject res = new JSONObject();
res.put("weight", "999.99");
res.put("weight", netWeight);
res.put("flag", "1");
res.put("message", "重量误差范围正常!");
PdmBdWorkorder workorder = workorderService.getById(workorder_id);
@@ -281,10 +295,10 @@ public class PdaJBServiceImpl implements PdaJBService {
}
res.put("org_weight", workorder.getPlan_weight());
res.put("stand_error", param.getValue());
if (workorder.getPlan_weight().subtract(BigDecimal.valueOf(999.99))
if (workorder.getPlan_weight().subtract(new BigDecimal(netWeight))
.abs().compareTo(new BigDecimal(param.getValue().trim())) > 0) {
res.put("flag", "2");
res.put("message", "重量误差过大,请注意!");
res.put("message", "重量误差过大,超过规定阈值,请注意!");
}
return PdaResponse.requestParamOk(res);
}

View File

@@ -1,5 +1,6 @@
package org.nl.wms.sch_manage.service.util;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import java.math.BigDecimal;
@@ -77,6 +78,7 @@ public class AcsTaskDto {
* 任务类型
*/
String task_type;
String truss_type;
/**
* 立库任务类型
@@ -125,7 +127,7 @@ public class AcsTaskDto {
* 扩展属性
*/
Map<String, String> params;
private JSONObject interaction_json;
private String task_group_id;

View File

@@ -87,7 +87,7 @@ public class JbBackAgvTask extends AbstractTask {
public AcsTaskDto sendAcsParam(String taskId) {
SchBaseTask taskDao = taskService.getById(taskId);
SchBaseTaskconfig taskconfig = taskconfigService.getTaskByConfigCode(taskDao.getConfig_code());
JSONObject object = JSONObject.parseObject(taskDao.getRequest_param());
// 组织下发给acs的数据
AcsTaskDto acsTaskDto = new AcsTaskDto();
acsTaskDto.setExt_task_uuid(taskDao.getTask_id());
@@ -101,6 +101,7 @@ public class JbBackAgvTask extends AbstractTask {
acsTaskDto.setTask_type(taskconfig.getTask_type());
acsTaskDto.setTask_group_id(taskDao.getTask_group_id());
acsTaskDto.setTask_group_seq(taskDao.getTask_group_seq());
acsTaskDto.setTruss_type(object.getString("truss_type"));
return acsTaskDto;
}

View File

@@ -89,6 +89,7 @@ public class JbDownAgvTask extends AbstractTask {
public AcsTaskDto sendAcsParam(String taskId) {
SchBaseTask taskDao = taskService.getById(taskId);
SchBaseTaskconfig taskconfig = taskconfigService.getTaskByConfigCode(taskDao.getConfig_code());
JSONObject object = JSONObject.parseObject(taskDao.getRequest_param());
// 组织下发给acs的数据
AcsTaskDto acsTaskDto = new AcsTaskDto();
@@ -103,6 +104,8 @@ public class JbDownAgvTask extends AbstractTask {
acsTaskDto.setPriority(taskDao.getPriority());
acsTaskDto.setAgv_system_type(taskconfig.getAcs_task_type());
acsTaskDto.setTask_type(taskconfig.getTask_type());
acsTaskDto.setTruss_type(object.getString("truss_type"));
acsTaskDto.setInteraction_json(new JSONObject().fluentPut("have_lid", object.getString("have_lid")));
return acsTaskDto;
}
@@ -149,7 +152,7 @@ public class JbDownAgvTask extends AbstractTask {
private void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
// 任务完成
taskObj.setRemark("该任务已完成,等待最后一条任务完成后全部完成");
taskObj.setRemark("该任务已完成,等待最后一条任务完成!");
if ("1".equals(taskObj.getTask_group_seq().toString())) {
// 开盖设置成有盖
SchBasePoint khgPoint = pointService.getById(taskObj.getPoint_code2());

View File

@@ -91,7 +91,7 @@ public class JbUpAgvTask extends AbstractTask {
public AcsTaskDto sendAcsParam(String taskId) {
SchBaseTask taskDao = taskService.getById(taskId);
SchBaseTaskconfig taskconfig = taskconfigService.getTaskByConfigCode(taskDao.getConfig_code());
JSONObject object = JSONObject.parseObject(taskDao.getRequest_param());
// 组织下发给acs的数据
AcsTaskDto acsTaskDto = new AcsTaskDto();
acsTaskDto.setExt_task_uuid(taskDao.getTask_id());
@@ -105,6 +105,7 @@ public class JbUpAgvTask extends AbstractTask {
acsTaskDto.setTask_type(taskconfig.getTask_type());
acsTaskDto.setTask_group_id(taskDao.getTask_group_id());
acsTaskDto.setTask_group_seq(taskDao.getTask_group_seq());
acsTaskDto.setTruss_type(object.getString("truss_type"));
return acsTaskDto;
}

View File

@@ -705,6 +705,8 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
task1.put("point_code2", cfgjPoint.getPoint_code());
task1.put("point_code3", cfgjPoint.getPoint_code());
task1.put("point_code4", emptyPoint.getPoint_code());
task1.put("truss_type", "3");
task1.put("have_lid", "1");
task1.put("vehicle_type", inStruct.getStoragevehicle_type());
task1.put("seq", 1);
// 空托盘
@@ -724,6 +726,8 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
task2.put("point_code2", fullPoint.getPoint_code());
task2.put("point_code3", emptyPoint.getPoint_code());
task2.put("point_code4", intoPoint.getPoint_code());
task2.put("truss_type", "3");
task1.put("have_lid", "0");
task2.put("seq", 2);
// 空托盘
task2.put("vehicle_code", inStruct.getStoragevehicle_code());
@@ -743,6 +747,8 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
task3.put("point_code2", cfgjPoint.getPoint_code());
task3.put("point_code3", cfgjPoint.getPoint_code());
task3.put("point_code4", structCode);
task3.put("truss_type", "3");
task1.put("have_lid", "2");
task3.put("seq", 3);
// 空托盘
task3.put("vehicle_code", inStruct.getStoragevehicle_code());