wbc
6 天以前 e19f8a13e2b35e6836ce46c17402c44327814a00
WebApi/Gs.Wom/Service/WompbaGxManager.cs
@@ -19,7 +19,6 @@
    private readonly IHttpContextAccessor _http;
    private readonly string _userCode, _userGuid, _orgFids;
    public WompbaGxManager(IHttpContextAccessor httpContextAccessor)
    {
        _http = httpContextAccessor;
@@ -82,7 +81,7 @@
        {
            LogHelper.Debug(ToString(), ex.Message);
            return ReturnDto<PageList<dynamic>>.QuickReturn(_pglist,
                ReturnCode.Exception, ex.Message);
          ReturnCode.Exception, ex.Message);
        }
        return ReturnDto<PageList<dynamic>>.QuickReturn(_pglist,
@@ -112,8 +111,7 @@
        var dset = new DataSet();
        try
        {
            dset = DbHelperSQL.RunProcedure("[prc_wom_pbagx_mx]", parameters,
                "0");
            dset = DbHelperSQL.RunProcedure("[prc_wom_pbagx_mx]", parameters, "0");
            if (dset != null && dset.Tables.Count > 0 &&
                dset.Tables[0].Rows.Count > 0)
            {
@@ -145,8 +143,8 @@
        Guid? guid = model.guid; //主键
        string bz = model.bz; //备注
        string cjId = model.cjId; //车间
        var cxId = ""; //产线,用不到了
        var jhrs = ""; //计划人数,用不到了
        string cxId = ""; //产线,用不到了
        string jhrs = ""; //计划人数,用不到了
        var _sb = new StringBuilder();
        var _split = "|";
        foreach (var m in model.list)
@@ -169,7 +167,6 @@
                _sb.Append("~");
            _sb.Append(_line);
        }
        dynamic mObj = new ExpandoObject();
        mObj.outMsg = "";
        mObj.outSum = -1;
@@ -189,8 +186,7 @@
                        new("@outSum", SqlDbType.Int),
                        new("@outGuid", SqlDbType.UniqueIdentifier),
                        new("@outNo", SqlDbType.NVarChar, 300),
                        new("@inOrderGuid",
                            CheckGuid(guid) ? guid : DBNull.Value),
                        new("@inOrderGuid", CheckGuid(guid) ? guid : DBNull.Value),
                        new("@inBz", bz),
                        new("@inCjId", cjId),
                        new("@inCxId", cxId),
@@ -223,12 +219,9 @@
                }
            }
        }
        if (mObj.outSum <= 0)
            return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception,
                mObj.outMsg);
        return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success,
            mObj.outMsg);
            return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Exception, mObj.outMsg);
        return ReturnDto<dynamic>.QuickReturn(mObj, ReturnCode.Success, mObj.outMsg);
    }
@@ -246,16 +239,16 @@
        string keyWhere = model.Paging.keyWhere;
        string itemid = model.ItemInfo.itemid;
        SqlParameter[] parameters =
        {
            new("@inCurrentPage", currentPage),
            new("@inEveryPageSize", everyPageSize),
            new("@inSortName", sortName),
            new("@inSortOrder", ""),
            new("@inQueryWhere", keyWhere),
            new("@itemID", itemid),
            new("@inP1", ""),
            new("@inP2", "")
        };
                  {
                        new("@inCurrentPage", currentPage),
                        new("@inEveryPageSize", everyPageSize),
                        new("@inSortName", sortName),
                        new("@inSortOrder", ""),
                        new("@inQueryWhere", keyWhere),
                        new("@itemID", itemid),
                        new("@inP1", ""),
                        new("@inP2", "")
                    };
        var dset = new DataSet();
        var _pglist = new PageList<dynamic>
        {
@@ -266,10 +259,9 @@
        };
        try
        {
            dset = DbHelperSQL.RunProcedure("prc_wom_pba_selectGX", parameters,
                "0");
            dset = DbHelperSQL.RunProcedure("prc_wom_pba_selectGX", parameters, "0");
            if (dset != null && dset.Tables.Count > 0 &&
                dset.Tables[0].Rows.Count > 0) //有数据
                    dset.Tables[0].Rows.Count > 0) //有数据
            {
                var intTotal =
                    int.Parse(dset.Tables[1].Rows[0]["intTotal"].ToString());
@@ -287,12 +279,13 @@
        {
            LogHelper.Debug(ToString(), ex.Message);
            return ReturnDto<PageList<dynamic>>.QuickReturn(_pglist,
                ReturnCode.Exception, ex.Message);
          ReturnCode.Exception, ex.Message);
        }
        return ReturnDto<PageList<dynamic>>.QuickReturn(_pglist,
            ReturnCode.Success, "读取成功");
    }
    /// <summary>
