fix:修复虚拟货位生成只到100的问题
This commit is contained in:
@@ -20,6 +20,7 @@ import lombok.SneakyThrows;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
||||||
import org.nl.common.utils.CodeUtil;
|
import org.nl.common.utils.CodeUtil;
|
||||||
|
import org.nl.common.utils.RedissonUtils;
|
||||||
import org.nl.common.utils.SecurityUtils;
|
import org.nl.common.utils.SecurityUtils;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.common.utils.FileUtil;
|
import org.nl.modules.common.utils.FileUtil;
|
||||||
@@ -1591,250 +1592,238 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
RedissonUtils.lock(a->{
|
||||||
|
//查询生成和未分配完的明细
|
||||||
|
JSONArray dtls = WQL.getWO("QST_IVT_CHECKOUTBILL")
|
||||||
|
.addParam("flag", "2")
|
||||||
|
.addParam("bill_status", "30")
|
||||||
|
.addParam("unassign_flag", "1")
|
||||||
|
.addParam("iostorinv_id", iostorinv_id)
|
||||||
|
.addParam("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id"))
|
||||||
|
.process()
|
||||||
|
.getResultJSONArray(0);
|
||||||
|
if (ObjectUtil.isEmpty(dtls)) {
|
||||||
|
throw new BadRequestException("当前订单无可分配出库明细");
|
||||||
|
}
|
||||||
|
//定义需要更新的仓位集合
|
||||||
|
HashMap<String, JSONObject> Struct_map = new HashMap<String, JSONObject>();
|
||||||
|
for (int i = 0; i < dtls.size(); i++) {
|
||||||
|
JSONObject dtl = dtls.getJSONObject(i);
|
||||||
|
double unassign_qty = dtl.getDoubleValue("unassign_qty");
|
||||||
|
double plan_qty = dtl.getDoubleValue("plan_qty");
|
||||||
|
/*
|
||||||
|
* 分配规则:
|
||||||
|
* top1.有销售订单号:用销售订单号、物料去找这批物料最早入库的所在的巷道
|
||||||
|
* top2.没有销售订单号,有子卷号:固定出某个木箱
|
||||||
|
* top3.没有销售订单号,没有子卷号:找此物料最早入库的所在巷道
|
||||||
|
*/
|
||||||
|
boolean is_top3 = false;
|
||||||
|
if (ObjectUtil.isEmpty(dtl.getString("source_bill_code")) && ObjectUtil.isEmpty(dtl.getString("pcsn"))) {
|
||||||
|
is_top3 = true;
|
||||||
|
}
|
||||||
|
JSONObject jsonMap = new JSONObject();
|
||||||
|
// 已分配重量
|
||||||
|
double assign_qty = dtl.getDoubleValue("assign_qty");
|
||||||
|
|
||||||
//查询生成和未分配完的明细
|
if (ObjectUtil.isNotEmpty(dtl.getString("source_bill_code")) || is_top3) {
|
||||||
JSONArray dtls = WQL.getWO("QST_IVT_CHECKOUTBILL")
|
while (unassign_qty > 0) {
|
||||||
.addParam("flag", "2")
|
// 1.有销售订单号
|
||||||
.addParam("bill_status", "30")
|
|
||||||
.addParam("unassign_flag", "1")
|
|
||||||
.addParam("iostorinv_id", iostorinv_id)
|
|
||||||
.addParam("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id"))
|
|
||||||
.process()
|
|
||||||
.getResultJSONArray(0);
|
|
||||||
if (ObjectUtil.isEmpty(dtls)) {
|
|
||||||
throw new BadRequestException("当前订单无可分配出库明细");
|
|
||||||
}
|
|
||||||
|
|
||||||
RLock lock = redissonClient.getLock("all_divOne");
|
|
||||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (tryLock) {
|
|
||||||
//定义需要更新的仓位集合
|
|
||||||
HashMap<String, JSONObject> Struct_map = new HashMap<String, JSONObject>();
|
|
||||||
for (int i = 0; i < dtls.size(); i++) {
|
|
||||||
JSONObject dtl = dtls.getJSONObject(i);
|
|
||||||
double unassign_qty = dtl.getDoubleValue("unassign_qty");
|
|
||||||
double plan_qty = dtl.getDoubleValue("plan_qty");
|
|
||||||
/*
|
|
||||||
* 分配规则:
|
|
||||||
* top1.有销售订单号:用销售订单号、物料去找这批物料最早入库的所在的巷道
|
|
||||||
* top2.没有销售订单号,有子卷号:固定出某个木箱
|
|
||||||
* top3.没有销售订单号,没有子卷号:找此物料最早入库的所在巷道
|
|
||||||
*/
|
|
||||||
boolean is_top3 = false;
|
|
||||||
if (ObjectUtil.isEmpty(dtl.getString("source_bill_code")) && ObjectUtil.isEmpty(dtl.getString("pcsn"))) {
|
|
||||||
is_top3 = true;
|
|
||||||
}
|
|
||||||
JSONObject jsonMap = new JSONObject();
|
|
||||||
// 已分配重量
|
|
||||||
double assign_qty = dtl.getDoubleValue("assign_qty");
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(dtl.getString("source_bill_code")) || is_top3) {
|
|
||||||
while (unassign_qty > 0) {
|
|
||||||
// 1.有销售订单号
|
|
||||||
jsonMap.put("flag", "1");
|
|
||||||
jsonMap.put("material_id", dtl.getString("material_id"));
|
|
||||||
jsonMap.put("sale_order_name", dtl.getString("source_bill_code"));
|
|
||||||
jsonMap.put("sect_id", whereJson.getString("sect_id"));
|
|
||||||
jsonMap.put("stor_id", whereJson.getString("stor_id"));
|
|
||||||
|
|
||||||
JSONObject jsonOneIvt = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(jsonOneIvt)) {
|
|
||||||
throw new BadRequestException("库存不足");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询这一巷道所有此物料此库存此销售订单的库存
|
|
||||||
jsonMap.put("flag", "2");
|
|
||||||
jsonMap.put("row_num", jsonOneIvt.getString("row_num"));
|
|
||||||
jsonMap.put("block_num", jsonOneIvt.getString("block_num"));
|
|
||||||
JSONArray ivtAllArr = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0);
|
|
||||||
|
|
||||||
for (int j = 0; j < ivtAllArr.size(); j++) {
|
|
||||||
JSONObject ivt = ivtAllArr.getJSONObject(j);
|
|
||||||
double canuse_qty = ivt.getDoubleValue("canuse_qty");
|
|
||||||
assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
|
||||||
|
|
||||||
if (unassign_qty >= canuse_qty) {
|
|
||||||
unassign_qty = NumberUtil.sub(unassign_qty, canuse_qty);
|
|
||||||
} else {
|
|
||||||
unassign_qty = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询此木箱下的所有子卷
|
|
||||||
jsonMap.put("flag", "3");
|
|
||||||
jsonMap.put("storagevehicle_code", ivt.getString("storagevehicle_code"));
|
|
||||||
JSONArray ivtAllArr2 = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0);
|
|
||||||
|
|
||||||
for (int k = 0; k < ivtAllArr2.size(); k++) {
|
|
||||||
// 更新库存
|
|
||||||
JSONObject ivt2 = ivtAllArr2.getJSONObject(k);
|
|
||||||
ivt2.put("change_qty", ivt2.getDoubleValue("canuse_qty"));
|
|
||||||
ivt2.put("bill_type_scode", jo_mst.getString("bill_type"));
|
|
||||||
ivt2.put("inv_id", dtl.getString("iostorinv_id"));
|
|
||||||
ivt2.put("bill_code", jo_mst.getString("bill_code"));
|
|
||||||
ivt2.put("bill_table", "ST_IVT_IOStorInv");
|
|
||||||
storPublicService.IOStor(ivt2, "11");
|
|
||||||
|
|
||||||
//生成分配明细
|
|
||||||
dtl.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId());
|
|
||||||
dtl.put("sect_id", ivt2.getString("sect_id"));
|
|
||||||
dtl.put("sect_code", ivt2.getString("sect_code"));
|
|
||||||
dtl.put("sect_name", ivt2.getString("sect_name"));
|
|
||||||
dtl.put("struct_id", ivt2.getString("struct_id"));
|
|
||||||
dtl.put("struct_code", ivt2.getString("struct_code"));
|
|
||||||
dtl.put("struct_name", ivt2.getString("struct_name"));
|
|
||||||
dtl.put("pcsn", ivt2.getString("pcsn"));
|
|
||||||
dtl.put("box_no", ivt2.getString("storagevehicle_code"));
|
|
||||||
dtl.put("storagevehicle_id", ivt2.getString("storagevehicle_id"));
|
|
||||||
dtl.put("storagevehicle_code", ivt2.getString("storagevehicle_code"));
|
|
||||||
dtl.put("storagevehicle_type", ivt2.getString("storagevehicle_type"));
|
|
||||||
dtl.put("is_issued", "0");
|
|
||||||
dtl.put("plan_qty", ivt2.getDoubleValue("change_qty"));
|
|
||||||
dtl.put("real_qty", ivt2.getDoubleValue("change_qty"));
|
|
||||||
dtl.put("is_overdue", ivt2.getString("is_overdue"));
|
|
||||||
dtl.put("instorage_time", ivt2.getString("instorage_time"));
|
|
||||||
|
|
||||||
// 如果所属仓位是虚拟区 则将分配明细状态变为生成
|
|
||||||
JSONObject jsonSect = wo_sect.query("sect_id = '" + ivt2.getString("sect_id") + "'").uniqueResult(0);
|
|
||||||
if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) {
|
|
||||||
dtl.put("work_status", "01");
|
|
||||||
} else {
|
|
||||||
dtl.put("work_status", "00");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jo_mst.getString("is_overdue").equals("1")) {
|
|
||||||
// 判断是否超期
|
|
||||||
if (ivt2.getString("is_overdue").equals("1")) {
|
|
||||||
dtl.put("work_status", "01");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wo_dis.insert(dtl);
|
|
||||||
}
|
|
||||||
//记录需锁定的仓位
|
|
||||||
Struct_map.put(ivt.getString("struct_id"), ivt);
|
|
||||||
// 为零结束
|
|
||||||
if (unassign_qty == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// 确定子卷: 根据子卷找到库存出掉
|
|
||||||
jsonMap.put("flag", "1");
|
jsonMap.put("flag", "1");
|
||||||
jsonMap.put("material_id", dtl.getString("material_id"));
|
jsonMap.put("material_id", dtl.getString("material_id"));
|
||||||
jsonMap.put("pcsn", dtl.getString("pcsn"));
|
jsonMap.put("sale_order_name", dtl.getString("source_bill_code"));
|
||||||
jsonMap.put("box_no", dtl.getString("box_no"));
|
|
||||||
jsonMap.put("sect_id", whereJson.getString("sect_id"));
|
jsonMap.put("sect_id", whereJson.getString("sect_id"));
|
||||||
jsonMap.put("stor_id", whereJson.getString("stor_id"));
|
jsonMap.put("stor_id", whereJson.getString("stor_id"));
|
||||||
|
|
||||||
JSONObject jsonIvt = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().uniqueResult(0);
|
JSONObject jsonOneIvt = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().uniqueResult(0);
|
||||||
if (ObjectUtil.isEmpty(jsonIvt)) {
|
if (ObjectUtil.isEmpty(jsonOneIvt)) {
|
||||||
throw new BadRequestException("库存不足");
|
throw new BadRequestException("库存不足");
|
||||||
}
|
}
|
||||||
|
|
||||||
double canuse_qty ;
|
// 查询这一巷道所有此物料此库存此销售订单的库存
|
||||||
if (StrUtil.equals(bill_type, "1011")) {
|
jsonMap.put("flag", "2");
|
||||||
canuse_qty = dtl.getDoubleValue("plan_qty");
|
jsonMap.put("row_num", jsonOneIvt.getString("row_num"));
|
||||||
} else {
|
jsonMap.put("block_num", jsonOneIvt.getString("block_num"));
|
||||||
canuse_qty = jsonIvt.getDoubleValue("canuse_qty");
|
JSONArray ivtAllArr = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0);
|
||||||
}
|
|
||||||
|
|
||||||
jsonIvt.put("change_qty", canuse_qty + "");
|
for (int j = 0; j < ivtAllArr.size(); j++) {
|
||||||
unassign_qty = 0;
|
JSONObject ivt = ivtAllArr.getJSONObject(j);
|
||||||
assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
double canuse_qty = ivt.getDoubleValue("canuse_qty");
|
||||||
|
assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
||||||
|
|
||||||
//更新库存
|
if (unassign_qty >= canuse_qty) {
|
||||||
jsonIvt.put("bill_type_scode", jo_mst.getString("bill_type"));
|
unassign_qty = NumberUtil.sub(unassign_qty, canuse_qty);
|
||||||
jsonIvt.put("inv_id", dtl.getString("iostorinv_id"));
|
} else {
|
||||||
jsonIvt.put("bill_code", jo_mst.getString("bill_code"));
|
unassign_qty = 0;
|
||||||
jsonIvt.put("bill_table", "ST_IVT_IOStorInv");
|
}
|
||||||
storPublicService.IOStor(jsonIvt, "11");
|
|
||||||
//生成分配明细
|
|
||||||
dtl.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId());
|
|
||||||
dtl.put("sect_id", jsonIvt.getString("sect_id"));
|
|
||||||
dtl.put("sect_code", jsonIvt.getString("sect_code"));
|
|
||||||
dtl.put("sect_name", jsonIvt.getString("sect_name"));
|
|
||||||
dtl.put("struct_id", jsonIvt.getString("struct_id"));
|
|
||||||
dtl.put("struct_code", jsonIvt.getString("struct_code"));
|
|
||||||
dtl.put("struct_name", jsonIvt.getString("struct_name"));
|
|
||||||
dtl.put("pcsn", jsonIvt.getString("pcsn"));
|
|
||||||
dtl.put("box_no", jsonIvt.getString("storagevehicle_code"));
|
|
||||||
dtl.put("storagevehicle_id", jsonIvt.getString("storagevehicle_id"));
|
|
||||||
dtl.put("storagevehicle_code", jsonIvt.getString("storagevehicle_code"));
|
|
||||||
dtl.put("storagevehicle_type", jsonIvt.getString("storagevehicle_type"));
|
|
||||||
dtl.put("is_issued", "0");
|
|
||||||
dtl.put("plan_qty", jsonIvt.getDoubleValue("change_qty"));
|
|
||||||
dtl.put("real_qty", jsonIvt.getDoubleValue("change_qty"));
|
|
||||||
dtl.put("is_overdue", jsonIvt.getString("is_overdue"));
|
|
||||||
dtl.put("instorage_time", jsonIvt.getString("instorage_time"));
|
|
||||||
// 如果所属仓位是虚拟区 则将分配明细状态变为生成
|
|
||||||
JSONObject jsonSect = wo_sect.query("sect_id = '" + jsonIvt.getString("sect_id") + "'").uniqueResult(0);
|
|
||||||
if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) {
|
|
||||||
dtl.put("work_status", "01");
|
|
||||||
} else {
|
|
||||||
dtl.put("work_status", "00");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断是否超期
|
// 查询此木箱下的所有子卷
|
||||||
if (jo_mst.getString("is_overdue").equals("1")) {
|
jsonMap.put("flag", "3");
|
||||||
if (jsonIvt.getString("is_overdue").equals("1")) {
|
jsonMap.put("storagevehicle_code", ivt.getString("storagevehicle_code"));
|
||||||
dtl.put("work_status", "01");
|
JSONArray ivtAllArr2 = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0);
|
||||||
|
|
||||||
|
for (int k = 0; k < ivtAllArr2.size(); k++) {
|
||||||
|
// 更新库存
|
||||||
|
JSONObject ivt2 = ivtAllArr2.getJSONObject(k);
|
||||||
|
ivt2.put("change_qty", ivt2.getDoubleValue("canuse_qty"));
|
||||||
|
ivt2.put("bill_type_scode", jo_mst.getString("bill_type"));
|
||||||
|
ivt2.put("inv_id", dtl.getString("iostorinv_id"));
|
||||||
|
ivt2.put("bill_code", jo_mst.getString("bill_code"));
|
||||||
|
ivt2.put("bill_table", "ST_IVT_IOStorInv");
|
||||||
|
storPublicService.IOStor(ivt2, "11");
|
||||||
|
|
||||||
|
//生成分配明细
|
||||||
|
dtl.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||||
|
dtl.put("sect_id", ivt2.getString("sect_id"));
|
||||||
|
dtl.put("sect_code", ivt2.getString("sect_code"));
|
||||||
|
dtl.put("sect_name", ivt2.getString("sect_name"));
|
||||||
|
dtl.put("struct_id", ivt2.getString("struct_id"));
|
||||||
|
dtl.put("struct_code", ivt2.getString("struct_code"));
|
||||||
|
dtl.put("struct_name", ivt2.getString("struct_name"));
|
||||||
|
dtl.put("pcsn", ivt2.getString("pcsn"));
|
||||||
|
dtl.put("box_no", ivt2.getString("storagevehicle_code"));
|
||||||
|
dtl.put("storagevehicle_id", ivt2.getString("storagevehicle_id"));
|
||||||
|
dtl.put("storagevehicle_code", ivt2.getString("storagevehicle_code"));
|
||||||
|
dtl.put("storagevehicle_type", ivt2.getString("storagevehicle_type"));
|
||||||
|
dtl.put("is_issued", "0");
|
||||||
|
dtl.put("plan_qty", ivt2.getDoubleValue("change_qty"));
|
||||||
|
dtl.put("real_qty", ivt2.getDoubleValue("change_qty"));
|
||||||
|
dtl.put("is_overdue", ivt2.getString("is_overdue"));
|
||||||
|
dtl.put("instorage_time", ivt2.getString("instorage_time"));
|
||||||
|
|
||||||
|
// 如果所属仓位是虚拟区 则将分配明细状态变为生成
|
||||||
|
JSONObject jsonSect = wo_sect.query("sect_id = '" + ivt2.getString("sect_id") + "'").uniqueResult(0);
|
||||||
|
if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) {
|
||||||
|
dtl.put("work_status", "01");
|
||||||
|
} else {
|
||||||
|
dtl.put("work_status", "00");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jo_mst.getString("is_overdue").equals("1")) {
|
||||||
|
// 判断是否超期
|
||||||
|
if (ivt2.getString("is_overdue").equals("1")) {
|
||||||
|
dtl.put("work_status", "01");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wo_dis.insert(dtl);
|
||||||
|
}
|
||||||
|
//记录需锁定的仓位
|
||||||
|
Struct_map.put(ivt.getString("struct_id"), ivt);
|
||||||
|
// 为零结束
|
||||||
|
if (unassign_qty == 0) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wo_dis.insert(dtl);
|
|
||||||
|
|
||||||
//记录需锁定的仓位 (如果此明细有相同物料的且子卷号不能为空的则在最后一个明细分配完成后锁定仓位)
|
|
||||||
JSONObject map = new JSONObject();
|
|
||||||
map.put("flag", "5");
|
|
||||||
map.put("material_id", dtl.getString("material_id"));
|
|
||||||
map.put("box_no", dtl.getString("box_no"));
|
|
||||||
map.put("iostorinv_id", iostorinv_id);
|
|
||||||
map.put("iostorinvdtl_id", dtl.getString("iostorinvdtl_id"));
|
|
||||||
JSONArray dtlArr = WQL.getWO("ST_OUTIVT01").addParamMap(map).process().getResultJSONArray(0);
|
|
||||||
if (dtlArr.size() == 0) {
|
|
||||||
Struct_map.put(jsonIvt.getString("struct_id"), jsonIvt);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
HashMap<String, String> map_dtl = new HashMap<String, String>();
|
|
||||||
//更新明细
|
} else {
|
||||||
map_dtl.put("unassign_qty", unassign_qty + "");
|
// 确定子卷: 根据子卷找到库存出掉
|
||||||
map_dtl.put("assign_qty", assign_qty + "");
|
jsonMap.put("flag", "1");
|
||||||
if (unassign_qty == 0) {
|
jsonMap.put("material_id", dtl.getString("material_id"));
|
||||||
map_dtl.put("bill_status", "40");
|
jsonMap.put("pcsn", dtl.getString("pcsn"));
|
||||||
|
jsonMap.put("box_no", dtl.getString("box_no"));
|
||||||
|
jsonMap.put("sect_id", whereJson.getString("sect_id"));
|
||||||
|
jsonMap.put("stor_id", whereJson.getString("stor_id"));
|
||||||
|
|
||||||
|
JSONObject jsonIvt = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().uniqueResult(0);
|
||||||
|
if (ObjectUtil.isEmpty(jsonIvt)) {
|
||||||
|
throw new BadRequestException("库存不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
double canuse_qty ;
|
||||||
|
if (StrUtil.equals(bill_type, "1011")) {
|
||||||
|
canuse_qty = dtl.getDoubleValue("plan_qty");
|
||||||
} else {
|
} else {
|
||||||
map_dtl.put("bill_status", "30");
|
canuse_qty = jsonIvt.getDoubleValue("canuse_qty");
|
||||||
}
|
}
|
||||||
wo_dtl.update(map_dtl, "iostorinvdtl_id='" + dtl.getString("iostorinvdtl_id") + "'");
|
|
||||||
|
|
||||||
//更新主表状态
|
jsonIvt.put("change_qty", canuse_qty + "");
|
||||||
this.updateMststatus(iostorinv_id);
|
unassign_qty = 0;
|
||||||
|
assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
||||||
|
|
||||||
//锁定起点点位、仓位
|
//更新库存
|
||||||
Collection<JSONObject> c = Struct_map.values();
|
jsonIvt.put("bill_type_scode", jo_mst.getString("bill_type"));
|
||||||
Iterator<JSONObject> it = c.iterator();
|
jsonIvt.put("inv_id", dtl.getString("iostorinv_id"));
|
||||||
JSONObject from_start = new JSONObject();
|
jsonIvt.put("bill_code", jo_mst.getString("bill_code"));
|
||||||
from_start.put("lock_type", "3");
|
jsonIvt.put("bill_table", "ST_IVT_IOStorInv");
|
||||||
for (; it.hasNext(); ) {
|
storPublicService.IOStor(jsonIvt, "11");
|
||||||
JSONObject Struct = it.next();
|
//生成分配明细
|
||||||
from_start.put("struct_id", Struct.getString("struct_id"));
|
dtl.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||||
from_start.put("inv_type", jo_mst.getString("bill_type"));
|
dtl.put("sect_id", jsonIvt.getString("sect_id"));
|
||||||
from_start.put("inv_id", jo_mst.getString("iostorinv_id"));
|
dtl.put("sect_code", jsonIvt.getString("sect_code"));
|
||||||
from_start.put("inv_code", jo_mst.getString("bill_code"));
|
dtl.put("sect_name", jsonIvt.getString("sect_name"));
|
||||||
storPublicService.updateStructAndPoint(from_start);
|
dtl.put("struct_id", jsonIvt.getString("struct_id"));
|
||||||
|
dtl.put("struct_code", jsonIvt.getString("struct_code"));
|
||||||
|
dtl.put("struct_name", jsonIvt.getString("struct_name"));
|
||||||
|
dtl.put("pcsn", jsonIvt.getString("pcsn"));
|
||||||
|
dtl.put("box_no", jsonIvt.getString("storagevehicle_code"));
|
||||||
|
dtl.put("storagevehicle_id", jsonIvt.getString("storagevehicle_id"));
|
||||||
|
dtl.put("storagevehicle_code", jsonIvt.getString("storagevehicle_code"));
|
||||||
|
dtl.put("storagevehicle_type", jsonIvt.getString("storagevehicle_type"));
|
||||||
|
dtl.put("is_issued", "0");
|
||||||
|
dtl.put("plan_qty", jsonIvt.getDoubleValue("change_qty"));
|
||||||
|
dtl.put("real_qty", jsonIvt.getDoubleValue("change_qty"));
|
||||||
|
dtl.put("is_overdue", jsonIvt.getString("is_overdue"));
|
||||||
|
dtl.put("instorage_time", jsonIvt.getString("instorage_time"));
|
||||||
|
// 如果所属仓位是虚拟区 则将分配明细状态变为生成
|
||||||
|
JSONObject jsonSect = wo_sect.query("sect_id = '" + jsonIvt.getString("sect_id") + "'").uniqueResult(0);
|
||||||
|
if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) {
|
||||||
|
dtl.put("work_status", "01");
|
||||||
|
} else {
|
||||||
|
dtl.put("work_status", "00");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断是否超期
|
||||||
|
if (jo_mst.getString("is_overdue").equals("1")) {
|
||||||
|
if (jsonIvt.getString("is_overdue").equals("1")) {
|
||||||
|
dtl.put("work_status", "01");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wo_dis.insert(dtl);
|
||||||
|
|
||||||
|
//记录需锁定的仓位 (如果此明细有相同物料的且子卷号不能为空的则在最后一个明细分配完成后锁定仓位)
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("flag", "5");
|
||||||
|
map.put("material_id", dtl.getString("material_id"));
|
||||||
|
map.put("box_no", dtl.getString("box_no"));
|
||||||
|
map.put("iostorinv_id", iostorinv_id);
|
||||||
|
map.put("iostorinvdtl_id", dtl.getString("iostorinvdtl_id"));
|
||||||
|
JSONArray dtlArr = WQL.getWO("ST_OUTIVT01").addParamMap(map).process().getResultJSONArray(0);
|
||||||
|
if (dtlArr.size() == 0) {
|
||||||
|
Struct_map.put(jsonIvt.getString("struct_id"), jsonIvt);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
HashMap<String, String> map_dtl = new HashMap<String, String>();
|
||||||
|
//更新明细
|
||||||
|
map_dtl.put("unassign_qty", unassign_qty + "");
|
||||||
|
map_dtl.put("assign_qty", assign_qty + "");
|
||||||
|
if (unassign_qty == 0) {
|
||||||
|
map_dtl.put("bill_status", "40");
|
||||||
|
} else {
|
||||||
|
map_dtl.put("bill_status", "30");
|
||||||
|
}
|
||||||
|
wo_dtl.update(map_dtl, "iostorinvdtl_id='" + dtl.getString("iostorinvdtl_id") + "'");
|
||||||
|
|
||||||
|
//更新主表状态
|
||||||
|
this.updateMststatus(iostorinv_id);
|
||||||
|
|
||||||
|
//锁定起点点位、仓位
|
||||||
|
Collection<JSONObject> c = Struct_map.values();
|
||||||
|
Iterator<JSONObject> it = c.iterator();
|
||||||
|
JSONObject from_start = new JSONObject();
|
||||||
|
from_start.put("lock_type", "3");
|
||||||
|
for (; it.hasNext(); ) {
|
||||||
|
JSONObject Struct = it.next();
|
||||||
|
from_start.put("struct_id", Struct.getString("struct_id"));
|
||||||
|
from_start.put("inv_type", jo_mst.getString("bill_type"));
|
||||||
|
from_start.put("inv_id", jo_mst.getString("iostorinv_id"));
|
||||||
|
from_start.put("inv_code", jo_mst.getString("bill_code"));
|
||||||
|
storPublicService.updateStructAndPoint(from_start);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw new BadRequestException("其他出库单当前正在分配货位,请等待几秒再进行操作!");
|
|
||||||
}
|
}
|
||||||
} finally {
|
return null;
|
||||||
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
},"all_divOne",whereJson);
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user