add:redisson
This commit is contained in:
@@ -362,7 +362,17 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
|
<version>3.12.3</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<!-- jwt -->
|
<!-- jwt -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.system.util.CodeUtil;
|
import org.nl.modules.system.util.CodeUtil;
|
||||||
@@ -25,6 +26,8 @@ import org.nl.wms.sch.tasks.EmptyVehicleTask;
|
|||||||
import org.nl.wms.sch.tasks.SendOutTask;
|
import org.nl.wms.sch.tasks.SendOutTask;
|
||||||
import org.nl.wms.st.inbill.service.RawAssistIStorService;
|
import org.nl.wms.st.inbill.service.RawAssistIStorService;
|
||||||
import org.nl.wms.st.inbill.service.StorPublicService;
|
import org.nl.wms.st.inbill.service.StorPublicService;
|
||||||
|
import org.redisson.api.RLock;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -34,6 +37,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -48,6 +52,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
|
|
||||||
private final CutConveyorTask cutConveyorTask;
|
private final CutConveyorTask cutConveyorTask;
|
||||||
|
|
||||||
|
private final RedissonClient redissonClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* task_id:任务标识
|
* task_id:任务标识
|
||||||
* task_code:任务编码
|
* task_code:任务编码
|
||||||
@@ -180,262 +186,272 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@SneakyThrows
|
||||||
public JSONObject apply(JSONObject whereJson) {
|
public JSONObject apply(JSONObject whereJson) {
|
||||||
log.info("apply请求参数:---------------------------------------------"+whereJson.toString());
|
log.info("apply请求参数:---------------------------------------------"+whereJson.toString());
|
||||||
synchronized (AcsToWmsServiceImpl.class) {
|
String type = whereJson.getString("type");
|
||||||
String type = whereJson.getString("type");
|
JSONObject result = new JSONObject();
|
||||||
String device_code = whereJson.getString("device_code");
|
RLock lock = redissonClient.getLock("acs_wms_apply:" + type);
|
||||||
String vehicle_code = whereJson.getString("vehicle_code");
|
boolean isLock = lock.tryLock(3,TimeUnit.SECONDS);
|
||||||
|
try {
|
||||||
|
if (isLock){
|
||||||
|
String device_code = whereJson.getString("device_code");
|
||||||
|
String vehicle_code = whereJson.getString("vehicle_code");
|
||||||
|
|
||||||
WQLObject point_table = WQLObject.getWQLObject("SCH_BASE_Point");
|
WQLObject point_table = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||||
WQLObject struct_table = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
WQLObject struct_table = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(type)) throw new BadRequestException("ACS申请任务失败!任务类型不能为空");
|
if (ObjectUtil.isEmpty(type)) throw new BadRequestException("ACS申请任务失败!任务类型不能为空");
|
||||||
if (ObjectUtil.isEmpty(device_code)) throw new BadRequestException("ACS申请任务失败!点位不能为空");
|
if (ObjectUtil.isEmpty(device_code)) throw new BadRequestException("ACS申请任务失败!点位不能为空");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 根据type判断是什么业务类型:
|
* 根据type判断是什么业务类型:
|
||||||
* 1.入库任务
|
* 1.入库任务
|
||||||
* 2.空盘入库任务
|
* 2.空盘入库任务
|
||||||
* 3.空盘出库任务
|
* 3.空盘出库任务
|
||||||
* 4.出库口申请入发货区任务
|
* 4.出库口申请入发货区任务
|
||||||
*/
|
*/
|
||||||
if (type.equals("1")) {
|
if (type.equals("1")) {
|
||||||
boolean checked = true;
|
boolean checked = true;
|
||||||
boolean auto_div = false;
|
boolean auto_div = false;
|
||||||
if (ObjectUtil.isEmpty(vehicle_code)) throw new BadRequestException("ACS申请任务失败!载具不能为空");
|
if (ObjectUtil.isEmpty(vehicle_code)) throw new BadRequestException("ACS申请任务失败!载具不能为空");
|
||||||
//通过该木箱码查询对应的分配明细
|
//通过该木箱码查询对应的分配明细
|
||||||
JSONArray dis_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("box_no",vehicle_code).addParam("flag","28").process().getResultJSONArray(0);
|
JSONArray dis_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("box_no",vehicle_code).addParam("flag","28").process().getResultJSONArray(0);
|
||||||
if (ObjectUtil.isEmpty(dis_rows)) {
|
if (ObjectUtil.isEmpty(dis_rows)) {
|
||||||
throw new BadRequestException("未查询到木箱:" + vehicle_code + "相关入库分配明细记录!");
|
throw new BadRequestException("未查询到木箱:" + vehicle_code + "相关入库分配明细记录!");
|
||||||
}
|
|
||||||
ArrayList<HashMap> dis_list = new ArrayList<>();
|
|
||||||
for (int i = 0; i < dis_rows.size(); i++) {
|
|
||||||
HashMap<String,String> dis_map = new HashMap<>();
|
|
||||||
JSONObject dis_row = dis_rows.getJSONObject(i);
|
|
||||||
dis_map.put("box_no",dis_row.getString("box_no"));
|
|
||||||
dis_map.put("point_code",device_code);
|
|
||||||
dis_map.put("sect_id",dis_row.getString("sect_id"));
|
|
||||||
dis_map.put("sect_code",dis_row.getString("sect_code"));
|
|
||||||
dis_map.put("sect_name",dis_row.getString("sect_name"));
|
|
||||||
dis_map.put("struct_id",dis_row.getString("struct_id"));
|
|
||||||
dis_map.put("struct_code",dis_row.getString("struct_code"));
|
|
||||||
if (StrUtil.isNotEmpty(dis_row.getString("struct_code"))){
|
|
||||||
auto_div = true;
|
|
||||||
checked = false;
|
|
||||||
}
|
}
|
||||||
dis_map.put("struct_name",dis_row.getString("struct_name"));
|
ArrayList<HashMap> dis_list = new ArrayList<>();
|
||||||
dis_map.put("iostorinv_id",dis_row.getString("iostorinv_id"));
|
for (int i = 0; i < dis_rows.size(); i++) {
|
||||||
dis_list.add(dis_map);
|
HashMap<String,String> dis_map = new HashMap<>();
|
||||||
|
JSONObject dis_row = dis_rows.getJSONObject(i);
|
||||||
|
dis_map.put("box_no",dis_row.getString("box_no"));
|
||||||
|
dis_map.put("point_code",device_code);
|
||||||
|
dis_map.put("sect_id",dis_row.getString("sect_id"));
|
||||||
|
dis_map.put("sect_code",dis_row.getString("sect_code"));
|
||||||
|
dis_map.put("sect_name",dis_row.getString("sect_name"));
|
||||||
|
dis_map.put("struct_id",dis_row.getString("struct_id"));
|
||||||
|
dis_map.put("struct_code",dis_row.getString("struct_code"));
|
||||||
|
if (StrUtil.isNotEmpty(dis_row.getString("struct_code"))){
|
||||||
|
auto_div = true;
|
||||||
|
checked = false;
|
||||||
|
}
|
||||||
|
dis_map.put("struct_name",dis_row.getString("struct_name"));
|
||||||
|
dis_map.put("iostorinv_id",dis_row.getString("iostorinv_id"));
|
||||||
|
dis_list.add(dis_map);
|
||||||
|
}
|
||||||
|
Map map = new HashMap();
|
||||||
|
//查询主存区的sect
|
||||||
|
JSONObject sect_jo = WQLObject.getWQLObject("st_ivt_sectattr").query("sect_type_attr = '00' AND is_used = '1'").uniqueResult(0);
|
||||||
|
map.put("tableMater", dis_list);
|
||||||
|
map.put("point_code", device_code);
|
||||||
|
map.put("sect_id", sect_jo.getString("sect_id"));
|
||||||
|
map.put("checked", checked);
|
||||||
|
map.put("auto_div", auto_div);
|
||||||
|
map.put("auto_issue", "1");
|
||||||
|
//自动分配货位并下发任务
|
||||||
|
rawAssistIStorService.divStruct(map);
|
||||||
}
|
}
|
||||||
Map map = new HashMap();
|
if (type.equals("2")) {
|
||||||
//查询主存区的sect
|
//查询一个可用的空载具点位并下发给ACS
|
||||||
JSONObject sect_jo = WQLObject.getWQLObject("st_ivt_sectattr").query("sect_type_attr = '00' AND is_used = '1'").uniqueResult(0);
|
/*
|
||||||
map.put("tableMater", dis_list);
|
* 1、优先存放空托盘区、托盘号默认99999;空托盘区没有位置,再找空巷道,或者空巷道有空位置的货位。
|
||||||
map.put("point_code", device_code);
|
2、分配货位规则:
|
||||||
map.put("sect_id", sect_jo.getString("sect_id"));
|
a、查找片区内,有空位的巷道,并且两头能够通畅的巷道排;判断巷道的任务类型,只能为入库或者无任务类型;
|
||||||
map.put("checked", checked);
|
b、没有,则优先找空的巷道;按空位置顺序分配;
|
||||||
map.put("auto_div", auto_div);
|
3、任务下发,判断巷道的任务类型,只能为空盘入库或者无任务类型;
|
||||||
map.put("auto_issue", "1");
|
* */
|
||||||
//自动分配货位并下发任务
|
vehicle_code = CodeUtil.getNewCode("VEHICCLE_CODE_KTP");
|
||||||
rawAssistIStorService.divStruct(map);
|
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "21").process().uniqueResult(0);
|
||||||
}
|
|
||||||
if (type.equals("2")) {
|
|
||||||
//查询一个可用的空载具点位并下发给ACS
|
|
||||||
/*
|
|
||||||
* 1、优先存放空托盘区、托盘号默认99999;空托盘区没有位置,再找空巷道,或者空巷道有空位置的货位。
|
|
||||||
2、分配货位规则:
|
|
||||||
a、查找片区内,有空位的巷道,并且两头能够通畅的巷道排;判断巷道的任务类型,只能为入库或者无任务类型;
|
|
||||||
b、没有,则优先找空的巷道;按空位置顺序分配;
|
|
||||||
3、任务下发,判断巷道的任务类型,只能为空盘入库或者无任务类型;
|
|
||||||
* */
|
|
||||||
vehicle_code = CodeUtil.getNewCode("VEHICCLE_CODE_KTP");
|
|
||||||
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "21").process().uniqueResult(0);
|
|
||||||
|
|
||||||
JSONObject struct_jo = new JSONObject();
|
JSONObject struct_jo = new JSONObject();
|
||||||
if (ObjectUtil.isNotEmpty(empty_row)) {
|
if (ObjectUtil.isNotEmpty(empty_row)) {
|
||||||
String block_num = empty_row.getString("block_num");
|
String block_num = empty_row.getString("block_num");
|
||||||
String row_num = empty_row.getString("row_num");
|
String row_num = empty_row.getString("row_num");
|
||||||
String placement_type = empty_row.getString("placement_type");
|
String placement_type = empty_row.getString("placement_type");
|
||||||
|
|
||||||
if (placement_type.equals("03")) {
|
if (placement_type.equals("03")) {
|
||||||
// 右通
|
// 右通
|
||||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq desc").uniqueResult(0);
|
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq desc").uniqueResult(0);
|
||||||
} else if (placement_type.equals("02")) {
|
} else if (placement_type.equals("02")) {
|
||||||
// 左通
|
// 左通
|
||||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq").uniqueResult(0);
|
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq").uniqueResult(0);
|
||||||
} else {
|
|
||||||
// 双通
|
|
||||||
|
|
||||||
// 先倒序找到第一个托盘、判断上一个是否有货位
|
|
||||||
JSONObject jsonDescBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0);
|
|
||||||
String out_order_seq = jsonDescBox.getString("out_order_seq");
|
|
||||||
// 上一个货位顺序号
|
|
||||||
String out_order_seq_desc = String.valueOf(NumberUtil.add(out_order_seq, "1"));
|
|
||||||
JSONObject jsonDescStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq = '" + out_order_seq_desc + "'").uniqueResult(0);
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(jsonDescStruct)) {
|
|
||||||
struct_jo = jsonDescStruct;
|
|
||||||
} else {
|
} else {
|
||||||
// 没有就正序找到第一个托盘、判断上一个是否有货位
|
// 双通
|
||||||
JSONObject jsonAscBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0);
|
|
||||||
String out_order_seq2 = jsonAscBox.getString("out_order_seq");
|
|
||||||
// 上一个货位顺序号
|
|
||||||
String out_order_seq_asc = String.valueOf(NumberUtil.sub(out_order_seq2, "1"));
|
|
||||||
JSONObject jsonAscStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq = '"+out_order_seq_asc+"'").uniqueResult(0);
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(jsonAscStruct)) {
|
// 先倒序找到第一个托盘、判断上一个是否有货位
|
||||||
struct_jo = jsonAscStruct;
|
JSONObject jsonDescBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0);
|
||||||
|
String out_order_seq = jsonDescBox.getString("out_order_seq");
|
||||||
|
// 上一个货位顺序号
|
||||||
|
String out_order_seq_desc = String.valueOf(NumberUtil.add(out_order_seq, "1"));
|
||||||
|
JSONObject jsonDescStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq = '" + out_order_seq_desc + "'").uniqueResult(0);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(jsonDescStruct)) {
|
||||||
|
struct_jo = jsonDescStruct;
|
||||||
|
} else {
|
||||||
|
// 没有就正序找到第一个托盘、判断上一个是否有货位
|
||||||
|
JSONObject jsonAscBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0);
|
||||||
|
String out_order_seq2 = jsonAscBox.getString("out_order_seq");
|
||||||
|
// 上一个货位顺序号
|
||||||
|
String out_order_seq_asc = String.valueOf(NumberUtil.sub(out_order_seq2, "1"));
|
||||||
|
JSONObject jsonAscStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq = '"+out_order_seq_asc+"'").uniqueResult(0);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(jsonAscStruct)) {
|
||||||
|
struct_jo = jsonAscStruct;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(struct_jo)) {
|
||||||
|
throw new BadRequestException("未查询到可用的空载具存放点位!");
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject task_jo = new JSONObject();
|
||||||
|
task_jo.put("point_code1", device_code);
|
||||||
|
task_jo.put("point_code2", struct_jo.getString("struct_code"));
|
||||||
|
task_jo.put("task_type", "010502");
|
||||||
|
task_jo.put("vehicle_code", vehicle_code);
|
||||||
|
EmptyVehicleTask task = new EmptyVehicleTask();
|
||||||
|
task.createTask(task_jo);
|
||||||
|
|
||||||
|
//锁定终点、货位点位
|
||||||
|
HashMap map = new HashMap();
|
||||||
|
map.put("lock_type", "5");
|
||||||
|
point_table.update(map, "point_code = '" + struct_jo.getString("struct_code") + "'");
|
||||||
|
struct_table.update(map, "struct_code = '" + struct_jo.getString("struct_code") + "'");
|
||||||
|
}
|
||||||
|
if (type.equals("3")) {
|
||||||
|
//查询一个可用的空载具点位并下发给ACS
|
||||||
|
/*
|
||||||
|
* 1、优先存放空托盘区、托盘号默认99999;空托盘区没有位置,再找空巷道,或者空巷道有空位置的货位。
|
||||||
|
2、分配货位规则:
|
||||||
|
a、查找片区内,有空位的巷道,并且两头能够通畅的巷道排;判断巷道的任务类型,只能为入库或者无任务类型;
|
||||||
|
b、没有,则优先找空的巷道;按空位置顺序分配;
|
||||||
|
3、任务下发,判断巷道的任务类型,只能为空盘入库或者无任务类型;
|
||||||
|
* */
|
||||||
|
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "22").process().uniqueResult(0);
|
||||||
|
|
||||||
|
JSONObject struct_jo = new JSONObject();
|
||||||
|
if (ObjectUtil.isNotEmpty(empty_row)) {
|
||||||
|
String block_num = empty_row.getString("block_num");
|
||||||
|
String row_num = empty_row.getString("row_num");
|
||||||
|
String placement_type = empty_row.getString("placement_type");
|
||||||
|
|
||||||
|
if (placement_type.equals("01") || placement_type.equals("03")) {
|
||||||
|
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq").uniqueResult(0);
|
||||||
|
} else {
|
||||||
|
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq desc").uniqueResult(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(struct_jo)) {
|
||||||
|
throw new BadRequestException("未查询到可用的空载具!");
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject task_jo = new JSONObject();
|
||||||
|
task_jo.put("point_code1", struct_jo.getString("struct_code"));
|
||||||
|
task_jo.put("point_code2", device_code);
|
||||||
|
task_jo.put("task_type", "010504");
|
||||||
|
task_jo.put("vehicle_code", struct_jo.getString("storagevehicle_code"));
|
||||||
|
EmptyVehicleTask task = new EmptyVehicleTask();
|
||||||
|
task.createTask(task_jo);
|
||||||
|
|
||||||
|
//锁定终点、货位点位
|
||||||
|
HashMap map = new HashMap();
|
||||||
|
map.put("lock_type", "4");
|
||||||
|
point_table.update(map, "point_code = '" + struct_jo.getString("struct_code") + "'");
|
||||||
|
struct_table.update(map, "struct_code = '" + struct_jo.getString("struct_code") + "'");
|
||||||
|
}
|
||||||
|
if (type.equals("4")) {
|
||||||
|
//查询该木箱对应的包装关系
|
||||||
|
JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + vehicle_code + "'").uniqueResult(0);
|
||||||
|
if (ObjectUtil.isEmpty(sub_jo)) {
|
||||||
|
throw new BadRequestException("未查询到该木箱对应的包装关系!");
|
||||||
|
}
|
||||||
|
String sale_order_name = sub_jo.getString("sale_order_name");
|
||||||
|
|
||||||
|
//查询是否存在可用的空位
|
||||||
|
String point_code = "";
|
||||||
|
JSONArray joArr = new JSONArray();
|
||||||
|
|
||||||
|
// 查找此订单号所在的所有排
|
||||||
|
JSONArray joRow = WQL.getWO("QST_ACSTOLMSTYPE4").addParam("flag", "1").addParam("sale_order_name", sale_order_name).process().getResultJSONArray(0);
|
||||||
|
for (int j = 0; j < joRow.size(); j++) {
|
||||||
|
JSONObject json = joRow.getJSONObject(j);
|
||||||
|
String row_num = json.getString("row_num");
|
||||||
|
|
||||||
|
// 查找此排下的所有空位
|
||||||
|
JSONArray joEmpPoint = WQL.getWO("QST_ACSTOLMSTYPE4").addParam("flag", "2").addParam("row_num", row_num).process().getResultJSONArray(0);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(joEmpPoint)) {
|
||||||
|
for (int n = 0; n < joEmpPoint.size(); n++) {
|
||||||
|
joArr.add(joEmpPoint.getJSONObject(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (ObjectUtil.isEmpty(struct_jo)) {
|
|
||||||
throw new BadRequestException("未查询到可用的空载具存放点位!");
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject task_jo = new JSONObject();
|
if (ObjectUtil.isEmpty(joArr)) {
|
||||||
task_jo.put("point_code1", device_code);
|
//查询新的一排
|
||||||
task_jo.put("point_code2", struct_jo.getString("struct_code"));
|
JSONObject point_jo = WQL.getWO("QST_ACSTOLMSTYPE4").addParam("flag", "3").process().uniqueResult(0);
|
||||||
task_jo.put("task_type", "010502");
|
if (ObjectUtil.isEmpty(point_jo)) {
|
||||||
task_jo.put("vehicle_code", vehicle_code);
|
throw new BadRequestException("未查询到相同销售订单的放货区点位或空的一排!");
|
||||||
EmptyVehicleTask task = new EmptyVehicleTask();
|
|
||||||
task.createTask(task_jo);
|
|
||||||
|
|
||||||
//锁定终点、货位点位
|
|
||||||
HashMap map = new HashMap();
|
|
||||||
map.put("lock_type", "5");
|
|
||||||
point_table.update(map, "point_code = '" + struct_jo.getString("struct_code") + "'");
|
|
||||||
struct_table.update(map, "struct_code = '" + struct_jo.getString("struct_code") + "'");
|
|
||||||
}
|
|
||||||
if (type.equals("3")) {
|
|
||||||
//查询一个可用的空载具点位并下发给ACS
|
|
||||||
/*
|
|
||||||
* 1、优先存放空托盘区、托盘号默认99999;空托盘区没有位置,再找空巷道,或者空巷道有空位置的货位。
|
|
||||||
2、分配货位规则:
|
|
||||||
a、查找片区内,有空位的巷道,并且两头能够通畅的巷道排;判断巷道的任务类型,只能为入库或者无任务类型;
|
|
||||||
b、没有,则优先找空的巷道;按空位置顺序分配;
|
|
||||||
3、任务下发,判断巷道的任务类型,只能为空盘入库或者无任务类型;
|
|
||||||
* */
|
|
||||||
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "22").process().uniqueResult(0);
|
|
||||||
|
|
||||||
JSONObject struct_jo = new JSONObject();
|
|
||||||
if (ObjectUtil.isNotEmpty(empty_row)) {
|
|
||||||
String block_num = empty_row.getString("block_num");
|
|
||||||
String row_num = empty_row.getString("row_num");
|
|
||||||
String placement_type = empty_row.getString("placement_type");
|
|
||||||
|
|
||||||
if (placement_type.equals("01") || placement_type.equals("03")) {
|
|
||||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq").uniqueResult(0);
|
|
||||||
} else {
|
|
||||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq desc").uniqueResult(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isEmpty(struct_jo)) {
|
|
||||||
throw new BadRequestException("未查询到可用的空载具!");
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject task_jo = new JSONObject();
|
|
||||||
task_jo.put("point_code1", struct_jo.getString("struct_code"));
|
|
||||||
task_jo.put("point_code2", device_code);
|
|
||||||
task_jo.put("task_type", "010504");
|
|
||||||
task_jo.put("vehicle_code", struct_jo.getString("storagevehicle_code"));
|
|
||||||
EmptyVehicleTask task = new EmptyVehicleTask();
|
|
||||||
task.createTask(task_jo);
|
|
||||||
|
|
||||||
//锁定终点、货位点位
|
|
||||||
HashMap map = new HashMap();
|
|
||||||
map.put("lock_type", "4");
|
|
||||||
point_table.update(map, "point_code = '" + struct_jo.getString("struct_code") + "'");
|
|
||||||
struct_table.update(map, "struct_code = '" + struct_jo.getString("struct_code") + "'");
|
|
||||||
}
|
|
||||||
if (type.equals("4")) {
|
|
||||||
//查询该木箱对应的包装关系
|
|
||||||
JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + vehicle_code + "'").uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(sub_jo)) {
|
|
||||||
throw new BadRequestException("未查询到该木箱对应的包装关系!");
|
|
||||||
}
|
|
||||||
String sale_order_name = sub_jo.getString("sale_order_name");
|
|
||||||
|
|
||||||
//查询是否存在可用的空位
|
|
||||||
String point_code = "";
|
|
||||||
JSONArray joArr = new JSONArray();
|
|
||||||
|
|
||||||
// 查找此订单号所在的所有排
|
|
||||||
JSONArray joRow = WQL.getWO("QST_ACSTOLMSTYPE4").addParam("flag", "1").addParam("sale_order_name", sale_order_name).process().getResultJSONArray(0);
|
|
||||||
for (int j = 0; j < joRow.size(); j++) {
|
|
||||||
JSONObject json = joRow.getJSONObject(j);
|
|
||||||
String row_num = json.getString("row_num");
|
|
||||||
|
|
||||||
// 查找此排下的所有空位
|
|
||||||
JSONArray joEmpPoint = WQL.getWO("QST_ACSTOLMSTYPE4").addParam("flag", "2").addParam("row_num", row_num).process().getResultJSONArray(0);
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(joEmpPoint)) {
|
|
||||||
for (int n = 0; n < joEmpPoint.size(); n++) {
|
|
||||||
joArr.add(joEmpPoint.getJSONObject(n));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(joArr)) {
|
|
||||||
//查询新的一排
|
|
||||||
JSONObject point_jo = WQL.getWO("QST_ACSTOLMSTYPE4").addParam("flag", "3").process().uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(point_jo)) {
|
|
||||||
throw new BadRequestException("未查询到相同销售订单的放货区点位或空的一排!");
|
|
||||||
} else {
|
|
||||||
JSONObject jsonNewRow = WQLObject.getWQLObject("sch_base_point").query("row_num = '" + point_jo.getString("row_num") + "' AND point_type ='9' AND is_delete = '0' order by out_order_seq ASC").uniqueResult(0);
|
|
||||||
point_code = jsonNewRow.getString("point_code");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 校验此货位是否被堵住:1.如果被堵住则判断下一个是否被堵住 2.如果全部被堵住则新开一排
|
|
||||||
for (int i = 0; i < joArr.size(); i++) {
|
|
||||||
JSONObject json = joArr.getJSONObject(i);
|
|
||||||
// 判断是否被挡住
|
|
||||||
JSONArray jsonArray = WQL.getWO("QST_ACSTOLMSTYPE4")
|
|
||||||
.addParam("flag", "4")
|
|
||||||
.addParam("point_code", json.getString("point_code"))
|
|
||||||
.process().getResultJSONArray(0);
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(jsonArray)) {
|
|
||||||
// 堵住则判断下一个
|
|
||||||
continue;
|
|
||||||
} else {
|
} else {
|
||||||
// 未堵住: 跳出循环
|
JSONObject jsonNewRow = WQLObject.getWQLObject("sch_base_point").query("row_num = '" + point_jo.getString("row_num") + "' AND point_type ='9' AND is_delete = '0' order by out_order_seq ASC").uniqueResult(0);
|
||||||
point_code = json.getString("point_code");
|
point_code = jsonNewRow.getString("point_code");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(point_code)) {
|
|
||||||
// 为空则新开一排
|
|
||||||
JSONObject point_jo = WQL.getWO("QST_ACSTOLMSTYPE4").addParam("flag", "3").process().uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(point_jo)) {
|
|
||||||
throw new BadRequestException("未查询到相同销售订单的放货区点位或空的一排!");
|
|
||||||
} else {
|
} else {
|
||||||
JSONObject jsonNewRow = WQLObject.getWQLObject("sch_base_point").query("row_num = '" + point_jo.getString("row_num") + "' AND point_type ='9' AND is_delete = '0' order by out_order_seq ASC").uniqueResult(0);
|
// 校验此货位是否被堵住:1.如果被堵住则判断下一个是否被堵住 2.如果全部被堵住则新开一排
|
||||||
point_code = jsonNewRow.getString("point_code");
|
for (int i = 0; i < joArr.size(); i++) {
|
||||||
|
JSONObject json = joArr.getJSONObject(i);
|
||||||
|
// 判断是否被挡住
|
||||||
|
JSONArray jsonArray = WQL.getWO("QST_ACSTOLMSTYPE4")
|
||||||
|
.addParam("flag", "4")
|
||||||
|
.addParam("point_code", json.getString("point_code"))
|
||||||
|
.process().getResultJSONArray(0);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(jsonArray)) {
|
||||||
|
// 堵住则判断下一个
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
// 未堵住: 跳出循环
|
||||||
|
point_code = json.getString("point_code");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(point_code)) {
|
||||||
|
// 为空则新开一排
|
||||||
|
JSONObject point_jo = WQL.getWO("QST_ACSTOLMSTYPE4").addParam("flag", "3").process().uniqueResult(0);
|
||||||
|
if (ObjectUtil.isEmpty(point_jo)) {
|
||||||
|
throw new BadRequestException("未查询到相同销售订单的放货区点位或空的一排!");
|
||||||
|
} else {
|
||||||
|
JSONObject jsonNewRow = WQLObject.getWQLObject("sch_base_point").query("row_num = '" + point_jo.getString("row_num") + "' AND point_type ='9' AND is_delete = '0' order by out_order_seq ASC").uniqueResult(0);
|
||||||
|
point_code = jsonNewRow.getString("point_code");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//创建任务
|
||||||
|
JSONObject task_jo = new JSONObject();
|
||||||
|
task_jo.put("point_code1", device_code);
|
||||||
|
task_jo.put("point_code2", point_code);
|
||||||
|
task_jo.put("vehicle_code", vehicle_code);
|
||||||
|
task_jo.put("task_type", "010506");
|
||||||
|
SendOutTask sendOutTask = new SendOutTask();
|
||||||
|
sendOutTask.createTask(task_jo);
|
||||||
}
|
}
|
||||||
|
result.put("status", HttpStatus.OK.value());
|
||||||
//创建任务
|
result.put("message", "下发成功!");
|
||||||
JSONObject task_jo = new JSONObject();
|
return result;
|
||||||
task_jo.put("point_code1", device_code);
|
|
||||||
task_jo.put("point_code2", point_code);
|
|
||||||
task_jo.put("vehicle_code", vehicle_code);
|
|
||||||
task_jo.put("task_type", "010506");
|
|
||||||
SendOutTask sendOutTask = new SendOutTask();
|
|
||||||
sendOutTask.createTask(task_jo);
|
|
||||||
}
|
}
|
||||||
JSONObject result = new JSONObject();
|
}finally {
|
||||||
result.put("status", HttpStatus.OK.value());
|
if (isLock){
|
||||||
result.put("message", "下发成功!");
|
lock.unlock();
|
||||||
return result;
|
}
|
||||||
}
|
}
|
||||||
|
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||||
|
result.put("message", "锁超时下发失败");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user