fix(change): 添加转单物料规格一致性校验
This commit is contained in:
@@ -13,6 +13,7 @@ import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl;
|
||||
@@ -26,7 +27,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PC端出入库新增
|
||||
@@ -149,6 +154,16 @@ public class ChangeServiceImpl implements ChangeService {
|
||||
/**
|
||||
* 根据传进来的载具物料明细,查询载具所有库存记录,并生成移库明细
|
||||
*
|
||||
* ids.append("'");
|
||||
* if (!Struct_map.containsKey(storagevehicle_code)) {
|
||||
* Struct_map.put(storagevehicle_code, row);
|
||||
* }
|
||||
* if (i != 0) {
|
||||
* ids.append("','");
|
||||
* }
|
||||
* ids.append(storagevehicle_code);
|
||||
* }
|
||||
* ids.append("'");
|
||||
* @param rows
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -159,6 +174,8 @@ public class ChangeServiceImpl implements ChangeService {
|
||||
double detail_count = 0;
|
||||
//定义需要需要插入的库存集合
|
||||
HashMap<String, HashMap> set = new HashMap<>();
|
||||
Set<String> saleOrderSet = new HashSet<>();
|
||||
Set<String> customerNameSet = new HashSet<>();
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
HashMap row = rows.get(i);
|
||||
String package_box_sn = (String) row.get("storagevehicle_code");
|
||||
@@ -167,9 +184,38 @@ public class ChangeServiceImpl implements ChangeService {
|
||||
} else {
|
||||
set.put(package_box_sn, row);
|
||||
}
|
||||
// 收集去重的销售订单号和客户名称
|
||||
saleOrderSet.add((String) row.get("new_sale_order_name"));
|
||||
customerNameSet.add((String) row.get("new_customer_name"));
|
||||
}
|
||||
// 判断转单前后的物料是否保持一致,如果不一致拒绝转单 88549333 20260714
|
||||
// 销售订单in
|
||||
String saleOrderStr = saleOrderSet.stream()
|
||||
.map(s -> "'" + s + "'")
|
||||
.collect(Collectors.joining(","));
|
||||
// 客户in 字段
|
||||
String customerNameStr = customerNameSet.stream()
|
||||
.map(s -> "'" + s + "'")
|
||||
.collect(Collectors.joining(","));
|
||||
JSONArray package_rows = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("sale_order_name in (" + saleOrderStr + ")" + " and customer_name in (" + customerNameStr + ")").getResultJSONArray(0);
|
||||
// 获取查询结果里面的物料编码,去重
|
||||
Set<String> materialCodeSet = new HashSet<>();
|
||||
for (int i = 0; i < package_rows.size(); i++) {
|
||||
JSONObject package_row = package_rows.getJSONObject(i);
|
||||
materialCodeSet.add(package_row.getString("product_name"));
|
||||
}
|
||||
//判断物料编码去重后的个数是否大于1 ,如果大于1 直接返回错误
|
||||
if (materialCodeSet.size() > 1) {
|
||||
throw new BadRequestException("存在跨物料规格转单,不允许转单,请检查!");
|
||||
}
|
||||
// 判断物料编码和原订单的物料编码是否一致,如果不一致 返回错误
|
||||
if (!materialCodeSet.isEmpty()) {
|
||||
String packageMaterialCode = materialCodeSet.iterator().next();
|
||||
String originalMaterialCode = (String) rows.get(0).get("material_code");
|
||||
if (!packageMaterialCode.equals(originalMaterialCode)) {
|
||||
throw new BadRequestException("转单物料编码[" + packageMaterialCode + "]与原订单物料编码[" + originalMaterialCode + "]不一致,不允许转单!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (String package_box_sn : set.keySet()) {
|
||||
HashMap row = set.get(package_box_sn);
|
||||
String SaleOrderItem = (String) row.get("new_sale_order_name");
|
||||
|
||||
@@ -133,10 +133,10 @@
|
||||
<el-form-item label="销售订单及行号-新" prop="new_sale_order_name">
|
||||
<el-input v-model="form.new_sale_order_name" :disabled="crud.status.view > 0" class="input-with-select"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="客户编码-新" prop="new_sale_order_name">
|
||||
<el-form-item label="客户编码-新" prop="new_customer_name">
|
||||
<el-input v-model="form.new_customer_name" :disabled="crud.status.view > 0" class="input-with-select"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="客户描述-新" prop="form.new_sale_order_name">
|
||||
<el-form-item label="客户描述-新" prop="new_customer_description">
|
||||
<el-input v-model="form.new_customer_description" :disabled="crud.status.view > 0" class="input-with-select"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="交货日期-新" prop="demand_date">
|
||||
@@ -219,9 +219,9 @@
|
||||
width="120"
|
||||
align="center"
|
||||
/>
|
||||
<el-table-column key="11" show-overflow-tooltip prop="storagevehicle_code" label="木箱号"/>
|
||||
<el-table-column key="11" width="160" show-overflow-tooltip prop="storagevehicle_code" label="木箱号"/>
|
||||
<el-table-column key="12" prop="turnout_sect_name" label="库区"/>
|
||||
<el-table-column key="14" prop="turnout_struct_code" show-overflow-tooltip label="货位"/>
|
||||
<el-table-column key="14" width="120" prop="turnout_struct_code" show-overflow-tooltip label="货位"/>
|
||||
<el-table-column key="15" width="150" prop="sale_order_name" show-overflow-tooltip label="销售订单行号-旧"/>
|
||||
<el-table-column key="16" width="150" prop="new_sale_order_name" label="销售订单行号-新">
|
||||
<template scope="scope">
|
||||
@@ -540,6 +540,14 @@ export default {
|
||||
this.nowrow = row
|
||||
},
|
||||
tableChanged(rows) {
|
||||
const allRows = this.form.tableData.concat(rows)
|
||||
const baseMaterial = allRows[0] && allRows[0].material_code
|
||||
const hasDiff = allRows.some(r => r.material_code !== baseMaterial)
|
||||
if (hasDiff) {
|
||||
this.crud.notify('转单数据规格不一致,不允许添加!', CRUD.NOTIFICATION_TYPE.ERROR)
|
||||
// 直接拦下,不入表
|
||||
return
|
||||
}
|
||||
const tablemap = new Map()
|
||||
rows.forEach((item) => {
|
||||
if (this.form.tableData.length !== 0) {
|
||||
|
||||
@@ -94,14 +94,14 @@
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column show-overflow-tooltip prop="turnout_sect_name" label="库区" />
|
||||
<el-table-column show-overflow-tooltip prop="turnout_struct_code" label="货位" width="110px" />
|
||||
<el-table-column show-overflow-tooltip prop="storagevehicle_code" width="250" label="载具号" />
|
||||
<el-table-column show-overflow-tooltip prop="material_code" label="物料编码" width="150px" />
|
||||
<el-table-column show-overflow-tooltip prop="material_name" label="物料名称" width="110px" />
|
||||
<el-table-column show-overflow-tooltip prop="storagevehicle_code" width="190" label="载具号" />
|
||||
<el-table-column show-overflow-tooltip prop="material_code" label="物料编码" width="130px" />
|
||||
<el-table-column show-overflow-tooltip prop="material_name" label="物料名称" width="190px" />
|
||||
<el-table-column show-overflow-tooltip prop="pcsn" label="子卷号" width="150" />
|
||||
<el-table-column show-overflow-tooltip prop="sap_pcsn" label="SAP批次" width="120" />
|
||||
<el-table-column show-overflow-tooltip prop="sale_order_name" width="150px" label="销售订单及批次" />
|
||||
<el-table-column show-overflow-tooltip prop="customer_name" label="客户编码" />
|
||||
<el-table-column show-overflow-tooltip prop="customer_description" label="客户描述" width="150" />
|
||||
<el-table-column show-overflow-tooltip prop="customer_description" label="客户描述" width="200" />
|
||||
<el-table-column show-overflow-tooltip prop="qty" label="重量" :formatter="crud.formatNum3" width="110px" />
|
||||
<el-table-column show-overflow-tooltip prop="qty_unit_name" label="重量单位" />
|
||||
</el-table>
|
||||
|
||||
Reference in New Issue
Block a user