JSONArrayisLock=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('1','2','7') AND block_num = '"+block_num+"'AND placement_type = '"+placement_type+"' AND row_num = '"+row_num+"' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0);
if(ObjectUtil.isEmpty(isLock)){
if("02".equals(placement_type)){
// 左通
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 ASC").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);
JSONObjectjsonDescBox=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);
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+"' order by out_order_seq ASC").uniqueResult(0);
}else{
// 先倒序找到第一个入库锁或者移库锁、判断上一个是否有货位
JSONObjectjsonDescEmpStruct=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') 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);
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+"' order by out_order_seq ASC").uniqueResult(0);
JSONObjectjsonAscBox=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);
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_seq2+"' order by out_order_seq DESC").uniqueResult(0);
}else{
JSONObjectjsonAscEmpStruct=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') 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);
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_seq2+"' order by out_order_seq DESC").uniqueResult(0);
JSONObjectempty_row=WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("col_num",col_num).addParam("sect_id",sect_id).addParam("flag","13").addParam("sql_str"," ORDER BY abs("+box_num+"-a.struct_num),block_num,row_num").process().uniqueResult(0);
struct_jo=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num2+"' AND row_num = '"+row_num2+"' AND placement_type = '"+placement_type2+"' AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq ASC").uniqueResult(0);
struct_jo=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num2+"' AND row_num = '"+row_num2+"' AND placement_type = '"+placement_type2+"'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq DESC").uniqueResult(0);
JSONArrayhaveArr=WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("col_num",col_num).addParam("sect_id",sect_id).addParam("flag","14").addParam("sql_str"," ORDER BY abs("+box_num+"-a.struct_num)").process().getResultJSONArray(0);
for(intj=0;j<haveArr.size();j++){
JSONObjecthave_row=haveArr.getJSONObject(j);
Stringblock_num3=have_row.getString("block_num");
Stringrow_num3=have_row.getString("row_num");
JSONArrayisLock2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('1','2','7') AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0);
if(ObjectUtil.isEmpty(isLock2)){
// 先倒序找到第一个木箱、判断上一个是否有货位
JSONObjectjsonDescBox2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0);
jsonDescStruct2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '"+out_order_seq+"' order by out_order_seq ASC").uniqueResult(0);
}else{
// 先倒序找到第一个入库锁或者移库锁、判断上一个是否有货位
JSONObjectjsonDescEmpStruct=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq DESC").uniqueResult(0);
jsonDescStruct2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '"+out_order_seq+"' order by out_order_seq ASC").uniqueResult(0);
JSONObjectjsonAscBox2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0);
jsonAscStruct2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '"+out_order_seq2+"' order by out_order_seq DESC").uniqueResult(0);
}else{
JSONObjectjsonAscEmpStruct=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq ASC").uniqueResult(0);
jsonAscStruct2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '"+out_order_seq2+"' 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 row_num = '"+row_num+"' AND placement_type = '"+placement_type+"' AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq ASC").uniqueResult(0);
}else{
struct_jo=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num+"' AND row_num = '"+row_num+"' AND placement_type = '"+placement_type+"'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq DESC").uniqueResult(0);
}
}else{
//如果查询不到空的一排,则查询有空位双通的一排
JSONArrayhaveArr=WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("col_num",col_num).addParam("sect_id",sect_id).addParam("flag","14").addParam("sql_str"," ORDER BY abs("+box_num+"-a.struct_num)").process().getResultJSONArray(0);
for(intj=0;j<haveArr.size();j++){
JSONObjecthave_row=haveArr.getJSONObject(j);
Stringblock_num3=have_row.getString("block_num");
Stringrow_num3=have_row.getString("row_num");
JSONArrayisLock2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('1','2','7') AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0);
if(ObjectUtil.isEmpty(isLock2)){
// 先倒序找到第一个木箱、判断上一个是否有货位
JSONObjectjsonDescBox2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0);
jsonDescStruct2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '"+out_order_seq+"' order by out_order_seq ASC").uniqueResult(0);
}else{
// 先倒序找到第一个入库锁或者移库锁、判断上一个是否有货位
JSONObjectjsonDescEmpStruct=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq DESC").uniqueResult(0);
jsonDescStruct2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '"+out_order_seq+"' order by out_order_seq ASC").uniqueResult(0);
JSONObjectjsonAscBox2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0);
jsonAscStruct2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '"+out_order_seq2+"' order by out_order_seq DESC").uniqueResult(0);
}else{
JSONObjectjsonAscEmpStruct=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq ASC").uniqueResult(0);
jsonAscStruct2=WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '"+block_num3+"' AND row_num = '"+row_num3+"' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '"+out_order_seq2+"' order by out_order_seq DESC").uniqueResult(0);