rev:更新

This commit is contained in:
2025-12-08 13:45:35 +08:00
parent 14d2329a57
commit 5869be9ee4
10 changed files with 283 additions and 128 deletions

View File

@@ -6,6 +6,9 @@ import com.alicp.jetcache.anno.config.EnableMethodCache;
import lombok.extern.slf4j.Slf4j;
import org.dromara.dynamictp.core.spring.EnableDynamicTp;
import org.mybatis.spring.annotation.MapperScan;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.conveyor.standard_weight.StandardWeightSiteDeviceDriver;
import org.nl.acs.opc.DeviceAppService;
import org.nl.config.SpringContextHolder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -15,6 +18,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
/**
@@ -59,5 +63,17 @@ public class AppRun {
public String index() {
return "Backend service started successfully";
}
@GetMapping("/setWeight/{weight}")
@SaIgnore
public String withStationRequireSuccess(@PathVariable Float weight) {
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
Device device = deviceAppService.findDeviceByCode("CZW01");
if (device != null && device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
StandardWeightSiteDeviceDriver standardWeightSiteDeviceDriver = (StandardWeightSiteDeviceDriver) device.getDeviceDriver();
standardWeightSiteDeviceDriver.setTemp_weight(weight);
}
return "称重位重量设置为:" + weight;
}
}

View File

@@ -19,8 +19,8 @@ public class ItemProtocol {
this.driver = driver;
}
public Float getWeight() {
return this.getOpcFloatValue(item_weight);
public Integer getWeight() {
return this.getOpcIntegerValue(item_weight);
}
Boolean isonline;

View File

@@ -51,10 +51,16 @@ public class StandardWeightSiteDeviceDriver extends AbstractOpcDeviceDriver impl
String deviceCode;
/**
* CTU请求取货标记和任务
* CTU请求取货标记和指令
*/
private volatile String reqTakeInstCode = null;
private volatile Boolean reqTakeRequireSuccess = false;
private volatile String reqCtuTakeInstCode = null;
private volatile Boolean reqCtuTakeRequireSuccess = false;
/**
* AGV请求取放货标记和指令号
*/
private volatile String reqAgvTakeInstCode = null;
private volatile Boolean reqAgvTakeRequireSuccess = false;
/**
* 请求时间
@@ -81,44 +87,56 @@ public class StandardWeightSiteDeviceDriver extends AbstractOpcDeviceDriver impl
return currentTimeMillis - this.requireTime >= this.requireTimeOut;
}
private Float temp_weight = 0.0f;
@Override
public void execute() {
this.deviceCode = this.getDevice().getDevice_code();
this.weight = this.itemProtocol.getWeight();
this.weight = (float) this.itemProtocol.getWeight() / 10;
if (!this.weight.equals(this.last_weight)) {
luceneExecuteLogService.deviceExecuteLog(new LuceneLogDto(this.deviceCode, "自动线程读取信号: weight,由" + this.last_weight + "->" + this.weight));
}
if (this.reqTakeRequireSuccess && ObjectUtil.isNotEmpty(this.reqTakeInstCode)) {
Instruction instruction = instructionService.findByCodeFromCache(this.reqTakeInstCode);
//取货申请
if (this.reqCtuTakeRequireSuccess && ObjectUtil.isNotEmpty(this.reqCtuTakeInstCode)) {
Instruction instruction = instructionService.findByCodeFromCache(this.reqCtuTakeInstCode);
//判断是否是取货还是放货
//如果是取货看是否需要反馈重量并拍照,如果不需要直接放行
if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getStart_device_code(), this.deviceCode)) {
if (StrUtil.equals(InstTypeEnum.CTU_IN_TASK.getCode(), instruction.getInstruction_type())) {
boolean feedFlag = Optional.ofNullable(this.getDevice().getExtraValue().get("isFeedWeight")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
if (feedFlag) {
if (feedFlag && !instruction.getTask_code().startsWith("-")) {
this.feedWeight(instruction);
} else {
this.boxApplyPass(ApplyPassEnum.GET_PASS.getCode());
}
} else if (StrUtil.equals(InstTypeEnum.AGV_THREE_TASK.getCode(), instruction.getInstruction_type()) ||
}
}
//如果是放货还需要判断this.weight是否小于1.0f 如果小于直接允许放货
else if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getNext_device_code(), this.deviceCode)) {
if (StrUtil.equals(InstTypeEnum.CTU_OUT_TASK.getCode(), instruction.getInstruction_type())) {
if (this.weight < 1.0f) {
this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode());
}
}
}
} else if (this.reqAgvTakeRequireSuccess && ObjectUtil.isNotEmpty(this.reqAgvTakeInstCode)) {
Instruction instruction = instructionService.findByCodeFromCache(this.reqAgvTakeInstCode);
//判断是否是取货还是放货
//如果是取货直接允许
if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getStart_device_code(), this.deviceCode)) {
if (StrUtil.equals(InstTypeEnum.AGV_THREE_TASK.getCode(), instruction.getInstruction_type()) ||
StrUtil.equals(InstTypeEnum.AGV_TWO_TASK.getCode(), instruction.getInstruction_type())) {
//this.boxApplyPass(ApplyPassEnum.GET_PASS.getCode());
this.continueTask();
}
}
//放货申请
//如果是放货则判断是否有CTU请求放货如果有则先不允许等待CTU放货
//还需要判断this.weight是否小于1.0f
else if (ObjectUtil.isNotEmpty(instruction) && StrUtil.equals(instruction.getNext_device_code(), this.deviceCode)) {
boolean putFlag = Optional.ofNullable(this.getDevice().getExtraValue().get("ignore_release_check")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
if (putFlag) {
this.applyPass(instruction);
} else {
// this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode());
if (StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.AGV_TWO3_TASK.getCode()) ||
StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.AGV_THREE_TASK.getCode())) {
if (StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.AGV_TWO3_TASK.getCode()) ||
StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.AGV_THREE_TASK.getCode())) {
if (this.weight < 1.0f && !this.reqCtuTakeRequireSuccess && this.reqCtuTakeInstCode == null) {
this.continueTask();
} else if (StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.CTU_OUT_TASK.getCode())) {
this.boxApplyPass(ApplyPassEnum.PUT_PASS.getCode());
}
}
}
@@ -148,8 +166,8 @@ public class StandardWeightSiteDeviceDriver extends AbstractOpcDeviceDriver impl
} catch (Exception e) {
luceneExecuteLogService.deviceExecuteLog(new LuceneLogDto(this.deviceCode, "反馈重量后,取消指令出现异常, 异常原因:" + e.getMessage()));
}
this.reqTakeRequireSuccess = false;
this.reqTakeInstCode = null;
this.reqCtuTakeRequireSuccess = false;
this.reqCtuTakeInstCode = null;
}
}
}
@@ -181,24 +199,24 @@ public class StandardWeightSiteDeviceDriver extends AbstractOpcDeviceDriver impl
private void boxApplyPass(String type) {
BoxApplyPassReq bapReq = BoxApplyPassReq.builder()
.taskCode(this.reqTakeInstCode)
.taskCode(this.reqCtuTakeInstCode)
.type(type)
.build();
UnifiedResponse<String> unifiedResponse = acsToHkService.boxApplyPass(bapReq, String.class);
if (unifiedResponse.isSuccess()) {
this.reqTakeRequireSuccess = false;
this.reqTakeInstCode = null;
this.reqCtuTakeRequireSuccess = false;
this.reqCtuTakeInstCode = null;
}
}
private void continueTask() {
ContinueTaskReq req = ContinueTaskReq.builder()
.taskCode(this.reqTakeInstCode)
.taskCode(this.reqAgvTakeInstCode)
.build();
UnifiedResponse unifiedResponse = acsToHkService.continueTask(req);
if (unifiedResponse.isSuccess()) {
this.reqTakeRequireSuccess = false;
this.reqTakeInstCode = null;
this.reqAgvTakeRequireSuccess = false;
this.reqAgvTakeInstCode = null;
}
}

View File

@@ -18,6 +18,9 @@ import org.nl.acs.instruction.enums.InstTypeEnum;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -46,6 +49,8 @@ public class HkToAcsServiceImpl implements HkToAcsService {
private ISysParamService sysParamService;
@Autowired
private AcsToWmsService acsToWmsService;
@Autowired
private TaskService taskService;
@Override
public JSONObject agvCallback(JSONObject requestParam) {
@@ -56,6 +61,13 @@ public class HkToAcsServiceImpl implements HkToAcsService {
String method = requestParam.getString("method");
Instruction instruction = instructionService.findByCodeFromCache(taskCode);
if (ObjectUtil.isEmpty(instruction)) {
resp.put("code", "1");
resp.put("message", "请求失败,指令信息不存在,指令号:" + taskCode);
resp.put("reqCode", reqCode);
return resp;
}
TaskDto taskDto = taskService.findByCodeFromCache(instruction.getTask_code());
if (ObjectUtil.isEmpty(taskDto)) {
resp.put("code", "1");
resp.put("message", "请求失败,任务信息不存在,指令号:" + taskCode);
resp.put("reqCode", reqCode);
@@ -74,12 +86,12 @@ public class HkToAcsServiceImpl implements HkToAcsService {
JSONObject reqParam = new JSONObject();
reqParam.put("task_id", instruction.getTask_id());
reqParam.put("task_code", instruction.getTask_code());
reqParam.put("car_no", reqCode);
reqParam.put("car_no", robotCode);
acsToWmsService.feedCarNo(reqParam);
}
//method 回调2、任务完成/结束end
else if (StrUtil.equals(method, "end")) {
if (instruction.getInstruction_type().equals(InstTypeEnum.AGV_THREE_TASK.getCode())){
if (instruction.getInstruction_type().equals(InstTypeEnum.AGV_THREE_TASK.getCode())) {
instruction.setExecute_device_code(instruction.getStart_point_code());
}
//修改指令状态完成
@@ -117,18 +129,29 @@ public class HkToAcsServiceImpl implements HkToAcsService {
//如果请求位置编号与指令起点一致并且是输送线则是取货申请
if (device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
standardWeightSiteDeviceDriver = (StandardWeightSiteDeviceDriver) device.getDeviceDriver();
standardWeightSiteDeviceDriver.setReqTakeRequireSuccess(true);
standardWeightSiteDeviceDriver.setReqTakeInstCode(taskCode);
if (TaskTypeEnum.CTU_TASK.getCode().equals(taskDto.getTask_type())) {
standardWeightSiteDeviceDriver.setReqCtuTakeRequireSuccess(true);
standardWeightSiteDeviceDriver.setReqCtuTakeInstCode(taskCode);
} else {
standardWeightSiteDeviceDriver.setReqAgvTakeRequireSuccess(true);
standardWeightSiteDeviceDriver.setReqAgvTakeInstCode(taskCode);
}
}
}
//method 回调5、inApplyOk
else if (StrUtil.equals(method, "inApplyOk")) {
//TODO 调用WMS取货完成通知接口
else if (StrUtil.equals(method, "inApplyOK")) {
//如果是WMS下发的任务就反馈WMS取货完成
if (!instruction.getTask_code().startsWith("-")) {
JSONObject reqParam = new JSONObject();
reqParam.put("task_code", instruction.getTask_code());
reqParam.put("point_code", instruction.getStart_point_code());
acsToWmsService.takeFinish(reqParam);
}
}
//method 回调6、放料箱申请outApply
else if (StrUtil.equals(method, "outApply")) {
Device device = deviceAppService.findDeviceByCode(instruction.getNext_device_code());
if (instruction.getInstruction_type().equals(InstTypeEnum.AGV_THREE_TASK.getCode())){
if (instruction.getInstruction_type().equals(InstTypeEnum.AGV_THREE_TASK.getCode())) {
device = deviceAppService.findDeviceByCode(instruction.getStart_device_code());
}
if (ObjectUtil.isEmpty(device)) {
@@ -142,8 +165,13 @@ public class HkToAcsServiceImpl implements HkToAcsService {
//如果请求位置编号与指令起点一致并且是输送线则是取货申请
if (device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
standardWeightSiteDeviceDriver = (StandardWeightSiteDeviceDriver) device.getDeviceDriver();
standardWeightSiteDeviceDriver.setReqTakeRequireSuccess(true);
standardWeightSiteDeviceDriver.setReqTakeInstCode(taskCode);
if (TaskTypeEnum.CTU_TASK.getCode().equals(taskDto.getTask_type())) {
standardWeightSiteDeviceDriver.setReqCtuTakeRequireSuccess(true);
standardWeightSiteDeviceDriver.setReqCtuTakeInstCode(taskCode);
} else {
standardWeightSiteDeviceDriver.setReqAgvTakeRequireSuccess(true);
standardWeightSiteDeviceDriver.setReqAgvTakeInstCode(taskCode);
}
}
}
resp.put("code", "0");

View File

@@ -43,4 +43,13 @@ public interface AcsToWmsService {
* @return
*/
<T> UnifiedResponse<T> applyPass(JSONObject request, Class<T> type);
/**
* 取货完成
*
* @param request
* @param <T>
* @return
*/
<T> UnifiedResponse<T> takeFinish(JSONObject request);
}

