啊鑫
2025-09-09 f2b71fe1d3c2b7651d525a5b5bbe66fad602ea06
WebApi/GS.QC/Service/MesQaItemsDetect01Manager.cs
@@ -1,5 +1,6 @@
using System.Data;
using System.Data.SqlClient;
using System.Dynamic;
using System.Text;
using Gs.Entity.QC;
using Gs.Toolbox;
@@ -8,21 +9,23 @@
using Gs.Toolbox.ApiCore.Group;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Dynamic;
using static Gs.Toolbox.UtilityHelper;
namespace GS.QC.Service;
[ApiGroup(ApiGroupNames.QC)]
public class MesQaItemsDetect01Manager : Repository<MesQaItemsDetect01>,IRomteService
public class MesQaItemsDetect01Manager : Repository<MesQaItemsDetect01>,
    IRomteService
{
    private readonly IHttpContextAccessor _http;
    private readonly string _userCode, _userGuid, _orgFids;
    public MesQaItemsDetect01Manager(IHttpContextAccessor httpContextAccessor)
    {
        _http = httpContextAccessor;
        (_userCode, _userGuid, _orgFids) =
            UtilityHelper.GetUserGuidAndOrgGuid(_http);
            GetUserGuidAndOrgGuid(_http);
    }
    #region CRUD
@@ -110,7 +113,8 @@
        var dset = new DataSet();
        try
        {
            dset = DbHelperSQL.RunProcedure("[iqc_detect01_get]", parameters, "0");
            dset = DbHelperSQL.RunProcedure("[iqc_detect01_get]", parameters,
                "0");
            if (dset != null && dset.Tables.Count > 0 &&
                dset.Tables[0].Rows.Count > 0)
            {
@@ -145,14 +149,17 @@
        dynamic m = new ExpandoObject();
        m.list = new List<dynamic>();
        m.list2 = new List<dynamic>();
        System.Text.StringBuilder sb = new StringBuilder();
        sb.Append("select * from  MES_QA_ITEMS_DETECT_DETAIL12 where parent_guid='" + guid + "' order by fstand asc");
        sb.Append("   select d13.*,d5.fcheck_item as  fcheckItemd5,d5.ybsl from  MES_QA_ITEMS_DETECT_DETAIL13 d13 left join[dbo].[MES_QA_ITEMS_DETECT_DETAIL5] d5 on d13.parent_guid = d5.guid");
        var sb = new StringBuilder();
        sb.Append(
            "select * from  MES_QA_ITEMS_DETECT_DETAIL12 where parent_guid='" +
            guid + "' order by fstand asc");
        sb.Append(
            "   select d13.*,d5.fcheck_item as  fcheckItemd5,d5.ybsl from  MES_QA_ITEMS_DETECT_DETAIL13 d13 left join[dbo].[MES_QA_ITEMS_DETECT_DETAIL5] d5 on d13.parent_guid = d5.guid");
        sb.Append("  where d13.parent_guid = '" + guid + "'");
        sb.Append(" order by d13.fcheck_item asc");
        try
        {
            DataSet dset = new DataSet();
            var dset = new DataSet();
            dset = DbHelperSQL.Query(sb.ToString());
            var _tb = dset.Tables[0].TableToDynamicList();
            m.list = _tb;
@@ -164,6 +171,7 @@
            LogHelper.Debug(ToString(),
                        "GetModel12 error:" + ex.Message);
        }
        if (m != null)
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success,
                "读取成功!");
@@ -182,7 +190,7 @@
        [FromBody] MesQaItemsDetect01 model)
    {
        int? rtnInt = (int)ReturnCode.Default;
        string _sbMsg = "";
        var _sbMsg = "";
        using (var conn = new SqlConnection(DbHelperSQL.strConn))
        {
            using (var cmd = new SqlCommand("iqc_detect01_reload", conn))
@@ -207,14 +215,14 @@
                    foreach (var parameter in parameters)
                        cmd.Parameters.Add(parameter);
                    cmd.ExecuteNonQuery();
                    _sbMsg = (parameters[0].Value.ToString());
                    _sbMsg = parameters[0].Value.ToString();
                    rtnInt = int.Parse(parameters[1].Value.ToString());
                }
                catch (Exception ex)
                {
                    LogHelper.Debug(ToString(),
                        "chk_iqc_detect01_reload error:" + ex.Message);
                    _sbMsg = ("存储过程执行失败," + ex.Message);
                    _sbMsg = "存储过程执行失败," + ex.Message;
                }
                finally
                {
@@ -222,12 +230,12 @@
                }
            }
        }
        if (rtnInt > 0)
            return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success,
                _sbMsg);
        return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception,
           _sbMsg);
    }
@@ -259,7 +267,7 @@
                        new("@inEdtUserGuid", _userGuid),
                        new("@inOrderGuid1", inOrderGuid1),
                        new("@inOrderGuid5", inOrderGuid5),
                        new("@inP1", inP1),
                        new("@inP1", inP1)
                    };
                    parameters[0].Direction = ParameterDirection.Output;
                    parameters[1].Direction = ParameterDirection.Output;
@@ -282,6 +290,7 @@
                }
            }
        }
        if (_outSum <= 0)
            return ReturnDto<string>.QuickReturn(_outSum,
                ReturnCode.Exception, _outMsg);
@@ -316,9 +325,10 @@
                        new("@outMsg", SqlDbType.NVarChar, 300),
                        new("@outSum", SqlDbType.Int),
                        new("@inEdtUserGuid", _userGuid),
                        new("@inOrderGuid", UtilityHelper.CheckGuid(guid) ? guid: DBNull.Value),
                        new("@inOrderGuid",
                            CheckGuid(guid) ? guid : DBNull.Value),
                        new("@fngDesc", fngDesc),
                        new("@ckId", ckId),
                        new("@ckId", ckId)
                    };
                    parameters[0].Direction = ParameterDirection.Output;
                    parameters[1].Direction = ParameterDirection.Output;
