liyuanyuan %!s(int64=3) %!d(string=hace) años
padre
commit
5ecf28651f

+ 24 - 8
RMYY_CallCenter_Api.Dal/T_Equipment.cs

@@ -63,9 +63,9 @@ namespace RMYY_CallCenter_Api.DAL
63 63
 		{
64 64
 			StringBuilder strSql=new StringBuilder();
65 65
 			strSql.Append("insert into T_Equipment(");
66
-			strSql.Append("F_EquipName,F_EquipNumber,F_EquipPrice,F_State,F_CreateUser,F_CreateTime,F_DeptId)");
66
+			strSql.Append("F_EquipName,F_EquipNumber,F_EquipPrice,F_State,F_CreateUser,F_CreateTime,F_DeptId,F_ApplicableDept)");
67 67
 			strSql.Append(" values (");
68
-			strSql.Append("@F_EquipName,@F_EquipNumber,@F_EquipPrice,@F_State,@F_CreateUser,@F_CreateTime,@F_DeptId)");
68
+			strSql.Append("@F_EquipName,@F_EquipNumber,@F_EquipPrice,@F_State,@F_CreateUser,@F_CreateTime,@F_DeptId,@F_ApplicableDept)");
69 69
 			strSql.Append(";select @@IDENTITY");
70 70
 			SqlParameter[] parameters = {
71 71
 					new SqlParameter("@F_EquipName", SqlDbType.NVarChar,200),
@@ -74,8 +74,10 @@ namespace RMYY_CallCenter_Api.DAL
74 74
 					new SqlParameter("@F_State", SqlDbType.Int,4),
75 75
 					new SqlParameter("@F_CreateUser", SqlDbType.NVarChar,50),
76 76
 					new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
77
-					new SqlParameter("@F_DeptId", SqlDbType.Int,4)
77
+					new SqlParameter("@F_DeptId", SqlDbType.Int,4),
78
+                     new SqlParameter("@F_ApplicableDept", SqlDbType.NVarChar,100)
78 79
                     
80
+
79 81
             };
80 82
 			parameters[0].Value = model.F_EquipName;
81 83
 			parameters[1].Value = model.F_EquipNumber;
@@ -84,6 +86,7 @@ namespace RMYY_CallCenter_Api.DAL
84 86
 			parameters[4].Value = model.F_CreateUser;
85 87
 			parameters[5].Value = model.F_CreateTime;
86 88
             parameters[6].Value = model.F_DeptId;
89
+            parameters[7].Value = model.F_ApplicableDept;
87 90
             object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
88 91
 			if (obj == null)
89 92
 			{
@@ -107,9 +110,12 @@ namespace RMYY_CallCenter_Api.DAL
107 110
 			strSql.Append("F_State=@F_State,");
108 111
 			strSql.Append("F_CreateUser=@F_CreateUser,");
109 112
 			strSql.Append("F_CreateTime=@F_CreateTime,");
110
-            strSql.Append("F_DeptId=@F_DeptId");
113
+            strSql.Append("F_DeptId=@F_DeptId,");
114
+            strSql.Append("F_ApplicableDept=@F_ApplicableDept");
111 115
             
112 116
 
117
+
118
+
113 119
             strSql.Append(" where F_EquipID=@F_EquipID");
114 120
 			SqlParameter[] parameters = {
115 121
 					new SqlParameter("@F_EquipName", SqlDbType.NVarChar,200),
@@ -119,6 +125,7 @@ namespace RMYY_CallCenter_Api.DAL
119 125
 					new SqlParameter("@F_CreateUser", SqlDbType.NVarChar,50),
120 126
 					new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
121 127
                      new SqlParameter("@F_DeptId", SqlDbType.Int,4),
128
+                     new SqlParameter("@F_ApplicableDept", SqlDbType.NVarChar,100),
122 129
                     
123 130
 
124 131
                     new SqlParameter("@F_EquipID", SqlDbType.Int,4)};
@@ -129,7 +136,8 @@ namespace RMYY_CallCenter_Api.DAL
129 136
 			parameters[4].Value = model.F_CreateUser;
130 137
 			parameters[5].Value = model.F_CreateTime;
131 138
             parameters[6].Value = model.F_DeptId;
132
-            parameters[7].Value = model.F_EquipID;
139
+            parameters[7].Value = model.F_ApplicableDept;            
140
+            parameters[8].Value = model.F_EquipID;
133 141
 
134 142
 			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
135 143
 			if (rows > 0)
@@ -193,7 +201,7 @@ namespace RMYY_CallCenter_Api.DAL
193 201
 		{
194 202
 			
195 203
 			StringBuilder strSql=new StringBuilder();
196
-			strSql.Append("select  top 1 F_EquipID,F_EquipName,F_EquipNumber,F_EquipPrice,F_State,F_CreateUser,F_CreateTime,F_DeptId from T_Equipment ");
204
+			strSql.Append("select  top 1 F_EquipID,F_EquipName,F_EquipNumber,F_EquipPrice,F_State,F_CreateUser,F_CreateTime,F_DeptId ,F_ApplicableDept from T_Equipment ");
197 205
 			strSql.Append(" where F_EquipID=@F_EquipID");
198 206
 			SqlParameter[] parameters = {
199 207
 					new SqlParameter("@F_EquipID", SqlDbType.Int,4)
@@ -221,6 +229,14 @@ namespace RMYY_CallCenter_Api.DAL
221 229
 			RMYY_CallCenter_Api.Model.T_Equipment model=new RMYY_CallCenter_Api.Model.T_Equipment();
222 230
             if (row != null)
223 231
             {
232
+
233
+                
234
+
235
+               if (row["F_ApplicableDept"] != null)
236
+                {
237
+                    model.F_ApplicableDept = row["F_ApplicableDept"].ToString();
238
+                }
239
+
224 240
                 if (row["F_DeptId"] != null && row["F_DeptId"].ToString() != "")
225 241
                 {
226 242
                     model.F_DeptId = int.Parse(row["F_DeptId"].ToString());
@@ -264,7 +280,7 @@ namespace RMYY_CallCenter_Api.DAL
264 280
 		public DataSet GetList(string strWhere)
265 281
 		{
266 282
 			StringBuilder strSql=new StringBuilder();
267
-			strSql.Append("select F_EquipID,F_EquipName,F_EquipNumber,F_DeptId, convert(varchar(50),F_EquipPrice) as F_EquipPrice,F_State,F_CreateUser,F_CreateTime ");
283
+			strSql.Append("select F_EquipID,F_EquipName,F_EquipNumber,F_DeptId, convert(varchar(50),F_EquipPrice) as F_EquipPrice,F_State,F_CreateUser,F_CreateTime,F_ApplicableDept ");
268 284
 			strSql.Append(" FROM T_Equipment ");
269 285
 			if(strWhere.Trim()!="")
270 286
 			{
@@ -284,7 +300,7 @@ namespace RMYY_CallCenter_Api.DAL
284 300
 			{
285 301
 				strSql.Append(" top "+Top.ToString());
286 302
 			}
287
-			strSql.Append(" F_EquipID,F_EquipName,F_EquipNumber,F_EquipPrice,F_State,F_CreateUser,F_CreateTime ,F_DeptId ");
303
+			strSql.Append(" F_EquipID,F_EquipName,F_EquipNumber,F_EquipPrice,F_State,F_CreateUser,F_CreateTime ,F_DeptId,F_ApplicableDept ");
288 304
 			strSql.Append(" FROM T_Equipment ");
289 305
 			if(strWhere.Trim()!="")
290 306
 			{

+ 9 - 1
RMYY_CallCenter_Api.Model/T_Equipment.cs

@@ -33,8 +33,16 @@ namespace RMYY_CallCenter_Api.Model
33 33
 		private int? _f_state;
34 34
 		private string _f_createuser;
35 35
 		private DateTime? _f_createtime;
36
-
36
+        private string _f_applicabledept;
37 37
         private int? _f_deptid;
38
+
39
+
40
+        public string F_ApplicableDept
41
+        {
42
+            set { _f_applicabledept = value; }
43
+            get { return _f_applicabledept; }
44
+        }
45
+
38 46
         public int? F_DeptId
39 47
         {
40 48
             set { _f_deptid = value; }

+ 62 - 13
RMYY_CallCenter_Api/Controllers/EquipmentController.cs

@@ -29,8 +29,36 @@ namespace RMYY_CallCenter_Api.Controllers
29 29
         public ActionResult GetList(string equipmentname,int PageSize = 10,int PageIndex=1)
30 30
         {
31 31
             string sql = "";
32
-            if (User .F_RoleCode !="GLY")
33
-              sql+= " and F_DeptId='"+User.F_DeptId+"'";
32
+           
33
+
34
+                DataTable dtdept = new DataTable();
35
+
36
+                dtdept = DbHelperSQL.Query(" select F_DeptId from [dbo].[GetDeptid]('" + User.F_DeptId + "')").Tables[0];
37
+
38
+                DataTable returndt = new DataTable();
39
+                if (dtdept.Rows.Count == 1)
40
+                {
41
+                    sql+="   and   charindex(','+'" + User.F_DeptId + "'+',',','+F_ApplicableDept+',')>0";
42
+                }
43
+                if (dtdept.Rows.Count > 1)
44
+                {
45
+                    sql += " and (";
46
+                    foreach (DataRow dr in dtdept.Rows)
47
+                    {
48
+                        int deptid = Convert.ToInt32(dr["F_DeptId"].ToString());
49
+                        sql += " ',' + F_ApplicableDept + ',' like '%," + deptid + ",%'" + " or";
50
+                    }
51
+                    sql = sql.Substring(0, sql.Length - 2);
52
+
53
+                    sql += " )";
54
+                } 
55
+            
56
+
57
+
58
+
59
+
60
+
61
+
34 62
             if(!string.IsNullOrEmpty(equipmentname))
35 63
             {
36 64
                 sql += " and F_EquipName='" + equipmentname + "'";
@@ -67,7 +95,7 @@ namespace RMYY_CallCenter_Api.Controllers
67 95
         /// </summary>
68 96
         /// <param name="input"></param>
69 97
         /// <returns></returns>
70
-        public ActionResult AddEquip(string equipname, string equipnumber, int state, decimal equipprice=0)
98
+        public ActionResult AddEquip(string equipname, string equipnumber,string ApplicableDept, int state, decimal equipprice=0)
71 99
         {
72 100
             Model.T_Equipment equipModel = new Model.T_Equipment();
73 101
 
@@ -78,15 +106,10 @@ namespace RMYY_CallCenter_Api.Controllers
78 106
             equipModel.F_CreateTime = DateTime.Now;
79 107
             equipModel.F_CreateUser =User.F_UserCode;
80 108
             equipModel.F_DeptId = User.F_DeptId;
109
+            equipModel.F_ApplicableDept = ApplicableDept;
81 110
             if (equipbll.Add(equipModel) > 0)
82 111
             {
83
-                Model.T_Sys_DictionaryValue dvmodel = new Model.T_Sys_DictionaryValue();
84
-                dvmodel.F_DictionaryFlag = "SBXX";
85
-                dvmodel.F_Name = equipname;
86
-                dvmodel.F_State = true;
87
-                dvmodel.F_Sort = 0;
88
-                Bll.T_Sys_DictionaryValue dvbll = new Bll.T_Sys_DictionaryValue();
89
-                dvbll.Add(dvmodel);
112
+               
90 113
                 return Success("设备添加成功");
91 114
             }
92 115
 
@@ -101,7 +124,7 @@ namespace RMYY_CallCenter_Api.Controllers
101 124
         /// </summary>
102 125
         /// <param name="input"></param>
103 126
         /// <returns></returns>
104
-        public ActionResult EditEquip(int equipid,string equipname,string equipnumber,int state, decimal equipprice=0)
127
+        public ActionResult EditEquip(int equipid,string equipname,string equipnumber, string ApplicableDept, int state, decimal equipprice=0)
105 128
         {
106 129
             Model.T_Equipment equipModel = equipbll.GetModel(equipid);
107 130
             if (equipModel == null)
@@ -111,6 +134,7 @@ namespace RMYY_CallCenter_Api.Controllers
111 134
             equipModel.F_State = state;
112 135
             equipModel.F_EquipPrice = equipprice;
113 136
             equipModel.F_DeptId = User.F_DeptId;
137
+            equipModel.F_ApplicableDept = ApplicableDept;
114 138
             if (equipbll.Update(equipModel))
115 139
                 return Success("设备修改成功");
116 140
             else
@@ -141,11 +165,35 @@ namespace RMYY_CallCenter_Api.Controllers
141 165
 
142 166
 
143 167
         //获取设备值列表
168
+      
144 169
         public ActionResult GetAllList()
145 170
         {
146 171
             DataTable dt = new DataTable();
147
-            dt = equipbll.GetList("   F_state=1  and F_DeptId(select F_DeptId from[dbo].[GetDeptid] ('" + User.F_DeptId + "')").Tables[0];
148
-            return Success("列表加载成功", dt);
172
+            //dt = equipbll.GetList("   F_state=1  and F_DeptId in (select F_DeptId from[dbo].[GetDeptid] ()").Tables[0];
173
+
174
+            dt =DbHelperSQL.Query(" select F_DeptId from [dbo].[GetDeptid]('" + User.F_DeptId + "')").Tables[0];
175
+
176
+            DataTable returndt = new DataTable();
177
+            if (dt.Rows.Count == 1)
178
+            {
179
+                returndt = equipbll.GetList("   F_state=1  and  charindex(','+'" + User.F_DeptId + "'+',',','+F_ApplicableDept+',')>0").Tables[0];
180
+            }
181
+            else
182
+            {
183
+                string sql = " select * from T_Equipment where  F_state=1 and (";
184
+                foreach (DataRow dr in dt.Rows)
185
+                {
186
+                    int deptid = Convert.ToInt32(dr["F_DeptId"].ToString());
187
+                    sql += " ',' + F_ApplicableDept + ',' like '%," + deptid + ",%'" +" or";               
188
+                }
189
+                sql = sql.Substring(0, sql.Length - 2);
190
+
191
+                sql += " )";
192
+                returndt = DbHelperSQL.Query(sql).Tables[0];
193
+            }
194
+            
195
+
196
+            return Success("列表加载成功", returndt);
149 197
 
150 198
         }
151 199
 
@@ -201,6 +249,7 @@ namespace RMYY_CallCenter_Api.Controllers
201 249
                                 Model.T_Equipment modelEquip = new Model.T_Equipment();
202 250
                                 #region
203 251
                                 modelEquip.F_DeptId = User.F_DeptId;
252
+                                modelEquip.F_ApplicableDept = User.F_DeptId.ToString();
204 253
                                 modelEquip.F_CreateTime = DateTime.Now;
205 254
                                 modelEquip.F_CreateUser = User.F_UserCode;
206 255
                                 modelEquip.F_State = 1;