南阳电信API

CallOutPlanController.cs 83KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873
  1. using CallCenterApi.Interface.Controllers.Base;
  2. using CallCenter.Utility;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using System.Data;
  10. using CallCenterApi.DB;
  11. using System.IO;
  12. using System.Data.SqlClient;
  13. using CallCenterApi.Interface.Models.Dto;
  14. namespace CallCenterApi.Interface.Controllers.callout
  15. {
  16. public class CallOutPlanController : BaseController
  17. {
  18. private readonly BLL.T_Call_OutTask otBLL = new BLL.T_Call_OutTask();
  19. private readonly BLL.T_Call_OutTaskTelNum otnBLL = new BLL.T_Call_OutTaskTelNum();
  20. private readonly BLL.T_Call_OutTaskRecords otrBLL = new BLL.T_Call_OutTaskRecords();
  21. private readonly BLL.T_Cus_CustomerBase cusBLL = new BLL.T_Cus_CustomerBase();
  22. private readonly BLL.T_Call_OutAnswers ansBLL = new BLL.T_Call_OutAnswers();
  23. private readonly BLL.T_Ask_Question questionBLL = new BLL.T_Ask_Question();
  24. private readonly BLL.T_Ask_QuestionItems questionItemBLL = new BLL.T_Ask_QuestionItems();
  25. private readonly BLL.T_Ask_PagerInfo pagerInfoBLL = new BLL.T_Ask_PagerInfo();
  26. private readonly BLL.T_Ask_QuestionCategory qcBLL = new BLL.T_Ask_QuestionCategory();
  27. #region 计划信息
  28. public ActionResult GetTaskList(string key, int pagesize = 10, int pageindex = 1)
  29. {
  30. StringBuilder sb = new StringBuilder();
  31. if (!string.IsNullOrWhiteSpace(key))
  32. {
  33. sb.Append(" and (F_TaskName like '%" + key + "%' or F_TaskRemark like '%" + key + "%') ");
  34. }
  35. var recordCount = 0;
  36. var dt = BLL.PagerBLL.GetListPager(
  37. "T_Call_OutTask",
  38. "F_TaskID",
  39. "*",
  40. " and F_DeleteFlag=0 " + sb.ToString(),
  41. "ORDER BY F_TaskID desc",
  42. pagesize,
  43. pageindex,
  44. true,
  45. out recordCount);
  46. var obj = new
  47. {
  48. rows = dt,
  49. total = recordCount
  50. };
  51. return Content(obj.ToJson());
  52. }
  53. public ActionResult GetAllTaskList()
  54. {
  55. var alllist = otBLL.GetModelList(" F_DeleteFlag=0 order by F_TaskID desc");
  56. return Success("获取试题分类成功", alllist);
  57. }
  58. public ActionResult GetTaskModel(int id = 0)
  59. {
  60. if (id <= 0)
  61. return Error("参数不正确");
  62. var model = otBLL.GetModel(id);
  63. if (model == null)
  64. return Error("当前数据不存在");
  65. var papermodel = pagerInfoBLL.GetModel(model.F_PagerID.Value);
  66. var newmodel = new
  67. {
  68. taskmodel = model,
  69. pagermodel = papermodel
  70. };
  71. return Success("获取成功", newmodel);
  72. }
  73. public ActionResult CreateOrUpdateTask(int id = 0, int pagerid = 0, string name = "", string remark = "")
  74. {
  75. var model = new Model.T_Call_OutTask();
  76. if (string.IsNullOrWhiteSpace(name))
  77. return Error("请填写名称" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  78. if (id <= 0)
  79. {
  80. model.F_TaskName = name;
  81. model.F_TaskRemark = remark;
  82. model.F_PagerID = pagerid;
  83. model.F_IsAllot = 0;
  84. model.F_IsStart = 0;
  85. model.F_CreateTime = DateTime.Now;
  86. model.F_CreateUserCode = CurrentUser.UserData.F_UserCode;
  87. model.F_DeleteFlag = 0;
  88. if (otBLL.Add(model) > 0)
  89. return Success("添加成功" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  90. return Error("添加失败" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  91. }
  92. model = otBLL.GetModel(id);
  93. model.F_TaskName = name;
  94. model.F_TaskRemark = remark;
  95. model.F_PagerID = pagerid;
  96. if (otBLL.Update(model))
  97. return Success("修改成功" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  98. return Error("修改失败" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  99. }
  100. //删除任务
  101. public ActionResult DeleteTask(int id = 0)
  102. {
  103. if (id > 0)
  104. {
  105. var tellist = otnBLL.GetRecordCount(" F_DeleteFlag=0 and F_TaskId=" + id);
  106. if (tellist > 0)
  107. {
  108. return Error("请先清理任务下的号码,再做删除!");
  109. }
  110. if (otBLL.Delete(id))
  111. {
  112. return Success("删除成功" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  113. }
  114. else
  115. {
  116. return Error("删除失败!" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  117. }
  118. }
  119. return Error("参数传入失败");
  120. }
  121. //清理号码
  122. public ActionResult DeletesTaskTel(int id = 0)
  123. {
  124. if (otnBLL.DeleteByTask(id))
  125. {
  126. return Success("清理任务下号码成功" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  127. }
  128. else
  129. {
  130. return Error("清理任务下号码失败!" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  131. }
  132. }
  133. //计划启动并关联客户档案、生成任务
  134. public ActionResult EditTaskNum(int taskid = 0, int state = 0)
  135. {
  136. if (state == 1)
  137. {
  138. if (taskid > 0)
  139. {
  140. //var cuslist = cusBLL.GetModelList(" F_AutoFlag=1 ");//标记为有效的客户
  141. //int cc = 0;
  142. //foreach (var cusitem in cuslist)
  143. //{
  144. // var otnModel = new Model.T_Call_OutTaskTelNum();
  145. // otnModel.F_TaskId = taskid;
  146. // otnModel.F_CusID = cusitem.F_CustomerId;
  147. // otnModel.F_CusName = cusitem.F_CustomerName;
  148. // otnModel.F_CreateTime = DateTime.Now;
  149. // otnModel.F_Phone = cusitem.F_Mobile;
  150. // otnModel.F_FPState = 0;
  151. // otnModel.F_HCState = 0;
  152. // otnModel.F_YJState = 0;
  153. // otnModel.F_DeleteFlag = 0;
  154. // if (otnBLL.Add(otnModel) > 0)
  155. // {
  156. // cc++;
  157. // }
  158. //}
  159. //if (cc == cuslist.Count)
  160. //{
  161. if (otBLL.UpdateStart(taskid, 1, DateTime.Now, DateTime.MaxValue))
  162. {
  163. return Success("计划启动成功!taskid=" + taskid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  164. }
  165. else
  166. {
  167. //otnBLL.DeleteByTask(taskid);
  168. return Error("计划启动失败!taskid=" + taskid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  169. }
  170. // }
  171. }
  172. }
  173. else
  174. {
  175. var taskmodel = otBLL.GetModel(taskid);
  176. if (taskmodel.F_IsStart == state)
  177. {
  178. return Error("计划未启动,无法停止!taskid=" + taskid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  179. }
  180. else
  181. {
  182. if (otBLL.UpdateStart(taskid, 0, taskmodel.F_StartTime.Value, DateTime.Now))
  183. {
  184. //otnBLL.DeleteByTask(taskid);
  185. return Success("计划已停止!taskid=" + taskid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  186. }
  187. }
  188. }
  189. return Error("计划操作失败!taskid=" + taskid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  190. }
  191. #endregion
  192. #region 号码导入
  193. int vfileid = 0;
  194. // 导入号码读取填入数据库
  195. public ActionResult TelInput(int taskid)
  196. {
  197. DataTable dtres = new DataTable();
  198. string errres = "";
  199. int i = 0;
  200. int count = 0;//导入成功的条数
  201. string Excelsource = "";
  202. int rcount = 0;
  203. int ccount = 0;
  204. System.Text.StringBuilder strBuilder = null;
  205. //Excelsource = Server.MapPath(this.Request.ApplicationPath + "\\ExcelData\\") + filename.ToString();
  206. Excelsource = uploadexcel();
  207. #region 将文件中的数据导入数据库
  208. try
  209. {
  210. //************************将文件中的数据导入数据库*************************//
  211. DataSet dt = ReadEcxel(Excelsource, 0);
  212. try
  213. {
  214. if (dt != null && dt.Tables[0].Rows.Count != 0)
  215. {
  216. rcount = dt.Tables[0].Rows.Count;
  217. ccount = dt.Tables[0].Columns.Count;
  218. strBuilder = new System.Text.StringBuilder();//用于如果导入失败,删除已经导入过的
  219. DataTable dtInputData = dt.Tables[0];//要导入的电话号码
  220. List<string> sqlList = new List<string>();
  221. List<string> lstsql = new List<string>();
  222. int ilns = dt.Tables[0].Columns.Count;
  223. DataSet dsnew = new DataSet();
  224. #region MyRegion
  225. using (SqlConnection coon = new SqlConnection(DbHelperSQL.connectionString))
  226. {
  227. try
  228. {
  229. coon.Open();
  230. int colscount = dtInputData.Columns.Count;//列数
  231. int rowscount = dtInputData.Rows.Count;//行数
  232. BLL.T_Call_OutTaskTelNum bll = new BLL.T_Call_OutTaskTelNum();
  233. Model.T_Call_OutTaskTelNum modelPhoneImport = new Model.T_Call_OutTaskTelNum();
  234. #region
  235. modelPhoneImport.F_FPState = 0;
  236. modelPhoneImport.F_YJState = 0;
  237. modelPhoneImport.F_DeleteFlag = 0;
  238. modelPhoneImport.F_HCState = 0;
  239. modelPhoneImport.ExpandVchField15 = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff");//导入时间
  240. modelPhoneImport.ExpandVchField14 = CurrentUser.UserData.F_UserId.ToString();//导入坐席ID
  241. modelPhoneImport.ExpandVchField13 = CurrentUser.UserData.F_UserName;
  242. modelPhoneImport.F_TaskId = taskid;
  243. modelPhoneImport.ExpandIntField6 = vfileid;//导入文件id
  244. #endregion
  245. if (rowscount > 0)
  246. {
  247. foreach (DataRow dr in dtInputData.Rows)
  248. {
  249. sqlList.Clear();
  250. lstsql.Clear();
  251. if (dr[1].ToString() != "")
  252. {
  253. string dddddd = dr[1].ToString();
  254. #region 导入表内容
  255. //目标分类、营业部、电话号码、宽带账号、地址、入网时间、入网渠道、营服、套餐、是否融合、状态
  256. modelPhoneImport.ExpandVchField1 = dr[0].ToString();//目标分类
  257. //modelPhoneImport.ExpandVchField2 = dr[1].ToString();//营业部
  258. //modelPhoneImport.ExpandVchField3 = dr[3].ToString();//宽带账号
  259. //modelPhoneImport.ExpandVchField4 = dr[5].ToString();//入网时间
  260. modelPhoneImport.Expandfield2 = dr[1].ToString();//营业部
  261. modelPhoneImport.F_Phone = dr[2].ToString();//号码
  262. modelPhoneImport.Expandfield3 = dr[3].ToString();//宽带账号
  263. modelPhoneImport.ExpandVchField12 = dr[4].ToString();//地址
  264. modelPhoneImport.Expandfield4 = dr[5].ToString();//入网时间
  265. // modelPhoneImport.ExpandVchField3 = dr[3].ToString();//dizhi
  266. // modelPhoneImport.ExpandVchField4 = dr[5].ToString();//入网时间
  267. modelPhoneImport.ExpandVchField5= dr[6].ToString(); //入网渠道
  268. modelPhoneImport.ExpandVchField6 = dr[7].ToString(); //营服
  269. modelPhoneImport.ExpandVchField7 = dr[8].ToString(); //套餐
  270. modelPhoneImport.ExpandVchField8 = dr[9].ToString(); //是否融合
  271. modelPhoneImport.ExpandVchField9 = dr[10].ToString(); //状态
  272. // modelPhoneImport.F_CusName = dr[0].ToString();//客户名称
  273. #endregion
  274. //#region 查重
  275. //string strwhere = " F_TaskId='" + taskid + "' and F_Phone='" + modelPhoneImport.F_Phone + "' and F_DeleteFlag=0";
  276. //DataSet ds = bll.GetList(strwhere);
  277. //if (ds != null && ds.Tables.Count > 0)
  278. //{
  279. // if (ds.Tables[0].Rows.Count > 0)
  280. // {
  281. // continue;
  282. // }
  283. //}
  284. //#endregion
  285. int rmw = otnBLL.Add(modelPhoneImport);
  286. if (rmw > 0)
  287. {
  288. count += 1;//导入成功,+1
  289. }
  290. }
  291. }
  292. dtres = dtInputData;
  293. }
  294. else
  295. {
  296. errres += "该文档的内容为空";
  297. }
  298. }
  299. catch (Exception ex)
  300. {
  301. if (coon.State == ConnectionState.Open)
  302. {
  303. coon.Close();
  304. }
  305. i++;
  306. errres += i.ToString() + ".导入出现异常,共导入" + count + "条数据,请从第" + (count + 2).ToString() + "行开始导入;\n";
  307. if (strBuilder.Length > 0)
  308. {
  309. errres += "重复的号码为:" + strBuilder.ToString() + "\n";
  310. }
  311. }
  312. finally
  313. {
  314. if (coon.State == ConnectionState.Open)
  315. {
  316. coon.Close();
  317. }
  318. }
  319. }//****************using*********
  320. #endregion
  321. }
  322. else
  323. {
  324. i++;
  325. errres += i.ToString() + ".Excel中无数据;\n";
  326. }
  327. }
  328. catch
  329. {
  330. i++;
  331. errres += i.ToString() + ".导入出现异常,导入失败;\n";
  332. }
  333. finally
  334. {
  335. dt.Clear();
  336. dt.Dispose();
  337. }
  338. }
  339. catch
  340. {
  341. errres += i.ToString() + ".Excel格式不正确,系统错误,导入失败;\n";
  342. }
  343. #endregion
  344. if (errres != "")
  345. {
  346. return Error("导入失败!错误信息:" + errres);
  347. }
  348. else
  349. {
  350. string info = "本文件有" + rcount.ToString() + "行" + ccount.ToString() + "列数据";
  351. return Success("导入成功!" + info, vfileid);
  352. }
  353. }
  354. #region 上传文件
  355. private string uploadexcel()
  356. {
  357. string Excelsource = "";
  358. try
  359. {
  360. //HttpFileCollection hfc = System.Web.HttpContext.Current.Request.Files;
  361. HttpPostedFile _upfile = RequestString.GetFile("upFile");
  362. if (_upfile != null)
  363. {
  364. string imgPath = "";
  365. string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss");
  366. newFileName = newFileName + "_" + _upfile.FileName;
  367. if (!Directory.Exists(Server.MapPath(this.Request.ApplicationPath + "\\ExcelData")))
  368. {
  369. Directory.CreateDirectory(Server.MapPath(this.Request.ApplicationPath + "\\ExcelData"));
  370. }
  371. imgPath = this.Request.ApplicationPath + "/ExcelData/" + newFileName.ToString();
  372. string PhysicalPath = Server.MapPath(imgPath);
  373. _upfile.SaveAs(PhysicalPath);
  374. Excelsource = Server.MapPath(this.Request.ApplicationPath + "\\ExcelData\\") + newFileName.ToString();
  375. Model.T_Vis_Files filesmodel = new Model.T_Vis_Files();
  376. filesmodel.F_FileNewName = newFileName;
  377. filesmodel.F_FileOldName = _upfile.FileName;
  378. filesmodel.F_FilePath = Excelsource;
  379. filesmodel.F_FileType = 0;
  380. filesmodel.F_TypeGroup = 0;
  381. filesmodel.F_FileFix = _upfile.FileName.Substring(_upfile.FileName.LastIndexOf('.') + 1);
  382. filesmodel.F_InputDate = DateTime.Now;
  383. filesmodel.F_InputUserCode = CurrentUser.UserData.F_UserCode;
  384. filesmodel.F_InputUserID = CurrentUser.UserData.F_UserId;
  385. vfileid = new BLL.T_Vis_Files().Add(filesmodel);
  386. }
  387. }
  388. catch (Exception ex) { }
  389. return Excelsource;
  390. }
  391. //导入后获取
  392. public ActionResult GetList(int? fileid, int? taskid)
  393. {
  394. string sql = " and F_DeleteFlag=0 and F_FPState=0 ";
  395. DataTable dt = new DataTable();
  396. string userid = CurrentUser.UserData.F_UserId.ToString();
  397. if (userid.Trim() != "")
  398. {
  399. sql += " and cast(ExpandVchField14 as varchar(max))='" + userid.Trim() + "' ";
  400. }
  401. if (fileid != null)
  402. {
  403. sql += " and ExpandIntField6='" + fileid + "' ";
  404. }
  405. if (taskid != null)
  406. {
  407. sql += " and F_TaskId=" + taskid;
  408. }
  409. //sql += " and F_InputDate=(select MAX(F_InputDate)from T_Vis_Telphone)";
  410. string strpageindex = RequestString.GetQueryString("page");
  411. int pageindex = 1;
  412. string strpagesize = RequestString.GetQueryString("pagesize");
  413. int pagesize = 10;
  414. if (strpageindex.Trim() != "")
  415. {
  416. pageindex = Convert.ToInt32(strpageindex);
  417. }
  418. if (strpagesize.Trim() != "")
  419. {
  420. pagesize = Convert.ToInt32(strpagesize);
  421. }
  422. int recordCount = 0;
  423. dt = BLL.PagerBLL.GetListPager(
  424. "T_Call_OutTaskTelNum",
  425. "F_Id",
  426. "*",
  427. " " + sql,
  428. "ORDER BY F_Id desc",
  429. pagesize,
  430. pageindex,
  431. true,
  432. out recordCount);
  433. var obj = new
  434. {
  435. rows = dt,
  436. total = recordCount
  437. };
  438. return Content(obj.ToJson());
  439. }
  440. //删除号码
  441. public ActionResult DeleteTels(string[] ids)
  442. {
  443. if (ids != null && ids.Length > 0)
  444. {
  445. string idd = " ";
  446. foreach (string str in ids)
  447. {
  448. idd += str + ",";
  449. }
  450. if (otnBLL.DeleteList(idd.TrimEnd(',')))
  451. {
  452. return Success("删除成功");
  453. }
  454. else
  455. return Error("删除失败");
  456. }
  457. else
  458. {
  459. return Error("请选择要删除的记录");
  460. }
  461. return Error("删除号码失败,操作人:" + CurrentUser.UserData.F_UserCode);
  462. }
  463. #endregion
  464. #region 读取Excel文件,返一个DataTable
  465. private DataSet ReadEcxel(string FileName, int Rows)
  466. {
  467. return ToDataTable(FileName);
  468. }
  469. /// <summary>
  470. /// 读取Excel文件到DataSet中
  471. /// </summary>
  472. /// <param name="filePath">文件路径</param>
  473. /// <returns></returns>
  474. private DataSet ToDataTable(string filePath)
  475. {
  476. DataSet ds = new DataSet();
  477. DataTable dt = null;
  478. try
  479. {
  480. FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
  481. NPOI.SS.UserModel.IWorkbook book = null;
  482. if (filePath.IndexOf(".xlsx") > 0) // 2007版本
  483. book = new NPOI.XSSF.UserModel.XSSFWorkbook(fs);
  484. else if (filePath.IndexOf(".xls") > 0) // 2003版本
  485. book = new NPOI.HSSF.UserModel.HSSFWorkbook(fs);
  486. //NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(fs);
  487. NPOI.SS.UserModel.ISheet sheet = book.GetSheetAt(0);
  488. NPOI.SS.UserModel.IRow row = sheet.GetRow(0);
  489. int firstCellNum = row.FirstCellNum;
  490. int lastCellNum = row.LastCellNum;
  491. //if (firstCellNum == lastCellNum) continue;
  492. dt = new DataTable(sheet.SheetName);
  493. //for (int i = firstCellNum; i < lastCellNum; i++)
  494. for (int i = firstCellNum; i < 12; i++)
  495. {
  496. if (row.GetCell(i) != null)
  497. {
  498. dt.Columns.Add(row.GetCell(i).ToString() + i.ToString(), typeof(string));
  499. }
  500. else
  501. {
  502. dt.Columns.Add(i.ToString(), typeof(string));
  503. }
  504. }
  505. for (int i = 1; i <= sheet.LastRowNum; i++)
  506. {
  507. if (sheet.GetRow(i).GetCell(1) != null && sheet.GetRow(i).GetCell(1).ToString() != "")
  508. {
  509. DataRow newRow = dt.Rows.Add();
  510. for (int j = firstCellNum; j < 12; j++)
  511. {
  512. if (sheet.GetRow(i).GetCell(j) != null)
  513. {
  514. newRow[j] = sheet.GetRow(i).GetCell(j).ToString();
  515. }
  516. else
  517. {
  518. newRow[j] = "";
  519. }
  520. }
  521. }
  522. }
  523. ds.Tables.Add(dt);
  524. }
  525. catch (Exception ex)
  526. {
  527. //SysLog.WriteLog(ex);
  528. }
  529. return ds;
  530. }
  531. #endregion
  532. #endregion
  533. #region 分配
  534. public ActionResult fpdata(string fpvalue, string[] arruser, string key,string yingyebu)
  535. {
  536. if (arruser.Length <= 0)
  537. return Error("请选择分配坐席");
  538. string fptype = "0";
  539. StringBuilder sb = new StringBuilder();
  540. sb.Append(" and F_FPState=0 and F_DeleteFlag=0 ");
  541. var sql = "";
  542. //if (!string.IsNullOrWhiteSpace(key))
  543. //{
  544. // sql += " and F_Phone='" + key + "' or F_TaskName like '%" + key + "%' or F_TaskRemark like '%" + key + "%'";
  545. //}
  546. if (!string.IsNullOrWhiteSpace(key))
  547. {
  548. sql += " and F_Phone='" + key + "'";
  549. }
  550. if (!string.IsNullOrWhiteSpace(yingyebu))
  551. {
  552. sql += " and Expandfield2='" + yingyebu + "'";
  553. }
  554. sb.Append(" and F_Taskid in (select F_TaskID from T_Call_OutTask where F_IsStart=1 and F_DeleteFlag=0 " + sql + " ) ");
  555. #region 20180612 zhengbingbing 需要调整部分语句必须执行
  556. //if (!string.IsNullOrWhiteSpace(key))
  557. //{
  558. // sb.Append(" and F_Taskid in (select F_TaskID from T_Call_OutTask where F_TaskName like '%" + key + "%' or F_TaskRemark like '%" + key + "%' and F_IsStart=1 and F_DeleteFlag=0 ) ");
  559. //}
  560. #endregion
  561. int userid = CurrentUser.UserData.F_UserId;
  562. string username = CurrentUser.UserData.F_UserName;
  563. #region 按数量平均分配
  564. DataTable dt = DbHelperSQL.Query("select *,NEWID() from T_Call_OutTaskTelNum where 1=1 " + sb.ToString() + " order by NEWID()").Tables[0];
  565. //otnBLL.GetList(" F_FPState=0 ").Tables[0];
  566. List<Model.T_Sys_UserAccount> userlist = new BLL.T_Sys_UserAccount().GetModelList(" F_SeatFlag=1 ");
  567. if (dt != null)
  568. {
  569. int count = dt.Rows.Count;
  570. int cqcount = 0;
  571. if (fptype.Trim() == "0")
  572. {
  573. //按数量平均分配
  574. cqcount = Convert.ToInt32(fpvalue.Trim());
  575. }
  576. int successcount = 0;
  577. if (cqcount > 0)
  578. {
  579. int m = 0;
  580. int n = 0;
  581. for (int i = 0; i < count; i++)
  582. {
  583. #region 更新分配数据
  584. //更新
  585. if (m < cqcount)
  586. {
  587. if (n < arruser.Length)
  588. {
  589. Model.T_Sys_UserAccount usermodel = userlist.Where(u => u.F_UserCode == arruser[n].ToString()).FirstOrDefault();
  590. bool b = otnBLL.UpdateFP(dt.Rows[i]["F_Id"].ToString(), 1, usermodel.F_UserId.ToString(), usermodel.F_UserName);
  591. if (b)
  592. {
  593. successcount++;
  594. }
  595. }
  596. m++;
  597. }
  598. else
  599. {
  600. n++;
  601. m = 0;
  602. i--;
  603. }
  604. #endregion
  605. }
  606. }
  607. return Success("成功分配外呼计划任务" + successcount.ToString() + "条数据" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  608. }
  609. #endregion
  610. return Error("分配外呼计划任务失败" + ",操作人:" + CurrentUser.UserData.F_UserCode);
  611. }
  612. //未分配列表
  613. public ActionResult GetTaskWPF(string key,string yingyebu, int pagesize = 10, int pageindex = 1)
  614. {
  615. StringBuilder sb = new StringBuilder();
  616. sb.Append(" and F_FPState=0 and F_DeleteFlag=0 ");
  617. var sql = "";
  618. //if (!string.IsNullOrWhiteSpace(key))
  619. //{
  620. // sql += " and F_Phone like '%" + key + "%' or F_TaskName like '%" + key + "%' or F_TaskRemark like '%" + key + "%'";
  621. //}
  622. if (!string.IsNullOrWhiteSpace(key))
  623. {
  624. sql += " and F_Phone= '" + key + "' ";
  625. }
  626. if (!string.IsNullOrWhiteSpace(yingyebu))
  627. {
  628. sql += " and Expandfield2 ='"+ yingyebu + "'";
  629. }
  630. sb.Append(" and F_Taskid in (select F_TaskID from T_Call_OutTask where F_IsStart=1 and F_DeleteFlag=0 "+sql+" ) ");
  631. var recordCount = 0;
  632. var dt = BLL.PagerBLL.GetListPager(
  633. "T_Call_OutTaskTelNum",
  634. "F_Id",
  635. "*",
  636. sb.ToString(),
  637. "ORDER BY F_Id desc",
  638. pagesize,
  639. pageindex,
  640. true,
  641. out recordCount);
  642. var obj = new
  643. {
  644. rows = dt,
  645. total = recordCount
  646. };
  647. return Content(obj.ToJson());
  648. }
  649. //获取坐席列表
  650. public ActionResult GetSeatList(int pagesize = 10, int pageindex = 1)
  651. {
  652. DataTable dt = new DataTable();
  653. string sql = " ";
  654. sql = " and f_seatflag=1 ";
  655. int roleid = CurrentUser.UserData.F_RoleId;
  656. int deptid = CurrentUser.UserData.F_DeptId;
  657. int recordCount = 0;
  658. dt = BLL.PagerBLL.GetListPager(
  659. "T_Sys_UserAccount",
  660. "F_UserId",
  661. "*",
  662. sql,
  663. "ORDER BY F_UserId desc",
  664. pagesize,
  665. pageindex,
  666. true,
  667. out recordCount);
  668. #region 条件调整
  669. string sqlc = "";
  670. // sqlc += " and isnull(F_HJJGName,'') not in ('正常接通','停机','空号','正常接通-不满意','不在本地居住') ";
  671. sqlc += " and F_HJJGName is null ";
  672. sqlc += "and F_TaskID in (select F_TaskID from T_Call_OutTask where F_IsStart=1 and F_DeleteFlag=0) ";
  673. DataTable dtCount = otnBLL.GetList(" F_DeleteFlag=0 " + sqlc).Tables[0];
  674. //20180607 zhengbingbing
  675. //DataTable dtCount = otnBLL.GetList(" F_DeleteFlag=0 and isnull(F_HJJGName,'')!='正常接通' and isnull(F_YHFKName,'')!='已同意' and F_TaskID in (select F_TaskID from T_Call_OutTask where F_IsStart=1 and F_DeleteFlag=0) ").Tables[0];//new BLL.T_Vis_TelAllot().GetList(" F_state=1 and F_HFTelID in (select F_TelID from T_Vis_Telphone where F_ISAllot=1 and F_ISCallRes=0 ) ").Tables[0];
  676. #endregion
  677. List<Model.UserAccount> modelList = new BLL.UserAccount().DataTableToList(dt);
  678. var obj = new
  679. {
  680. rows = modelList.Select(x => new
  681. {
  682. UserCode = x.F_UserCode,
  683. UserName = x.F_UserName,
  684. Deparment = x.F_DeptName,
  685. WWCCount = dtCount.Select(" F_UserId=" + x.F_UserId).Count()
  686. }),
  687. total = recordCount
  688. };
  689. return Content(obj.ToJson());
  690. }
  691. #endregion
  692. #region
  693. //获取任务
  694. public ActionResult GetTaskTelModel(int id = 0)
  695. {
  696. if (id <= 0)
  697. return Error("参数不正确");
  698. var model = otnBLL.GetModel(id);
  699. var paperid = 0;
  700. var taskmodel = new CallPlanNewDto();
  701. if (model != null)
  702. {
  703. #region 绑定任务和客户信息
  704. if (model.F_CusID != null)
  705. {
  706. var cusmodel = cusBLL.GetModel(model.F_CusID.Value);
  707. if (cusmodel != null)
  708. {
  709. taskmodel.F_CusID = model.F_CusID.Value;//客户id
  710. taskmodel.F_CityID = cusmodel.F_CityID.Value;//乡镇id
  711. taskmodel.F_Address = cusmodel.F_Address;//住址
  712. taskmodel.F_CusName = cusmodel.F_CustomerName;//客户姓名
  713. taskmodel.F_Phone = cusmodel.F_Telephone;//号码
  714. taskmodel.F_Telephone = cusmodel.F_Mobile;//手机号码
  715. taskmodel.F_City = cusmodel.F_City;//乡镇
  716. taskmodel.F_ordernature = model.ExpandVchField1;
  717. taskmodel.F_broadbandaccount = model.Expandfield3;
  718. taskmodel.F_accesstime = model.Expandfield4;
  719. taskmodel.F_channel = model.ExpandVchField5;
  720. taskmodel.F_service = model.ExpandVchField6;
  721. taskmodel.F_packaget = model.ExpandVchField7;
  722. taskmodel.F_fusion = model.ExpandVchField8;
  723. taskmodel.F_status = model.ExpandVchField9;
  724. //用户分类、电话号码、宽带账号、地址、入网时间、入网渠道、营服、套餐、是否融合、状态
  725. }
  726. }
  727. taskmodel.F_Id = model.F_Id;//号码id
  728. taskmodel.F_TaskId = model.F_TaskId.Value;//任务id
  729. taskmodel.F_HJJGId = model.F_HJJGId != null ? model.F_HJJGId.Value : 0;//呼叫结果id
  730. taskmodel.F_ordernature = model.ExpandVchField1;
  731. taskmodel.F_broadbandaccount = model.Expandfield3;
  732. taskmodel.F_accesstime = model.Expandfield4;
  733. taskmodel.F_channel = model.ExpandVchField5;
  734. taskmodel.F_service = model.ExpandVchField6;
  735. taskmodel.F_packaget = model.ExpandVchField7;
  736. taskmodel.F_fusion = model.ExpandVchField8;
  737. taskmodel.F_status = model.ExpandVchField9;
  738. if (!string.IsNullOrWhiteSpace(model.F_CusName))
  739. taskmodel.F_CusName = model.F_CusName;//客户姓名
  740. if (!string.IsNullOrWhiteSpace(model.F_Phone))
  741. taskmodel.F_Phone = model.F_Phone;//号码
  742. if (!string.IsNullOrWhiteSpace(model.ExpandVchField12))
  743. taskmodel.F_Address = model.ExpandVchField12;//住址
  744. #endregion
  745. var tmodel = otBLL.GetModel(model.F_TaskId.Value);
  746. if (tmodel != null)
  747. {
  748. paperid = tmodel.F_PagerID.Value;
  749. taskmodel.F_TaskName = tmodel.F_TaskName;//任务名称
  750. taskmodel.F_TaskRemark = tmodel.F_TaskRemark;//任务备注
  751. }
  752. }
  753. if (model == null)
  754. return Error("当前数据不存在");
  755. var obj = new
  756. {
  757. taskModel = taskmodel,
  758. paperid = paperid
  759. };
  760. return Success("获取成功", obj);
  761. }
  762. //获取我的任务列表
  763. public ActionResult GetMyTaskList(string key, string sdate, string edate, int pagesize = 10, int pageindex = 1)
  764. {
  765. StringBuilder sb = new StringBuilder();
  766. int userid = CurrentUser.UserData.F_UserId;
  767. #region 条件查询
  768. if (!string.IsNullOrWhiteSpace(sdate))
  769. sb.Append(" and DATEDIFF(day,ExpandDatField1,'" + sdate.Trim() + "')<=0");
  770. if (!string.IsNullOrWhiteSpace(edate))
  771. sb.Append(" and DATEDIFF(day,ExpandDatField1,'" + edate.Trim() + "')>=0");
  772. sb.Append(" and F_UserId=" + userid);
  773. sb.Append(" and F_DeleteFlag=0 ");
  774. #region 息县特殊要求
  775. //20180522 zhengbingbing
  776. //正常接通,停机,空号,正常接通-不满意,不在本地居住 均不显示在我的任务
  777. //sb.Append(" and isnull(F_HJJGName,'')!='正常接通' and isnull(F_YHFKName,'')!='已同意'");
  778. //sb.Append(" and isnull(F_HJJGName,'')=''");
  779. // sb.Append(" and isnull(F_HJJGName,'') not in ('正常接通','停机','空号','正常接通-不满意','不在本地居住')");
  780. sb.Append(" and F_HJJGName is null");
  781. #endregion
  782. sb.Append(" and F_Taskid in (select F_TaskID from T_Call_OutTask where F_IsStart=1 and F_DeleteFlag=0)");
  783. if (!string.IsNullOrWhiteSpace(key))
  784. {
  785. sb.Append(" and F_Phone like '%" + key.Trim() + "%'");
  786. }
  787. //string sqlwhere = "";
  788. //if (!string.IsNullOrWhiteSpace(key))
  789. //{
  790. // sqlwhere = " and F_TaskName like '%" + key + "%' or F_TaskRemark like '%" + key + "%' ";
  791. //}
  792. //sb.Append(" and F_TaskID in (select F_TaskID from T_Call_OutTask where F_IsStart=1 and F_DeleteFlag=0 " + sqlwhere + ") ");
  793. #endregion
  794. var recordCount = 0;
  795. var dt = BLL.PagerBLL.GetListPager(
  796. "T_Call_OutTaskTelNum",
  797. "F_Id",
  798. "*",
  799. sb.ToString(),
  800. "ORDER BY ExpandDatField1 asc,F_Id desc",//ExpandDatField1 asc 调查时间正序 id倒序
  801. pagesize,
  802. pageindex,
  803. true,
  804. out recordCount);
  805. var obj = new
  806. {
  807. rows = dt,
  808. total = recordCount
  809. };
  810. return Content(obj.ToJson());
  811. }
  812. //获取我的任务结果
  813. public ActionResult GetMyResultList(string key, string sdate, string edate, int hjjgid = 0, int yhfkid = 0, int pagesize = 10, int pageindex = 1)
  814. {
  815. StringBuilder sb = new StringBuilder();
  816. int userid = CurrentUser.UserData.F_UserId;
  817. #region 条件查询
  818. sb.Append(" and F_UserId=" + userid);
  819. sb.Append(" and F_DeleteFlag=0 ");
  820. if (!string.IsNullOrWhiteSpace(sdate))
  821. sb.Append(" and DATEDIFF(day,ExpandDatField1,'" + sdate.Trim() + "')<=0");
  822. if (!string.IsNullOrWhiteSpace(edate))
  823. sb.Append(" and DATEDIFF(day,ExpandDatField1,'" + edate.Trim() + "')>=0");
  824. if (hjjgid != 0)
  825. {
  826. sb.Append(" and F_HJJGId=" + hjjgid);
  827. }
  828. else
  829. {
  830. sb.Append(" and isnull(F_HJJGId,'')!=''");
  831. }
  832. //if (yhfkid != 0)
  833. //{
  834. // sb.Append(" and F_YHFKId=" + yhfkid);
  835. //}
  836. if (!string.IsNullOrWhiteSpace(key))
  837. {
  838. sb.Append(" and F_Phone like '%" + key.Trim() + "%'");
  839. }
  840. //string sqlwhere = "";
  841. //if (!string.IsNullOrWhiteSpace(key))
  842. //{
  843. // sqlwhere = " and F_TaskName like '%" + key + "%' or F_TaskRemark like '%" + key + "%' ";
  844. //}
  845. //sb.Append(" and F_TaskID in (select F_TaskID from T_Call_OutTask where F_IsStart=1 and F_DeleteFlag=0 " + sqlwhere + ") ");
  846. #endregion
  847. var recordCount = 0;
  848. string tablenew = "( select a.*, b.F_typeValue1,b.F_typeValue2,b.F_typeValue3,b.F_typeValue4,b.F_typeValue5,b.F_typeValue6 from T_Call_OutTaskTelNum a left join T_TypeResult b on a.F_id=b.F_phoneid) as t";
  849. var dt = BLL.PagerBLL.GetListPager(
  850. //"T_Call_OutTaskTelNum",
  851. tablenew,
  852. "F_Id",
  853. "*",
  854. sb.ToString(),
  855. "ORDER BY ExpandDatField1 desc,F_Id desc",//ExpandDatField1 调查时间倒序,id倒序
  856. pagesize,
  857. pageindex,
  858. true,
  859. out recordCount);
  860. //dt.Columns.Add("type1");
  861. //dt.Columns.Add("type2");
  862. //dt.Columns.Add("type3");
  863. //dt.Columns.Add("type4");
  864. //dt.Columns.Add("type5");
  865. //dt.Columns.Add("type6");
  866. #region 判断是否已存在工单 ;再判断 如果问题里包括那六大类的问题,给分数赋值
  867. foreach (DataRow item in dt.Rows)
  868. {
  869. string wjid = item["F_Id"].ToString();
  870. int c=new BLL.T_Wo_WorkOrder().GetRecordCount(" isnull(WjID,'')='"+wjid+"'");
  871. if (c > 0)
  872. {
  873. item["ExpandSintField1"] = 1;
  874. }
  875. else
  876. item["ExpandSintField1"] = 0;
  877. ////如果问题里包括那六大类的问题,给分数赋值
  878. ////移网上网质量;移网通话质量;光网网络质量;装维服务;营业厅服务;套餐资费
  879. //int F_TaskId = Convert.ToInt32(item["F_TaskId"].ToString());
  880. //var model = otnBLL.GetModel(Convert.ToInt32(wjid));
  881. //if(model!=null)
  882. //{
  883. // int cusid= model.F_CusID.Value;
  884. //string sql1 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId+" and F_CusID = "+ cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '移网上网质量') and F_SortModel = 0)";
  885. //item["type1"] = DbHelperSQL.GetSingle(sql1);
  886. //string sql2 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '移网通话质量') and F_SortModel = 0)";
  887. //item["type2"] = DbHelperSQL.GetSingle(sql2);
  888. //string sql3 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '光网网络质量') and F_SortModel = 0)";
  889. //item["type3"] = DbHelperSQL.GetSingle(sql3);
  890. //string sql4 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '装维服务') and F_SortModel = 0)";
  891. //item["type4"] = DbHelperSQL.GetSingle(sql4);
  892. //string sql5 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '营业厅服务') and F_SortModel = 0)";
  893. //item["type5"] = DbHelperSQL.GetSingle(sql5);
  894. //string sql6 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '套餐资费') and F_SortModel = 0)";
  895. //item["type6"] = DbHelperSQL.GetSingle(sql6);
  896. //}
  897. }
  898. #endregion
  899. var obj = new
  900. {
  901. rows = dt,
  902. total = recordCount
  903. };
  904. return Content(obj.ToJson());
  905. }
  906. [Authorize]
  907. public ActionResult ExportGetMyResultList(string key, string sdate, string edate, int hjjgid = 0)
  908. {
  909. StringBuilder sb = new StringBuilder();
  910. int userid = CurrentUser.UserData.F_UserId;
  911. #region 条件查询
  912. sb.Append(" a. F_UserId=" + userid);
  913. sb.Append(" and F_DeleteFlag=0 ");
  914. if (!string.IsNullOrWhiteSpace(sdate))
  915. sb.Append(" and DATEDIFF(day,ExpandDatField1,'" + sdate.Trim() + "')<=0");
  916. if (!string.IsNullOrWhiteSpace(edate))
  917. sb.Append(" and DATEDIFF(day,ExpandDatField1,'" + edate.Trim() + "')>=0");
  918. if (hjjgid != 0)
  919. {
  920. sb.Append(" and F_HJJGId=" + hjjgid);
  921. }
  922. else
  923. {
  924. sb.Append(" and isnull(F_HJJGId,'')!=''");
  925. }
  926. if (!string.IsNullOrWhiteSpace(key))
  927. {
  928. sb.Append(" and F_Phone like '%" + key.Trim() + "%'");
  929. }
  930. #endregion
  931. #region
  932. //modelPhoneImport.ExpandVchField1 = dr[0].ToString();//目标分类
  933. //modelPhoneImport.ExpandVchField2 = dr[1].ToString();//营业部
  934. //modelPhoneImport.F_Phone = dr[2].ToString();//号码
  935. //modelPhoneImport.ExpandVchField3 = dr[3].ToString();//宽带账号
  936. //modelPhoneImport.ExpandVchField12 = dr[4].ToString();//地址
  937. //modelPhoneImport.ExpandVchField4 = dr[5].ToString();//入网时间
  938. //modelPhoneImport.ExpandVchField5 = dr[6].ToString(); //入网渠道
  939. //modelPhoneImport.ExpandVchField6 = dr[7].ToString(); //营服
  940. //modelPhoneImport.ExpandVchField7 = dr[8].ToString(); //套餐
  941. //modelPhoneImport.ExpandVchField8 = dr[9].ToString(); //是否融合
  942. //modelPhoneImport.ExpandVchField9 = dr[10].ToString(); //状态
  943. #endregion
  944. string sql = " select ExpandVchField1,Expandfield2,F_Phone,b.F_typeValue1,b.F_typeValue2,b.F_typeValue3,b.F_typeValue4,b.F_typeValue5,b.F_typeValue6, F_UserName,F_HJJGName,ExpandDatField1 from T_Call_OutTaskTelNum a left join T_TypeResult b on a.F_id=b.F_phoneid where " + sb.ToString() + " ORDER BY ExpandDatField1 desc,a.F_Id desc";
  945. DataTable dt = DbHelperSQL.Query(sql).Tables[0];
  946. #region
  947. //dt.Columns.Add("type1");
  948. //dt.Columns.Add("type2");
  949. //dt.Columns.Add("type3");
  950. //dt.Columns.Add("type4");
  951. //dt.Columns.Add("type5");
  952. //dt.Columns.Add("type6");
  953. //#region 判断是否已存在工单 ;再判断 如果问题里包括那六大类的问题,给分数赋值
  954. //foreach (DataRow item in dt.Rows)
  955. //{
  956. // string wjid = item["F_Id"].ToString();
  957. // //如果问题里包括那六大类的问题,给分数赋值
  958. // //移网上网质量;移网通话质量;光网网络质量;装维服务;营业厅服务;套餐资费
  959. // int F_TaskId = Convert.ToInt32(item["F_TaskId"].ToString());
  960. // var model = otnBLL.GetModel(Convert.ToInt32(wjid));
  961. // if (model != null)
  962. // {
  963. // int cusid = model.F_CusID.Value;
  964. // string sql1 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '移网上网质量') and F_SortModel = 0)";
  965. // item["type1"] = DbHelperSQL.GetSingle(sql1);
  966. // string sql2 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '移网通话质量') and F_SortModel = 0)";
  967. // item["type2"] = DbHelperSQL.GetSingle(sql2);
  968. // string sql3 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '光网网络质量') and F_SortModel = 0)";
  969. // item["type3"] = DbHelperSQL.GetSingle(sql3);
  970. // string sql4 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '装维服务') and F_SortModel = 0)";
  971. // item["type4"] = DbHelperSQL.GetSingle(sql4);
  972. // string sql5 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '营业厅服务') and F_SortModel = 0)";
  973. // item["type5"] = DbHelperSQL.GetSingle(sql5);
  974. // string sql6 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '套餐资费') and F_SortModel = 0)";
  975. // item["type6"] = DbHelperSQL.GetSingle(sql6);
  976. // }
  977. //}
  978. //#endregion
  979. #endregion
  980. NPOIHelper npoi = new NPOIHelper();
  981. if (npoi.ExportToExcel("我的任务结果数据", dt, col()) == "")
  982. {
  983. return Success("导出成功");
  984. }
  985. else
  986. {
  987. return Error("导出失败");
  988. }
  989. }
  990. private string[] col()
  991. {
  992. string[] ccc = {
  993. //用户分类、营业部、电话号码、【移网质量、渠道服务、光网质量、装维服务、套餐资费】(五大类所对应的分值)、分配坐席、呼叫结果、调查时间
  994. "用户分类", "营业部","电话号码","移网上网质量","移网通话质量","光网网络质量"," 装维服务"," 营业厅服务","套餐资费", "分配坐席","呼叫结果","调查时间"
  995. };
  996. return ccc;
  997. }
  998. //获取总体任务结果
  999. public ActionResult GetResultList(string key, string sdate, string edate,int taskid=0, int userid = 0, int hjjgid = 0, int yhfkid = 0, int pagesize = 10, int pageindex = 1)
  1000. {
  1001. StringBuilder sb = new StringBuilder();
  1002. #region 条件查询
  1003. sb.Append(" and F_DeleteFlag=0 ");
  1004. if (!string.IsNullOrWhiteSpace(sdate))
  1005. sb.Append(" and DATEDIFF(day,ExpandDatField1,'" + sdate.Trim() + "')<=0");
  1006. if (!string.IsNullOrWhiteSpace(edate))
  1007. sb.Append(" and DATEDIFF(day,ExpandDatField1,'" + edate.Trim() + "')>=0");
  1008. if (userid != 0)
  1009. {
  1010. sb.Append(" and F_UserId=" + userid);
  1011. }
  1012. if (hjjgid != 0)
  1013. {
  1014. sb.Append(" and F_HJJGId=" + hjjgid);
  1015. }
  1016. if (taskid!=0)
  1017. {
  1018. sb.Append(" and F_TaskId=" + hjjgid);
  1019. }
  1020. else
  1021. {
  1022. sb.Append(" and isnull(F_HJJGId,'')!=''");
  1023. }
  1024. //if (yhfkid != 0)
  1025. //{
  1026. // sb.Append(" and F_YHFKId=" + yhfkid);
  1027. //}
  1028. if (!string.IsNullOrWhiteSpace(key))
  1029. {
  1030. sb.Append(" and F_Phone like '%" + key.Trim() + "%'");
  1031. }
  1032. //string sqlwhere = "";
  1033. //if (!string.IsNullOrWhiteSpace(key))
  1034. //{
  1035. // sqlwhere = " and F_TaskName like '%" + key + "%' or F_TaskRemark like '%" + key + "%' ";
  1036. //}
  1037. //sb.Append(" and F_TaskID in (select F_TaskID from T_Call_OutTask where F_IsStart=1 and F_DeleteFlag=0 " + sqlwhere + ") ");
  1038. #endregion
  1039. string tablenew = "( select a.*, b.F_typeValue1,b.F_typeValue2,b.F_typeValue3,b.F_typeValue4,b.F_typeValue5,b.F_typeValue6 from T_Call_OutTaskTelNum a left join T_TypeResult b on a.F_id=b.F_phoneid) as t";
  1040. var recordCount = 0;
  1041. var dt = BLL.PagerBLL.GetListPager(
  1042. //"T_Call_OutTaskTelNum",
  1043. tablenew,
  1044. "F_Id",
  1045. "*",
  1046. sb.ToString(),
  1047. "ORDER BY ExpandDatField1 desc,F_Id desc",//ExpandDatField1 调查时间倒序,id倒序
  1048. pagesize,
  1049. pageindex,
  1050. true,
  1051. out recordCount);
  1052. #region 判断是否已存在工单
  1053. //dt.Columns.Add("type1");
  1054. //dt.Columns.Add("type2");
  1055. //dt.Columns.Add("type3");
  1056. //dt.Columns.Add("type4");
  1057. //dt.Columns.Add("type5");
  1058. //dt.Columns.Add("type6");
  1059. #region 判断是否已存在工单 ;再判断 如果问题里包括那六大类的问题,给分数赋值
  1060. foreach (DataRow item in dt.Rows)
  1061. {
  1062. string wjid = item["F_Id"].ToString();
  1063. int c = new BLL.T_Wo_WorkOrder().GetRecordCount(" isnull(WjID,'')='" + wjid + "'");
  1064. if (c > 0)
  1065. {
  1066. item["ExpandSintField1"] = 1;
  1067. }
  1068. else
  1069. item["ExpandSintField1"] = 0;
  1070. //如果问题里包括那六大类的问题,给分数赋值
  1071. //移网上网质量;移网通话质量;光网网络质量;装维服务;营业厅服务;套餐资费
  1072. //int F_TaskId = Convert.ToInt32(item["F_TaskId"].ToString());
  1073. //var model = otnBLL.GetModel(Convert.ToInt32(wjid));
  1074. //if (model != null)
  1075. //{
  1076. // int cusid = model.F_CusID.Value;
  1077. // string sql1 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '移网上网质量') and F_SortModel = 0)";
  1078. // item["type1"] = DbHelperSQL.GetSingle(sql1);
  1079. // string sql2 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '移网通话质量') and F_SortModel = 0)";
  1080. // item["type2"] = DbHelperSQL.GetSingle(sql2);
  1081. // string sql3 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '光网网络质量') and F_SortModel = 0)";
  1082. // item["type3"] = DbHelperSQL.GetSingle(sql3);
  1083. // string sql4 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '装维服务') and F_SortModel = 0)";
  1084. // item["type4"] = DbHelperSQL.GetSingle(sql4);
  1085. // string sql5 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '营业厅服务') and F_SortModel = 0)";
  1086. // item["type5"] = DbHelperSQL.GetSingle(sql5);
  1087. // string sql6 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '套餐资费') and F_SortModel = 0)";
  1088. // item["type6"] = DbHelperSQL.GetSingle(sql6);
  1089. //}
  1090. }
  1091. #endregion
  1092. #endregion
  1093. var obj = new
  1094. {
  1095. rows = dt,
  1096. total = recordCount
  1097. };
  1098. return Content(obj.ToJson());
  1099. }
  1100. //导出总体任务结果
  1101. public ActionResult ExportGetResultList(string key, string sdate, string edate, int userid = 0, int hjjgid = 0, int yhfkid = 0)
  1102. {
  1103. StringBuilder sb = new StringBuilder();
  1104. #region 条件查询
  1105. sb.Append(" F_DeleteFlag=0 ");
  1106. if (!string.IsNullOrWhiteSpace(sdate))
  1107. sb.Append(" and DATEDIFF(day,ExpandDatField1,'" + sdate.Trim() + "')<=0");
  1108. if (!string.IsNullOrWhiteSpace(edate))
  1109. sb.Append(" and DATEDIFF(day,ExpandDatField1,'" + edate.Trim() + "')>=0");
  1110. if (userid != 0)
  1111. {
  1112. sb.Append(" and a.F_UserId=" + userid);
  1113. }
  1114. if (hjjgid != 0)
  1115. {
  1116. sb.Append(" and F_HJJGId=" + hjjgid);
  1117. }
  1118. else
  1119. {
  1120. sb.Append(" and isnull(F_HJJGId,'')!=''");
  1121. }
  1122. if (!string.IsNullOrWhiteSpace(key))
  1123. {
  1124. sb.Append(" and F_Phone like '%" + key.Trim() + "%'");
  1125. }
  1126. #endregion
  1127. // string tablenew = "( select a.*, b.F_typeValue1,b.F_typeValue2,b.F_typeValue3,b.F_typeValue4,b.F_typeValue5,b.F_typeValue6 from T_Call_OutTaskTelNum a left join T_TypeResult b on a.F_id=b.F_phoneid) as t";
  1128. string sql = " select ExpandVchField1 ,Expandfield2,F_Phone,b.F_typeValue1,b.F_typeValue2,b.F_typeValue3,b.F_typeValue4,b.F_typeValue5,b.F_typeValue6 , F_UserName,F_HJJGName,ExpandDatField1 from T_Call_OutTaskTelNum a left join T_TypeResult b on a.F_id=b.F_phoneid where " + sb.ToString() + " ORDER BY ExpandDatField1 desc,a.F_Id desc";
  1129. DataTable dt = DbHelperSQL.Query(sql).Tables[0];
  1130. #region 判断是否已存在工单
  1131. //dt.Columns.Add("type1");
  1132. //dt.Columns.Add("type2");
  1133. //dt.Columns.Add("type3");
  1134. //dt.Columns.Add("type4");
  1135. //dt.Columns.Add("type5");
  1136. //dt.Columns.Add("type6");
  1137. #region 判断是否已存在工单 ;再判断 如果问题里包括那六大类的问题,给分数赋值
  1138. //foreach (DataRow item in dt.Rows)
  1139. //{
  1140. // string wjid = item["F_Id"].ToString();
  1141. // //如果问题里包括那六大类的问题,给分数赋值
  1142. // //移网上网质量;移网通话质量;光网网络质量;装维服务;营业厅服务;套餐资费
  1143. // int F_TaskId = Convert.ToInt32(item["F_TaskId"].ToString());
  1144. // var model = otnBLL.GetModel(Convert.ToInt32(wjid));
  1145. // if (model != null)
  1146. // {
  1147. // int cusid = model.F_CusID.Value;
  1148. // string sql1 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '移网上网质量') and F_SortModel = 0)";
  1149. // item["type1"] = DbHelperSQL.GetSingle(sql1);
  1150. // string sql2 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '移网通话质量') and F_SortModel = 0)";
  1151. // item["type2"] = DbHelperSQL.GetSingle(sql2);
  1152. // string sql3 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '光网网络质量') and F_SortModel = 0)";
  1153. // item["type3"] = DbHelperSQL.GetSingle(sql3);
  1154. // string sql4 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '装维服务') and F_SortModel = 0)";
  1155. // item["type4"] = DbHelperSQL.GetSingle(sql4);
  1156. // string sql5 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '营业厅服务') and F_SortModel = 0)";
  1157. // item["type5"] = DbHelperSQL.GetSingle(sql5);
  1158. // string sql6 = " SELECT F_Answer FROM T_Call_OutAnswers where F_TaskID = " + F_TaskId + " and F_CusID = " + cusid + " and F_QID in (select F_QuestionId from T_Ask_Question where F_CategoryId in (select F_CategoryId from T_Ask_QuestionCategory where F_CategoryName = '套餐资费') and F_SortModel = 0)";
  1159. // item["type6"] = DbHelperSQL.GetSingle(sql6);
  1160. // }
  1161. //}
  1162. NPOIHelper npoi = new NPOIHelper();
  1163. if (npoi.ExportToExcel("任务结果数据", dt, col()) == "")
  1164. {
  1165. return Success("导出成功");
  1166. }
  1167. else
  1168. {
  1169. return Error("导出失败");
  1170. }
  1171. #endregion
  1172. #endregion
  1173. }
  1174. //获取任务结果详情
  1175. public ActionResult GetTaskTelInfo(int id = 0)
  1176. {
  1177. //id = 40582;
  1178. if (id <= 0)
  1179. return Error("参数不正确");
  1180. var model = otnBLL.GetModel(id);
  1181. var paperid = 0;
  1182. if (model != null)
  1183. {
  1184. var taskmodel = new CallPlanNewDto();
  1185. #region 绑定任务和客户信息
  1186. if (model.F_CusID != null)
  1187. {
  1188. var cusmodel = cusBLL.GetModel(model.F_CusID.Value);
  1189. if (cusmodel != null)
  1190. {
  1191. taskmodel.F_CusID = model.F_CusID.Value;//客户id
  1192. taskmodel.F_CityID = cusmodel.F_CityID.Value;//乡镇id
  1193. taskmodel.F_CusName = cusmodel.F_CustomerName;//客户姓名
  1194. taskmodel.F_Phone = cusmodel.F_Telephone;//号码
  1195. taskmodel.F_Telephone = cusmodel.F_Mobile;//手机号码
  1196. taskmodel.F_City = cusmodel.F_City;//乡镇
  1197. taskmodel.F_Address = cusmodel.F_Address;//住址
  1198. }
  1199. }
  1200. taskmodel.F_Id = model.F_Id;//号码id
  1201. taskmodel.F_TaskId = model.F_TaskId.Value;//任务id
  1202. taskmodel.F_HJJGId = model.F_HJJGId != null ? model.F_HJJGId.Value : 0;//呼叫结果id
  1203. taskmodel.F_ordernature = model.ExpandVchField1;
  1204. taskmodel.F_broadbandaccount = model.Expandfield3;
  1205. taskmodel.F_accesstime = model.Expandfield4;
  1206. taskmodel.F_channel = model.ExpandVchField5;
  1207. taskmodel.F_service = model.ExpandVchField6;
  1208. taskmodel.F_packaget = model.ExpandVchField7;
  1209. taskmodel.F_fusion = model.ExpandVchField8;
  1210. taskmodel.F_status = model.ExpandVchField9;
  1211. //if (!string.IsNullOrWhiteSpace(model.F_CusName))
  1212. // taskmodel.F_CusName = model.F_CusName;//客户姓名
  1213. //if (!string.IsNullOrWhiteSpace(model.F_Phone))
  1214. // taskmodel.F_Phone = model.F_Phone;//号码
  1215. //if (!string.IsNullOrWhiteSpace(model.ExpandVchField12))
  1216. // taskmodel.F_Address = model.ExpandVchField12;//住址
  1217. #endregion
  1218. var anslist = ansBLL.GetModelList(" F_TaskID=" + model.F_TaskId.Value + " and F_CusTelID=" + id + " ");
  1219. var tmodel = otBLL.GetModel(model.F_TaskId.Value);
  1220. var qCategorylist = qcBLL.GetModelList("");
  1221. if (tmodel != null)
  1222. {
  1223. paperid = tmodel.F_PagerID.Value;
  1224. #region 获取问卷试题信息以及答案
  1225. var pmodel = pagerInfoBLL.GetModel(paperid);
  1226. var qlist = questionBLL.GetModelList(" F_DeleteFlag=0 and F_QuestionId in (select F_QuestionId from T_Ask_PagerItems where F_PagerId=" + paperid + ") order by F_QuestionId ");
  1227. var qilist = questionItemBLL.GetModelList(" F_QuestionId in (select F_QuestionId from T_Ask_PagerItems where F_PagerId=" + paperid + ") order by F_ItemId ");
  1228. var newmodel = new
  1229. {
  1230. F_Title = pmodel.F_Title,
  1231. F_Remark = pmodel.F_Remark,
  1232. F_StartText = pmodel.F_StartText,
  1233. F_EndText = pmodel.F_EndText,
  1234. F_Questions = qlist.Select(q =>
  1235. {
  1236. var answers = "";
  1237. var qalist = anslist.Where(al => al.F_QID.Value == q.F_QuestionId).ToList<Model.T_Call_OutAnswers>();
  1238. if (qalist.Count > 0)
  1239. {
  1240. if (q.F_Type > 1)
  1241. {
  1242. foreach (var item in qalist)
  1243. {
  1244. answers += item.F_QIID + "|";
  1245. }
  1246. }
  1247. else
  1248. {
  1249. answers = qalist[0].F_Answer;
  1250. }
  1251. }
  1252. return new
  1253. {
  1254. quesid = q.F_QuestionId,
  1255. questitle = q.F_Title,
  1256. questype = q.F_Type,
  1257. quescontent = q.F_Content,
  1258. quesremark = q.F_Remark,
  1259. sortmodel=q.F_SortModel,
  1260. quesanswers = answers.Trim('|'),
  1261. F_CategoryName = qCategorylist.Where(m => m.F_CategoryId == q.F_CategoryId).First().F_CategoryName,
  1262. quesitems = qilist.Where(qq => qq.F_QuestionId == q.F_QuestionId).Select(qi =>
  1263. {
  1264. return new
  1265. {
  1266. itemid = qi.F_ItemId,
  1267. itemname = qi.F_ItemName,
  1268. itemremark = qi.F_Remark,
  1269. };
  1270. })
  1271. };
  1272. })
  1273. };
  1274. #endregion
  1275. taskmodel.F_TaskName = tmodel.F_TaskName;//任务名称
  1276. taskmodel.F_TaskRemark = tmodel.F_TaskRemark;//任务备注
  1277. var objy = new
  1278. {
  1279. taskModel = taskmodel,
  1280. paperModel = newmodel
  1281. };
  1282. return Success("获取详情成功", objy);
  1283. }
  1284. }
  1285. return Error("获取详情失败");
  1286. }
  1287. #endregion
  1288. #region 问卷回答
  1289. /// <summary>
  1290. ///
  1291. /// </summary>
  1292. /// <param name="taskid">任务ID</param>
  1293. /// <param name="custelid">客户电话ID</param>
  1294. /// <param name="ans">答案,数组形式["15_20_单选选项内容","17_25|36|58_复选选项内容1|选项内容2|选项内容3","30_0_问答题"]</param>
  1295. /// <param name="hjjgid">呼叫结果</param>
  1296. /// <param name="telphone">电话号码</param>
  1297. /// <param name="name">姓名</param>
  1298. /// <param name="phone">固定号码</param>
  1299. /// <param name="countryid">乡镇id</param>
  1300. /// <param name="address">地址</param>
  1301. /// <returns></returns>
  1302. public ActionResult Answers(int taskid, int custelid, string[] ans, int hjjgid,
  1303. string name, string phone, string callid, string address,
  1304. string fenlei, string kuandai, string dizhi, string ruwangshijian, string qudao, string yingfu, string taocan, string ronghe, string zhuangtai,
  1305. int countryid=0)
  1306. {//
  1307. int cc = 0;
  1308. if (custelid > 0)
  1309. {
  1310. var otnModel = otnBLL.GetModel(custelid);
  1311. if (otnModel != null)
  1312. {
  1313. otnModel.ExpandVchField1 = fenlei;//目标分类
  1314. otnModel.Expandfield3 = kuandai;//宽带账号
  1315. otnModel.ExpandVchField12 = dizhi;//地址
  1316. otnModel.Expandfield4 = ruwangshijian;//入网时间
  1317. otnModel.ExpandVchField5 = qudao; //入网渠道
  1318. otnModel.ExpandVchField6 = yingfu; //营服
  1319. otnModel.ExpandVchField7 = taocan; //套餐
  1320. otnModel.ExpandVchField8 = ronghe; //是否融合
  1321. otnModel.ExpandVchField9 = zhuangtai; //状态
  1322. otnBLL.Update(otnModel);
  1323. int cusid = saveCus(otnModel.F_Phone, name, phone, countryid, address, "", ruwangshijian, kuandai, qudao, ronghe);
  1324. #region 保存答案
  1325. var ansModel = new Model.T_Call_OutAnswers();
  1326. string askqids = "";
  1327. string ansids = "";
  1328. if (ans != null)
  1329. {
  1330. //先删除 后添加
  1331. ansBLL.DeleteByTelid(custelid, taskid);
  1332. ansModel.F_TaskID = taskid;
  1333. ansModel.F_CusTelID = custelid;
  1334. ansModel.F_CusID = cusid;
  1335. ansModel.F_OptBy = CurrentUser.UserData.F_UserId;
  1336. ansModel.F_OptByName = CurrentUser.UserData.F_UserName;
  1337. ansModel.F_OptOn = DateTime.Now;
  1338. ansModel.F_Expand1 = countryid.ToString();
  1339. ansModel.F_Expand3 = DateTime.Now.ToString("yyyyMMddHHmmssfff");
  1340. #region 循环保存
  1341. foreach (var item in ans)
  1342. {
  1343. if (!string.IsNullOrEmpty(item)) {
  1344. var nn = 0;
  1345. var ii = item.Split('_');
  1346. ansModel.F_QID = int.Parse(ii[0]);
  1347. askqids += ii[0] + ",";
  1348. ansids += ii[1] + ",";
  1349. if (ii[1].IndexOf('|') > 0)
  1350. {
  1351. var iii = ii[1].Trim('|').Split('|');
  1352. var iia = ii[2].Trim('|').Split('|');
  1353. for (int i = 0; i < iii.Length; i++)
  1354. {
  1355. ansModel.F_QIID = int.Parse(iii[i]);
  1356. ansModel.F_Answer = iia[i];
  1357. if (ansBLL.Add(ansModel) > 0)
  1358. nn++;
  1359. }
  1360. if (nn == iii.Length)
  1361. cc++;
  1362. }
  1363. else
  1364. {
  1365. ansModel.F_QIID = int.Parse(ii[1]);
  1366. ansModel.F_Answer = ii[2];
  1367. if (ansBLL.Add(ansModel) > 0)
  1368. cc++;
  1369. }
  1370. }
  1371. }
  1372. #endregion
  1373. }
  1374. #endregion
  1375. #region 保存日志
  1376. otnModel.F_HJJGId = hjjgid;
  1377. var hjconfig = new BLL.T_Sys_DictionaryValue().GetModel(hjjgid);
  1378. if (hjconfig != null)
  1379. otnModel.F_HJJGName = hjconfig.F_Name;
  1380. //otnModel.F_YHFKId = yhfkid;
  1381. //var fkconfig = new BLL.T_Sys_DictionaryValue().GetModel(yhfkid);
  1382. //if (fkconfig != null)
  1383. // otnModel.F_YHFKName = fkconfig.F_Name;
  1384. otnModel.ExpandVchField2 = phone;
  1385. otnModel.ExpandVchField3 = address;
  1386. var fkconfig = new BLL.T_Sys_DictionaryValue().GetModel(countryid);
  1387. if (fkconfig != null)
  1388. otnModel.ExpandVchField4 = fkconfig.F_Name;
  1389. otnModel.ExpandIntField1 = countryid;//乡镇
  1390. otnModel.ExpandDatField1 = DateTime.Now;//调查时间
  1391. otnModel.F_AskRes = askqids;
  1392. otnModel.F_AskInfo = ansids;
  1393. otnModel.F_CusID = cusid;
  1394. otnModel.F_CusName = name;
  1395. otnModel.CallId = callid;
  1396. otnBLL.Update(otnModel);
  1397. planrecord(otnModel);
  1398. #endregion
  1399. }
  1400. }
  1401. if (ans != null)
  1402. {
  1403. //if (cc == ans.Length)
  1404. if(cc>0)
  1405. {
  1406. return Success("问卷答案提交成功!taskid=" + taskid + ",custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode, custelid);
  1407. }
  1408. //else
  1409. //{
  1410. // ansBLL.DeleteByTelid(custelid, taskid);
  1411. // return Error("问卷答案提交失败!taskid=" + taskid + ",custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  1412. //}
  1413. else
  1414. {
  1415. return Error("没有问卷答案提交");
  1416. }
  1417. }
  1418. else
  1419. {
  1420. return Error("没有问卷答案提交");
  1421. }
  1422. }
  1423. #endregion
  1424. public ActionResult AddAnswers(int phoneid,string F_typeName1,string F_typeName2, string F_typeName3, string F_typeName4, string F_typeName5, string F_typeName6,string value1, string value2, string value3, string value4, string value5, string value6, string F_TypeName7,string value7)
  1425. {
  1426. Model.T_TypeResult remodel = new Model.T_TypeResult();
  1427. remodel.F_PhoneID = phoneid;
  1428. remodel.F_typeName1 = F_typeName1;
  1429. remodel.F_typeName2 = F_typeName2;
  1430. remodel.F_typeName3 = F_typeName3;
  1431. remodel.F_typeName4 = F_typeName4;
  1432. remodel.F_typeName5 = F_typeName5;
  1433. remodel.F_typeName6 = F_typeName6;
  1434. remodel.F_typeName7 = F_TypeName7;
  1435. remodel.F_typeValue1 = value1;
  1436. remodel.F_typeValue2 = value2;
  1437. remodel.F_typeValue3 = value3;
  1438. remodel.F_typeValue4 = value4;
  1439. remodel.F_typeValue5 = value5;
  1440. remodel.F_typeValue6 = value6;
  1441. remodel.F_typeValue7 = value7;
  1442. remodel.F_userId = CurrentUser.UserData.F_UserId.ToString();
  1443. BLL.T_TypeResult bll = new BLL.T_TypeResult();
  1444. bll.Add(remodel);
  1445. return Success("保存成功");
  1446. }
  1447. #region 客户档案
  1448. /// <summary>
  1449. /// 保存客户档案
  1450. /// </summary>
  1451. /// <param name="telphone"></param>
  1452. /// <param name="name"></param>
  1453. /// <param name="phone"></param>
  1454. /// <param name="countryid"></param>
  1455. /// <param name="address"></param>
  1456. /// <returns></returns>
  1457. private int saveCus(string telphone, string name, string phone,int countryid, string address, string F_SaleOffice, string F_AccessTime, string F_BroadbandAccount, string F_Channel, string F_Fusion)
  1458. {
  1459. //F_SaleOffice,F_AccessTime,F_BroadbandAccount,F_Channele,F_Fusion
  1460. int res = 0;
  1461. Model.T_Cus_CustomerBase cusmodel = new Model.T_Cus_CustomerBase();
  1462. if (!string.IsNullOrWhiteSpace(telphone))
  1463. {
  1464. var fkconfig = new BLL.T_Sys_DictionaryValue().GetModel(countryid);
  1465. cusmodel = cusBLL.GetModelByPhone(telphone);
  1466. if (cusmodel != null)
  1467. {
  1468. cusmodel.F_Address = address;
  1469. if (fkconfig != null)
  1470. cusmodel.F_City = fkconfig.F_Name;
  1471. cusmodel.F_CityID = countryid;
  1472. cusmodel.F_CustomerName = name;
  1473. cusmodel.F_Telephone = phone;
  1474. cusmodel.F_SaleOffice = F_SaleOffice;
  1475. cusmodel.F_AccessTime = F_AccessTime;
  1476. cusmodel.F_BroadbandAccount = F_BroadbandAccount;
  1477. cusmodel.F_Channel = F_Channel;
  1478. cusmodel.F_Fusion = F_Fusion;
  1479. cusBLL.Update(cusmodel);
  1480. res = cusmodel.F_CustomerId;
  1481. }
  1482. else
  1483. {
  1484. cusmodel = new Model.T_Cus_CustomerBase();
  1485. cusmodel.F_Address = address;
  1486. if (fkconfig != null)
  1487. cusmodel.F_City = fkconfig.F_Name;
  1488. cusmodel.F_CityID = countryid;
  1489. cusmodel.F_CustomerName = name;
  1490. cusmodel.F_Telephone = phone;
  1491. cusmodel.F_Mobile = telphone;
  1492. cusmodel.F_SaleOffice = F_SaleOffice;
  1493. cusmodel.F_AccessTime = F_AccessTime;
  1494. cusmodel.F_BroadbandAccount = F_BroadbandAccount;
  1495. cusmodel.F_Channel = F_Channel;
  1496. cusmodel.F_Fusion = F_Fusion;
  1497. res = cusBLL.Add(cusmodel);
  1498. }
  1499. }
  1500. return res;
  1501. }
  1502. #endregion
  1503. #region 获取记录
  1504. //获取外呼通话记录
  1505. public ActionResult GetTelList(string type, string telid, string phone, string usercode)
  1506. {
  1507. string sql = "";
  1508. DataTable dt = new DataTable();
  1509. sql += " and TaskType='1'";
  1510. if (telid != null && telid.Trim() != "")
  1511. {
  1512. sql += " and CallType=1 and TaskPhoneID='" + telid.Trim() + "' ";
  1513. }
  1514. if (phone != null && phone.Trim() != "")
  1515. {
  1516. sql += " and CallNumber like'%" + phone + "%'";
  1517. }
  1518. if (usercode != null && usercode.Trim() != "")
  1519. {
  1520. sql += " and UserCode='" + usercode + "'";
  1521. }
  1522. string strpageindex = RequestString.GetQueryString("page");
  1523. int pageindex = 1;
  1524. string strpagesize = RequestString.GetQueryString("pagesize");
  1525. int pagesize = 10;
  1526. if (strpageindex.Trim() != "")
  1527. {
  1528. pageindex = Convert.ToInt32(strpageindex);
  1529. }
  1530. if (strpagesize.Trim() != "")
  1531. {
  1532. pagesize = Convert.ToInt32(strpagesize);
  1533. }
  1534. int recordCount = 0;
  1535. dt = BLL.PagerBLL.GetListPager(
  1536. "T_Call_CallRecords",
  1537. "CallRecordsId",
  1538. "*",
  1539. sql,
  1540. "ORDER BY CallRecordsId desc",
  1541. pagesize,
  1542. pageindex,
  1543. true,
  1544. out recordCount);
  1545. var obj = new
  1546. {
  1547. rows = dt,
  1548. total = recordCount
  1549. };
  1550. return Content(obj.ToJson());
  1551. }
  1552. #endregion
  1553. #region 记录日志
  1554. private void planrecord(Model.T_Call_OutTaskTelNum tnModel)
  1555. {
  1556. Model.T_Call_OutTaskRecords trModel = new Model.T_Call_OutTaskRecords();
  1557. trModel.F_AskInfo = tnModel.F_AskInfo;
  1558. trModel.F_AskRes = tnModel.F_AskRes;
  1559. trModel.F_CreateTime = tnModel.F_CreateTime;
  1560. trModel.F_CusID = tnModel.F_CusID;
  1561. trModel.F_CusName = tnModel.F_CusName;
  1562. trModel.F_FPState = tnModel.F_FPState;
  1563. trModel.F_HCState = tnModel.F_HCState;
  1564. trModel.F_HJJGId = tnModel.F_HJJGId;
  1565. trModel.F_HJJGName = tnModel.F_HJJGName;
  1566. trModel.F_TelID = tnModel.F_Id;
  1567. trModel.F_OptTime = DateTime.Now;
  1568. trModel.F_OptUserCode = CurrentUser.UserData.F_UserCode;
  1569. trModel.F_Phone = tnModel.F_Phone;
  1570. trModel.F_PhoneBy = tnModel.F_PhoneBy;
  1571. trModel.F_TaskId = tnModel.F_TaskId;
  1572. trModel.F_UserId = tnModel.F_UserId;
  1573. trModel.F_UserName = tnModel.F_UserName;
  1574. trModel.F_YHFKId = tnModel.F_YHFKId;
  1575. trModel.F_YHFKName = tnModel.F_YHFKName;
  1576. trModel.F_YJState = tnModel.F_YJState;
  1577. trModel.ExpandIntField1 = tnModel.ExpandIntField1;
  1578. trModel.ExpandDatField1 = tnModel.ExpandDatField1;
  1579. new BLL.T_Call_OutTaskRecords().Add(trModel);
  1580. }
  1581. #endregion
  1582. public ActionResult GetDepartList()
  1583. {
  1584. string sql = " F_State=1 and F_ParentId!=0 and F_ParentName is not null ";
  1585. BLL.T_Sys_Department bll = new BLL.T_Sys_Department();
  1586. List<Model.T_Sys_Department> userSeartList = bll.GetModelList(sql + " order by F_DeptId desc ");
  1587. if (userSeartList.Count > 0)
  1588. return Success("列表加载成功", userSeartList);
  1589. else
  1590. return Error("列表加载失败");
  1591. }
  1592. }
  1593. }