add:x
This commit is contained in:
@@ -39,8 +39,11 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class AppRun {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(AppRun.class, args);
|
||||
try {
|
||||
SpringApplication.run(AppRun.class, args);
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -28,6 +28,8 @@ import org.nl.wms.sch.tasks.EmptyVehicleTask;
|
||||
import org.nl.wms.sch.tasks.SendOutTask;
|
||||
import org.nl.wms.st.inbill.service.RawAssistIStorService;
|
||||
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.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -55,6 +57,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
|
||||
private final CutConveyorTask cutConveyorTask;
|
||||
|
||||
private final RedissonClient redissonClient;
|
||||
|
||||
/**
|
||||
* task_id:任务标识
|
||||
* task_code:任务编码
|
||||
@@ -192,64 +196,68 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
log.info("apply请求参数:---------------------------------------------"+whereJson.toString());
|
||||
String type = whereJson.getString("type");
|
||||
JSONObject result = new JSONObject();
|
||||
synchronized (lock.intern(type)){
|
||||
String device_code = whereJson.getString("device_code");
|
||||
String vehicle_code = whereJson.getString("vehicle_code");
|
||||
WQLObject point_table = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject struct_table = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
||||
RLock lock = redissonClient.getLock("acs_to_wms:" + type);
|
||||
boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock){
|
||||
{
|
||||
String device_code = whereJson.getString("device_code");
|
||||
String vehicle_code = whereJson.getString("vehicle_code");
|
||||
WQLObject point_table = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject struct_table = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
||||
|
||||
if (ObjectUtil.isEmpty(type)) throw new BadRequestException("ACS申请任务失败!任务类型不能为空");
|
||||
if (ObjectUtil.isEmpty(device_code)) throw new BadRequestException("ACS申请任务失败!点位不能为空");
|
||||
if (ObjectUtil.isEmpty(type)) throw new BadRequestException("ACS申请任务失败!任务类型不能为空");
|
||||
if (ObjectUtil.isEmpty(device_code)) throw new BadRequestException("ACS申请任务失败!点位不能为空");
|
||||
|
||||
/*
|
||||
* 根据type判断是什么业务类型:
|
||||
* 1.入库任务
|
||||
* 2.空盘入库任务
|
||||
* 3.空盘出库任务
|
||||
* 4.出库口申请入发货区任务
|
||||
*/
|
||||
if (type.equals("1")) {
|
||||
boolean checked = true;
|
||||
boolean auto_div = false;
|
||||
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);
|
||||
if (ObjectUtil.isEmpty(dis_rows)) {
|
||||
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;
|
||||
/*
|
||||
* 根据type判断是什么业务类型:
|
||||
* 1.入库任务
|
||||
* 2.空盘入库任务
|
||||
* 3.空盘出库任务
|
||||
* 4.出库口申请入发货区任务
|
||||
*/
|
||||
if (type.equals("1")) {
|
||||
boolean checked = true;
|
||||
boolean auto_div = false;
|
||||
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);
|
||||
if (ObjectUtil.isEmpty(dis_rows)) {
|
||||
throw new BadRequestException("未查询到木箱:" + vehicle_code + "相关入库分配明细记录!");
|
||||
}
|
||||
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);
|
||||
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"));
|
||||
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();
|
||||
//查询主存区的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);
|
||||
}
|
||||
if (type.equals("2")) {
|
||||
//查询一个可用的空载具点位并下发给ACS
|
||||
if (type.equals("2")) {
|
||||
//查询一个可用的空载具点位并下发给ACS
|
||||
/*
|
||||
* 1、优先存放空托盘区、托盘号默认99999;空托盘区没有位置,再找空巷道,或者空巷道有空位置的货位。
|
||||
2、分配货位规则:
|
||||
@@ -257,191 +265,199 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
b、没有,则优先找空的巷道;按空位置顺序分配;
|
||||
3、任务下发,判断巷道的任务类型,只能为空盘入库或者无任务类型;
|
||||
* */
|
||||
vehicle_code = CodeUtil.getNewCode("VEHICCLE_CODE_KTP");
|
||||
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("flag", "21").process().uniqueResult(0);
|
||||
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();
|
||||
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");
|
||||
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("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);
|
||||
} 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);
|
||||
} 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;
|
||||
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);
|
||||
} 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);
|
||||
} 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();
|
||||
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(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;
|
||||
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 {
|
||||
// 未堵住: 跳出循环
|
||||
point_code = json.getString("point_code");
|
||||
break;
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
// 校验此货位是否被堵住: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 {
|
||||
// 未堵住: 跳出循环
|
||||
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);
|
||||
}
|
||||
|
||||
//创建任务
|
||||
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", "下发成功!");
|
||||
return result;
|
||||
}
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "下发成功!");
|
||||
return result;
|
||||
|
||||
}
|
||||
}finally {
|
||||
if (tryLock){
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
result.put("message", "申请任务超时!"+type);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user