fix: 叉车二次分配

This commit is contained in:
2024-06-21 08:56:49 +08:00
parent 06e7f163e2
commit c7dd36d940
18 changed files with 969 additions and 378 deletions

View File

@@ -53,6 +53,7 @@ public class AgvWaitUtil {
if(manipulatorAgvStationDeviceDriver.getAction() != 1){
throw new BadRequestException("上位系统不允许取货");
}
}
//agv叉车对接位安全信号交互
if(startDevice.getDeviceDriver() instanceof BoxSubvolumesConveyorDeviceDriver){

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
@@ -23,6 +24,9 @@ import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.InteractionJsonDTO;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.device.enums.DeviceType;
import org.nl.acs.task.enums.ActionTypeEnum;
import org.nl.acs.task.enums.AgvActionTypeEnum;
import org.nl.acs.task.enums.AgvSystemTypeEnum;
import org.nl.common.exception.BadRequestException;
import org.nl.config.language.LangProcess;
import org.nl.config.lucene.service.LuceneExecuteLogService;
@@ -32,10 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author 20220102CG\noblelift
@@ -251,7 +252,11 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
jo.put("id", inst.getInstruction_code());
//运单封口,true=创建运单之后不可添加动作块;false=创建运单可以添加动作块
jo.put("complete", true);
if (AgvActionTypeEnum.ORDINARY.getCode().equals(inst.getAgv_action_type())) {
jo.put("complete", true);
} else {
jo.put("complete", false);
}
//动作块
jo.put("blocks", createBlocksData(inst));
//运单优先级
@@ -262,7 +267,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
log.info("任务号:{},指令号{},下发agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo);
log.info("任务号:{},指令号{},下发诺宝运单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo);
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
@@ -304,22 +309,14 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
String start_point_code = inst.getStart_point_code();
String next_device_code = inst.getNext_device_code();
String next_point_code = inst.getNext_point_code();
String start_device_code2 = inst.getStart_device_code2();
String start_point_code2 = inst.getStart_point_code2();
String next_device_code2 = inst.getNext_device_code2();
String next_point_code2 = inst.getNext_point_code2();
Integer agv_action_type = inst.getAgv_action_type();
//起点1
sendStartDeviceOrder(ja, start_device_code, start_point_code, instruction_code);
sendStartDeviceOrder(ja, start_device_code, start_point_code, instruction_code, agv_action_type);
//终点1
sendEndDeviceOrder(ja, start_device_code, instruction_code, next_point_code, next_device_code);
//起点2
if (StrUtil.isNotEmpty(start_device_code2)) {
sendStartDeviceOrder(ja, start_device_code2, start_point_code2, instruction_code);
}
//终点2
if (StrUtil.isNotEmpty(next_device_code2)) {
sendEndDeviceOrder(ja, start_device_code2, instruction_code, next_device_code2, next_point_code2);
}
sendEndDeviceOrder(ja, start_device_code, instruction_code, next_point_code, next_device_code, agv_action_type);
return ja;
}
@@ -327,11 +324,12 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
* 下发取货信号
*
* @param ja
* @param pointCode 起始点位
* @param device_code 起始设备
* @param instCode 指令号
* @param pointCode 起始点位
* @param device_code 起始设备
* @param instCode 指令号
* @param agv_action_type
*/
public void sendStartDeviceOrder(JSONArray ja, String pointCode, String device_code, String instCode) {
public void sendStartDeviceOrder(JSONArray ja, String pointCode, String device_code, String instCode, Integer agv_action_type) {
Device startDevice = deviceAppService.findDeviceByCode(device_code);
//取货前等待
JSONObject jo = new JSONObject();
@@ -357,110 +355,99 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
jo.put("script_args", script_args);
ja.add(jo);
//将货物顶起来,机器识别提升高度
JSONObject jo1 = new JSONObject();
jo1.put("blockId", IdUtil.simpleUUID());
jo1.put("location", pointCode);
jo1.put("operation", "JackLoad");
jo1.put("operationArgs", new JSONObject() {{
put("recognize", true);
}});
ja.add(jo1);
if (AgvActionTypeEnum.ORDINARY.getCode().equals(agv_action_type) || AgvActionTypeEnum.OUT_STOCK.getCode().equals(agv_action_type)) {
//将货物顶起来,机器识别提升高度
JSONObject jo1 = new JSONObject();
jo1.put("blockId", IdUtil.simpleUUID());
jo1.put("location", pointCode);
jo1.put("operation", "JackLoad");
jo1.put("operationArgs", new JSONObject() {{
put("recognize", true);
}});
ja.add(jo1);
JSONObject jo2 = new JSONObject();
jo2.put("blockId", IdUtil.simpleUUID());
jo2.put("location", pointCode + "OUTGET");
jo2.put("operation", "script");
jo2.put("id", pointCode + "OUTGET");
jo2.put("script_name", "userpy/interact.py");
JSONObject script_args2 = new JSONObject();
script_args2.put("addr", addr);
JSONObject data2 = new JSONObject();
JSONObject reach2 = new JSONObject();
reach2.put("task_code", instCode);
reach2.put("address", pointCode + "OUTGET");
data2.put("reach", reach2);
script_args2.put("data", data2);
script_args2.put("protocol", "HTTP");
jo2.put("script_args", script_args2);
ja.add(jo2);
JSONObject jo2 = new JSONObject();
jo2.put("blockId", IdUtil.simpleUUID());
jo2.put("location", pointCode + "OUTGET");
jo2.put("operation", "script");
jo2.put("id", pointCode + "OUTGET");
jo2.put("script_name", "userpy/interact.py");
JSONObject script_args2 = new JSONObject();
script_args2.put("addr", addr);
JSONObject data2 = new JSONObject();
JSONObject reach2 = new JSONObject();
reach2.put("task_code", instCode);
reach2.put("address", pointCode + "OUTGET");
data2.put("reach", reach2);
script_args2.put("data", data2);
script_args2.put("protocol", "HTTP");
jo2.put("script_args", script_args2);
ja.add(jo2);
}
}
/**
* 下发放货信号
*
* @param ja
* @param device_code 起始设备
* @param instCode 指令号
* @param pointCode 终点点位
* @param nextDeviceCode 终点设备
* @param device_code 起始设备
* @param instCode 指令号
* @param pointCode 终点点位
* @param nextDeviceCode 终点设备
* @param agv_action_type
*/
public void sendEndDeviceOrder(JSONArray ja, String device_code, String instCode, String pointCode, String nextDeviceCode) {
public void sendEndDeviceOrder(JSONArray ja, String device_code, String instCode, String pointCode, String nextDeviceCode, Integer agv_action_type) {
Device nextDevice = deviceAppService.findDeviceByCode(nextDeviceCode);
if (!AgvActionTypeEnum.IN_STOCK.getCode().equals(agv_action_type)) {
//放货前等待
JSONObject jo3 = new JSONObject();
jo3.put("blockId", IdUtil.simpleUUID());
jo3.put("location", pointCode + "INPUT");
jo3.put("operation", "script");
jo3.put("id", pointCode + "INPUT");
jo3.put("script_name", "userpy/interact.py");
JSONObject script_args3 = new JSONObject();
script_args3.put("addr", addr);
JSONObject data3 = new JSONObject();
JSONObject reach3 = new JSONObject();
reach3.put("task_code", instCode);
reach3.put("address", pointCode + "INPUT");
data3.put("reach", reach3);
script_args3.put("data", data3);
script_args3.put("protocol", "HTTP");
jo3.put("script_args", script_args3);
ja.add(jo3);
//放货前等待
JSONObject jo3 = new JSONObject();
jo3.put("blockId", IdUtil.simpleUUID());
jo3.put("location", pointCode + "INPUT");
jo3.put("operation", "script");
jo3.put("id", pointCode + "INPUT");
jo3.put("script_name", "userpy/interact.py");
JSONObject script_args3 = new JSONObject();
script_args3.put("addr", addr);
JSONObject data3 = new JSONObject();
JSONObject reach3 = new JSONObject();
reach3.put("task_code", instCode);
reach3.put("address", pointCode + "INPUT");
data3.put("reach", reach3);
script_args3.put("data", data3);
script_args3.put("protocol", "HTTP");
jo3.put("script_args", script_args3);
ja.add(jo3);
if (AgvActionTypeEnum.ORDINARY.getCode().equals(agv_action_type)) {
//将货物放下
com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject();
jo4.put("blockId", IdUtil.simpleUUID());
jo4.put("location", pointCode);
jo4.put("operation", "JackUnload");
ja.add(jo4);
//放货前下发旋转角度
/*JSONObject json1 = new JSONObject();
AcsPointAngle acsPointAngleDto = acsPointAngleService.findByCode(device_code, nextDeviceCode);
if (ObjectUtil.isNotEmpty(acsPointAngleDto)) {
log.info("acsPointAngleDto----參數,{}", acsPointAngleDto.toString());
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
BigDecimal next_point_angle = acsPointAngleDto.getNext_point_angle();
operation_args.put("increase_spin_angle", next_point_angle);//弧度值如3.14
operation_args.put("skill_name", "GoByOdometer");
json1.put("blockId", IdUtil.simpleUUID());
json1.put("location", pointCode + "INPUT");
json1.put("operation_args", operation_args);
ja.add(json1);
}*/
//将货物放下
com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject();
jo4.put("blockId", IdUtil.simpleUUID());
jo4.put("location", pointCode);
jo4.put("operation", "JackUnload");
ja.add(jo4);
//放货完成等待
com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject();
jo5.put("blockId", IdUtil.simpleUUID());
jo5.put("location", pointCode + "OUTPUT");
jo5.put("operation", "script");
jo5.put("id", pointCode + "OUTPUT");
jo5.put("script_name", "userpy/interact.py");
com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject();
script_args5.put("addr", addr);
com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject();
com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject();
reach5.put("task_code", instCode);
reach5.put("address", pointCode + "OUTPUT");
data5.put("reach", reach5);
script_args5.put("data", data5);
script_args5.put("protocol", "HTTP");
jo5.put("script_args", script_args5);
ja.add(jo5);
//放货完成等待
com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject();
jo5.put("blockId", IdUtil.simpleUUID());
jo5.put("location", pointCode + "OUTPUT");
jo5.put("operation", "script");
jo5.put("id", pointCode + "OUTPUT");
jo5.put("script_name", "userpy/interact.py");
com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject();
script_args5.put("addr", addr);
com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject();
com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject();
reach5.put("task_code", instCode);
reach5.put("address", pointCode + "OUTPUT");
data5.put("reach", reach5);
script_args5.put("data", data5);
script_args5.put("protocol", "HTTP");
jo5.put("script_args", script_args5);
ja.add(jo5);
}
}
}
@@ -709,14 +696,33 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
throw new BadRequestException("请求失败,地址为空!");
}
if (address.contains("IN")) {
String instructionCode = instructionDto.getInstruction_code();
String deviceCodeNow = address.substring(0, address.length() - 5);
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
}
if (address.contains("GET")) {
if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
//如果是取货二次分配,取放货二次分配需要重新追加动作块
if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
Integer actionType = ActionTypeEnum.IN_STOCK.getCode();
deviceCodeNow = applyXGAgvTask(instructionCode, actionType, instructionDto);
}
} else if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
}
return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
} else if (address.contains("PUT")) {
if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
//如果是放货二次分配,取放货二次分配需要重新追加动作块
if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
Integer actionType = ActionTypeEnum.OUT_STOCK.getCode();
deviceCodeNow = applyXGAgvTask(instructionCode, actionType, instructionDto);
}
} else if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
Integer actionType = ActionTypeEnum.OUT_STOCK.getCode();
deviceCodeNow = applyCCAgvTask(instructionCode, actionType, instructionDto);
}
return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
}
}
@@ -736,6 +742,102 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
throw new BadRequestException("请求失败IN OUT 站点错误!");
}
private String applyCCAgvTask(String instructionCode, Integer actionType, Instruction instructionDto) {
try {
JSONObject param = new JSONObject();
param.put("taskCode", instructionCode);
param.put("actionType", actionType.toString());
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("追加动叉车作块:")
.content("追加动叉车作块,参数:" + instructionCode + "--" + actionType)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
String response = acsToWmsService.secondaryAllocationPoint(param);
JSONObject jo = JSON.parseObject(response);
if (jo.getInteger("status") == 200) {
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code("追加动叉车作块:")
.content("追加动叉车作块,参数,接口返回:" + jo)
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
//请求成功调用叉车追加动作块
sendAddSequencesToCCAgv(instructionCode, jo.getString("data"), instructionDto);
return jo.getString("data");
} else {
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code("追加动叉车作块:")
.content("追加动叉车作块失败,返回参数:" + jo.getString("body"))
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
throw new BadRequestException("追加动叉车作块返回失败");
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private void sendAddSequencesToCCAgv(String instructionCode, String nextPoint, Instruction instructionDto) {
com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
jo.put("id", instructionCode);
//动作块
jo.put("blocks", createBlocksDataTowCCStart(nextPoint));
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("追加诺宝运单")
.content("指令号:" + instructionCode + ",追加诺宝运单参数:" + jo)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
log.info("任务号:{},指令号{},追加诺宝运单:{}", instructionCode, instructionCode, jo);
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
agvurl = agvurl + ":" + agvport + "/addBlocks";
log.info(agvurl);
HttpResponse result = HttpRequest.post(agvurl)
//表单内容
.body(String.valueOf(jo))
//超时,毫秒
.timeout(20000)
.execute();
LuceneLogDto logDto1 = LuceneLogDto.builder()
.device_code("叉车运单响应")
.content("指令号:" + instructionCode + ",下发追加诺宝运单反馈参数:" + jo)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto1);
log.info("指令号{},状态{},下发追加诺宝运单序列反馈:{}", instructionCode, result.getStatus(), result.body());
}
}
private Object createBlocksDataTowCCStart(String nextPoint) {
JSONArray ja = new JSONArray();
JSONObject jo9 = new JSONObject();
jo9.put("blockId", IdUtil.simpleUUID());
jo9.put("location", nextPoint);
jo9.put("binTask", "ForkUnload");
ja.add(jo9);
JSONObject jo10 = new JSONObject();
jo10.put("blockId", IdUtil.simpleUUID());
jo10.put("location", nextPoint + "OUTPUT");
jo10.put("binTask", "OutForkHeight");
ja.add(jo10);
return ja;
}
@Override
public HttpResponse getRobotInfo(String robotCode) {
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
@@ -754,14 +856,61 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
}
}
private String applyXGAgvTask(String instructionCode, Integer actionType, Instruction instructionDto) {
try {
JSONObject param = new JSONObject();
param.put("taskCode", instructionCode);
param.put("actionType", actionType.toString());
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("追加动诺宝作块:")
.content("追加动诺宝作块,参数:" + instructionCode + "--" + actionType)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
String response = acsToWmsService.secondaryAllocationPoint(param);
JSONObject jo = JSON.parseObject(response);
if (jo.getInteger("status") == 200) {
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code("追加动诺宝作块:")
.content("追加动诺宝作块,参数,接口返回:" + jo)
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
if (!ActionTypeEnum.IN_FINISHING.getCode().equals(actionType)) {
//请求成功调用诺宝追加动作块
sendAddSequencesToNBAgv(instructionCode, jo.getString("data"), instructionDto);
}
return jo.getString("data");
} else {
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code("追加动诺宝作块:")
.content("追加动诺宝作块失败,返回参数:" + jo.getString("body"))
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
throw new BadRequestException("追加动诺宝作块返回失败");
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public HttpResponse sendOrderSequencesToForklift(Instruction inst, InteractionJsonDTO interactionJsonDTO) {
com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
jo.put("id", inst.getInstruction_code());
//运单封口,true=创建运单之后不可添加动作块;false=创建运单可以添加动作块
jo.put("complete", true);
//动作块
jo.put("blocks", createBlocksForklift(inst,interactionJsonDTO));
//运单封口,true=创建运单之后不可添加动作块;false=创建运单可以添加动作块
if (AgvActionTypeEnum.ORDINARY.getCode().equals(inst.getAgv_action_type())) {
jo.put("complete", true);
} else {
jo.put("complete", false);
} //动作块
jo.put("blocks", createBlocksForklift(inst, interactionJsonDTO));
//运单优先级
jo.put("priority", inst.getPriority());
LuceneLogDto logDto = LuceneLogDto.builder()
@@ -799,6 +948,184 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
}
}
/**
* 追加动作块
*
* @param
* @param instructionCode
* @param instructionDto
* @return
*/
private void sendAddSequencesToNBAgv(String instructionCode, String point, Instruction instructionDto) {
com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
jo.put("id", instructionCode);
//动作块
if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
jo.put("blocks", createBlocksDataTowStart(instructionCode, point, instructionDto));
}
if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
jo.put("blocks", createBlocksDataTowEnd(instructionCode, point, instructionDto));
}
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("追加诺宝运单")
.content("指令号:" + instructionCode + ",追加诺宝运单参数:" + jo)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
log.info("任务号:{},指令号{},追加诺宝运单:{}", instructionCode, point, jo);
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
agvurl = agvurl + ":" + agvport + "/addBlocks";
log.info(agvurl);
HttpResponse result = HttpRequest.post(agvurl)
//表单内容
.body(String.valueOf(jo))
//超时,毫秒
.timeout(20000)
.execute();
LuceneLogDto logDto1 = LuceneLogDto.builder()
.device_code("叉车运单响应")
.content("指令号:" + instructionCode + ",下发追加诺宝运单反馈参数:" + jo)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto1);
log.info("指令号{},状态{},下发追加诺宝运单序列反馈:{}", instructionCode, result.getStatus(), result.body());
}
}
private Object createBlocksDataTowEnd(String instructionCode, String point, Instruction instructionDto) {
JSONArray ja = new JSONArray();
String nextDeviceCode = instructionDto.getNext_device_code();
//终点2
sendEndDeviceOrder3(ja, nextDeviceCode, instructionCode, instructionDto);
return ja;
}
private void sendEndDeviceOrder3(JSONArray ja, String nextDeviceCode, String instructionCode, Instruction instructionDto) {
//将货物放下
com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject();
jo4.put("blockId", IdUtil.simpleUUID());
jo4.put("location", nextDeviceCode);
jo4.put("operation", "JackUnload");
ja.add(jo4);
//放货完成等待
com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject();
jo5.put("blockId", IdUtil.simpleUUID());
jo5.put("location", nextDeviceCode + "OUTPUT");
jo5.put("operation", "script");
jo5.put("id", nextDeviceCode + "OUTPUT");
jo5.put("script_name", "userpy/interact.py");
com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject();
script_args5.put("addr", addr);
com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject();
com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject();
reach5.put("task_code", instructionCode);
reach5.put("address", nextDeviceCode + "OUTPUT");
data5.put("reach", reach5);
script_args5.put("data", data5);
script_args5.put("protocol", "HTTP");
jo5.put("script_args", script_args5);
ja.add(jo5);
}
private Object createBlocksDataTowStart(String instructionCode, String startPoint, Instruction instructionDto) {
JSONArray ja = new JSONArray();
String nextDeviceCode = instructionDto.getNext_device_code();
//起点2
sendStartDeviceOrder2(ja, startPoint, instructionCode);
//终点2
sendEndDeviceOrder2(ja, nextDeviceCode, instructionCode, instructionDto);
return ja;
}
private void sendEndDeviceOrder2(JSONArray ja, String nextDeviceCode, String instructionCode, Instruction instructionDto) {
//放货前等待
JSONObject jo3 = new JSONObject();
jo3.put("blockId", IdUtil.simpleUUID());
jo3.put("location", nextDeviceCode + "INPUT");
jo3.put("operation", "script");
jo3.put("id", nextDeviceCode + "INPUT");
jo3.put("script_name", "userpy/interact.py");
JSONObject script_args3 = new JSONObject();
script_args3.put("addr", addr);
JSONObject data3 = new JSONObject();
JSONObject reach3 = new JSONObject();
reach3.put("task_code", instructionCode);
reach3.put("address", nextDeviceCode + "INPUT");
data3.put("reach", reach3);
script_args3.put("data", data3);
script_args3.put("protocol", "HTTP");
jo3.put("script_args", script_args3);
ja.add(jo3);
if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type())) {
//将货物放下
com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject();
jo4.put("blockId", IdUtil.simpleUUID());
jo4.put("location", nextDeviceCode);
jo4.put("operation", "JackUnload");
ja.add(jo4);
//放货完成等待
com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject();
jo5.put("blockId", IdUtil.simpleUUID());
jo5.put("location", nextDeviceCode + "OUTPUT");
jo5.put("operation", "script");
jo5.put("id", nextDeviceCode + "OUTPUT");
jo5.put("script_name", "userpy/interact.py");
com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject();
script_args5.put("addr", addr);
com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject();
com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject();
reach5.put("task_code", instructionCode);
reach5.put("address", nextDeviceCode + "OUTPUT");
data5.put("reach", reach5);
script_args5.put("data", data5);
script_args5.put("protocol", "HTTP");
jo5.put("script_args", script_args5);
ja.add(jo5);
}
}
private void sendStartDeviceOrder2(JSONArray ja, String startPoint, String instructionCode) {
//将货物顶起来,机器识别提升高度
JSONObject jo1 = new JSONObject();
jo1.put("blockId", IdUtil.simpleUUID());
jo1.put("location", startPoint);
jo1.put("operation", "JackLoad");
jo1.put("operationArgs", new JSONObject() {{
put("recognize", true);
}});
ja.add(jo1);
JSONObject jo2 = new JSONObject();
jo2.put("blockId", IdUtil.simpleUUID());
jo2.put("location", startPoint + "OUTGET");
jo2.put("operation", "script");
jo2.put("id", startPoint + "OUTGET");
jo2.put("script_name", "userpy/interact.py");
JSONObject script_args2 = new JSONObject();
script_args2.put("addr", addr);
JSONObject data2 = new JSONObject();
JSONObject reach2 = new JSONObject();
reach2.put("task_code", instructionCode);
reach2.put("address", startPoint + "OUTGET");
data2.put("reach", reach2);
script_args2.put("data", data2);
script_args2.put("protocol", "HTTP");
jo2.put("script_args", script_args2);
ja.add(jo2);
}
/**
* 叉车运单动作块
*
@@ -813,7 +1140,6 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
String pointCode = inst.getStart_point_code();
//取货前等待
JSONObject jo = new JSONObject();
//动作块id
@@ -838,100 +1164,208 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
jo.put("script_args", script_args);
ja.add(jo);
if (AgvActionTypeEnum.ORDINARY.getCode().equals(inst.getAgv_action_type())) {
// to do
JSONObject jo1 = new JSONObject();
jo1.put("blockId", IdUtil.simpleUUID());
jo1.put("location", inst.getStart_point_code() + "INGET");
jo1.put("binTask", "InForkHeight");
ja.add(jo1);
JSONObject jo1 = new JSONObject();
jo1.put("blockId", IdUtil.simpleUUID());
jo1.put("location", inst.getStart_point_code()+ "INGET");
jo1.put("binTask", "InForkHeight");
ja.add(jo1);
JSONObject jo3 = new JSONObject();
//动作块id
jo3.put("blockId", IdUtil.simpleUUID());
//目的地名称
jo3.put("location", pointCode + "INGET");
jo3.put("id", pointCode + "INGET");
//执行脚本
jo3.put("operation", "expand");
//通信脚本,动作前后与现场设备交互的场景
jo3.put("script_name", "Fork-expand.py");
JSONObject script_args2 = new JSONObject();
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
script_args2.put("expandWidth", interactionJsonDTO.getExpandWidthLength());
}
script_args2.put("operation", "expand");
jo3.put("script_args", script_args2);
ja.add(jo3);
JSONObject jo4 = new JSONObject();
//动作块id
jo4.put("blockId", IdUtil.simpleUUID());
//目的地名称
jo4.put("location", pointCode + "INGET");
jo4.put("id", pointCode + "INGET");
//执行脚本
jo4.put("operation", "stretch");
//通信脚本,动作前后与现场设备交互的场景
jo4.put("script_name", "Fork-expand.py");
JSONObject script_args1 = new JSONObject();
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
script_args1.put("stretchLength", interactionJsonDTO.getExpandWidthLength());
}
script_args1.put("operation", "stretch");
jo4.put("script_args", script_args1);
ja.add(jo4);
JSONObject jo6 = new JSONObject();
jo6.put("blockId", IdUtil.simpleUUID());
jo6.put("location", inst.getStart_point_code());
jo6.put("binTask", "Script");
ja.add(jo6);
JSONObject jo7 = new JSONObject();
jo7.put("blockId", IdUtil.simpleUUID());
jo7.put("location", inst.getStart_point_code());
jo7.put("binTask", "ForkLoad");
ja.add(jo7);
//取货完成
JSONObject jo2 = new JSONObject();
jo2.put("blockId", IdUtil.simpleUUID());
jo2.put("location", pointCode + "OUTGET");
jo2.put("operation", "script");
jo2.put("id", pointCode + "OUTGET");
jo2.put("script_name", "userpy/interact.py");
JSONObject script_args4 = new JSONObject();
script_args4.put("addr", addr);
JSONObject data2 = new JSONObject();
JSONObject reach2 = new JSONObject();
reach2.put("task_code", inst.getInstruction_code());
reach2.put("address", pointCode + "OUTGET");
data2.put("reach", reach2);
script_args4.put("data", data2);
script_args4.put("protocol", "HTTP");
jo2.put("script_args", script_args4);
ja.add(jo2);
//ForkUnload(货叉卸载货物,会将叉车的状态变成非载货中)
JSONObject jo8 = new JSONObject();
jo8.put("blockId", IdUtil.simpleUUID());
jo8.put("location", inst.getStart_point_code() + "OUTGET");
jo8.put("binTask", "OutForkHeight");
ja.add(jo8);
JSONObject jo9 = new JSONObject();
jo9.put("blockId", IdUtil.simpleUUID());
jo9.put("location", inst.getNext_point_code());
jo9.put("binTask", "ForkUnload");
ja.add(jo9);
JSONObject jo10 = new JSONObject();
jo10.put("blockId", IdUtil.simpleUUID());
jo10.put("location", inst.getNext_point_code() + "OUTPUT");
jo10.put("binTask", "OutForkHeight");
ja.add(jo10);
} else if (AgvActionTypeEnum.IN_STOCK.getCode().equals(inst.getAgv_action_type())) {
} else if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(inst.getAgv_action_type())) {
// to do
JSONObject jo1 = new JSONObject();
jo1.put("blockId", IdUtil.simpleUUID());
jo1.put("location", inst.getStart_point_code() + "INGET");
jo1.put("binTask", "InForkHeight");
ja.add(jo1);
JSONObject jo3 = new JSONObject();
//动作块id
jo3.put("blockId", IdUtil.simpleUUID());
//目的地名称
jo3.put("location", pointCode + "INGET");
jo3.put("id", pointCode + "INGET");
//执行脚本
jo3.put("operation", "expand");
//通信脚本,动作前后与现场设备交互的场景
jo3.put("script_name", "Fork-expand.py");
JSONObject script_args2 = new JSONObject();
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
script_args2.put("expandWidth", interactionJsonDTO.getExpandWidthLength());
}
script_args2.put("operation", "expand");
jo3.put("script_args", script_args2);
ja.add(jo3);
JSONObject jo4 = new JSONObject();
//动作块id
jo4.put("blockId", IdUtil.simpleUUID());
//目的地名称
jo4.put("location", pointCode + "INGET");
jo4.put("id", pointCode + "INGET");
//执行脚本
jo4.put("operation", "stretch");
//通信脚本,动作前后与现场设备交互的场景
jo4.put("script_name", "Fork-expand.py");
JSONObject script_args1 = new JSONObject();
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
script_args1.put("stretchLength", interactionJsonDTO.getExpandWidthLength());
}
script_args1.put("operation", "stretch");
jo4.put("script_args", script_args1);
ja.add(jo4);
JSONObject jo6 = new JSONObject();
jo6.put("blockId", IdUtil.simpleUUID());
jo6.put("location", inst.getStart_point_code());
jo6.put("binTask", "Script");
ja.add(jo6);
JSONObject jo7 = new JSONObject();
jo7.put("blockId", IdUtil.simpleUUID());
jo7.put("location", inst.getStart_point_code());
jo7.put("binTask", "ForkLoad");
ja.add(jo7);
//取货完成
JSONObject jo2 = new JSONObject();
jo2.put("blockId", IdUtil.simpleUUID());
jo2.put("location", pointCode + "OUTGET");
jo2.put("operation", "script");
jo2.put("id", pointCode + "OUTGET");
jo2.put("script_name", "userpy/interact.py");
JSONObject script_args4 = new JSONObject();
script_args4.put("addr", addr);
JSONObject data2 = new JSONObject();
JSONObject reach2 = new JSONObject();
reach2.put("task_code", inst.getInstruction_code());
reach2.put("address", pointCode + "OUTGET");
data2.put("reach", reach2);
script_args4.put("data", data2);
script_args4.put("protocol", "HTTP");
jo2.put("script_args", script_args4);
ja.add(jo2);
//ForkUnload(货叉卸载货物,会将叉车的状态变成非载货中)
JSONObject jo8 = new JSONObject();
jo8.put("blockId", IdUtil.simpleUUID());
jo8.put("location", inst.getStart_point_code() + "OUTGET");
jo8.put("binTask", "OutForkHeight");
ja.add(jo8);
JSONObject jo9 = new JSONObject();
jo9.put("blockId", IdUtil.simpleUUID());
jo9.put("location", pointCode + "INPUT");
jo9.put("operation", "script");
jo9.put("id", pointCode + "INPUT");
jo9.put("script_name", "userpy/interact.py");
JSONObject script_args5 = new JSONObject();
script_args5.put("addr", addr);
JSONObject data3 = new JSONObject();
JSONObject reach3 = new JSONObject();
reach3.put("task_code", inst.getInstruction_code());
reach3.put("address", pointCode + "INPUT");
data3.put("reach", reach3);
script_args5.put("data", data3);
script_args5.put("protocol", "HTTP");
jo9.put("script_args", script_args5);
ja.add(jo9);
} else if (AgvActionTypeEnum.IN_STOCK.getCode().equals(inst.getAgv_action_type())) {
JSONObject jo3 = new JSONObject();
//动作块id
jo3.put("blockId", IdUtil.simpleUUID());
//目的地名称
jo3.put("location", pointCode + "INGET");
jo3.put("id", pointCode + "INGET");
//执行脚本
jo3.put("operation", "expand");
//通信脚本,动作前后与现场设备交互的场景
jo3.put("script_name", "Fork-expand.py");
JSONObject script_args2 = new JSONObject();
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
script_args2.put("expandWidth",interactionJsonDTO.getExpandWidthLength());
}
script_args2.put("operation", "expand");
jo3.put("script_args", script_args2);
ja.add(jo3);
JSONObject jo4 = new JSONObject();
//动作块id
jo4.put("blockId", IdUtil.simpleUUID());
//目的地名称
jo4.put("location", pointCode + "INGET");
jo4.put("id", pointCode + "INGET");
//执行脚本
jo4.put("operation", "stretch");
//通信脚本,动作前后与现场设备交互的场景
jo4.put("script_name", "Fork-expand.py");
JSONObject script_args1 = new JSONObject();
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getExpandWidthLength())) {
script_args2.put("stretchLength",interactionJsonDTO.getExpandWidthLength());
}
script_args1.put("operation", "stretch");
jo4.put("script_args", script_args1);
ja.add(jo4);
JSONObject jo6 = new JSONObject();
jo6.put("blockId", IdUtil.simpleUUID());
jo6.put("location", inst.getStart_point_code());
jo6.put("binTask", "Script");
ja.add(jo6);
JSONObject jo7 = new JSONObject();
jo7.put("blockId", IdUtil.simpleUUID());
jo7.put("location", inst.getStart_point_code());
jo7.put("binTask", "ForkLoad");
ja.add(jo7);
//取货完成
JSONObject jo2 = new JSONObject();
jo2.put("blockId", IdUtil.simpleUUID());
jo2.put("location", pointCode + "OUTGET");
jo2.put("operation", "script");
jo2.put("id", pointCode + "OUTGET");
jo2.put("script_name", "userpy/interact.py");
JSONObject script_args4 = new JSONObject();
script_args4.put("addr", addr);
JSONObject data2 = new JSONObject();
JSONObject reach2 = new JSONObject();
reach2.put("task_code", inst.getInstruction_code());
reach2.put("address", pointCode + "OUTGET");
data2.put("reach", reach2);
script_args4.put("data", data2);
script_args4.put("protocol", "HTTP");
jo2.put("script_args", script_args4);
ja.add(jo2);
//ForkUnload(货叉卸载货物,会将叉车的状态变成非载货中)
JSONObject jo8 = new JSONObject();
jo8.put("blockId", IdUtil.simpleUUID());
jo8.put("location", inst.getStart_point_code()+"OUTGET");
jo8.put("binTask", "OutForkHeight");
ja.add(jo8);
JSONObject jo9 = new JSONObject();
jo9.put("blockId", IdUtil.simpleUUID());
jo9.put("location", inst.getNext_point_code());
jo9.put("binTask", "ForkUnload");
ja.add(jo9);
JSONObject jo10 = new JSONObject();
jo10.put("blockId", IdUtil.simpleUUID());
jo10.put("location", inst.getNext_point_code()+"OUTPUT");
jo10.put("binTask", "OutForkHeight");
ja.add(jo10);
return ja;
}

View File

@@ -262,11 +262,11 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
case 25:
if ( StrUtil.isEmpty(material_barcode)) {
message = "子卷码为空";
}
//二楼到一楼输送线申请行架任务
if (move == 1 && !requireSucess) {
applyManipulatorTask();
}else {
//二楼到一楼输送线申请行架任务
if (move == 1 && !requireSucess) {
applyManipulatorTask();
}
}
break;
}

View File

@@ -234,8 +234,9 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
if (move == 1 && !requireSucess) {
if (StrUtil.isEmpty(material_barcode)) {
message = "条码为空";
}else {
applyAgvTask();
}
applyAgvTask();
}
break;

View File

@@ -210,7 +210,7 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
}
if (move != last_move && move==0 && last_move==1) {
if (move != last_move && move == 0 && last_move == 1) {
requireSucess = false;
clearWrite();
}
@@ -244,21 +244,21 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
//申请空托盘入库
if (mode == 9 && move == 1 && !requireSucess) {
if (container_type==0){
if (container_type == 0) {
message = "托盘类型为空";
} else {
applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode);
}
applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode);
}
//申请空托盘出库
if (mode == 8 && !requireSucess) {
if (container_type==0){
if (container_type == 0) {
message = "托盘类型为空";
} else {
applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType(), mode);
}
applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType(), mode);
}
@@ -315,21 +315,21 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
List list = new ArrayList<>();
Map map = new HashMap<>();
map.put("code","to_target");
map.put("value","0");
map.put("code", "to_target");
map.put("value", "0");
list.add(map);
Map map2 = new HashMap<>();
map2.put("code","to_task");
map2.put("value","0");
map2.put("code", "to_task");
map2.put("value", "0");
list.add(map2);
Map map4 = new HashMap<>();
map4.put("code","to_container_type");
map4.put("value","0");
map4.put("code", "to_container_type");
map4.put("value", "0");
list.add(map4);
this.writing(list);
message=null;
vehicle_code=null;
message = null;
vehicle_code = null;
}

View File

@@ -316,7 +316,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
//申请空托盘入库
if (mode == 9 && move == 1 && !requireSucess) {
if (container_type == 0) {
if (container_type == 0 || StrUtil.isEmpty(barcode)) {
message = "托盘类型为空";
}else {
applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode);
@@ -580,6 +580,12 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
JSONObject param = new JSONObject();
param.put("device_code", device_code);
param.put("container_type", container_type);
if (StrUtil.isNotEmpty(hand_barcode)) {
param.put("vehicle_code", hand_barcode);
}
if (StrUtil.isNotEmpty(barcode)&&(barcode.startsWith("A")||barcode.startsWith("B"))) {
param.put("vehicle_code", barcode);
}
param.put("type", type);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)

View File

@@ -199,4 +199,6 @@ public interface AcsToWmsService {
* @return
*/
HttpResponse feedbackDies(JSONObject param);
String secondaryAllocationPoint(JSONObject param);
}

