This commit is contained in:
2022-12-05 17:30:38 +08:00
parent f8144305f2
commit 30f864d37b
4 changed files with 238 additions and 151 deletions

View File

@@ -39,13 +39,13 @@ public class SapToLmsServiceImpl implements SapToLmsService {
for (int i = 0; i < rows.size(); i++) {
JSONObject row = rows.getJSONObject(i);
String MATNR = row.getString("MATNR");
if (StrUtil.isEmpty(MATNR)){
if (StrUtil.isEmpty(MATNR)) {
throw new BadRequestException("物料编码不能为空!");
}
JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbaseext").query("MATNR ='"+MATNR+"'").uniqueResult(0);
if (ObjectUtil.isEmpty(mater_jo)){
JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbaseext").query("MATNR ='" + MATNR + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(mater_jo)) {
WQLObject.getWQLObject("md_me_materialbaseext").insert(row);
}else {
} else {
WQLObject.getWQLObject("md_me_materialbaseext").update(row);
}
}
@@ -69,158 +69,177 @@ public class SapToLmsServiceImpl implements SapToLmsService {
JSONObject result = new JSONObject();
try {
JSONArray item = jo.getJSONArray("ITEM");
JSONArray items = jo.getJSONArray("ITEM");
JSONObject jsonMst = new JSONObject();
//获取SAP的存储地点
String LGORT = item.getJSONObject(0).getString("LGORT");
JSONObject stor_jo = WQLObject.getWQLObject("ST_IVT_BSRealStorAttr").query("ext_id = '"+LGORT+"'").uniqueResult(0);
if (ObjectUtil.isEmpty(stor_jo)){
result.put("RTYPE", "E");
result.put("RTMSG", "操作失败!" + "未查询到外部标识为:"+LGORT+"对应的仓库!");
result.put("RTOAL", 1);
result.put("RTDAT", null);
return result;
HashMap<String, JSONArray> mst_rows = new HashMap<>();
for (int i = 0; i < items.size(); i++) {
JSONObject dtl = items.getJSONObject(i);
String vbeln = dtl.getString(" ");
if (mst_rows.containsKey(vbeln)) {
JSONArray objects = mst_rows.get(vbeln);
objects.add(dtl);
mst_rows.put(vbeln, objects);
} else {
JSONArray objects = new JSONArray();
objects.add(dtl);
mst_rows.put(vbeln, objects);
}
}
jsonMst.put("stor_id", stor_jo.getString("stor_id"));
jsonMst.put("stor_code", stor_jo.getString("stor_code"));
jsonMst.put("stor_name", stor_jo.getString("stor_name"));
jsonMst.put("detail_count", item.size());
jsonMst.put("bill_status", "10");
jsonMst.put("create_mode", "03");
jsonMst.put("biz_date", DateUtil.now());
jsonMst.put("user", "sap");
JSONArray tableData = new JSONArray();
ArrayList<HashMap> box_rows = new ArrayList<>();
for (String s : mst_rows.keySet()) {
JSONArray item = mst_rows.get(s);
JSONObject jsonMst = new JSONObject();
//获取SAP的存储地点
String LGORT = item.getJSONObject(0).getString("LGORT");
JSONObject stor_jo = WQLObject.getWQLObject("ST_IVT_BSRealStorAttr").query("ext_id = '" + LGORT + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(stor_jo)) {
result.put("RTYPE", "E");
result.put("RTMSG", "操作失败!" + "未查询到外部标识为:" + LGORT + "对应的仓库!");
result.put("RTOAL", 1);
result.put("RTDAT", null);
return result;
}
jsonMst.put("stor_id", stor_jo.getString("stor_id"));
jsonMst.put("stor_code", stor_jo.getString("stor_code"));
jsonMst.put("stor_name", stor_jo.getString("stor_name"));
jsonMst.put("detail_count", item.size());
jsonMst.put("bill_status", "10");
jsonMst.put("create_mode", "03");
jsonMst.put("biz_date", DateUtil.now());
jsonMst.put("user", "sap");
JSONArray tableData = new JSONArray();
ArrayList<HashMap> box_rows = new ArrayList<>();
String lfart = "";
for (int i = 0; i < item.size(); i++) {
JSONObject json = item.getJSONObject(i);
lfart = json.getString("LFART");
JSONObject jsonDtl = new JSONObject();
if (StrUtil.equals(lfart, "ZLF")) {
// 生成出库单
jsonMst.put("io_type", "1");
jsonMst.put("buss_type", "1001");
jsonMst.put("bill_type", "1001");
jsonMst.put("source_id", json.getLongValue("VBELN"));
jsonMst.put("source_name", "交货单");
jsonMst.put("receiver", json.getString("CONSIGNEE")); // 收货人
jsonMst.put("receiptphone", json.getString("TEL_NUMBER")); // 联系电话
jsonMst.put("contractno", json.getString("BSTNK")); // 合同号
jsonMst.put("cust_code", json.getString("KUNNR")); // 客户
/*jsonMst.put("remark",json.getString("LGORT"));//库位*/
// 明细
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonMater))
throw new BadRequestException("此物料不存在" + json.getString("MATNR"));
JSONObject jsonUnit = unitTab.query("measure_unit_id = '" + jsonMater.getString("base_unit_id") + "'").uniqueResult(0);
jsonDtl.put("material_id", jsonMater.getString("material_id"));
jsonDtl.put("qty_unit_id", jsonMater.getLongValue("base_unit_id"));
jsonDtl.put("qty_unit_name", jsonUnit.getString("unit_name"));
jsonDtl.put("plan_qty", json.getDoubleValue("LFIMG"));
jsonDtl.put("source_bill_code", json.getString("VGBEL-VGPOS"));
jsonDtl.put("vbeln", json.getString("VBELN")); // 来源交货单
jsonDtl.put("posnr", json.getString("POSNR")); // 来源交货单行
tableData.add(jsonDtl);
}
if (StrUtil.equals(lfart, "ZLR")) {
/*jsonMst.put("remark",json.getString("LGORT"));//库位*/
HashMap map = new HashMap();
//更新包装关系
String sap_pcsn = json.getString("CHARG");
if (StrUtil.isEmpty(sap_pcsn)) {
throw new BadRequestException("批次不能为空!");
}
String package_box_sn = json.getString("ZZJXH");
if (StrUtil.isEmpty(package_box_sn)) {
throw new BadRequestException("箱号不能为空!");
}
String sale_order_name = json.getString("VGBEL-VGPOS");
if (StrUtil.isEmpty(sale_order_name)) {
throw new BadRequestException("销售订单及行号不能为空!");
}
String length = json.getString("ZZJCD");
if (StrUtil.isEmpty(length)) {
throw new BadRequestException("子卷长度不能为空!");
}
String width = json.getString("HL02");
if (StrUtil.isEmpty(width)) {
throw new BadRequestException("子卷幅宽不能为空!");
}
// 明细
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonMater)) {
throw new BadRequestException("此物料不存在" + json.getString("MATNR"));
}
JSONObject sub_jo = WQLObject.getWQLObject("PDM_BI_SubPackageRelation").query("sap_pcsn = '" + sap_pcsn + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(sub_jo)) {
//为空新增一条
sub_jo = new JSONObject();
sub_jo.put("workorder_id", IdUtil.getSnowflake(1, 1).nextId());
sub_jo.put("package_box_sn", package_box_sn);
sub_jo.put("quanlity_in_box", 1);
sub_jo.put("sale_order_name", sale_order_name);
sub_jo.put("customer_name", json.getString("KUNNR"));
sub_jo.put("customer_description", json.getString("NAMEM"));
sub_jo.put("product_name", json.getString("MATNR"));
sub_jo.put("product_description", jsonMater.getString("material_name"));
sub_jo.put("container_name", sap_pcsn);
sub_jo.put("width", width);
sub_jo.put("net_weight", json.getString("LFIMG"));
sub_jo.put("length", length);
sub_jo.put("is_un_plan_production", 0);
sub_jo.put("create_id", 0);
sub_jo.put("create_name", 0);
sub_jo.put("create_time", 0);
sub_jo.put("status", "0");
sub_jo.put("sap_pcsn", sap_pcsn);
sub_jo.put("vbeln", json.getString("VBELN"));
sub_jo.put("posnr", json.getString("POSNR"));
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").insert(sub_jo);
} else {
//不为空修改子卷包装关系
sub_jo.put("vbeln", json.getString("VBELN"));
sub_jo.put("posnr", json.getString("POSNR"));
sub_jo.put("package_box_sn", package_box_sn);
sub_jo.put("width", width);
sub_jo.put("length", length);
sub_jo.put("status", "0");
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").update(sub_jo);
}
map.put("container_name", sub_jo.getString("container_name"));
map.put("net_weight", sub_jo.getString("net_weight"));
map.put("package_box_sn", sub_jo.getString("package_box_sn"));
map.put("product_name", sub_jo.getString("product_name"));
map.put("vbeln", json.getString("VBELN"));
map.put("posnr", json.getString("POSNR"));
box_rows.add(map);
}
}
String lfart = "";
for (int i = 0; i < item.size(); i++) {
JSONObject json = item.getJSONObject(i);
lfart = json.getString("LFART");
JSONObject jsonDtl = new JSONObject();
if (StrUtil.equals(lfart, "ZLF")) {
// 生成出库单
jsonMst.put("io_type", "1");
jsonMst.put("buss_type", "1001");
jsonMst.put("bill_type", "1001");
jsonMst.put("source_id", json.getLongValue("VBELN"));
jsonMst.put("source_name", "交货单");
jsonMst.put("receiver", json.getString("CONSIGNEE")); // 收货人
jsonMst.put("receiptphone", json.getString("TEL_NUMBER")); // 联系电话
jsonMst.put("contractno", json.getString("BSTNK")); // 合同号
jsonMst.put("cust_code", json.getString("KUNNR")); // 客户
/*jsonMst.put("remark",json.getString("LGORT"));//库位*/
// 明细
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonMater))
throw new BadRequestException("此物料不存在" + json.getString("MATNR"));
JSONObject jsonUnit = unitTab.query("measure_unit_id = '" + jsonMater.getString("base_unit_id") + "'").uniqueResult(0);
jsonDtl.put("material_id", jsonMater.getString("material_id"));
jsonDtl.put("qty_unit_id", jsonMater.getLongValue("base_unit_id"));
jsonDtl.put("qty_unit_name", jsonUnit.getString("unit_name"));
jsonDtl.put("plan_qty", json.getDoubleValue("LFIMG"));
jsonDtl.put("source_bill_code", json.getString("VGBEL-VGPOS"));
jsonDtl.put("vbeln", json.getString("VBELN")); // 来源交货单
jsonDtl.put("posnr", json.getString("POSNR")); // 来源交货单行
tableData.add(jsonDtl);
jsonMst.put("tableData", tableData);
// 调用出库新增并分配
String iostorinv_id = checkOutBillService.insertDtl2(jsonMst);
JSONObject jsonObject = new JSONObject();
jsonObject.put("iostorinv_id", iostorinv_id);
//checkOutBillService.allDiv(jsonObject);
}
if (StrUtil.equals(lfart, "ZLR")) {
/*jsonMst.put("remark",json.getString("LGORT"));//库位*/
HashMap map = new HashMap();
//更新包装关系
String sap_pcsn = json.getString("CHARG");
if (StrUtil.isEmpty(sap_pcsn)) {
throw new BadRequestException("批次不能为空!");
}
String package_box_sn = json.getString("ZZJXH");
if (StrUtil.isEmpty(package_box_sn)) {
throw new BadRequestException("箱号不能为空!");
}
String sale_order_name = json.getString("VGBEL-VGPOS");
if (StrUtil.isEmpty(sale_order_name)) {
throw new BadRequestException("销售订单及行号不能为空!");
}
String length = json.getString("ZZJCD");
if (StrUtil.isEmpty(length)) {
throw new BadRequestException("子卷长度不能为空!");
}
String width = json.getString("HL02");
if (StrUtil.isEmpty(width)) {
throw new BadRequestException("子卷幅宽不能为空!");
}
// 明细
JSONObject jsonMater = materTab.query("material_code = '" + json.getString("MATNR") + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonMater)) {
throw new BadRequestException("此物料不存在" + json.getString("MATNR"));
}
JSONObject sub_jo = WQLObject.getWQLObject("PDM_BI_SubPackageRelation").query("sap_pcsn = '" + sap_pcsn + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(sub_jo)) {
//为空新增一条
sub_jo = new JSONObject();
sub_jo.put("workorder_id", IdUtil.getSnowflake(1, 1).nextId());
sub_jo.put("package_box_sn", package_box_sn);
sub_jo.put("quanlity_in_box", 1);
sub_jo.put("sale_order_name", sale_order_name);
sub_jo.put("customer_name", json.getString("KUNNR"));
sub_jo.put("customer_description", json.getString("NAMEM"));
sub_jo.put("product_name", json.getString("MATNR"));
sub_jo.put("product_description", jsonMater.getString("material_name"));
sub_jo.put("container_name", sap_pcsn);
sub_jo.put("width", width);
sub_jo.put("net_weight", json.getString("LFIMG"));
sub_jo.put("length", length);
sub_jo.put("is_un_plan_production", 0);
sub_jo.put("create_id", 0);
sub_jo.put("create_name", 0);
sub_jo.put("create_time", 0);
sub_jo.put("status", "0");
sub_jo.put("sap_pcsn", sap_pcsn);
sub_jo.put("vbeln", json.getString("VBELN"));
sub_jo.put("posnr", json.getString("POSNR"));
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").insert(sub_jo);
} else {
//不为空修改子卷包装关系
sub_jo.put("vbeln", json.getString("VBELN"));
sub_jo.put("posnr", json.getString("POSNR"));
sub_jo.put("package_box_sn", package_box_sn);
sub_jo.put("width", width);
sub_jo.put("length", length);
sub_jo.put("status", "0");
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").update(sub_jo);
}
map.put("container_name", sub_jo.getString("container_name"));
map.put("net_weight", sub_jo.getString("net_weight"));
map.put("package_box_sn", sub_jo.getString("package_box_sn"));
map.put("product_name", sub_jo.getString("product_name"));
map.put("vbeln", json.getString("VBELN"));
map.put("posnr", json.getString("POSNR"));
box_rows.add(map);
jsonMst.put("tableData", box_rows);
//创建退货入库单
jsonMst.put("bill_type", "0002");
jsonMst.put("biz_date", DateUtil.now());
jsonMst.put("bill_status", "30");
rawAssistIStorService.insertDtl(jsonMst);
}
}
if (StrUtil.equals(lfart, "ZLF")) {
jsonMst.put("tableData", tableData);
// 调用出库新增并分配
String iostorinv_id = checkOutBillService.insertDtl2(jsonMst);
JSONObject jsonObject = new JSONObject();
jsonObject.put("iostorinv_id", iostorinv_id);
//checkOutBillService.allDiv(jsonObject);
}
if (StrUtil.equals(lfart, "ZLR")) {
jsonMst.put("tableData", box_rows);
//创建退货入库单
jsonMst.put("bill_type", "0002");
jsonMst.put("biz_date", DateUtil.now());
jsonMst.put("bill_status", "30");
rawAssistIStorService.insertDtl(jsonMst);
}
} catch (Exception e) {
result.put("RTYPE", "E");
result.put("RTMSG", "操作失败!" + e.getMessage());

View File

@@ -158,7 +158,7 @@ public class ChangeServiceImpl implements ChangeService {
HashMap<String, HashMap> set = new HashMap<>();
for (int i = 0; i < rows.size(); i++) {
HashMap row = rows.get(i);
String package_box_sn = (String) row.get("package_box_sn");
String package_box_sn = (String) row.get("storagevehicle_code");
if (set.containsKey(package_box_sn)) {
continue;
} else {

View File

@@ -128,7 +128,54 @@
/>
</el-form-item>
</el-form>
<el-card class="box-card" shadow="never" :body-style="{padding:'20px 20px 0 20px'}" style="margin-top: 5px;">
<el-form ref="form2" :inline="true" :model="form" :rules="rules" size="mini">
<el-form-item label="销售订单-" prop="new_sale_order_name">
<el-input v-model="form.new_sale_order_name" class="input-with-select"/>
</el-form-item>
<el-form-item label="客户编码-" prop="new_sale_order_name">
<el-input v-model="form.new_customer_name" class="input-with-select"/>
</el-form-item>
<el-form-item label="客户描述-" prop="form.new_sale_order_name">
<el-input v-model="form.new_customer_description" class="input-with-select"/>
</el-form-item>
<el-form-item label="交货日期-" prop="demand_date">
<el-date-picker
v-model="form.demand_date"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
<el-form-item label="制造日期-" prop="date_of_fg_inbound">
<el-date-picker
v-model="form.date_of_fg_inbound"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
<el-form-item label="更换外包装标签" prop="isreprintpackageboxlabel">
<el-switch
v-model="form.isreprintpackageboxlabel"
active-value="1"
inactive-value="0"
active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</el-form-item>
<el-form-item label="更换子卷标签" prop="isunpackbox">
<el-switch
v-model="form.isunpackbox"
active-value="1"
inactive-value="0"
active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</el-form-item>
</el-form>
<el-button class="filter-item" @click="allSend()" size="medium" icon="el-icon-plus" style="float: right; padding: 3px 0" type="warning">一键填充</el-button>
</el-card>
<div class="crud-opts2">
<span class="role-span">变更明细</span>
<span v-if="crud.status.cu > 0" class="crud-opts-right2">
@@ -299,6 +346,10 @@ const defaultForm = {
remark: '',
biz_date: new Date(),
create_mode: '',
demand_date: '',
new_customer_description: '',
new_customer_name: '',
new_sale_order_name: '',
tableData: []
}
export default {
@@ -461,6 +512,23 @@ export default {
this.storId = this.form.stor_id
this.dtlShow = true
},
allSend() {
if (this.form.tableData.length === 0) {
this.crud.notify('请至少选择一条明细', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
for (let i = 0; i < this.form.tableData.length; i++) {
this.$set(this.form.tableData[i], 'new_sale_order_name', this.form.new_sale_order_name)
this.$set(this.form.tableData[i], 'new_customer_name', this.form.new_customer_name)
this.$set(this.form.tableData[i], 'new_customer_description', this.form.new_customer_description)
this.$set(this.form.tableData[i], 'demand_date', this.form.demand_date)
this.$set(this.form.tableData[i], 'date_of_fg_inbound', this.form.date_of_fg_inbound)
this.$set(this.form.tableData[i], 'isunpackbox', this.form.isunpackbox)
this.$set(this.form.tableData[i], 'isreprintpackageboxlabel', this.form.isreprintpackageboxlabel)
this.form.tableData.splice(i, 1, this.form.tableData[i]) // 通过splice 替换数据 触发视图更新
}
},
async queryStruct(index, row) {
this.structShow = true
this.$refs.child.getMsg(false)
@@ -564,12 +632,12 @@ export default {
this.crud.notify('请至少选择一条明细', CRUD.NOTIFICATION_TYPE.INFO)
return false
}
for (let i = 0; i < this.form.tableData.length; i++) {
/* for (let i = 0; i < this.form.tableData.length; i++) {
if (!this.form.tableData[i].edit) {
this.crud.notify('尚有未完成编辑的物料明细序号' + (i + 1) + ',请检查!')
return false
}
}
}*/
}
}
}

View File

@@ -106,7 +106,7 @@
@current-change="handleDtlCurrentChange"
>
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="bill_code" label="出库单号" align="center" width="100"/>
<el-table-column prop="bill_code" label="出库单号" align="center" width="120"/>
<el-table-column :formatter="bill_statusFormat" prop="bill_status" label="状态" />
<el-table-column min-width="120" show-overflow-tooltip prop="material_code" label="物料编码" align="center" />
<el-table-column min-width="120" show-overflow-tooltip prop="material_name" label="物料名称" align="center" />