啊鑫
8 天以前 aedc81d40157133df8b5c44d3fbabc803a0e6e75
WebApi/GS.QC/Service/MesQaItemsDetect01Manager.cs
@@ -1,6 +1,5 @@
using System.Data;
using System.Data.SqlClient;
using System.Dynamic;
using System.Text;
using Gs.Entity.QC;
using Gs.Toolbox;
@@ -9,23 +8,21 @@
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) =
            GetUserGuidAndOrgGuid(_http);
            UtilityHelper.GetUserGuidAndOrgGuid(_http);
    }
    #region CRUD
@@ -113,8 +110,7 @@
        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)
            {
@@ -149,17 +145,14 @@
        dynamic m = new ExpandoObject();
        m.list = new List<dynamic>();
        m.list2 = new List<dynamic>();
        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");
        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");
        sb.Append("  where d13.parent_guid = '" + guid + "'");
        sb.Append(" order by d13.fcheck_item asc");
        try
        {
            var dset = new DataSet();
            DataSet dset = new DataSet();
            dset = DbHelperSQL.Query(sb.ToString());
            var _tb = dset.Tables[0].TableToDynamicList();
            m.list = _tb;
@@ -169,9 +162,8 @@
        catch (Exception ex)
        {
            LogHelper.Debug(ToString(),
                "GetModel12 error:" + ex.Message);
                        "GetModel12 error:" + ex.Message);
        }
        if (m != null)
            return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success,
                "读取成功!");
@@ -190,7 +182,7 @@
        [FromBody] MesQaItemsDetect01 model)
    {
        int? rtnInt = (int)ReturnCode.Default;
        var _sbMsg = "";
        string _sbMsg = "";
        using (var conn = new SqlConnection(DbHelperSQL.strConn))
        {
            using (var cmd = new SqlCommand("iqc_detect01_reload", conn))
@@ -215,14 +207,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
                {
@@ -230,17 +222,17 @@
                }
            }
        }
        if (rtnInt > 0)
            return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Success,
                _sbMsg);
        return ReturnDto<int>.QuickReturn(rtnInt, ReturnCode.Exception,
            _sbMsg);
           _sbMsg);
    }
    /// <summary>
    ///     录入检验结果
    /// 录入检验结果
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
@@ -267,7 +259,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;
@@ -290,7 +282,6 @@
                }
            }
        }
        if (_outSum <= 0)
            return ReturnDto<string>.QuickReturn(_outSum,
                ReturnCode.Exception, _outMsg);
@@ -308,8 +299,9 @@
    public ReturnDto<string> EditModel([FromBody] dynamic model)
    {
        Guid? guid = model.guid; //到货单主键
        string fngDesc = model.fngDesc; //备注
        string ckId = model.ckId;
        string fngDesc = model.fngDesc; //异常描述
        string iqcRemark = model.iqcRemark;
        string ckId=model.ckId;
        var _outMsg = "";
        var _outSum = -1;
        using (var conn = new SqlConnection(DbHelperSQL.strConn))
@@ -325,10 +317,10 @@
                        new("@outMsg", SqlDbType.NVarChar, 300),
                        new("@outSum", SqlDbType.Int),
                        new("@inEdtUserGuid", _userGuid),
                        new("@inOrderGuid",
                            CheckGuid(guid) ? guid : DBNull.Value),
                        new("@inOrderGuid", UtilityHelper.CheckGuid(guid) ? guid: DBNull.Value),
                        new("@fngDesc", fngDesc),
                        new("@ckId", ckId)
                        new("@ckId", ckId),
                        new("@iqcRemark", iqcRemark),
                    };
                    parameters[0].Direction = ParameterDirection.Output;
                    parameters[1].Direction = ParameterDirection.Output;
@@ -363,9 +355,8 @@
    #region 提交检验
    /// <summary>
    ///     提交检验
    /// 提交检验
    /// </summary>
    /// <param name="mode"></param>
    /// <returns></returns>
@@ -386,14 +377,14 @@
                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlParameter[] parameters =
                    {
                        new("@outMsg", SqlDbType.NVarChar, 300),
                        new("@outSum", SqlDbType.Int),
                        new("@inEdtUserGuid", _userGuid),
                        new("@inOrderGuid", _guid),
                        new("@inFieldValue", 1),
                        new("@in1", ""),
                        new("@in2", "")
                    };
                                new("@outMsg", SqlDbType.NVarChar, 300),
                                new("@outSum", SqlDbType.Int),
                                new("@inEdtUserGuid", _userGuid),
                                new("@inOrderGuid", _guid),
                                new("@inFieldValue", 1),
                                new("@in1", ""),
                                new("@in2", "")
                            };
                    parameters[0].Direction = ParameterDirection.Output;
                    parameters[1].Direction = ParameterDirection.Output;
                    foreach (var parameter in parameters)
@@ -405,10 +396,8 @@
                catch (Exception ex)
                {
                    m.outMsg = ex.Message;
                    LogHelper.Debug(ToString(),
                        "chk_iqc_detect01_submit error:" + ex.Message);
                    return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default,
                        ex.Message);
                    LogHelper.Debug(this.ToString(), "chk_iqc_detect01_submit error:" + ex.Message);
                    return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, ex.Message);
                }
                finally
                {
@@ -416,19 +405,17 @@
                }
            }
        }
        return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "操作成功!");
    }
    /// <summary>
    ///     质量,审核,反审核,驳回
    /// 质量,审核,反审核,驳回
    /// </summary>
    /// <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;
