周口郸城医院 DanChengCallCenter_API

FollowUpController.cs 31KB

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