1
dytyqx
2026-02-26 09bef7222f28abfe5fbb308c610997dc52da5f18
WebAPI/Controllers/BaseSet/Gy_ConkTypeController.cs
@@ -18,6 +18,7 @@
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        ClsXt_SystemParameter oClsXt_SystemParameter = new ClsXt_SystemParameter();
        /// <summary>
        /// 返回故障类别列表
@@ -169,7 +170,7 @@
                    //保存前控制=========================================      
                    string sql1 = "exec h_p_Gy_ConkType_BeforeSaveCtrl " + HMakeEmp + ",'" + 1 + "'";
                    string sql1 = "exec h_p_Gy_ConkType_BeforeSaveCtrl '" + HNumber + "','" + HName + "'," + HUSEORGID + ",1,0";
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_ConkType_BeforeSaveCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
@@ -185,7 +186,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "保存失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.Message = "保存失败!原因:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); ;
                        objJsonResult.data = null;
                        oCN.RollBack();
                        return objJsonResult;
@@ -235,7 +236,7 @@
                    oCN.BeginTran();
                    //保存前控制=========================================      
                    string sql1 = "exec h_p_Gy_ConkType_BeforeSaveCtrl " + HMakeEmp + ",'" + 2 + "'";
                    string sql1 = "exec h_p_Gy_ConkType_BeforeSaveCtrl '" + HNumber + "','" + HName + "'," + HUSEORGID + ",3," + HItemID;
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_ConkType_BeforeSaveCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
@@ -251,7 +252,7 @@
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "保存失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        objJsonResult.Message = "保存失败!原因:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); ;
                        objJsonResult.data = null;
                        oCN.RollBack();
                        return objJsonResult;
@@ -306,11 +307,48 @@
     
                    oCN.Commit();
                }
                objJsonResult.code = "0";
                //自动审核功能
                if (HItemID == 0)
                {
                    ds = oCN.RunProcReturn("select HItemID,HNumber,HName from Gy_ConkType with(nolock) where HNumber='" + HNumber + "' and HUSEORGID = " + HUSEORGID, "Gy_ConkType");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "保存成功!自动审核失败找不到对应单据";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else if (ds.Tables[0].Rows.Count > 1)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "相同使用组织下,出现" + ds.Tables[0].Rows.Count + "个相同的代码:" + ds.Tables[0].Rows[0]["HNumber"];
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        string sAutoCheck = oClsXt_SystemParameter.GetSingleSystemParameter("Gy_ConkType_AutoCheck", ref DBUtility.ClsPub.sExeReturnInfo);
                        objJsonResult.Verify = "N";
                        if (sAutoCheck == "Y")
                        {
                            objJsonResult.code = "1";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "保存成功";
                            objJsonResult.data = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            objJsonResult.Verify = "Y";
                            return objJsonResult;
                        }
                    }
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "保存成功!";
                //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
                objJsonResult.data = 1;
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
@@ -336,7 +374,7 @@
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_Gy_ConkTypeList where HitemID=" + HInterID, "h_v_Gy_ConkTypeList");
                ds = oCN.RunProcReturn("select * from h_v_Gy_ConkType_Edit where HitemID=" + HInterID, "h_v_Gy_ConkType_Edit");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
@@ -364,7 +402,7 @@
            }
        }
        [Route("DeltetGy_ConkType")]
        [HttpGet]
        public object DeltetGy_ConkType(string HItemID, string user)
@@ -419,6 +457,17 @@
                    objJsonResult.Message = "此项目已使用,不能删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "" || ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据当前处于不能删除状态!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                //删除前控制=========================================      
                string sql1 = "exec h_p_Gy_ConkType_BeforeDelCtrl " + HItemID + ",'" + user + "'";
@@ -490,6 +539,63 @@
            }
        }
        [Route("Gy_ConkType/List_PDA2")]
        [HttpGet]
        public object List_PDA(string sWhere, string user, string Mode)
        {
            if (string.IsNullOrWhiteSpace(Mode))
            {
                return List_PDA(sWhere, user);
            }
            try
            {
                string errRef = "";
                List<object> columnNameList = new List<object>();
                if(oClsXt_SystemParameter.ShowBill(ref errRef))
                {
                    if(oClsXt_SystemParameter.omodel.WMS_CampanyName == "华舟")
                    {
                        if(Mode == "Module")
                        {
                            sWhere += $" and 故障类别代码 like 'MJ%' ";
                        }
                        else if (Mode == "Equip")
                        {
                            sWhere += $" and 故障类别代码 like 'SB%' ";
                        }
                    }
                }
                sWhere += $" and 禁用标志='' ";
                LogService.Write(sWhere);
                string sql1 = string.Format(@"select * from h_v_Gy_ConkTypeList where 1=1 ");
                ds = oCN.RunProcReturn(sql1 + sWhere + " order by 故障类别代码 ", "h_v_Gy_ConkTypeList");
                //添加列名
                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列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }