Просмотр исходного кода

除报表及坐席组上传代码

machenyang лет назад: 8
Родитель
Сommit
ba753c3355

+ 26 - 1
codegit/CallCenterApi/CallCenterApi.BLL/T_Cus_CustomerBase.cs

@@ -70,9 +70,17 @@ namespace CallCenterApi.BLL
70 70
         /// </summary>
71 71
         public CallCenterApi.Model.T_Cus_CustomerBase GetModel(int F_CustomerId)
72 72
         {
73
-
74 73
             return dal.GetModel(F_CustomerId);
75 74
         }
75
+        /// <summary>
76
+        /// 通过电话号码获取客户信息
77
+        /// </summary>
78
+        /// <param name="F_Mobile"></param>
79
+        /// <returns></returns>
80
+        public CallCenterApi.Model.T_Cus_CustomerBase GetModel(string F_Mobile)
81
+        {
82
+            return dal.GetModel(F_Mobile);
83
+        }
76 84
 
77 85
         /// <summary>
78 86
         /// 获得数据列表
@@ -141,6 +149,23 @@ namespace CallCenterApi.BLL
141 149
             return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
142 150
         }
143 151
         /// <summary>
152
+        /// 获取来电单位
153
+        /// </summary>
154
+        /// <returns>单位列表</returns>
155
+        public List<string> GetLDdep()
156
+        {
157
+            return dal.GetLDdep();
158
+        }
159
+        /// <summary>
160
+        /// 判断来电单位是否存在
161
+        /// </summary>
162
+        /// <returns></returns>
163
+        public bool LDdepExist(string lddep)
164
+        {
165
+            return dal.LDdepExist(lddep);
166
+        }
167
+
168
+        /// <summary>
144 169
         /// 分页获取数据列表
145 170
         /// </summary>
146 171
         //public DataSet GetList(int PageSize,int PageIndex,string strWhere)

+ 76 - 0
codegit/CallCenterApi/CallCenterApi.DAL/T_Cus_CustomerBase.cs

@@ -207,6 +207,54 @@ namespace CallCenterApi.DAL
207 207
             }
208 208
         }
209 209
         /// <summary>
210
+        /// 判断来电单位是否存在
211
+        /// </summary>
212
+        /// <returns></returns>
213
+        public bool LDdepExist(string lddep)
214
+        {
215
+            bool lddepexists = false;
216
+            List<string> dep = null;
217
+            string str = "select distinct F_CustomerIndustry from T_Cus_CustomerBase";
218
+            DataSet ds = DbHelperSQL.Query(str);
219
+            if (ds != null && ds.Tables[0].Rows.Count > 0)
220
+            {
221
+                foreach (DataRow dr in ds.Tables[0].Rows)
222
+                {
223
+                    if (!string.IsNullOrEmpty(dr[0].ToString()))
224
+                    {
225
+                        dep.Add(dr[0].ToString());
226
+                    }
227
+                }
228
+                if (dep.Contains(lddep))
229
+                    lddepexists = true;
230
+            }
231
+            
232
+            return lddepexists;
233
+        }
234
+
235
+        /// <summary>
236
+        /// 获取来电单位
237
+        /// </summary>
238
+        /// <returns></returns>
239
+        public List<string> GetLDdep()
240
+        {
241
+            List<string> lddep = null;
242
+            string str = "select F_CustomerIndustry from T_Cus_CustomerBase group by F_CustomerIndustry";
243
+            DataSet ds = DbHelperSQL.Query(str);
244
+            if (ds != null && ds.Tables[0].Rows.Count > 0)
245
+            {
246
+                foreach (DataRow dr in ds.Tables[0].Rows)
247
+                {
248
+                    if (!string.IsNullOrEmpty(dr[0].ToString()))
249
+                    {
250
+                        lddep.Add(dr[0].ToString());
251
+                    }
252
+                }
253
+            }
254
+            return lddep;
255
+        }
256
+
257
+        /// <summary>
210 258
         /// 更新一条数据
211 259
         /// </summary>
212 260
         public bool Update(CallCenterApi.Model.T_Cus_CustomerBase model)
@@ -511,6 +559,34 @@ namespace CallCenterApi.DAL
511 559
             }
512 560
         }
513 561
 
562
+        /// <summary>
563
+        /// 通过电话获得客户实体
564
+        /// </summary>
565
+        /// <param name="F_Mobile">电话号码</param>
566
+        /// <returns></returns>
567
+        public CallCenterApi.Model.T_Cus_CustomerBase GetModel(string F_Mobile)
568
+        {
569
+
570
+            StringBuilder strSql = new StringBuilder();
571
+            strSql.Append("select top 1 * from T_Cus_CustomerBase ");
572
+            strSql.Append(" where F_Mobile=@F_Mobile");
573
+            SqlParameter[] parameters = {
574
+                    new SqlParameter("@F_Mobile", SqlDbType.NVarChar,200)
575
+            };
576
+            parameters[0].Value = F_Mobile;
577
+
578
+            CallCenterApi.Model.T_Cus_CustomerBase model = new CallCenterApi.Model.T_Cus_CustomerBase();
579
+            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
580
+            if (ds.Tables[0].Rows.Count > 0)
581
+            {
582
+                return DataRowToModel(ds.Tables[0].Rows[0]);
583
+            }
584
+            else
585
+            {
586
+                return null;
587
+            }
588
+        }
589
+
514 590
 
515 591
         /// <summary>
516 592
         /// 得到一个对象实体

+ 309 - 125
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/customer/CustomerController.cs

@@ -9,6 +9,10 @@ using System.Data;
9 9
 using CallCenter.Utility;
10 10
 using CallCenterApi.Common;
11 11
 using CallCenterApi.DB;
12
+using System.IO;
13
+using NPOI.XSSF.UserModel;
14
+using NPOI.HSSF.UserModel;
15
+using NPOI.SS.UserModel;
12 16
 
13 17
 namespace CallCenterApi.Interface.Controllers.customer
14 18
 {
@@ -27,63 +31,63 @@ namespace CallCenterApi.Interface.Controllers.customer
27 31
                 string sql = " and F_DeleteFlag=0";
28 32
                 DataTable dt = new DataTable();
29 33
 
30
-                    string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
31
-                    string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
32
-                    string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
33
-                    string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
34
+                string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
35
+                string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
36
+                string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
37
+                string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
34 38
 
35
-                    string strpageindex = RequestString.GetQueryString("page");
36
-                    int pageindex = 1;
37
-                    string strpagesize = RequestString.GetQueryString("pagesize");
38
-                    int pagesize = 10;
39
+                string strpageindex = RequestString.GetQueryString("page");
40
+                int pageindex = 1;
41
+                string strpagesize = RequestString.GetQueryString("pagesize");
42
+                int pagesize = 10;
39 43
 
40
-                    if (strname.Trim() != "" && strname != "undefined")
41
-                    {
42
-                        sql += " and F_CustomerName like '%" + strname.Trim() + "%' ";
43
-                    }
44
-                    if (strtel.Trim() != "" && strtel != "undefined")
45
-                    {
46
-                        sql += " and (F_Telephone like '%" + strtel + "%' or F_Mobile like '%" + strtel + "%' or F_ChargeTelephone like '%" + strtel + "%') ";
47
-                    }
48
-                    if (strstarttime.Trim() != "" && strstarttime != "undefined")
49
-                    {
50
-                        sql += " and datediff(day,F_CreatedOn,'" + strstarttime + "')<=0 ";
51
-                    }
52
-                    if (strendtime.Trim() != "" && strendtime != "undefined")
53
-                    {
54
-                        sql += " and datediff(day,F_CreatedOn,'" + strendtime + "')>=0   ";
55
-                    }
44
+                if (strname.Trim() != "" && strname != "undefined")
45
+                {
46
+                    sql += " and F_CustomerName like '%" + strname.Trim() + "%' ";
47
+                }
48
+                if (strtel.Trim() != "" && strtel != "undefined")
49
+                {
50
+                    sql += " and (F_Telephone like '%" + strtel + "%' or F_Mobile like '%" + strtel + "%' or F_ChargeTelephone like '%" + strtel + "%') ";
51
+                }
52
+                if (strstarttime.Trim() != "" && strstarttime != "undefined")
53
+                {
54
+                    sql += " and datediff(day,F_CreatedOn,'" + strstarttime + "')<=0 ";
55
+                }
56
+                if (strendtime.Trim() != "" && strendtime != "undefined")
57
+                {
58
+                    sql += " and datediff(day,F_CreatedOn,'" + strendtime + "')>=0   ";
59
+                }
56 60
 
57
-                    if (strpageindex.Trim() != "")
58
-                    {
59
-                        pageindex = Convert.ToInt32(strpageindex);
60
-                    }
61
+                if (strpageindex.Trim() != "")
62
+                {
63
+                    pageindex = Convert.ToInt32(strpageindex);
64
+                }
61 65
 
62
-                    if (strpagesize.Trim() != "")
63
-                    {
64
-                        pagesize = Convert.ToInt32(strpagesize);
65
-                    }
66
-                    int recordCount = 0;
67
-                    dt = BLL.PagerBLL.GetListPager(
68
-                        "T_Cus_CustomerBase",
69
-                        "F_CustomerId",
70
-                        "*",
71
-                        sql,
72
-                        "ORDER BY F_CustomerId desc",
73
-                        pagesize,
74
-                        pageindex,
75
-                        true,
76
-                        out recordCount);
77
-
78
-                    var obj = new
79
-                    {
80
-                        state = "success",
81
-                        message = "成功",
82
-                        rows = dt,
83
-                        total = recordCount
84
-                    };
66
+                if (strpagesize.Trim() != "")
67
+                {
68
+                    pagesize = Convert.ToInt32(strpagesize);
69
+                }
70
+                int recordCount = 0;
71
+                dt = BLL.PagerBLL.GetListPager(
72
+                    "T_Cus_CustomerBase",
73
+                    "F_CustomerId",
74
+                    "*",
75
+                    sql,
76
+                    "ORDER BY F_CustomerId desc",
77
+                    pagesize,
78
+                    pageindex,
79
+                    true,
80
+                    out recordCount);
81
+
82
+                var obj = new
83
+                {
84
+                    state = "success",
85
+                    message = "成功",
86
+                    rows = dt,
87
+                    total = recordCount
88
+                };
85 89
 
86
-                    res = Content(obj.ToJson());
90
+                res = Content(obj.ToJson());
87 91
 
88 92
             }