@@ -341,10 +334,8 @@
        }
        catch (Exception ex)
        {
            LogHelper.Debug(ToString(),
                "prc_wom_pba_select error:" + ex.Message);
            return ReturnDto<PageList<dynamic>>.QuickReturn(
                default(PageList<dynamic>), ReturnCode.Exception, "读取失败");
            LogHelper.Debug(ToString(), "prc_wom_pba_select error:" + ex.Message);
            return ReturnDto<PageList<dynamic>>.QuickReturn(default(PageList<dynamic>), ReturnCode.Exception, "读取失败");
        }
        var _pglist = new PageList<dynamic>
@@ -497,7 +488,7 @@
    /// <summary>
    ///     审核
    ///   审核
    /// </summary>
    /// <param name="mode"></param>
    /// <returns></returns>
@@ -553,7 +544,7 @@
    }
    /// <summary>
    ///     反审核
    ///   反审核
    /// </summary>
    /// <param name="mode"></param>
    /// <returns></returns>
@@ -578,7 +569,7 @@
                        new("@outMsg", SqlDbType.NVarChar, 300),
                        new("@outSum", SqlDbType.Int),
                        new("@inEdtUserGuid", _userGuid),
                        new("@PI_ID", _guid)
                        new("@PI_ID", _guid),
                        //new("@inFieldValue", 1),
                        //new("@in1", ""),
                        //new("@in2", "")
@@ -605,7 +596,116 @@
                }
            }
        }
        return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "操作成功!");
    }
    /// <summary>
    /// 批量处理明细数据
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    [RequestMethod(RequestMethods.POST)]
    public ReturnDto<ExpandoObject> BatchProcessDetails([FromBody] dynamic model)
    {
        dynamic result = new ExpandoObject();
        result.outSum = 0;
        result.outMsg = "";
        try
        {
            // 获取请求参数
            string operatorGuid = model.operatorGuid?.ToString() ?? "";
            string operationType = model.operationType?.ToString() ?? "BatchProcess";
            var selectedDetails = model.selectedDetails;
            if (selectedDetails == null)
            {
                result.outMsg = "未接收到要处理的明细数据!";
                return ReturnDto<ExpandoObject>.QuickReturn(result, ReturnCode.Default, result.outMsg);
            }
            // 构建明细数据字符串,用于传递给存储过程
            var _sb = new StringBuilder();
            var _split = "|";
            int processCount = 0;
            foreach (var detail in selectedDetails)
            {
                string detailGuid = detail.guid?.ToString() ?? "";
                string daa002 = detail.daa002?.ToString() ?? "";
                string daa003 = detail.daa003?.ToString() ?? "";
                string daa005 = detail.daa005?.ToString() ?? "";
                string daa010 = detail.daa010?.ToString() ?? "";
                // 验证必要字段
                if (string.IsNullOrEmpty(detailGuid))
                    continue;
                // 构建明细行数据字符串
                var _line = detailGuid + _split
                           + daa002 + _split
                           + daa003 + _split
                           + daa005 + _split
                           + daa010 + _split
                           + operationType + _split
                           + _userCode + _split
                           + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (_sb.Length > 0)
                    _sb.Append("~");
                _sb.Append(_line);
                processCount++;
            }
            if (processCount == 0)
            {
                result.outMsg = "没有有效的明细数据需要处理!";
                return ReturnDto<ExpandoObject>.QuickReturn(result, ReturnCode.Default, result.outMsg);
            }
            // 调用存储过程进行批量处理
            SqlParameter[] parameters =
            {
            new("@inOperatorGuid", operatorGuid),
            new("@inOperationType", operationType),
            new("@inDetailsData", _sb.ToString()),
            new("@inUserCode", _userCode),
            new("@inUserGuid", _userGuid),
            new("@inOrgFids", _orgFids),
            new("@outSum", SqlDbType.Int) { Direction = ParameterDirection.Output },
            new("@outMsg", SqlDbType.NVarChar, 500) { Direction = ParameterDirection.Output }
        };
            var dset = new DataSet();
            dset = DbHelperSQL.RunProcedure("prc_wom_pbagx_batch_process", parameters, "0");
            // 获取输出参数
            int outSum = Convert.ToInt32(parameters[6].Value ?? 0);
            string outMsg = parameters[7].Value?.ToString() ?? "";
            result.outSum = outSum;
            result.outMsg = outMsg;
            if (outSum > 0)
            {
                return ReturnDto<ExpandoObject>.QuickReturn(result, ReturnCode.Success, outMsg);
            }
            else
            {
                return ReturnDto<ExpandoObject>.QuickReturn(result, ReturnCode.Default, outMsg);
            }
        }
        catch (Exception ex)
        {
            result.outMsg = "批量处理明细时发生异常:" + ex.Message;
            return ReturnDto<ExpandoObject>.QuickReturn(result, ReturnCode.Exception, result.outMsg);
        }
    }
}