@@ -445,14 +432,14 @@
                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlParameter[] parameters =
                    {
                        new("@outMsg", SqlDbType.NVarChar, 300),
                        new("@outSum", SqlDbType.Int),
                        new("@inEdtUserGuid", _userGuid),
                        new("@inOrderGuid", _guid),
                        new("@inFieldValue", _inFieldValue),
                        new("@in1", ""),
                        new("@in2", "")
                    };
                                new("@outMsg", SqlDbType.NVarChar, 300),
                                new("@outSum", SqlDbType.Int),
                                new("@inEdtUserGuid", _userGuid),
                                new("@inOrderGuid", _guid),
                                new("@inFieldValue",_inFieldValue),
                                new("@in1", ""),
                                new("@in2", "")
                            };
                    parameters[0].Direction = ParameterDirection.Output;
                    parameters[1].Direction = ParameterDirection.Output;
                    foreach (var parameter in parameters)
@@ -464,10 +451,8 @@
                catch (Exception ex)
                {
                    m.outMsg = ex.Message;
                    LogHelper.Debug(ToString(),
                        "iqc_detect01_zhiliang error:" + ex.Message);
                    return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default,
                        ex.Message);
                    LogHelper.Debug(this.ToString(), "iqc_detect01_zhiliang error:" + ex.Message);
                    return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, ex.Message);
                }
                finally
                {
@@ -475,7 +460,6 @@
                }
            }
        }
        return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "操作成功!");
    }
@@ -492,52 +476,49 @@
    public ReturnDto<List<dynamic>> GetYangLi([FromBody] dynamic model)
    {
        string guid = model.dt01Guid.ToString();
        var lst = new List<dynamic>();
        List<dynamic> 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)
            {
                var _tb = dset.Tables[1];
                var maxYl = int.Parse(dset.Tables[0].Rows[0][0].ToString());
                DataTable _tb = dset.Tables[1];
                int maxYl = int.Parse(dset.Tables[0].Rows[0][0].ToString());
                //在检验项目表上,根据样本数自动延申样本1,样本2,样本3……
                for (var i = 1; i <= maxYl; i++)
                for (int i = 1; i <= maxYl; i++)
                {
                    _tb.Columns.Add("样本" + i, typeof(decimal));
                    _tb.Columns.Add("样本" + i + "jg", typeof(string));
                }
                ;
                var _tb2 = dset.Tables[2];
                    _tb.Columns.Add("样本" + i.ToString(), typeof(decimal));
                    _tb.Columns.Add("样本" + i.ToString() + "jg", typeof(string));
                };
                DataTable _tb2 = dset.Tables[2];
                //循环样本结果表的每一行
                foreach (DataRow row in _tb.Rows)
                {
                    //然后循环检验项目本的第一列
                foreach (DataColumn col in _tb.Columns)
                    if (col.ColumnName.StartsWith("样本"))
                    foreach (DataColumn col in _tb.Columns)
                    {
                        var _idx = col.ColumnName.Replace("样本", "");
                        //排除样本数这一列
                        if (!string.IsNullOrEmpty(_idx) && _idx != "数")
                        if (col.ColumnName.ToString().StartsWith("样本"))
                        {
                            var _row = _tb2.Select(" parent_guid='" +
                                                   row["guid"] +
                                                   "' and fcheck_item='" +
                                                   col.ColumnName.Trim() + "'");
                            if (_row.Length > 0)
                            string _idx = col.ColumnName.ToString().Replace("样本", "");
                            //排除样本数这一列
                            if (!string.IsNullOrEmpty(_idx) && _idx != "数")
                            {
                                row[col.ColumnName] = _row[0]["fcheck_resu"];
                                row[col.ColumnName + "jg"] = _row[0]["fstand"];
                                DataRow[] _row = _tb2.Select(" parent_guid='" + row["guid"].ToString() + "' and fcheck_item='" + col.ColumnName.ToString().Trim() + "'");
                                if (_row.Length > 0)
                                {
                                    row[col.ColumnName] = _row[0]["fcheck_resu"];
                                    row[col.ColumnName + "jg"] = _row[0]["fstand"];
                                }
                            }
                        }
                    }
                }
                lst = _tb.TableToDynamicList();
            }
        }
@@ -545,7 +526,6 @@
        {
            LogHelper.Debug(ToString(), ex.Message);
        }
        return ReturnDto<List<dynamic>>.QuickReturn(lst, ReturnCode.Success,
            "读取成功!");
    }
@@ -580,11 +560,11 @@
                        new("@outSum", SqlDbType.Int),
                        new("@outGuid", SqlDbType.UniqueIdentifier),
                        new("@outNo", SqlDbType.NVarChar, 300),
                        new("@outFstand", SqlDbType.NVarChar, 10),
                        new("@outFstand",SqlDbType.NVarChar, 10),
                        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;
@@ -613,11 +593,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.Success, mObj.outMsg);
    }
    #endregion