89 93
             return res;
@@ -99,27 +103,57 @@ namespace CallCenterApi.Interface.Controllers.customer
99 103
             if (Request.IsAuthenticated)
100 104
             {
101 105
 
102
-                    int cid = Utils.StrToInt(RequestString.GetQueryString("cid"), 0);
103
-                    if (cid != 0)
106
+                int cid = Utils.StrToInt(RequestString.GetQueryString("cid"), 0);
107
+                if (cid != 0)
108
+                {
109
+                    Model.T_Cus_CustomerBase userModel = new BLL.T_Cus_CustomerBase().GetModel(cid);
110
+                    if (userModel != null)
104 111
                     {
105
-                        Model.T_Cus_CustomerBase userModel = new BLL.T_Cus_CustomerBase().GetModel(cid);
106
-                        if (userModel != null)
107
-                        {
108
-                            res = Success("获取成功", userModel);
109
-                        }
110
-                        else
111
-                        {
112
-                            res = Error("获取失败");
113
-                        }
112
+                        res = Success("获取成功", userModel);
114 113
                     }
115 114
                     else
116 115
                     {
117
-                        res = Error("参数传输失败");
116
+                        res = Error("获取失败");
118 117
                     }
118
+                }
119
+                else
120
+                {
121
+                    res = Error("参数传输失败");
122
+                }
119 123
 
120 124
             }
121 125
             return res;
122 126
         }
127
+        /// <summary>
128
+        /// 通过来电号码获取来电弹屏左侧客户信息
129
+        /// </summary>
130
+        /// <returns></returns>
131
+        public ActionResult GetCustomerByTel()
132
+        {
133
+            ActionResult res = NoToken("未知错误,请重新登录");
134
+            if (Request.IsAuthenticated)
135
+            {
136
+
137
+                string tel = RequestString.GetQueryString("tel");
138
+                if (!string.IsNullOrEmpty(tel))
139
+                {
140
+                    Model.T_Cus_CustomerBase userModel = new BLL.T_Cus_CustomerBase().GetModel(tel);
141
+                    if (userModel != null)
142
+                    {
143
+                        res = Success("获取成功", userModel);
144
+                    }
145
+                    else
146
+                    {
147
+                        res = Error("获取失败");
148
+                    }
149
+                }
150
+                else
151
+                {
152
+                    res = Error("参数传输失败");
153
+                }
154
+            }
155
+            return res;
156
+        }
123 157
 
124 158
         /// <summary>
125 159
         /// 添加/修改客户信息
@@ -130,72 +164,66 @@ namespace CallCenterApi.Interface.Controllers.customer
130 164
             ActionResult res = NoToken("未知错误,请重新登录");
131 165
             if (Request.IsAuthenticated)
132 166
             {
167
+                int userId = CurrentUser.UserData.F_UserId;
168
+                if (userId != 0)
169
+                {
170
+                    //联系人
171
+                    string name = RequestString.GetFormString("name");
172
+                    string province = RequestString.GetFormString("province");
173
+                    //客户名称
174
+                    string customerindustry = RequestString.GetFormString("customerindustry");
175
+                    string mobile = RequestString.GetFormString("mobile");
176
+                    //获取当前表格选择的客户
177
+                    int cid = Utils.StrToInt(RequestString.GetFormString("cid"), 0);
133 178
 
134
-                    int userId = CurrentUser.UserData.F_UserId;
135
-                    if (userId != 0)
179
+                    Model.T_Cus_CustomerBase model = new Model.T_Cus_CustomerBase();
180
+                    BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
181
+                    //添加或修改时要根据电话判断是否已有记录
182
+                    if (cid == 0)
136 183
                     {
137
-                        string name = RequestString.GetFormString("name");
138
-                        string code = RequestString.GetFormString("code");
139
-                        string ename = RequestString.GetFormString("ename");
140
-                        string mobile = RequestString.GetFormString("mobile");
141
-                        string telphone = RequestString.GetFormString("telphone");
142
-                        string chargetelephone = RequestString.GetFormString("chargetelephone");
143
-
144
-                        int cid = Utils.StrToInt(RequestString.GetFormString("cid"), 0);
145
-
184
+                        model.F_CustomerName = name;
185
+                        model.F_Province = province;
186
+                        model.F_CustomerIndustry = customerindustry;
187
+                        model.F_Mobile = mobile;
146 188
 
147
-                        Model.T_Cus_CustomerBase model = new Model.T_Cus_CustomerBase();
148
-                        BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
149
-                        if (cid == 0)
189
+                        model.F_CreateBy = userId;
190
+                        model.F_CreatedOn = DateTime.Now;
191
+                        model.F_DeleteFlag = 0;
192
+                        int n = bll.Add(model);
193
+                        if (n > 0)
194
+                        {
195
+                            res = Success("新增成功!", n);
196
+                        }
197
+                        else
198
+                        {
199
+                            res = Error("新增失败!");
200
+                        }
201
+                    }
202
+                    else
203
+                    {
204
+                        model = bll.GetModel(cid);
205
+                        if (model != null)
150 206
                         {
151 207
                             model.F_CustomerName = name;
152
-                            model.F_CustomerCode = code;
153
-                            model.F_CustomerEName = ename;
208
+                            model.F_Province = province;
209
+                            model.F_CustomerIndustry = customerindustry;
154 210
                             model.F_Mobile = mobile;
155
-                            model.F_Telephone = telphone;
156
-                            model.F_ChargeTelephone = chargetelephone;
157
-
158
-                            model.F_CreateBy = userId;
159
-                            model.F_CreatedOn = DateTime.Now;
160
-                            model.F_DeleteFlag = 0;
161
-                            int n = bll.Add(model);
162
-                            if (n > 0)
211
+                            if (bll.Update(model))
163 212
                             {
164
-                                res = Success("新增成功!", n);
213
+                                res = Success("修改成功!");
165 214
                             }
166 215
                             else
167 216
                             {
168
-                                res = Error("新增失败!");
169
-                            }
170
-                        }
171
-                        else
172
-                        {
173
-                            model = bll.GetModel(cid);
174
-                            if (model != null)
175
-                            {
176
-                                model.F_CustomerName = name;
177
-                                model.F_CustomerCode = code;
178
-                                model.F_CustomerEName = ename;
179
-                                model.F_Mobile = mobile;
180
-                                model.F_Telephone = telphone;
181
-                                model.F_ChargeTelephone = chargetelephone;
182
-                                if (bll.Update(model))
183
-                                {
184
-                                    res = Success("修改成功!");
185
-                                }
186
-                                else
187
-                                {
188
-                                    res = Error("修改失败!");
189
-                                }
217
+                                res = Error("修改失败!");
190 218
                             }
191 219
                         }
192 220
                     }
221
+                }
193 222
 
194 223
             }
195 224
             return res;
196 225
         }
197 226
 
198
-
199 227
         /// <summary>
200 228
         /// 删除客户
201 229
         /// </summary>
@@ -207,37 +235,193 @@ namespace CallCenterApi.Interface.Controllers.customer
207 235
             if (Request.IsAuthenticated)
