|
|
|
|
@@ -104,7 +104,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
UserStorServiceImpl userStorService = new UserStorServiceImpl();
|
|
|
|
|
String in_stor_id = userStorService.getInStor();
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(in_stor_id)) map.put("in_stor_id",in_stor_id);
|
|
|
|
|
if (ObjectUtil.isNotEmpty(in_stor_id)) map.put("in_stor_id", in_stor_id);
|
|
|
|
|
|
|
|
|
|
JSONObject jo = WQL.getWO("QST_IVT_CHECKOUTBILL").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "bill_code desc");
|
|
|
|
|
return jo;
|
|
|
|
|
@@ -299,7 +299,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
map.put("update_time", now);
|
|
|
|
|
map.put("is_delete", "0");
|
|
|
|
|
map.put("is_upload", "0");
|
|
|
|
|
map.put("out_stor_id",map.getString("out_stor_id"));
|
|
|
|
|
map.put("out_stor_id", map.getString("out_stor_id"));
|
|
|
|
|
if (ObjectUtil.isNotEmpty(user)) {
|
|
|
|
|
if (!user.equals("mes") || user.equals("sap")) {
|
|
|
|
|
Long deptId = SecurityUtils.getDeptId();
|
|
|
|
|
@@ -586,10 +586,10 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
if (ObjectUtil.isEmpty(task_status)) {
|
|
|
|
|
String work_status = json.getString("work_status");
|
|
|
|
|
if (StrUtil.equals(work_status, "01")) {
|
|
|
|
|
json.put("task_status","01");
|
|
|
|
|
json.put("task_status", "01");
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.equals(work_status, "99")) {
|
|
|
|
|
json.put("task_status","07");
|
|
|
|
|
json.put("task_status", "07");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -608,12 +608,12 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
paramMap.put("task_id", "");
|
|
|
|
|
paramMap.put("work_status", "00");
|
|
|
|
|
paramMap.put("point_id", "");
|
|
|
|
|
disTab.update(paramMap,"task_id = '"+task_id+"'");
|
|
|
|
|
disTab.update(paramMap, "task_id = '" + task_id + "'");
|
|
|
|
|
|
|
|
|
|
// 删除此任务
|
|
|
|
|
JSONObject paramMap2 = new JSONObject();
|
|
|
|
|
paramMap2.put("is_delete","1" );
|
|
|
|
|
taskTab.update(paramMap2,"task_id = '"+task_id+"'");
|
|
|
|
|
paramMap2.put("is_delete", "1");
|
|
|
|
|
taskTab.update(paramMap2, "task_id = '" + task_id + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -809,10 +809,10 @@ 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);
|
|
|
|
|
assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
|
|
|
|
|
|
|
|
|
if (unassign_qty >= canuse_qty) {
|
|
|
|
|
unassign_qty = NumberUtil.sub(unassign_qty,canuse_qty);
|
|
|
|
|
unassign_qty = NumberUtil.sub(unassign_qty, canuse_qty);
|
|
|
|
|
// ivt.put("change_qty", canuse_qty + "");
|
|
|
|
|
} else {
|
|
|
|
|
// ivt.put("change_qty", unassign_qty + "");
|
|
|
|
|
@@ -883,7 +883,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);
|
|
|
|
|
assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
|
|
|
|
|
|
|
|
|
//更新库存
|
|
|
|
|
jsonIvt.put("bill_type_scode", jo_mst.getString("bill_type"));
|
|
|
|
|
@@ -1029,7 +1029,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);
|
|
|
|
|
assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
|
|
|
|
|
|
|
|
|
if (unassign_qty >= canuse_qty) {
|
|
|
|
|
unassign_qty = unassign_qty - canuse_qty;
|
|
|
|
|
@@ -1101,7 +1101,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);
|
|
|
|
|
assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
|
|
|
|
jsonIvt.put("change_qty", canuse_qty + "");
|
|
|
|
|
unassign_qty = 0;
|
|
|
|
|
|
|
|
|
|
@@ -1282,8 +1282,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
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")));
|
|
|
|
|
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);
|
|
|
|
|
@@ -1357,7 +1357,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
//查询主表信息
|
|
|
|
|
JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
|
|
|
|
|
// 查询此分配明细下的所有相同箱号的分配明细
|
|
|
|
|
JSONArray diss = wo_dis.query("box_no = '" + whereJson.getString("storagevehicle_code") + "' and iostorinv_id = '"+iostorinv_id+"'").getResultJSONArray(0);
|
|
|
|
|
JSONArray diss = wo_dis.query("box_no = '" + whereJson.getString("storagevehicle_code") + "' and iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < diss.size(); i++) {
|
|
|
|
|
JSONObject dis = diss.getJSONObject(i);
|
|
|
|
|
@@ -1388,8 +1388,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
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")));
|
|
|
|
|
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);
|
|
|
|
|
@@ -1949,7 +1949,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(json)) {
|
|
|
|
|
jsonAttr.put("placement_type","02");
|
|
|
|
|
}*/
|
|
|
|
|
jsonAttr.put("placement_type","02");
|
|
|
|
|
jsonAttr.put("placement_type", "02");
|
|
|
|
|
} else {
|
|
|
|
|
// 调用验证方法进行校验
|
|
|
|
|
String out_order_seq = NumberUtil.add(jsonIsBlockL.getString("out_order_seq"), "1").toString();
|
|
|
|
|
@@ -1967,14 +1967,14 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
boolean left_verify2 = this.is_trueOrFalse(jsonParam);
|
|
|
|
|
|
|
|
|
|
if (left_verify2) {
|
|
|
|
|
jsonAttr.put("placement_type","02");
|
|
|
|
|
jsonAttr.put("placement_type", "02");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
jsonParam.put("option", "4");
|
|
|
|
|
boolean left_verify2 = this.is_trueOrFalse(jsonParam);
|
|
|
|
|
|
|
|
|
|
if (left_verify2) {
|
|
|
|
|
jsonAttr.put("placement_type","02");
|
|
|
|
|
jsonAttr.put("placement_type", "02");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1993,7 +1993,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(json)) {
|
|
|
|
|
jsonAttr.put("placement_type","03");
|
|
|
|
|
}*/
|
|
|
|
|
jsonAttr.put("placement_type","03");
|
|
|
|
|
jsonAttr.put("placement_type", "03");
|
|
|
|
|
} else {
|
|
|
|
|
// 调用验证方法进行校验
|
|
|
|
|
String out_order_seq = NumberUtil.sub(jsonIsBlockR.getString("out_order_seq"), "1").toString();
|
|
|
|
|
@@ -2011,14 +2011,14 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
boolean right_verify2 = this.is_trueOrFalse(jsonParam);
|
|
|
|
|
|
|
|
|
|
if (right_verify2) {
|
|
|
|
|
jsonAttr.put("placement_type","03");
|
|
|
|
|
jsonAttr.put("placement_type", "03");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
jsonParam.put("option", "4");
|
|
|
|
|
boolean right_verify2 = this.is_trueOrFalse(jsonParam);
|
|
|
|
|
|
|
|
|
|
if (right_verify2) {
|
|
|
|
|
jsonAttr.put("placement_type","03");
|
|
|
|
|
jsonAttr.put("placement_type", "03");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -2138,7 +2138,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (StrUtil.equals(jsonAttr.getString("placement_type"),"01")) {
|
|
|
|
|
if (StrUtil.equals(jsonAttr.getString("placement_type"), "01")) {
|
|
|
|
|
throw new BadRequestException("任务生成失败,请重新选择");
|
|
|
|
|
}
|
|
|
|
|
map.put("struct_code", jsonAttr.getString("struct_code"));
|
|
|
|
|
@@ -2450,6 +2450,550 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void allSetPoint(JSONObject whereJson) {
|
|
|
|
|
//出库分配表
|
|
|
|
|
WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
|
|
|
|
//点位表
|
|
|
|
|
WQLObject wo_Point = WQLObject.getWQLObject("SCH_BASE_Point");
|
|
|
|
|
//任务表
|
|
|
|
|
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
|
|
|
//出库主表
|
|
|
|
|
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
|
|
|
|
//仓位表
|
|
|
|
|
WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
|
|
|
|
// 库存表
|
|
|
|
|
WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt");
|
|
|
|
|
|
|
|
|
|
String point_code = whereJson.getString("point_code"); // 终点
|
|
|
|
|
String iostorinv_id = whereJson.getString("iostorinv_id");
|
|
|
|
|
String iostorinvdtl_id = whereJson.getString("iostorinvdtl_id");
|
|
|
|
|
|
|
|
|
|
//查询主表信息
|
|
|
|
|
JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(jo_mst)) {
|
|
|
|
|
throw new BadRequestException("未查到相关出库单");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject jsonPoint2 = wo_Point.query("lock_type='1' and (vehicle_code='' or vehicle_code IS NULL) and point_code='" + point_code + "'").uniqueResult(0);
|
|
|
|
|
//如果终点站点被锁定或者有载具号,则不允许设置点位
|
|
|
|
|
if (ObjectUtil.isEmpty(jsonPoint2)) {
|
|
|
|
|
throw new BadRequestException("该站点被锁定或者有载具号,不允许设置!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询此明细的所有未生成的分配明细(根据片区、排 分组)
|
|
|
|
|
JSONArray allRowArr = WQL.getWO("ST_OUTIVT04")
|
|
|
|
|
.addParam("flag", "1")
|
|
|
|
|
.addParam("iostorinvdtl_id", iostorinvdtl_id)
|
|
|
|
|
.process()
|
|
|
|
|
.getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < allRowArr.size(); i++) {
|
|
|
|
|
// 调用当前排处理方法
|
|
|
|
|
JSONObject jsonRow = allRowArr.getJSONObject(i);
|
|
|
|
|
jsonRow.put("iostorinv_id", iostorinv_id);
|
|
|
|
|
jsonRow.put("point_code", point_code);
|
|
|
|
|
jsonRow.put("iostorinvdtl_id", iostorinvdtl_id);
|
|
|
|
|
jsonRow.put("point_id", jsonPoint2.getString("point_id"));
|
|
|
|
|
this.rowDispose(jsonRow);
|
|
|
|
|
}
|
|
|
|
|
outTask.immediateNotifyAcs(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void rowDispose(JSONObject jsonRow) {
|
|
|
|
|
//出库分配表
|
|
|
|
|
WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
|
|
|
|
//任务表
|
|
|
|
|
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
|
|
|
|
|
|
|
|
String point_code = jsonRow.getString("point_code");
|
|
|
|
|
String iostorinvdtl_id = jsonRow.getString("iostorinvdtl_id");
|
|
|
|
|
String point_id = jsonRow.getString("point_id");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 查询这一排的要出库的所有分配明细(正序)
|
|
|
|
|
*/
|
|
|
|
|
JSONArray disRowArr = WQL.getWO("ST_OUTIVT04")
|
|
|
|
|
.addParam("flag", "2")
|
|
|
|
|
.addParam("iostorinvdtl_id", iostorinvdtl_id)
|
|
|
|
|
.addParam("block_num", jsonRow.getString("block_num"))
|
|
|
|
|
.addParam("row_num", jsonRow.getString("row_num"))
|
|
|
|
|
.process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
JSONArray disRowArrNew = new JSONArray();
|
|
|
|
|
String option = ""; // 1.左 2.右
|
|
|
|
|
String placement_type = jsonRow.getString("placement_type"); // 单通或双通
|
|
|
|
|
// 双通
|
|
|
|
|
if (StrUtil.equals(placement_type, "01")) {
|
|
|
|
|
|
|
|
|
|
// 取右边第一个
|
|
|
|
|
JSONObject jsonDisRight = disRowArr.getJSONObject(0);
|
|
|
|
|
// 取左边第一个
|
|
|
|
|
JSONObject jsonDisLeft = disRowArr.getJSONObject(disRowArr.size() - 1);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 判断左边被挡住的个数多还是右边被挡住的个数多
|
|
|
|
|
*/
|
|
|
|
|
// 判断右边边被挡住的个数
|
|
|
|
|
JSONObject isNumMap = new JSONObject();
|
|
|
|
|
isNumMap.put("flag", "3");
|
|
|
|
|
isNumMap.put("block_num", jsonDisRight.getString("block_num"));
|
|
|
|
|
isNumMap.put("row_num", jsonDisRight.getString("row_num"));
|
|
|
|
|
isNumMap.put("out_order_seq", jsonDisRight.getString("out_order_seq"));
|
|
|
|
|
JSONArray numArrFirst = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
// 调用共用方法计算被挡个数
|
|
|
|
|
JSONArray rightNumArr = this.isNum(numArrFirst);
|
|
|
|
|
|
|
|
|
|
// 判断左边被挡住的个数
|
|
|
|
|
isNumMap.put("flag", "4");
|
|
|
|
|
isNumMap.put("block_num", jsonDisLeft.getString("block_num"));
|
|
|
|
|
isNumMap.put("row_num", jsonDisLeft.getString("row_num"));
|
|
|
|
|
isNumMap.put("out_order_seq", jsonDisLeft.getString("out_order_seq"));
|
|
|
|
|
JSONArray numArrLast = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
// 调用共用方法计算被挡个数
|
|
|
|
|
JSONArray leftNumArr = this.isNum(numArrLast);
|
|
|
|
|
// 判断哪边少
|
|
|
|
|
if (rightNumArr.size() > leftNumArr.size()) {
|
|
|
|
|
/*
|
|
|
|
|
* 左边开始
|
|
|
|
|
*/
|
|
|
|
|
// 查询仓位被锁住的货位
|
|
|
|
|
isNumMap.put("flag", "5");
|
|
|
|
|
isNumMap.put("block_num", jsonDisLeft.getString("block_num"));
|
|
|
|
|
isNumMap.put("row_num", jsonDisLeft.getString("row_num"));
|
|
|
|
|
isNumMap.put("out_order_seq", jsonDisLeft.getString("out_order_seq"));
|
|
|
|
|
JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
JSONArray numArr = this.isNum(isLockArr);
|
|
|
|
|
// 不为空则返回报错
|
|
|
|
|
if (ObjectUtil.isNotEmpty(numArr)) {
|
|
|
|
|
String error = "";
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < numArr.size(); k++) {
|
|
|
|
|
JSONObject json = numArr.getJSONObject(k);
|
|
|
|
|
error += json.getString("struct_code") + ",";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new BadRequestException("仓位:" + error + "被锁定且未下发任务");
|
|
|
|
|
}
|
|
|
|
|
// 重新按照排序查询
|
|
|
|
|
disRowArrNew = WQL.getWO("ST_OUTIVT04")
|
|
|
|
|
.addParam("flag", "22")
|
|
|
|
|
.addParam("iostorinvdtl_id", iostorinvdtl_id)
|
|
|
|
|
.addParam("block_num", jsonRow.getString("block_num"))
|
|
|
|
|
.addParam("row_num", jsonRow.getString("row_num"))
|
|
|
|
|
.process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
option = "1";
|
|
|
|
|
|
|
|
|
|
} else if (rightNumArr.size() < leftNumArr.size()) {
|
|
|
|
|
/*
|
|
|
|
|
* 右边开始
|
|
|
|
|
*/
|
|
|
|
|
// 查询仓位被锁住的货位
|
|
|
|
|
isNumMap.put("flag", "6");
|
|
|
|
|
isNumMap.put("block_num", jsonDisRight.getString("block_num"));
|
|
|
|
|
isNumMap.put("row_num", jsonDisRight.getString("row_num"));
|
|
|
|
|
isNumMap.put("out_order_seq", jsonDisRight.getString("out_order_seq"));
|
|
|
|
|
JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
JSONArray numArr = this.isNum(isLockArr);
|
|
|
|
|
// 不为空则返回报错
|
|
|
|
|
if (ObjectUtil.isNotEmpty(numArr)) {
|
|
|
|
|
String error = "";
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < numArr.size(); k++) {
|
|
|
|
|
JSONObject json = numArr.getJSONObject(k);
|
|
|
|
|
error += json.getString("struct_code") + ",";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new BadRequestException("仓位:" + error + "被锁定且未下发任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重新按照排序查询
|
|
|
|
|
disRowArrNew = WQL.getWO("ST_OUTIVT04")
|
|
|
|
|
.addParam("flag", "2")
|
|
|
|
|
.addParam("iostorinvdtl_id", iostorinvdtl_id)
|
|
|
|
|
.addParam("block_num", jsonRow.getString("block_num"))
|
|
|
|
|
.addParam("row_num", jsonRow.getString("row_num"))
|
|
|
|
|
.process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
option = "2";
|
|
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* 相等默认右边开始
|
|
|
|
|
*/
|
|
|
|
|
// 查询仓位被锁住的货位
|
|
|
|
|
isNumMap.put("flag", "6");
|
|
|
|
|
isNumMap.put("block_num", jsonDisRight.getString("block_num"));
|
|
|
|
|
isNumMap.put("row_num", jsonDisRight.getString("row_num"));
|
|
|
|
|
isNumMap.put("out_order_seq", jsonDisRight.getString("out_order_seq"));
|
|
|
|
|
JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
JSONArray numArr = this.isNum(isLockArr);
|
|
|
|
|
// 不为空则返回报错
|
|
|
|
|
if (ObjectUtil.isNotEmpty(numArr)) {
|
|
|
|
|
String error = "";
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < numArr.size(); k++) {
|
|
|
|
|
JSONObject json = numArr.getJSONObject(k);
|
|
|
|
|
error += json.getString("struct_code") + ",";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new BadRequestException("仓位:" + error + "被锁定且未下发任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重新按照排序查询
|
|
|
|
|
disRowArrNew = WQL.getWO("ST_OUTIVT04")
|
|
|
|
|
.addParam("flag", "2")
|
|
|
|
|
.addParam("iostorinvdtl_id", iostorinvdtl_id)
|
|
|
|
|
.addParam("block_num", jsonRow.getString("block_num"))
|
|
|
|
|
.addParam("row_num", jsonRow.getString("row_num"))
|
|
|
|
|
.process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
option = "2";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (StrUtil.equals(placement_type, "02")) {
|
|
|
|
|
// 左通
|
|
|
|
|
JSONObject jsonDisLeft = disRowArr.getJSONObject(disRowArr.size() - 1);
|
|
|
|
|
|
|
|
|
|
JSONObject isNumMap = new JSONObject();
|
|
|
|
|
// 查询仓位被锁住的货位
|
|
|
|
|
isNumMap.put("flag", "5");
|
|
|
|
|
isNumMap.put("block_num", jsonDisLeft.getString("block_num"));
|
|
|
|
|
isNumMap.put("row_num", jsonDisLeft.getString("row_num"));
|
|
|
|
|
isNumMap.put("out_order_seq", jsonDisLeft.getString("out_order_seq"));
|
|
|
|
|
JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
JSONArray numArr = this.isNum(isLockArr);
|
|
|
|
|
// 不为空则返回报错
|
|
|
|
|
if (ObjectUtil.isNotEmpty(numArr)) {
|
|
|
|
|
String error = "";
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < numArr.size(); k++) {
|
|
|
|
|
JSONObject json = numArr.getJSONObject(k);
|
|
|
|
|
error += json.getString("struct_code") + ",";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new BadRequestException("仓位:" + error + "被锁定且未下发任务");
|
|
|
|
|
}
|
|
|
|
|
// 重新按照排序查询
|
|
|
|
|
disRowArrNew = WQL.getWO("ST_OUTIVT04")
|
|
|
|
|
.addParam("flag", "22")
|
|
|
|
|
.addParam("iostorinvdtl_id", iostorinvdtl_id)
|
|
|
|
|
.addParam("block_num", jsonRow.getString("block_num"))
|
|
|
|
|
.addParam("row_num", jsonRow.getString("row_num"))
|
|
|
|
|
.process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
option = "1";
|
|
|
|
|
|
|
|
|
|
} else if (StrUtil.equals(placement_type, "03")) {
|
|
|
|
|
// 右通
|
|
|
|
|
JSONObject jsonDisRight = disRowArr.getJSONObject(0);
|
|
|
|
|
JSONObject isNumMap = new JSONObject();
|
|
|
|
|
// 查询仓位被锁住的货位
|
|
|
|
|
isNumMap.put("flag", "6");
|
|
|
|
|
isNumMap.put("block_num", jsonDisRight.getString("block_num"));
|
|
|
|
|
isNumMap.put("row_num", jsonDisRight.getString("row_num"));
|
|
|
|
|
isNumMap.put("out_order_seq", jsonDisRight.getString("out_order_seq"));
|
|
|
|
|
JSONArray isLockArr = WQL.getWO("ST_OUTIVT04").addParamMap(isNumMap).process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
JSONArray numArr = this.isNum(isLockArr);
|
|
|
|
|
// 不为空则返回报错
|
|
|
|
|
if (ObjectUtil.isNotEmpty(numArr)) {
|
|
|
|
|
String error = "";
|
|
|
|
|
|
|
|
|
|
for (int k = 0; k < numArr.size(); k++) {
|
|
|
|
|
JSONObject json = numArr.getJSONObject(k);
|
|
|
|
|
error += json.getString("struct_code") + ",";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new BadRequestException("仓位:" + error + "被锁定且未下发任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重新按照排序查询
|
|
|
|
|
disRowArrNew = WQL.getWO("ST_OUTIVT04")
|
|
|
|
|
.addParam("flag", "2")
|
|
|
|
|
.addParam("iostorinvdtl_id", iostorinvdtl_id)
|
|
|
|
|
.addParam("block_num", jsonRow.getString("block_num"))
|
|
|
|
|
.addParam("row_num", jsonRow.getString("row_num"))
|
|
|
|
|
.process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
option = "2";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 循环生成任务
|
|
|
|
|
*/
|
|
|
|
|
boolean canOut = false;
|
|
|
|
|
int j = 0;
|
|
|
|
|
JSONObject jsonObject = disRowArrNew.getJSONObject(j);
|
|
|
|
|
|
|
|
|
|
// 创建任务
|
|
|
|
|
JSONObject param = new JSONObject();
|
|
|
|
|
param.put("task_type", "010503");
|
|
|
|
|
param.put("vehicle_code", jsonObject.getString("box_no"));
|
|
|
|
|
param.put("task_name", "");
|
|
|
|
|
param.put("point_code1", jsonObject.getString("struct_code"));
|
|
|
|
|
param.put("point_code2", point_code);
|
|
|
|
|
param.put("material_id", jsonObject.getString("material_id"));
|
|
|
|
|
param.put("task_group_id", ""); // 任务组
|
|
|
|
|
param.put("sort_seq", ""); // 任务组顺序号
|
|
|
|
|
|
|
|
|
|
String create_task_id = outTask.createTask(param);
|
|
|
|
|
|
|
|
|
|
// 更新分配状态、任务标识、出库点位
|
|
|
|
|
JSONObject jsonTask = wo_Task.query("task_id = '" + create_task_id + "'").uniqueResult(0);
|
|
|
|
|
JSONObject jsonUpdateMap = new JSONObject();
|
|
|
|
|
jsonUpdateMap.put("work_status", "01");
|
|
|
|
|
jsonUpdateMap.put("task_id", jsonTask.getLong("task_id"));
|
|
|
|
|
jsonUpdateMap.put("point_id", point_id);
|
|
|
|
|
wo_dis.update(jsonUpdateMap, "iostorinvdis_id = '" + jsonObject.getString("iostorinvdis_id") + "'");
|
|
|
|
|
|
|
|
|
|
// 1.判断此条分配明细的 ‘仓位’在此主表下的分配明细是否有相同的 ‘仓位’
|
|
|
|
|
JSONArray disArr = wo_dis.query("struct_id = '" + jsonObject.getString("struct_id") +
|
|
|
|
|
"' and iostorinv_id = '" + jsonObject.getString("iostorinv_id") +
|
|
|
|
|
"' and iostorinvdis_id <> '" + jsonObject.getString("iostorinvdis_id") +
|
|
|
|
|
"' and work_status = '00'").getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
// 依次更新相同仓位的分配明细状态、任务标识、出库点位
|
|
|
|
|
for (int n = 0; n < disArr.size(); n++) {
|
|
|
|
|
JSONObject jsonObject2 = disArr.getJSONObject(n);
|
|
|
|
|
jsonObject2.put("work_status", "01");
|
|
|
|
|
jsonObject2.put("task_id", jsonTask.getLong("task_id"));
|
|
|
|
|
jsonObject2.put("point_id", point_id);
|
|
|
|
|
wo_dis.update(jsonObject2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询未被锁住的仓位
|
|
|
|
|
JSONArray moveArr = new JSONArray();
|
|
|
|
|
JSONObject map = new JSONObject();
|
|
|
|
|
map.put("block_num", jsonObject.getString("block_num"));
|
|
|
|
|
map.put("row_num", jsonObject.getString("row_num"));
|
|
|
|
|
map.put("out_order_seq", jsonObject.getString("out_order_seq"));
|
|
|
|
|
|
|
|
|
|
if (StrUtil.equals(option, "1")) {
|
|
|
|
|
// 左边
|
|
|
|
|
map.put("flag", "7");
|
|
|
|
|
moveArr = WQL.getWO("ST_OUTIVT04").addParamMap(map).process().getResultJSONArray(0);
|
|
|
|
|
} else {
|
|
|
|
|
// 右边
|
|
|
|
|
map.put("flag", "8");
|
|
|
|
|
moveArr = WQL.getWO("ST_OUTIVT04").addParamMap(map).process().getResultJSONArray(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建任务组
|
|
|
|
|
long task_group_id = IdUtil.getSnowflake(1, 1).nextId();
|
|
|
|
|
// 更新出库任务:任务组和顺序号
|
|
|
|
|
jsonTask.put("task_group_id", task_group_id);
|
|
|
|
|
jsonTask.put("sort_seq", 0);
|
|
|
|
|
wo_Task.update(jsonTask);
|
|
|
|
|
|
|
|
|
|
// 判断是否需要生成移库
|
|
|
|
|
if (ObjectUtil.isNotEmpty(moveArr)) {
|
|
|
|
|
JSONObject moveParam = new JSONObject();
|
|
|
|
|
moveParam.put("jsonAllBlockPoint", moveArr);
|
|
|
|
|
moveParam.put("iostorinvdis_id", jsonObject.getString("iostorinvdis_id"));
|
|
|
|
|
moveParam.put("task_group_id", task_group_id);
|
|
|
|
|
this.createMove(moveParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 判断下一个出库仓位是否相邻
|
|
|
|
|
*/
|
|
|
|
|
int out_order_seq = jsonObject.getIntValue("out_order_seq");
|
|
|
|
|
boolean canAdd = true;
|
|
|
|
|
int nextNum = j + 1;
|
|
|
|
|
while (canAdd) {
|
|
|
|
|
// 判断数组是否到头
|
|
|
|
|
if (nextNum <= disRowArrNew.size() - 1) {
|
|
|
|
|
JSONObject jsonNext = disRowArrNew.getJSONObject(nextNum);
|
|
|
|
|
int out_order_seq_next = jsonNext.getIntValue("out_order_seq");
|
|
|
|
|
if (Math.abs(out_order_seq_next - out_order_seq) != nextNum) {
|
|
|
|
|
// 下发当前任务组
|
|
|
|
|
outTask.immediateNotifyAcs(null);
|
|
|
|
|
|
|
|
|
|
// 更新任务组
|
|
|
|
|
task_group_id = IdUtil.getSnowflake(1, 1).nextId();
|
|
|
|
|
canAdd = false;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// 查询此任务组最后一个生成的任务
|
|
|
|
|
JSONObject jsonTaskLast = wo_Task.query("task_group_id = '" + task_group_id + "' order by sort_seq ASC").uniqueResult(0);
|
|
|
|
|
// 创建任务并添加到任务组
|
|
|
|
|
JSONObject param2 = new JSONObject();
|
|
|
|
|
param2.put("task_type", "010503");
|
|
|
|
|
param2.put("vehicle_code", jsonNext.getString("box_no"));
|
|
|
|
|
param2.put("task_name", "");
|
|
|
|
|
param2.put("point_code1", jsonNext.getString("struct_code"));
|
|
|
|
|
param2.put("point_code2", point_code);
|
|
|
|
|
param2.put("material_id", jsonNext.getString("material_id"));
|
|
|
|
|
param2.put("task_group_id", task_group_id); // 任务组
|
|
|
|
|
param2.put("sort_seq", jsonTaskLast.getIntValue("sort_seq") - 1); // 任务组顺序号
|
|
|
|
|
|
|
|
|
|
String create_task_id2 = outTask.createTask(param2);
|
|
|
|
|
|
|
|
|
|
// 更新分配状态、任务标识、出库点位
|
|
|
|
|
JSONObject jsonTask2 = wo_Task.query("task_id = '" + create_task_id2 + "'").uniqueResult(0);
|
|
|
|
|
JSONObject jsonUpdateMap2 = new JSONObject();
|
|
|
|
|
jsonUpdateMap2.put("work_status", "01");
|
|
|
|
|
jsonUpdateMap2.put("task_id", jsonTask2.getLong("task_id"));
|
|
|
|
|
jsonUpdateMap2.put("point_id", point_id);
|
|
|
|
|
wo_dis.update(jsonUpdateMap2, "iostorinvdis_id = '" + jsonNext.getString("iostorinvdis_id") + "'");
|
|
|
|
|
|
|
|
|
|
// 1.判断此条分配明细的 ‘仓位’在此主表下的分配明细是否有相同的 ‘仓位’
|
|
|
|
|
JSONArray disArr2 = wo_dis.query("struct_id = '" + jsonNext.getString("struct_id") +
|
|
|
|
|
"' and iostorinv_id = '" + jsonNext.getString("iostorinv_id") +
|
|
|
|
|
"' and iostorinvdis_id <> '" + jsonNext.getString("iostorinvdis_id") +
|
|
|
|
|
"' and work_status = '00'").getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
// 依次更新相同仓位的分配明细状态、任务标识、出库点位
|
|
|
|
|
for (int m = 0; m < disArr2.size(); m++) {
|
|
|
|
|
JSONObject jsonObject3 = disArr2.getJSONObject(m);
|
|
|
|
|
jsonObject3.put("work_status", "01");
|
|
|
|
|
jsonObject3.put("task_id", jsonTask2.getLong("task_id"));
|
|
|
|
|
jsonObject3.put("point_id", point_id);
|
|
|
|
|
wo_dis.update(jsonObject3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nextNum++;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
canAdd = false;
|
|
|
|
|
canOut = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (canOut) {
|
|
|
|
|
// 下发当前任务组
|
|
|
|
|
outTask.immediateNotifyAcs(null);
|
|
|
|
|
disRowArrNew.clear();
|
|
|
|
|
|
|
|
|
|
// 更新任务组
|
|
|
|
|
task_group_id = IdUtil.getSnowflake(1, 1).nextId();
|
|
|
|
|
} else {
|
|
|
|
|
// 迭代调用自身
|
|
|
|
|
this.rowDispose(jsonRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void createMove(JSONObject whereJson) {
|
|
|
|
|
//任务表
|
|
|
|
|
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
|
|
|
|
|
|
|
|
JSONArray jsonAllBlockPoint = whereJson.getJSONArray("jsonAllBlockPoint");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < jsonAllBlockPoint.size(); i++) {
|
|
|
|
|
JSONObject json = jsonAllBlockPoint.getJSONObject(i);
|
|
|
|
|
|
|
|
|
|
JSONObject mapParam = new JSONObject();// 生成移库单传入参数
|
|
|
|
|
JSONArray table = new JSONArray(); // 明细参数
|
|
|
|
|
mapParam.put("bill_status", "10");
|
|
|
|
|
mapParam.put("bill_type", "21");
|
|
|
|
|
mapParam.put("buss_type", "21");
|
|
|
|
|
mapParam.put("biz_date", DateUtil.today());
|
|
|
|
|
mapParam.put("stor_code", "CP01");
|
|
|
|
|
mapParam.put("stor_id", "1582991156504039424");
|
|
|
|
|
mapParam.put("stor_name", "成品仓库");
|
|
|
|
|
mapParam.put("is_task", "1");
|
|
|
|
|
|
|
|
|
|
// 查询移入货位
|
|
|
|
|
JSONObject moveParam = new JSONObject();
|
|
|
|
|
moveParam.put("box_no", json.getString("storagevehicle_code"));
|
|
|
|
|
moveParam.put("sect_id", RegionTypeEnum.ZZ01.getId());
|
|
|
|
|
JSONObject jsonMove = rawAssistIStorService.autoDis(moveParam);
|
|
|
|
|
// 查询移出货位的库存物料
|
|
|
|
|
JSONObject jsonMoveIvt = WQL.getWO("ST_OUTIVT03")
|
|
|
|
|
.addParam("flag", "6")
|
|
|
|
|
.addParam("struct_id", json.getString("struct_id"))
|
|
|
|
|
.process().uniqueResult(0);
|
|
|
|
|
|
|
|
|
|
// 移库单明细
|
|
|
|
|
JSONObject jsonMoveDtl = new JSONObject();
|
|
|
|
|
jsonMoveDtl.put("is_task", "2");
|
|
|
|
|
jsonMoveDtl.put("turnout_sect_id", json.getLongValue("sect_id"));
|
|
|
|
|
jsonMoveDtl.put("turnout_sect_code", json.getString("sect_code"));
|
|
|
|
|
jsonMoveDtl.put("turnout_sect_name", json.getString("sect_name"));
|
|
|
|
|
jsonMoveDtl.put("turnout_struct_id", json.getLongValue("struct_id"));
|
|
|
|
|
jsonMoveDtl.put("turnout_struct_code", json.getString("struct_code"));
|
|
|
|
|
jsonMoveDtl.put("turnout_struct_name", json.getString("struct_name"));
|
|
|
|
|
jsonMoveDtl.put("material_id", jsonMoveIvt.getLongValue("material_id"));
|
|
|
|
|
jsonMoveDtl.put("pcsn", jsonMoveIvt.getString("pcsn"));
|
|
|
|
|
jsonMoveDtl.put("quality_scode", "01");
|
|
|
|
|
jsonMoveDtl.put("qty_unit_id", jsonMoveIvt.getLongValue("qty_unit_id"));
|
|
|
|
|
jsonMoveDtl.put("qty_unit_name", jsonMoveIvt.getString("unit_name"));
|
|
|
|
|
jsonMoveDtl.put("qty", jsonMoveIvt.getDoubleValue("canuse_qty"));
|
|
|
|
|
jsonMoveDtl.put("storagevehicle_code", json.getString("storagevehicle_code"));
|
|
|
|
|
jsonMoveDtl.put("turnin_sect_id", jsonMove.getLongValue("sect_id"));
|
|
|
|
|
jsonMoveDtl.put("turnin_sect_code", jsonMove.getString("sect_code"));
|
|
|
|
|
jsonMoveDtl.put("turnin_sect_name", jsonMove.getString("sect_name"));
|
|
|
|
|
jsonMoveDtl.put("turnin_struct_id", jsonMove.getLongValue("struct_id"));
|
|
|
|
|
jsonMoveDtl.put("turnin_struct_code", jsonMove.getString("struct_code"));
|
|
|
|
|
jsonMoveDtl.put("turnin_struct_name", jsonMove.getString("struct_name"));
|
|
|
|
|
jsonMoveDtl.put("source_billdtl_id", whereJson.getLongValue("iostorinvdis_id"));
|
|
|
|
|
|
|
|
|
|
// 生成任务
|
|
|
|
|
JSONObject param2 = new JSONObject();
|
|
|
|
|
param2.put("task_type", "010503");
|
|
|
|
|
param2.put("vehicle_code", json.getString("storagevehicle_code"));
|
|
|
|
|
param2.put("point_code1", json.getString("struct_code"));
|
|
|
|
|
param2.put("point_code2", jsonMove.getString("struct_code"));
|
|
|
|
|
param2.put("task_group_id", whereJson.getLongValue("task_group_id")); // 任务组
|
|
|
|
|
param2.put("sort_seq", jsonAllBlockPoint.size() - i); // 任务组顺序号
|
|
|
|
|
String move_task_id = outTask.createTask(param2);
|
|
|
|
|
|
|
|
|
|
// 回显移库明细任务id
|
|
|
|
|
jsonMoveDtl.put("task_id", move_task_id);
|
|
|
|
|
table.add(jsonMoveDtl);
|
|
|
|
|
// 更新任务处理类
|
|
|
|
|
JSONObject jsonTaskMove = wo_Task.query("task_id = '" + move_task_id + "'").uniqueResult(0);
|
|
|
|
|
jsonTaskMove.put("task_type", "010505");
|
|
|
|
|
jsonTaskMove.put("handle_class", HandMoveStorAcsTask.class.getName());
|
|
|
|
|
wo_Task.update(jsonTaskMove);
|
|
|
|
|
|
|
|
|
|
mapParam.put("tableData", table);
|
|
|
|
|
// 调用移库单新增方法
|
|
|
|
|
if (ObjectUtil.isNotEmpty(jsonAllBlockPoint)) {
|
|
|
|
|
handMoveStorService.insertDtl2(mapParam);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 被挡的个数
|
|
|
|
|
*
|
|
|
|
|
* @param arr
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public JSONArray isNum(JSONArray arr) {
|
|
|
|
|
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task"); // 任务表
|
|
|
|
|
|
|
|
|
|
JSONArray result = new JSONArray();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < arr.size(); i++) {
|
|
|
|
|
JSONObject json = arr.getJSONObject(i);
|
|
|
|
|
String struct_code = json.getString("struct_code");
|
|
|
|
|
|
|
|
|
|
JSONObject jsonTask1 = taskTab.query("point_code1 = '" + struct_code + "' and task_status in ('05','06')").uniqueResult(0);
|
|
|
|
|
JSONObject jsonTask2 = taskTab.query("point_code2 = '" + struct_code + "' and task_status in ('05','06')").uniqueResult(0);
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(jsonTask1) || ObjectUtil.isNotEmpty(jsonTask2)) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
result.add(json);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public boolean is_trueOrFalse(JSONObject json) {
|
|
|
|
|
/*
|
|
|
|
|
@@ -2482,7 +3026,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(jsondis)) {
|
|
|
|
|
// 存在:判断是否生成任务
|
|
|
|
|
if (!StrUtil.equals(jsondis.getString("work_status"),"00")) {
|
|
|
|
|
if (!StrUtil.equals(jsondis.getString("work_status"), "00")) {
|
|
|
|
|
param = false;
|
|
|
|
|
} else {
|
|
|
|
|
throw new BadRequestException("此仓位不可生成任务,请按照顺序选择!");
|
|
|
|
|
@@ -2499,14 +3043,14 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(jsonTask1) && ObjectUtil.isEmpty(jsonTask2)) {
|
|
|
|
|
// 未生成任务
|
|
|
|
|
throw new BadRequestException("挡住仓位"+struct_code+"已锁定但未生成任务,请按照顺序选择");
|
|
|
|
|
throw new BadRequestException("挡住仓位" + struct_code + "已锁定但未生成任务,请按照顺序选择");
|
|
|
|
|
} else {
|
|
|
|
|
// 已生成
|
|
|
|
|
param = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (StrUtil.equals(json.getString("option"), "2")){
|
|
|
|
|
} else if (StrUtil.equals(json.getString("option"), "2")) {
|
|
|
|
|
// 双通
|
|
|
|
|
// 判断此货位在此出库单中是否存在
|
|
|
|
|
JSONObject jsondis = disTab.query("iostorinv_id = '" + iostorinv_id + "' and struct_code = '" + struct_code + "'").uniqueResult(0);
|
|
|
|
|
@@ -2538,7 +3082,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(jsondis)) {
|
|
|
|
|
// 存在:判断是否生成任务
|
|
|
|
|
if (!StrUtil.equals(jsondis.getString("work_status"),"00")) {
|
|
|
|
|
if (!StrUtil.equals(jsondis.getString("work_status"), "00")) {
|
|
|
|
|
param = true;
|
|
|
|
|
} else {
|
|
|
|
|
param = false;
|
|
|
|
|
@@ -2673,11 +3217,11 @@ 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);
|
|
|
|
|
assign_qty = NumberUtil.add(assign_qty, canuse_qty);
|
|
|
|
|
|
|
|
|
|
if (unassign_qty >= canuse_qty) {
|
|
|
|
|
// unassign_qty = unassign_qty - canuse_qty;
|
|
|
|
|
unassign_qty = NumberUtil.sub(unassign_qty,canuse_qty);
|
|
|
|
|
unassign_qty = NumberUtil.sub(unassign_qty, canuse_qty);
|
|
|
|
|
ivt.put("change_qty", canuse_qty + "");
|
|
|
|
|
} else {
|
|
|
|
|
ivt.put("change_qty", canuse_qty + "");
|
|
|
|
|
@@ -2915,12 +3459,12 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
storPublicService.updateStructAndPoint(from_start);
|
|
|
|
|
|
|
|
|
|
//查询对应明细
|
|
|
|
|
JSONObject dtl_jo = WQLObject.getWQLObject("st_ivt_iostorinvdtl").query("iostorinvdtl_id = '"+dis.getString("iostorinvdtl_id")+"'").uniqueResult(0);
|
|
|
|
|
JSONObject dtl_jo = WQLObject.getWQLObject("st_ivt_iostorinvdtl").query("iostorinvdtl_id = '" + dis.getString("iostorinvdtl_id") + "'").uniqueResult(0);
|
|
|
|
|
// 更新子卷包装关系表 状态 - 3
|
|
|
|
|
JSONObject jsonSub = subTab.query("container_name = '" + dis.getString("pcsn") + "' and status = '2'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(jsonSub)) throw new BadRequestException("此子卷不存在或不为入库状态:" + dis.getString("pcsn"));
|
|
|
|
|
// 如果是拆分入库则将包装关系改为生成状态
|
|
|
|
|
if (jo_mst.getString("bill_type").equals("1005") || (jo_mst.getString("bill_type").equals("1009") && StrUtil.isEmpty(dtl_jo.getString("source_bill_code")))){
|
|
|
|
|
if (jo_mst.getString("bill_type").equals("1005") || (jo_mst.getString("bill_type").equals("1009") && StrUtil.isEmpty(dtl_jo.getString("source_bill_code")))) {
|
|
|
|
|
jsonSub.put("status", "0");
|
|
|
|
|
} else {
|
|
|
|
|
jsonSub.put("status", "3");
|
|
|
|
|
@@ -2933,8 +3477,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
wo_dis.update(jsonDis);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject out_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '"+iostorinv_id+"'").uniqueResult(0);
|
|
|
|
|
if (out_jo.getString("bill_type").equals("1004")){
|
|
|
|
|
JSONObject out_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
|
|
|
|
|
if (out_jo.getString("bill_type").equals("1004")) {
|
|
|
|
|
//调拨出库自动生成调拨入库单
|
|
|
|
|
WQLObject dtl_wql = WQLObject.getWQLObject("st_ivt_iostorinvdtl");
|
|
|
|
|
WQLObject mst_wql = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
|
|
|
|
@@ -2957,13 +3501,13 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
jo_mst.put("bill_type", "0004");
|
|
|
|
|
jo_mst.put("buss_type", ((String) jo_mst.get("bill_type")).substring(0, 4));
|
|
|
|
|
//查询移入仓库的信息
|
|
|
|
|
JSONObject in_stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("stor_id = '"+out_jo.getString("out_stor_id")+"'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(in_stor)){
|
|
|
|
|
JSONObject in_stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("stor_id = '" + out_jo.getString("out_stor_id") + "'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(in_stor)) {
|
|
|
|
|
throw new BadRequestException("未查询到对应的移入仓库信息!");
|
|
|
|
|
}
|
|
|
|
|
jo_mst.put("stor_id",in_stor.getString("stor_id"));
|
|
|
|
|
jo_mst.put("stor_code",in_stor.getString("stor_code"));
|
|
|
|
|
jo_mst.put("stor_name",in_stor.getString("stor_name"));
|
|
|
|
|
jo_mst.put("stor_id", in_stor.getString("stor_id"));
|
|
|
|
|
jo_mst.put("stor_code", in_stor.getString("stor_code"));
|
|
|
|
|
jo_mst.put("stor_name", in_stor.getString("stor_name"));
|
|
|
|
|
jo_mst.put("bill_status", "30");
|
|
|
|
|
jo_mst.put("input_optid", currentUserId + "");
|
|
|
|
|
jo_mst.put("input_optname", nickName);
|
|
|
|
|
@@ -3014,13 +3558,13 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (out_jo.getString("bill_type").equals("1003")){
|
|
|
|
|
if (out_jo.getString("bill_type").equals("1003")) {
|
|
|
|
|
//更新改切子卷为该子卷的分切计划
|
|
|
|
|
JSONObject source_dtl = WQLObject.getWQLObject("st_ivt_iostorinvdtl").query("iostorinv_id = '"+iostorinv_id+"' AND IFNULL(source_billdtl_id,'') <> ''").uniqueResult(0);
|
|
|
|
|
JSONObject source_dtl = WQLObject.getWQLObject("st_ivt_iostorinvdtl").query("iostorinv_id = '" + iostorinv_id + "' AND IFNULL(source_billdtl_id,'') <> ''").uniqueResult(0);
|
|
|
|
|
|
|
|
|
|
HashMap<String,String> map = new HashMap<>();
|
|
|
|
|
map.put("is_parent_ok","1");
|
|
|
|
|
WQLObject.getWQLObject("PDM_BI_SlittingProductionPlan").update(map,"restruct_container_name = '"+source_dtl.getString("pcsn")+"'");
|
|
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
|
|
|
map.put("is_parent_ok", "1");
|
|
|
|
|
WQLObject.getWQLObject("PDM_BI_SlittingProductionPlan").update(map, "restruct_container_name = '" + source_dtl.getString("pcsn") + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -3292,10 +3836,10 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
// System.out.println(acsTaskDtos.toString());
|
|
|
|
|
|
|
|
|
|
// 更新任务状态为下发
|
|
|
|
|
jsonTask.put("task_status",TaskStatusEnum.ISSUE.getCode());
|
|
|
|
|
jsonTask.put("update_optid",currentUserId);
|
|
|
|
|
jsonTask.put("update_optname",nickName);
|
|
|
|
|
jsonTask.put("update_time",now);
|
|
|
|
|
jsonTask.put("task_status", TaskStatusEnum.ISSUE.getCode());
|
|
|
|
|
jsonTask.put("update_optid", currentUserId);
|
|
|
|
|
jsonTask.put("update_optname", nickName);
|
|
|
|
|
jsonTask.put("update_time", now);
|
|
|
|
|
wo_Task.update(jsonTask);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -3328,7 +3872,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
String sort_seq_last = NumberUtil.add(task.getString("sort_seq"), "1").toString();
|
|
|
|
|
|
|
|
|
|
JSONObject jsonTaskLast = wo_Task.query("task_group_id = '" + task_group_id + "' and sort_seq = '" + sort_seq_last + "' and task_status <> '07'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isNotEmpty(jsonTaskLast)) throw new BadRequestException("请先完成"+jsonTaskLast.getString("task_code")+"的任务!");
|
|
|
|
|
if (ObjectUtil.isNotEmpty(jsonTaskLast))
|
|
|
|
|
throw new BadRequestException("请先完成" + jsonTaskLast.getString("task_code") + "的任务!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject dtljo = wo_dis.query("task_id='" + task_id + "'").uniqueResult(0);
|
|
|
|
|
@@ -3573,19 +4118,19 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
JSONObject jsonDtl = dtlTab.query("iostorinv_id = '" + jsonMst.getString("iostorinv_id") + "'").uniqueResult(0);
|
|
|
|
|
if (ObjectUtil.isNotEmpty(jsonDtl)) {
|
|
|
|
|
// 送货单号
|
|
|
|
|
oneMap.put("vbeln",jsonDtl.getString("vbeln"));
|
|
|
|
|
oneMap.put("vbeln", jsonDtl.getString("vbeln"));
|
|
|
|
|
// 订单号
|
|
|
|
|
String source_bill_code = jsonDtl.getString("source_bill_code");
|
|
|
|
|
if (ObjectUtil.isNotEmpty(source_bill_code)) {
|
|
|
|
|
try {
|
|
|
|
|
oneMap.put("order_no",source_bill_code.substring(0,source_bill_code.indexOf("-")));
|
|
|
|
|
oneMap.put("order_no", source_bill_code.substring(0, source_bill_code.indexOf("-")));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
oneMap.put("order_no",source_bill_code);
|
|
|
|
|
oneMap.put("order_no", source_bill_code);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String pageNow = String.valueOf(j + 1); // 页码
|
|
|
|
|
oneMap.put("page",pageNow+ "/" + MapUtil.getStr(whereJson,"pageNum"));
|
|
|
|
|
oneMap.put("page", pageNow + "/" + MapUtil.getStr(whereJson, "pageNum"));
|
|
|
|
|
oneMap.put("consignee", jsonMst.getString("consignee")); // 收货单位
|
|
|
|
|
oneMap.put("receiver", jsonMst.getString("receiver")); // 收货人
|
|
|
|
|
String receiptaddress = jsonMst.getString("receiptaddress");
|
|
|
|
|
@@ -3611,9 +4156,9 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
double all_box_qty = 0;
|
|
|
|
|
for (int t = 0; t < jsonAllBox.size(); t++) {
|
|
|
|
|
JSONObject json = jsonAllBox.getJSONObject(t);
|
|
|
|
|
all_box_qty = NumberUtil.add(all_box_qty,json.getDoubleValue("box_qty"));
|
|
|
|
|
all_box_qty = NumberUtil.add(all_box_qty, json.getDoubleValue("box_qty"));
|
|
|
|
|
}
|
|
|
|
|
oneMap.put("all_box_qty", NumberUtil.round(all_box_qty,2).toString());
|
|
|
|
|
oneMap.put("all_box_qty", NumberUtil.round(all_box_qty, 2).toString());
|
|
|
|
|
oneMap.put("deliveryaddress", jsonMst.getString("deliveryaddress")); // 送货方地址
|
|
|
|
|
oneMap.put("deliveryname", jsonMst.getString("deliveryname")); // 送货方联系人
|
|
|
|
|
oneMap.put("deliveryphone", jsonMst.getString("deliveryphone")); // 送货方联系电话
|
|
|
|
|
@@ -3636,13 +4181,13 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
order_no = jsonSub.getString("sale_order_name");
|
|
|
|
|
|
|
|
|
|
// 规格: 厚度*幅宽
|
|
|
|
|
String material_spec = jsonSub.getString("thickness_request") + "*" + jsonSub.getString("width");
|
|
|
|
|
String material_spec = jsonSub.getString("thickness_request") + "*" + jsonSub.getString("width");
|
|
|
|
|
// 箱号
|
|
|
|
|
String box_no = json.getString("box_no");
|
|
|
|
|
String sub_box_no = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(box_no)) {
|
|
|
|
|
try {
|
|
|
|
|
sub_box_no = box_no.substring(box_no.lastIndexOf("@")+1, box_no.length());
|
|
|
|
|
sub_box_no = box_no.substring(box_no.lastIndexOf("@") + 1, box_no.length());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
sub_box_no = box_no;
|
|
|
|
|
}
|
|
|
|
|
@@ -3664,7 +4209,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
/* if (ObjectUtil.isNotEmpty(order_no)) {
|
|
|
|
|
oneMap.put("order_no",order_no.substring(0,order_no.indexOf("-")));
|
|
|
|
|
}*/
|
|
|
|
|
oneMap.put("all_qty",all_qty); // 合计
|
|
|
|
|
oneMap.put("all_qty", all_qty); // 合计
|
|
|
|
|
workBook.fill(oneMap, sheet);
|
|
|
|
|
workBook.fill(new FillWrapper("data", flData), sheet);
|
|
|
|
|
workBook.finish();
|
|
|
|
|
@@ -3687,13 +4232,13 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
order_no = jsonSub.getString("sale_order_name");
|
|
|
|
|
|
|
|
|
|
// 规格: 厚度*幅宽
|
|
|
|
|
String material_spec = jsonSub.getString("thickness_request") + "*" + jsonSub.getString("width");
|
|
|
|
|
String material_spec = jsonSub.getString("thickness_request") + "*" + jsonSub.getString("width");
|
|
|
|
|
// 箱号
|
|
|
|
|
String box_no = json.getString("box_no");
|
|
|
|
|
String sub_box_no = "";
|
|
|
|
|
if (ObjectUtil.isNotEmpty(box_no)) {
|
|
|
|
|
try {
|
|
|
|
|
sub_box_no = box_no.substring(box_no.lastIndexOf("@")+1, box_no.length());
|
|
|
|
|
sub_box_no = box_no.substring(box_no.lastIndexOf("@") + 1, box_no.length());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
sub_box_no = box_no;
|
|
|
|
|
}
|
|
|
|
|
@@ -3718,7 +4263,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
/* if (ObjectUtil.isNotEmpty(order_no)) {
|
|
|
|
|
oneMap.put("order_no",order_no.substring(0,order_no.indexOf("-")));
|
|
|
|
|
}*/
|
|
|
|
|
oneMap.put("all_qty",all_qty); // 合计
|
|
|
|
|
oneMap.put("all_qty", all_qty); // 合计
|
|
|
|
|
WriteSheet sheet = EasyExcel.writerSheet(0).build();
|
|
|
|
|
workBook.fill(oneMap, sheet);
|
|
|
|
|
workBook.fill(new FillWrapper("data", flData), sheet);
|
|
|
|
|
@@ -3734,7 +4279,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
json.put("num", dtlArr.size());
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONArray queryBox(JSONObject whereJson) {
|
|
|
|
|
|