View File

@@ -637,6 +637,46 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
}
@Override
public String secondaryAllocationPoint(JSONObject param) {
try {
MDC.put(log_file_type, log_type);
log.info("applyTaskToWms-----输入参数{}", param);
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("secondaryAllocationPoint");
String url = wmsurl + addressDto.getMethods_url();
HttpResponse result2 = null;
try {
result2 = HttpRequest.post(url)
.header("Authorization", token)
.body(String.valueOf(param))
.execute();
} catch (Exception e) {
String msg = e.getMessage();
log.info("applyTaskToWms-----输出参数{}", msg);
//网络不通
}
if(ObjectUtil.isEmpty(result2)){
log.info("applyTaskToWms-----输出参数{}", "返回结果为空");
return null;
}
String type = "";
if (result2.getStatus() == 200) {
type = "info";
} else {
type = "error";
}
log.info("applyTaskToWms-----输出参数{}", result2.body());
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"applyTaskToWms", String.valueOf(result2.getStatus()),
JSON.toJSONString(param), String.valueOf(result2.body()), "二期发货申请捆扎、贴标");
luceneLogService.interfaceExecuteLog(luceneLogDto);
return result2.body();
} finally {
MDC.remove(log_file_type);
}
}
@Override
public HttpResponse feedbackDies(JSONObject param) {
HttpResponse result2 = null;

View File

@@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
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.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.conveyor.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.one_conveyor.fold_disc_site.FoldDiscSiteDeviceDriver;
@@ -492,7 +493,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
public PutActionResponse putAction(String jsonObject) throws Exception {
log.info("putAction--------------:输入参数" + jsonObject);
String date = new Date().toString();
LuceneLogDto luceneLogDto = new LuceneLogDto(4, jsonObject, date+"LMS反馈ACS动作信号");
LuceneLogDto luceneLogDto = new LuceneLogDto(4, jsonObject, date + "LMS反馈ACS动作信号");
luceneLogService.interfaceExecuteLog(luceneLogDto);
JSONArray datas = JSONArray.parseArray(jsonObject);
PutActionResponse response = new PutActionResponse();
@@ -504,51 +505,51 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
String code = request.getCode();
String value = request.getValue();
Device device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device)) {
throw new Exception("未找到对应设备:" + device_code);
}
InflatableShaftLibraryDeviceDriver inflatableShaftLibraryDeviceDriver;
HongXiangStationDeviceDriver hongXiangStationDeviceDriver;
LampThreecolorDeviceDriver lampThreecolorDeviceDriver;
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
WasteFoilWeighingStationDriver wasteFoilWeighingStationDriver;
FoldDiscSiteDeviceDriver foldDiscSiteDeviceDriver;
if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) {
hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver();
hongXiangStationDeviceDriver.writing(code, value);
}
if (device.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) device.getDeviceDriver();
lampThreecolorDeviceDriver.writing(code, value);
}
if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) {
siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver();
siemensConveyorDeviceDriver.writing(code, value);
}
if (device.getDeviceDriver() instanceof InflatableShaftLibraryDeviceDriver) {
inflatableShaftLibraryDeviceDriver = (InflatableShaftLibraryDeviceDriver) device.getDeviceDriver();
inflatableShaftLibraryDeviceDriver.writing(code, value);
}
if (device.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) {
foldDiscSiteDeviceDriver = (FoldDiscSiteDeviceDriver) device.getDeviceDriver();
List list = new ArrayList();
Map map = new HashMap();
map.put("code",code);
map.put("value",value);
list.add(map);
foldDiscSiteDeviceDriver.writing(list);
}
if (device.getDeviceDriver() instanceof WasteFoilWeighingStationDriver) {
wasteFoilWeighingStationDriver = (WasteFoilWeighingStationDriver) device.getDeviceDriver();
wasteFoilWeighingStationDriver.writing(code, value);
try {
Thread.sleep(1000); //休眠1秒
} catch (InterruptedException e) {
e.printStackTrace();
}
if (ObjectUtil.isEmpty(device)) {
throw new Exception("未找到对应设备:" + device_code);
}
InflatableShaftLibraryDeviceDriver inflatableShaftLibraryDeviceDriver;
HongXiangStationDeviceDriver hongXiangStationDeviceDriver;
LampThreecolorDeviceDriver lampThreecolorDeviceDriver;
BeltConveyorDeviceDriver beltConveyorDeviceDriver ;
WasteFoilWeighingStationDriver wasteFoilWeighingStationDriver;
FoldDiscSiteDeviceDriver foldDiscSiteDeviceDriver;
if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) {
hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver();
hongXiangStationDeviceDriver.writing(code, value);
}
if (device.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) device.getDeviceDriver();
lampThreecolorDeviceDriver.writing(code, value);
}
if (device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriver=(BeltConveyorDeviceDriver) device.getDeviceDriver();
beltConveyorDeviceDriver.writing(code, value);
}
if (device.getDeviceDriver() instanceof InflatableShaftLibraryDeviceDriver) {
inflatableShaftLibraryDeviceDriver = (InflatableShaftLibraryDeviceDriver) device.getDeviceDriver();
inflatableShaftLibraryDeviceDriver.writing(code, value);
}
if (device.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) {
foldDiscSiteDeviceDriver = (FoldDiscSiteDeviceDriver) device.getDeviceDriver();
List list = new ArrayList();
Map map = new HashMap();
map.put("code", code);
map.put("value", value);
list.add(map);
foldDiscSiteDeviceDriver.writing(list);
}
if (device.getDeviceDriver() instanceof WasteFoilWeighingStationDriver) {
wasteFoilWeighingStationDriver = (WasteFoilWeighingStationDriver) device.getDeviceDriver();
wasteFoilWeighingStationDriver.writing(code, value);
try {
Thread.sleep(1000); //休眠1秒
} catch (InterruptedException e) {
e.printStackTrace();
}
}
response.setStatus(200);
}
response.setStatus(200);
response.setMessage("success");
LuceneLogDto luceneLogDto1 = new LuceneLogDto(4, "putAction", String.valueOf(response.getCode()),
jsonObject, String.valueOf(response), "LMS下发动作");
@@ -561,7 +562,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
public Map<String, Object> putWeightAction(String jsonObject) throws Exception {
log.info("putWeightAction--------------:输入参数" + jsonObject);
String date = new Date().toString();
LuceneLogDto luceneLogDto = new LuceneLogDto(4, jsonObject, date+"LMS反馈ACS废箔重量");
LuceneLogDto luceneLogDto = new LuceneLogDto(4, jsonObject, date + "LMS反馈ACS废箔重量");
luceneLogService.interfaceExecuteLog(luceneLogDto);
JSONArray datas = JSONArray.parseArray(jsonObject);
JSONObject jo = new JSONObject();
@@ -622,7 +623,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
public Map<String, Object> getTubeMes(String jsonObject) throws Exception {
log.info("getTubeMes--------------:输入参数" + jsonObject);
String date = new Date().toString();
LuceneLogDto luceneLogDto = new LuceneLogDto(4, jsonObject, date+"获取管芯信息");
LuceneLogDto luceneLogDto = new LuceneLogDto(4, jsonObject, date + "获取管芯信息");
luceneLogService.interfaceExecuteLog(luceneLogDto);
JSONArray datas = JSONArray.parseArray(jsonObject);
JSONObject jo = new JSONObject();
@@ -721,7 +722,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("action", Math.min(3, blankManipulatorDeviceDriver.getAction()));
jo.put("task", Math.min(3, blankManipulatorDeviceDriver.getTask()));
jo.put("error", blankManipulatorDeviceDriver.getError());
}else if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
} else if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
jo.put("device_code", parent_device_code);
jo.put("mode", hongXiangConveyorDeviceDriver.getMode());
@@ -831,7 +832,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("action", subvolumeWeighingStationDriver.getAction());
jo.put("weight", subvolumeWeighingStationDriver.getWeight());
jo.put("error", subvolumeWeighingStationDriver.getError());
}else if (device.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) {
} else if (device.getDeviceDriver() instanceof FoldDiscSiteDeviceDriver) {
foldDiscSiteDeviceDriver = (FoldDiscSiteDeviceDriver) device.getDeviceDriver();
jo.put("device_code", parent_device_code);
jo.put("move", foldDiscSiteDeviceDriver.getMove());
@@ -848,7 +849,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
resultJson.put("status", HttpStatus.OK.value());
resultJson.put("message", "操作成功");
resultJson.put("data", backja);
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"queryDevice", String.valueOf(resultJson.get("status")),
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "queryDevice", String.valueOf(resultJson.get("status")),
jsonObject, String.valueOf(resultJson), "LMS查询设备状态");
luceneExecuteLogService.interfaceExecuteLog(luceneLogDto);
return resultJson;
@@ -878,5 +879,4 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
}