208 236
             {
209 237
 
210
-                    if (ids != null && ids.Length > 0)
238
+                if (ids != null && ids.Length > 0)
239
+                {
240
+                    string idd = " ";
241
+                    foreach (string str in ids)
242
+                    {
243
+                        idd += str + ",";
244
+                    }
245
+                    //string state = RequestString.GetQueryString("state");
246
+
247
+                    string sql = "update T_Cus_CustomerBase set F_DeleteFlag=1 where F_CustomerId in(" + idd.TrimEnd(',') + ")";
248
+                    if (!string.IsNullOrEmpty(idd.Trim()))
211 249
                     {
212
-                        string idd = " ";
213
-                        foreach (string str in ids)
250
+                        if (DbHelperSQL.ExecuteSql(sql) > 0)
214 251
                         {
215
-                            idd += str + ",";
252
+                            res = Success("设置成功");
216 253
                         }
217
-                        //string state = RequestString.GetQueryString("state");
254
+                        else
255
+                        {
256
+                            res = Error("设置失败");
257
+                        }
258
+                    }
259
+                    else
260
+                    {
261
+                        res = Error("请选择用户");
262
+                    }
263
+                }
264
+                else
265
+                {
266
+                    res = Error("获取参数失败");
267
+                }
218 268
 
219
-                        string sql = "update T_Cus_CustomerBase set F_DeleteFlag=1 where F_CustomerId in(" + idd.TrimEnd(',') + ")";
220
-                        if (!string.IsNullOrEmpty(idd.Trim()))
269
+            }
270
+            return res;
271
+        }
272
+        /// <summary>
273
+        /// 绑定来电单位
274
+        /// </summary>
275
+        /// <returns></returns>
276
+        public ActionResult BindLDdep()
277
+        {
278
+            ActionResult res = NoToken("未知错误,请重新登录");
279
+            if (Request.IsAuthenticated)
280
+            {
281
+                List<string> lddep = new BLL.T_Cus_CustomerBase().GetLDdep();
282
+                if (lddep != null && lddep.Count > 0)
283
+                {
284
+                    res = Success("获取成功", lddep);
285
+                }
286
+                else
287
+                {
288
+                    res = Error("获取失败");
289
+                }
290
+            }
291
+            return res;
292
+        }
293
+        /// <summary>
294
+        /// 判断来电单位是否存在。不存在才可以
295
+        /// </summary>
296
+        /// <returns></returns>
297
+        public ActionResult LDdepExist()
298
+        {
299
+            ActionResult res = NoToken("未知错误,请重新登录");
300
+            if (Request.IsAuthenticated)
301
+            {
302
+                string lddep = RequestString.GetQueryString("lddep");
303
+                if (!string.IsNullOrEmpty(lddep))
304
+                {
305
+                    bool lddepexists = new BLL.T_Cus_CustomerBase().LDdepExist(lddep);
306
+                    if (lddepexists)
307
+                    {
308
+                        res = Success("获取成功");
309
+                    }
310
+                    else
311
+                    {
312
+                        res = Error("获取失败");
313
+                    }
314
+                }
315
+                else
316
+                {
317
+                    res = Error("参数传输失败");
318
+                }
319
+            }
320
+            return res;
321
+        }
322
+        /// <summary>
323
+        /// 导入excel
324
+        /// </summary>
325
+        /// <returns></returns>
326
+        public ActionResult ExportExcel()
327
+        {
328
+            ActionResult res = NoToken("未知错误,请重新登录");
329
+            if (Request.IsAuthenticated)
330
+            {
331
+                //string filestr = RequestString.GetFormString("file");
332
+                //string filestr = RequestString.GetQueryString("file");
333
+                int userId = CurrentUser.UserData.F_UserId;
334
+                if (userId != 0)
335
+                {
336
+                    //需要先将文件保存到服务器项目下,再读取
337
+                    //传入的应该是整个文件,file和上传按钮
338
+                    string file = Request.Files[0].FileName;
339
+                    string fileextension = Request.Files[0].ContentType;
340
+
341
+                    if (!string.IsNullOrEmpty(file) && file != "undefined")
342
+                    {
343
+                        //string extensionstr = Path.GetExtension(filestr);
344
+                        //if (extensionstr == ".xls" || extensionstr == ".xlsx")
345
+                        if (fileextension == "application/vnd.ms-excel" || fileextension == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
221 346
                         {
222
-                            if (DbHelperSQL.ExecuteSql(sql) > 0)
347
+                            //将上传的文件保存在服务器下
348
+                            Request.SaveAs(Server.MapPath("~/App_Data/" + file), false);
349
+
350
+                            if (System.IO.File.Exists(Server.MapPath("~/App_Data/" + file)))
223 351
                             {
224
-                                res = Success("设置成功");
352
+                                HSSFWorkbook hssfworkbook;
353
+                                XSSFWorkbook xssfworkbook;
354
+                                ISheet sheet;
355
+                                DataTable dt = new DataTable();
356
+                                using (FileStream filestream = new FileStream(Path.GetFullPath(file), FileMode.Open, FileAccess.Read))
357
+                                {
358
+                                    if (fileextension == "application/vnd.ms-excel")
359
+                                    {
360
+                                        hssfworkbook = new HSSFWorkbook(filestream);
361
+                                        sheet = hssfworkbook.GetSheetAt(0);
362
+                                    }
363
+                                    else
364
+                                    {
365
+                                        xssfworkbook = new XSSFWorkbook(filestream);
366
+                                        sheet = xssfworkbook.GetSheetAt(0);
367
+                                    }
368
+                                }
369
+                                System.Collections.IEnumerator rows = sheet.GetRowEnumerator();
370
+
371
+                                IRow headerRow = sheet.GetRow(0);
372
+                                int cellCount = headerRow.LastCellNum;
373
+
374
+                                for (int j = 0; j < cellCount; j++)
375
+                                {
376
+                                    ICell cell = headerRow.GetCell(j);
377
+                                    dt.Columns.Add(cell.ToString());
378
+                                }
379
+
380
+                                Model.T_Cus_CustomerBase model = new Model.T_Cus_CustomerBase();
381
+                                BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
382
+                                int count = 0;
383
+                                for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
384
+                                {
385
+                                    IRow row = sheet.GetRow(i);
386
+                                    DataRow dataRow = dt.NewRow();
387
+
388
+                                    for (int j = row.FirstCellNum; j < cellCount; j++)
389
+                                    {
390
+                                        if (row.GetCell(j) != null)
391
+                                            dataRow[j] = row.GetCell(j).ToString();
392
+                                    }
393
+                                    dt.Rows.Add(dataRow);
394
+
395
+                                    //导入后要插入数据库
396
+                                    model.F_CustomerName = dataRow[2].ToString();
397
+                                    model.F_Province = dataRow[0].ToString();
398
+                                    model.F_CustomerIndustry = dataRow[1].ToString();
399
+                                    model.F_Mobile = dataRow[3].ToString();
400
+
401
+                                    model.F_CreateBy = userId;
402
+                                    model.F_CreatedOn = DateTime.Now;
403
+                                    model.F_DeleteFlag = 0;
404
+                                    int n = bll.Add(model);
405
+                                    if (n > 0)
406
+                                    { count++; }
407
+                                }
408
+                                res = Success("共导入" + dt.Rows.Count + "条,成功" + count + "条", dt);
225 409
                             }
226 410
                             else
227 411
                             {
228
-                                res = Error("设置失败");
412
+                                res = Error("文件未上传成功");
229 413
                             }
230 414
                         }
231 415
                         else
232 416
                         {
233
-                            res = Error("请选择用户");
417
+                            res = Error("文件类型错误");
234 418
                         }
235 419
                     }
236 420
                     else
237 421
                     {
238
-                        res = Error("获取参数失败");
422
+                        res = Error("参数传输失败");
239 423
                     }
240
-
424
+                }
241 425
             }
242 426
             return res;
243 427
         }

+ 192 - 183
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/tel/CallInScreenController.cs

@@ -21,63 +21,63 @@ namespace CallCenterApi.Interface.Controllers.tel
21 21
             ActionResult res = NoToken("未知错误,请重新登录");
22 22
             if (Request.IsAuthenticated)
23 23
             {
24
-                
25
-                    int userId = CurrentUser.UserData.F_UserId;
26
-                    if (userId != 0)
24
+
25
+                int userId = CurrentUser.UserData.F_UserId;
26
+                if (userId != 0)
27
+                {
28
+                    Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
29
+                    if (ua != null)
27 30
                     {
28
-                        Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
29
-                        if (ua != null)
31
+                        string tel = HttpUtility.UrlDecode(RequestString.GetFormString("tel"));
32
+                        string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
33
+                        int n = RequestString.GetInt("num", 0);
34
+                        int type = RequestString.GetInt("type", 0);
35
+                        Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
36
+
37
+                        var date = DateTime.Now;
38
+                        var enddate = date;
39
+                        switch (type)
40
+                        {
41
+                            case 1: enddate = enddate.AddDays(n); break;
42
+                            case 2: enddate = enddate.AddHours(n); break;
43
+                            case 3: enddate = enddate.AddMinutes(n); break;
44
+                            case 4: enddate = DateTime.MaxValue; break;
45
+                        }
46
+                        if (dModel == null)
30 47
                         {
31
-                            string tel = HttpUtility.UrlDecode(RequestString.GetFormString("tel"));
32
-                            string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
33
-                            int n = RequestString.GetInt("num", 0);
34
-                            int type = RequestString.GetInt("type", 0);
35
-                            Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
36
-
37
-                            var date = DateTime.Now;
38
-                            var enddate = date;
39
-                            switch (type)
48
+                            dModel = new Model.T_Call_Blacklist();
49
+                            dModel.F_CallId = callid;
50
+                            dModel.F_TelPhone = tel.Trim();
51
+                            dModel.F_SetTime = date;
52
+                            dModel.F_RemoveTime = enddate;
53
+                            dModel.F_InterceptNum = 1;
54
+                            dModel.F_UserId = ua.F_UserId;
55
+                            int b = new BLL.T_Call_Blacklist().Add(dModel);
56
+                            if (b > 0)
40 57
                             {
41
-                                case 1: enddate = enddate.AddDays(n); break;
42
-                                case 2: enddate = enddate.AddHours(n); break;
43
-                                case 3: enddate = enddate.AddMinutes(n); break;
44
-                                case 4: enddate = DateTime.MaxValue; break;
58
+                                res = Success("添加成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
45 59
                             }
46
-                            if (dModel == null)
60
+                            else
47 61
                             {
48
-                                dModel = new Model.T_Call_Blacklist();
49
-                                dModel.F_CallId = callid;
50
-                                dModel.F_TelPhone = tel.Trim();
51
-                                dModel.F_SetTime = date;
52
-                                dModel.F_RemoveTime = enddate;
53
-                                dModel.F_InterceptNum = 1;
54
-                                dModel.F_UserId = ua.F_UserId;
55
-                                int b = new BLL.T_Call_Blacklist().Add(dModel);
56
-                                if (b > 0)
57
-                                {
58
-                                    res = Success("添加成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
59
-                                }
60
-                                else
61
-                                {
62
-                                    res = Error("添加失败");
63
-                                }
62
+                                res = Error("添加失败");
63
+                            }
64
+                        }
65
+                        else
66
+                        {
67
+
68
+                            dModel.F_RemoveTime = enddate;
69
+                            if (new BLL.T_Call_Blacklist().Update(dModel))
70
+                            {
71
+                                res = Success("修改成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
64 72
                             }
65 73
                             else
66 74
                             {
67
-
68
-                                dModel.F_RemoveTime = enddate;
69
-                                if (new BLL.T_Call_Blacklist().Update(dModel))
70
-                                {
71
-                                    res = Success("修改成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
72
-                                }
73
-                                else
74
-                                {
75
-                                    res = Error("修改失败");
76
-                                }
75
+                                res = Error("修改失败");
77 76
                             }
78 77
                         }
79 78
                     }
80
-              
79
+                }
80
+
81 81
             }
82 82
             return res;
83 83
         }
@@ -184,7 +184,7 @@ namespace CallCenterApi.Interface.Controllers.tel
184 184
                 if (tel.Trim().Length == 11 && tel.Substring(0, 1) != "0")
185 185
                 {
186 186
                     BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
187
-                    Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='" + tel.Substring(0, 7) + "' ").FirstOrDefault(); 
187
+                    Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='" + tel.Substring(0, 7) + "' ").FirstOrDefault();
188 188
 
189 189
                     if (mobileModel != null)
190 190
                     {
@@ -293,17 +293,17 @@ namespace CallCenterApi.Interface.Controllers.tel
293 293
                     }
294 294
                 }
295 295
 
296
-                int hrcount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=0 "+ sqlcount);
297
-                int hccount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=1 "+ sqlcount);
298
-                
296
+                int hrcount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=0 " + sqlcount);
297
+                int hccount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=1 " + sqlcount);
298
+
299 299
                 var obj = new
300 300
                 {
301 301
                     state = "success",
302 302
                     message = "成功",
303 303
                     rows = dt,
304 304
                     total = recordCount,
305
-                    hrcount=hrcount,
306
-                    hccount=hccount,
305
+                    hrcount = hrcount,
306
+                    hccount = hccount,
307 307
                 };
308 308
 
309 309
                 res = Content(obj.ToJson());
@@ -354,34 +354,34 @@ namespace CallCenterApi.Interface.Controllers.tel
354 354
             ActionResult res = NoToken("未知错误,请重新登录");
355 355
             if (Request.IsAuthenticated)
356 356
             {
357
-               
358
-                    int userId = CurrentUser.UserData.F_UserId;
359
-                    if (userId != 0)
357
+
358
+                int userId = CurrentUser.UserData.F_UserId;
359
+                if (userId != 0)
360
+                {
361
+                    Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
362
+                    if (ua != null)
360 363
                     {
361
-                        Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
362
-                        if (ua != null)
363
-                        {
364
-                            Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
365
-                            model.CallId = RequestString.GetFormString("callid");
366
-                            model.UserId = ua.F_UserId;
367
-                            model.UserCode = ua.F_UserCode;
368
-                            model.UserName = ua.F_UserName;
364
+                        Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
365
+                        model.CallId = RequestString.GetFormString("callid");
366
+                        model.UserId = ua.F_UserId;
367
+                        model.UserCode = ua.F_UserCode;
368
+                        model.UserName = ua.F_UserName;
369 369
                         //model.ExtNumber = ua.F_WorkNumber;
370 370
                         model.ExtNumber = CurrentUser.UserData.F_ExtensionNumber;
371 371
 
372
-                            model.DealType = 5;
373
-                            bool bl = new BLL.T_Call_CallRecords().UpdateCallInRingTelRecord(model);
374
-                            if (bl)
375
-                            {
376
-                                res = Success("更新振铃状态成功");
377
-                            }
378
-                            else
379
-                            {
380
-                                res = Error("更新振铃状态失败");
381
-                            }
372
+                        model.DealType = 5;
373
+                        bool bl = new BLL.T_Call_CallRecords().UpdateCallInRingTelRecord(model);
374
+                        if (bl)
375
+                        {
376
+                            res = Success("更新振铃状态成功");
377
+                        }
378
+                        else
379
+                        {
380
+                            res = Error("更新振铃状态失败");
382 381
                         }
383 382
                     }
384
-            
383
+                }
384
+
385 385
             }
386 386
             return res;
387 387
         }
@@ -498,53 +498,63 @@ namespace CallCenterApi.Interface.Controllers.tel
498 498
                     Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
499 499
                     if (ua != null)
500 500
                     {
501
-                        int type = RequestString.GetInt("type", 0);
502
-                        int tslx = RequestString.GetInt("tslx", 0);
503
-                        string callid = RequestString.GetFormString("callid");
504
-                        int khid = RequestString.GetInt("khid", 0);
505
-                        string tskh = RequestString.GetFormString("tskh");
506
-                        string tsdh = RequestString.GetFormString("tsdh");
507
-                        int zrbm = RequestString.GetInt("zrbm", 0);
508
-                        int zrid = RequestString.GetInt("zrid", 0);
509
-                        string cont = RequestString.GetFormString("cont");
510
-                        string answer = RequestString.GetFormString("answer");
511
-                        string clcont = RequestString.GetFormString("clcont");
512
-
513
-                        int clbm = RequestString.GetInt("clbm", 0);
514
-                        int clid = RequestString.GetInt("clid", 0);
501
+                        //姓名
502
+                        string callCustomer = RequestString.GetFormString("callCustomer");
503
+                        //电话
504
+                        string tel = RequestString.GetFormString("tel");
505
+                        //来电单位
506
+                        string lddep = RequestString.GetFormString("lddep");
507
+                        //反馈单位
508
+                        string fkdep = RequestString.GetFormString("fkdep");
509
+                        //工单来源
510
+                        int gdly = RequestString.GetInt("gdlx", 0);
511
+                        //工单类型
512
+                        int gdlx = RequestString.GetInt("gdlx", 0);
513
+                        //工单状态
514
+                        int gdzt = RequestString.GetInt("gdzt", 0);
515
+                        //反馈内容
516
+                        string fkcont = RequestString.GetFormString("fkcont");
517
+                        //快递信息
518
+                        string sendmsg = RequestString.GetFormString("sendmsg");
519
+                        //备注1
520
+                        string note1 = RequestString.GetFormString("note1");
521
+                        //备注2
522
+                        string note2 = RequestString.GetFormString("note2");
523
+                        //备注3
524
+                        string note3 = RequestString.GetFormString("note3");
525
+                        //callID
526
+                        string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
515 527
 
516 528
                         Model.T_Wo_WorkOrder model = new Model.T_Wo_WorkOrder();
517 529
                         model.WorkOrderID = DateTime.Now.ToString("yyyyMMddHHmmssms");//工单编号
518
-                        model.CallID = callid;
519
-                        model.Customer = tskh;
520
-                        model.CustomerID = khid;
521
-                        model.CustomerTel = tsdh;
522
-                        model.Detail = cont;
523
-                        model.Clcontent = clcont;
524
-                        model.Type = type;
525
-                        model.TypeClass = tslx;
526
-
527
-                        if (type == 1)
528
-                        {
529
-                            model.State = 2;
530
-                        }
531
-                        else
532
-                            model.State = 0;
530
+                        model.Customer = callCustomer;
531
+                        model.CustomerTel = tel;
532
+                        //工单来源
533
+                        model.Type = gdly;
534
+                        //工单类型
535
+                        model.TypeClass = gdlx;
536
+                        //反馈内容
537
+                        model.Detail = fkcont;
538
+                        //快递信息
539
+                        model.Files = sendmsg;
540
+                        //备注一
541
+                        model.County = note1;
542
+                        //备注二
543
+                        model.Province = note2;
544
+                        //备注三
545
+                        model.City = note3;
546
+                        //默认为待指派
547
+                        model.State = 0;
533 548
                         model.IsDel = 0;
534 549
                         model.IsReturn = 0;
535 550
                         model.IsReturnBak = 0;
536
-                        model.ResponDept = zrbm;
537
-                        model.Answer = answer;
551
+                        model.ResponDept = 0;
552
+                        model.Answer = "";
538 553
                         model.IsTimeOut = 0;
539 554
                         model.IsUserSend = 0;
540 555
                         model.IsAdminSend = 0;
541 556
 
542
-                        Model.T_Sys_UserAccount us = new BLL.T_Sys_UserAccount().GetModel(zrid);
543
-                        if (us != null)
544
-                        {
545
-                            model.ResponUser = us.F_UserCode;
546
-                        }
547
-                        Model.T_Wo_WorkOrderTimeOut to = new BLL.T_Wo_WorkOrderTimeOut().GetModel(type);
557
+                        Model.T_Wo_WorkOrderTimeOut to = new BLL.T_Wo_WorkOrderTimeOut().GetModel(gdlx);
548 558
                         if (to != null)
549 559
                         {
550 560
                             model.LimitTime = to.MainTime;
@@ -553,77 +563,77 @@ namespace CallCenterApi.Interface.Controllers.tel
553 563
                         model.CreateUser = ua.F_UserCode;
554 564
                         model.CreateTime = DateTime.Now;
555 565
 
556
-                        if (clbm != 0 || clid != 0)
557
-                        {
558
-                            Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
559
-                            item.WorkOrderID = model.WorkOrderID;
560
-                            item.ToDept = clbm;
561
-                            item.Type = 1;
562
-
563
-                            if (clid != 0)
564
-                            {
565
-                                Model.T_Sys_UserAccount clus = new BLL.T_Sys_UserAccount().GetModel(clid);
566
-                                if (clus != null)
567
-                                {
568
-                                    item.ToUser = clus.F_UserCode;
569
-                                }
570
-                            }
571
-                            else
572
-                            {
573
-                                string users = string.Empty;
574
-                                var list = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId='" + clbm + "'");
575
-                                foreach (var l in list)
576
-                                {
577
-                                    if (string.IsNullOrEmpty(users))
578
-                                    {
579
-                                        users = l.F_UserCode;
580
-                                    }
581
-                                    else
582
-                                    {
583
-                                        users = users + "," + l.F_UserCode;
584
-                                    }
585
-                                }
586
-                                item.ToUser = users;
587
-                            }
588
-
589
-                            if (to != null)
590
-                            {
591
-                                item.LimitTime = to.ItemTime;
592
-                            }
593
-
594
-                            item.Detail = answer;
595
-                            item.IsLast = 0;
596
-                            item.State = 0;
597
-                            item.IsStart = 0;
598
-                            item.IsTimeOut = 0;
599
-                            item.IsDel = 0;
600
-                            item.CreateUser = ua.F_UserCode;
601
-                            item.CreateTime = DateTime.Now;
602
-
603
-                            long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
604
-                            if (itemid > 0)
605
-                            {
606
-                                model.State = 1;//已指派
607
-                                model.AppointTime = DateTime.Now;
608
-
609
-                                #region 消息表
610
-                                foreach (string ur in item.ToUser.Split(','))
611
-                                {
612
-                                    Model.T_Msg_List msg = new Model.T_Msg_List();
613
-                                    msg.Type = 1;
614
-                                    msg.ToUser = ur;
615
-                                    msg.ToID = Int32.Parse(itemid.ToString());
616
-                                    msg.Detail = ua.F_UserName + "给你指派了工单,单号:" + model.WorkOrderID;
617
-                                    msg.State = 0;
618
-                                    msg.IsDel = 0;
619
-                                    msg.CreateUser = ua.F_UserCode;
620
-                                    msg.CreateDate = DateTime.Now;
621
-
622
-                                    new BLL.T_Msg_List().Add(msg);
623
-                                }
624
-                                #endregion
625
-                            }
626
-                        }
566
+                        //if (clbm != 0 || clid != 0)
567
+                        //{
568
+                        //    Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
569
+                        //    item.WorkOrderID = model.WorkOrderID;
570
+                        //    item.ToDept = clbm;
571
+                        //    item.Type = 1;
572
+
573
+                        //    if (clid != 0)
574
+                        //    {
575
+                        //        Model.T_Sys_UserAccount clus = new BLL.T_Sys_UserAccount().GetModel(clid);
576
+                        //        if (clus != null)
577
+                        //        {
578
+                        //            item.ToUser = clus.F_UserCode;
579
+                        //        }
580
+                        //    }
581
+                        //    else
582
+                        //    {
583
+                        //        string users = string.Empty;
584
+                        //        var list = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId='" + clbm + "'");
585
+                        //        foreach (var l in list)
586
+                        //        {
587
+                        //            if (string.IsNullOrEmpty(users))
588
+                        //            {
589
+                        //                users = l.F_UserCode;
590
+                        //            }
591
+                        //            else
592
+                        //            {
593
+                        //                users = users + "," + l.F_UserCode;
594
+                        //            }
595
+                        //        }
596
+                        //        item.ToUser = users;
597
+                        //    }
598
+
599
+                        //    if (to != null)
600
+                        //    {
601
+                        //        item.LimitTime = to.ItemTime;
602
+                        //    }
603
+
604
+                        //    item.Detail = answer;
605
+                        //    item.IsLast = 0;
606
+                        //    item.State = 0;
607
+                        //    item.IsStart = 0;
608
+                        //    item.IsTimeOut = 0;
609
+                        //    item.IsDel = 0;
610
+                        //    item.CreateUser = ua.F_UserCode;
611
+                        //    item.CreateTime = DateTime.Now;
612
+
613
+                        //    long itemid = new BLL.T_Wo_WorkOrderItem().Add(item);
614
+                        //    if (itemid > 0)
615
+                        //    {
616
+                        //        model.State = 1;//已指派
617
+                        //        model.AppointTime = DateTime.Now;
618
+
619
+                        //        #region 消息表
620
+                        //        foreach (string ur in item.ToUser.Split(','))
621
+                        //        {
622
+                        //            Model.T_Msg_List msg = new Model.T_Msg_List();
623
+                        //            msg.Type = 1;
624
+                        //            msg.ToUser = ur;
625
+                        //            msg.ToID = Int32.Parse(itemid.ToString());
626
+                        //            msg.Detail = ua.F_UserName + "给你指派了工单,单号:" + model.WorkOrderID;
627
+                        //            msg.State = 0;
628
+                        //            msg.IsDel = 0;
629
+                        //            msg.CreateUser = ua.F_UserCode;
630
+                        //            msg.CreateDate = DateTime.Now;
631
+
632
+                        //            new BLL.T_Msg_List().Add(msg);
633
+                        //        }
634
+                        //        #endregion
635
+                        //    }
636
+                        //}
627 637
 
628 638
                         if (new BLL.T_Wo_WorkOrder().Add(model) > 0)
629 639
                         {
@@ -681,7 +691,6 @@ namespace CallCenterApi.Interface.Controllers.tel
681 691
                         #endregion
682 692
                     }
683 693
                 }
684
-
685 694
             }
686 695
             return res;
687 696
         }

+ 189 - 34
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

@@ -143,12 +143,17 @@ namespace CallCenterApi.Interface.Controllers.workorder
143 143
                     Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
144 144
                     if (ua != null)
145 145
                     {
146
-                        string strorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("orderid"));
146
+                        //string strorderid = HttpUtility.UrlDecode(RequestString.GetQueryString("orderid"));
147
+                        //工单状态
147 148
                         string strltype = HttpUtility.UrlDecode(RequestString.GetQueryString("ltype"));
149
+                        //工单来源
148 150
                         string strtype = HttpUtility.UrlDecode(RequestString.GetQueryString("type"));
149
-                        string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
150
-                        string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
151
-                        string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
151
+                        //工单类型
152
+                        string strtypeclass = HttpUtility.UrlDecode(RequestString.GetQueryString("typeclass"));
153
+                        //string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
154
+                        //string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
155
+                        //string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
156
+                        //工单起止时间
152 157
                         string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
153 158
                         string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
154 159
 
@@ -157,45 +162,56 @@ namespace CallCenterApi.Interface.Controllers.workorder
157 162
                         string strpagesize = RequestString.GetQueryString("pagesize");
158 163
                         int pagesize = 10;
159 164
 
165
+                        //客服部根据工单状态判断是否加旗标,工程部根据备注
160 166
                         switch (strltype)
161 167
                         {
162
-                            case "0"://待指派的
168
+                            //case "0"://待指派的
169
+                            //    sql += " and State ='0' and CreateUser= '" + ua.F_UserCode + "' ";
170
+                            //    break;
171
+                            //case "1"://待接单的
172
+                            //    sql += " and State ='1' and WorkOrderID in ( '" + GetDJDWorkOrderID(ua.F_UserCode) + "') ";
173
+                            //    break;
174
+                            //case "2"://待完成的
175
+                            //    sql += " and State ='1' and WorkOrderID in ( '" + GetDWCWorkOrderID(ua.F_UserCode) + "') ";
176
+                            //    break;
177
+                            //case "3"://已完成的
178
+                            //    sql += " and State ='2' and LastDealUser = '" + ua.F_UserCode + "' ";
179
+                            //    break;
180
+                            //case "4"://我参与的
181
+                            //    sql += " and (CreateUser= '" + ua.F_UserCode + "' or WorkOrderID in ( '" + GetCYWorkOrderID(ua.F_UserCode) + "')) ";
182
+                            //    break;
183
+                            case "0"://待处理
163 184
                                 sql += " and State ='0' and CreateUser= '" + ua.F_UserCode + "' ";
164 185
                                 break;
165
-                            case "1"://待接单的
166
-                                sql += " and State ='1' and WorkOrderID in ( '" + GetDJDWorkOrderID(ua.F_UserCode) + "') ";
167
-                                break;
168
-                            case "2"://待完成的
169
-                                sql += " and State ='1' and WorkOrderID in ( '" + GetDWCWorkOrderID(ua.F_UserCode) + "') ";
170
-                                break;
171
-                            case "3"://已完成的
172
-                                sql += " and State ='2' and LastDealUser = '" + ua.F_UserCode + "' ";
173
-                                break;
174
-                            case "4"://我参与的
175
-                                sql += " and (CreateUser= '" + ua.F_UserCode + "' or WorkOrderID in ( '" + GetCYWorkOrderID(ua.F_UserCode) + "')) ";
186
+                            case "1"://已处理
187
+                                sql += " and State ='1' and LastDealUser = '" + ua.F_UserCode + "' ";
176 188
                                 break;
177 189
                         }
178 190
 
179
-                        if (strorderid.Trim() != "" && strorderid != "undefined")
180
-                        {
181
-                            sql += " and WorkOrderID like '%" + strorderid.Trim() + "%' ";
182
-                        }
191
+                        //if (strorderid.Trim() != "" && strorderid != "undefined")
192
+                        //{
193
+                        //    sql += " and WorkOrderID like '%" + strorderid.Trim() + "%' ";
194
+                        //}
183 195
                         if (strtype.Trim() != "" && strtype != "undefined")
184 196
                         {
185
-                            sql += " and Type = '" + strkey.Trim() + "' ";
186
-                        }
187
-                        if (strkey.Trim() != "" && strkey != "undefined")
188
-                        {
189
-                            sql += " and Detail like '%" + strkey.Trim() + "%' ";
197
+                            sql += " and Type = '" + strtype.Trim() + "' ";
190 198
                         }
191
-                        if (strname.Trim() != "" && strname != "undefined")
199
+                        if (strtypeclass.Trim() != "" && strtypeclass != "undefined")
192 200
                         {
193
-                            sql += " and Customer like '%" + strname.Trim() + "%' ";
194
-                        }
195
-                        if (strtel.Trim() != "" && strtel != "undefined")
196
-                        {
197
-                            sql += " and CustomerTel like '%" + strtel + "%'  ";
201
+                            sql += " and TypeClass = '" + strtype.Trim() + "' ";
198 202
                         }
203
+                        //if (strkey.Trim() != "" && strkey != "undefined")
204
+                        //{
205
+                        //    sql += " and Detail like '%" + strkey.Trim() + "%' ";
206
+                        //}
207
+                        //if (strname.Trim() != "" && strname != "undefined")
208
+                        //{
209
+                        //    sql += " and Customer like '%" + strname.Trim() + "%' ";
210
+                        //}
211
+                        //if (strtel.Trim() != "" && strtel != "undefined")
212
+                        //{
213
+                        //    sql += " and CustomerTel like '%" + strtel + "%'  ";
214
+                        //}
199 215
                         if (strstarttime.Trim() != "" && strstarttime != "undefined")
200 216
                         {
201 217
                             sql += " and datediff(day,CreateTime,'" + strstarttime + "')<=0 ";
@@ -243,7 +259,6 @@ namespace CallCenterApi.Interface.Controllers.workorder
243 259
                         res = Content(obj.ToJson());
244 260
                     }
245 261
                 }
246
-
247 262
             }
248 263
             return res;
249 264
         }
