sjz
2025-07-28 f1deb7b024e17cba204de5fcb0dac15801436b90
MES.Service/service/WomcaaWWManager.cs
@@ -2,8 +2,6 @@
using MES.Service.Dto.webApi;
using MES.Service.Modes;
using SqlSugar;
using System;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace MES.Service.service;
@@ -15,8 +13,8 @@
    private readonly WomcabManager _womcabWWManager = new();
    private decimal?[] decimals;
    private bool update;
    private bool insertOrUpdate;
    private bool update;
    public bool SaveList(List<ErpWOM> rohIns)
    {
@@ -39,27 +37,27 @@
                case "1":
                case "2":
                case "4":
                    return SaveOrUpdateDataWw(db, mesWomcaa, mesWomcabs) ? 1 : 0;
                    return SaveOrUpdateDataWw(db, mesWomcaa, mesWomcabs)
                        ? 1
                        : 0;
                case "5":
                    return UpdateData(db, mesWomcaa, mesWomcabs) ? 1 : 0;
                default:
                    throw new NotImplementedException(
                        $"type没有{womErpCaa.Type}这个类型");
                    throw new NotImplementedException($"type没有{womErpCaa.Type}这个类型");
            }
        }) > 0;
    }
    private bool UpdateData(SqlSugarScope db, Womcaa mesWomcaa, List<Womcab> mesWomcabs)
    private bool UpdateData(SqlSugarScope db, Womcaa mesWomcaa,List<Womcab> mesWomcabs)
    {
        if (mesWomcaa.Id != null)
        {
            base.DeleteById(mesWomcaa.Id);
        }
        if (mesWomcaa.Id != null) base.DeleteById(mesWomcaa.Id);
        if (mesWomcabs.Count > 0)
        {
            db.Deleteable<Womcab>().Where(s => s.Eid == mesWomcaa.Erpid).ExecuteCommand();
        }
        var orUpdate = base.Insert(mesWomcaa);
        var baOrUpdate = _womcabWWManager.InsertRange(mesWomcabs);
        db.Ado.CommitTran();
        if (orUpdate && baOrUpdate)
        {
            //定义输入参数
@@ -68,24 +66,25 @@
            var outParam1 = new SugarParameter("c_Result", null, true);
            var outParam2 = new SugarParameter("C_MSG", null, true);
            // 使用 SqlSugar 执行存储过程
            Db.Ado.ExecuteCommand("BEGIN PRC_UPDATE_DAA(:P_WORK_NO,:c_Result,:C_MSG); END;", inputParam1, outParam1, outParam2);
            Db.Ado.ExecuteCommand("BEGIN PRC_UPDATE_DAA(:P_WORK_NO,:c_Result,:C_MSG); END;",inputParam1, outParam1, outParam2);
            // 获取输出参数的值
            int result = int.Parse((string)outParam1.Value);
            string message = outParam2.Value == DBNull.Value ? string.Empty : (string)outParam2.Value;
            var result = int.Parse((string)outParam1.Value);
            var message = outParam2.Value == DBNull.Value ? string.Empty : (string)outParam2.Value;
            if (result == 1)
            {
                //存储过程失败则事务进行回滚
                db.Ado.RollbackTran();
                //db.Ado.RollbackTran();
                throw new Exception(message);
            }
            // 提交事务
            db.Ado.CommitTran();
            //db.Ado.CommitTran();
            return true;
        }
        throw new NotImplementedException("插入或更新失败");
    }
    private bool SaveOrUpdateDataWw(SqlSugarScope db, Womcaa mesWomcaa, List<Womcab> mesWomcabss)
    private bool SaveOrUpdateDataWw(SqlSugarScope db, Womcaa mesWomcaa,List<Womcab> mesWomcabss)
    {
        if (mesWomcaa.Id != null)
        {
@@ -97,7 +96,7 @@
        }
        var orUpdate = base.Insert(mesWomcaa);
        var baOrUpdate = _womcabWWManager.InsertRange(mesWomcabss);
        db.Ado.CommitTran();
        if (orUpdate && baOrUpdate)
        {
            //定义输入参数
@@ -106,18 +105,18 @@
            var outParam1 = new SugarParameter("c_Result", null, true);
            var outParam2 = new SugarParameter("C_MSG", null, true);
            // 使用 SqlSugar 执行存储过程
            Db.Ado.ExecuteCommand("BEGIN PRC_UPDATE_DAA(:P_WORK_NO,:c_Result,:C_MSG); END;", inputParam1, outParam1, outParam2);
            Db.Ado.ExecuteCommand("BEGIN PRC_UPDATE_DAA(:P_WORK_NO,:c_Result,:C_MSG); END;",inputParam1, outParam1, outParam2);
            // 获取输出参数的值
            int result = int.Parse((string)outParam1.Value);
            string message = outParam2.Value == DBNull.Value ? string.Empty : (string)outParam2.Value;
            var result = int.Parse((string)outParam1.Value);
            var message = outParam2.Value == DBNull.Value ? string.Empty : (string)outParam2.Value;
            if (result == 1)
            {
                //存储过程失败则事务进行回滚
                db.Ado.RollbackTran();
                //db.Ado.RollbackTran();
                throw new Exception(message);
            }
            // 提交事务
            db.Ado.CommitTran();
            //db.Ado.CommitTran();
            return true;
        }
@@ -137,7 +136,11 @@
            update = true;
            insertOrUpdate = true;
        }
        if (update && insertOrUpdate) return true;
        if (update && insertOrUpdate)
        {
            return true;
        }
        throw new NotImplementedException("更新失败");
    }