View File

@@ -34,211 +34,215 @@ import java.io.Serializable;
public class InstructionMybatis extends CommonModel<InstructionMybatis> implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String instruction_id;
private String task_id;
@NotBlank
private String instruction_code;
private String link_num;
private String execute_device_code;
private String execute_status;
private String execute_status_description;
private String follow_device_code;
@NotBlank
private String compound_inst;
private String compound_inst_data;
private String material;
@NotNull
private BigDecimal quantity;
private String instruction_type;
private String instruction_status;
private String create_type;
private String finish_type;
private String priority;
private String execute_code;
private String execute_message;
private String start_point_code;
private String start_device_code;
private String start_point_code2;
private String start_device_code2;
private String next_point_code;
private String next_device_code;
private String next_point_code2;
private String next_device_code2;
private String put_point_code;
private String put_device_code;
private String task_code;
private String vehicle_code;
private String vehicle_type;
private String from_x;
private String from_y;
private String from_z;
private String from_x2;
private String from_y2;
private String from_z2;
private String put_x;
private String put_y;
private String put_z;
private String to_x;
private String to_y;
private String to_z;
private String to_x2;
private String to_y2;
private String to_z2;
private String last_instruction_id;
@NotBlank
private String can_modify;
private String remark;
@NotBlank
private String is_active;
@NotBlank
private String is_delete;
@NotBlank
@TableField(fill = FieldFill.INSERT)
private String create_by;
@NotBlank
@TableField(fill = FieldFill.INSERT)
private String create_time;
@TableField(fill = FieldFill.INSERT_UPDATE)
private String update_by;
@TableField(fill = FieldFill.INSERT_UPDATE)
private String update_time;
private String carno;
private String agv_jobno;
private String send_status;
private String weight;
private String route_plan_code;
private String emptypallet_num;
private String agv_inst_type;
private String agv_system_type;
private Integer agv_action_type;
public void copyFrom(Instruction source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@@ -365,6 +365,12 @@ public class InstructionDto implements Serializable {
private String to_device_code;
/**
* agv二次分配类型1、普通任务 2、取货二次分配 3、防货二次分配 4、取放货二次分配
*/
private Integer agv_action_type;
/**
*
*/

View File

@@ -516,7 +516,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
// } else
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
String interactionJson = task.getInteraction_json();
if (StrUtil.isNotEmpty(interactionJson)){
if (StrUtil.isEmpty(interactionJson)){
throw new BadRequestException("agv叉车调整长宽参数为空");
}
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
@@ -645,24 +645,43 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
if (ObjectUtil.isEmpty(route) && !(start_device_code.equals(next_device_code))) {
throw new BadRequestException(LangProcess.msg("error_isNull", "route"));
}
if (StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
// 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统
if (!StrUtil.equals(task.getAgv_system_type(), "0")
&& ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
} else {
Resp resp = acsToLiKuService.sendInst(task.getStorage_task_type(), dto);
if (StrUtil.equals(resp.result, "true")) {
dto.setSend_status("1");
} else {
//判断是否是仙工AGV
if (shortPathsList.size() > 0 && StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
Device deviceByCode = deviceAppService.findDeviceByCode(dto.getStart_device_code());
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
String interactionJson = task.getInteraction_json();
if (StrUtil.isEmpty(interactionJson)){
throw new BadRequestException("agv叉车调整长宽参数为空");
}
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
//仙工叉车
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto,interactionJsonDTO);
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
dto.setSend_status("2");
} else {
dto.setSend_status("1");
}
} else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
//一楼agv任务创建运单序列
HttpResponse response = xiangGongAgvService.sendOrderSequencesToXZ(dto);
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
dto.setSend_status("2");
} else {
dto.setSend_status("1");
}
}
}
} catch (Exception e) {
dto.setSend_status("2");
e.printStackTrace();
log.error(e.getMessage());
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code("创建指令报错")
.content("任务号" + dto.getTask_code() + "报错原因:" + e.getMessage())
.build();
logDto.setLog_level(2);
luceneExecuteLogService.deviceExecuteLog(logDto);
throw e;
}
InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class);