@@ -494,7 +509,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
494 509
         }
495 510
 
496 511
         /// <summary>
497
-        /// 添加/修改工单信息
512
+        /// 添加/修改工单信息客服部
498 513
         /// </summary>
499 514
         /// <returns></returns>
500 515
         public ActionResult AddWorkOrder()
@@ -502,7 +517,6 @@ namespace CallCenterApi.Interface.Controllers.workorder
502 517
             ActionResult res = NoToken("未知错误,请重新登录");
503 518
             if (Request.IsAuthenticated)
504 519
             {
505
-
506 520
                 int userId = CurrentUser.UserData.F_UserId;
507 521
                 if (userId != 0)
508 522
                 {
@@ -634,6 +648,147 @@ namespace CallCenterApi.Interface.Controllers.workorder
634 648
         }
635 649
 
636 650
         /// <summary>
651
+        /// 添加/修改工单信息市场部
652
+        /// </summary>
653
+        /// <returns></returns>
654
+        public ActionResult AddWorkOrderForMarket()
655
+        {
656
+            ActionResult res = NoToken("未知错误,请重新登录");
657
+            if (Request.IsAuthenticated)
658
+            {
659
+                int userId = CurrentUser.UserData.F_UserId;
660
+                if (userId != 0)
661
+                {
662
+                    Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
663
+                    if (ua != null)
664
+                    {
665
+                        int type = RequestString.GetInt("type", 0);
666
+                        int tslx = RequestString.GetInt("tslx", 0);
667
+                        string callid = RequestString.GetFormString("callid");
668
+                        int khid = RequestString.GetInt("khid", 0);
669
+                        string tskh = RequestString.GetFormString("tskh");
670
+                        string tsdh = RequestString.GetFormString("tsdh");
671
+                        int zrbm = RequestString.GetInt("zrbm", 0);
672
+                        int zrid = RequestString.GetInt("zrid", 0);
673
+                        string answer = RequestString.GetFormString("answer");
674
+                        string cont = RequestString.GetFormString("cont");
675
+                        //备注二
676
+                        string cont2 = RequestString.GetFormString("cont2");
677
+                        //备注三
678
+                        string cont3 = RequestString.GetFormString("cont3");
679
+
680
+                        Model.T_Wo_WorkOrder model = new Model.T_Wo_WorkOrder();
681
+                        model.WorkOrderID = DateTime.Now.ToString("yyyyMMddHHmmssmsfff");//工单编号
682
+                        model.CallID = callid;
683
+                        model.Customer = tskh;
684
+                        model.CustomerID = khid;
685
+                        model.CustomerTel = tsdh;
686
+                        model.Detail = cont;
687
+                        model.Type = type;
688
+                        model.TypeClass = tslx;
689
+                        model.Province = cont2;
690
+                        model.City = cont3;
691
+
692
+                        if (type == 1)
693
+                        {
694
+                            model.State = 2;
695
+                        }
696
+                        else
697
+                            model.State = 0;
698
+                        model.IsDel = 0;
699
+                        model.IsReturn = 0;
700
+                        model.IsReturnBak = 0;
701
+                        model.ResponDept = zrbm;
702
+                        model.IsTimeOut = 0;
703
+                        model.IsUserSend = 0;
704
+                        model.IsAdminSend = 0;
705
+
706
+                        Model.T_Sys_UserAccount us = new BLL.T_Sys_UserAccount().GetModel(zrid);
707
+                        if (us != null)
708
+                        {
709
+                            model.ResponUser = us.F_UserCode;
710
+                        }
711
+                        Model.T_Wo_WorkOrderTimeOut to = new BLL.T_Wo_WorkOrderTimeOut().GetModel(type);
712
+                        if (to != null)
713
+                        {
714
+                            model.LimitTime = to.MainTime;
715
+                        }
716
+                        model.IsAdminSend = 0;
717
+                        model.IsUserSend = 0;
718
+                        model.CreateUser = ua.F_UserCode;
719
+                        model.CreateTime = DateTime.Now;
720
+
721
+                        int clbm = RequestString.GetInt("clbm", 0);
722
+                        int clid = RequestString.GetInt("clid", 0);
723
+
724
+                        if (clbm != 0 || clid != 0)
725
+                        {
726
+                            Model.T_Wo_WorkOrderItem item = new Model.T_Wo_WorkOrderItem();
727
+                            item.WorkOrderID = model.WorkOrderID;
728
+                            item.ToDept = clbm;
729
+
730
+
731
+                            if (clid != 0)
732
+                            {
733
+                                Model.T_Sys_UserAccount clus = new BLL.T_Sys_UserAccount().GetModel(clid);
734
+                                if (clus != null)
735
+                                {
736
+                                    item.ToUser = clus.F_UserCode;
737
+                                }
738
+                            }
739
+                            else
740
+                            {
741
+                                string users = string.Empty;
742
+                                var list = new BLL.T_Sys_UserAccount().GetModelList(" F_DeptId='" + clbm + "'");
743
+                                foreach (var l in list)
744
+                                {
745
+                                    if (string.IsNullOrEmpty(users))
746
+                                    {
747
+                                        users = l.F_UserCode;
748
+                                    }
749
+                                    else
750
+                                    {
751
+                                        users = users + "," + l.F_UserCode;
752
+                                    }
753
+                                }
754
+                                item.ToUser = users;
755
+                            }
756
+
757
+                            if (to != null)
758
+                            {
759
+                                item.LimitTime = to.ItemTime;
760
+                            }
761
+
762
+                            item.Detail = answer;
763
+                            item.IsLast = 0;
764
+                            item.State = 0;
765
+                            item.IsStart = 0;
766
+                            item.IsTimeOut = 0;
767
+                            item.CreateUser = ua.F_UserCode;
768
+                            item.CreateTime = DateTime.Now;
769
+
770
+                            if (new BLL.T_Wo_WorkOrderItem().Add(item) > 0)
771
+                            {
772
+                                model.State = 1;//已指派
773
+                            }
774
+                        }
775
+
776
+                        if (new BLL.T_Wo_WorkOrder().Add(model) > 0)
777
+                        {
778
+                            res = Success("新增成功!");
779
+                        }
780
+                        else
781
+                        {
782
+                            res = Error("新增失败!");
783
+                        }
784
+                    }
785
+                }
786
+
787
+            }
788
+            return res;
789
+        }
790
+
791
+        /// <summary>
637 792
         /// 删除工单
638 793
         /// </summary>
639 794
         /// <param name="ids"></param>

+ 269 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkTypeController.cs

@@ -0,0 +1,269 @@
1
+using CallCenterApi.Interface.Controllers.Base;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Data;
5
+using System.Linq;
6
+using System.Web;
7
+using System.ServiceModel;
8
+using System.ServiceModel.Web;
9
+using System.Runtime.Serialization;
10
+using System.Web.Mvc;
11
+using System.Web.Script.Serialization;
12
+using CallCenter.Utility;
13
+
14
+namespace CallCenterApi.Interface.Controllers.workorder
15
+{
16
+    public class WorkTypeController : BaseController
17
+    {
18
+        /// <summary>
19
+        /// 加载工单类型
20
+        /// </summary>
21
+        /// <returns></returns>
22
+        public ActionResult GetTreeList()
23
+        {
24
+            ActionResult res = NoToken("未知错误,请重新登录");
25
+            string resstr = "";
26
+            if (Request.IsAuthenticated)
27
+            {
28
+                DataTable dt = new DataTable();
29
+
30
+                try
31
+                {
32
+                    //F_CategoryType=1为工单类型
33
+                    dt = new BLL.T_RepositoryCategory().GetList("F_ParentId=0 and F_DeleteFlag=0 and F_CategoryType=1").Tables[0];
34
+                    if (dt != null && dt.Rows.Count > 0)
35
+                    {
36
+                        System.Collections.Generic.List<Model.TreeModel> modelList = BindTree(dt, "0");
37
+                        //将对象转为json字符串
38
+                        //resstr = new JavaScriptSerializer().Serialize(modelList);
39
+                        res = Success("", modelList);
40
+                    }
41
+                }
42
+                catch (Exception err)
43
+                {
44
+                    //res = err.ToString(); 
45
+                }
46
+                finally
47
+                {
48
+                    dt.Clear();
49
+                    dt.Dispose();
50
+                }
51
+            }
52
+            return res;
53
+        }
54
+        /// <summary>
55
+        /// 删除工单
56
+        /// </summary>
57
+        /// <returns></returns>
58
+        public ActionResult DeleteById()
59
+        {
60
+            ActionResult res = NoToken("未知错误,请重新登录");
61
+            string resstr = "";
62
+            //获取选中的类别id
63
+            string id = RequestString.GetQueryString("id");
64
+            if (id != null && id.Length > 0)
65
+            {
66
+                //获取它下面的子类别
67
+                DataTable dt = new BLL.T_RepositoryCategory().GetList("F_DeleteFlag=0 and F_ParentId=" + Convert.ToInt32(id) + " and F_CategoryType=1").Tables[0];
68
+                string rid = string.Empty;
69
+                resstr = DeleteWoType(dt.Rows[0]["F_CategoryId"].ToString());
70
+
71
+                if (resstr == "")
72
+                    res = Success("删除成功");
73
+                else
74
+                {
75
+                    res = Error("删除失败");
76
+                }
77
+            }
78
+            else
79
+            {
80
+                res = Error("获取参数失败");
81
+            }
82
+
83
+            return res;
84
+        }
85
+        /// <summary>
86
+        /// 添加/修改工单类别
87
+        /// </summary>
88
+        /// <returns></returns>
89
+        public ActionResult Init()
90
+        {
91
+            ActionResult res = NoToken("未知错误,请重新登录");
92
+            string id = RequestString.GetQueryString("id");
93
+            try
94
+            {
95
+                T_RepositoryCategory = new BLL.T_RepositoryCategory().GetModel(Convert.ToInt32(id));
96
+                var obj = new
97
+                {
98
+                    catagoryname = name,
99
+                    parentid = pid,
100
+                    sort = sort
101
+                };
102
+                res = Success("", obj);
103
+            }
104
+            catch (Exception e)
105
+            {
106
+                res = Error(e.Message);
107
+            }
108
+            return res;
109
+        }
110
+        /// <summary>
111
+        /// 类别保存
112
+        /// </summary>
113
+        /// <returns></returns>
114
+        public ActionResult Save()
115
+        {
116
+            ActionResult res = NoToken("未知错误,请重新登录");
117
+            int bl = new BLL.T_RepositoryCategory().Add(T_RepositoryCategory);
118
+            if (bl > 0)
119
+            {
120
+                res = Success("新增成功");
121
+            }
122
+            else
123
+            {
124
+                res = Error("新增失败");
125
+            }
126
+            return res;
127
+        }
128
+
129
+        /// <summary>
130
+        /// 递归获取树形结构
131
+        /// </summary>
132
+        /// <param name="tab">数据源</param>
133
+        /// <param name="parentid">父节点ID</param>
134
+        /// <returns></returns>
135
+        public List<Model.TreeModel> BindTree(DataTable tab, string parentid)
136
+        {
137
+            DataTable tab2 = new DataTable();
138
+
139
+            if (tab != null && tab.Rows.Count > 0)
140
+            {
141
+                System.Collections.Generic.List<Model.T_RepositoryCategory> categorylist = new BLL.T_RepositoryCategory().DataTableToList(tab);
142
+                System.Collections.Generic.List<Model.TreeModel> modelList = new List<Model.TreeModel>(categorylist.Count);
143
+                for (int i = 0; i < categorylist.Count; i++)
144
+                {
145
+                    Model.TreeModel model = new Model.TreeModel();
146
+                    string currentID = categorylist[i].F_CategoryId.ToString();//当前功能ID
147
+                    model.id = currentID;
148
+                    model.IconCls = "";//图标
149
+                    model.text = categorylist[i].F_CategoryName;
150
+                    tab2 = new BLL.T_RepositoryCategory().GetList("F_ParentId=" + currentID + " and F_DeleteFlag=0 order by F_Sort").Tables[0];
151
+                    if (tab2 != null && tab2.Rows.Count > 0)
152
+                    {
153
+                        model.children = BindTree(tab2, currentID);
154
+                    }
155
+                    modelList.Add(model);
156
+                }
157
+                return modelList;
158
+
159
+            }
160
+            else
161
+            {
162
+                return null;
163
+            }
164
+
165
+        }
166
+        /// <summary>
167
+        /// 删除工单类别
168
+        /// </summary>
169
+        /// <param name="f_catagoryid">要删除的工单类别的类别id</param>
170
+        /// <returns></returns>
171
+        public string DeleteWoType(string f_catagoryid)
172
+        {
173
+            //获取它下面的子类别
174
+            string res = "";
175
+            DataTable dt = new BLL.T_RepositoryCategory().GetList("F_DeleteFlag=0 and F_ParentId=" + Convert.ToInt32(f_catagoryid) + " and F_CategoryType=1").Tables[0];
176
+            string rid = string.Empty;
177
+            if (dt.Rows.Count > 0)
178
+            {
179
+                try
180
+                {
181
+                    //先删除子类类别,再删除父类
182
+                    for (int i = 0; i < dt.Rows.Count; i++)
183
+                    {
184
+                        rid = dt.Rows[i]["F_CategoryId"].ToString();
185
+                        if (!string.IsNullOrEmpty(rid))
186
+                        {
187
+                            DataTable dtsub = new BLL.T_RepositoryCategory().GetList("F_DeleteFlag=0 and F_ParentId=" + Convert.ToInt32(rid) + " and F_CategoryType=1").Tables[0];
188
+                            if (dtsub.Rows.Count > 0)
189
+                            {
190
+                                DeleteWoType(dtsub.Rows[i]["F_CategoryId"].ToString());
191
+                            }
192
+                            else
193
+                            {
194
+                                new BLL.T_RepositoryCategory().Delete(Convert.ToInt32(rid));
195
+                            }
196
+                        }
197
+                    }
198
+                }
199
+                catch (Exception e)
200
+                {
201
+                    res = e.Message;
202
+                }
203
+            }
204
+            return res;
205
+        }
206
+
207
+        #region 公共属性
208
+        string id = "";
209
+        string name = "";
210
+        string pid = "";
211
+        string sort = "";
212
+
213
+        private Model.T_RepositoryCategory T_RepositoryCategory
214
+        {
215
+            get
216
+            {
217
+                Model.T_RepositoryCategory _model = new Model.T_RepositoryCategory();
218
+                id = RequestString.GetQueryString("id");
219
+                if (id.Trim() != "")
220
+                {
221
+                    _model.F_CategoryId = Convert.ToInt32(id.Trim());
222
+                }
223
+                else
224
+                {
225
+                    _model.F_CategoryId = 0;
226
+                }
227
+                name = RequestString.GetFormString("name");
228
+                _model.F_CategoryName = name.Trim();
229
+
230
+                pid = RequestString.GetFormString("pid");
231
+                try
232
+                {
233
+                    _model.F_ParentId = Convert.ToInt32(pid.Trim());
234
+                }
235
+                catch
236
+                {
237
+                    _model.F_ParentId = 0;
238
+                }
239
+
240
+                sort = RequestString.GetFormString("sort");
241
+                try
242
+                {
243
+                    _model.F_Sort = Convert.ToInt32(sort.Trim());
244
+                }
245
+                catch
246
+                {
247
+                    _model.F_Sort = 0;
248
+                }
249
+                if (_model.F_CreateOn == null)
250
+                    _model.F_CreateOn = DateTime.Now;
251
+                _model.F_DeleteFlag = 0;
252
+                //F_CategoryType = 1为工单类别
253
+                _model.F_CategoryType = 1;
254
+                return _model;
255
+            }
256
+            set
257
+            {
258
+                if (value != null)
259
+                {
260
+                    id = value.F_CategoryId.ToString();
261
+                    pid = value.F_ParentId.ToString();
262
+                    name = value.F_CategoryName;
263
+                    sort = value.F_Sort.ToString();
264
+                }
265
+            }
266
+        }
267
+        #endregion
268
+    }
269
+}

+ 4 - 4
codegit/CallCenterApi/CallCenterApi.Model/T_Cus_CustomerBase.cs

@@ -95,7 +95,7 @@ namespace CallCenterApi.Model
95 95
             get { return _f_customerid; }
96 96
         }
