Merge branch 'master' of http://121.40.234.130:8899/root/lanzhouhailiang_one
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package org.nl.common.utils;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.concurrent.FutureCallback;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
|
||||
import org.apache.http.impl.nio.client.HttpAsyncClients;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/*
|
||||
* HTtp异步调用
|
||||
*/
|
||||
public class AsyncHttpRequest {
|
||||
|
||||
private StringEntity entity;
|
||||
public HttpRequestBase httpbase;
|
||||
private String url;
|
||||
|
||||
public AsyncHttpRequest(String url) {
|
||||
this.url=url;
|
||||
}
|
||||
|
||||
public static AsyncHttpRequest post(String url,String body){
|
||||
return new AsyncHttpRequest(url).body(body);
|
||||
};
|
||||
|
||||
public static AsyncHttpRequest get(String url){
|
||||
return new AsyncHttpRequest(url).getEntity();
|
||||
};
|
||||
private AsyncHttpRequest getEntity(){
|
||||
HttpGet httpGet = new HttpGet(this.url);
|
||||
this.httpbase = httpGet;
|
||||
return this;
|
||||
};
|
||||
private AsyncHttpRequest body(String body){
|
||||
this.entity = new StringEntity(body, "UTF-8");
|
||||
this.entity.setContentType("application/json");
|
||||
HttpPost httpPost = new HttpPost(this.url);
|
||||
httpPost.setEntity(entity);
|
||||
this.httpbase = httpPost;
|
||||
return this;
|
||||
};
|
||||
public Future<HttpResponse> execute(FutureCallback<HttpResponse> callback){
|
||||
CloseableHttpAsyncClient client = SpringContextHolder.getBean(CloseableHttpAsyncClient.class);
|
||||
Future<HttpResponse> execute = client.execute(httpbase, callback);
|
||||
return execute;
|
||||
};
|
||||
}
|
||||
@Component
|
||||
class HttpAsyncClientInit{
|
||||
|
||||
@Bean
|
||||
public CloseableHttpAsyncClient closeableHttpAsyncClient(){
|
||||
CloseableHttpAsyncClient aDefault = HttpAsyncClients.createDefault();
|
||||
aDefault.start();
|
||||
return aDefault;
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class WebSocketServer {
|
||||
* @param message 客户端发送过来的消息*/
|
||||
@OnMessage
|
||||
public void onMessage(String message, Session session) {
|
||||
log.info("收到来"+sid+"的信息:"+message);
|
||||
// log.info("收到来"+sid+"的信息:"+message);
|
||||
//群发消息
|
||||
for (WebSocketServer item : webSocketSet) {
|
||||
try {
|
||||
@@ -106,7 +106,7 @@ public class WebSocketServer {
|
||||
* */
|
||||
public static void sendInfo(SocketMsg socketMsg,@PathParam("sid") String sid) throws IOException {
|
||||
String message = JSONObject.toJSONString(socketMsg);
|
||||
log.info("推送消息到"+sid+",推送内容:"+message);
|
||||
// log.info("推送消息到"+sid+",推送内容:"+message);
|
||||
for (WebSocketServer item : webSocketSet) {
|
||||
try {
|
||||
//这里可以设定只推送给这个sid的,为null则全部推送
|
||||
|
||||
@@ -50,7 +50,6 @@ public class AcsToWmsController {
|
||||
@PostMapping("/apply")
|
||||
@Log(value = "申请任务", isInterfaceLog = true,interfaceLogType= InterfaceLogType.ACS_TO_LMS)
|
||||
@ApiOperation("申请任务")
|
||||
@SaCheckPermission("menu:list")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> apply(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(acsToWmsService.apply(whereJson), HttpStatus.OK);
|
||||
@@ -59,7 +58,7 @@ public class AcsToWmsController {
|
||||
@PostMapping("/againApply")
|
||||
@Log(value = "二次申请任务", isInterfaceLog = true,interfaceLogType= InterfaceLogType.ACS_TO_LMS)
|
||||
@ApiOperation("二次申请任务")
|
||||
@SaCheckPermission("menu:list")
|
||||
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> againApply(@RequestBody String task_id) {
|
||||
return new ResponseEntity<>(acsToWmsService.againApply(task_id), HttpStatus.OK);
|
||||
@@ -92,7 +91,7 @@ public class AcsToWmsController {
|
||||
@Log(value = "仓位初始化", isInterfaceLog = true,interfaceLogType= InterfaceLogType.ACS_TO_LMS)
|
||||
@ApiOperation("仓位初始化")
|
||||
@SaIgnore
|
||||
@SaCheckPermission("menu:list")
|
||||
|
||||
public ResponseEntity<Object> initialize(@RequestBody JSONObject json) {
|
||||
acsToWmsService.initialize(json);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -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;
|
||||
@@ -44,7 +46,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Slf4j
|
||||
public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
|
||||
private static Interner<String> lock = Interners.newWeakInterner();
|
||||
private static Interner<String> Heap_Lock = Interners.newWeakInterner();
|
||||
|
||||
|
||||
private final PrintService printService;
|
||||
@@ -55,7 +57,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
|
||||
private final CutConveyorTask cutConveyorTask;
|
||||
|
||||
// private final RedissonClient redissonClient;
|
||||
private final RedissonClient redissonClient;
|
||||
|
||||
/**
|
||||
* task_id:任务标识
|
||||
@@ -191,261 +193,269 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@SneakyThrows
|
||||
public JSONObject apply(JSONObject whereJson) {
|
||||
log.info("apply请求参数:---------------------------------------------"+whereJson.toString());
|
||||
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;
|
||||
}
|
||||
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);
|
||||
/*
|
||||
* 根据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 + "相关入库分配明细记录!");
|
||||
}
|
||||
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();
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
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") + "'");
|
||||
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);
|
||||
}
|
||||
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 {
|
||||
// 未堵住: 跳出循环
|
||||
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", "下发成功!");
|
||||
return result;
|
||||
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
|
||||
/*
|
||||
* 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();
|
||||
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;
|
||||
} 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(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 {
|
||||
// 未堵住: 跳出循环
|
||||
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", "下发成功!");
|
||||
return result;
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
result.put("message", "申请任务超时!" + type);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,10 +51,6 @@ public class InTask extends AbstractAcsTask {
|
||||
JSONObject struct_jo = WQLObject.getWQLObject("ST_IVT_StructAttr").query("struct_code = '"+point_code2+"'").uniqueResult(0);
|
||||
String row_num = struct_jo.getString("row_num");
|
||||
String block_num = struct_jo.getString("block_num");
|
||||
JSONObject task_jo = WQLObject.getWQLObject("ST_IVT_StructAttr").query("block_num = '"+block_num+"' AND row_num = '"+row_num+"' AND lock_type in ('3','6')").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(task_jo)){
|
||||
continue;
|
||||
}
|
||||
|
||||
char dtl_type = json.getString("task_type").charAt(json.getString("task_type").length()-1);
|
||||
AcsTaskDto dto = AcsTaskDto.builder()
|
||||
|
||||
@@ -808,7 +808,7 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
/*
|
||||
* 分配逻辑:
|
||||
* 1、先查找该木箱内属于什么物料、订单,定位到具体的块、排,查看是否存在空位
|
||||
* a、存在的话,优先放在这一块这一排中
|
||||
* a、存在的话,优先放在这一块这一排中(遍历)
|
||||
* b、不存在则根据该订单物料大概数量、选择数量相近的一个空巷道
|
||||
* 1)存在空巷道
|
||||
* 2)不存在,则找一个双通有空位置、数量相近的巷道
|
||||
@@ -832,119 +832,142 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
row_map.put("sect_id", sect_id);
|
||||
row_map.put("flag", "11");
|
||||
//查询到当前可用的巷道
|
||||
JSONObject row_jo = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().uniqueResult(0);
|
||||
JSONArray rowArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
|
||||
for (int i = 0; i < rowArr.size(); i++) {
|
||||
JSONObject row_jo = rowArr.getJSONObject(i);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(row_jo)) {
|
||||
String block_num = row_jo.getString("block_num");
|
||||
String row_num = row_jo.getString("row_num");
|
||||
String placement_type = row_jo.getString("placement_type");
|
||||
|
||||
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 ASC").uniqueResult(0);
|
||||
} else 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 {
|
||||
// 双通
|
||||
// 先倒序找到第一个木箱、判断上一个是否有货位
|
||||
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);
|
||||
|
||||
JSONObject jsonDescStruct = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(jsonDescBox)) {
|
||||
String out_order_seq = jsonDescBox.getString("out_order_seq");
|
||||
// 上一个货位顺序号
|
||||
String out_order_seq_desc = String.valueOf(NumberUtil.add(out_order_seq, "1"));
|
||||
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;
|
||||
// 判断此排是否有除:入库锁、移入锁以外的锁
|
||||
JSONArray isLock = 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 (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 ASC").uniqueResult(0);
|
||||
break;
|
||||
} else 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);
|
||||
break;
|
||||
} 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);
|
||||
// 双通
|
||||
|
||||
JSONObject jsonAscStruct = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(jsonAscBox)) {
|
||||
String out_order_seq2 = jsonAscBox.getString("out_order_seq");
|
||||
// 上一个货位顺序号
|
||||
String out_order_seq_asc = String.valueOf(NumberUtil.sub(out_order_seq2, "1"));
|
||||
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);
|
||||
// 先倒序找到第一个木箱、判断上一个是否有货位
|
||||
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);
|
||||
|
||||
JSONObject jsonDescStruct = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(jsonDescBox)) {
|
||||
String out_order_seq = jsonDescBox.getString("out_order_seq");
|
||||
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 {
|
||||
// 先倒序找到第一个入库锁或者移库锁、判断上一个是否有货位
|
||||
JSONObject jsonDescEmpStruct = 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);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonDescEmpStruct)) {
|
||||
String out_order_seq = jsonDescEmpStruct.getString("out_order_seq");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonAscStruct)) {
|
||||
struct_jo = jsonAscStruct;
|
||||
if (ObjectUtil.isNotEmpty(jsonDescStruct)) {
|
||||
struct_jo = jsonDescStruct;
|
||||
break;
|
||||
} else {
|
||||
// 说明这排有任务在执行,新开一排
|
||||
//根据分切计划查询该订单物料大概还有多少未入
|
||||
row_map.put("flag", "12");
|
||||
JSONArray plan_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(plan_rows)) {
|
||||
plan_rows = new JSONArray();
|
||||
}
|
||||
//查询该销售订单及行号有多少个生成状态的箱子
|
||||
row_map.put("flag", "27");
|
||||
JSONArray box_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(box_rows)) {
|
||||
box_rows = new JSONArray();
|
||||
}
|
||||
int box_num = (int) Math.ceil(plan_rows.size() / 2) + box_rows.size();
|
||||
// 没有就正序找到第一个物料、判断上一个是否有货位
|
||||
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);
|
||||
|
||||
//查询数量与订单物料箱子数量相近的一排
|
||||
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").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);
|
||||
if (ObjectUtil.isNotEmpty(empty_row)) {
|
||||
String block_num2 = empty_row.getString("block_num");
|
||||
String row_num2 = empty_row.getString("row_num");
|
||||
String placement_type2 = empty_row.getString("placement_type");
|
||||
|
||||
if (placement_type.equals("02")) {
|
||||
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);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
JSONObject jsonAscStruct = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(jsonAscBox)) {
|
||||
String out_order_seq2 = jsonAscBox.getString("out_order_seq");
|
||||
// 上一个货位顺序号
|
||||
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 {
|
||||
JSONObject jsonAscEmpStruct = 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);
|
||||
|
||||
//如果查询不到空的一排,则查询有空位双通的一排
|
||||
JSONObject have_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id", sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(have_row)) {
|
||||
String block_num3 = have_row.getString("block_num");
|
||||
String row_num3 = have_row.getString("row_num");
|
||||
|
||||
//判断该排是左边为空,还是右边为空
|
||||
JSONObject right_str = WQLObject.getWQLObject("st_ivt_structattr").query("block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' order by out_order_seq").uniqueResult(0);
|
||||
JSONObject left_str = WQLObject.getWQLObject("st_ivt_structattr").query("block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' order by out_order_seq desc").uniqueResult(0);
|
||||
if (StrUtil.isNotEmpty(right_str.getString("storagevehicle_code")) || !right_str.getString("lock_type").equals("1")) {
|
||||
struct_jo = 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").uniqueResult(0);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(left_str.getString("storagevehicle_code")) || !left_str.getString("lock_type").equals("1")) {
|
||||
struct_jo = 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);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(jsonAscEmpStruct)) {
|
||||
String out_order_seq2 = jsonAscEmpStruct.getString("out_order_seq");
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(jsonAscStruct)) {
|
||||
struct_jo = jsonAscStruct;
|
||||
break;
|
||||
} else {
|
||||
// 说明这排有任务在执行,新开一排
|
||||
//根据分切计划查询该订单物料大概还有多少未入
|
||||
row_map.put("flag", "12");
|
||||
JSONArray plan_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(plan_rows)) {
|
||||
plan_rows = new JSONArray();
|
||||
}
|
||||
//查询该销售订单及行号有多少个生成状态的箱子
|
||||
row_map.put("flag", "27");
|
||||
JSONArray box_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(box_rows)) {
|
||||
box_rows = new JSONArray();
|
||||
}
|
||||
int box_num = (int) Math.ceil(plan_rows.size() / 2) + box_rows.size();
|
||||
|
||||
//查询数量与订单物料箱子数量相近的一排
|
||||
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").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);
|
||||
if (ObjectUtil.isNotEmpty(empty_row)) {
|
||||
String block_num2 = empty_row.getString("block_num");
|
||||
String row_num2 = empty_row.getString("row_num");
|
||||
String placement_type2 = empty_row.getString("placement_type");
|
||||
|
||||
if (placement_type.equals("02")) {
|
||||
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);
|
||||
break;
|
||||
} else {
|
||||
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);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//如果查询不到空的一排,则查询有空位双通的一排
|
||||
JSONObject have_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id", sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(have_row)) {
|
||||
String block_num3 = have_row.getString("block_num");
|
||||
String row_num3 = have_row.getString("row_num");
|
||||
|
||||
//判断该排是左边为空,还是右边为空
|
||||
JSONObject right_str = WQLObject.getWQLObject("st_ivt_structattr").query("block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' order by out_order_seq").uniqueResult(0);
|
||||
JSONObject left_str = WQLObject.getWQLObject("st_ivt_structattr").query("block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' order by out_order_seq desc").uniqueResult(0);
|
||||
if (StrUtil.isNotEmpty(right_str.getString("storagevehicle_code")) || !right_str.getString("lock_type").equals("1")) {
|
||||
struct_jo = 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").uniqueResult(0);
|
||||
break;
|
||||
}
|
||||
if (StrUtil.isNotEmpty(left_str.getString("storagevehicle_code")) || !left_str.getString("lock_type").equals("1")) {
|
||||
struct_jo = 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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
//如果不存在相同订单物料的巷道
|
||||
/*//查询是否存在未完成的相同订单物流的入库单,如果存在则查询该排是否存在可用的仓位
|
||||
HashMap<String,String> io_map = new HashMap<>();
|
||||
io_map.put("flag","12");
|
||||
io_map.put("material_code",material_code);
|
||||
io_map.put("sale_order_name",sale_order_name);
|
||||
JSONArray io_rows = WQL.getWO("").addParamMap(io_map).process().getResultJSONArray(0);*/
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(rowArr) || ObjectUtil.isEmpty(struct_jo)) {
|
||||
//如果不存在相同订单物料的巷道 或者未找到相同物料订单号巷道中的货位 则
|
||||
|
||||
//根据分切计划查询该订单物料大概还有多少未入
|
||||
row_map.put("flag", "12");
|
||||
JSONArray plan_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(plan_rows)){
|
||||
if (ObjectUtil.isEmpty(plan_rows)) {
|
||||
plan_rows = new JSONArray();
|
||||
}
|
||||
//查询该销售订单及行号有多少个生成状态的箱子
|
||||
row_map.put("flag", "27");
|
||||
JSONArray box_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(box_rows)){
|
||||
if (ObjectUtil.isEmpty(box_rows)) {
|
||||
box_rows = new JSONArray();
|
||||
}
|
||||
int box_num = (int) Math.ceil(plan_rows.size() / 2) + box_rows.size();
|
||||
@@ -982,6 +1005,7 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(struct_jo)) {
|
||||
throw new BadRequestException("未查询到可用的仓位!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user