@@ -353,6 +363,7 @@
    #region 提交检验
    /// <summary>
    /// 提交检验
    /// </summary>
@@ -394,8 +405,10 @@
                catch (Exception ex)
                {
                    m.outMsg = ex.Message;
                    LogHelper.Debug(this.ToString(), "chk_iqc_detect01_submit error:" + ex.Message);
                    return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, ex.Message);
                    LogHelper.Debug(ToString(),
                        "chk_iqc_detect01_submit error:" + ex.Message);
                    return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default,
                        ex.Message);
                }
                finally
                {
@@ -403,6 +416,7 @@
                }
            }
        }
        return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "操作成功!");
    }
@@ -413,7 +427,8 @@
    /// <param name="mode"></param>
    /// <returns></returns>
    [RequestMethod(RequestMethods.POST)]
    public ReturnDto<ExpandoObject> EditModelSubmitZhiLiang([FromBody] dynamic mode)
    public ReturnDto<ExpandoObject> EditModelSubmitZhiLiang(
        [FromBody] dynamic mode)
    {
        string _guid = mode.guid;
        string _inFieldValue = mode.inFieldValue;
@@ -449,8 +464,10 @@
                catch (Exception ex)
                {
                    m.outMsg = ex.Message;
                    LogHelper.Debug(this.ToString(), "iqc_detect01_zhiliang error:" + ex.Message);
                    return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, ex.Message);
                    LogHelper.Debug(ToString(),
                        "iqc_detect01_zhiliang error:" + ex.Message);
                    return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default,
                        ex.Message);
                }
                finally
                {
@@ -458,6 +475,7 @@
                }
            }
        }
        return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "操作成功!");
    }
@@ -474,40 +492,44 @@
    public ReturnDto<List<dynamic>> GetYangLi([FromBody] dynamic model)
    {
        string guid = model.dt01Guid.ToString();
        List<dynamic> lst = new List<dynamic>();
        var lst = new List<dynamic>();
        SqlParameter[] parameters =
        {
            new("@dt01Guid", guid),
            new("@dt01Guid", guid)
        };
        var dset = new DataSet();
        try
        {
            dset = DbHelperSQL.RunProcedure("[iqc_detect01_13Lst]", parameters, "0");
            dset = DbHelperSQL.RunProcedure("[iqc_detect01_13Lst]", parameters,
                "0");
            if (dset != null && dset.Tables.Count > 0 &&
                dset.Tables[0].Rows.Count > 0)
            {
                DataTable _tb = dset.Tables[1];
                int maxYl = int.Parse(dset.Tables[0].Rows[0][0].ToString());
                var _tb = dset.Tables[1];
                var maxYl = int.Parse(dset.Tables[0].Rows[0][0].ToString());
                //在检验项目表上,根据样本数自动延申样本1,样本2,样本3……
                for (int i = 1; i <= maxYl; i++)
                for (var i = 1; i <= maxYl; i++)
                {
                    _tb.Columns.Add("样本" + i.ToString(), typeof(decimal));
                    _tb.Columns.Add("样本" + i.ToString() + "jg", typeof(string));
                };
                DataTable _tb2 = dset.Tables[2];
                    _tb.Columns.Add("样本" + i, typeof(decimal));
                    _tb.Columns.Add("样本" + i + "jg", typeof(string));
                }
                ;
                var _tb2 = dset.Tables[2];
                //循环样本结果表的每一行
                foreach (DataRow row in _tb.Rows)
                {
                    //然后循环检验项目本的第一列
                    foreach (DataColumn col in _tb.Columns)
                    if (col.ColumnName.StartsWith("样本"))
                    {
                        if (col.ColumnName.ToString().StartsWith("样本"))
                        {
                            string _idx = col.ColumnName.ToString().Replace("样本", "");
                        var _idx = col.ColumnName.Replace("样本", "");
                            //排除样本数这一列
                            if (!string.IsNullOrEmpty(_idx) && _idx != "数")
                            {
                                DataRow[] _row = _tb2.Select(" parent_guid='" + row["guid"].ToString() + "' and fcheck_item='" + col.ColumnName.ToString().Trim() + "'");
                            var _row = _tb2.Select(" parent_guid='" +
                                                   row["guid"] +
                                                   "' and fcheck_item='" +
                                                   col.ColumnName.Trim() + "'");
                                if (_row.Length > 0)
                                {
                                    row[col.ColumnName] = _row[0]["fcheck_resu"];
@@ -515,8 +537,7 @@
                                }
                            }
                        }
                    }
                }
                lst = _tb.TableToDynamicList();
            }
        }
@@ -524,6 +545,7 @@
        {
            LogHelper.Debug(ToString(), ex.Message);
        }
        return ReturnDto<List<dynamic>>.QuickReturn(lst, ReturnCode.Success,
            "读取成功!");
    }
@@ -562,7 +584,7 @@
                        new("@dt05Guid", CheckGuid(guid) ? guid : DBNull.Value),
                        new("@fVal", fVal),
                        new("@fSeq", fSeq),
                        new("@inEdtUserGuid", _userGuid),
                        new("@inEdtUserGuid", _userGuid)
                    };
                    parameters[0].Direction = ParameterDirection.Output;
                    parameters[1].Direction = ParameterDirection.Output;
@@ -591,9 +613,11 @@
                }
            }
        }
        //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.Success,
            mObj.outMsg);
    }
    #endregion