97 97
         /// <summary>
98
-        /// 
98
+        /// 客户名称
99 99
         /// </summary>
100 100
         public string F_CustomerName
101 101
         {
@@ -447,7 +447,7 @@ namespace CallCenterApi.Model
447 447
             get { return _f_chargetelephone; }
448 448
         }
449 449
         /// <summary>
450
-        /// 
450
+        /// 来电单位所在省份
451 451
         /// </summary>
452 452
         public string F_Province
453 453
         {
@@ -495,7 +495,7 @@ namespace CallCenterApi.Model
495 495
             get { return _f_customerclass; }
496 496
         }
497 497
         /// <summary>
498
-        /// 
498
+        /// 来电单位
499 499
         /// </summary>
500 500
         public string F_CustomerIndustry
501 501
         {
@@ -503,7 +503,7 @@ namespace CallCenterApi.Model
503 503
             get { return _f_customerindustry; }
504 504
         }
505 505
         /// <summary>
506
-        /// 
506
+        /// 反馈单位
507 507
         /// </summary>
508 508
         public string F_RelationShipClass
509 509
         {

+ 9 - 9
codegit/CallCenterApi/CallCenterApi.Model/T_Wo_WorkOrder.cs

@@ -68,7 +68,7 @@ namespace CallCenterApi.Model
68 68
             get { return _workorderid; }
69 69
         }
