周口郸城医院 DanChengCallCenter_API

FollowUpController.cs 55KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace CallCenterApi.Interface.Controllers.MedicalFollowup
  13. {
  14. public class FollowUpController : BaseController
  15. {
  16. //private readonly BLL.T_Call_OutTaskTelNum otnBLL = new BLL.T_Call_OutTaskTelNum();
  17. private readonly BLL.T_Call_OutAnswers ansBLL = new BLL.T_Call_OutAnswers();
  18. private readonly BLL.SF_TaskAnswers ansnewBLL = new BLL.SF_TaskAnswers();
  19. private readonly BLL.T_Med_FollowUp mfBLL = new BLL.T_Med_FollowUp();
  20. private readonly BLL.T_Ask_Question questionBLL = new BLL.T_Ask_Question();
  21. private readonly BLL.T_Ask_QuestionItems questionItemBLL = new BLL.T_Ask_QuestionItems();
  22. private readonly BLL.T_Ask_PagerInfo pagerInfoBLL = new BLL.T_Ask_PagerInfo();
  23. private readonly BLL.SF_Task taskBLL = new BLL.SF_Task();
  24. private readonly BLL.SF_TaskDetail taskDetailBLL = new BLL.SF_TaskDetail();
  25. BLL.SF_BINGRENQK busSF_BINGRENQK = new BLL.SF_BINGRENQK();
  26. // GET: FollowUp
  27. public ActionResult Index()
  28. {
  29. return View();
  30. }
  31. #region 获取随访列表
  32. /// <summary>
  33. /// 获取随访列表
  34. /// </summary>
  35. /// <returns></returns>
  36. public ActionResult GetListAll()
  37. {
  38. //BAH not LIKE '%[_]11' 是客户要求列表中去掉xxx之子,xxx之女 的随访,这种是母亲 BAH_11
  39. // string sql = " datediff(day,T1.CYRQ,'2020-11-01')<=0 and BAH not LIKE '%[_]11' ";
  40. string sql = " BAH not LIKE '%[_]11' ";
  41. DataTable dt = new DataTable();
  42. string dischargedept = HttpUtility.UrlDecode(RequestString.GetQueryString("dischargedept"));//出院科室
  43. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));//状态
  44. string strcode = HttpUtility.UrlDecode(RequestString.GetQueryString("code"));//病案号
  45. string stropename = HttpUtility.UrlDecode(RequestString.GetQueryString("opename"));//手术名称
  46. //来电号码
  47. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("phone"));//联系人电话
  48. string BRXM = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));//姓名
  49. string strdoctor = "";// HttpUtility.UrlDecode(RequestString.GetQueryString("tubedoctor"));//管床医生 adminken
  50. //诊断名称
  51. string strzdmc = HttpUtility.UrlDecode(RequestString.GetQueryString("zdmc"));//诊断名称
  52. //出院日期
  53. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));//查询起始时间
  54. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));//查询截止时间
  55. //总费用
  56. string strcosts = HttpUtility.UrlDecode(RequestString.GetQueryString("costs"));
  57. string strcoste = HttpUtility.UrlDecode(RequestString.GetQueryString("coste"));
  58. //随访日期 adminken
  59. string strtime = "";// HttpUtility.UrlDecode(RequestString.GetQueryString("sftime"));
  60. //仅包含随访结束的
  61. string strsfend = "";// HttpUtility.UrlDecode(RequestString.GetQueryString("sfend"));
  62. string strResult = "";// HttpUtility.UrlDecode(RequestString.GetQueryString("sresult"));
  63. //仅二级随访未完成
  64. string strejwwc = "";//HttpUtility.UrlDecode(RequestString.GetQueryString("secondlevel"));
  65. //满意度
  66. string strsatisfy = ""; HttpUtility.UrlDecode(RequestString.GetQueryString("satisfied"));
  67. //类型
  68. string strtype = "";// HttpUtility.UrlDecode(RequestString.GetQueryString("type"));
  69. //建档日期
  70. string strjdrq = "";
  71. //病例分类
  72. string blfl = RequestString.GetQueryString("blfl");
  73. string strpageindex = RequestString.GetQueryString("page");
  74. int pageindex = 1;
  75. string strpagesize = RequestString.GetQueryString("pagesize");
  76. int pagesize = 10;
  77. if (dischargedept.Trim() != "" && dischargedept != "undefined")
  78. {
  79. sql += " and T1.CYKS like '%" + dischargedept.Trim() + "%' ";
  80. }
  81. if (strstate.Trim() != "" && strstate != "undefined")
  82. {
  83. if (strstate == "2")
  84. {
  85. sql += " and T4.F_Id IS NOT NULL and T4.F_Result in ('正常接通','拒访','不是本人','停机','空号','免回访','电话错误','死亡')";
  86. }
  87. else if (strstate == "1")
  88. {
  89. //'心胸外科','肿瘤科','肿瘤科病区',
  90. sql += " and T4.F_Id IS NULL AND T1.CYKS NOT IN ('肾病内科','感染性疾病科','肾病内科病区','肾病内科1','感染性疾病科病区','重症医学科(ICU)病区') AND T1.RYKS NOT IN ('肾病内科','感染性疾病科','肾病内科病区','肾病内科1','感染性疾病科病区','重症医学科(ICU)病区') ";//'心胸外科','肿瘤科','肿瘤科病区',
  91. }
  92. else if (strstate == "3")
  93. {
  94. sql += " and T4.F_Id IS NOT NULL and (T4.F_Result = '无人接听' OR t4.F_Result='关机' )";
  95. }
  96. else if (strstate == "4")
  97. {
  98. sql += " and T4.F_Id IS NOT NULL and T4.F_Result = '无人接听(二次)' ";
  99. }
  100. }
  101. else
  102. {
  103. sql += " and T4.F_Id IS NULL ";
  104. }
  105. if (strcode.Trim() != "" && strcode != "undefined")
  106. {
  107. sql += " and T1.BAH = '" + strcode.Trim() + "' ";
  108. }
  109. if (stropename.Trim() != "" && stropename != "undefined")
  110. {
  111. sql += " and ssmc like '%" + stropename.Trim() + "%' ";
  112. }
  113. if (BRXM.Trim() != "" && BRXM != "undefined")
  114. {
  115. sql += " and T1.BRXM = '" + BRXM.Trim() + "' ";
  116. }
  117. if (strdoctor.Trim() != "" && strdoctor != "undefined")
  118. {
  119. sql += " and F_TubeDoctor like '%" + strdoctor.Trim() + "%' ";
  120. }
  121. if (strtel.Trim() != "" && strtel != "undefined")
  122. {
  123. sql += " and T1.XZZDH like '%" + strtel + "%' ";
  124. }
  125. if (strstarttime != null && strstarttime.Trim() != "" && strstarttime != "undefined")
  126. {
  127. sql += " and datediff(day,T1.CYRQ,'" + strstarttime + "')<=0 ";
  128. }
  129. if (strendtime.Trim() != "" && strendtime != "undefined")
  130. {
  131. sql += " and datediff(day,T1.CYRQ,'" + strendtime + "')>=0 ";
  132. }
  133. if (strzdmc.Trim() != "" && strzdmc != "undefined")
  134. {
  135. sql += " and T3.ZZDMC = '" + strzdmc.Trim() + "' ";
  136. }
  137. if (strcosts.Trim() != "" && strcosts != "undefined")
  138. {
  139. sql += " and T1.ZFY >= '" + strzdmc.Trim() + "' ";
  140. }
  141. if (strcoste.Trim() != "" && strcoste != "undefined")
  142. {
  143. sql += " and T1.ZFY <= '" + strzdmc.Trim() + "' ";
  144. }
  145. if (strtime.Trim() != "" && strtime != "undefined")
  146. {
  147. sql += " and datediff(day,F_SFDate,'" + strtime + "')=0 ";
  148. }
  149. //if (strsfend.Trim() != "" && strsfend != "undefined")
  150. //{
  151. // sql += " and F_State = 3 ";//随访完成状态
  152. //}
  153. if (strejwwc.Trim() != "" && strejwwc != "undefined")
  154. {
  155. sql += " and F_State = 2 ";//随访完成状态
  156. }
  157. if (strsatisfy.Trim() != "" && strsatisfy != "undefined")
  158. {
  159. sql += " and F_Satisfied = '" + strsatisfy + "' ";//随访完成状态
  160. }
  161. if (strtype.Trim() != "" && strtype != "undefined")
  162. {
  163. sql += " and F_Type = '" + strtype.Trim() + "' ";
  164. }
  165. if (strpageindex.Trim() != "")
  166. {
  167. pageindex = Convert.ToInt32(strpageindex);
  168. }
  169. if (strjdrq.Trim() != "")
  170. {
  171. sql += "and T1.JDRQ='" + strjdrq.Trim() + "'";
  172. }
  173. if (blfl.Trim() != "")
  174. {
  175. sql += "and T1.BLFL='" + blfl.Trim() + "'";
  176. }
  177. if (strpagesize.Trim() != "")
  178. {
  179. pagesize = Convert.ToInt32(strpagesize);
  180. }
  181. int count = 0;
  182. //排序慢 先去掉
  183. string orderby = "";
  184. if (strstate == "2")
  185. {
  186. orderby = "F_SFTime desc";
  187. }
  188. if (strstate == "3")
  189. {
  190. orderby = "F_SFTime ";
  191. }
  192. dt = busSF_BINGRENQK.GetALLListByPage(sql, orderby, (pageindex - 1) * pagesize, pagesize * pageindex, out count);
  193. //dt = BLL.PagerBLL.GetListPager(
  194. // "T_Med_FollowUp",
  195. // "T_Med_FollowUp.F_Id",
  196. // "*",
  197. // sql,
  198. // "ORDER BY T_Med_FollowUp.F_Id desc",
  199. // pagesize,
  200. // pageindex,
  201. // true,
  202. // out recordCount);
  203. var obj = new
  204. {
  205. state = "success",
  206. message = "成功",
  207. rows = dt,
  208. total = count
  209. };
  210. return Content(obj.ToJson());
  211. }
  212. /// <summary>
  213. /// 根据id获取信息
  214. /// </summary>
  215. /// <returns></returns>
  216. public ActionResult GetListById(string id)
  217. {
  218. //int idint = Convert.ToInt32(id);
  219. DataTable dt = new DataTable();
  220. dt = busSF_BINGRENQK.GetALLListById(" T1.BINGRENZYID='" + id+"'", "", 0, 1);
  221. var obj = new
  222. {
  223. state = "success",
  224. message = "成功",
  225. rows = dt,
  226. total = 1
  227. };
  228. return Content(obj.ToJson());
  229. }
  230. /// <summary>
  231. /// 获取随访单条结果
  232. /// </summary>
  233. /// <returns></returns>
  234. public ActionResult Getdetail()
  235. {
  236. DataTable dt = new DataTable();
  237. int F_Id = Convert.ToInt32(HttpUtility.UrlDecode(RequestString.GetQueryString("F_Id")));
  238. BLL.T_Med_FollowUp busfollowUp = new BLL.T_Med_FollowUp();
  239. Model.T_Med_FollowUp model = busfollowUp.GetModel(F_Id);
  240. return Content(model.ToJson());
  241. }
  242. /// <summary>
  243. /// 获取随访列表
  244. /// </summary>
  245. /// <returns></returns>
  246. public ActionResult GetListAllOld()
  247. {
  248. string sql = " and F_IsDel=0 ";
  249. DataTable dt = new DataTable();
  250. string dischargedept = HttpUtility.UrlDecode(RequestString.GetQueryString("dischargedept"));//出院科室
  251. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));//状态
  252. string strcode = HttpUtility.UrlDecode(RequestString.GetQueryString("code"));//病案号
  253. string stropename = HttpUtility.UrlDecode(RequestString.GetQueryString("opename"));//手术名称
  254. //来电号码
  255. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("phone"));//联系人电话
  256. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));//姓名
  257. string strdoctor = HttpUtility.UrlDecode(RequestString.GetQueryString("tubedoctor"));//管床医生
  258. //诊断名称
  259. string strzdmc = HttpUtility.UrlDecode(RequestString.GetQueryString("zdmc"));//诊断名称
  260. //出院日期
  261. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));//查询起始时间
  262. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));//查询截止时间
  263. //总费用
  264. string strcosts = HttpUtility.UrlDecode(RequestString.GetQueryString("costs"));
  265. string strcoste = HttpUtility.UrlDecode(RequestString.GetQueryString("coste"));
  266. //随访日期
  267. string strtime = HttpUtility.UrlDecode(RequestString.GetQueryString("sftime"));
  268. //仅包含随访结束的
  269. string strsfend = HttpUtility.UrlDecode(RequestString.GetQueryString("sfend"));
  270. //仅二级随访未完成
  271. string strejwwc = HttpUtility.UrlDecode(RequestString.GetQueryString("secondlevel"));
  272. //满意度
  273. string strsatisfy = HttpUtility.UrlDecode(RequestString.GetQueryString("satisfied"));
  274. //类型
  275. string strtype = HttpUtility.UrlDecode(RequestString.GetQueryString("type"));
  276. string strpageindex = RequestString.GetQueryString("page");
  277. int pageindex = 1;
  278. string strpagesize = RequestString.GetQueryString("pagesize");
  279. int pagesize = 10;
  280. if (dischargedept.Trim() != "" && dischargedept != "undefined")
  281. {
  282. sql += " and F_DischargeDept like '%" + dischargedept.Trim() + "%' ";
  283. }
  284. if (strstate.Trim() != "" && strstate != "undefined")
  285. {
  286. sql += " and F_State = '" + strstate.Trim() + "' ";
  287. }
  288. if (strcode.Trim() != "" && strcode != "undefined")
  289. {
  290. sql += " and F_Code = '" + strcode.Trim() + "' ";
  291. }
  292. if (stropename.Trim() != "" && stropename != "undefined")
  293. {
  294. sql += " and F_OpeName like '%" + stropename.Trim() + "%' ";
  295. }
  296. if (strname.Trim() != "" && strname != "undefined")
  297. {
  298. sql += " and F_Name = '" + strname.Trim() + "' ";
  299. }
  300. if (strdoctor.Trim() != "" && strdoctor != "undefined")
  301. {
  302. sql += " and F_TubeDoctor like '%" + strdoctor.Trim() + "%' ";
  303. }
  304. if (strtel.Trim() != "" && strtel != "undefined")
  305. {
  306. sql += " and F_Phone like '%" + strtel + "%' ";
  307. }
  308. if (strstarttime.Trim() != "" && strstarttime != "undefined")
  309. {
  310. sql += " and datediff(day,F_OutDate,'" + strstarttime + "')<=0 ";
  311. }
  312. if (strendtime.Trim() != "" && strendtime != "undefined")
  313. {
  314. sql += " and datediff(day,F_OutDate,'" + strendtime + "')>=0 ";
  315. }
  316. if (strzdmc.Trim() != "" && strzdmc != "undefined")
  317. {
  318. sql += " and F_ZDMC = '" + strzdmc.Trim() + "' ";
  319. }
  320. if (strcosts.Trim() != "" && strcosts != "undefined")
  321. {
  322. sql += " and F_TotalCosts >= '" + strzdmc.Trim() + "' ";
  323. }
  324. if (strcoste.Trim() != "" && strcoste != "undefined")
  325. {
  326. sql += " and F_TotalCosts <= '" + strzdmc.Trim() + "' ";
  327. }
  328. if (strtime.Trim() != "" && strtime != "undefined")
  329. {
  330. sql += " and datediff(day,F_SFDate,'" + strtime + "')=0 ";
  331. }
  332. if (strsfend.Trim() != "" && strsfend != "undefined")
  333. {
  334. sql += " and F_State = 3 ";//随访完成状态
  335. }
  336. if (strejwwc.Trim() != "" && strejwwc != "undefined")
  337. {
  338. sql += " and F_State = 2 ";//随访完成状态
  339. }
  340. if (strsatisfy.Trim() != "" && strsatisfy != "undefined")
  341. {
  342. sql += " and F_Satisfied = '" + strsatisfy + "' ";//随访完成状态
  343. }
  344. if (strtype.Trim() != "" && strtype != "undefined")
  345. {
  346. sql += " and F_Type = '" + strtype.Trim() + "' ";
  347. }
  348. if (strpageindex.Trim() != "")
  349. {
  350. pageindex = Convert.ToInt32(strpageindex);
  351. }
  352. if (strpagesize.Trim() != "")
  353. {
  354. pagesize = Convert.ToInt32(strpagesize);
  355. }
  356. int recordCount = 0;
  357. dt = BLL.PagerBLL.GetListPager(
  358. "T_Med_FollowUp",
  359. "T_Med_FollowUp.F_Id",
  360. "*",
  361. sql,
  362. "ORDER BY T_Med_FollowUp.F_SFTime desc",
  363. pagesize,
  364. pageindex,
  365. true,
  366. out recordCount);
  367. var obj = new
  368. {
  369. state = "success",
  370. message = "成功",
  371. rows = dt,
  372. total = recordCount
  373. };
  374. return Content(obj.ToJson());
  375. }
  376. /// <summary>
  377. /// 病例信息
  378. /// </summary>
  379. /// <param name="dal">电话</param>
  380. /// <returns></returns>
  381. public ActionResult GetxinxiList(string dal,DateTime? sdate, DateTime? edate,string ryks)
  382. {
  383. string strpageindex = RequestString.GetQueryString("page");
  384. int pageindex = 1;
  385. string strpagesize = RequestString.GetQueryString("pagesize");
  386. int pagesize = 10;
  387. if (strpageindex.Trim() != "")
  388. {
  389. pageindex = Convert.ToInt32(strpageindex);
  390. }
  391. if (strpagesize.Trim() != "")
  392. {
  393. pagesize = Convert.ToInt32(strpagesize);
  394. }
  395. string sql = "";
  396. if (dal != null &&dal.Trim() != "" && dal != "undefined")
  397. {
  398. sql += " and XZZDH = '" + dal + "'";
  399. }
  400. if (sdate!=null && edate != null)
  401. {
  402. sql += " and RYRQ BETWEEN '"+sdate+ "' and '"+edate+"' ";
  403. }
  404. if (ryks != null &&ryks.Trim() != "" && ryks != "undefined")
  405. {
  406. sql += " and RYKS = '" + ryks + "'";
  407. }
  408. int recordCount = 0;
  409. DataTable dt = new DataTable();
  410. // dt = mfBLL.GetBLList(" XZZDH='" + dal + "'").Tables[0];
  411. dt = BLL.PagerBLL.GetListPager(
  412. "SF_BINGRENQK",
  413. "BAH",
  414. "*",
  415. sql,
  416. "ORDER BY RYRQ",
  417. pagesize,
  418. pageindex,
  419. true,
  420. out recordCount);
  421. var obj = new
  422. {
  423. state = "success",
  424. message = "成功",
  425. rows = dt,
  426. total = recordCount
  427. };
  428. return Content(obj.ToJson());
  429. }
  430. #endregion
  431. #region 问卷回答
  432. /// <summary>
  433. ///
  434. /// </summary>
  435. /// <param name="taskid">任务ID</param>
  436. /// <param name="custelid">BINGRENZYID</param>
  437. /// <param name="ans">答案,数组形式["15_20_单选选项内容","17_25|36|58_复选选项内容1|选项内容2|选项内容3","30_0_问答题"]</param>
  438. /// <param name="hjjgid">呼叫结果</param>
  439. /// <param name="telphone">电话号码</param>
  440. /// <param name="name">姓名</param>
  441. /// <param name="phone">固定号码</param>
  442. /// <param name="countryid">乡镇id</param>
  443. /// <param name="address">地址</param>
  444. /// <returns></returns>
  445. public ActionResult Answers(int? taskid, string custelid, string[] ans, int hjjgid,
  446. string name, string phone, string address, string advise, string satisfied, string praise, string criticism,string blfl, int pagerid = 0, int countryid = 0)
  447. {
  448. taskid = 0;
  449. int cc = 0;
  450. var hjconfig = new BLL.T_Sys_DictionaryValue().GetModel(hjjgid);
  451. if (hjconfig == null)
  452. {
  453. return Error("提交结果配置不正常");
  454. }
  455. if (!string.IsNullOrEmpty(custelid))
  456. {
  457. var otnModel = busSF_BINGRENQK.GetModel(custelid);
  458. if (otnModel != null)
  459. {
  460. if (!string.IsNullOrEmpty(blfl))
  461. {
  462. otnModel.BLFL = blfl;
  463. busSF_BINGRENQK.Update(otnModel);
  464. }
  465. //物业系统,客户档案信息是存储业主信息的,外呼不需要存储
  466. //int cusid = saveCus(otnModel.F_Phone, name, phone, countryid, address);
  467. int cusid = 0;
  468. #region 保存答案
  469. var ansModel = new Model.T_Call_OutAnswers();
  470. string askqids = "";
  471. string ansids = "";
  472. if (ans != null)
  473. {
  474. //先删除 后添加
  475. ansBLL.DeleteByTelid(custelid, taskid);
  476. ansModel.F_TaskID = taskid;
  477. ansModel.F_CusTelID = custelid;
  478. ansModel.F_CusID = cusid;
  479. ansModel.F_OptBy = CurrentUser.UserData.F_UserId;
  480. ansModel.F_OptByName = CurrentUser.UserData.F_UserName;
  481. ansModel.F_OptOn = DateTime.Now;
  482. ansModel.F_Expand1 = countryid.ToString();
  483. ansModel.F_Expand3 = DateTime.Now.ToString("yyyyMMddHHmmssfff");
  484. #region 循环保存
  485. foreach (var item in ans)
  486. {
  487. var nn = 0;
  488. var ii = item.Split('_');
  489. ansModel.F_QID = int.Parse(ii[0]);
  490. askqids += ii[0] + ",";
  491. ansids += ii[1] + ",";
  492. if (ii[1].IndexOf('|') > 0)
  493. {
  494. var iii = ii[1].Trim('|').Split('|');
  495. var iia = ii[2].Trim('|').Split('|');
  496. for (int i = 0; i < iii.Length; i++)
  497. {
  498. ansModel.F_QIID = int.Parse(iii[i]);
  499. ansModel.F_Answer = iia[i];
  500. if (ansBLL.Add(ansModel) > 0)
  501. nn++;
  502. }
  503. if (nn == iii.Length)
  504. cc++;
  505. }
  506. else
  507. {
  508. ansModel.F_QIID = int.Parse(ii[1]);
  509. ansModel.F_Answer = ii[2];
  510. if (ansBLL.Add(ansModel) > 0)
  511. cc++;
  512. }
  513. }
  514. #endregion
  515. }
  516. #endregion
  517. #region 保存日志
  518. BLL.SF_Result busResult = new BLL.SF_Result();
  519. Model.SF_Result modelResult = busResult.GetModel(custelid.ToString());
  520. if (modelResult != null)
  521. {
  522. busResult.Delete(modelResult.F_Id);
  523. modelResult.F_SFNum += 1;
  524. modelResult.F_Remark += "<br/>上次满意度:" + modelResult.F_MYD;
  525. modelResult.F_Remark += "<br/>上次建议:" + modelResult.F_Advise;
  526. modelResult.F_Remark += "<br/>上次回访结果" + modelResult.F_Result;
  527. }
  528. else
  529. {
  530. modelResult = new Model.SF_Result();
  531. modelResult.F_SFNum = 1;
  532. }
  533. modelResult.F_Result = hjconfig.F_Name;
  534. modelResult.F_Id = custelid.ToString();
  535. modelResult.F_SFPersion = CurrentUser.UserData.F_UserName;
  536. modelResult.F_SFPersionId = CurrentUser.UserData.F_UserCode;
  537. modelResult.F_SFTime = DateTime.Now;
  538. modelResult.F_Advise = advise;
  539. modelResult.F_MYD = satisfied;
  540. modelResult.F_PagerID = pagerid.ToString();
  541. modelResult.F_Praise = praise;
  542. modelResult.F_Criticism = criticism;
  543. modelResult.F_State = 2;
  544. busResult.Add(modelResult);
  545. //planrecord(otnModel);
  546. #endregion
  547. }
  548. }
  549. if (ans != null)
  550. {
  551. if (cc == ans.Length)
  552. {
  553. //return Success("问卷答案提交成功!taskid=" + taskid + ",custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  554. return Success("问卷答案提交成功!custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  555. }
  556. else
  557. {
  558. ansBLL.DeleteByTelid(custelid, taskid);
  559. return Error("问卷答案提交失败!custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  560. }
  561. }
  562. else if (hjconfig.F_Name.Contains("正常"))
  563. {
  564. return Error("没有问卷答案提交");
  565. }
  566. else
  567. {
  568. return Success("提交成功!custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  569. }
  570. }
  571. #endregion
  572. #region 导出
  573. #endregion
  574. #region 获取随访结果详情
  575. //获取任务结果详情
  576. public ActionResult GetTaskTelInfo(int id = 0)
  577. {
  578. if (id <= 0)
  579. return Error("参数不正确");
  580. var model = mfBLL.GetModel(id);
  581. var paperid = 0;
  582. if (model != null)
  583. {
  584. var taskmodel = new Model.T_Med_FollowUp();
  585. #region 绑定任务和客户信息
  586. taskmodel.F_Id = model.F_Id;//号码id
  587. //taskmodel.F_TaskId = model.F_TaskId.Value;//任务id
  588. //taskmodel.F_HJJGId = model.F_HJJGId != null ? model.F_HJJGId.Value : 0;//呼叫结果id
  589. taskmodel.F_Satisfied = model.F_Satisfied;
  590. taskmodel.F_SFResult = model.F_SFResult;
  591. if (!string.IsNullOrWhiteSpace(model.F_Name))
  592. taskmodel.F_Name = model.F_Name;//客户姓名
  593. if (!string.IsNullOrWhiteSpace(model.F_Phone))
  594. taskmodel.F_Phone = model.F_Phone;//号码
  595. if (!string.IsNullOrWhiteSpace(model.F_Addr))
  596. taskmodel.F_Addr = model.F_Addr;//住址
  597. #endregion
  598. var anslist = ansBLL.GetModelList(" F_CusTelID=" + id + " ");//ansBLL.GetModelList(" F_TaskID=" + model.F_TaskId.Value + " and F_CusTelID=" + id + " ");
  599. //var tmodel = otBLL.GetModel(model.F_TaskId.Value);
  600. //if (tmodel != null)
  601. //{
  602. paperid = model.F_PagerID;
  603. #region 获取问卷试题信息以及答案
  604. var pmodel = pagerInfoBLL.GetModel(paperid);
  605. 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 ");
  606. var qilist = questionItemBLL.GetModelList(" F_QuestionId in (select F_QuestionId from T_Ask_PagerItems where F_PagerId=" + paperid + ") order by F_ItemId ");
  607. var newmodel = new
  608. {
  609. F_Title = pmodel.F_Title,
  610. F_Remark = pmodel.F_Remark,
  611. F_StartText = pmodel.F_StartText,
  612. F_EndText = pmodel.F_EndText,
  613. F_Questions = qlist.Select(q =>
  614. {
  615. var answers = "";
  616. var qalist = anslist.Where(al => al.F_QID.Value == q.F_QuestionId).ToList<Model.T_Call_OutAnswers>();
  617. if (qalist.Count > 0)
  618. {
  619. if (q.F_Type > 1)
  620. {
  621. foreach (var item in qalist)
  622. {
  623. answers += item.F_QIID + "|";
  624. }
  625. }
  626. else
  627. {
  628. answers = qalist[0].F_Answer;
  629. }
  630. }
  631. return new
  632. {
  633. quesid = q.F_QuestionId,
  634. questitle = q.F_Title,
  635. questype = q.F_Type,
  636. quescontent = q.F_Content,
  637. quesremark = q.F_Remark,
  638. quesanswers = answers.Trim('|'),
  639. quesitems = qilist.Where(qq => qq.F_QuestionId == q.F_QuestionId).Select(qi =>
  640. {
  641. return new
  642. {
  643. itemid = qi.F_ItemId,
  644. itemname = qi.F_ItemName,
  645. itemremark = qi.F_Remark,
  646. };
  647. })
  648. };
  649. })
  650. };
  651. #endregion
  652. //taskmodel.F_TaskName = tmodel.F_TaskName;//任务名称
  653. //taskmodel.F_TaskRemark = tmodel.F_TaskRemark;//任务备注
  654. var objy = new
  655. {
  656. taskModel = taskmodel,
  657. paperModel = newmodel
  658. };
  659. return Success("获取详情成功", objy);
  660. //}
  661. }
  662. return Error("获取详情失败");
  663. }
  664. #endregion
  665. #region 科室随访率统计
  666. //获取数据
  667. public ActionResult GetSFList(string stime,string etime)
  668. {
  669. if (Request.IsAuthenticated)
  670. {
  671. return Success("获取随访率成功", GetSFData(stime,etime));
  672. }
  673. return NoToken("未知错误,请重新登录");
  674. }
  675. private DataTable GetSFData(string stime, string etime)
  676. {
  677. string sql = "";
  678. if (stime != null && stime.Trim() != "")
  679. {
  680. sql += " and CONVERT(varchar ,CYRQ, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  681. }
  682. if (etime != null && etime.Trim() != "")
  683. {
  684. sql += " and CONVERT(varchar ,CYRQ, 120)<=CONVERT(varchar , '" + etime.Trim() + " 23:59:59', 120) ";
  685. }
  686. DataTable dt = new DataTable();
  687. dt.Columns.Add("科室");
  688. dt.Columns.Add("总量");
  689. dt.Columns.Add("随访量");
  690. dt.Columns.Add("随访率");
  691. dt.Columns.Add("rate", typeof(double));
  692. int zltotal = 0;
  693. int sfltotal = 0;
  694. var kslist = DbHelperSQL.Query("select distinct CYKS FROM SF_BINGRENQK").Tables[0];
  695. var tlist = DbHelperSQL.Query("select count(1) Num,CYKS FROM SF_BINGRENQK where BAH NOT LIKE '%[_]11' "+sql+" group by CYKS").Tables[0];
  696. var sflist = DbHelperSQL.Query("select CYKS,COUNT(1) Num from SF_BINGRENQK a,SF_Result b where a.BINGRENZYID=b.F_Id and b.F_Result='正常接通' and a.BAH NOT LIKE '%[_]11'" + sql + " group by CYKS").Tables[0];
  697. foreach (DataRow dr in kslist.Rows)
  698. {
  699. var drnew = dt.NewRow();
  700. var cyks = dr["CYKS"].ToString();
  701. //心胸外科,肿瘤科,肿瘤科病区,
  702. string paichuks = "肾病内科,感染性疾病科,肾病内科病区,肾病内科1,感染性疾病科病区,重症医学科(ICU)病区";
  703. if (paichuks.Contains(cyks))
  704. {
  705. //排除这几个科室
  706. continue;
  707. }
  708. drnew["科室"] = cyks;
  709. var zl = tlist.Select("CYKS='" + cyks + "'").FirstOrDefault()?.ItemArray[0].ToString() ?? "0";
  710. if (zl != "")
  711. {
  712. drnew["总量"] = zl;
  713. zltotal += Convert.ToInt32(zl);
  714. var sfl = sflist.Select("CYKS='" + cyks + "'").FirstOrDefault()?.ItemArray[1].ToString() ?? "0";
  715. drnew["随访量"] = sfl;
  716. sfltotal += Convert.ToInt32(sfl);
  717. if (zl == "0" && sfl == "0")
  718. {
  719. drnew["rate"] = 0.000001;
  720. drnew["随访率"] = "0%";
  721. }
  722. else
  723. {
  724. var Rate = Math.Round(double.Parse(sfl) * 100 / double.Parse(zl), 2);
  725. drnew["rate"] = Rate;
  726. drnew["随访率"] = Rate + "%";
  727. }
  728. }
  729. if (zl!= "0")
  730. {
  731. dt.Rows.Add(drnew);
  732. }
  733. }
  734. DataRow drlast = dt.NewRow();
  735. drlast["科室"] = "总计";
  736. drlast["总量"] = zltotal;
  737. drlast["随访量"] = sfltotal;
  738. drlast["随访率"] = "";
  739. drlast["rate"] = 0;
  740. dt.Rows.Add(drlast);
  741. var dtnew = dt.Select("1=1", "rate desc").CopyToDataTable();
  742. dtnew.Columns.Remove("rate");
  743. return dtnew;
  744. }
  745. /// <summary>
  746. /// 导出数据
  747. /// </summary>
  748. /// <returns></returns>
  749. public ActionResult ExportExcel(string stime,string etime)
  750. {
  751. ActionResult res = NoToken("未知错误,请重新登录");
  752. if (Request.IsAuthenticated)
  753. {
  754. NPOIHelper npoi = new NPOIHelper();
  755. DataTable dt = GetSFData(stime,etime);
  756. dt.Columns.Add("序号").SetOrdinal(0);
  757. for (int i = 0; i < dt.Rows.Count; i++)
  758. {
  759. dt.Rows[i]["序号"] = i + 1;
  760. }
  761. if (npoi.ExportToExcel("科室随访率数据", dt) == "")
  762. {
  763. return Success("导出成功");
  764. }
  765. else
  766. {
  767. return Error("导出失败");
  768. }
  769. }
  770. return res;
  771. }
  772. //获取图形数据
  773. public ActionResult GetSFChartData()
  774. {
  775. ActionResult res = NoToken("未知错误,请重新登录");
  776. if (Request.IsAuthenticated)
  777. {
  778. var kslist = DbHelperSQL.Query("select distinct CYKS FROM SF_BINGRENQK").Tables[0];
  779. var tlist = DbHelperSQL.Query("select count(1) Num,CYKS FROM SF_BINGRENQK group by CYKS").Tables[0];
  780. var sflist = DbHelperSQL.Query("select CYKS,COUNT(1) Num from SF_BINGRENQK a,SF_Result b where a.BINGRENZYID=b.F_Id and b.F_Result='正常接通' group by CYKS").Tables[0];
  781. var ksc = kslist.Rows.Count;
  782. Dictionary<string, double> dics = new Dictionary<string, double>();
  783. for (int i = 0; i < ksc; i++)
  784. {
  785. var cyks = kslist.Rows[i]["CYKS"].ToString();
  786. var zl = tlist.Select("CYKS='" + cyks + "'").FirstOrDefault()?.ItemArray[0].ToString() ?? "";
  787. if (zl != "")
  788. {
  789. var sfl = sflist.Select("CYKS='" + cyks + "'").FirstOrDefault()?.ItemArray[1].ToString() ?? "0";
  790. var Rate = Math.Round(double.Parse(sfl) * 100 / double.Parse(zl), 2);
  791. dics.Add(cyks, Rate);
  792. }
  793. }
  794. dics = dics.OrderByDescending(p => p.Value).ToDictionary(p => p.Key, p => p.Value);
  795. var obj = new
  796. {
  797. ks = dics.Keys,
  798. rate = dics.Values
  799. };
  800. res = Success("获取科室随访数据成功", obj);
  801. }
  802. return res;
  803. }
  804. #endregion
  805. #region 满意度
  806. public ActionResult GetMYDList(string stime,string etime)
  807. {
  808. if (Request.IsAuthenticated)
  809. {
  810. return Success("获取满意度成功", GetDataMYD(stime,etime));
  811. }
  812. return NoToken("未知错误,请重新登录");
  813. }
  814. private DataTable GetDataMYD(string stime, string etime)
  815. {
  816. DataTable dt = new DataTable();
  817. dt.Columns.Add("科室");
  818. dt.Columns.Add("随访量");
  819. dt.Columns.Add("满意量");
  820. dt.Columns.Add("满意度");
  821. dt.Columns.Add("rate", typeof(double));
  822. string sql = "";
  823. if (stime != null && stime.Trim() != "")
  824. {
  825. sql += " and CONVERT(varchar ,CYRQ, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
  826. }
  827. if (etime != null && etime.Trim() != "")
  828. {
  829. sql += " and CONVERT(varchar ,CYRQ, 120)<=CONVERT(varchar , '" + etime.Trim() + " 23:59:59', 120) ";
  830. }
  831. var kslist = DbHelperSQL.Query("select distinct CYKS FROM SF_BINGRENQK").Tables[0];
  832. var myd = DbHelperSQL.Query("select distinct a.CYKS,COUNT(b.F_MYD) from SF_BINGRENQK a,SF_Result b where a.BINGRENZYID=b.F_Id and b.F_Result='正常接通' and b.F_MYD='满意' and a.BAH NOT LIKE '%[_]11' " + sql +" group by a.CYKS ").Tables[0];
  833. var sflist = DbHelperSQL.Query("select CYKS,COUNT(1) Num from SF_BINGRENQK a,SF_Result b where a.BINGRENZYID=b.F_Id and b.F_Result='正常接通' and a.BAH NOT LIKE '%[_]11' " + sql + "group by CYKS").Tables[0];
  834. int sfltotal = 0;
  835. int myltotal = 0;
  836. foreach (DataRow dr in kslist.Rows)
  837. {
  838. var drnew = dt.NewRow();
  839. var cyks = dr["CYKS"].ToString();
  840. //心胸外科,肿瘤科,肿瘤科病区,
  841. string paichuks = "肾病内科,感染性疾病科,肾病内科病区,肾病内科1,感染性疾病科病区,重症医学科(ICU)病区";
  842. if (paichuks.Contains(cyks))
  843. {
  844. //排除这几个科室
  845. continue;
  846. }
  847. drnew["科室"] = cyks;
  848. var zl = sflist.Select("CYKS='" + cyks + "'").FirstOrDefault()?.ItemArray[1].ToString() ?? "0";
  849. if (zl != "")
  850. {
  851. drnew["随访量"] = zl;
  852. sfltotal += Convert.ToInt32(zl);
  853. var sfl = sflist.Select("CYKS='" + cyks + "'").FirstOrDefault()?.ItemArray[1].ToString() ?? "0";
  854. var my = myd.Select("CYKS='" + cyks + "'").FirstOrDefault()?.ItemArray[1].ToString() ?? "0";
  855. drnew["满意量"] = my;
  856. myltotal += Convert.ToInt32(my);
  857. if (my == "0" && sfl == "0")
  858. {
  859. drnew["rate"] = 0.0000001;
  860. drnew["满意度"] = "0%";
  861. }
  862. else
  863. {
  864. var Rate = Math.Round(double.Parse(my) * 100 / double.Parse(sfl), 2);
  865. drnew["rate"] = Rate;
  866. drnew["满意度"] = Rate + "%";
  867. }
  868. }
  869. if (zl != "0")
  870. {
  871. dt.Rows.Add(drnew);
  872. }
  873. }
  874. var drlast= dt.NewRow();
  875. drlast["科室"] = "总计";
  876. drlast["随访量"] = sfltotal;
  877. drlast["满意量"] = myltotal;
  878. drlast["rate"] = 0;
  879. drlast["满意度"] = "";
  880. dt.Rows.Add(drlast);
  881. var dtnew = dt.Select("1=1", "rate desc").CopyToDataTable();
  882. dtnew.Columns.Remove("rate");
  883. return dtnew;
  884. }
  885. /// <summary>
  886. /// 导出
  887. /// </summary>
  888. public ActionResult ExportExcelMYD(string stime,string etime)
  889. {
  890. ActionResult res = NoToken("未知错误,请重新登录");
  891. if (Request.IsAuthenticated)
  892. {
  893. NPOIHelper npoi = new NPOIHelper();
  894. DataTable dt = GetDataMYD(stime,etime);
  895. dt.Columns.Add("序号").SetOrdinal(0);
  896. for (int i = 0; i < dt.Rows.Count; i++)
  897. {
  898. dt.Rows[i]["序号"] = i + 1;
  899. }
  900. if (npoi.ExportToExcel("满意度数据", dt) == "")
  901. {
  902. return Success("导出成功");
  903. }
  904. else
  905. {
  906. return Error("导出失败");
  907. }
  908. }
  909. return res;
  910. }
  911. //获取图形数据
  912. public ActionResult GetMYDData(string mydys)
  913. {
  914. ActionResult res = NoToken("未知错误,请重新登录");
  915. if (Request.IsAuthenticated)
  916. {
  917. var kslist = DbHelperSQL.Query("select distinct CYKS FROM SF_BINGRENQK").Tables[0];
  918. var myd = DbHelperSQL.Query("select distinct a.CYKS,COUNT(b.F_MYD) from SF_BINGRENQK a,SF_Result b where a.BINGRENZYID=b.F_Id and b.F_Result='正常接通' and b.F_MYD='满意' group by a.CYKS ").Tables[0];
  919. var sflist = DbHelperSQL.Query("select CYKS,COUNT(1) Num from SF_BINGRENQK a,SF_Result b where a.BINGRENZYID=b.F_Id and b.F_Result='正常接通' group by CYKS").Tables[0];
  920. Dictionary<string, double> dics = new Dictionary<string, double>();
  921. for (int i = 0; i < kslist.Rows.Count; i++)
  922. {
  923. var cyks = kslist.Rows[i]["CYKS"].ToString();
  924. var sfl = sflist.Select("CYKS='" + cyks + "'").FirstOrDefault()?.ItemArray[1].ToString() ?? "";
  925. if (sfl != "")
  926. {
  927. var my = myd.Select("CYKS='" + cyks + "'").FirstOrDefault()?.ItemArray[1].ToString() ?? "0";
  928. var Rate = Math.Round(double.Parse(my) * 100 / double.Parse(sfl), 2);
  929. dics.Add(cyks, Rate);
  930. }
  931. }
  932. dics = dics.OrderByDescending(p => p.Value).ToDictionary(p => p.Key, p => p.Value);
  933. var obj = new
  934. {
  935. ks = dics.Keys,
  936. rate = dics.Values
  937. };
  938. res = Success("获取满意度数据成功", obj);
  939. }
  940. return res;
  941. }
  942. #endregion
  943. #region
  944. // 病人信息加随访登记相关内容
  945. public ActionResult CreateTask(string taskname,string sdate,string edate,string ryks)
  946. {
  947. int userId = CurrentUser.UserData.F_UserId;
  948. string sql = "";
  949. if (sdate != null && edate != null)
  950. {
  951. sql += " RYRQ BETWEEN '" + sdate + "' and '" + edate + "' ";
  952. }
  953. if (ryks.Trim() != "" && ryks != "undefined")
  954. {
  955. sql += " and RYKS = '" + ryks + "'";
  956. }
  957. DataTable dt = DbHelperSQL.Query(" select BINGRENZYID from SF_BINGRENQK where" + sql).Tables[0] ;
  958. // var modellist = new BLL.SF_BINGRENQK().DataTableToList(ds.Tables[0]);
  959. if (dt.Rows.Count == 0) {
  960. return Error("创建任务失败,没有符合条件的数据");
  961. }
  962. //创建一个task
  963. var sfTaskModel = new Model.SF_Task();
  964. sfTaskModel.taskName = taskname;
  965. sfTaskModel.createTime = DateTime.Now;
  966. sfTaskModel.createBy = userId;
  967. int n= taskBLL.Add(sfTaskModel);
  968. foreach (DataRow item in dt.Rows)
  969. {
  970. var sftaskdetailModel = new Model.SF_TaskDetail();
  971. sftaskdetailModel.taskID = n;
  972. sftaskdetailModel.BINGRENZYID = item["BINGRENZYID"].ToString();
  973. sftaskdetailModel.sfstate = "未随访";
  974. taskDetailBLL.Add(sftaskdetailModel);
  975. }
  976. return Success("创建成功");
  977. }
  978. #endregion
  979. /// <summary>
  980. /// 获取任务列表
  981. /// </summary>
  982. /// <returns></returns>
  983. public ActionResult GetTaskList(string taskname,string sdate,string edate)
  984. {
  985. string strpageindex = RequestString.GetQueryString("page");
  986. int pageindex = 1;
  987. string strpagesize = RequestString.GetQueryString("pagesize");
  988. int pagesize = 10;
  989. if (strpageindex.Trim() != "")
  990. {
  991. pageindex = Convert.ToInt32(strpageindex);
  992. }
  993. if (strpagesize.Trim() != "")
  994. {
  995. pagesize = Convert.ToInt32(strpagesize);
  996. }
  997. string sql = "";
  998. if (taskname.Trim() != "" && taskname != "undefined")
  999. {
  1000. sql += " and taskname like '%" + taskname + "%'";
  1001. }
  1002. int recordCount = 0;
  1003. DataTable dt = new DataTable();
  1004. dt = BLL.PagerBLL.GetListPager(
  1005. "SF_Task",
  1006. "SF_Task.ID",
  1007. "*",
  1008. sql,
  1009. "ORDER BY createTime desc",
  1010. pagesize,
  1011. pageindex,
  1012. true,
  1013. out recordCount);
  1014. var obj = new
  1015. {
  1016. state = "success",
  1017. message = "成功",
  1018. rows = dt,
  1019. total = recordCount
  1020. };
  1021. return Content(obj.ToJson());
  1022. }
  1023. /// <summary>
  1024. /// 根据taskid 读任务中的病人id 与病人信息表连接查询
  1025. /// </summary>
  1026. /// <param name="taskID"></param>
  1027. /// <returns></returns>
  1028. public ActionResult GetDetailListByTaskID(int taskID,string sfstate)
  1029. {
  1030. string sql = "";
  1031. if (!string.IsNullOrEmpty(sfstate))
  1032. {
  1033. sql += " sfstate='"+ sfstate + "'";
  1034. }
  1035. if (taskID!=0)
  1036. {
  1037. sql += " and taskID='" + taskID + "'";
  1038. }
  1039. var task = new BLL.SF_Task().GetModel(taskID);
  1040. if (task == null)
  1041. {
  1042. return Error("任务ID不存在");
  1043. }
  1044. string strpageindex = RequestString.GetQueryString("page");
  1045. int pageindex = 1;
  1046. string strpagesize = RequestString.GetQueryString("pagesize");
  1047. int pagesize = 10;
  1048. int count = 0;
  1049. if (strpageindex.Trim() != "")
  1050. {
  1051. pageindex = Convert.ToInt32(strpageindex);
  1052. }
  1053. if (strpagesize.Trim() != "")
  1054. {
  1055. pagesize = Convert.ToInt32(strpagesize);
  1056. }
  1057. DataTable dt = new BLL.SF_TaskDetail().GetALLList(sql, "", (pageindex - 1) * pagesize +1, pagesize * pageindex, out count);
  1058. var obj = new
  1059. {
  1060. state = "success",
  1061. message = "成功",
  1062. rows = dt,
  1063. total = count
  1064. };
  1065. return Content(obj.ToJson());
  1066. }
  1067. #region 病人信息中的问卷回答
  1068. /// <summary>
  1069. ///
  1070. /// </summary>
  1071. /// <param name="taskid">任务ID</param>
  1072. /// <param name="custelid">客户电话ID</param> bingrenzyid
  1073. /// <param name="ans">答案,数组形式["15_20_单选选项内容","17_25|36|58_复选选项内容1|选项内容2|选项内容3","30_0_问答题"]</param>
  1074. /// <param name="hjjgid">呼叫结果</param>
  1075. /// <param name="telphone">电话号码</param>
  1076. /// <param name="name">姓名</param>
  1077. /// <param name="phone">固定号码</param>
  1078. /// <param name="countryid">乡镇id</param>
  1079. /// <param name="address">地址</param>
  1080. /// <returns></returns>
  1081. public ActionResult Answersnew(int taskid, string custelid, string[] ans, int hjjgid,
  1082. string name, string phone, string address, string advise, string satisfied, string praise, string criticism, string blfl, int pagerid = 0, int countryid = 0)
  1083. {
  1084. int cc = 0;
  1085. var hjconfig = new BLL.T_Sys_DictionaryValue().GetModel(hjjgid);
  1086. if (hjconfig == null)
  1087. {
  1088. return Error("提交结果配置不正常");
  1089. }
  1090. if (!string.IsNullOrEmpty(custelid))
  1091. {
  1092. var otnModel = busSF_BINGRENQK.GetModel(custelid);
  1093. if (otnModel != null)
  1094. {
  1095. if (!string.IsNullOrEmpty(blfl))
  1096. {
  1097. otnModel.BLFL = blfl;
  1098. // busSF_BINGRENQK.Update(otnModel);
  1099. }
  1100. //物业系统,客户档案信息是存储业主信息的,外呼不需要存储
  1101. //int cusid = saveCus(otnModel.F_Phone, name, phone, countryid, address);
  1102. int cusid = 0;
  1103. #region 保存答案
  1104. var ansModel = new Model.SF_TaskAnswers();
  1105. string askqids = "";
  1106. string ansids = "";
  1107. if (ans != null)
  1108. {
  1109. //先删除 后添加
  1110. // ansnewBLL.DeleteByTelid(custelid, taskid);
  1111. ansModel.F_TaskID = taskid;
  1112. ansModel.F_CusTelID = custelid;
  1113. ansModel.F_CusID = cusid;
  1114. ansModel.F_OptBy = CurrentUser.UserData.F_UserId;
  1115. ansModel.F_OptByName = CurrentUser.UserData.F_UserName;
  1116. ansModel.F_OptOn = DateTime.Now;
  1117. ansModel.F_Expand1 = countryid.ToString();
  1118. ansModel.F_Expand3 = DateTime.Now.ToString("yyyyMMddHHmmssfff");
  1119. #region 循环保存
  1120. foreach (var item in ans)
  1121. {
  1122. var nn = 0;
  1123. var ii = item.Split('_');
  1124. ansModel.F_QID = int.Parse(ii[0]);
  1125. askqids += ii[0] + ",";
  1126. ansids += ii[1] + ",";
  1127. if (ii[1].IndexOf('|') > 0)
  1128. {
  1129. var iii = ii[1].Trim('|').Split('|');
  1130. var iia = ii[2].Trim('|').Split('|');
  1131. for (int i = 0; i < iii.Length; i++)
  1132. {
  1133. ansModel.F_QIID = int.Parse(iii[i]);
  1134. ansModel.F_Answer = iia[i];
  1135. if (ansnewBLL.Add(ansModel) > 0)
  1136. nn++;
  1137. }
  1138. if (nn == iii.Length)
  1139. cc++;
  1140. }
  1141. else
  1142. {
  1143. ansModel.F_QIID = int.Parse(ii[1]);
  1144. ansModel.F_Answer = ii[2];
  1145. if (ansnewBLL.Add(ansModel) > 0)
  1146. cc++;
  1147. }
  1148. }
  1149. #endregion
  1150. }
  1151. #endregion
  1152. #region 保存日志
  1153. BLL.SF_TaskResult busResult = new BLL.SF_TaskResult();
  1154. Model.SF_TaskResult modelResult = busResult.GetModel(custelid.ToString());
  1155. if (modelResult != null)
  1156. {
  1157. busResult.Delete(modelResult.F_Id);
  1158. modelResult.F_SFNum += 1;
  1159. modelResult.F_Remark += "<br/>上次满意度:" + modelResult.F_MYD;
  1160. modelResult.F_Remark += "<br/>上次建议:" + modelResult.F_Advise;
  1161. modelResult.F_Remark += "<br/>上次回访结果" + modelResult.F_Result;
  1162. }
  1163. else
  1164. {
  1165. modelResult = new Model.SF_TaskResult();
  1166. modelResult.F_SFNum = 1;
  1167. }
  1168. modelResult.F_Result = hjconfig.F_Name;
  1169. modelResult.F_Id = custelid.ToString();
  1170. modelResult.F_SFPersion = CurrentUser.UserData.F_UserName;
  1171. modelResult.F_SFPersionId = CurrentUser.UserData.F_UserCode;
  1172. modelResult.F_SFTime = DateTime.Now;
  1173. modelResult.F_Advise = advise;
  1174. modelResult.F_MYD = satisfied;
  1175. modelResult.F_PagerID = pagerid.ToString();
  1176. modelResult.F_Praise = praise;
  1177. modelResult.F_Criticism = criticism;
  1178. modelResult.F_State = 2;
  1179. modelResult.F_TaskID = taskid;
  1180. busResult.Add(modelResult);
  1181. //planrecord(otnModel);
  1182. //修改taskdetail的值
  1183. Model.SF_TaskDetail model = taskDetailBLL.GetModelByTaskIdAndBingrenzyID(taskid, custelid);
  1184. if (model != null)
  1185. {
  1186. model.sfstate = "已随访";
  1187. taskDetailBLL.Update(model);
  1188. }
  1189. #endregion
  1190. }
  1191. }
  1192. if (ans != null)
  1193. {
  1194. if (cc == ans.Length)
  1195. {
  1196. //return Success("问卷答案提交成功!taskid=" + taskid + ",custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  1197. return Success("问卷答案提交成功!custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  1198. }
  1199. else
  1200. {
  1201. ansBLL.DeleteByTelid(custelid, taskid);
  1202. return Error("问卷答案提交失败!custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  1203. }
  1204. }
  1205. else if (hjconfig.F_Name.Contains("正常"))
  1206. {
  1207. return Error("没有问卷答案提交");
  1208. }
  1209. else
  1210. {
  1211. return Success("提交成功!custelid=" + custelid + ",操作人:" + CurrentUser.UserData.F_UserCode);
  1212. }
  1213. }
  1214. #endregion
  1215. public ActionResult GetListByIdNew(string id)
  1216. {
  1217. // int idint = Convert.ToInt32(id);
  1218. DataTable dt = new DataTable();
  1219. dt = taskDetailBLL.GetALLListById(" T1.BINGRENZYID='" + id+"'", "", 0, 1);
  1220. var obj = new
  1221. {
  1222. state = "success",
  1223. message = "成功",
  1224. rows = dt,
  1225. total = 1
  1226. };
  1227. return Content(obj.ToJson());
  1228. }
  1229. }
  1230. }