yusijie
2023-08-30 02bfe366088dd52dd143239a94ea45a1e3e898fe
WebAPI/Controllers/Æ·ÖʹÜÀí/Ê×¼þ¼ìÑéµ¥/QC_FirstPieceCheckBillController.cs
@@ -20,6 +20,59 @@
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        //获取系统参数
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        #region é¦–件检验单列表
        [Route("QC_FirstPieceCheckBill/QC_FirstPieceCheckBillList")]
        [HttpGet]
        public object QC_FirstPieceCheckBillList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql1 = "select * from h_v_QC_FirstPieceCheckBill where 1 = 1  ";
                string sql = sql1 + sWhere + " order by hmainid desc";
                ds = oCN.RunProcReturn(sql, "h_v_QC_FirstPieceCheckBill");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.list = columnNameList;
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有查询到数据";
                    objJsonResult.list = columnNameList;
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region é¦–件检验单保存
        [Route("QC_FirstPieceCheckBill/set_SaveBill")]
@@ -190,58 +243,7 @@
                return objJsonResult;
            }
        }
        #endregion
        #region é¦–件检验单根据源单类型获取信息-源单为生产状态临时表(3722)
        /// <summary>
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("QC_FirstPieceCheckBill/get_ICMOBillStatus_Tmp")]
        [HttpGet]
        public object get_ICMOBillStatus_Tmp(int HInterID,int HEntryID,string HBillType)
        {
            try
            {
                if (HInterID == 0 || HBillType.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "参数不全,获取源单信息失败!HInterID:"+ HInterID+ ";HEntryID:"+ HEntryID + ";HBillType:"+ HBillType+";";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_QC_GetInfoByICMOStatusBill " + HInterID + "," + HEntryID + "," + HBillType, "h_p_QC_GetInfoByICMOStatusBill");
                }
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "查询数据异常,请与管理员联系!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "查询数据异常,请与管理员联系!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region æ£€éªŒå€¼ä¿å­˜
        [Route("QC_FirstPieceCheckBill/set_SaveValue")]
@@ -376,19 +378,91 @@
            }
        }
        #region é¦–件检验单列表
        [Route("QC_FirstPieceCheckBill/QC_FirstPieceCheckBillList")]
        /// <summary>
        /// é¦–件检验逻辑删除功能
        /// </summary>
        /// <returns></returns>
        [Route("DeltetQC_FirstPieceCheck")]
        [HttpGet]
        public object QC_FirstPieceCheckBillList(string sWhere, string user)
        public object DeltetQC_FirstPieceCheck(string HInterID, string user)
        {
            string ModRightNameCheck = "QC_FirstPieceCheckBill_Delete";
            try
            {
                //删除权限
                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //开始事物
                oCN.BeginTran();
                oCN.RunProc("Delete From QC_FirstPieceCheckBillMain where HInterID = " + HInterID);
                oCN.RunProc("Delete From QC_FirstPieceCheckBillSub where HInterID = " + HInterID);
                oCN.RunProc("Delete From QC_FirstPieceCheckBillSub_ValueGrid where HInterID = " + HInterID);
                oCN.RunProc("Delete From QC_FirstPieceCheckBillSub_Result where HInterID = " + HInterID);
                //提交事务
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack(); //回滚事物
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "删除失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #region é¦–件检验单根据源单类型获取信息-源单为工序进站单
        [Route("QC_FirstPieceCheckBill/get_StationInBill")]
        [HttpGet]
        public object get_StationInBill(string HInterID, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql1 = "select * from h_v_QC_FirstPieceCheckBill where 1 = 1  ";
                string sql = sql1 + sWhere + " order by hmainid desc";
                ds = oCN.RunProcReturn(sql, "h_v_QC_FirstPieceCheckBill");
                string sReturn = "";
                string sql = "";
                if (oSystemParameter.ShowBill(ref sReturn))
                {
                    switch (oSystemParameter.omodel.QC_FirstPieceCheckBill_QCSchemeSource)
                    {
                        case "工序":
                            sql = "exec h_p_QC_FirstPiece_GetStationInBillList " + "'工序','" + HInterID + "'";
                            break;
                        case "物料":
                            sql = "exec h_p_QC_FirstPiece_GetStationInBillList " + "'物料','" + HInterID + "'";
                            break;
                        case "工艺路线":
                            sql = "exec h_p_QC_FirstPiece_GetStationInBillList " + "'工艺路线','" + HInterID + "'";
                            break;
                    }
                }
                ds = oCN.RunProcReturn(sql, "h_p_QC_FirstPiece_GetStationInBillList");
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
@@ -396,19 +470,70 @@
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.Message = "查询数据异常,请与管理员联系!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region é¦–件检验单根据源单类型获取信息-源单为生产状态临时表(3722)
        /// <summary>
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("QC_FirstPieceCheckBill/get_ICMOBillStatus_Tmp")]
        [HttpGet]
        public object get_ICMOBillStatus_Tmp(int HInterID, int HEntryID, string HBillType)
        {
            try
            {
                if (HInterID == 0 || HBillType.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "参数不全,获取源单信息失败!HInterID:" + HInterID + ";HEntryID:" + HEntryID + ";HBillType:" + HBillType + ";";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_QC_GetInfoByICMOStatusBill " + HInterID + "," + HEntryID + "," + HBillType, "h_p_QC_GetInfoByICMOStatusBill");
                }
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "查询数据异常,请与管理员联系!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "查询数据异常,请与管理员联系!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }