周口郸城医院 DanChengCallCenter_API

FollowUpController.cs 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. using CallCenter.Utility;
  2. using CallCenterApi.DB;
  3. using CallCenterApi.Interface.Controllers.Base;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.Mvc;
  10. namespace CallCenterApi.Interface.Controllers.MedicalFollowup
  11. {
  12. public class FollowUpController : BaseController
  13. {
  14. //private readonly BLL.T_Call_OutTaskTelNum otnBLL = new BLL.T_Call_OutTaskTelNum();
  15. private readonly BLL.T_Call_OutAnswers ansBLL = new BLL.T_Call_OutAnswers();
  16. private readonly BLL.T_Med_FollowUp mfBLL = new BLL.T_Med_FollowUp();
  17. private readonly BLL.T_Ask_Question questionBLL = new BLL.T_Ask_Question();
  18. private readonly BLL.T_Ask_QuestionItems questionItemBLL = new BLL.T_Ask_QuestionItems();
  19. private readonly BLL.T_Ask_PagerInfo pagerInfoBLL = new BLL.T_Ask_PagerInfo();
  20. BLL.SF_BINGRENQK busSF_BINGRENQK = new BLL.SF_BINGRENQK();
  21. // GET: FollowUp
  22. public ActionResult Index()
  23. {
  24. return View();
  25. }
  26. #region 获取随访列表
  27. /// <summary>
  28. /// 获取随访列表
  29. /// </summary>
  30. /// <returns></returns>
  31. public ActionResult GetListAll()
  32. {
  33. string sql = " datediff(day,T1.CYRQ,'2020-11-01')<=0 ";
  34. DataTable dt = new DataTable();
  35. string dischargedept = HttpUtility.UrlDecode(RequestString.GetQueryString("dischargedept"));//出院科室
  36. string strstate = "0";// HttpUtility.UrlDecode(RequestString.GetQueryString("state"));//状态
  37. string strcode = HttpUtility.UrlDecode(RequestString.GetQueryString("code"));//病案号
  38. string stropename = HttpUtility.UrlDecode(RequestString.GetQueryString("opename"));//手术名称
  39. //来电号码
  40. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("phone"));//联系人电话
  41. string BRXM = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));//姓名
  42. string strdoctor = "";// HttpUtility.UrlDecode(RequestString.GetQueryString("tubedoctor"));//管床医生 adminken
  43. //诊断名称
  44. string strzdmc = HttpUtility.UrlDecode(RequestString.GetQueryString("zdmc"));//诊断名称
  45. //出院日期
  46. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));//查询起始时间
  47. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));//查询截止时间
  48. //总费用
  49. string strcosts = HttpUtility.UrlDecode(RequestString.GetQueryString("costs"));
  50. string strcoste = HttpUtility.UrlDecode(RequestString.GetQueryString("coste"));
  51. //随访日期 adminken
  52. string strtime = "";// HttpUtility.UrlDecode(RequestString.GetQueryString("sftime"));
  53. //仅包含随访结束的
  54. string strsfend = "";// HttpUtility.UrlDecode(RequestString.GetQueryString("sfend"));
  55. //仅二级随访未完成
  56. string strejwwc = "";//HttpUtility.UrlDecode(RequestString.GetQueryString("secondlevel"));
  57. //满意度
  58. string strsatisfy = ""; HttpUtility.UrlDecode(RequestString.GetQueryString("satisfied"));
  59. //类型
  60. string strtype = "";// HttpUtility.UrlDecode(RequestString.GetQueryString("type"));
  61. string strpageindex = RequestString.GetQueryString("page");
  62. int pageindex = 1;
  63. string strpagesize = RequestString.GetQueryString("pagesize");
  64. int pagesize = 10;
  65. if (dischargedept.Trim() != "" && dischargedept != "undefined")
  66. {
  67. sql += " and T1.CYKS like '%" + dischargedept.Trim() + "%' ";
  68. }
  69. if (strstate.Trim() != "" && strstate != "undefined")
  70. {
  71. if (strstate == "2")
  72. {
  73. sql += " and T4.F_Id IS NOT NULL ";
  74. }
  75. else if (strstate == "0")
  76. {
  77. sql += " and T4.F_Id IS NULL ";
  78. }
  79. }
  80. if (strcode.Trim() != "" && strcode != "undefined")
  81. {
  82. sql += " and T1.BAH = '" + strcode.Trim() + "' ";
  83. }
  84. if (stropename.Trim() != "" && stropename != "undefined")
  85. {
  86. sql += " and T2.SSMC like '%" + stropename.Trim() + "%' ";
  87. }
  88. if (BRXM.Trim() != "" && BRXM != "undefined")
  89. {
  90. sql += " and T1.BRXM = '" + BRXM.Trim() + "' ";
  91. }
  92. if (strdoctor.Trim() != "" && strdoctor != "undefined")
  93. {
  94. sql += " and F_TubeDoctor like '%" + strdoctor.Trim() + "%' ";
  95. }
  96. if (strtel.Trim() != "" && strtel != "undefined")
  97. {
  98. sql += " and T1.XZZDH like '%" + strtel + "%' ";
  99. }
  100. if (strstarttime!=null&&strstarttime.Trim() != "" && strstarttime != "undefined")
  101. {
  102. sql += " and datediff(day,T1.CYRQ,'" + strstarttime + "')<=0 ";
  103. }
  104. if (strendtime.Trim() != "" && strendtime != "undefined")
  105. {
  106. sql += " and datediff(day,T1.CYRQ,'" + strendtime + "')>=0 ";
  107. }
  108. if (strzdmc.Trim() != "" && strzdmc != "undefined")
  109. {
  110. sql += " and T3.ZZDMC = '" + strzdmc.Trim() + "' ";
  111. }
  112. if (strcosts.Trim() != "" && strcosts != "undefined")
  113. {
  114. sql += " and T1.ZFY >= '" + strzdmc.Trim() + "' ";
  115. }
  116. if (strcoste.Trim() != "" && strcoste != "undefined")
  117. {
  118. sql += " and T1.ZFY <= '" + strzdmc.Trim() + "' ";
  119. }
  120. if (strtime.Trim() != "" && strtime != "undefined")
  121. {
  122. sql += " and datediff(day,F_SFDate,'" + strtime + "')=0 ";
  123. }
  124. //if (strsfend.Trim() != "" && strsfend != "undefined")
  125. //{
  126. // sql += " and F_State = 3 ";//随访完成状态
  127. //}
  128. if (strejwwc.Trim() != "" && strejwwc != "undefined")
  129. {
  130. sql += " and F_State = 2 ";//随访完成状态
  131. }
  132. if (strsatisfy.Trim() != "" && strsatisfy != "undefined")
  133. {
  134. sql += " and F_Satisfied = '" + strsatisfy + "' ";//随访完成状态
  135. }
  136. if (strtype.Trim() != "" && strtype != "undefined")
  137. {
  138. sql += " and F_Type = '" + strtype.Trim() + "' ";
  139. }
  140. if (strpageindex.Trim() != "")
  141. {
  142. pageindex = Convert.ToInt32(strpageindex);
  143. }
  144. if (strpagesize.Trim() != "")
  145. {
  146. pagesize = Convert.ToInt32(strpagesize);
  147. }
  148. int count = 0;
  149. dt =busSF_BINGRENQK.GetALLListByPage(sql,"", (pageindex-1)*pagesize, pagesize*pageindex, out count);
  150. //dt = BLL.PagerBLL.GetListPager(
  151. // "T_Med_FollowUp",
  152. // "T_Med_FollowUp.F_Id",
  153. // "*",
  154. // sql,
  155. // "ORDER BY T_Med_FollowUp.F_Id desc",
  156. // pagesize,
  157. // pageindex,
  158. // true,
  159. // out recordCount);
  160. var obj = new
  161. {
  162. state = "success",
  163. message = "成功",
  164. rows = dt,
  165. total = count
  166. };
  167. return Content(obj.ToJson());
  168. }
  169. /// <summary>
  170. /// 根据id获取信息
  171. /// </summary>
  172. /// <returns></returns>
  173. public ActionResult GetListById(string id)
  174. {
  175. int idint = Convert.ToInt32(id);
  176. DataTable dt = new DataTable();
  177. dt = busSF_BINGRENQK.GetALLListById(" T1.BINGRENZYID="+ idint, "", 0, 1);
  178. var obj = new
  179. {
  180. state = "success",
  181. message = "成功",
  182. rows = dt,
  183. total = 1
  184. };
  185. return Content(obj.ToJson());
  186. }
  187. /// <summary>
  188. /// 获取随访单条结果
  189. /// </summary>
  190. /// <returns></returns>
  191. public ActionResult Getdetail()
  192. {
  193. DataTable dt = new DataTable();
  194. int F_Id =Convert.ToInt32(HttpUtility.UrlDecode(RequestString.GetQueryString("F_Id")));
  195. BLL.T_Med_FollowUp busfollowUp = new BLL.T_Med_FollowUp();
  196. Model.T_Med_FollowUp model = busfollowUp.GetModel(F_Id);
  197. return Content(model.ToJson());
  198. }
  199. /// <summary>
  200. /// 获取随访列表
  201. /// </summary>
  202. /// <returns></returns>
  203. public ActionResult GetListAllOld()
  204. {
  205. string sql = " and F_IsDel=0 ";
  206. DataTable dt = new DataTable();
  207. string dischargedept = HttpUtility.UrlDecode(RequestString.GetQueryString("dischargedept"));//出院科室
  208. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));//状态
  209. string strcode = HttpUtility.UrlDecode(RequestString.GetQueryString("code"));//病案号
  210. string stropename = HttpUtility.UrlDecode(RequestString.GetQueryString("opename"));//手术名称
  211. //来电号码
  212. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("phone"));//联系人电话
  213. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));//姓名
  214. string strdoctor = HttpUtility.UrlDecode(RequestString.GetQueryString("tubedoctor"));//管床医生
  215. //诊断名称
  216. string strzdmc = HttpUtility.UrlDecode(RequestString.GetQueryString("zdmc"));//诊断名称
  217. //出院日期
  218. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));//查询起始时间
  219. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));//查询截止时间
  220. //总费用
  221. string strcosts = HttpUtility.UrlDecode(RequestString.GetQueryString("costs"));
  222. string strcoste = HttpUtility.UrlDecode(RequestString.GetQueryString("coste"));
  223. //随访日期
  224. string strtime = HttpUtility.UrlDecode(RequestString.GetQueryString("sftime"));
  225. //仅包含随访结束的
  226. string strsfend = HttpUtility.UrlDecode(RequestString.GetQueryString("sfend"));
  227. //仅二级随访未完成
  228. string strejwwc = HttpUtility.UrlDecode(RequestString.GetQueryString("secondlevel"));
  229. //满意度
  230. string strsatisfy = HttpUtility.UrlDecode(RequestString.GetQueryString("satisfied"));
  231. //类型
  232. string strtype = HttpUtility.UrlDecode(RequestString.GetQueryString("type"));
  233. string strpageindex = RequestString.GetQueryString("page");
  234. int pageindex = 1;
  235. string strpagesize = RequestString.GetQueryString("pagesize");
  236. int pagesize = 10;
  237. if (dischargedept.Trim() != "" && dischargedept != "undefined")
  238. {
  239. sql += " and F_DischargeDept like '%" + dischargedept.Trim() + "%' ";
  240. }
  241. if (strstate.Trim() != "" && strstate != "undefined")
  242. {
  243. sql += " and F_State = '" + strstate.Trim() + "' ";
  244. }
  245. if (strcode.Trim() != "" && strcode != "undefined")
  246. {
  247. sql += " and F_Code = '" + strcode.Trim() + "' ";
  248. }
  249. if (stropename.Trim() != "" && stropename != "undefined")
  250. {
  251. sql += " and F_OpeName like '%" + stropename.Trim() + "%' ";
  252. }
  253. if (strname.Trim() != "" && strname != "undefined")
  254. {
  255. sql += " and F_Name = '" + strname.Trim() + "' ";
  256. }
  257. if (strdoctor.Trim() != "" && strdoctor != "undefined")
  258. {
  259. sql += " and F_TubeDoctor like '%" + strdoctor.Trim() + "%' ";
  260. }
  261. if (strtel.Trim() != "" && strtel != "undefined")
  262. {
  263. sql += " and F_Phone like '%" + strtel + "%' ";
  264. }
  265. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  266. {
  267. sql += " and datediff(day,F_OutDate,'" + strstarttime + "')<=0 ";
  268. }
  269. if (strendtime.Trim() != "" && strendtime != "undefined")
  270. {
  271. sql += " and datediff(day,F_OutDate,'" + strendtime + "')>=0 ";
  272. }
  273. if (strzdmc.Trim() != "" && strzdmc != "undefined")
  274. {
  275. sql += " and F_ZDMC = '" + strzdmc.Trim() + "' ";
  276. }
  277. if (strcosts.Trim() != "" && strcosts != "undefined")
  278. {
  279. sql += " and F_TotalCosts >= '" + strzdmc.Trim() + "' ";
  280. }
  281. if (strcoste.Trim() != "" && strcoste != "undefined")
  282. {
  283. sql += " and F_TotalCosts <= '" + strzdmc.Trim() + "' ";
  284. }
  285. if (strtime.Trim() != "" && strtime != "undefined")
  286. {
  287. sql += " and datediff(day,F_SFDate,'" + strtime + "')=0 ";
  288. }
  289. if (strsfend.Trim() != "" && strsfend != "undefined")
  290. {
  291. sql += " and F_State = 3 ";//随访完成状态
  292. }
  293. if (strejwwc.Trim() != "" && strejwwc != "undefined")
  294. {
  295. sql += " and F_State = 2 ";//随访完成状态
  296. }
  297. if (strsatisfy.Trim() != "" && strsatisfy != "undefined")
  298. {
  299. sql += " and F_Satisfied = '"+strsatisfy +"' ";//随访完成状态
  300. }
  301. if (strtype.Trim() != "" && strtype != "undefined")
  302. {
  303. sql += " and F_Type = '" + strtype.Trim() + "' ";
  304. }
  305. if (strpageindex.Trim() != "")
  306. {
  307. pageindex = Convert.ToInt32(strpageindex);
  308. }
  309. if (strpagesize.Trim() != "")
  310. {
  311. pagesize = Convert.ToInt32(strpagesize);
  312. }
  313. int recordCount = 0;
  314. dt = BLL.PagerBLL.GetListPager(
  315. "T_Med_FollowUp",
  316. "T_Med_FollowUp.F_Id",
  317. "*",
  318. sql,
  319. "ORDER BY T_Med_FollowUp.F_Id desc",
  320. pagesize,
  321. pageindex,
  322. true,
  323. out recordCount);
  324. var obj = new
  325. {
  326. state = "success",
  327. message = "成功",
  328. rows = dt,
  329. total = recordCount
  330. };
  331. return Content(obj.ToJson());
  332. }
  333. #endregion
  334. #region 问卷回答
  335. /// <summary>
  336. ///
  337. /// </summary>
  338. /// <param name="taskid">任务ID</param>
  339. /// <param name="custelid">客户电话ID</param>
  340. /// <param name="ans">答案,数组形式["15_20_单选选项内容","17_25|36|58_复选选项内容1|选项内容2|选项内容3","30_0_问答题"]</param>
  341. /// <param name="hjjgid">呼叫结果</param>
  342. /// <param name="telphone">电话号码</param>
  343. /// <param name="name">姓名</param>
  344. /// <param name="phone">固定号码</param>
  345. /// <param name="countryid">乡镇id</param>
  346. /// <param name="address">地址</param>
  347. /// <returns></returns>
  348. public ActionResult Answers(int? taskid, int custelid, string[] ans, int hjjgid,
  349. string name, string phone, string address,string advise, string satisfied,string praise,string criticism,int pagerid=0, int countryid = 0)
  350. {
  351. taskid = 0;
  352. int cc = 0;
  353. if (custelid > 0)
  354. {
  355. var otnModel = busSF_BINGRENQK.GetModel(custelid.ToString());
  356. if (otnModel != null)
  357. {
  358. //物业系统,客户档案信息是存储业主信息的,外呼不需要存储
  359. //int cusid = saveCus(otnModel.F_Phone, name, phone, countryid, address);
  360. int cusid = 0;
  361. #region 保存答案
  362. var ansModel = new Model.T_Call_OutAnswers();
  363. string askqids = "";
  364. string ansids = "";
  365. if (ans != null)
  366. {
  367. //先删除 后添加
  368. ansBLL.DeleteByTelid(custelid, taskid);
  369. ansModel.F_TaskID = taskid;
  370. ansModel.F_CusTelID = custelid;
  371. ansModel.F_CusID = cusid;
  372. ansModel.F_OptBy = CurrentUser.UserData.F_UserId;
  373. ansModel.F_OptByName = CurrentUser.UserData.F_UserName;
  374. ansModel.F_OptOn = DateTime.Now;
  375. ansModel.F_Expand1 = countryid.ToString();
  376. ansModel.F_Expand3 = DateTime.Now.ToString("yyyyMMddHHmmssfff");
  377. #region 循环保存
  378. foreach (var item in ans)
  379. {
  380. var nn = 0;
  381. var ii = item.Split('_');
  382. ansModel.F_QID = int.Parse(ii[0]);
  383. askqids += ii[0] + ",";
  384. ansids += ii[1] + ",";
  385. if (ii[1].IndexOf('|') > 0)
  386. {
  387. var iii = ii[1].Trim('|').Split('|');
  388. var iia = ii[2].Trim('|').Split('|');
  389. for (int i = 0; i < iii.Length; i++)
  390. {
  391. ansModel.F_QIID = int.Parse(iii[i]);
  392. ansModel.F_Answer = iia[i];
  393. if (ansBLL.Add(ansModel) > 0)
  394. nn++;
  395. }
  396. if (nn == iii.Length)
  397. cc++;
  398. }
  399. else
  400. {
  401. ansModel.F_QIID = int.Parse(ii[1]);
  402. ansModel.F_Answer = ii[2];
  403. if (ansBLL.Add(ansModel) > 0)
  404. cc++;
  405. }
  406. }
  407. #endregion
  408. }
  409. #endregion
  410. #region 保存日志
  411. BLL.SF_Result busResult= new BLL.SF_Result();
  412. Model.SF_Result modelResult= busResult.GetModel(custelid.ToString());
  413. if (modelResult != null)
  414. {
  415. busResult.Delete(modelResult.F_Id);
  416. modelResult.F_SFNum += 1;
  417. modelResult.F_Remark += "<br/>上次满意度:" + modelResult.F_MYD;
  418. modelResult.F_Remark += "<br/>上次建议:" + modelResult.F_Advise;
  419. modelResult.F_Remark += "<br/>上次回访结果" + modelResult.F_Result;
  420. }
  421. else
  422. {
  423. modelResult = new Model.SF_Result();
  424. modelResult.F_SFNum = 1;
  425. }
  426. var hjconfig = new BLL.T_Sys_DictionaryValue().GetModel(hjjgid);
  427. if (hjconfig != null)
  428. modelResult.F_Result = hjconfig.F_Name;
  429. modelResult.F_Id = custelid.ToString();
  430. modelResult.F_SFPersion = CurrentUser.UserData.F_UserName;
  431. modelResult.F_SFPersionId= CurrentUser.UserData.F_UserCode;
  432. modelResult.F_SFTime = DateTime.Now;
  433. modelResult.F_Advise = advise;
  434. modelResult.F_MYD = satisfied;
  435. modelResult.F_PagerID = pagerid.ToString();
  436. modelResult.F_Praise = praise;
  437. modelResult.F_Criticism = criticism;
  438. modelResult.F_State = 2;
  439. busResult.Add(modelResult);
  440. //planrecord(otnModel);
  441. #endregion
  442. }
  443. }
  444. if (ans != null)
  445. {
  446. if (cc == ans.Length)
  447. {
  448. //return Success("问卷答案提交成功!taskid=" + taskid + ",custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  449. return Success("问卷答案提交成功!custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  450. }
  451. else
  452. {
  453. ansBLL.DeleteByTelid(custelid, taskid);
  454. return Error("问卷答案提交失败!custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  455. }
  456. }
  457. else
  458. {
  459. return Error("没有问卷答案提交");
  460. }
  461. }
  462. #endregion
  463. #region 导出
  464. #endregion
  465. #region 获取随访结果详情
  466. //获取任务结果详情
  467. public ActionResult GetTaskTelInfo(int id = 0)
  468. {
  469. if (id <= 0)
  470. return Error("参数不正确");
  471. var model = mfBLL.GetModel(id);
  472. var paperid = 0;
  473. if (model != null)
  474. {
  475. var taskmodel = new Model.T_Med_FollowUp();
  476. #region 绑定任务和客户信息
  477. taskmodel.F_Id = model.F_Id;//号码id
  478. //taskmodel.F_TaskId = model.F_TaskId.Value;//任务id
  479. //taskmodel.F_HJJGId = model.F_HJJGId != null ? model.F_HJJGId.Value : 0;//呼叫结果id
  480. taskmodel.F_Satisfied = model.F_Satisfied;
  481. taskmodel.F_SFResult = model.F_SFResult;
  482. if (!string.IsNullOrWhiteSpace(model.F_Name))
  483. taskmodel.F_Name = model.F_Name;//客户姓名
  484. if (!string.IsNullOrWhiteSpace(model.F_Phone))
  485. taskmodel.F_Phone = model.F_Phone;//号码
  486. if (!string.IsNullOrWhiteSpace(model.F_Addr))
  487. taskmodel.F_Addr = model.F_Addr;//住址
  488. #endregion
  489. var anslist = ansBLL.GetModelList(" F_CusTelID=" + id + " ");//ansBLL.GetModelList(" F_TaskID=" + model.F_TaskId.Value + " and F_CusTelID=" + id + " ");
  490. //var tmodel = otBLL.GetModel(model.F_TaskId.Value);
  491. //if (tmodel != null)
  492. //{
  493. paperid = model .F_PagerID;
  494. #region 获取问卷试题信息以及答案
  495. var pmodel = pagerInfoBLL.GetModel(paperid);
  496. 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 ");
  497. var qilist = questionItemBLL.GetModelList(" F_QuestionId in (select F_QuestionId from T_Ask_PagerItems where F_PagerId=" + paperid + ") order by F_ItemId ");
  498. var newmodel = new
  499. {
  500. F_Title = pmodel.F_Title,
  501. F_Remark = pmodel.F_Remark,
  502. F_StartText = pmodel.F_StartText,
  503. F_EndText = pmodel.F_EndText,
  504. F_Questions = qlist.Select(q =>
  505. {
  506. var answers = "";
  507. var qalist = anslist.Where(al => al.F_QID.Value == q.F_QuestionId).ToList<Model.T_Call_OutAnswers>();
  508. if (qalist.Count > 0)
  509. {
  510. if (q.F_Type > 1)
  511. {
  512. foreach (var item in qalist)
  513. {
  514. answers += item.F_QIID + "|";
  515. }
  516. }
  517. else
  518. {
  519. answers = qalist[0].F_Answer;
  520. }
  521. }
  522. return new
  523. {
  524. quesid = q.F_QuestionId,
  525. questitle = q.F_Title,
  526. questype = q.F_Type,
  527. quescontent = q.F_Content,
  528. quesremark = q.F_Remark,
  529. quesanswers = answers.Trim('|'),
  530. quesitems = qilist.Where(qq => qq.F_QuestionId == q.F_QuestionId).Select(qi =>
  531. {
  532. return new
  533. {
  534. itemid = qi.F_ItemId,
  535. itemname = qi.F_ItemName,
  536. itemremark = qi.F_Remark,
  537. };
  538. })
  539. };
  540. })
  541. };
  542. #endregion
  543. //taskmodel.F_TaskName = tmodel.F_TaskName;//任务名称
  544. //taskmodel.F_TaskRemark = tmodel.F_TaskRemark;//任务备注
  545. var objy = new
  546. {
  547. taskModel = taskmodel,
  548. paperModel = newmodel
  549. };
  550. return Success("获取详情成功", objy);
  551. //}
  552. }
  553. return Error("获取详情失败");
  554. }
  555. #endregion
  556. #region 科室随访率统计
  557. //获取数据
  558. public ActionResult GetSFDataList(string ks,string stime,string etime)
  559. {
  560. ActionResult res = NoToken("未知错误,请重新登录");
  561. DataTable dtNew = new DataTable();
  562. dtNew = GetData(ks, stime, etime);
  563. res = Success("获取科室随访率统计数据成功", dtNew);
  564. return res;
  565. }
  566. //获取数据源
  567. private DataTable GetData(string ks, string stime, string etime)
  568. {
  569. DataTable dtNew = new DataTable();
  570. #region 编辑表头
  571. /*DataColumn dc1 = new DataColumn("科室名称", Type.GetType("System.String"));
  572. DataColumn dc2 = new DataColumn("科室代码", Type.GetType("System.String"));
  573. DataColumn dc3 = new DataColumn("时间", Type.GetType("System.String"));
  574. DataColumn dc4 = new DataColumn("需要随访病人数", Type.GetType("System.String"));
  575. DataColumn dc5 = new DataColumn("随访完成人数", Type.GetType("System.String"));
  576. DataColumn dc6 = new DataColumn("科室随访率", Type.GetType("System.String"));
  577. DataColumn dc7 = new DataColumn("满意人数", Type.GetType("System.String"));
  578. DataColumn dc8 = new DataColumn("不满意人数", Type.GetType("System.String"));
  579. DataColumn dc9 = new DataColumn("随访满意率", Type.GetType("System.String"));
  580. dtNew.Columns.Add(dc1);
  581. dtNew.Columns.Add(dc2);
  582. dtNew.Columns.Add(dc3);
  583. dtNew.Columns.Add(dc4);
  584. dtNew.Columns.Add(dc5);
  585. dtNew.Columns.Add(dc6);
  586. #endregion
  587. string sql = " ";
  588. var list = bllCall.DataTableToList(bllCall.GetList($" 1=1 {sql} and UserCode is not null ").Tables[0]);
  589. int callInCount = 0, callOutCount = 0, calledCount = 0, nocalledCount = 0;
  590. //一天24小时
  591. for (int i = 0; i < 24; i++)
  592. {
  593. DateTime stimes = Convert.ToDateTime(stime + " 00:00:00").AddHours(i);
  594. DateTime etimes = Convert.ToDateTime(stime + " 00:59:59").AddHours(i);
  595. DataRow drNew = dtNew.NewRow();
  596. //SELECT BeginTime, * FROM T_Call_CallRecords WHERE DATEPART(hh,BeginTime) = DATEPART(hh, DATEADD(hh,-2,GETDATE())) and DATEPART(dd,BeginTime) = DATEPART(dd, GETDATE()) and DATEPART(mm, BeginTime) = DATEPART(mm, GETDATE()) and DATEPART(yy, BeginTime) = DATEPART(yy, GETDATE())
  597. //CallType
  598. //CallState呼叫状态,0:未接通电话1已接通电话
  599. var callInTimes = list.Where(x => x.CallType == 0 && x.BeginTime >= stimes && x.BeginTime <= etimes).Count(); //呼入量
  600. var callOutTimes = list.Where(x => x.CallType == 1 && x.BeginTime >= stimes && x.BeginTime <= etimes).Count(); //呼出量
  601. var calledTimes = list.Where(x => x.CallState == 1 && x.BeginTime >= stimes && x.BeginTime <= etimes).Count(); //接通量
  602. var nocalledTimes = list.Where(x => x.CallState == 0 && x.BeginTime >= stimes && x.BeginTime <= etimes).Count();//未接通量
  603. //var calledRate = list.Where(x => x.CallType == 1 && x.BeginTime >= stimes && x.BeginTime <= etimes).Count();
  604. drNew["时间"] = (i + 1).ToString();
  605. drNew["呼入量"] = callInTimes.ToString();
  606. drNew["呼出量"] = callOutTimes.ToString();
  607. drNew["接通量"] = calledTimes.ToString();
  608. drNew["未接通量"] = nocalledTimes.ToString();
  609. //计算未结案率
  610. var calledTotal = calledTimes + nocalledTimes;
  611. Double notRate = 0.00;
  612. if (calledTotal > 0)
  613. notRate = (double)calledTimes / (double)calledTotal;
  614. drNew["接通率"] = (notRate * 100).ToString("0.00") + "%";
  615. ////统计结案,未结案数
  616. callInCount += callInTimes;
  617. callOutCount += callOutTimes;
  618. calledCount += calledTimes;
  619. nocalledCount += nocalledTimes;
  620. dtNew.Rows.Add(drNew);
  621. }
  622. #region 获取一条统计信息
  623. DataRow drzj = dtNew.NewRow();
  624. drzj["时间"] = "总计";
  625. drzj["呼入量"] = callInCount.ToString();
  626. drzj["呼出量"] = callOutCount.ToString();
  627. drzj["接通量"] = calledCount.ToString();
  628. drzj["未接通量"] = nocalledCount.ToString();
  629. //计算未结案率
  630. int totalAllCount = calledCount + nocalledCount;
  631. Double calledAllRate = 0.00;
  632. if (totalAllCount > 0)
  633. calledAllRate = (double)calledCount / (double)totalAllCount;
  634. drzj["接通率"] = (calledAllRate * 100).ToString("0.00") + "%";
  635. dtNew.Rows.Add(drzj);*/
  636. #endregion
  637. return dtNew;
  638. }
  639. #endregion
  640. }
  641. }