1
wangbin
2024-07-08 4548e24916ac5f63eef736cabdcd634864f8de16
WebAPI/Controllers/BaseSet/Gy_ModelTypeController.cs
@@ -1,4 +1,5 @@
using DBUtility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -30,27 +31,45 @@
        /// </summary>
        [Route("Gy_ModelType/list")]
        [HttpGet]
        public object list(string sWhere)
        public object list(string sWhere, string ModRightNameSelect, string user)
        {
            try
            {
                ds = oCN.RunProcReturn("select HItemID,HParentID,HNumber,HName,HLevel, case when HEndFlag<>0 then 'Y'else ' 'end HEndFlag,case when HStopFlag <> 0 then 'Y'else ' 'end HStopFlag, HRemark, HUseFlag from Gy_MouldType where 1=1 " + sWhere, "Gy_MouldType");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                List<object> a = new List<object>();
                if (!DBUtility.ClsPub.Security_Log(ModRightNameSelect, 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无模治具分类数据!";
                    objJsonResult.Message = "没有查看权限";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                ds = oCN.RunProcReturn("select HItemID,HParentID,HNumber,HName,HLevel, case when HEndFlag<>0 then 'Y'else ' 'end HEndFlag,case when HStopFlag <> 0 then 'Y'else ' 'end HStopFlag, HRemark, HUseFlag from Gy_MouldType where 1=1 " + sWhere+ " order by HNumber", "Gy_MouldType");
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "查找成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    a.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = a;
                return objJsonResult;
                //}
                //else
                //{
                //objJsonResult.code = "0";
                //objJsonResult.count = 0;
                //objJsonResult.Message = "无数据";
                //objJsonResult.data = null;
                //return objJsonResult;
                //}
            }
            catch (Exception e)
            {
@@ -120,14 +139,14 @@
            try
            {
                //if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 1, true, User))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "没有删除权限";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 1, false, User))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有删除权限";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oDeptHlp.GetInfoByID(HItemID))
                {
                    if (oDept.HavChildCodes(HItemID))
@@ -201,10 +220,15 @@
            {
                var _value = oMain["oMain"].ToString();
                string msg1 = _value.ToString();
                //反序列化
                msg1 = "[" + msg1.ToString() + "]";
                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string msg2 = sArray[0].ToString();
                string msg3 = sArray[1].ToString();//当前人
                string msg4 = sArray[2].ToString();//模块权限
                List<Model.ClsGy_MouldType_Model> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_MouldType_Model>>(msg1);
                //反序列化
                msg2 = "[" + msg2.ToString() + "]";
                List<Model.ClsGy_MouldType_Model> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_MouldType_Model>>(msg2);
                string HNumber = list[0].HNumber;
                string HName = list[0].HName;
@@ -216,6 +240,16 @@
                bool HStopflag = list[0].HStopflag;
                string HUseFlag = list[0].HUseFlag;
                bool HEndFlag = list[0].HEndFlag;
                //判断权限
                if (!DBUtility.ClsPub.Security_Log(msg4, 1, false, msg3))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (!DBUtility.ClsPub.AllowNumber(HNumber))
                {
@@ -275,8 +309,8 @@
                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string msg2 = sArray[0].ToString();
                string msg3 = sArray[1].ToString();
                string msg4 = sArray[2].ToString();
                string msg5 = sArray[3].ToString();
                string msg4 = sArray[2].ToString();//当前人
                string msg5 = sArray[3].ToString();//权限模块
                //反序列化
                msg2 = "[" + msg2.ToString() + "]";
@@ -293,14 +327,14 @@
                string HUseFlag = list[0].HUseFlag;
                //判断权限
                //if (!ClsPub.Security_Log(msg5, 1, true, msg4))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "没有找到该功能模块!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                if (!DBUtility.ClsPub.Security_Log(msg5, 1, false, msg4))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有保存权限";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (!DBUtility.ClsPub.AllowNumber(HNumber))
@@ -415,5 +449,109 @@
            }
        }
        #endregion
        #region 器具分类审核/反审核
        [Route("Gy_MouldType/AuditGy_MouldType")]
        [HttpGet]
        public object AuditGy_MouldType(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有审核权限
                if (!DBUtility.ClsPub.Security_Log("Gy_MouldType_Check", 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;
                }
                DAL.ClsGy_MouldType_Ctl oBill = new DAL.ClsGy_MouldType_Ctl();
                ClsPub.CurUserName = user;
                oCN.BeginTran();//开始事务
                //Type 1 审核  2  反审核
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from  Gy_MouldType  where HItemID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, oBill.MvarItemKey);
                    if (ds.Tables[0].Rows[0]["HCheckEmp"] != null && ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已审核!不能再次审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //审核单据
                    if (!oBill.AuditByID2(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反审核
                    DataSet ds;
                    string sql = "select * from  Gy_MouldType  where HItemID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, oBill.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCheckEmp"] == null || ds.Tables[0].Rows[0]["HCheckEmp"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未审核!不需要反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //反审核单据
                        if (!oBill.DeAuditByID2(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo;
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "执行成功!";
                objJsonResult.data = null;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "执行失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}