View File

@@ -44,4 +44,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
AddressDto addressDto = addressService.findByCode("applyPass");
return lmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), request, type);
}
@Override
public <T> UnifiedResponse<T> takeFinish(JSONObject request) {
AddressDto addressDto = addressService.findByCode("takeFinish");
return lmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), request);
}
}

View File

@@ -274,4 +274,12 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
* @return
*/
InstructionDto findByInstTypeAndIsWait(String inst_type, String is_wait);
/**
* 根据指令类型查询指令数量
*
* @param instTypes
* @return
*/
int findInstCountByInstType(List<String> instTypes);
}

View File

@@ -352,9 +352,9 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
.taskCode(dto.getInstruction_code())
.build();
} else if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.AGV_TASK.getCode())) {
if (StrUtil.equals(dto.getInstruction_type(), InstTypeEnum.AGV_THREE_TASK.getCode())) {
if (StrUtil.equals(dto.getInstruction_type(), InstTypeEnum.AGV_THREE_TASK.getCode())) {
positionCodePath = Arrays.asList(MapOf.of("positionCode", dto.getStart_parent_code(), "type", "00"), MapOf.of("positionCode", dto.getNext_parent_code(), "type", "00"), MapOf.of("positionCode", dto.getStart_parent_code(), "type", "00"));
} else {
} else {
positionCodePath = Arrays.asList(MapOf.of("positionCode", dto.getStart_parent_code(), "type", "00"), MapOf.of("positionCode", dto.getNext_parent_code(), "type", "00"));
}
gasReq = GenAgvSchedulingTaskReq
@@ -1093,4 +1093,14 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
.orElse(null);
}
@Override
public int findInstCountByInstType(List<String> instTypes) {
return Optional.ofNullable(this.instructions)
.orElse(new ArrayList<>())
.stream()
.filter(instruction -> instTypes.contains(instruction.getInstruction_type()))
.collect(Collectors.toList())
.size();
}
}

