|
|
|
|
@@ -738,6 +738,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
is_top3 = true;
|
|
|
|
|
}
|
|
|
|
|
JSONObject jsonMap = new JSONObject();
|
|
|
|
|
// 已分配重量
|
|
|
|
|
double assign_qty = 0;
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dtl.getString("source_bill_code")) || is_top3) {
|
|
|
|
|
while (unassign_qty > 0) {
|
|
|
|
|
@@ -759,6 +761,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
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);
|
|
|
|
|
@@ -829,6 +832,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
double canuse_qty = jsonIvt.getDoubleValue("canuse_qty");
|
|
|
|
|
jsonIvt.put("change_qty", canuse_qty + "");
|
|
|
|
|
unassign_qty = 0;
|
|
|
|
|
assign_qty = NumberUtil.add(assign_qty,canuse_qty);
|
|
|
|
|
|
|
|
|
|
//更新库存
|
|
|
|
|
jsonIvt.put("bill_type_scode", jo_mst.getString("bill_type"));
|
|
|
|
|
@@ -874,7 +878,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
HashMap<String, String> map_dtl = new HashMap<String, String>();
|
|
|
|
|
//更新明细
|
|
|
|
|
map_dtl.put("unassign_qty", unassign_qty + "");
|
|
|
|
|
map_dtl.put("assign_qty", (plan_qty - unassign_qty) + "");
|
|
|
|
|
map_dtl.put("assign_qty", assign_qty + "");
|
|
|
|
|
if (unassign_qty == 0) {
|
|
|
|
|
map_dtl.put("bill_status", "40");
|
|
|
|
|
} else {
|
|
|
|
|
@@ -948,7 +952,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
is_top3 = true;
|
|
|
|
|
}
|
|
|
|
|
JSONObject jsonMap = new JSONObject();
|
|
|
|
|
|
|
|
|
|
// 已分配数量
|
|
|
|
|
double assign_qty = 0;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dtl.getString("source_bill_code")) || is_top3) {
|
|
|
|
|
while (unassign_qty > 0) {
|
|
|
|
|
// 1.有销售订单号
|
|
|
|
|
@@ -969,6 +974,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
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 = unassign_qty - canuse_qty;
|
|
|
|
|
@@ -1037,6 +1043,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
if (ObjectUtil.isEmpty(jsonIvt)) throw new BadRequestException("库存不足");
|
|
|
|
|
|
|
|
|
|
double canuse_qty = jsonIvt.getDoubleValue("canuse_qty");
|
|
|
|
|
assign_qty = NumberUtil.add(assign_qty,canuse_qty);
|
|
|
|
|
jsonIvt.put("change_qty", canuse_qty + "");
|
|
|
|
|
unassign_qty = 0;
|
|
|
|
|
|
|
|
|
|
@@ -1076,7 +1083,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
HashMap<String, String> map_dtl = new HashMap<String, String>();
|
|
|
|
|
//更新明细
|
|
|
|
|
map_dtl.put("unassign_qty", unassign_qty + "");
|
|
|
|
|
map_dtl.put("assign_qty", (plan_qty - unassign_qty) + "");
|
|
|
|
|
map_dtl.put("assign_qty", assign_qty + "");
|
|
|
|
|
if (unassign_qty == 0) {
|
|
|
|
|
map_dtl.put("bill_status", "40");
|
|
|
|
|
} else {
|
|
|
|
|
@@ -1215,8 +1222,115 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
//更新【出入库单明细表】中分配记录
|
|
|
|
|
JSONObject jo_dtl = wo_dtl.query("iostorinvdtl_id = '" + iostorinvdtl_id + "'").uniqueResult(0);
|
|
|
|
|
|
|
|
|
|
jo_dtl.put("assign_qty", jo_dtl.getDoubleValue("assign_qty") - plan_qty);
|
|
|
|
|
jo_dtl.put("unassign_qty", jo_dtl.getDoubleValue("unassign_qty") + plan_qty);
|
|
|
|
|
|
|
|
|
|
jo_dtl.put("assign_qty", NumberUtil.sub(jo_dtl.getDoubleValue("assign_qty") ,plan_qty));
|
|
|
|
|
jo_dtl.put("unassign_qty", NumberUtil.sub(jo_dtl.getDoubleValue("plan_qty"),jo_dtl.getDoubleValue("assign_qty")));
|
|
|
|
|
|
|
|
|
|
if (jo_dtl.getDoubleValue("assign_qty") < 0) {
|
|
|
|
|
jo_dtl.put("assign_qty", 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (jo_dtl.getDoubleValue("unassign_qty") > jo_dtl.getDoubleValue("plan_qty")) {
|
|
|
|
|
jo_dtl.put("unassign_qty", jo_dtl.getDoubleValue("plan_qty"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (jo_dtl.getDoubleValue("unassign_qty") == jo_dtl.getDoubleValue("plan_qty")) {
|
|
|
|
|
jo_dtl.put("bill_status", "10");
|
|
|
|
|
} else {
|
|
|
|
|
jo_dtl.put("bill_status", "30");
|
|
|
|
|
}
|
|
|
|
|
wo_dtl.update(jo_dtl);
|
|
|
|
|
//更新主表状态
|
|
|
|
|
this.updateMststatus(iostorinv_id);
|
|
|
|
|
//判断是否存在同单据的同起点仓位的分配
|
|
|
|
|
JSONArray flag = WQL.getWO("QST_IVT_CHECKOUTBILL")
|
|
|
|
|
.addParam("flag", "5")
|
|
|
|
|
.addParam("is_issued", "0")
|
|
|
|
|
.addParam("struct_id", dis.getString("struct_id"))
|
|
|
|
|
.addParam("iostorinv_id", iostorinv_id)
|
|
|
|
|
.addParam("bill_status", "01")
|
|
|
|
|
.process()
|
|
|
|
|
.getResultJSONArray(0);
|
|
|
|
|
if (flag.size() == 0) {//仓位载具冻结数为0
|
|
|
|
|
//任务号不为空
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dis.getString("task_id"))) {
|
|
|
|
|
//更新对应任务为删除
|
|
|
|
|
map.put("is_delete", "1");
|
|
|
|
|
wo_Task.update(map, "task_id='" + dis.getString("task_id") + "'");
|
|
|
|
|
}
|
|
|
|
|
//解锁起点仓位点位
|
|
|
|
|
JSONObject from_start = new JSONObject();
|
|
|
|
|
from_start.put("struct_id", dis.getString("struct_id"));
|
|
|
|
|
from_start.put("lock_type", "1");
|
|
|
|
|
storPublicService.updateStructAndPoint2(from_start);
|
|
|
|
|
//解锁终点仓位点位
|
|
|
|
|
if (StrUtil.isNotEmpty(dis.getString("point_code"))) {
|
|
|
|
|
JSONObject from_end = new JSONObject();
|
|
|
|
|
from_end.put("point_code", dis.getString("point_code"));
|
|
|
|
|
from_end.put("lock_type", "1");
|
|
|
|
|
storPublicService.updateStructAndPoint2(from_end);
|
|
|
|
|
}
|
|
|
|
|
} else {//仓位载具扔有冻结数,需改任务类型为拣选出库
|
|
|
|
|
//任务号不为空
|
|
|
|
|
/* if (ObjectUtil.isNotEmpty(dis.getString("task_id"))) {
|
|
|
|
|
//更新对应任务为拣选出库
|
|
|
|
|
map.put("taskdtl_type", "05");
|
|
|
|
|
wo_Task.update(map, "task_id='" + dis.getString("task_id") + "'");
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void oneCancel(JSONObject whereJson) {
|
|
|
|
|
//出库分配表
|
|
|
|
|
WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
|
|
|
|
//出库明细表
|
|
|
|
|
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
|
|
|
|
|
//出库主表
|
|
|
|
|
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
|
|
|
|
//任务表
|
|
|
|
|
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
|
|
|
|
|
|
|
|
String iostorinv_id = whereJson.getString("iostorinv_id");
|
|
|
|
|
//查询主表信息
|
|
|
|
|
JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
|
|
|
|
|
// 查询此分配明细下的所有相同箱号的分配明细
|
|
|
|
|
JSONArray diss = wo_dis.query("box_no = '" + whereJson.getString("storagevehicle_code") + "'").getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < diss.size(); i++) {
|
|
|
|
|
JSONObject dis = diss.getJSONObject(i);
|
|
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
String iostorinvdtl_id = dis.getString("iostorinvdtl_id");
|
|
|
|
|
//统计【出入库单分配表】执行状态大于等于执行中,或【任务指令表】任务状态大于等于下发时的记录和
|
|
|
|
|
JSONArray dtl = WQL.getWO("QST_IVT_CHECKOUTBILL")
|
|
|
|
|
.addParam("flag", "4")
|
|
|
|
|
.addParam("iostorinvdtl_id", iostorinvdtl_id)
|
|
|
|
|
.process()
|
|
|
|
|
.getResultJSONArray(0);
|
|
|
|
|
//若存在记录,则不可取消该出库明细对应的任何分配记录
|
|
|
|
|
if (dtl.size() != 0) {
|
|
|
|
|
throw new BadRequestException("存在出库明细对应任务执行中或完成!");
|
|
|
|
|
}
|
|
|
|
|
double plan_qty = dis.getDoubleValue("plan_qty");
|
|
|
|
|
//更新库存
|
|
|
|
|
dis.put("change_qty", plan_qty + "");
|
|
|
|
|
dis.put("bill_type_scode", jo_mst.getString("bill_type"));
|
|
|
|
|
dis.put("inv_id", iostorinv_id);
|
|
|
|
|
dis.put("bill_code", jo_mst.getString("bill_code"));
|
|
|
|
|
dis.put("bill_table", "ST_IVT_IOStorInv");
|
|
|
|
|
storPublicService.IOStor(dis, "12");
|
|
|
|
|
//删除【出入库单分配表】中分配记录
|
|
|
|
|
wo_dis.delete("iostorinvdis_id='" + dis.getString("iostorinvdis_id") + "'");
|
|
|
|
|
//更新【出入库单明细表】中分配记录
|
|
|
|
|
JSONObject jo_dtl = wo_dtl.query("iostorinvdtl_id = '" + iostorinvdtl_id + "'").uniqueResult(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jo_dtl.put("assign_qty", NumberUtil.sub(jo_dtl.getDoubleValue("assign_qty") ,plan_qty));
|
|
|
|
|
jo_dtl.put("unassign_qty", NumberUtil.sub(jo_dtl.getDoubleValue("plan_qty"),jo_dtl.getDoubleValue("assign_qty")));
|
|
|
|
|
|
|
|
|
|
if (jo_dtl.getDoubleValue("assign_qty") < 0) {
|
|
|
|
|
jo_dtl.put("assign_qty", 0);
|
|
|
|
|
@@ -1690,6 +1804,10 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
throw new BadRequestException("当前订单无可分配出库明细");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断此明细是否有相同仓位的明细:如果没有则将此仓位下的所有库存出出来
|
|
|
|
|
JSONArray jsonDtl = wo_dtl.query("iostorinv_id = '"+iostorinv_id+"' and material_id = '"+dtl.getString("material_id")+"' and source_bill_code = '"+dtl.getString("source_bill_code")+"'").getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
double assign_qty = dtl.getDoubleValue("assign_qty");
|
|
|
|
|
double unassign_qty = dtl.getDoubleValue("unassign_qty");
|
|
|
|
|
double plan_qty = dtl.getDoubleValue("plan_qty");
|
|
|
|
|
|
|
|
|
|
@@ -1698,6 +1816,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
JSONObject ivt = rows.getJSONObject(j);
|
|
|
|
|
|
|
|
|
|
double canuse_qty = ivt.getDoubleValue("ivt_qty");
|
|
|
|
|
assign_qty = NumberUtil.add(assign_qty,canuse_qty);
|
|
|
|
|
|
|
|
|
|
if (unassign_qty >= canuse_qty) {
|
|
|
|
|
unassign_qty = unassign_qty - canuse_qty;
|
|
|
|
|
ivt.put("change_qty", canuse_qty + "");
|
|
|
|
|
@@ -1743,7 +1863,194 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
HashMap<String, String> map_dtl = new HashMap<String, String>();
|
|
|
|
|
//更新明细
|
|
|
|
|
map_dtl.put("unassign_qty", unassign_qty + "");
|
|
|
|
|
map_dtl.put("assign_qty", (plan_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") + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断是否还有相同物料相同仓位的明细
|
|
|
|
|
JSONObject jsonMap = new JSONObject();
|
|
|
|
|
jsonMap.put("flag", "4");
|
|
|
|
|
jsonMap.put("material_id", dtl.getString("material_id"));
|
|
|
|
|
jsonMap.put("iostorinv_id", iostorinv_id);
|
|
|
|
|
jsonMap.put("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id"));
|
|
|
|
|
|
|
|
|
|
JSONArray dtlArr = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0);
|
|
|
|
|
for (int i = 0; i < dtlArr.size(); i++) {
|
|
|
|
|
JSONObject json = dtlArr.getJSONObject(i);
|
|
|
|
|
|
|
|
|
|
JSONObject ivt = WQL.getWO("ST_OUTIVT01")
|
|
|
|
|
.addParam("flag", "1")
|
|
|
|
|
.addParam("material_id", json.getString("material_id"))
|
|
|
|
|
.addParam("pcsn", json.getString("pcsn"))
|
|
|
|
|
.process().uniqueResult(0);
|
|
|
|
|
|
|
|
|
|
//更新库存
|
|
|
|
|
ivt.put("change_qty", ivt.getDoubleValue("canuse_qty"));
|
|
|
|
|
ivt.put("bill_type_scode", jo_mst.getString("bill_type"));
|
|
|
|
|
ivt.put("inv_id", json.getString("iostorinv_id"));
|
|
|
|
|
ivt.put("bill_code", jo_mst.getString("bill_code"));
|
|
|
|
|
ivt.put("bill_table", "ST_IVT_IOStorInv");
|
|
|
|
|
storPublicService.IOStor(ivt, "11");
|
|
|
|
|
//生成分配明细
|
|
|
|
|
json.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId());
|
|
|
|
|
json.put("sect_id", ivt.getString("sect_id"));
|
|
|
|
|
json.put("sect_code", ivt.getString("sect_code"));
|
|
|
|
|
json.put("sect_name", ivt.getString("sect_name"));
|
|
|
|
|
json.put("struct_id", ivt.getString("struct_id"));
|
|
|
|
|
json.put("struct_code", ivt.getString("struct_code"));
|
|
|
|
|
json.put("struct_name", ivt.getString("struct_name"));
|
|
|
|
|
json.put("pcsn", ivt.getString("pcsn"));
|
|
|
|
|
json.put("box_no", ivt.getString("storagevehicle_code"));
|
|
|
|
|
json.put("storagevehicle_id", ivt.getString("storagevehicle_id"));
|
|
|
|
|
json.put("storagevehicle_code", ivt.getString("storagevehicle_code"));
|
|
|
|
|
json.put("storagevehicle_type", ivt.getString("storagevehicle_type"));
|
|
|
|
|
json.put("is_issued", "0");
|
|
|
|
|
json.put("plan_qty", ivt.getDoubleValue("change_qty"));
|
|
|
|
|
json.put("real_qty", ivt.getDoubleValue("change_qty"));
|
|
|
|
|
// 如果所属仓位是虚拟区 则将分配明细状态变为生成
|
|
|
|
|
if (StrUtil.equals(ivt.getString("sect_code"), "XN01")) {
|
|
|
|
|
json.put("work_status", "01");
|
|
|
|
|
} else {
|
|
|
|
|
json.put("work_status", "00");
|
|
|
|
|
}
|
|
|
|
|
wo_dis.insert(json);
|
|
|
|
|
|
|
|
|
|
// 更新明细
|
|
|
|
|
HashMap<String, String> map_dtl = new HashMap<String, String>();
|
|
|
|
|
map_dtl.put("unassign_qty", "0");
|
|
|
|
|
map_dtl.put("assign_qty", ivt.getString("change_qty"));
|
|
|
|
|
map_dtl.put("bill_status", "40");
|
|
|
|
|
wo_dtl.update(map_dtl, "iostorinvdtl_id='" + json.getString("iostorinvdtl_id") + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新主表状态
|
|
|
|
|
this.updateMststatus(iostorinv_id);
|
|
|
|
|
//锁定点位、仓位
|
|
|
|
|
Collection<JSONObject> c = Struct_map.values();
|
|
|
|
|
Iterator<JSONObject> it = c.iterator();
|
|
|
|
|
for (; it.hasNext(); ) {
|
|
|
|
|
JSONObject Struct = it.next();
|
|
|
|
|
//锁定起点仓位点位
|
|
|
|
|
JSONObject from_start = new JSONObject();
|
|
|
|
|
from_start.put("struct_id", Struct.getString("struct_id"));
|
|
|
|
|
from_start.put("lock_type", "2");
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void manualDiv2(JSONObject form) {
|
|
|
|
|
//出库分配表
|
|
|
|
|
WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
|
|
|
|
//出库明细表
|
|
|
|
|
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
|
|
|
|
|
//出库主表
|
|
|
|
|
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
|
|
|
|
|
|
|
|
|
//定义需要更新的仓位集合
|
|
|
|
|
HashMap<String, JSONObject> Struct_map = new HashMap<>();
|
|
|
|
|
JSONObject whereJson = form.getJSONObject("row");
|
|
|
|
|
JSONArray rows = form.getJSONArray("rows");
|
|
|
|
|
String iostorinv_id = whereJson.getString("iostorinv_id");
|
|
|
|
|
//查询主表信息
|
|
|
|
|
JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(jo_mst)) {
|
|
|
|
|
throw new BadRequestException("当前订单无可分配出库明细");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询生成和未分配完的明细
|
|
|
|
|
JSONObject dtl = 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()
|
|
|
|
|
.uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(dtl)) {
|
|
|
|
|
throw new BadRequestException("当前订单无可分配出库明细");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rows = WQL.getWO("QST_IVT_CHECKOUTBILL")
|
|
|
|
|
.addParam("flag", "3")
|
|
|
|
|
.addParam("box_no", dtl.get("box_no"))
|
|
|
|
|
.process()
|
|
|
|
|
.getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
double assign_qty = dtl.getDoubleValue("assign_qty");
|
|
|
|
|
double unassign_qty = dtl.getDoubleValue("unassign_qty");
|
|
|
|
|
double plan_qty = dtl.getDoubleValue("plan_qty");
|
|
|
|
|
|
|
|
|
|
// 判断此明细是否有相同仓位的明细:如果没有则将此仓位下的所有库存出出来
|
|
|
|
|
JSONArray jsonDtl = wo_dtl.query("box_no = '" + dtl.getString("box_no") + "'").getResultJSONArray(0);
|
|
|
|
|
if (jsonDtl.size() == 1) {
|
|
|
|
|
rows = WQL.getWO("QST_IVT_CHECKOUTBILL")
|
|
|
|
|
.addParam("flag", "3")
|
|
|
|
|
.addParam("box_no", dtl.get("source_bill_code"))
|
|
|
|
|
.process()
|
|
|
|
|
.getResultJSONArray(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rows.size() != 0) {
|
|
|
|
|
for (int j = 0; j < rows.size(); j++) {
|
|
|
|
|
JSONObject ivt = rows.getJSONObject(j);
|
|
|
|
|
|
|
|
|
|
double canuse_qty = ivt.getDoubleValue("ivt_qty");
|
|
|
|
|
assign_qty = NumberUtil.add(assign_qty,canuse_qty);
|
|
|
|
|
|
|
|
|
|
if (unassign_qty >= canuse_qty) {
|
|
|
|
|
unassign_qty = unassign_qty - canuse_qty;
|
|
|
|
|
ivt.put("change_qty", canuse_qty + "");
|
|
|
|
|
} else {
|
|
|
|
|
ivt.put("change_qty", canuse_qty + "");
|
|
|
|
|
unassign_qty = 0;
|
|
|
|
|
}
|
|
|
|
|
//更新库存
|
|
|
|
|
ivt.put("bill_type_scode", jo_mst.getString("bill_type"));
|
|
|
|
|
ivt.put("inv_id", dtl.getString("iostorinv_id"));
|
|
|
|
|
ivt.put("bill_code", jo_mst.getString("bill_code"));
|
|
|
|
|
ivt.put("bill_table", "ST_IVT_IOStorInv");
|
|
|
|
|
storPublicService.IOStor(ivt, "11");
|
|
|
|
|
//生成分配明细
|
|
|
|
|
dtl.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId());
|
|
|
|
|
dtl.put("sect_id", ivt.getString("sect_id"));
|
|
|
|
|
dtl.put("sect_code", ivt.getString("sect_code"));
|
|
|
|
|
dtl.put("sect_name", ivt.getString("sect_name"));
|
|
|
|
|
dtl.put("struct_id", ivt.getString("struct_id"));
|
|
|
|
|
dtl.put("struct_code", ivt.getString("struct_code"));
|
|
|
|
|
dtl.put("struct_name", ivt.getString("struct_name"));
|
|
|
|
|
dtl.put("pcsn", ivt.getString("pcsn"));
|
|
|
|
|
dtl.put("box_no", ivt.getString("storagevehicle_code"));
|
|
|
|
|
dtl.put("storagevehicle_id", ivt.getString("storagevehicle_id"));
|
|
|
|
|
dtl.put("storagevehicle_code", ivt.getString("storagevehicle_code"));
|
|
|
|
|
dtl.put("storagevehicle_type", ivt.getString("storagevehicle_type"));
|
|
|
|
|
dtl.put("is_issued", "0");
|
|
|
|
|
dtl.put("plan_qty", ivt.getDoubleValue("change_qty"));
|
|
|
|
|
dtl.put("real_qty", ivt.getDoubleValue("change_qty"));
|
|
|
|
|
// 如果所属仓位是虚拟区 则将分配明细状态变为生成
|
|
|
|
|
if (StrUtil.equals(ivt.getString("sect_code"), "XN01")) {
|
|
|
|
|
dtl.put("work_status", "01");
|
|
|
|
|
} else {
|
|
|
|
|
dtl.put("work_status", "00");
|
|
|
|
|
}
|
|
|
|
|
wo_dis.insert(dtl);
|
|
|
|
|
//记录需锁定的仓位
|
|
|
|
|
Struct_map.put(ivt.getString("struct_id"), ivt);
|
|
|
|
|
if (unassign_qty == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
|
|