70 70
         /// <summary>
71
-        /// 工单类型
71
+        /// 工单来源
72 72
         /// </summary>
73 73
         public int? Type
74 74
         {
@@ -76,7 +76,7 @@ namespace CallCenterApi.Model
76 76
             get { return _type; }
77 77
         }
78 78
         /// <summary>
79
-        /// 工单类型分类
79
+        /// 工单类型
80 80
         /// </summary>
81 81
         public int? TypeClass
82 82
         {
@@ -92,7 +92,7 @@ namespace CallCenterApi.Model
92 92
             get { return _title; }
93 93
         }
94 94
         /// <summary>
95
-        /// 工单内容
95
+        /// 反馈内容/备注一
96 96
         /// </summary>
97 97
         public string Detail
98 98
         {
@@ -100,7 +100,7 @@ namespace CallCenterApi.Model
100 100
             get { return _detail; }
101 101
         }
102 102
         /// <summary>
103
-        /// 
103
+        /// 快递信息
104 104
         /// </summary>
105 105
         public string Files
106 106
         {
@@ -156,7 +156,7 @@ namespace CallCenterApi.Model
156 156
             get { return _customertel; }
157 157
         }
158 158
         /// <summary>
159
-        /// 
159
+        /// 备注二
160 160
         /// </summary>
161 161
         public string Province
162 162
         {
@@ -164,7 +164,7 @@ namespace CallCenterApi.Model
164 164
             get { return _province; }
165 165
         }
166 166
         /// <summary>
167
-        /// 
167
+        /// 备注三
168 168
         /// </summary>
169 169
         public string City
170 170
         {
@@ -172,7 +172,7 @@ namespace CallCenterApi.Model
172 172
             get { return _city; }
173 173
         }
174 174
         /// <summary>
175
-        /// 
175
+        /// 
176 176
         /// </summary>
177 177
         public string County
178 178
         {
@@ -188,7 +188,7 @@ namespace CallCenterApi.Model
188 188
             get { return _address; }
189 189
         }
190 190
         /// <summary>
191
-        /// 工单来源
191
+        /// 
192 192
         /// </summary>
193 193
         public string Source
194 194
         {
@@ -204,7 +204,7 @@ namespace CallCenterApi.Model
204 204
             get { return _answer; }
205 205
         }
206 206
         /// <summary>
207
-        /// 工单状态
207
+        /// 工单状态 0为待处理 1为已处理
208 208
         /// </summary>
209 209
         public int? State
210 210
         {