hao
2025-09-18 4598e856759f043f203d45a0674626b9e2ff89b8
组装拆卸
已修改6个文件
220 ■■■■■ 文件已修改
StandardInterface/MES.Service/Dto/webApi/ERPZZCXD.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/Modes/ZZCX.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/Modes/Zzcxa.cs 105 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/Modes/Zzcxb.cs 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/service/ZZCXDManager.cs 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MESApplication/appsettings.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardInterface/MES.Service/Dto/webApi/ERPZZCXD.cs
@@ -25,7 +25,7 @@
    public class ERPZZCXMain
    {
        public string? erpid { get; set; }     // ERP 主表id(主表的 ERPID)
        public string? bill_no { get; set; }   // 单据编码
        public string bill_no { get; set; }   // 单据编码
        public string? type { get; set; }   //  
        public string? dj_lx { get; set; }       // 单据类型
        public string? kc_zz { get; set; }       // 库存组织
@@ -91,5 +91,6 @@
        public string? depot_id { get; set; }  // 仓库
        public string? lot_no { get; set; }    // 批号
        public string? memo { get; set; }      // 备注
        public string? yd_id { get; set; }      // 备注
    }
}
StandardInterface/MES.Service/Modes/ZZCX.cs
@@ -1,5 +1,4 @@
// 文件: MES.Service.Modes/ZZCX.cs
using System;
using SqlSugar;
namespace MES.Service.Modes
@@ -11,7 +10,7 @@
    public class ZZCX
    {
        /// <summary>
        /// 主键 ID
        /// 主键 ID(Oracle 序列)
        /// </summary>
        [SugarColumn(ColumnName = "ID", IsPrimaryKey = true, OracleSequenceName = "SEQ_ZZCX")]
        public decimal? Id { get; set; }
@@ -20,18 +19,19 @@
        /// ERP 主表 ID
        /// </summary>
        [SugarColumn(ColumnName = "ERPID")]
        public string Erpid { get; set; }
        public decimal? Erpid { get; set; }
        /// <summary>
        /// 单据编码
        /// </summary>
        [SugarColumn(ColumnName = "BILL_NO")]
        public string BillNo { get; set; }
        /// <summary>
        /// 单据编码
        /// 类型
        /// </summary>
        [SugarColumn(ColumnName = "TYPE")]
        public string Type { get; set; }
        public string Type { get; set; }
        /// <summary>
        /// 单据类型
StandardInterface/MES.Service/Modes/Zzcxa.cs
@@ -1,38 +1,38 @@
// 文件: MES.Service.Modes/ZZCXA.cs
using System;
using SqlSugar;
using System.Collections.Generic;
namespace MES.Service.Modes
{
    /// <summary>
    /// ZZCXA - 组装拆卸 子表(之前的 ZZCXA 字段集合),新增 YD_ID 字段来记录主表 ERPID
    /// ZZCXA - 组装拆卸 子表
    /// </summary>
    [SugarTable("ZZCXA")]
    public class ZZCXA
    {
        /// <summary>
        /// 主键 ID
        /// 主键 ID(Oracle 序列)
        /// </summary>
        [SugarColumn(ColumnName = "ID", IsPrimaryKey = true, OracleSequenceName = "SEQ_ZZCXA")]
        public decimal? Id { get; set; }
        /// <summary>
        /// 父表 ID (对应 ZZCX.ID) —— 可用于关系查询
        /// 父表 ID (对应 ZZCX.ID)
        /// </summary>
        [SugarColumn(ColumnName = "PID")]
        public decimal? Pid { get; set; }
        /// <summary>
        /// YD_ID:写入主表的 ERPID(你要求:子表的 yd_id 存主表的 erpid)
        /// YD_ID:写入主表的 ERPID
        /// </summary>
        [SugarColumn(ColumnName = "YD_ID")]
        public string YdId { get; set; }
        public decimal? YdId { get; set; }
        /// <summary>
        /// ERP 子表/行 id(erpid/eid 等 ERP 行标识)
        /// ERP 子表 ID
        /// </summary>
        [SugarColumn(ColumnName = "ERPID")]
        public string Erpid { get; set; }
        public decimal? Erpid { get; set; }
        /// <summary>
        /// 单据编码
@@ -41,88 +41,10 @@
        public string BillNo { 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; }
        /// <summary>
        /// 物料编码 id
        /// 物料编码 ID
        /// </summary>
        [SugarColumn(ColumnName = "ITEM_ID")]
        public string ItemId { get; set; }
        public decimal? ItemId { get; set; }
        /// <summary>
        /// 数量
@@ -137,11 +59,14 @@
        public string Unit { get; set; }
        /// <summary>
        /// 仓库
        /// 仓库 ID
        /// </summary>
        [SugarColumn(ColumnName = "DEPOT_ID")]
        public string DepotId { get; set; }
        public decimal? DepotId { get; set; }
        /// <summary>
        /// 孙表集合
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public List<ZZCXB> SubItems { get; set; } = new List<ZZCXB>();
StandardInterface/MES.Service/Modes/Zzcxb.cs
@@ -4,13 +4,13 @@
namespace MES.Service.Modes
{
    /// <summary>
    /// ZZCXB - 组装拆卸 孙表(与子表一对多)
    /// ZZCXB - 组装拆卸 孙表
    /// </summary>
    [SugarTable("ZZCXB")]
    public class ZZCXB
    {
        /// <summary>
        /// 主键 ID
        /// 主键 ID(Oracle 序列)
        /// </summary>
        [SugarColumn(ColumnName = "ID", IsPrimaryKey = true, OracleSequenceName = "SEQ_ZZCXB")]
        public decimal? Id { get; set; }
@@ -22,22 +22,28 @@
        public decimal? Pid { get; set; }
        /// <summary>
        /// ERP 主表 id(冗余)
        /// ERP 主表 ID(冗余)
        /// </summary>
        [SugarColumn(ColumnName = "ERPID")]
        public string Erpid { get; set; }
        public decimal? Erpid { get; set; }
        /// <summary>
        /// ERP 子表行 id (EID)
        /// YD_ID:主表 ERPID(冗余)
        /// </summary>
        [SugarColumn(ColumnName = "YD_ID")]
        public decimal? YdId { get; set; }
        /// <summary>
        /// ERP 子表行 ID (EID)
        /// </summary>
        [SugarColumn(ColumnName = "EID")]
        public string Eid { get; set; }
        public decimal? Eid { get; set; }
        /// <summary>
        /// 物料编码 id
        /// 物料编码 ID
        /// </summary>
        [SugarColumn(ColumnName = "ITEM_ID")]
        public string ItemId { get; set; }
        public decimal? ItemId { get; set; }
        /// <summary>
        /// 数量
@@ -52,10 +58,10 @@
        public string Unit { get; set; }
        /// <summary>
        /// 仓库
        /// 仓库 ID
        /// </summary>
        [SugarColumn(ColumnName = "DEPOT_ID")]
        public string DepotId { get; set; }
        public decimal? DepotId { get; set; }
        /// <summary>
        /// 批号
StandardInterface/MES.Service/service/ZZCXDManager.cs
@@ -44,8 +44,9 @@
            var entity = new ZZCX
            {
                BillNo = dto.bill_no,   // 单据编码
                Erpid = dto.erpid ,      // ERP 主表 ID
                 DjLx = dto.dj_lx,
                Erpid = string.IsNullOrEmpty(dto.erpid) ? (decimal?)null : Convert.ToDecimal(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),
@@ -78,27 +79,28 @@
            {
                var item = new ZZCXA
                {
                    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,
                       /*   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,*/
                    Erpid = string.IsNullOrEmpty(dto.erpid) ? (decimal?)null : Convert.ToDecimal(dto.erpid),
                    YdId = string.IsNullOrEmpty(dto.yd_id) ? (decimal?)null : Convert.ToDecimal(dto.yd_id),
                    ItemId = string.IsNullOrEmpty(dto.item_id) ? (decimal?)null : Convert.ToDecimal(dto.item_id),
                    Qty = string.IsNullOrEmpty(dto.qty) ? (decimal?)null : Convert.ToDecimal(dto.qty),
                    Unit = dto.unit,
                    DepotId = dto.depot_id,
                    YdId = mainErpId
                    DepotId = string.IsNullOrEmpty(dto.depot_id) ? (decimal?)null : Convert.ToDecimal(dto.depot_id)
                };
                var existing = Db.Queryable<ZZCXA>().Where(s => s.Erpid == item.Erpid).Single();
@@ -113,14 +115,15 @@
                    {
                        var subEntity = new ZZCXB
                        {
                            Eid = subDto.eid,
                            ItemId = subDto.item_id,
                            Eid = string.IsNullOrEmpty(subDto.eid) ? (decimal?)null : Convert.ToDecimal(subDto.eid),
                            Erpid = string.IsNullOrEmpty(subDto.erpid) ? (decimal?)null : Convert.ToDecimal(subDto.erpid),
                            YdId = string.IsNullOrEmpty(subDto.yd_id) ? (decimal?)null : Convert.ToDecimal(subDto.yd_id),
                            ItemId = string.IsNullOrEmpty(subDto.item_id) ? (decimal?)null : Convert.ToDecimal(subDto.item_id),
                            Qty = string.IsNullOrEmpty(subDto.qty) ? (decimal?)null : Convert.ToDecimal(subDto.qty),
                            Unit = subDto.unit,
                            DepotId = subDto.depot_id,
                            DepotId = string.IsNullOrEmpty(subDto.depot_id) ? (decimal?)null : Convert.ToDecimal(subDto.depot_id),
                            LotNo = subDto.lot_no,
                            Memo = subDto.memo,
                            Erpid = mainErpId
                            Memo = subDto.memo
                        };
                        var existingSub = Db.Queryable<ZZCXB>().Where(s => s.Eid == subEntity.Eid).Single();
@@ -137,6 +140,15 @@
        private bool SaveOrUpdateData(SqlSugarScope db, ZZCX head, List<ZZCXA> children)
        {
            // 1. 校验是否存在领料记录(MES_INV_ITEM_OUTS)
            var hasMaterialOut = db.Queryable<MesInvItemOuts>()
                                   .Any(x => x.WorkNo == head.BillNo);
            if (hasMaterialOut)
            {
                throw new Exception($"MES已有领料记录,单号:{head.BillNo},不能更新!");
            }
            if (head.Id != null)
                base.DeleteById(head.Id);
@@ -180,6 +192,16 @@
        private bool UpdateData(SqlSugarScope db, ZZCX head, List<ZZCXA> children)
        {
            // 1. 校验是否存在领料记录(MES_INV_ITEM_OUTS)
            var hasMaterialOut = db.Queryable<MesInvItemOuts>()
                                   .Any(x => x.WorkNo == head.BillNo);
            if (hasMaterialOut)
            {
                throw new Exception($"MES已有领料记录,单号:{head.BillNo},不能删除!");
            }
            // 删除主表
            var deletedHead = db.Deleteable<ZZCX>()
                                .Where(d => d.Erpid == head.Erpid)
StandardInterface/MESApplication/appsettings.json
@@ -10,6 +10,6 @@
  "AppSettings": {
    "TestErpUrl": "http://192.168.11.120:8098/WebService1.asmx/mesToErpinfo",
    "ProductionErpUrl": "http://192.168.11.120:8098/WebService1.asmx/mesToErpinfoFormal",
    "DataBaseConn": "Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ORCL))); Persist Security Info=True;User ID = hm_prd; Password=hmprd"
    "DataBaseConn": "Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ORCL))); Persist Security Info=True;User ID = test_dev; Password=hmprd"
  }
}