add:拣选出库开发

This commit is contained in:
2024-04-30 10:57:40 +08:00
parent 18008d04a1
commit b6736b9a9d
4 changed files with 292 additions and 24 deletions

View File

@@ -484,6 +484,12 @@ public class StorPublicServiceImpl implements StorPublicService {
map.put("storagevehicle_code", storagevehicle_code);
}
if (ObjectUtil.isNotEmpty(from.getString("bill_type"))) {
if (from.getString("bill_type").equals("1011")){
map.put("storagevehicle_code", storagevehicle_code);
}
}
wo_Struct.update(map, "struct_id = '" + jo.getString("struct_id") + "'");
wo_Point.update(map, "point_id = '" + jo.getString("point_id") + "'");
} else {//锁定

View File

@@ -398,6 +398,11 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
@Override
@Transactional(rollbackFor = Exception.class)
public String insertDtl(JSONObject map) {
if(MapUtil.getStr(map,"bill_type").equals("1011")) {
String iostorinv_id = inserdtlPic(map);
return iostorinv_id ;
}
WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt");
//明细另一种写法
JSONArray array = map.getJSONArray("tableData");
@@ -555,6 +560,116 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
return iostorinv_id;
}
/**
* 拣选出库新增
* @param map 、
* @return 单据标识
*/
private String inserdtlPic(JSONObject map) {
WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt");
//明细另一种写法
JSONArray rows = map.getJSONArray("tableData");
map.remove("tableData");
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String user = map.getString("user");
if (ObjectUtil.isNotEmpty(user)) {
if ("mes".equals(user)) {
currentUserId = "2";
nickName = "mes用户";
}
if ("sap".equals(user)) {
currentUserId = "3";
nickName = "sap用户";
}
}
String now = DateUtil.now();
String iostorinv_id = IdUtil.getSnowflake(1, 1).nextId() + "";
String bill_code = CodeUtil.getNewCode("IO_CODE");
JSONObject jsonStor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("stor_id ='" + MapUtil.getStr(map, "stor_id") + "'").uniqueResult(0);
map.put("iostorinv_id", iostorinv_id);
map.put("bill_code", bill_code);
map.put("biz_date", map.getString("biz_date").substring(0, 10));
String bill_type = (String) map.get("bill_type");
map.put("buss_type", bill_type.substring(0, 4));
map.put("io_type", "1");
map.put("detail_count", rows.size() + "");
map.put("create_mode", "01");
map.put("stor_code", jsonStor.getString("stor_code"));
map.put("stor_name", jsonStor.getString("stor_name"));
map.put("input_optid", currentUserId + "");
map.put("input_optname", nickName);
map.put("input_time", now);
map.put("update_optid", currentUserId + "");
map.put("update_optname", nickName);
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"));
if (ObjectUtil.isNotEmpty(user)) {
if (!"mes".equals(user) || "sap".equals(user)) {
Long deptId = SecurityUtils.getDeptId();
map.put("sysdeptid", deptId);
map.put("syscompanyid", deptId);
}
}
double qty = 0.0; // 主表重量
int num = rows.size(); // 明细数
for (int i = 0; i < rows.size(); i++) {
JSONObject row = rows.getJSONObject(i);
// 校验计划数量不能为零
double plan_qty = row.getDoubleValue("plan_qty");
if (Double.compare(plan_qty, 0.0) == 0) {
throw new BadRequestException("数量不能为0");
}
JSONObject jsonDtl = new JSONObject();
jsonDtl.put("iostorinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + "");
jsonDtl.put("iostorinv_id", iostorinv_id);
jsonDtl.put("seq_no", (i + 1) + "");
jsonDtl.put("material_id", row.getString("material_id"));
jsonDtl.put("pcsn", row.getString("pcsn"));
jsonDtl.put("box_no", row.getString("box_no"));
jsonDtl.put("quality_scode", "01");
jsonDtl.put("bill_status", "10");
jsonDtl.put("qty_unit_id", row.get("qty_unit_id"));
jsonDtl.put("qty_unit_name", row.getString("qty_unit_name"));
jsonDtl.put("plan_qty", row.get("plan_qty"));
jsonDtl.put("remark", row.getString("remark"));
jsonDtl.put("source_bill_code", row.getString("source_bill_code"));
jsonDtl.put("assign_qty", "0");
jsonDtl.put("unassign_qty", row.get("plan_qty"));
jsonDtl.put("vbeln", row.getString("vbeln"));
jsonDtl.put("posnr", row.getString("posnr"));
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").insert(jsonDtl);
qty += jsonDtl.getDoubleValue("plan_qty");
// 判断此明细子卷是否存在,存在则将此木箱下的子卷全部生成明细
String pcsn = row.getString("pcsn");
String box_no = row.getString("box_no");
//查询该箱子所在货位
JSONObject struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + box_no + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(pcsn)) {
if (ObjectUtil.isEmpty(struct_jo)) {
throw new BadRequestException("未查询到该批次所在货位!");
}
String struct_code = struct_jo.getString("struct_code");
JSONObject json = ivtTab.query("pcsn = '" + pcsn + "' AND struct_code = '" + struct_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(json)) {
continue;
}
}
}
map.put("total_qty", qty);
map.put("detail_count", num);
WQLObject.getWQLObject("ST_IVT_IOStorInv").insert(map);
return iostorinv_id;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String insertDtl2(JSONObject map) {
@@ -1129,6 +1244,11 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(JSONObject whereJson) {
if (whereJson.getString("bill_type").equals("1011")) {
updatePic(whereJson);
return;
}
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
@@ -1254,6 +1374,82 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
}
}
/**
* 分拣出库修改
* @param whereJson、
*/
private void updatePic(JSONObject whereJson) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
whereJson.put("update_optid", currentUserId + "");
whereJson.put("update_optname", nickName);
whereJson.put("update_time", now);
WQLObject wo = WQLObject.getWQLObject("ST_IVT_IOStorInv");
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt");
wo.update(whereJson);
//先删除该单据下的所有明细
String iostorinv_id = (String) whereJson.get("iostorinv_id");
wo_dtl.delete("iostorinv_id = '" + iostorinv_id + "'");
JSONArray rows = whereJson.getJSONArray("tableData");
double qty = 0.0; // 主表重量
int num = rows.size(); // 明细数
for (int i = 0; i < rows.size(); i++) {
JSONObject row = rows.getJSONObject(i);
// 校验计划数量不能为零
double plan_qty = row.getDoubleValue("plan_qty");
if (Double.compare(plan_qty, 0) == 0) {
throw new BadRequestException("数量不能为0");
}
JSONObject jsonDtl = new JSONObject();
jsonDtl.put("iostorinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + "");
jsonDtl.put("iostorinv_id", iostorinv_id);
jsonDtl.put("seq_no", (i + 1) + "");
jsonDtl.put("material_id", row.getString("material_id"));
jsonDtl.put("pcsn", row.getString("pcsn"));
jsonDtl.put("box_no", row.getString("box_no"));
jsonDtl.put("quality_scode", "01");
jsonDtl.put("bill_status", "10");
jsonDtl.put("qty_unit_id", row.get("qty_unit_id"));
jsonDtl.put("qty_unit_name", row.getString("qty_unit_name"));
jsonDtl.put("plan_qty", row.get("plan_qty"));
jsonDtl.put("remark", row.getString("remark"));
jsonDtl.put("source_bill_code", row.getString("source_bill_code"));
jsonDtl.put("assign_qty", "0");
jsonDtl.put("unassign_qty", row.get("plan_qty"));
jsonDtl.put("vbeln", row.getString("vbeln"));
jsonDtl.put("posnr", row.getString("posnr"));
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").insert(jsonDtl);
qty += jsonDtl.getDoubleValue("plan_qty");
// 判断此明细子卷是否存在,存在则将此木箱下的子卷全部生成明细
String pcsn = row.getString("pcsn");
String box_no = row.getString("box_no");
//查询该箱子所在货位
JSONObject struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + box_no + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(pcsn)) {
if (ObjectUtil.isEmpty(struct_jo)) {
throw new BadRequestException("未查询到该批次所在货位!");
}
String struct_code = struct_jo.getString("struct_code");
JSONObject json = ivtTab.query("pcsn = '" + pcsn + "' AND struct_code = '" + struct_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(json)) {
continue;
}
}
whereJson.put("total_qty", qty);
whereJson.put("detail_count", num);
wo.update(whereJson);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void allDiv(JSONObject whereJson) {
@@ -1425,7 +1621,13 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
throw new BadRequestException("库存不足");
}
double canuse_qty = jsonIvt.getDoubleValue("canuse_qty");
double canuse_qty ;
if (StrUtil.equals(bill_type, "1011")) {
canuse_qty = dtl.getDoubleValue("plan_qty");
} else {
canuse_qty = jsonIvt.getDoubleValue("canuse_qty");
}
jsonIvt.put("change_qty", canuse_qty + "");
unassign_qty = 0;
assign_qty = NumberUtil.add(assign_qty, canuse_qty);
@@ -4402,23 +4604,6 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
storPublicService.IOStor(dis, "21");
}
}
//解锁起点
JSONObject from_start = new JSONObject();
from_start.put("struct_id", dis.getString("struct_id"));
from_start.put("lock_type", "1");
from_start.put("is_overdue", dis.getString("is_overdue"));
if (jo_mst.getString("is_overdue").equals("1")) {
if (dis.getString("is_overdue").equals("1")) {
from_start.put("storagevehicle_code", dis.getString("box_no"));
} else {
from_start.put("storagevehicle_code", "");
}
} else {
from_start.put("storagevehicle_code", "");
}
storPublicService.updateStructAndPoint(from_start);
// 更新分配明细执行状态为 - 99
JSONObject jsonDis = wo_dis.query("iostorinvdis_id = '" + dis.getString("iostorinvdis_id") + "'").uniqueResult(0);
@@ -4450,8 +4635,55 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
} else {
jsonSub.put("status", "3");
}
if (jo_mst.getString("bill_type").equals("1011")) {
// 更新子卷包装净重
double net_weight = NumberUtil.sub(jsonSub.getDoubleValue("net_weight"), plan_qty);
jsonSub.put("net_weight",net_weight);
if (net_weight <= 0) {
jsonSub.put("status","3");
} else {
jsonSub.put("status","2");
}
}
subTab.update(jsonSub);
// 解锁起点
JSONObject from_start = new JSONObject();
from_start.put("struct_id", dis.getString("struct_id"));
from_start.put("lock_type", "1");
from_start.put("is_overdue", dis.getString("is_overdue"));
if (jo_mst.getString("is_overdue").equals("1")) {
if (dis.getString("is_overdue").equals("1")) {
from_start.put("storagevehicle_code", dis.getString("box_no"));
} else {
from_start.put("storagevehicle_code", "");
}
} else {
from_start.put("storagevehicle_code", "");
}
if (jo_mst.getString("bill_type").equals("1011")) {
// 判断此木箱下的所有子卷净重是否为0如果为0则清空载具
List<JSONObject> packageList = subTab.query("package_box_sn = '" + jsonSub.getString("package_box_sn") + "'")
.getResultJSONArray(0).toJavaList(JSONObject.class);
boolean is_zero = packageList.stream()
.allMatch(row -> row.getDoubleValue("net_weight") <= 0);
if (is_zero) {
from_start.put("storagevehicle_code", "");
} else {
from_start.put("bill_type","1011");
from_start.put("storagevehicle_code", jsonSub.getString("package_box_sn"));
}
}
storPublicService.updateStructAndPoint(from_start);
//插入包装关系出入库记录表
jsonSub.put("bill_code", jo_mst.getString("bill_code"));
jsonSub.put("bill_id", jo_mst.getString("iostorinv_id"));