From 4e814dc13545fde4c5c294865370c165db7eb40e Mon Sep 17 00:00:00 2001
From: hao <1836460075@qq.com>
Date: 星期二, 16 九月 2025 19:19:48 +0800
Subject: [PATCH] 组装拆卸测试2
---
StandardInterface/MES.Service/Dto/webApi/ERPZZCXD.cs | 96 ++++++++---
StandardInterface/MES.Service/Modes/ZZCX.cs | 115 ++++++++++++++
StandardInterface/MESApplication/Controllers/ZZCXDController.cs | 20 +-
StandardInterface/MES.Service/service/ZZCXDManager.cs | 190 ++++++++++++++++-------
StandardInterface/MES.Service/Modes/Zzcxa.cs | 40 +++-
StandardInterface/MES.Service/Modes/Zzcxb.cs | 18 +-
6 files changed, 360 insertions(+), 119 deletions(-)
diff --git a/StandardInterface/MES.Service/Dto/webApi/ERPZZCXD.cs b/StandardInterface/MES.Service/Dto/webApi/ERPZZCXD.cs
index 214222e..1a0703d 100644
--- a/StandardInterface/MES.Service/Dto/webApi/ERPZZCXD.cs
+++ b/StandardInterface/MES.Service/Dto/webApi/ERPZZCXD.cs
@@ -1,50 +1,90 @@
-锘縰sing System.Collections.Generic;
+锘�// 鏂囦欢: MES.Service.Dto.webApi/ERPZZCX.cs
+using System.Collections.Generic;
namespace MES.Service.Dto.webApi
{
/// <summary>
- /// ERP 浼犺緭鐨勫埗閫犳媶鍗稿崟锛堜富琛� + 鏄庣粏闆嗗悎锛�
+ /// ERP 缁勮鎷嗗嵏 鏁村寘 DTO锛堜富琛� + 瀛愯〃闆嗗悎锛屽瓙琛ㄤ腑鍖呭惈瀛欒〃闆嗗悎锛�
/// </summary>
public class ERPZZCXD
{
- public ERPZZCXA ERPZZCXA { get; set; } = new ERPZZCXA();
- public List<ERPZZCXB> ERPZZCXB { get; set; } = new List<ERPZZCXB>();
+ /// <summary>
+ /// ERP 涓昏〃锛堝搴� DB 琛� ZZCX 鐨勬暟鎹細ERPID銆丅ILL_NO锛�
+ /// </summary>
+ public ERPZZCXMain Main { get; set; } = new ERPZZCXMain();
+
+ /// <summary>
+ /// 瀛愯〃闆嗗悎锛堟瘡涓瓙琛ㄥ彲鍖呭惈瀛欒〃闆嗗悎锛�
+ /// </summary>
+ public List<ERPZZCXA> Children { get; set; } = new List<ERPZZCXA>();
}
/// <summary>
- /// ERP 鍒堕�犳媶鍗稿崟 涓昏〃 DTO
+ /// ERP 涓昏〃 DTO (ZZCX)
+ /// </summary>
+ public class ERPZZCXMain
+ {
+ public string? erpid { get; set; } // ERP 涓昏〃id锛堜富琛ㄧ殑 ERPID锛�
+ public string? bill_no { get; set; } // 鍗曟嵁缂栫爜
+ public string? type { get; set; } //
+ public string? dj_lx { get; set; } // 鍗曟嵁绫诲瀷
+ public string? kc_zz { get; set; } // 搴撳瓨缁勭粐
+ public string? sw_lx { get; set; } // 浜嬪姟绫诲瀷
+ public string? time { get; set; } // 鏃ユ湡
+ public string? bm { get; set; } // 閮ㄩ棬
+ public string? cgy { get; set; } // 浠撶鍛�
+ public string? kcz { get; set; } // 搴撳瓨缁�
+ public string? dj_zt { get; set; } // 鍗曟嵁鐘舵��
+ public string? memo { get; set; } // 澶囨敞
+ public string? cphzlx { get; set; } // 鎴愬搧璐т富绫诲瀷
+ public string? cphz { get; set; } // 鎴愬搧璐т富
+ public string? zjhzlx { get; set; } // 瀛愪欢璐т富绫诲瀷
+ public string? zjhz { get; set; } // 瀛愪欢璐т富
+ }
+
+ /// <summary>
+ /// ERP 瀛愯〃 DTO锛圸ZCXA锛� 鈥斺�� 鍖呭惈涔嬪墠 ZZCXA 鐨勫叏閮ㄥ瓧娈碉紝骞舵柊澧炲彲鏀剧疆瀛欒〃闆嗗悎
+ /// NOTE: 杩欓噷鐨� yd_id 搴斿綋鐢变富琛ㄧ殑 erpid 濉厖锛堜綘瑕佹眰鐨勯渶姹傦級
/// </summary>
public class ERPZZCXA
{
- public string? bill_no { get; set; } // 鍗曟嵁缂栫爜
- public string? dj_lx { get; set; } // 鍗曟嵁绫诲瀷
- public string? kc_zz { get; set; } // 搴撳瓨缁勭粐
- public string? sw_lx { get; set; } // 浜嬪姟绫诲瀷
- public string? time { get; set; } // 鏃ユ湡
- public string? bm { get; set; } // 閮ㄩ棬
- public string? cgy { get; set; } // 浠撶鍛�
- public string? kcz { get; set; } // 搴撳瓨缁�
- public string? dj_zt { get; set; } // 鍗曟嵁鐘舵��
- public string? memo { get; set; } // 澶囨敞
- public string? cphzlx { get; set; } // 鎴愬搧璐т富绫诲瀷
- public string? cphz { get; set; } // 鎴愬搧璐т富
- public string? zjhzlx { get; set; } // 瀛愪欢璐т富绫诲瀷
- public string? zjhz { get; set; } // 瀛愪欢璐т富
- public string? item_id { get; set; } // 鐗╂枡缂栫爜id
- public string? qty { get; set; } // 鏁伴噺
- public string? unit { get; set; } // 鍗曚綅
- public string? depot_id { get; set; } // 浠撳簱
- public string? erpid { get; set; } // ERP 涓昏〃id
- public string? type { get; set; }
+ // 鍏宠仈涓昏〃
+ public string? yd_id { get; set; } // 瀵瑰簲涓昏〃 ERPID锛堢敱涓昏〃濉厖锛�
+ public string? erpid { get; set; } // ERP 瀛愯〃id锛堝鏋� ERP 鏈夎 id锛�
+/* public string? bill_no { get; set; } // 鍗曟嵁缂栫爜锛堝彲閲嶅锛�
+ public string? dj_lx { get; set; } // 鍗曟嵁绫诲瀷
+ public string? kc_zz { get; set; } // 搴撳瓨缁勭粐
+ public string? sw_lx { get; set; } // 浜嬪姟绫诲瀷
+ public string? time { get; set; } // 鏃ユ湡
+ public string? bm { get; set; } // 閮ㄩ棬
+ public string? cgy { get; set; } // 浠撶鍛�
+ public string? kcz { get; set; } // 搴撳瓨缁�
+ public string? dj_zt { get; set; } // 鍗曟嵁鐘舵��
+ public string? memo { get; set; } // 澶囨敞
+ public string? cphzlx { get; set; } // 鎴愬搧璐т富绫诲瀷
+ public string? cphz { get; set; } // 鎴愬搧璐т富
+ public string? zjhzlx { get; set; } // 瀛愪欢璐т富绫诲瀷
+ public string? zjhz { get; set; } // 瀛愪欢璐т富*/
+
+ // 鏄庣粏鐩稿叧瀛楁锛堝瓙琛ㄥ彲鑳戒篃璁板綍鏌愭潯鐗╂枡淇℃伅锛�
+ public string? item_id { get; set; } // 鐗╂枡缂栫爜id
+ public string? qty { get; set; } // 鏁伴噺
+ public string? unit { get; set; } // 鍗曚綅
+ public string? depot_id { get; set; } // 浠撳簱
+
+ /// <summary>
+ /// 瀛欒〃闆嗗悎锛氭瘡鏉″瓙琛ㄨ褰曞搴� 0..N 鏉″瓩琛紙ZZCXB锛�
+ /// </summary>
+ public List<ERPZZCXB> SubItems { get; set; } = new List<ERPZZCXB>();
}
/// <summary>
- /// ERP 鍒堕�犳媶鍗稿崟 鏄庣粏 DTO
+ /// ERP 瀛欒〃 DTO锛圸ZCXB锛�
/// </summary>
public class ERPZZCXB
{
- public string? erpid { get; set; } // ERP 涓昏〃id
- public string? eid { get; set; } // ERP 鍗曟嵁澶磇d
+ public string? erpid { get; set; } // ERP 涓昏〃id锛堟垨鍐椾綑锛�
+ public string? eid { get; set; } // ERP 瀛愯〃id / 琛宨d
public string? item_id { get; set; } // 鐗╂枡缂栫爜id
public string? qty { get; set; } // 鏁伴噺
public string? unit { get; set; } // 鍗曚綅
diff --git a/StandardInterface/MES.Service/Modes/ZZCX.cs b/StandardInterface/MES.Service/Modes/ZZCX.cs
new file mode 100644
index 0000000..6e1faa0
--- /dev/null
+++ b/StandardInterface/MES.Service/Modes/ZZCX.cs
@@ -0,0 +1,115 @@
+锘�// 鏂囦欢: MES.Service.Modes/ZZCX.cs
+using System;
+using SqlSugar;
+
+namespace MES.Service.Modes
+{
+ /// <summary>
+ /// ZZCX - 缁勮鎷嗗嵏 涓昏〃
+ /// </summary>
+ [SugarTable("ZZCX")]
+ public class ZZCX
+ {
+ /// <summary>
+ /// 涓婚敭 ID
+ /// </summary>
+ [SugarColumn(ColumnName = "ID", IsPrimaryKey = true, OracleSequenceName = "SEQ_ZZCX")]
+ public decimal? Id { get; set; }
+
+ /// <summary>
+ /// ERP 涓昏〃 ID
+ /// </summary>
+ [SugarColumn(ColumnName = "ERPID")]
+ public string Erpid { get; set; }
+
+ /// <summary>
+ /// 鍗曟嵁缂栫爜
+ /// </summary>
+ [SugarColumn(ColumnName = "BILL_NO")]
+ public string BillNo { get; set; }
+ /// <summary>
+ /// 鍗曟嵁缂栫爜
+ /// </summary>
+ [SugarColumn(ColumnName = "TYPE")]
+ public string Type { get; set; }
+
+ /// <summary>
+ /// 鍗曟嵁绫诲瀷
+ /// </summary>
+ [SugarColumn(ColumnName = "DJ_LX")]
+ public string DjLx { get; set; }
+
+ /// <summary>
+ /// 搴撳瓨缁勭粐
+ /// </summary>
+ [SugarColumn(ColumnName = "KC_ZZ")]
+ public string KcZz { get; set; }
+
+ /// <summary>
+ /// 浜嬪姟绫诲瀷
+ /// </summary>
+ [SugarColumn(ColumnName = "SW_LX")]
+ public string SwLx { get; set; }
+
+ /// <summary>
+ /// 鏃ユ湡
+ /// </summary>
+ [SugarColumn(ColumnName = "TIME")]
+ public string Time { get; set; }
+
+ /// <summary>
+ /// 閮ㄩ棬
+ /// </summary>
+ [SugarColumn(ColumnName = "BM")]
+ public string Bm { get; set; }
+
+ /// <summary>
+ /// 浠撶鍛�
+ /// </summary>
+ [SugarColumn(ColumnName = "CGY")]
+ public string Cgy { get; set; }
+
+ /// <summary>
+ /// 搴撳瓨缁�
+ /// </summary>
+ [SugarColumn(ColumnName = "KCZ")]
+ public string Kcz { get; set; }
+
+ /// <summary>
+ /// 鍗曟嵁鐘舵��
+ /// </summary>
+ [SugarColumn(ColumnName = "DJ_ZT")]
+ public string DjZt { get; set; }
+
+ /// <summary>
+ /// 澶囨敞
+ /// </summary>
+ [SugarColumn(ColumnName = "MEMO")]
+ public string Memo { get; set; }
+
+ /// <summary>
+ /// 鎴愬搧璐т富绫诲瀷
+ /// </summary>
+ [SugarColumn(ColumnName = "CPHZLX")]
+ public string Cphzlx { get; set; }
+
+ /// <summary>
+ /// 鎴愬搧璐т富
+ /// </summary>
+ [SugarColumn(ColumnName = "CPHZ")]
+ public string Cphz { get; set; }
+
+ /// <summary>
+ /// 瀛愪欢璐т富绫诲瀷
+ /// </summary>
+ [SugarColumn(ColumnName = "ZJHZLX")]
+ public string Zjhzlx { get; set; }
+
+ /// <summary>
+ /// 瀛愪欢璐т富
+ /// </summary>
+ [SugarColumn(ColumnName = "ZJHZ")]
+ public string Zjhz { get; set; }
+
+ }
+}
diff --git a/StandardInterface/MES.Service/Modes/Zzcxa.cs b/StandardInterface/MES.Service/Modes/Zzcxa.cs
index 4b51bf0..d46aa3f 100644
--- a/StandardInterface/MES.Service/Modes/Zzcxa.cs
+++ b/StandardInterface/MES.Service/Modes/Zzcxa.cs
@@ -1,19 +1,38 @@
-锘縰sing System;
+锘�// 鏂囦欢: MES.Service.Modes/ZZCXA.cs
+using System;
using SqlSugar;
namespace MES.Service.Modes
{
/// <summary>
- /// ZZCXA 涓昏〃
+ /// ZZCXA - 缁勮鎷嗗嵏 瀛愯〃锛堜箣鍓嶇殑 ZZCXA 瀛楁闆嗗悎锛夛紝鏂板 YD_ID 瀛楁鏉ヨ褰曚富琛� ERPID
/// </summary>
[SugarTable("ZZCXA")]
- public class Zzcxa
+ public class ZZCXA
{
/// <summary>
- /// 涓婚敭ID
+ /// 涓婚敭 ID
/// </summary>
[SugarColumn(ColumnName = "ID", IsPrimaryKey = true, OracleSequenceName = "SEQ_ZZCXA")]
public decimal? Id { get; set; }
+
+ /// <summary>
+ /// 鐖惰〃 ID (瀵瑰簲 ZZCX.ID) 鈥斺�� 鍙敤浜庡叧绯绘煡璇�
+ /// </summary>
+ [SugarColumn(ColumnName = "PID")]
+ public decimal? Pid { get; set; }
+
+ /// <summary>
+ /// YD_ID锛氬啓鍏ヤ富琛ㄧ殑 ERPID锛堜綘瑕佹眰锛氬瓙琛ㄧ殑 yd_id 瀛樹富琛ㄧ殑 erpid锛�
+ /// </summary>
+ [SugarColumn(ColumnName = "YD_ID")]
+ public string YdId { get; set; }
+
+ /// <summary>
+ /// ERP 瀛愯〃/琛� id锛坋rpid/eid 绛� ERP 琛屾爣璇嗭級
+ /// </summary>
+ [SugarColumn(ColumnName = "ERPID")]
+ public string Erpid { get; set; }
/// <summary>
/// 鍗曟嵁缂栫爜
@@ -100,10 +119,10 @@
public string Zjhz { get; set; }
/// <summary>
- /// 鐗╂枡缂栫爜id
+ /// 鐗╂枡缂栫爜 id
/// </summary>
[SugarColumn(ColumnName = "ITEM_ID")]
- public decimal? ItemId { get; set; }
+ public string ItemId { get; set; }
/// <summary>
/// 鏁伴噺
@@ -123,10 +142,9 @@
[SugarColumn(ColumnName = "DEPOT_ID")]
public string DepotId { get; set; }
- /// <summary>
- /// ERP 涓昏〃id
- /// </summary>
- [SugarColumn(ColumnName = "ERPID")]
- public string Erpid { get; set; }
+ [SugarColumn(IsIgnore = true)]
+ public List<ZZCXB> SubItems { get; set; } = new List<ZZCXB>();
+
+
}
}
diff --git a/StandardInterface/MES.Service/Modes/Zzcxb.cs b/StandardInterface/MES.Service/Modes/Zzcxb.cs
index 56d628b..a70d778 100644
--- a/StandardInterface/MES.Service/Modes/Zzcxb.cs
+++ b/StandardInterface/MES.Service/Modes/Zzcxb.cs
@@ -1,43 +1,43 @@
-锘縰sing System;
+锘�// 鏂囦欢: MES.Service.Modes/ZZCXB.cs
using SqlSugar;
namespace MES.Service.Modes
{
/// <summary>
- /// ZZCXB 鏄庣粏琛�
+ /// ZZCXB - 缁勮鎷嗗嵏 瀛欒〃锛堜笌瀛愯〃涓�瀵瑰锛�
/// </summary>
[SugarTable("ZZCXB")]
- public class Zzcxb
+ public class ZZCXB
{
/// <summary>
- /// 涓婚敭ID
+ /// 涓婚敭 ID
/// </summary>
[SugarColumn(ColumnName = "ID", IsPrimaryKey = true, OracleSequenceName = "SEQ_ZZCXB")]
public decimal? Id { get; set; }
/// <summary>
- /// 涓昏〃ID
+ /// 瀵瑰簲瀛愯〃 ID (ZZCXA.ID)
/// </summary>
[SugarColumn(ColumnName = "PID")]
public decimal? Pid { get; set; }
/// <summary>
- /// ERP 涓昏〃id
+ /// ERP 涓昏〃 id锛堝啑浣欙級
/// </summary>
[SugarColumn(ColumnName = "ERPID")]
public string Erpid { get; set; }
/// <summary>
- /// ERP 鍗曟嵁澶磇d
+ /// ERP 瀛愯〃琛� id (EID)
/// </summary>
[SugarColumn(ColumnName = "EID")]
public string Eid { get; set; }
/// <summary>
- /// 鐗╂枡缂栫爜id
+ /// 鐗╂枡缂栫爜 id
/// </summary>
[SugarColumn(ColumnName = "ITEM_ID")]
- public decimal? ItemId { get; set; }
+ public string ItemId { get; set; }
/// <summary>
/// 鏁伴噺
diff --git a/StandardInterface/MES.Service/service/ZZCXDManager.cs b/StandardInterface/MES.Service/service/ZZCXDManager.cs
index ff0136e..ecbfdae 100644
--- a/StandardInterface/MES.Service/service/ZZCXDManager.cs
+++ b/StandardInterface/MES.Service/service/ZZCXDManager.cs
@@ -8,7 +8,7 @@
namespace MES.Service.service
{
- public class ZzcxdManager : Repository<Zzcxa>
+ public class ZzcxManager : Repository<ZZCX>
{
public bool SaveList(List<ERPZZCXD> list)
{
@@ -18,51 +18,50 @@
public bool Save(ERPZZCXD data)
{
- var head = MapErpToMesHead(data.ERPZZCXA);
- var details = MapErpDbckbToDbckb(data.ERPZZCXB);
+ var head = MapErpToMesHead(data.Main);
+ var children = MapErpChildren(data.Children, data.Main.erpid);
return UseTransaction(db =>
{
- switch (data.ERPZZCXA.type)
+ switch (data.Main.type)
{
- case "3":
- return UpdateData(db, head, details) ? 1 : 0;
+ case "3": // 鍒犻櫎 / 绂佺敤
+ return UpdateData(db, head, children) ? 1 : 0;
+
case "2":
case "4":
- case "5":
- return SaveOrUpdateData(db, head, details) ? 1 : 0;
+ case "5": // 鏂板鎴栨洿鏂�
+ return SaveOrUpdateData(db, head, children) ? 1 : 0;
+
default:
- throw new NotImplementedException($"type娌℃湁 {data.ERPZZCXA.type} 杩欎釜绫诲瀷");
+ throw new NotImplementedException($"type 娌℃湁 {data.Main.type} 杩欎釜绫诲瀷");
}
}) > 0;
}
- private Zzcxa MapErpToMesHead(ERPZZCXA dto)
+ private ZZCX MapErpToMesHead(ERPZZCXMain dto)
{
- var entity = new Zzcxa
+ var entity = new ZZCX
{
- BillNo = dto.bill_no, // 鍗曟嵁缂栫爜
- DjLx = dto.dj_lx, // 鍗曟嵁绫诲瀷
- KcZz = dto.kc_zz, // 搴撳瓨缁勭粐
- SwLx = dto.sw_lx, // 浜嬪姟绫诲瀷
- Time = dto.time , // 鏃ユ湡
- Bm = dto.bm, // 閮ㄩ棬
- Cgy = dto.cgy, // 浠撶鍛�
- Kcz = dto.kcz, // 搴撳瓨缁�
- DjZt = dto.dj_zt, // 鍗曟嵁鐘舵��
- Memo = dto.memo, // 澶囨敞
- Cphzlx = dto.cphzlx, // 鎴愬搧璐т富绫诲瀷
- Cphz = dto.cphz, // 鎴愬搧璐т富
- Zjhzlx = dto.zjhzlx, // 瀛愪欢璐т富绫诲瀷
- Zjhz = dto.zjhz, // 瀛愪欢璐т富
- ItemId = string.IsNullOrEmpty(dto.item_id) ? null : Convert.ToDecimal(dto.item_id), // 鐗╂枡缂栫爜id
- Qty = string.IsNullOrEmpty(dto.qty) ? null : Convert.ToDecimal(dto.qty), // 鏁伴噺
- Unit = dto.unit, // 鍗曚綅
- DepotId = dto.depot_id, // 浠撳簱
- Erpid = dto.erpid // ERP 涓昏〃id
+ BillNo = dto.bill_no, // 鍗曟嵁缂栫爜
+ Erpid = dto.erpid , // ERP 涓昏〃 ID
+ DjLx = dto.dj_lx,
+ KcZz = dto.kc_zz,
+ SwLx = dto.sw_lx,
+ // Time = string.IsNullOrEmpty(dto.time) ? (DateTime?)null : DateTime.Parse(dto.time),
+ Time = dto.time,
+ Bm = dto.bm,
+ Cgy = dto.cgy,
+ Kcz = dto.kcz,
+ DjZt = dto.dj_zt,
+ Memo = dto.memo,
+ Cphzlx = dto.cphzlx,
+ Cphz = dto.cphz,
+ Zjhzlx = dto.zjhzlx,
+ Zjhz = dto.zjhz,
};
- var single = Db.Queryable<Zzcxa>()
+ var single = Db.Queryable<ZZCX>()
.Where(it => it.Erpid == entity.Erpid)
.First();
if (single != null)
@@ -71,41 +70,78 @@
return entity;
}
- private List<Zzcxb> MapErpDbckbToDbckb(List<ERPZZCXB> list)
+ private List<ZZCXA> MapErpChildren(List<ERPZZCXA> list, string mainErpId)
{
- var result = new List<Zzcxb>();
+ var result = new List<ZZCXA>();
foreach (var dto in list)
{
- var item = new Zzcxb
+ var item = new ZZCXA
{
- Erpid = dto.erpid, // ERP 涓昏〃id
- Eid = dto.eid, // ERP 鍗曟嵁澶磇d
- ItemId = string.IsNullOrEmpty(dto.item_id) ? null : Convert.ToDecimal(dto.item_id), // 鐗╂枡缂栫爜id
- Qty = string.IsNullOrEmpty(dto.qty) ? null : Convert.ToDecimal(dto.qty), // 鏁伴噺
- Unit = dto.unit, // 鍗曚綅
- DepotId = dto.depot_id, // 浠撳簱
- LotNo = dto.lot_no, // 鎵瑰彿
- Memo = dto.memo // 澶囨敞
+ Erpid = dto.erpid,
+ /* BillNo = dto.bill_no,
+ DjLx = dto.dj_lx,
+ KcZz = dto.kc_zz,
+ SwLx = dto.sw_lx,
+ // Time = string.IsNullOrEmpty(dto.time) ? (DateTime?)null : DateTime.Parse(dto.time),
+ Time = dto.time,
+ Bm = dto.bm,
+ Cgy = dto.cgy,
+ Kcz = dto.kcz,
+ DjZt = dto.dj_zt,
+ Memo = dto.memo,
+ Cphzlx = dto.cphzlx,
+ Cphz = dto.cphz,
+ Zjhzlx = dto.zjhzlx,
+ Zjhz = dto.zjhz,*/
+ ItemId = dto.item_id,
+ Qty = string.IsNullOrEmpty(dto.qty) ? (decimal?)null : Convert.ToDecimal(dto.qty),
+ Unit = dto.unit,
+ DepotId = dto.depot_id,
+ YdId = mainErpId
};
- var existing = Db.Queryable<Zzcxb>().Where(s => s.Erpid == item.Erpid).Single();
+ var existing = Db.Queryable<ZZCXA>().Where(s => s.Erpid == item.Erpid).Single();
if (existing != null) item.Id = existing.Id;
result.Add(item);
+
+ // 瀛欒〃澶勭悊
+ if (dto.SubItems != null && dto.SubItems.Count > 0)
+ {
+ foreach (var subDto in dto.SubItems)
+ {
+ var subEntity = new ZZCXB
+ {
+ Eid = subDto.eid,
+ ItemId = subDto.item_id,
+ Qty = string.IsNullOrEmpty(subDto.qty) ? (decimal?)null : Convert.ToDecimal(subDto.qty),
+ Unit = subDto.unit,
+ DepotId = subDto.depot_id,
+ LotNo = subDto.lot_no,
+ Memo = subDto.memo,
+ Erpid = mainErpId
+ };
+
+ var existingSub = Db.Queryable<ZZCXB>().Where(s => s.Eid == subEntity.Eid).Single();
+ if (existingSub != null) subEntity.Id = existingSub.Id;
+
+ item.SubItems ??= new List<ZZCXB>();
+ item.SubItems.Add(subEntity);
+ }
+ }
}
return result;
}
- private bool SaveOrUpdateData(SqlSugarScope db, Zzcxa head, List<Zzcxb> details)
+ private bool SaveOrUpdateData(SqlSugarScope db, ZZCX head, List<ZZCXA> children)
{
if (head.Id != null)
base.DeleteById(head.Id);
- db.Deleteable<Zzcxb>()
- .Where(d => d.Eid == head.Erpid)
- .ExecuteCommand();
+ db.Deleteable<ZZCXA>().Where(d => d.YdId == head.Erpid).ExecuteCommand();
+ db.Deleteable<ZZCXB>().Where(d => d.Erpid == head.Erpid).ExecuteCommand();
var insertedHead = db.Insertable(head)
.IgnoreColumns(true)
@@ -113,23 +149,59 @@
if (insertedHead <= 0)
throw new Exception("涓昏〃鎻掑叆澶辫触锛屾湭杩斿洖ID");
- var success = db.Insertable(details)
- .PageSize(10)
- .IgnoreColumnsNull()
- .ExecuteCommand() > 0;
+ foreach (var child in children)
+ {
+ child.Pid = insertedHead;
+ var childId = db.Insertable(child).IgnoreColumns(true).ExecuteReturnIdentity();
- if (insertedHead >= 0 && success) return true;
- throw new NotImplementedException("鎻掑叆鎴栨洿鏂板け璐�");
+ if (child.SubItems != null && child.SubItems.Count > 0)
+ {
+ foreach (var sub in child.SubItems)
+ {
+ sub.Pid = childId;
+ db.Insertable(sub).IgnoreColumns(true).ExecuteCommand();
+ }
+ }
+ }
+
+ return true;
}
- private bool UpdateData(SqlSugarScope db, Zzcxa head, List<Zzcxb> details)
+ /* private bool UpdateData(SqlSugarScope db, ZZCX head, List<ZZCXA> children)
+ {
+ // 鍒犻櫎涓昏〃 & 瀛愬瓩琛�
+ var deletedHead = base.DeleteById(head.Id);
+ var deletedChildren = db.Deleteable<ZZCXA>().Where(d => d.YdId == head.Erpid).ExecuteCommand();
+ var deletedGrand = db.Deleteable<ZZCXB>().Where(d => d.Erpid == head.Erpid).ExecuteCommand();
+
+ if (deletedHead && deletedChildren >= 0 && deletedGrand >= 0) return true;
+ throw new NotImplementedException("鍒犻櫎澶辫触");
+ }*/
+
+ private bool UpdateData(SqlSugarScope db, ZZCX head, List<ZZCXA> children)
{
- var ids = details.Select(d => d.Id).ToArray();
- var deletedHead = base.DeleteById(head.Id);
- var deletedDetails = db.Deleteable<Zzcxb>().In(ids).ExecuteCommand() > 0;
+ // 鍒犻櫎涓昏〃
+ var deletedHead = db.Deleteable<ZZCX>()
+ .Where(d => d.Erpid == head.Erpid)
+ .ExecuteCommand();
- if (deletedHead && deletedDetails) return true;
- throw new NotImplementedException("鏇存柊澶辫触");
+ // 鍒犻櫎瀛愯〃
+ var deletedChildren = db.Deleteable<ZZCXA>()
+ .Where(d => d.YdId == head.Erpid)
+ .ExecuteCommand();
+
+ // 鍒犻櫎瀛欒〃
+ var deletedGrand = db.Deleteable<ZZCXB>()
+ .Where(d => d.Erpid == head.Erpid)
+ .ExecuteCommand();
+
+ // 濡傛灉涓昏〃娌″垹鍒拌褰曪紝涔熻涓哄厑璁革紙鍙兘涔嬪墠灏变笉瀛樺湪锛�
+ if (deletedHead >= 0 && deletedChildren >= 0 && deletedGrand >= 0)
+ return true;
+
+ throw new NotImplementedException("鍒犻櫎澶辫触");
}
+
+
}
}
diff --git a/StandardInterface/MESApplication/Controllers/ZZCXDController.cs b/StandardInterface/MESApplication/Controllers/ZZCXDController.cs
index 96fe204..168709f 100644
--- a/StandardInterface/MESApplication/Controllers/ZZCXDController.cs
+++ b/StandardInterface/MESApplication/Controllers/ZZCXDController.cs
@@ -2,28 +2,27 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
-using MES.Service.service;
using MES.Service.Dto.webApi;
using MES.Service.util;
using Newtonsoft.Json;
using MES.Service.Modes;
+using MES.Service.service;
namespace MESApplication.Controllers
{
[ApiController]
[Route("api/[controller]")]
- public class ZZCXDController : ControllerBase
+ public class ZzcxController : ControllerBase
{
- private readonly ZzcxdManager _manager = new(); // 杩欓噷瀵瑰簲鏂扮殑 Service
+ private readonly ZzcxManager _manager = new();
private readonly MessageCenterManager _messageManager = new();
private const string METHOD = "POST";
- private const string TableName = "ZZCXD";
- private const string URL = "http://localhost:10054/api/ERPZZCXD/";
+ private const string TableName = "ZZCX";
+ private const string URL = "http://localhost:10054/api/Zzcx/";
- /// <summary>
- /// 淇濆瓨鍗曟潯璋冩嫧鍗�
- /// </summary>
+
+
[HttpPost("Save")]
public ResponseResult Save([FromBody] ERPZZCXD data)
{
@@ -35,7 +34,7 @@
Data = JsonConvert.SerializeObject(data),
Status = 1,
CreateBy = "PL017",
- Route = data.ERPZZCXA.bill_no // 娉ㄦ剰鍙� billno
+ Route = data.Main.bill_no
};
try
@@ -61,9 +60,6 @@
}
}
- /// <summary>
- /// 鎵归噺淇濆瓨璋冩嫧鍗�
- /// </summary>
[HttpPost("SaveList")]
public ResponseResult SaveList([FromBody] List<ERPZZCXD> dataList)
{
--
Gitblit v1.9.3