opt: ndc驱动、解包完善

This commit is contained in:
2025-09-15 13:20:56 +08:00
parent 53b6c5bd7a
commit 8a30bc065d
19 changed files with 395 additions and 390 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,10 +84,11 @@ 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;
// 车号。。。
String carno = inst.getCarno();
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
@@ -108,6 +108,8 @@ public class NDCAgvServiceImpl implements NDCAgvService {
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));
@@ -129,143 +131,32 @@ public class NDCAgvServiceImpl implements NDCAgvService {
str += "优先级 /priority:" + (priority);
str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF);
byte[] b = new byte[]{};
if (type == 1) {
b = new byte[]{(byte) 0X87, (byte) 0XCD,
str += "车号 /carno:" + (carno);
str1 += "车号 /carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF);
byte[] b = new byte[]{
(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X16,
(byte) 0X00, (byte) 0X18,
(byte) 0X00, (byte) 0X01,
(byte) 0X00, (byte) 0X71,
(byte) 0X00, (byte) 0X12,
(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) fhdhigh, (byte) fhdlow,
(byte) fhdhigh2, (byte) fhdlow2
(byte) fhdhigh2, (byte) fhdlow2,
(byte) carhigh, (byte) carlow
};
} 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));
if (StrUtil.equals(agv_system_type, "2")) {
TwoNDCSocketConnectionAutoRun.write(b);
}
} else {
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));
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

@@ -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,8 +64,41 @@ 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);
// 根据任务组别分组
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 (carNo == null) {
return;
}
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;
}
@@ -95,6 +137,8 @@ public class AutoCreateInst {
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;
@@ -174,7 +218,11 @@ public class AutoCreateInst {
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);
@@ -186,30 +234,14 @@ public class AutoCreateInst {
//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 {
if (ObjectUtil.isEmpty(task_type)) {
log.info("未找到对应的AGV指令类型任务号:" + acsTask.getTask_code() + ",task_type:" + acsTask.getTask_type());
continue;
}
} else {
instdto.setAgv_inst_type("4");
instdto.setAgv_inst_type(task_type);
}
try {
instructionService.create(instdto);
} catch (Exception e) {
@@ -231,4 +263,5 @@ public class AutoCreateInst {
}
}
}
}

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());