StatisticsController.java 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  1. package com.yihu.wlyy.web.statistic;
  2. import com.yihu.wlyy.entity.statistics.PopulationBase;
  3. import com.yihu.wlyy.service.app.statistics.StatisticsAllService;
  4. import com.yihu.wlyy.service.app.statistics.StatisticsService;
  5. import com.yihu.wlyy.util.ValueComparator;
  6. import com.yihu.wlyy.web.BaseController;
  7. import io.swagger.annotations.Api;
  8. import org.apache.commons.lang3.StringUtils;
  9. import org.json.JSONArray;
  10. import org.json.JSONObject;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.data.redis.core.StringRedisTemplate;
  13. import org.springframework.http.MediaType;
  14. import org.springframework.stereotype.Controller;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestMethod;
  17. import org.springframework.web.bind.annotation.RequestParam;
  18. import org.springframework.web.bind.annotation.ResponseBody;
  19. import java.util.*;
  20. /**
  21. * Created by lyr on 2016/08/16.
  22. */
  23. @Controller
  24. @RequestMapping(value = "/statistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  25. @Api(description = "统计")
  26. public class StatisticsController extends BaseController {
  27. @Autowired
  28. StatisticsService statisticsService;
  29. @Autowired
  30. StatisticsAllService statisticsAllService;
  31. /**
  32. * 获取统计时间
  33. *
  34. * @return
  35. */
  36. @RequestMapping(value = "/time")
  37. @ResponseBody
  38. public String getStatisticsTime() {
  39. try {
  40. return write(200, "查询成功", "data", statisticsService.getStatisticsTime());
  41. } catch (Exception e) {
  42. return error(-1, "查询失败");
  43. }
  44. }
  45. /**
  46. * 指标按间隔统计
  47. *
  48. * @param startDate 起始日期
  49. * @param endDate 结束时间
  50. * @param interval 时间间隔
  51. * @param area 区域或机构
  52. * @param level 级别
  53. * @param index 指标
  54. * @return
  55. */
  56. @RequestMapping(value = "/interval")
  57. @ResponseBody
  58. public String indexInterval(@RequestParam(required = true) String startDate,
  59. @RequestParam(required = true) String endDate,
  60. @RequestParam(required = true) int interval,
  61. @RequestParam(required = true) String area,
  62. @RequestParam(required = true) int level,
  63. @RequestParam(required = true) String index,
  64. @RequestParam(required = false) String level2_type) {
  65. String tag = "";
  66. try {
  67. String[] indexes = index.split(",");
  68. JSONObject result = new JSONObject();
  69. if (index != null) {
  70. for (String idx : indexes) {
  71. result.put("index_" + idx, statisticsService.getDateIncrementDetail(startDate, endDate, interval, area, level, idx, level2_type));
  72. }
  73. }
  74. return write(200, "查询成功!", "data", result);
  75. } catch (Exception e) {
  76. return error(-1, tag + "查询失败!");
  77. }
  78. }
  79. /**
  80. * 指标期间增长量
  81. *
  82. * @param startDate
  83. * @param endDate
  84. * @param area
  85. * @param level
  86. * @param index
  87. * @return
  88. */
  89. @RequestMapping("/increment")
  90. @ResponseBody
  91. public String getIndexIncrement(@RequestParam(required = true) String startDate,
  92. @RequestParam(required = true) String endDate,
  93. @RequestParam(required = true) String area,
  94. @RequestParam(required = true) int level,
  95. @RequestParam(required = true) String index) {
  96. try {
  97. String[] indexes = index.split(",");
  98. JSONObject result = new JSONObject();
  99. for (String idx : indexes) {
  100. result.put("index_" + idx, statisticsService.getIntervalIncrement(startDate, endDate, area, level, idx));
  101. }
  102. return write(200, "查询成功", "data", result);
  103. } catch (Exception e) {
  104. e.printStackTrace();
  105. return error(-1, "查询失败");
  106. }
  107. }
  108. /**
  109. * 指标截止日期累积量
  110. *
  111. * @param endDate 结束时间
  112. * @param area 父code
  113. * @param level 等级 1 团队,2 机构,3 区,4 市
  114. * @param index 指标代码
  115. * @param level2_type 指标代码 例如性别 1 男 2 女 不传就返回男和女的总和
  116. * @return
  117. */
  118. @RequestMapping("/total")
  119. @ResponseBody
  120. public String getIndexTotal(@RequestParam(required = true) String endDate,
  121. @RequestParam(required = true) String area,
  122. @RequestParam(required = true) int level,
  123. @RequestParam(required = true) String index,
  124. @RequestParam(required = false) String level2_type) {
  125. try {
  126. String[] indexes = index.split(",");
  127. JSONObject result = new JSONObject();
  128. for (String idx : indexes) {
  129. result.put("index_" + idx, statisticsService.getTotalAmount(endDate, area, level, idx, level2_type));
  130. }
  131. return write(200, "查询成功", "data", result);
  132. } catch (Exception e) {
  133. return error(-1, "查询失败");
  134. }
  135. }
  136. /**
  137. * 指标期间增长量
  138. *
  139. * @param startDate
  140. * @param endDate
  141. * @param area
  142. * @param level
  143. * @param index
  144. * @return
  145. */
  146. @RequestMapping("/lowlevel_increment")
  147. @ResponseBody
  148. public String getIndexLowLevelIncrement(@RequestParam(required = true) String startDate,
  149. @RequestParam(required = true) String endDate,
  150. @RequestParam(required = true) String area,
  151. @RequestParam(required = true) int level,
  152. @RequestParam(required = true) String index,
  153. @RequestParam(required = true) int sort,
  154. @RequestParam(required = false) String lowLevel) {
  155. try {
  156. String[] indexes = index.split(",");
  157. JSONObject result = new JSONObject();
  158. for (String idx : indexes) {
  159. result.put("index_" + idx, statisticsService.getLowLevelIncrementDetail(startDate, endDate, area, level, idx, sort, lowLevel));
  160. }
  161. return write(200, "查询成功", "data", result);
  162. } catch (Exception e) {
  163. e.printStackTrace();
  164. return error(-1, "查询失败");
  165. }
  166. }
  167. /**
  168. * 指标截止日期增量
  169. * (如:待预约量)
  170. * @param endDate 结束时间
  171. * @param area 父code
  172. * @param level 等级 1 团队,2 机构,3 区,4 市
  173. * @param index 指标代码
  174. * @param sort 排序 1倒叙 2是 正序
  175. * @param lowLevel
  176. * @param level2_type 指标代码 例如性别 1 男 2 女 不传就返回男和女的总和
  177. * @return
  178. */
  179. @RequestMapping("/lowlevel_total")
  180. @ResponseBody
  181. public String getIndexLowLevelTotal(@RequestParam(required = true) String endDate,
  182. @RequestParam(required = true) String area,
  183. @RequestParam(required = true) int level,
  184. @RequestParam(required = true) String index,
  185. @RequestParam(required = true) int sort,
  186. @RequestParam(required = false) String lowLevel,
  187. @RequestParam(required = false) String level2_type) {
  188. try {
  189. String[] indexes = index.split(",");
  190. JSONObject result = new JSONObject();
  191. for (String idx : indexes) {
  192. result.put("index_" + idx, statisticsService.getLowLevelTotalDetail(endDate, area, level, idx, sort, lowLevel, level2_type));
  193. }
  194. return write(200, "查询成功", "data", result);
  195. } catch (Exception e) {
  196. return error(-1, "查询失败");
  197. }
  198. }
  199. /**
  200. * 指标截止日期累积量
  201. * 根据2个ID合并指标
  202. *
  203. * @param endDate
  204. * @param area
  205. * @param level
  206. * @param index
  207. * @return
  208. */
  209. @RequestMapping("/lowlevel_total_mesh")
  210. @ResponseBody
  211. public String getIndexLowLevelTotalMesh(@RequestParam(required = true) String endDate, // 2007-10-02
  212. @RequestParam(required = true) String area,//区域 350205
  213. @RequestParam(required = true) int level,//等级
  214. @RequestParam(required = true) String index,//指标code
  215. @RequestParam(required = true) int sort,//1是倒叙 0是正序
  216. @RequestParam(required = false) String lowLevel) {
  217. try {
  218. String[] indexes = index.split(",");
  219. JSONObject result = new JSONObject();
  220. JSONArray returnJa = new JSONArray();
  221. List<JSONArray> jsonArrays = new ArrayList<>();
  222. JSONArray jsonArray1 = statisticsService.getLowLevelTotalDetail(endDate, area, level, indexes[0], sort, lowLevel, null);
  223. jsonArrays.add(jsonArray1);
  224. JSONArray jsonArray2 = statisticsService.getLowLevelIncrementDetail(endDate, endDate, area, level, indexes[1], sort, lowLevel);
  225. jsonArrays.add(jsonArray2);
  226. //遍历合并2个指标中key值一样的
  227. if (jsonArrays.get(1).length() == 0) {
  228. //如果只有一个指标的时候 另外一个指标默认是0
  229. for (int i = 0; i < jsonArrays.get(0).length(); i++) {
  230. //未回复咨询不存在的时候默认是0
  231. JSONObject map1 = jsonArrays.get(0).getJSONObject(i);
  232. String amount = map1.get("amount").toString() + ",0";
  233. map1.put("amount", amount);
  234. returnJa.put(map1);
  235. }
  236. } else {
  237. //如果是2个指标的时候,分别放入map中,以减少查询次数
  238. Map<String,JSONObject> in =new TreeMap<>();
  239. ValueComparator vc = new ValueComparator(in);
  240. Map<String,JSONObject> index2=new TreeMap<>();
  241. for (int i = 0; i < jsonArrays.get(0).length(); i++) {
  242. JSONObject map1 = jsonArrays.get(0).getJSONObject(i);
  243. in.put(map1.get("code").toString(),map1);
  244. }
  245. Map<String,JSONObject> index1 =new TreeMap<>(vc);
  246. index1.putAll(in);
  247. for (int i = 0; i < jsonArrays.get(1).length(); i++) {
  248. JSONObject map1 = jsonArrays.get(1).getJSONObject(i);
  249. index2.put(map1.get("code").toString(),map1);
  250. }
  251. for(Map.Entry<String , JSONObject> one:index1.entrySet()){
  252. JSONObject map1 = one.getValue();
  253. JSONObject map2 = index2.get(one.getKey());
  254. String amount = map1.get("amount").toString() + "," + map2.get("amount").toString();
  255. map1.put("amount", amount);
  256. returnJa.put(map1);
  257. }
  258. }
  259. if(level==2){
  260. statisticsAllService.translateTeamLeaderNameByCode(returnJa);
  261. }
  262. result.put("index_" + indexes[0], returnJa);
  263. return write(200, "查询成功", "data", result);
  264. } catch (
  265. Exception e
  266. )
  267. {
  268. e.printStackTrace();
  269. return error(-1, "查询失败");
  270. }
  271. }
  272. /**
  273. * 指标期间增长量
  274. *
  275. * @param startDate
  276. * @param endDate
  277. * @param area
  278. * @param level
  279. * @param index
  280. * @return
  281. */
  282. @RequestMapping("/leveltwo_increment")
  283. @ResponseBody
  284. public String getIndexLevelTwoIncrement(@RequestParam(required = false) String startDate,
  285. @RequestParam(required = true) String endDate,
  286. @RequestParam(required = true) String area,
  287. @RequestParam(required = true) int level,
  288. @RequestParam(required = true) String index) {
  289. try {
  290. String[] indexes = index.split(",");
  291. JSONObject result = new JSONObject();
  292. for (String idx : indexes) {
  293. result.put("index_" + idx, statisticsAllService.getIndexLevelTwototal(endDate, area, level, idx));
  294. }
  295. return write(200, "查询成功", "data", result);
  296. } catch (Exception e) {
  297. e.printStackTrace();
  298. return error(-1, "查询失败");
  299. }
  300. }
  301. /**
  302. * 获取签约率、签约完成率
  303. *
  304. * @param endDate 截止日期
  305. * @param area 区域
  306. * @param level 区域级别 4:城市 3:区 2:社区 1:团队
  307. * @return
  308. */
  309. @RequestMapping(value = "/sign_info")
  310. @ResponseBody
  311. public String getAreaSignInfo(@RequestParam(required = true) String endDate,
  312. @RequestParam(required = true) String area,
  313. @RequestParam(required = true) int level,
  314. @RequestParam(required = false) String lowCode) {
  315. try {
  316. JSONObject result = new JSONObject();
  317. if (StringUtils.isEmpty(lowCode)) {
  318. long sign = statisticsAllService.getIndexTotal(endDate, area, level, "13");
  319. long weiJf = statisticsAllService.getWeiJiaoFei(endDate, area, level);
  320. JSONObject signRate = statisticsAllService.getSignRate(endDate, area, level);
  321. JSONObject signTaskRate = statisticsAllService.getSignTaskRate(endDate, area, level);
  322. result.put("sign", sign);
  323. result.put("expenses", weiJf);
  324. result.put("signRate", signRate);
  325. result.put("signTaskRate", signTaskRate);
  326. } else {
  327. result = statisticsAllService.getGroupInfo(endDate, lowCode, area, level);
  328. }
  329. return write(200, "查询成功", "data", result);
  330. } catch (Exception e) {
  331. return error(-1, "查询失败");
  332. }
  333. }
  334. /**
  335. * 获取三级指标增量
  336. *
  337. * @param startDate
  338. * @param endDate
  339. * @param area
  340. * @param level
  341. * @return
  342. */
  343. @RequestMapping(value = "/sixfive_statistics")
  344. @ResponseBody
  345. public String getSixFiveStatistics(@RequestParam(required = false) String startDate,
  346. @RequestParam(required = true) String endDate,
  347. @RequestParam(required = true) String area, int level) {
  348. try {
  349. JSONArray result = statisticsAllService.getSixFiveStatistics(endDate, area, level);
  350. return write(200, "查询成功", "data", result);
  351. } catch (Exception e) {
  352. e.printStackTrace();
  353. return error(-1, "查询失败");
  354. }
  355. }
  356. /**
  357. * 指标按间隔统计
  358. *
  359. * @param startDate 起始日期
  360. * @param endDate 结束时间
  361. * @param interval 时间间隔
  362. * @param area 区域或机构
  363. * @param level 级别
  364. * @param index 指标
  365. * @return
  366. */
  367. @RequestMapping(value = "/interval_total")
  368. @ResponseBody
  369. public String indexIntervalTotal(@RequestParam(required = true) String startDate,
  370. @RequestParam(required = true) String endDate,
  371. @RequestParam(required = true) int interval,
  372. @RequestParam(required = true) String area,
  373. @RequestParam(required = true) int level,
  374. @RequestParam(required = true) String index,
  375. @RequestParam(required = false) String lowCode) {
  376. try {
  377. String[] indexes = index.split(",");
  378. JSONObject result = new JSONObject();
  379. if (index != null) {
  380. for (String idx : indexes) {
  381. result.put("index_" + idx, statisticsAllService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode));
  382. }
  383. }
  384. return write(200, "查询成功!", "data", result);
  385. } catch (Exception e) {
  386. return error(-1, "查询失败!");
  387. }
  388. }
  389. /**
  390. * 指标截止日期累积量
  391. *
  392. * @param date
  393. * @param area
  394. * @param level level1_type等级 1:团队 2社区机构 3区级 4市级
  395. * @param index quotoCode 18/19两率
  396. * @param sort 1降序排列-1升序排列
  397. * @return
  398. */
  399. @RequestMapping("/lowlevel_all")
  400. @ResponseBody
  401. public String getIndexLowLevelTotalSign(@RequestParam(required = true) String date,
  402. @RequestParam(required = true) String area,
  403. @RequestParam(required = true) int level,
  404. @RequestParam(required = true) String index,
  405. @RequestParam(required = true) int sort,
  406. @RequestParam(required = false) String lowLevel,
  407. @RequestParam(required = false) String lowCode,
  408. @RequestParam(required = false) String startDate) {
  409. try {
  410. String[] indexes = index.split(",");
  411. JSONObject result = new JSONObject();
  412. if (StringUtils.isNotEmpty(lowCode)) {
  413. // 指定level下特定查询级别
  414. if(index.equals("17")){
  415. result.put("index_" + index, statisticsAllService.getLevelTwoLowLevelTotalTeamLeader(date, area, level, index, sort, lowLevel, lowCode));
  416. }else{
  417. result.put("index_" + index, statisticsAllService.getLevelTwoLowLevelTotal(date, area, level, index, sort, lowLevel, lowCode));
  418. }
  419. } else {
  420. // 未指定level下特定查询级别
  421. for (String idx : indexes) {
  422. if (idx.equals("18") || index.equals("19")) {
  423. result.put("index_" + idx, statisticsAllService.getLowLevelTotalSpecial(date, area, level, idx, sort, lowLevel));
  424. } else if (idx.equals("1") || index.equals("21")) {
  425. result.put("index_" + idx, statisticsAllService.getLowLevelTotal2(date, area, level, idx, sort, lowLevel));
  426. } else if (idx.equals("28")){
  427. result.put("index_" + idx, statisticsService.getAvgAllInfo(level,area,lowLevel));
  428. } else if(idx.equals("13")){
  429. result.put("index_" + idx, statisticsAllService.getLowLevelTotalTeamLeader(date, area, level, idx, sort, lowLevel));
  430. }else{
  431. result.put("index_" + idx, statisticsAllService.getLowLevelTotal(date, area, level, idx, sort, lowLevel));
  432. }
  433. }
  434. }
  435. return write(200, "查询成功", "data", result);
  436. } catch (Exception e) {
  437. e.printStackTrace();
  438. return error(-1, "查询失败");
  439. }
  440. }
  441. /**
  442. * 获取三师转签或高危人群
  443. *
  444. * @param endDate
  445. * @param area
  446. * @param level
  447. * @return
  448. */
  449. @RequestMapping(value = "/sszq_qwrq_info")
  450. @ResponseBody
  451. public String getSszqAndGwrq(@RequestParam(required = true) String endDate,
  452. @RequestParam(required = true) String area,
  453. @RequestParam(required = true) int level) {
  454. try {
  455. JSONObject result = new JSONObject();
  456. JSONObject sszq = statisticsAllService.getSszqAndGwrq(endDate, area, level, "18");
  457. JSONObject gwrq = statisticsAllService.getSszqAndGwrq(endDate, area, level, "19");
  458. result.put("sszq", sszq);
  459. result.put("gwrq", gwrq);
  460. return write(200, "查询成功", "data", result);
  461. } catch (Exception e) {
  462. return error(-1, "查询失败");
  463. }
  464. }
  465. /**
  466. * 二级指标到达量
  467. *
  468. * @param date
  469. * @param area
  470. * @param level
  471. * @param index
  472. * @return
  473. */
  474. @RequestMapping(value = "/leveltwo_all")
  475. @ResponseBody
  476. public String getIndexLevelTwoTotal(@RequestParam(required = true) String date,
  477. @RequestParam(required = true) String area,
  478. @RequestParam(required = true) int level,
  479. @RequestParam(required = true) String index) {
  480. try {
  481. String[] indexes = index.split(",");
  482. JSONObject result = new JSONObject();
  483. for (String idx : indexes) {
  484. result.put("index_" + idx, statisticsAllService.getIndexLevelTwototal(date, area, level, idx));
  485. }
  486. return write(200, "查询成功", "data", result);
  487. } catch (Exception e) {
  488. e.printStackTrace();
  489. return error(-1, "查询失败");
  490. }
  491. }
  492. /**
  493. * 指标截止日期到达量
  494. *
  495. * @param endDate
  496. * @param area
  497. * @param level
  498. * @param index
  499. * @return
  500. */
  501. @RequestMapping("/index_all")
  502. @ResponseBody
  503. public String getIndexAll(@RequestParam(required = true) String endDate,
  504. @RequestParam(required = true) String area,
  505. @RequestParam(required = true) int level,
  506. @RequestParam(required = true) String index) {
  507. try {
  508. String[] indexes = index.split(",");
  509. JSONObject result = new JSONObject();
  510. for (String idx : indexes) {
  511. result.put("index_" + idx, statisticsAllService.getIndexTotal(endDate, area, level, idx));
  512. }
  513. return write(200, "查询成功", "data", result);
  514. } catch (Exception e) {
  515. return error(-1, "查询失败");
  516. }
  517. }
  518. /**
  519. * 咨询统计
  520. * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
  521. * ①回复及时率------医生首次回复24小时内比例
  522. * ②未回复数(数、率)----------当前未回复咨询数、以及相应比例
  523. * ③处理咨询回复时间分布---------全部咨询的首次回复咨询时间分布
  524. *
  525. * @param level 查询的等级,按市、区、机构
  526. * @param area 查询的等级对应Code
  527. * @return
  528. */
  529. @RequestMapping("/Consulting_Stat")
  530. @ResponseBody
  531. public String getConsultingStatistics(@RequestParam(required = true) Integer level,
  532. @RequestParam(required = true) String area) {
  533. try {
  534. return write(200, "查询成功", "data", statisticsService.getConsultingStatistics(level, area));
  535. } catch (Exception e) {
  536. return error(-1, "查询失败");
  537. }
  538. }
  539. /**
  540. * 咨询统计
  541. * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
  542. * ①回复及时率------医生首次回复24小时内比例
  543. * ②未回复数(数、率)----------当前未回复咨询数、以及相应比例
  544. * ③处理咨询回复时间分布---------全部咨询的首次回复咨询时间分布
  545. *
  546. * @param level 查询的等级,按市、区、机构
  547. * @return
  548. */
  549. @RequestMapping("/Consulting_StatList")
  550. @ResponseBody
  551. public String getConsultingStatisticsList(@RequestParam(required = true) Integer level,
  552. @RequestParam(required = true) String area,
  553. @RequestParam(required = false) String lowlevel) {
  554. try {
  555. JSONObject data = statisticsService.getConsultingStatisticsList(level, area, lowlevel);
  556. if (data != null) {
  557. return write(200, "查询成功", "data", data);
  558. } else {
  559. return error(-1, "查询失败");
  560. }
  561. } catch (Exception e) {
  562. return error(-1, "查询失败");
  563. }
  564. }
  565. /**
  566. * 咨询统计
  567. * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
  568. * ①回复及时率------医生首次回复24小时内比例
  569. * ②未回复数(数、率)----------当前未回复咨询数、以及相应比例
  570. * ③处理咨询回复时间分布---------全部咨询的首次回复咨询时间分布
  571. *
  572. * @param level 查询的等级,按市、区、机构
  573. * @return
  574. */
  575. @RequestMapping("/Consulting_Title")
  576. @ResponseBody
  577. public String getConsultingTitle(@RequestParam(required = true) Integer level,
  578. @RequestParam(required = true) String area) {
  579. try {
  580. JSONObject data = statisticsService.getConsultingTitle(level, area);
  581. if (data != null) {
  582. return write(200, "查询成功", "data", data);
  583. } else {
  584. return error(-1, "查询失败");
  585. }
  586. } catch (Exception e) {
  587. return error(-1, "查询失败");
  588. }
  589. }
  590. /**
  591. * 获取回复数时间分布数
  592. *
  593. * @param level
  594. * @param area
  595. * @return
  596. */
  597. @RequestMapping("/getCoutListByTime")
  598. @ResponseBody
  599. public String getCoutListByTime(@RequestParam(required = true) String level, @RequestParam(required = true) String area) {
  600. try {
  601. return write(200, "查询成功", "data", statisticsService.getCoutListByTime(level, area));
  602. } catch (Exception e) {
  603. return error(-1, "查询失败");
  604. }
  605. }
  606. /**
  607. * 获取绑定率
  608. * 1、选定绑定微信指标,下面排行内,在绑定微信数后新增:"绑定率:xx.22%"
  609. * 2、绑定率=绑定数/已签约数
  610. *
  611. * @return
  612. */
  613. @RequestMapping("/bindingRate_stat")
  614. @ResponseBody
  615. public String getBindingRate() {
  616. try {
  617. return write(200, "查询成功", "data", statisticsService.getBindingRate());
  618. } catch (Exception e) {
  619. return error(-1, "查询失败");
  620. }
  621. }
  622. /**
  623. * 获取得分平均数
  624. * @param level
  625. * @param area
  626. * @return
  627. */
  628. @RequestMapping("/getAVGSocre")
  629. @ResponseBody
  630. public String getAVGSocre(@RequestParam(required = true) String level, @RequestParam(required = true) String area) {
  631. try {
  632. return write(200, "查询成功", "data", statisticsService.getAVGSocre(level,area));
  633. } catch (Exception e) {
  634. return error(-1, "查询失败");
  635. }
  636. }
  637. /**
  638. * 获取得分平均数按月份
  639. * @return
  640. */
  641. @RequestMapping("/getAVGSocreByMonth")
  642. @ResponseBody
  643. public String getAVGSocreByMonth(@RequestParam(required = true)String level ,
  644. @RequestParam(required = true)String area,
  645. @RequestParam(required = true)String statDate,
  646. @RequestParam(required = true)String endDate){
  647. try {
  648. return write(200, "查询成功", "data", statisticsService.getAVGSocreByMonth(level,area,statDate,endDate));
  649. } catch (Exception e) {
  650. error(e);
  651. return error(-1, "查询失败");
  652. }
  653. }
  654. /**
  655. * 统计当前团队,签约人数,服务次数,平均满意度
  656. * @return
  657. */
  658. @RequestMapping("/getStatTitleInfo")
  659. @ResponseBody
  660. public String getStatTitleInfo(@RequestParam(required = true)String startDate,
  661. @RequestParam(required = true)String endDate){
  662. try {
  663. return write(200, "查询成功", "data", statisticsService.getStatTitleInfo(getUID(),startDate,endDate));
  664. //return write(200, "查询成功", "data", statisticsService.getStatTitleInfo("xh1D201703150222",startDate,endDate));
  665. } catch (Exception e) {
  666. error(e);
  667. return error(-1, "查询失败");
  668. }
  669. }
  670. /**
  671. * 获取签约折线图
  672. * @param startDate
  673. * @param endDate
  674. * @param signType 0 签约,1 续签
  675. * @param type 0 按周,1 按月
  676. * @return
  677. */
  678. @RequestMapping("/getSignCountLineByType")
  679. @ResponseBody
  680. public String getSignCountLineByType(@RequestParam(required = true)String startDate,
  681. @RequestParam(required = true)String endDate,
  682. @RequestParam(required = true)String signType,
  683. @RequestParam(required = true)String type){
  684. try {
  685. //判断是签约还是续签
  686. if("0".equals(signType)){
  687. return write(200, "查询成功", "data", statisticsService.getSignCountLineByType(getUID(),type,startDate,endDate));
  688. //return write(200, "查询成功", "data", statisticsService.getSignCountLineByType("xh1D201703150222",type,startDate,endDate));
  689. }else{
  690. return write(200, "查询成功", "data", statisticsService.getRenewCountLineByType(getUID(),type,startDate,endDate));
  691. //return write(200, "查询成功", "data", statisticsService.getRenewCountLineByType("xh1D201703150222",type,startDate,endDate));
  692. }
  693. } catch (Exception e) {
  694. error(e);
  695. return error(-1, "查询失败");
  696. }
  697. }
  698. /**
  699. * 获取咨询数和未回复数
  700. * @param startDate
  701. * @param endDate
  702. * @param isNow 1 为当前;2为非当前
  703. * @return
  704. */
  705. @RequestMapping("/getReyStatbyTeam")
  706. @ResponseBody
  707. public String getReyStatbyTeam(@RequestParam(required = true)String startDate,
  708. @RequestParam(required = true)String endDate,
  709. @RequestParam(required = true)String isNow){
  710. try {
  711. return write(200, "查询成功", "data", statisticsService.getReyStatbyTeam(getUID(),startDate,endDate,isNow));
  712. //return write(200, "查询成功", "data", statisticsService.getReyStatbyTeam("xh1D201703150222",startDate,endDate,isNow));
  713. } catch (Exception e) {
  714. error(e);
  715. return error(-1, "查询失败");
  716. }
  717. }
  718. /**
  719. * 获取机构内服务排行
  720. * @param startDate
  721. * @param endDate
  722. * @return
  723. */
  724. @RequestMapping("/getServiceRankingList")
  725. @ResponseBody
  726. public String getServiceRankingList(@RequestParam(required = true)String startDate,
  727. @RequestParam(required = true)String endDate){
  728. try {
  729. return write(200, "查询成功", "data", statisticsService.getServiceRankingList(getUID(),startDate,endDate));
  730. //return write(200, "查询成功", "data", statisticsService.getServiceRankingList("xh1D201703150222",startDate,endDate));
  731. } catch (Exception e) {
  732. error(e);
  733. return error(-1, "查询失败");
  734. }
  735. }
  736. /**
  737. * 获取平均值统计折线图
  738. * @param startDate
  739. * @param endDate
  740. * @param type 0周,1月
  741. * @return
  742. */
  743. @RequestMapping("/getAvgLine")
  744. @ResponseBody
  745. public String getAvgLine(@RequestParam(required = true)String startDate,
  746. @RequestParam(required = true)String endDate,
  747. @RequestParam(required = true)String type){
  748. try {
  749. return write(200, "查询成功", "data", statisticsService.getAvgLine(getUID(),startDate,endDate,type));
  750. // return write(200, "查询成功", "data", statisticsService.getAvgLine("xh1D201703150222",startDate,endDate,type));
  751. } catch (Exception e) {
  752. error(e);
  753. return error(-1, "查询失败");
  754. }
  755. }
  756. /**
  757. * 判断团队是否是团队长
  758. * @return
  759. */
  760. @RequestMapping("/checkDoctorIsTeamLeder")
  761. @ResponseBody
  762. public String checkDoctorIsTeamLeder(){
  763. try {
  764. return write(200, "查询成功", "data", statisticsService.checkDoctorIsTeamleader(getUID()));
  765. } catch (Exception e) {
  766. error(e);
  767. return error(-1, "查询失败");
  768. }
  769. }
  770. /**
  771. * 获取团队月或周咨询未回复和总数折线图
  772. * @param teamCode 团队id
  773. * @param startDate
  774. * @param endDate
  775. * @param type 0周,1月
  776. * @return
  777. */
  778. @RequestMapping("/getTeamConsultCount")
  779. @ResponseBody
  780. public String getTeamConsultCount(@RequestParam(required = true)String teamCode,
  781. @RequestParam(required = true)String startDate,
  782. @RequestParam(required = true)String endDate,
  783. @RequestParam(required = true)String type){
  784. try {
  785. return write(200, "查询成功", "data", statisticsService.getTeamConsultCount(teamCode,startDate,endDate,type));
  786. } catch (Exception e) {
  787. error(e);
  788. return error(-1, "查询失败");
  789. }
  790. }
  791. /**
  792. * 计算团队医生月或周咨询未回复和总数折线图
  793. * @param teamCode
  794. * @param startDate
  795. * @param endDate
  796. * @param type 0周,1月
  797. * @param doctor
  798. * @return
  799. */
  800. @RequestMapping("/getTeamDoctorConsultCount")
  801. @ResponseBody
  802. public String getTeamDoctorConsultCount(@RequestParam(required = true)String teamCode,
  803. @RequestParam(required = true)String startDate,
  804. @RequestParam(required = true)String endDate,
  805. @RequestParam(required = true)String type,
  806. @RequestParam(required = true)String doctor){
  807. try {
  808. return write(200, "查询成功", "data", statisticsService.getTeamDoctorConsultCount(teamCode,startDate,endDate,type,doctor));
  809. } catch (Exception e) {
  810. error(e);
  811. return error(-1, "查询失败");
  812. }
  813. }
  814. /**
  815. * 获取团队内这成员,未回复数,总数,结束咨询数
  816. * @param teamCode
  817. * @param startDate
  818. * @param endDate
  819. * @param sort 0降序,1升序
  820. * @return
  821. */
  822. @RequestMapping("/getMemberConsultList")
  823. @ResponseBody
  824. public String getMemberConsultList(@RequestParam(required = true)String teamCode,
  825. @RequestParam(required = true)String startDate,
  826. @RequestParam(required = true)String endDate,
  827. @RequestParam(required = true)String sort){
  828. try {
  829. return write(200, "查询成功", "data", statisticsService.getMemberConsultList(teamCode,startDate,endDate,sort));
  830. } catch (Exception e) {
  831. error(e);
  832. return error(-1, "查询失败");
  833. }
  834. }
  835. /**
  836. * 获取Doctor咨询结果
  837. * @param doctor
  838. * @param teamCode
  839. * @param startDate
  840. * @param endDate
  841. * @return
  842. */
  843. @RequestMapping("/getDoctorConsultTitle")
  844. @ResponseBody
  845. public String getDoctorConsultTitle(@RequestParam(required = true)String doctor,
  846. @RequestParam(required = true)String teamCode,
  847. @RequestParam(required = true)String startDate,
  848. @RequestParam(required = true)String endDate){
  849. try {
  850. return write(200, "查询成功", "data", statisticsService.getDoctorConsultTitle(doctor,teamCode,startDate,endDate));
  851. } catch (Exception e) {
  852. error(e);
  853. return error(-1, "查询失败");
  854. }
  855. }
  856. /**
  857. * 获取团队随访量折线统计图
  858. * @param type
  859. * @param teamCode
  860. * @param startDate
  861. * @param endDate
  862. * @return
  863. */
  864. @RequestMapping("/getTeamFollowupLine")
  865. @ResponseBody
  866. public String getTeamFollowupLine(@RequestParam(required = true)String type,
  867. @RequestParam(required = true)String teamCode,
  868. @RequestParam(required = true)String startDate,
  869. @RequestParam(required = true)String endDate){
  870. try {
  871. return write(200, "查询成功", "data", statisticsService.getTeamFollowupLine(teamCode,startDate,endDate,type));
  872. } catch (Exception e) {
  873. error(e);
  874. return error(-1, "查询失败");
  875. }
  876. }
  877. @RequestMapping("/getTeamDoctorFollowupLine")
  878. @ResponseBody
  879. public String getTeamDoctorFollowupLine(@RequestParam(required = true)String type,
  880. @RequestParam(required = true)String teamCode,
  881. @RequestParam(required = true)String startDate,
  882. @RequestParam(required = true)String endDate,
  883. @RequestParam(required = true)String doctor){
  884. try {
  885. return write(200, "查询成功", "data", statisticsService.getTeamDoctorFollowupLine(teamCode,startDate,endDate,type,doctor));
  886. } catch (Exception e) {
  887. error(e);
  888. return error(-1, "查询失败");
  889. }
  890. }
  891. }