@@ -168,7 +171,7 @@
            Caa023 = dto.FStatus,
            Caa024 = 0,
            RoutingId = dto.FRoutingId,
            WorkShopId = dto.FREMWorkShopId,
            WorkShopId = dto.FremWorkShopId,
            DepotCode = dto.FStockId,
            CreateDate = dto.FDate,
            WorkGroupId = dto.FWorkGroupId,
@@ -188,8 +191,8 @@
            SrcSplitBillno = dto.FSrcSplitBillNo,
            F_ZSXG_KH = dto.F_ZJXF_BASE_KH,
            F_ZJXF_YHRQ = dto.F_ZJXF_DATETIME_YHRQ,
            PrdOrg = dto.erP_SCZZ,
            TrustOrg = dto.erP_WTZZ,
            PrdOrg = dto.ErpRkhz,  //入库货主
            TrustOrg = dto.ErpRkzz, //入库组织
            TbTime = DateTime.Now,
            JaBs = "0",
            FPURORDERNO = dto.FPurOrderNo,
@@ -201,13 +204,9 @@
            FinishedProduct = dto.FinishedProduct
        };
        if (dto.Type == "5")
        {
            entity.IsXg = 1;
        }
        else
        {
            entity.IsXg = 0;
        }
        if (dto.FStatus == "6" || dto.FStatus == "7")
        {
@@ -216,7 +215,10 @@
        }
        var single = base.GetSingle(it => it.Erpid == entity.Erpid);
        if (single != null) entity.Id = single.Id;
        if (single != null)
        {
            entity.Id = single.Id;
        }
        return entity;
    }
@@ -252,11 +254,14 @@
                Denominator = Convert.ToDecimal(dto.FDenominator),
                SCRAPQTY = Convert.ToDecimal(dto.FFixScrapQty),
                SCRAPRATE = Convert.ToDecimal(dto.FScrapRate),
                SalesOrder = dto.FXSHTBH,
                SalesOrder = dto.F_WWC_TEXT
            };
            var entity = Db.Queryable<Womcab>().Where(s => s.Erpid == womcab.Erpid).Single();
            if (entity != null) womcab.Id = entity.Id;
            if (entity != null)
            {
                womcab.Id = entity.Id;
            }
            womcabList.Add(womcab);
        }