View File

@@ -39,6 +39,11 @@ import java.util.stream.Collectors;
@Component
public class AutoCreateInst {
/**
* 定义一个小于料框空箱的重量,当称重数量小于该数量时,则认为没有货
*/
private static final Float DEFAULT_WEIGHT = 1.0f;
@Autowired
private TaskService taskService;
@Autowired
@@ -82,7 +87,102 @@ public class AutoCreateInst {
return InstTypeEnum.OTHER_TASK.getCode();
}));
groupByInstTypeTasks.forEach((instType, acsTaskList) -> {
if (InstTypeEnum.CTU_OUT_TASK.getCode().equals(instType)) {
if (!InstTypeEnum.CTU_OUT_TASK.getCode().equals(instType)) {
acsTaskList.forEach(acsTask -> {
String taskId = acsTask.getTask_id();
String taskCode = acsTask.getTask_code();
String vehicle_code = acsTask.getVehicle_code();
String priority = acsTask.getPriority();
String start_device_code = acsTask.getStart_device_code();
String start_point_code = acsTask.getStart_point_code();
String start_parent_code = acsTask.getStart_parent_code();
String next_device_code = acsTask.getNext_device_code();
String next_point_code = acsTask.getNext_point_code();
String next_parent_code = acsTask.getNext_parent_code();
String vehicle_type = acsTask.getVehicle_type();
String agv_system_type = acsTask.getAgv_system_type();
String is_get_pause = acsTask.getIs_get_pause();
String is_put_pause = acsTask.getIs_put_pause();
String is_wait = acsTask.getIs_wait();
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, "normal");
if (ObjectUtils.isEmpty(shortPathsList)) {
acsTask.setRemark("路由不通无法生成指令");
taskService.updateByCodeFromCache(acsTask);
return;
}
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
int index = 0;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
index = m + 1;
break;
}
}
next_device_code = pathlist.get(index);
if (StrUtil.equals(deviceAppService.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(instType);
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRemark(acsTask.getRemark());
instdto.setTask_id(taskId);
instdto.setTask_code(taskCode);
instdto.setVehicle_code(vehicle_code);
instdto.setVehicle_type(vehicle_type);
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.setStart_parent_code(start_parent_code);
instdto.setNext_device_code(next_device_code);
instdto.setNext_point_code(next_point_code);
instdto.setNext_parent_code(next_parent_code);
instdto.setIs_get_pause(is_get_pause);
instdto.setIs_put_pause(is_put_pause);
instdto.setIs_wait(is_wait);
instdto.setPriority(priority);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(start_point_code);
instdto.setAgv_system_type(agv_system_type);
try {
instructionService.create(instdto);
} catch (Exception e) {
acsTask.setRemark("指令创建失败:" + e.getMessage());
taskService.updateByCodeFromCache(acsTask);
return;
}
//创建成功后
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskService.update(acsTask);
});
} else {
//查询到称重点的AGV指令数量如果说指令数量大于1则return
int count = instructionService.findInstCountByInstType(Arrays.asList(InstTypeEnum.AGV_TWO3_TASK.getCode(), InstTypeEnum.AGV_THREE_TASK.getCode()));
if (count > 1) {
return;
}
// 获取称重位的重量看是有货有货则return
Device device = deviceAppService.findDeviceByCode("CZW01");
if (device != null && device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
StandardWeightSiteDeviceDriver standardWeightSiteDeviceDriver = (StandardWeightSiteDeviceDriver) device.getDeviceDriver();
if (standardWeightSiteDeviceDriver.getWeight() > DEFAULT_WEIGHT) {
return;
}
}
InstructionDto waitInst = instructionService.findByInstTypeAndIsWait(InstTypeEnum.CTU_OUT_TASK.getCode(), "1");
if (ObjectUtil.isEmpty(waitInst)) {
Map<String, List<TaskDto>> groupedByWaitStatus = acsTaskList.stream()
@@ -255,88 +355,6 @@ public class AutoCreateInst {
}
});
}
} else {
acsTaskList.forEach(acsTask -> {
String taskId = acsTask.getTask_id();
String taskCode = acsTask.getTask_code();
String vehicle_code = acsTask.getVehicle_code();
String priority = acsTask.getPriority();
String start_device_code = acsTask.getStart_device_code();
String start_point_code = acsTask.getStart_point_code();
String start_parent_code = acsTask.getStart_parent_code();
String next_device_code = acsTask.getNext_device_code();
String next_point_code = acsTask.getNext_point_code();
String next_parent_code = acsTask.getNext_parent_code();
String vehicle_type = acsTask.getVehicle_type();
String agv_system_type = acsTask.getAgv_system_type();
String is_get_pause = acsTask.getIs_get_pause();
String is_put_pause = acsTask.getIs_put_pause();
String is_wait = acsTask.getIs_wait();
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, "normal");
if (ObjectUtils.isEmpty(shortPathsList)) {
acsTask.setRemark("路由不通无法生成指令");
taskService.updateByCodeFromCache(acsTask);
return;
}
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
int index = 0;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
index = m + 1;
break;
}
}
next_device_code = pathlist.get(index);
if (StrUtil.equals(deviceAppService.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(instType);
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRemark(acsTask.getRemark());
instdto.setTask_id(taskId);
instdto.setTask_code(taskCode);
instdto.setVehicle_code(vehicle_code);
instdto.setVehicle_type(vehicle_type);
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.setStart_parent_code(start_parent_code);
instdto.setNext_device_code(next_device_code);
instdto.setNext_point_code(next_point_code);
instdto.setNext_parent_code(next_parent_code);
instdto.setIs_get_pause(is_get_pause);
instdto.setIs_put_pause(is_put_pause);
instdto.setIs_wait(is_wait);
instdto.setPriority(priority);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(start_point_code);
instdto.setAgv_system_type(agv_system_type);
try {
instructionService.create(instdto);
} catch (Exception e) {
acsTask.setRemark("指令创建失败:" + e.getMessage());
taskService.updateByCodeFromCache(acsTask);
return;
}
//创建成功后
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskService.update(acsTask);
});
}
});
} else if (TaskTypeEnum.AGV_TASK.getCode().equals(taskType)) {
@@ -390,19 +408,61 @@ public class AutoCreateInst {
if ("1".equals(is_wait)) {
inst_type = InstTypeEnum.AGV_THREE_TASK.getCode();
} else if (start_device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver
&& next_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
&& next_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
inst_type = InstTypeEnum.AGV_TWO_TASK.getCode();
} else if (start_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver
&& next_device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver){
&& next_device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
inst_type = InstTypeEnum.AGV_TWO3_TASK.getCode();
} else if (start_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver
&& next_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver){
&& next_device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
inst_type = InstTypeEnum.AGV_TWO2_TASK.getCode();
}
} else {
return;
}
//如果是到称重位的AGV任务
if (inst_type.equals(InstTypeEnum.AGV_TWO3_TASK.getCode()) || inst_type.equals(InstTypeEnum.AGV_THREE_TASK.getCode())) {
//查询是否存在CTU出库的指令如果存在则return
int ctuCount = instructionService.findInstCountByInstType(Arrays.asList(InstTypeEnum.CTU_OUT_TASK.getCode()));
//如果存在CTU出库指令
if (ctuCount > 0) {
//查询AGV到称重位的指令是否存在如果存在则return
int agvCount = instructionService.findInstCountByInstType(Arrays.asList(InstTypeEnum.AGV_TWO3_TASK.getCode(), InstTypeEnum.AGV_THREE_TASK.getCode()));
if (agvCount > 0) {
return;
}
Device device = deviceAppService.findDeviceByCode("CZW01");
if (device != null && device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
StandardWeightSiteDeviceDriver standardWeightSiteDeviceDriver = (StandardWeightSiteDeviceDriver) device.getDeviceDriver();
if (standardWeightSiteDeviceDriver.getWeight() > DEFAULT_WEIGHT) {
return;
}
}
}
//如果不存在CTU出库任务
else {
Device device = deviceAppService.findDeviceByCode("CZW01");
if (device != null && device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
StandardWeightSiteDeviceDriver standardWeightSiteDeviceDriver = (StandardWeightSiteDeviceDriver) device.getDeviceDriver();
//如果称重位有货物就查询到称重位到AGV指令数量是否存在如果存在则return
if (standardWeightSiteDeviceDriver.getWeight() > DEFAULT_WEIGHT) {
int agvCount = instructionService.findInstCountByInstType(Arrays.asList(InstTypeEnum.AGV_TWO3_TASK.getCode(), InstTypeEnum.AGV_THREE_TASK.getCode()));
if (agvCount > 0) {
return;
}
}
//如果称重位没有货物就查询到称重位到AGV指令数量是否大于1如果大于1则return
else {
int agvCount = instructionService.findInstCountByInstType(Arrays.asList(InstTypeEnum.AGV_TWO3_TASK.getCode(), InstTypeEnum.AGV_THREE_TASK.getCode()));
if (agvCount > 1) {
return;
}
}
}
}
}
Instruction instdto = new Instruction();
instdto.setInstruction_type(inst_type);
instdto.setInstruction_id(IdUtil.simpleUUID());

View File

@@ -6,7 +6,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: dev
active: prod
jackson:
time-zone: GMT+8
data: