代码更新

This commit is contained in:
2023-02-06 12:50:29 +08:00
parent 83ca6e8f44
commit fcda87f637
2 changed files with 53 additions and 95 deletions

View File

@@ -193,13 +193,13 @@ 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();
RLock lock = redissonClient.getLock("acs_to_wms:" + type);
boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS);
try {
if (tryLock){
if (tryLock) {
String device_code = whereJson.getString("device_code");
String vehicle_code = whereJson.getString("vehicle_code");
WQLObject point_table = WQLObject.getWQLObject("SCH_BASE_Point");
@@ -220,27 +220,27 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
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);
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<>();
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"))){
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_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();
@@ -257,13 +257,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
if (type.equals("2")) {
//查询一个可用的空载具点位并下发给ACS
/*
* 1、优先存放空托盘区、托盘号默认99999空托盘区没有位置再找空巷道或者空巷道有空位置的货位。
2、分配货位规则
a、查找片区内有空位的巷道并且两头能够通畅的巷道排判断巷道的任务类型只能为入库或者无任务类型
b、没有则优先找空的巷道按空位置顺序分配
3、任务下发判断巷道的任务类型只能为空盘入库或者无任务类型
* */
/*
* 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);
@@ -297,7 +297,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
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);
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;
@@ -326,13 +326,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
if (type.equals("3")) {
//查询一个可用的空载具点位并下发给ACS
/*
* 1、优先存放空托盘区、托盘号默认99999空托盘区没有位置再找空巷道或者空巷道有空位置的货位。
2、分配货位规则
a、查找片区内有空位的巷道并且两头能够通畅的巷道排判断巷道的任务类型只能为入库或者无任务类型
b、没有则优先找空的巷道按空位置顺序分配
3、任务下发判断巷道的任务类型只能为空盘入库或者无任务类型
* */
/*
* 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();
@@ -448,13 +448,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
result.put("message", "下发成功!");
return result;
}
}finally {
if (tryLock){
} finally {
if (tryLock) {
lock.unlock();
}
}
result.put("status", HttpStatus.BAD_REQUEST.value());
result.put("message", "申请任务超时!"+type);
result.put("message", "申请任务超时!" + type);
return result;
}

View File

@@ -808,7 +808,7 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
/*
* 分配逻辑:
* 1、先查找该木箱内属于什么物料、订单定位到具体的块、排查看是否存在空位
* a、存在的话优先放在这一块这一排中
* a、存在的话优先放在这一块这一排中(遍历)
* b、不存在则根据该订单物料大概数量、选择数量相近的一个空巷道
* 1存在空巷道
* 2不存在则找一个双通有空位置、数量相近的巷道
@@ -832,9 +832,11 @@ 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");
@@ -845,9 +847,11 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
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 {
// 双通
@@ -870,6 +874,7 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
if (ObjectUtil.isNotEmpty(jsonDescStruct)) {
struct_jo = jsonDescStruct;
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);
@@ -890,6 +895,7 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
}
if (ObjectUtil.isNotEmpty(jsonAscStruct)) {
struct_jo = jsonAscStruct;
break;
} else {
// 说明这排有任务在执行,新开一排
//根据分切计划查询该订单物料大概还有多少未入
@@ -915,11 +921,12 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
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);
@@ -932,85 +939,35 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
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 {
// 说明这排有任务在执行,新开一排
//根据分切计划查询该订单物料大概还有多少未入
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);
} 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);
}
} 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);
}
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);
}
}
}
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();
@@ -1048,6 +1005,7 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
}
}
}
if (ObjectUtil.isEmpty(struct_jo)) {
throw new BadRequestException("未查询到可用的仓位!");
}