View File

@@ -240,6 +240,10 @@ public class Task extends CommonModel<Task> implements Serializable {
private String interaction_json;
private Integer agv_action_type;
public void copyFrom(Task source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@@ -0,0 +1,35 @@
package org.nl.acs.task.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum ActionTypeEnum {
/**
* 取货二次分配
*/
IN_STOCK(1, "取货二次分配"),
/**
* 防货二次分配
*/
OUT_STOCK(2, "防货二次分配"),
/**
* 取货完成
*/
IN_FINISHING(3, "取货完成");
Integer code;
String status;
public static String getStatus(Integer code) {
for (ActionTypeEnum value : values()) {
if (value.code.equals(code)) {
return value.status;
}
}
return null;
}
}

View File

@@ -0,0 +1,39 @@
package org.nl.acs.task.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum AgvActionTypeEnum {
/**
* 普通任务
*/
ORDINARY(1, "普通任务"),
/**
* 取货二次分配
*/
IN_STOCK(2, "取货二次分配"),
/**
* 防货二次分配
*/
OUT_STOCK(3, "防货二次分配"),
/**
* 取放货二次分配
*/
IN_OUT_STOCK(4, "取放货二次分配");
Integer code;
String status;
public static String getStatus(Integer code) {
for (AgvActionTypeEnum value : values()) {
if (value.code.equals(code)) {
return value.status;
}
}
return null;
}
}

View File

@@ -349,4 +349,10 @@ public class TaskDto implements Serializable {
* 是否拔轴 0/1
*/
private String is_pulling;
/**
* agv二次分配类型1、普通任务 2、取货二次分配 3、防货二次分配 4、取放货二次分配
*/
private Integer agv_action_type;
}

View File

@@ -42,6 +42,7 @@ import org.nl.acs.route.domain.RoutePlan;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.route.service.mapper.RoutePlanMapper;
import org.nl.acs.task.enums.AgvSystemTypeEnum;
import org.nl.acs.task.enums.TaskStatusEnum;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskFeedbackService;
@@ -839,7 +840,9 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
//反馈上位系统任务状态
this.feedWmsTaskStatus(entity);
//关闭仙工运单序列
this.markComplete(entity);
if(StrUtil.equals(task.getTask_type(),TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode())||StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) {
this.markComplete(entity);
}
}
@Override
@@ -868,7 +871,9 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
//反馈上位系统任务状态
this.feedWmsTaskStatus(entity);
//关闭仙工运单序列
this.markComplete(entity);
if(StrUtil.equals(task.getTask_type(),TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode())||StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) {
this.markComplete(entity);
}
}
@@ -1634,23 +1639,10 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
*/
private void markComplete(TaskDto taskDto) {
// 如果属于先知AGV关闭运单序列
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(
taskDto.getStart_device_code(),
taskDto.getNext_device_code(),
taskDto.getRoute_plan_code());
if (ObjectUtil.isNotEmpty(shortPathsList)) {
String type = shortPathsList.get(0).getType();
// != 0 为agv任务
if (!StrUtil.equals(type, "0")) {
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) {
try {
agvService.markComplete(taskDto.getTask_code());
} catch (Exception e) {
log.error("关闭运单异常,原因:{}", e.getMessage());
}
}
}
try {
agvService.markComplete(taskDto.getTask_code());
} catch (Exception e) {
log.error("关闭运单异常,原因:{}", e.getMessage());
}
}

View File

@@ -86,6 +86,7 @@ public class AutoCreateInst {
String start_height = acsTask.getStart_height();
String next_height = acsTask.getNext_height();
Integer agvActionType = acsTask.getAgv_action_type();
if (StrUtil.equals(is_send, "0")) {
@@ -158,6 +159,7 @@ public class AutoCreateInst {
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系统