rev:下发指令时要判断车辆类型
This commit is contained in:
@@ -69,6 +69,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
reqParam.put("complete", true);
|
||||
reqParam.put("blocks", createBlocksData(inst));
|
||||
reqParam.put("priority", inst.getPriority());
|
||||
reqParam.put("group", inst.getMaterial());
|
||||
String path = "/setOrder";
|
||||
return xgHttpUtil.sendPostRequest(path, reqParam);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package org.nl.acs.instruction.service.impl;
|
||||
|
||||
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 cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
@@ -33,6 +34,7 @@ import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.utils.enums.RegionEnum;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
@@ -530,6 +532,30 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
instdto.setPriority(acsTask.getPriority());
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(dto.getNext_device_code());
|
||||
// 根据起点区域和终点区域判断下发车辆类型
|
||||
WQLObject cellTab = WQLObject.getWQLObject("acs_storage_cell");
|
||||
JSONObject startJson = cellTab.query("storage_code = '" + start_point_code + "'").uniqueResult(0);
|
||||
JSONObject nextJson = cellTab.query("storage_code = '" + next_point_code + "'").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(startJson) || ObjectUtil.isEmpty(nextJson)) {
|
||||
throw new BadRequestException("任务 [" + instdto.getTask_code() + "] 起点或终点没有找到对应点位无法生成指令。");
|
||||
}
|
||||
|
||||
List<RegionEnum> regionEnumList = RegionEnum.find(startJson.getString("region_code"), nextJson.getString("region_code"));
|
||||
if (ObjectUtil.isEmpty(regionEnumList)) {
|
||||
throw new BadRequestException("任务 [" + instdto.getTask_code() + "] 起点或终点没有找到对应AGV类型无法生成指令。");
|
||||
}
|
||||
|
||||
if (regionEnumList.size() > 1) {
|
||||
// 判断终点是否是1层的
|
||||
if (nextJson.getString("z").equals("01")) {
|
||||
instdto.setMaterial(RegionEnum.AB_DMHJ_ONE.getAgv_type());
|
||||
} else {
|
||||
instdto.setMaterial(RegionEnum.AB_DMHJ.getAgv_type());
|
||||
}
|
||||
} else {
|
||||
instdto.setMaterial(regionEnumList.get(0).getAgv_type());
|
||||
}
|
||||
this.create(instdto);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.utils.enums.RegionEnum;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
@@ -424,6 +425,31 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(start_point_code);
|
||||
instdto.setVehicle_type(vehicleType);
|
||||
|
||||
// 根据起点区域和终点区域判断下发车辆类型
|
||||
WQLObject cellTab = WQLObject.getWQLObject("acs_storage_cell");
|
||||
JSONObject startJson = cellTab.query("storage_code = '" + start_point_code + "'").uniqueResult(0);
|
||||
JSONObject nextJson = cellTab.query("storage_code = '" + next_point_code + "'").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(startJson) || ObjectUtil.isEmpty(nextJson)) {
|
||||
throw new BadRequestException("任务 [" + taskcode + "] 起点或终点没有找到对应点位无法生成指令。");
|
||||
}
|
||||
|
||||
List<RegionEnum> regionEnumList = RegionEnum.find(startJson.getString("region_code"), nextJson.getString("region_code"));
|
||||
if (ObjectUtil.isEmpty(regionEnumList)) {
|
||||
throw new BadRequestException("任务 [" + taskcode + "] 起点或终点没有找到对应AGV类型无法生成指令。");
|
||||
}
|
||||
|
||||
if (regionEnumList.size() > 1) {
|
||||
// 判断终点是否是1层的
|
||||
if (nextJson.getString("z").equals("01")) {
|
||||
instdto.setMaterial(RegionEnum.AB_DMHJ_ONE.getAgv_type());
|
||||
} else {
|
||||
instdto.setMaterial(RegionEnum.AB_DMHJ.getAgv_type());
|
||||
}
|
||||
} else {
|
||||
instdto.setMaterial(regionEnumList.get(0).getAgv_type());
|
||||
}
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.common.utils.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 区域对应车辆场景
|
||||
* </p>
|
||||
* @author Liuxy
|
||||
* @date 2024-10-31
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum RegionEnum {
|
||||
|
||||
// AB生产区-->C生产区
|
||||
AB_C("AB", "C","PS20","Group-001"),
|
||||
|
||||
// AB生产区到-->地面面货架
|
||||
AB_DMHJ("AB", "DMHJ","PS20","Group-001"),
|
||||
|
||||
// C生产区-->D生产区
|
||||
C_D("C", "D","PS20","Group-001"),
|
||||
|
||||
// D生产区-->地面货架
|
||||
D_DMHJ("D", "DMHJ","PS20","Group-001"),
|
||||
|
||||
// 地面货架-->拆盘机
|
||||
DMHJ_CPJ("DMHJ", "CPJ","PS20","Group-001"),
|
||||
|
||||
// AB生产区-->地面货架一层
|
||||
AB_DMHJ_ONE("AB", "DMHJ","PS30","Group-002"),
|
||||
|
||||
// 地面货架-->AB生产区
|
||||
DMHJ_AB("DMHJ", "AB","PS30","Group-002"),
|
||||
|
||||
// AB生产区-->钢平台接驳
|
||||
AB_GPTJB("AB", "GPTJB","PS20","Group-001"),
|
||||
|
||||
// 钢平台接驳-->钢平台货架
|
||||
GPTJB_GPTHJ("GPTJB", "GPTHJ","PS10","Group-003"),
|
||||
|
||||
// 钢平台货架-->钢平台接驳
|
||||
GPTHJ_GPTJB("GPTHJ", "GPTJB","PS10","Group-003"),
|
||||
|
||||
// 钢平台接驳-->AB生产区
|
||||
GPTJB_AB("GPTJB", "AB","PS20","Group-001"),
|
||||
|
||||
// 钢平台接驳-->拆盘机
|
||||
GPTJB_CPJ("GPTJB", "CPJ","PS20","Group-001"),
|
||||
|
||||
// 包装线-->拆盘机
|
||||
BZX_CPJ("BZX", "CPJ","PS15","Group-004"),
|
||||
;
|
||||
|
||||
// 起点区域
|
||||
private final String start_region;
|
||||
// 终点区域
|
||||
private final String end_region;
|
||||
// 车辆类型
|
||||
private final String car_type;
|
||||
// 下发agv类型
|
||||
private final String agv_type;
|
||||
|
||||
public static List<RegionEnum> find(String start_region, String end_region) {
|
||||
ArrayList<RegionEnum> list = new ArrayList<>();
|
||||
for (RegionEnum value : RegionEnum.values()) {
|
||||
if (start_region.equals(value.getStart_region()) && end_region.equals(value.getEnd_region())) {
|
||||
list.add(value);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package org.nl.modules.quartz.task;
|
||||
|
||||
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.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
@@ -15,7 +17,9 @@ import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.modules.common.utils.enums.RegionEnum;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -164,6 +168,37 @@ public class AutoCreateInst {
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(start_point_code);
|
||||
instdto.setVehicle_type(vehicleType);
|
||||
// 根据起点区域和终点区域判断下发车辆类型
|
||||
WQLObject cellTab = WQLObject.getWQLObject("acs_storage_cell");
|
||||
JSONObject startJson = cellTab.query("storage_code = '" + start_point_code + "'").uniqueResult(0);
|
||||
JSONObject nextJson = cellTab.query("storage_code = '" + next_point_code + "'").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(startJson) || ObjectUtil.isEmpty(nextJson)) {
|
||||
log.info("任务 [" + taskcode + "] 起点或终点没有找到对应点位无法生成指令。");
|
||||
acsTask.setRemark("任务 [" + taskcode + "] 起点或终点没有找到对应点位无法生成指令。");
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<RegionEnum> regionEnumList = RegionEnum.find(startJson.getString("region_code"), nextJson.getString("region_code"));
|
||||
if (ObjectUtil.isEmpty(regionEnumList)) {
|
||||
log.info("任务 [" + taskcode + "] 起点或终点没有找到对应AGV类型无法生成指令。");
|
||||
acsTask.setRemark("任务 [" + taskcode + "] 起点或终点没有找到对应AGV类型无法生成指令。");
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (regionEnumList.size() > 1) {
|
||||
// 判断终点是否是1层的
|
||||
if (nextJson.getString("z").equals("01")) {
|
||||
instdto.setMaterial(RegionEnum.AB_DMHJ_ONE.getAgv_type());
|
||||
} else {
|
||||
instdto.setMaterial(RegionEnum.AB_DMHJ.getAgv_type());
|
||||
}
|
||||
} else {
|
||||
instdto.setMaterial(regionEnumList.get(0).getAgv_type());
|
||||
}
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user