StatisticsController.java 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460
  1. package com.yihu.wlyy.web.statistic;
  2. import com.yihu.wlyy.entity.statistics.PopulationBase;
  3. import com.yihu.wlyy.entity.statistics.WlyyQuotaResult;
  4. import com.yihu.wlyy.job.Constant;
  5. import com.yihu.wlyy.service.app.statistics.StatisticsAllService;
  6. import com.yihu.wlyy.service.app.statistics.StatisticsService;
  7. import com.yihu.wlyy.util.ValueComparator;
  8. import com.yihu.wlyy.web.BaseController;
  9. import io.swagger.annotations.Api;
  10. import org.apache.commons.lang3.StringUtils;
  11. import org.json.JSONArray;
  12. import org.json.JSONObject;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.http.MediaType;
  15. import org.springframework.stereotype.Controller;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RequestMethod;
  18. import org.springframework.web.bind.annotation.RequestParam;
  19. import org.springframework.web.bind.annotation.ResponseBody;
  20. import java.util.*;
  21. /**
  22. * Created by lyr on 2016/08/16.
  23. */
  24. @Controller
  25. @RequestMapping(value = "/statistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  26. @Api(description = "统计")
  27. public class StatisticsController extends BaseController {
  28. @Autowired
  29. StatisticsService statisticsService;
  30. @Autowired
  31. StatisticsAllService statisticsAllService;
  32. /**
  33. * 获取统计时间
  34. *
  35. * @return
  36. */
  37. @RequestMapping(value = "/time")
  38. @ResponseBody
  39. public String getStatisticsTime() {
  40. try {
  41. return write(200, "查询成功", "data", statisticsService.getStatisticsTime());
  42. } catch (Exception e) {
  43. return error(-1, "查询失败");
  44. }
  45. }
  46. /**
  47. * 指标按间隔统计 增量
  48. * 按年度统计是根据前端传的 startDate
  49. *
  50. * @param startDate 起始日期
  51. * @param endDate 结束时间
  52. * @param interval 时间间隔
  53. * @param area 区域或机构
  54. * @param level 级别
  55. * @param index 指标 3 4 5 27
  56. * @return
  57. */
  58. @RequestMapping(value = "/interval")
  59. @ResponseBody
  60. public String indexInterval(@RequestParam(required = true) String startDate,
  61. @RequestParam(required = true) String endDate,
  62. @RequestParam(required = true) int interval,
  63. @RequestParam(required = true) String area,
  64. @RequestParam(required = true) int level,
  65. @RequestParam(required = true) String index,
  66. @RequestParam(required = false) String level2_type) {
  67. String tag = "";
  68. try {
  69. String[] indexes = index.split(",");
  70. JSONObject result = new JSONObject();
  71. if (index != null) {
  72. for (String idx : indexes) {
  73. result.put("index_" + idx, statisticsService.getDateIncrementDetail(startDate, endDate, interval, area, level, idx, level2_type));
  74. }
  75. }
  76. return write(200, "查询成功!", "data", result);
  77. } catch (Exception e) {
  78. return error(-1, tag + "查询失败!");
  79. }
  80. }
  81. /**
  82. * 指标期间 增长量
  83. *
  84. * @param startDate
  85. * @param endDate
  86. * @param area
  87. * @param level
  88. * @param index
  89. * @return
  90. */
  91. @RequestMapping("/increment")
  92. @ResponseBody
  93. public String getIndexIncrement(@RequestParam(required = true) String startDate,
  94. @RequestParam(required = true) String endDate,
  95. @RequestParam(required = true) String area,
  96. @RequestParam(required = true) int level,
  97. @RequestParam(required = true) String index,
  98. @RequestParam(required = false) String year) {
  99. try {
  100. String[] indexes = index.split(",");
  101. JSONObject result = new JSONObject();
  102. for (String idx : indexes) {
  103. result.put("index_" + idx, statisticsService.getIntervalIncrement(startDate, endDate, area, level, idx));
  104. }
  105. return write(200, "查询成功", "data", result);
  106. } catch (Exception e) {
  107. e.printStackTrace();
  108. return error(-1, "查询失败");
  109. }
  110. }
  111. /**
  112. * 指标截止日期累积量 增量的累加接口
  113. *
  114. * @param startDate 开始时间
  115. * @param endDate 结束时间
  116. * @param area 父code
  117. * @param level 等级 1 团队,2 机构,3 区,4 市
  118. * @param index 指标代码 3 4 5 27
  119. * @param level2_type 指标代码 例如性别 1 男 2 女 不传就返回男和女的总和
  120. * @return
  121. */
  122. @RequestMapping("/total")
  123. @ResponseBody
  124. public String getIndexTotal(
  125. @RequestParam(required = true) String startDate,
  126. @RequestParam(required = true) String endDate,
  127. @RequestParam(required = true) String area,
  128. @RequestParam(required = true) int level,
  129. @RequestParam(required = true) String index,
  130. @RequestParam(required = false) String level2_type) {
  131. try {
  132. String[] indexes = index.split(",");
  133. JSONObject result = new JSONObject();
  134. for (String idx : indexes) {
  135. result.put("index_" + idx, statisticsService.getTotalAmount(startDate, endDate, area, level, idx, level2_type));
  136. }
  137. return write(200, "查询成功", "data", result);
  138. } catch (Exception e) {
  139. return error(-1, "查询失败");
  140. }
  141. }
  142. /**
  143. * 指标期间增长量 此接口前端没用
  144. *
  145. * @param startDate
  146. * @param endDate
  147. * @param area
  148. * @param level
  149. * @param index
  150. * @return
  151. */
  152. @RequestMapping("/lowlevel_increment")
  153. @ResponseBody
  154. @Deprecated
  155. public String getIndexLowLevelIncrement(@RequestParam(required = true) String startDate,
  156. @RequestParam(required = true) String endDate,
  157. @RequestParam(required = true) String area,
  158. @RequestParam(required = true) int level,
  159. @RequestParam(required = true) String index,
  160. @RequestParam(required = true) int sort,
  161. @RequestParam(required = false) String lowLevel,
  162. @RequestParam(required = false) String year) {
  163. try {
  164. String[] indexes = index.split(",");
  165. JSONObject result = new JSONObject();
  166. for (String idx : indexes) {
  167. result.put("index_" + idx, statisticsService.getLowLevelIncrementDetail(startDate, endDate, area, level, idx, sort, lowLevel));
  168. }
  169. return write(200, "查询成功", "data", result);
  170. } catch (Exception e) {
  171. e.printStackTrace();
  172. return error(-1, "查询失败");
  173. }
  174. }
  175. /**
  176. * 指标截止日期 增量
  177. * (如:待预约量)
  178. *
  179. * @param endDate 结束时间
  180. * @param area 父code
  181. * @param level 等级 1 团队,2 机构,3 区,4 市
  182. * @param index 指标代码
  183. * @param sort 排序 1倒叙 2是 正序
  184. * @param lowLevel
  185. * @param level2_type 指标代码 例如性别 1 男 2 女 不传就返回男和女的总和
  186. * @return
  187. */
  188. @RequestMapping("/lowlevel_total")
  189. @ResponseBody
  190. public String getIndexLowLevelTotal(@RequestParam(required = true) String endDate,
  191. @RequestParam(required = true) String area,
  192. @RequestParam(required = true) int level,
  193. @RequestParam(required = true) String index,
  194. @RequestParam(required = true) int sort,
  195. @RequestParam(required = false) String lowLevel,
  196. @RequestParam(required = false) String level2_type,
  197. @RequestParam(required = false) String year) {
  198. try {
  199. String[] indexes = index.split(",");
  200. JSONObject result = new JSONObject();
  201. for (String idx : indexes) {
  202. result.put("index_" + idx, statisticsService.getLowLevelTotalDetail(endDate, area, level, idx, sort, lowLevel, level2_type, year));
  203. }
  204. return write(200, "查询成功", "data", result);
  205. } catch (Exception e) {
  206. return error(-1, "查询失败");
  207. }
  208. }
  209. /**
  210. * 指标截止日期累积量 增量
  211. * 根据2个ID合并指标
  212. *
  213. * @param endDate
  214. * @param area
  215. * @param level
  216. * @param index 3,22
  217. * @return
  218. */
  219. @RequestMapping("/lowlevel_total_mesh")
  220. @ResponseBody
  221. public String getIndexLowLevelTotalMesh(@RequestParam(required = true) String endDate, // 2007-10-02
  222. @RequestParam(required = true) String area,//区域 350205
  223. @RequestParam(required = true) int level,//等级
  224. @RequestParam(required = true) String index,//指标code
  225. @RequestParam(required = true) int sort,//1是倒叙 0是正序
  226. @RequestParam(required = false) String lowLevel,
  227. @RequestParam(required = false) String year) {
  228. try {
  229. String[] indexes = index.split(",");
  230. JSONObject result = new JSONObject();
  231. JSONArray returnJa = new JSONArray();
  232. List<JSONArray> jsonArrays = new ArrayList<>();
  233. JSONArray jsonArray1 = statisticsService.getLowLevelTotalDetail(endDate, area, level, indexes[0], sort, lowLevel, null, year);
  234. jsonArrays.add(jsonArray1);
  235. JSONArray jsonArray2 = statisticsService.getLowLevelIncrementDetail(endDate, endDate, area, level, indexes[1], sort, lowLevel);
  236. jsonArrays.add(jsonArray2);
  237. //遍历合并2个指标中key值一样的
  238. if (jsonArrays.get(1).length() == 0) {
  239. //如果只有一个指标的时候 另外一个指标默认是0
  240. for (int i = 0; i < jsonArrays.get(0).length(); i++) {
  241. //未回复咨询不存在的时候默认是0
  242. JSONObject map1 = jsonArrays.get(0).getJSONObject(i);
  243. String amount = map1.get("amount").toString() + ",0";
  244. map1.put("amount", amount);
  245. returnJa.put(map1);
  246. }
  247. } else {
  248. //如果是2个指标的时候,分别放入map中,以减少查询次数
  249. Map<String, JSONObject> in = new TreeMap<>();
  250. ValueComparator vc = new ValueComparator(in);
  251. Map<String, JSONObject> index2 = new TreeMap<>();
  252. for (int i = 0; i < jsonArrays.get(0).length(); i++) {
  253. JSONObject map1 = jsonArrays.get(0).getJSONObject(i);
  254. in.put(map1.get("code").toString(), map1);
  255. }
  256. Map<String, JSONObject> index1 = new TreeMap<>(vc);
  257. index1.putAll(in);
  258. for (int i = 0; i < jsonArrays.get(1).length(); i++) {
  259. JSONObject map1 = jsonArrays.get(1).getJSONObject(i);
  260. index2.put(map1.get("code").toString(), map1);
  261. }
  262. for (Map.Entry<String, JSONObject> one : index1.entrySet()) {
  263. JSONObject map1 = one.getValue();
  264. JSONObject map2 = index2.get(one.getKey());
  265. String amount = map1.get("amount").toString() + "," + map2.get("amount").toString();
  266. map1.put("amount", amount);
  267. returnJa.put(map1);
  268. }
  269. }
  270. if (level == 2) {
  271. statisticsAllService.translateTeamLeaderNameByCode(returnJa);
  272. }
  273. result.put("index_" + indexes[0], returnJa);
  274. return write(200, "查询成功", "data", result);
  275. } catch (
  276. Exception e
  277. )
  278. {
  279. e.printStackTrace();
  280. return error(-1, "查询失败");
  281. }
  282. }
  283. /**
  284. * 指标期间 增长量
  285. *
  286. * @param startDate
  287. * @param endDate
  288. * @param area
  289. * @param level
  290. * @param index
  291. * @return
  292. */
  293. @RequestMapping("/leveltwo_increment")
  294. @ResponseBody
  295. public String getIndexLevelTwoIncrement(@RequestParam(required = false) String startDate,
  296. @RequestParam(required = true) String endDate,
  297. @RequestParam(required = true) String area,
  298. @RequestParam(required = true) int level,
  299. @RequestParam(required = true) String index,
  300. @RequestParam(required = false) String year) {
  301. try {
  302. String[] indexes = index.split(",");
  303. JSONObject result = new JSONObject();
  304. for (String idx : indexes) {
  305. result.put("index_" + idx, statisticsAllService.getIndexLevelTwototal(endDate, area, level, idx));
  306. }
  307. return write(200, "查询成功", "data", result);
  308. } catch (Exception e) {
  309. e.printStackTrace();
  310. return error(-1, "查询失败");
  311. }
  312. }
  313. /**
  314. * 获取签约率、签约完成率
  315. *
  316. * @param endDate 截止日期
  317. * @param area 区域
  318. * @param level 区域级别 4:城市 3:区 2:社区 1:团队
  319. * @return
  320. */
  321. @RequestMapping(value = "/sign_info")
  322. @ResponseBody
  323. public String getAreaSignInfo(@RequestParam(required = true) String endDate,
  324. @RequestParam(required = true) String area,
  325. @RequestParam(required = true) int level,
  326. @RequestParam(required = false) String lowCode,
  327. @RequestParam(required = false) String year
  328. ) {
  329. try {
  330. JSONObject result = new JSONObject();
  331. if (StringUtils.isEmpty(lowCode)) {
  332. long sign = statisticsAllService.getIndexTotal(endDate, area, level, "13");
  333. long weiJf = statisticsAllService.getWeiJiaoFei(endDate, area, level);
  334. JSONObject signRate = statisticsAllService.getSignRate(endDate, area, level);
  335. JSONObject signTaskRate = statisticsAllService.getSignTaskRate(endDate, area, level);
  336. result.put("sign", sign);
  337. result.put("expenses", weiJf);
  338. result.put("signRate", signRate);
  339. result.put("signTaskRate", signTaskRate);
  340. } else {
  341. result = statisticsAllService.getGroupInfo(endDate, lowCode, area, level);
  342. }
  343. return write(200, "查询成功", "data", result);
  344. } catch (Exception e) {
  345. return error(-1, "查询失败");
  346. }
  347. }
  348. /**
  349. * 获取三级指标增量 到达量
  350. *
  351. * @param startDate
  352. * @param endDate
  353. * @param area
  354. * @param level
  355. * @return
  356. */
  357. @RequestMapping(value = "/sixfive_statistics")
  358. @ResponseBody
  359. public String getSixFiveStatistics(@RequestParam(required = false) String startDate,
  360. @RequestParam(required = true) String endDate,
  361. @RequestParam(required = true) String area,
  362. int level,
  363. @RequestParam(required = false) String year) {
  364. try {
  365. JSONArray result = statisticsAllService.getSixFiveStatistics(endDate, area, level);
  366. return write(200, "查询成功", "data", result);
  367. } catch (Exception e) {
  368. e.printStackTrace();
  369. return error(-1, "查询失败");
  370. }
  371. }
  372. /**
  373. * 指标按间隔统计 到达量
  374. *
  375. * @param startDate 起始日期
  376. * @param endDate 结束时间
  377. * @param interval 时间间隔
  378. * @param area 区域或机构
  379. * @param level 级别
  380. * @param index 指标 除了增量的指标都会调用
  381. * @param lowCode 子维度
  382. * @param year 查询年份
  383. * @return
  384. */
  385. @RequestMapping(value = "/interval_total")
  386. @ResponseBody
  387. public String indexIntervalTotal(@RequestParam(required = true) String startDate,
  388. @RequestParam(required = true) String endDate,
  389. @RequestParam(required = true) int interval,
  390. @RequestParam(required = true) String area,
  391. @RequestParam(required = true) int level,
  392. @RequestParam(required = true) String index,
  393. @RequestParam(required = false) String lowCode,
  394. @RequestParam(required = false) String year) {
  395. try {
  396. String[] indexes = index.split(",");
  397. JSONObject result = new JSONObject();
  398. if (index != null) {
  399. for (String idx : indexes) {
  400. JSONObject json = statisticsAllService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode);
  401. //如果year不为空 那么因为是到达量 所以要累加上一年的数据
  402. if (!org.springframework.util.StringUtils.isEmpty(year) && !"2016".equals(year)) {
  403. //得到上一个年份的的最后一天的统计数据
  404. String date = year + "-06-30";//固定是 6月三十号 为一个年份的最后一天,如果是2017年份 那么就是2017-7-1 到 2018-6-30
  405. WlyyQuotaResult wlyyQuotaResult = statisticsService.findOneQuotaResult(date, level, idx, area);
  406. if (wlyyQuotaResult != null) {
  407. JSONArray ja = json.getJSONArray("data");
  408. for (int i = 0; i < ja.length(); i++) {
  409. Integer value = Integer.valueOf(ja.getJSONObject(i).getString("amount"));
  410. super.infoMessage("原来的总数:" + value);
  411. ja.getJSONObject(i).put("amount", value + Integer.valueOf(wlyyQuotaResult.getResult()));
  412. super.infoMessage("需要想加的总数:" + wlyyQuotaResult.getResult());
  413. }
  414. }
  415. }
  416. result.put("index_" + idx, json);
  417. }
  418. }
  419. return write(200, "查询成功!", "data", result);
  420. } catch (Exception e) {
  421. return error(-1, "查询失败!");
  422. }
  423. }
  424. /**
  425. * 指标截止日期累积量 到达量
  426. *
  427. * @param date
  428. * @param area
  429. * @param level level1_type等级 1:团队 2社区机构 3区级 4市级
  430. * @param index quotoCode 18/19两率 28 13 17
  431. * @param sort 0:升序 1:降序
  432. * @param lowCode
  433. * @return
  434. */
  435. @RequestMapping("/lowlevel_all")
  436. @ResponseBody
  437. public String getIndexLowLevelTotalSign(@RequestParam(required = true) String date,
  438. @RequestParam(required = true) String area,
  439. @RequestParam(required = true) int level,
  440. @RequestParam(required = true) String index,
  441. @RequestParam(required = true) int sort,
  442. @RequestParam(required = false) String lowLevel,
  443. @RequestParam(required = false) String lowCode,
  444. @RequestParam(required = false) String year) {
  445. try {
  446. String[] indexes = index.split(",");
  447. JSONObject result = new JSONObject();
  448. if (StringUtils.isNotEmpty(lowCode)) {
  449. // 指定level下特定查询级别
  450. if (index.equals("17")) {
  451. result.put("index_" + index, statisticsAllService.getLevelTwoLowLevelTotalTeamLeader(date, area, level, index, sort, lowLevel, lowCode));
  452. } else {
  453. result.put("index_" + index, statisticsAllService.getLevelTwoLowLevelTotal(date, area, level, index, sort, lowLevel, lowCode));
  454. }
  455. } else {
  456. // 未指定level下特定查询级别
  457. for (String idx : indexes) {
  458. if (idx.equals("18") || index.equals("19")) {
  459. result.put("index_" + idx, statisticsAllService.getLowLevelTotalSpecial(date, area, level, idx, sort, lowLevel));
  460. } else if (idx.equals("1") || index.equals("21")) {
  461. result.put("index_" + idx, statisticsAllService.getLowLevelTotal2(date, area, level, idx, sort, lowLevel));
  462. } else if (idx.equals("28")) {
  463. result.put("index_" + idx, statisticsService.getAvgAllInfo(level, area, lowLevel));
  464. } else if (idx.equals("13")) {
  465. result.put("index_" + idx, statisticsAllService.getLowLevelTotalTeamLeader(date, area, level, idx, sort, lowLevel));
  466. } else {
  467. result.put("index_" + idx, statisticsAllService.getLowLevelTotal(date, area, level, idx, sort, lowLevel));
  468. }
  469. }
  470. }
  471. return write(200, "查询成功", "data", result);
  472. } catch (Exception e) {
  473. e.printStackTrace();
  474. return error(-1, "查询失败");
  475. }
  476. }
  477. /**
  478. * 获取三师转签或高危人群
  479. *
  480. * @param endDate
  481. * @param area
  482. * @param level
  483. * @return
  484. */
  485. @RequestMapping(value = "/sszq_qwrq_info")
  486. @ResponseBody
  487. public String getSszqAndGwrq(@RequestParam(required = true) String endDate,
  488. @RequestParam(required = true) String area,
  489. @RequestParam(required = true) int level) {
  490. try {
  491. JSONObject result = new JSONObject();
  492. JSONObject sszq = statisticsAllService.getSszqAndGwrq(endDate, area, level, "18");
  493. JSONObject gwrq = statisticsAllService.getSszqAndGwrq(endDate, area, level, "19");
  494. result.put("sszq", sszq);
  495. result.put("gwrq", gwrq);
  496. return write(200, "查询成功", "data", result);
  497. } catch (Exception e) {
  498. return error(-1, "查询失败");
  499. }
  500. }
  501. /**
  502. * 二级指标 到达量 废弃接口 前端没有调用
  503. *
  504. * @param date
  505. * @param area
  506. * @param level
  507. * @param index
  508. * @return
  509. */
  510. @RequestMapping(value = "/leveltwo_all")
  511. @ResponseBody
  512. @Deprecated
  513. public String getIndexLevelTwoTotal(@RequestParam(required = true) String date,
  514. @RequestParam(required = true) String area,
  515. @RequestParam(required = true) int level,
  516. @RequestParam(required = true) String index) {
  517. try {
  518. String[] indexes = index.split(",");
  519. JSONObject result = new JSONObject();
  520. for (String idx : indexes) {
  521. result.put("index_" + idx, statisticsAllService.getIndexLevelTwototal(date, area, level, idx));
  522. }
  523. return write(200, "查询成功", "data", result);
  524. } catch (Exception e) {
  525. e.printStackTrace();
  526. return error(-1, "查询失败");
  527. }
  528. }
  529. /**
  530. * 指标截止日期 到达量
  531. *
  532. * @param endDate
  533. * @param area
  534. * @param level
  535. * @param index
  536. * @return
  537. */
  538. @RequestMapping("/index_all")
  539. @ResponseBody
  540. public String getIndexAll(@RequestParam(required = true) String endDate,
  541. @RequestParam(required = true) String area,
  542. @RequestParam(required = true) int level,
  543. @RequestParam(required = true) String index,
  544. @RequestParam(required = false) String year) {
  545. try {
  546. String[] indexes = index.split(",");
  547. JSONObject result = new JSONObject();
  548. for (String idx : indexes) {
  549. Long total = statisticsAllService.getIndexTotal(endDate, area, level, idx);
  550. super.infoMessage("原来的总数:" + total);
  551. //如果year不为空 那么因为是到达量 所以要加上一年的数据
  552. if (!org.springframework.util.StringUtils.isEmpty(year) && !"2016".equals(year)) {
  553. //得到上一个年份的的最后一天的统计数据
  554. String date = year + "-06-30";//固定是 6月三十号 为一个年份的最后一天,如果是2017年份 那么就是2017-7-1 到 2018-6-30
  555. WlyyQuotaResult wlyyQuotaResult = statisticsService.findOneQuotaResult(date, level, idx, area);
  556. if (wlyyQuotaResult != null) {
  557. super.infoMessage("需要添加的数目:" + wlyyQuotaResult.getResult());
  558. total = total + Long.valueOf(wlyyQuotaResult.getResult());
  559. }
  560. }
  561. result.put("index_" + idx, total);
  562. }
  563. return write(200, "查询成功", "data", result);
  564. } catch (Exception e) {
  565. return error(-1, "查询失败");
  566. }
  567. }
  568. /**
  569. * 咨询统计
  570. * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
  571. * ①回复及时率------医生首次回复24小时内比例
  572. * ②未回复数(数、率)----------当前未回复咨询数、以及相应比例
  573. * ③处理咨询回复时间分布---------全部咨询的首次回复咨询时间分布
  574. *
  575. * @param level 查询的等级,按市、区、机构
  576. * @param area 查询的等级对应Code
  577. * @return
  578. */
  579. @RequestMapping("/Consulting_Stat")
  580. @ResponseBody
  581. public String getConsultingStatistics(@RequestParam(required = true) Integer level,
  582. @RequestParam(required = true) String area) {
  583. try {
  584. return write(200, "查询成功", "data", statisticsService.getConsultingStatistics(level, area));
  585. } catch (Exception e) {
  586. return error(-1, "查询失败");
  587. }
  588. }
  589. /**
  590. * 咨询统计
  591. * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
  592. * ①回复及时率------医生首次回复24小时内比例
  593. * ②未回复数(数、率)----------当前未回复咨询数、以及相应比例
  594. * ③处理咨询回复时间分布---------全部咨询的首次回复咨询时间分布
  595. *
  596. * @param level 查询的等级,按市、区、机构
  597. * @return
  598. */
  599. @RequestMapping("/Consulting_StatList")
  600. @ResponseBody
  601. public String getConsultingStatisticsList(@RequestParam(required = true) Integer level,
  602. @RequestParam(required = true) String area,
  603. @RequestParam(required = false) String lowlevel,
  604. @RequestParam(required = false) String year) {
  605. try {
  606. JSONObject data = null;
  607. if (Constant.getStartYear().equals(year)) {
  608. data = statisticsService.getConsultingStatisticsList(level, area, lowlevel);
  609. } else if (org.springframework.util.StringUtils.isEmpty(year)) {
  610. data = statisticsService.getConsultingStatisticsListAll(level, area, lowlevel,year);
  611. } else {
  612. data = statisticsService.getConsultingStatisticsListYear(level, area, lowlevel,year);
  613. }
  614. if (data != null) {
  615. return write(200, "查询成功", "data", data);
  616. } else {
  617. return error(-1, "查询失败");
  618. }
  619. } catch (Exception e) {
  620. return error(-1, "查询失败");
  621. }
  622. }
  623. /**
  624. * 咨询统计
  625. * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
  626. * ①回复及时率------医生首次回复24小时内比例
  627. * ②未回复数(数、率)----------当前未回复咨询数、以及相应比例
  628. * ③处理咨询回复时间分布---------全部咨询的首次回复咨询时间分布
  629. *
  630. * @param level 查询的等级,按市、区、机构
  631. * @return
  632. */
  633. @RequestMapping("/Consulting_Title")
  634. @ResponseBody
  635. public String getConsultingTitle(@RequestParam(required = true) Integer level,
  636. @RequestParam(required = true) String area,
  637. @RequestParam(required = false) String year) {
  638. try {
  639. JSONObject data = null;
  640. if (Constant.getStartYear().equals(year)) {
  641. //查今年的查找redis即可
  642. data = statisticsService.getConsultingTitle(level, area);
  643. } else if (org.springframework.util.StringUtils.isEmpty(year)) {
  644. //为空默认查询全部
  645. //查找redis的然后再添加去年年度的
  646. data = statisticsService.getConsultingTitleAll(level, area,year);
  647. } else {
  648. //去数据库查找年份
  649. data = statisticsService.getConsultingTitleWithYear(level, area, year);
  650. }
  651. if (data != null) {
  652. return write(200, "查询成功", "data", data);
  653. } else {
  654. return error(-1, "查询失败");
  655. }
  656. } catch (Exception e) {
  657. return error(-1, "查询失败");
  658. }
  659. }
  660. /**
  661. * 获取回复数时间分布数
  662. *
  663. * @param level
  664. * @param area
  665. * @return
  666. */
  667. @RequestMapping("/getCoutListByTime")
  668. @ResponseBody
  669. public String getCoutListByTime(
  670. @RequestParam(required = true) String level,
  671. @RequestParam(required = true) String area,
  672. @RequestParam(required = false) String year) {
  673. try {
  674. if (Constant.getStartYear().equals(year)) {
  675. return write(200, "查询成功", "data", statisticsService.getCoutListByTime(level, area));
  676. } else if (org.springframework.util.StringUtils.isEmpty(year)) {
  677. return write(200, "查询成功", "data", statisticsService.getCoutListByTimeAll(level, area));
  678. } else {
  679. return write(200, "查询成功", "data", statisticsService.getCoutListByTimeYear(level, area, year));
  680. }
  681. } catch (Exception e) {
  682. return error(-1, "查询失败");
  683. }
  684. }
  685. /**
  686. * 获取绑定率
  687. * 1、选定绑定微信指标,下面排行内,在绑定微信数后新增:"绑定率:xx.22%"
  688. * 2、绑定率=绑定数/已签约数
  689. *
  690. * @return
  691. */
  692. @RequestMapping("/bindingRate_stat")
  693. @ResponseBody
  694. public String getBindingRate() {
  695. try {
  696. return write(200, "查询成功", "data", statisticsService.getBindingRate());
  697. } catch (Exception e) {
  698. return error(-1, "查询失败");
  699. }
  700. }
  701. /**
  702. * 获取得分平均数
  703. *
  704. * @param level
  705. * @param area
  706. * @return
  707. */
  708. @RequestMapping("/getAVGSocre")
  709. @ResponseBody
  710. public String getAVGSocre(@RequestParam(required = true) String level, @RequestParam(required = true) String area) {
  711. try {
  712. return write(200, "查询成功", "data", statisticsService.getAVGSocre(level, area));
  713. } catch (Exception e) {
  714. return error(-1, "查询失败");
  715. }
  716. }
  717. /**
  718. * 获取得分平均数按月份
  719. *
  720. * @return
  721. */
  722. @RequestMapping("/getAVGSocreByMonth")
  723. @ResponseBody
  724. public String getAVGSocreByMonth(@RequestParam(required = true) String level,
  725. @RequestParam(required = true) String area,
  726. @RequestParam(required = true) String statDate,
  727. @RequestParam(required = true) String endDate) {
  728. try {
  729. return write(200, "查询成功", "data", statisticsService.getAVGSocreByMonth(level, area, statDate, endDate));
  730. } catch (Exception e) {
  731. error(e);
  732. return error(-1, "查询失败");
  733. }
  734. }
  735. /**
  736. * 统计当前团队,签约人数,服务次数,平均满意度
  737. *
  738. * @return
  739. */
  740. @RequestMapping("/getStatTitleInfo")
  741. @ResponseBody
  742. public String getStatTitleInfo(@RequestParam(required = true) String startDate,
  743. @RequestParam(required = true) String endDate) {
  744. try {
  745. return write(200, "查询成功", "data", statisticsService.getStatTitleInfo(getUID(), startDate, endDate));
  746. //return write(200, "查询成功", "data", statisticsService.getStatTitleInfo("xh1D201703150222",startDate,endDate));
  747. } catch (Exception e) {
  748. error(e);
  749. return error(-1, "查询失败");
  750. }
  751. }
  752. /**
  753. * 获取签约折线图
  754. *
  755. * @param startDate
  756. * @param endDate
  757. * @param signType 0 签约,1 续签
  758. * @param type 0 按周,1 按月
  759. * @return
  760. */
  761. @RequestMapping("/getSignCountLineByType")
  762. @ResponseBody
  763. public String getSignCountLineByType(@RequestParam(required = true) String startDate,
  764. @RequestParam(required = true) String endDate,
  765. @RequestParam(required = true) String signType,
  766. @RequestParam(required = true) String type) {
  767. try {
  768. //判断是签约还是续签
  769. if ("0".equals(signType)) {
  770. return write(200, "查询成功", "data", statisticsService.getSignCountLineByType(getUID(), type, startDate, endDate));
  771. //return write(200, "查询成功", "data", statisticsService.getSignCountLineByType("xh1D201703150222",type,startDate,endDate));
  772. } else {
  773. return write(200, "查询成功", "data", statisticsService.getRenewCountLineByType(getUID(), type, startDate, endDate));
  774. //return write(200, "查询成功", "data", statisticsService.getRenewCountLineByType("xh1D201703150222",type,startDate,endDate));
  775. }
  776. } catch (Exception e) {
  777. error(e);
  778. return error(-1, "查询失败");
  779. }
  780. }
  781. /**
  782. * 获取咨询数和未回复数
  783. *
  784. * @param startDate
  785. * @param endDate
  786. * @param isNow 1 为当前;2为非当前
  787. * @return
  788. */
  789. @RequestMapping("/getReyStatbyTeam")
  790. @ResponseBody
  791. public String getReyStatbyTeam(@RequestParam(required = true) String startDate,
  792. @RequestParam(required = true) String endDate,
  793. @RequestParam(required = true) String isNow) {
  794. try {
  795. return write(200, "查询成功", "data", statisticsService.getReyStatbyTeam(getUID(), startDate, endDate, isNow));
  796. //return write(200, "查询成功", "data", statisticsService.getReyStatbyTeam("xh1D201703150222",startDate,endDate,isNow));
  797. } catch (Exception e) {
  798. error(e);
  799. return error(-1, "查询失败");
  800. }
  801. }
  802. /**
  803. * 获取机构内服务排行
  804. *
  805. * @param startDate
  806. * @param endDate
  807. * @return
  808. */
  809. @RequestMapping("/getServiceRankingList")
  810. @ResponseBody
  811. public String getServiceRankingList(@RequestParam(required = true) String startDate,
  812. @RequestParam(required = true) String endDate) {
  813. try {
  814. return write(200, "查询成功", "data", statisticsService.getServiceRankingList(getUID(), startDate, endDate));
  815. //return write(200, "查询成功", "data", statisticsService.getServiceRankingList("xh1D201703150222",startDate,endDate));
  816. } catch (Exception e) {
  817. error(e);
  818. return error(-1, "查询失败");
  819. }
  820. }
  821. /**
  822. * 获取平均值统计折线图
  823. *
  824. * @param startDate
  825. * @param endDate
  826. * @param type 0周,1月
  827. * @return
  828. */
  829. @RequestMapping("/getAvgLine")
  830. @ResponseBody
  831. public String getAvgLine(@RequestParam(required = true) String startDate,
  832. @RequestParam(required = true) String endDate,
  833. @RequestParam(required = true) String type) {
  834. try {
  835. return write(200, "查询成功", "data", statisticsService.getAvgLine(getUID(), startDate, endDate, type));
  836. // return write(200, "查询成功", "data", statisticsService.getAvgLine("xh1D201703150222",startDate,endDate,type));
  837. } catch (Exception e) {
  838. error(e);
  839. return error(-1, "查询失败");
  840. }
  841. }
  842. /**
  843. * 判断团队是否是团队长
  844. *
  845. * @return
  846. */
  847. @RequestMapping("/checkDoctorIsTeamLeder")
  848. @ResponseBody
  849. public String checkDoctorIsTeamLeder() {
  850. try {
  851. return write(200, "查询成功", "data", statisticsService.checkDoctorIsTeamleader(getUID()));
  852. } catch (Exception e) {
  853. error(e);
  854. return error(-1, "查询失败");
  855. }
  856. }
  857. /**
  858. * 获取团队月或周咨询未回复和总数折线图
  859. *
  860. * @param teamCode 团队id
  861. * @param startDate
  862. * @param endDate
  863. * @param type 0周,1月
  864. * @return
  865. */
  866. @RequestMapping("/getTeamConsultCount")
  867. @ResponseBody
  868. public String getTeamConsultCount(@RequestParam(required = true) String teamCode,
  869. @RequestParam(required = true) String startDate,
  870. @RequestParam(required = true) String endDate,
  871. @RequestParam(required = true) String type) {
  872. try {
  873. return write(200, "查询成功", "data", statisticsService.getTeamConsultCount(teamCode, startDate, endDate, type));
  874. } catch (Exception e) {
  875. error(e);
  876. return error(-1, "查询失败");
  877. }
  878. }
  879. /**
  880. * 计算团队医生月或周咨询未回复和总数折线图
  881. *
  882. * @param teamCode
  883. * @param startDate
  884. * @param endDate
  885. * @param type 0周,1月
  886. * @param doctor
  887. * @return
  888. */
  889. @RequestMapping("/getTeamDoctorConsultCount")
  890. @ResponseBody
  891. public String getTeamDoctorConsultCount(@RequestParam(required = true) String teamCode,
  892. @RequestParam(required = true) String startDate,
  893. @RequestParam(required = true) String endDate,
  894. @RequestParam(required = true) String type,
  895. @RequestParam(required = true) String doctor) {
  896. try {
  897. return write(200, "查询成功", "data", statisticsService.getTeamDoctorConsultCount(teamCode, startDate, endDate, type, doctor));
  898. } catch (Exception e) {
  899. error(e);
  900. return error(-1, "查询失败");
  901. }
  902. }
  903. /**
  904. * 获取团队内这成员,未回复数,总数,结束咨询数
  905. *
  906. * @param teamCode
  907. * @param startDate
  908. * @param endDate
  909. * @param sort 0降序,1升序
  910. * @return
  911. */
  912. @RequestMapping("/getMemberConsultList")
  913. @ResponseBody
  914. public String getMemberConsultList(@RequestParam(required = true) String teamCode,
  915. @RequestParam(required = true) String startDate,
  916. @RequestParam(required = true) String endDate,
  917. @RequestParam(required = true) String sort,
  918. @RequestParam(required = true) String sortType) {
  919. try {
  920. return write(200, "查询成功", "data", statisticsService.getMemberConsultList(teamCode, startDate, endDate, sort, sortType));
  921. } catch (Exception e) {
  922. error(e);
  923. return error(-1, "查询失败");
  924. }
  925. }
  926. /**
  927. * 获取Doctor咨询结果
  928. *
  929. * @param doctor
  930. * @param teamCode
  931. * @param startDate
  932. * @param endDate
  933. * @return
  934. */
  935. @RequestMapping("/getDoctorConsultTitle")
  936. @ResponseBody
  937. public String getDoctorConsultTitle(@RequestParam(required = true) String doctor,
  938. @RequestParam(required = true) String teamCode,
  939. @RequestParam(required = true) String startDate,
  940. @RequestParam(required = true) String endDate) {
  941. try {
  942. return write(200, "查询成功", "data", statisticsService.getDoctorConsultTitle(doctor, teamCode, startDate, endDate));
  943. } catch (Exception e) {
  944. error(e);
  945. return error(-1, "查询失败");
  946. }
  947. }
  948. /**
  949. * 获取团队随访量折线统计图
  950. *
  951. * @param type
  952. * @param teamCode
  953. * @param startDate
  954. * @param endDate
  955. * @return
  956. */
  957. @RequestMapping("/getTeamFollowupLine")
  958. @ResponseBody
  959. public String getTeamFollowupLine(@RequestParam(required = true) String type,
  960. @RequestParam(required = true) String teamCode,
  961. @RequestParam(required = true) String startDate,
  962. @RequestParam(required = true) String endDate) {
  963. try {
  964. return write(200, "查询成功", "data", statisticsService.getTeamFollowupLine(teamCode, startDate, endDate, type));
  965. } catch (Exception e) {
  966. error(e);
  967. return error(-1, "查询失败");
  968. }
  969. }
  970. @RequestMapping("/getTeamDoctorFollowupLine")
  971. @ResponseBody
  972. public String getTeamDoctorFollowupLine(@RequestParam(required = true) String type,
  973. @RequestParam(required = true) String teamCode,
  974. @RequestParam(required = true) String startDate,
  975. @RequestParam(required = true) String endDate,
  976. @RequestParam(required = true) String doctor) {
  977. try {
  978. return write(200, "查询成功", "data", statisticsService.getTeamDoctorFollowupLine(teamCode, startDate, endDate, type, doctor));
  979. } catch (Exception e) {
  980. error(e);
  981. return error(-1, "查询失败");
  982. }
  983. }
  984. /**
  985. * 根据团队获取团队底下用户列表
  986. *
  987. * @param sort 0为降序,1为升序
  988. * @param teamCode
  989. * @param startDate
  990. * @param endDate
  991. * @param sortType 0为总数排序,1为增量排序,2为计划中排序
  992. * @return
  993. */
  994. @RequestMapping("/getDoctorTeamFolList")
  995. @ResponseBody
  996. public String getDoctorTeamFolList(@RequestParam(required = true) String sort,
  997. @RequestParam(required = true) String teamCode,
  998. @RequestParam(required = true) String startDate,
  999. @RequestParam(required = true) String endDate,
  1000. @RequestParam(required = true) String sortType) {
  1001. try {
  1002. return write(200, "查询成功", "data", statisticsService.getDoctorTeamFolList(startDate, endDate, teamCode, sort, sortType));
  1003. } catch (Exception e) {
  1004. error(e);
  1005. return error(-1, "查询失败");
  1006. }
  1007. }
  1008. /**
  1009. * 获取医生随访头信息
  1010. *
  1011. * @param teamCode
  1012. * @param doctor
  1013. * @param startDate
  1014. * @param endDate
  1015. * @return
  1016. */
  1017. @RequestMapping("/getTeamDoctorFolTitle")
  1018. @ResponseBody
  1019. public String getTeamDoctorFolTitle(@RequestParam(required = true) String teamCode,
  1020. @RequestParam(required = true) String doctor,
  1021. @RequestParam(required = true) String startDate,
  1022. @RequestParam(required = true) String endDate) {
  1023. try {
  1024. return write(200, "查询成功", "data", statisticsService.getTeamDoctorFolTitle(teamCode, doctor, startDate, endDate));
  1025. } catch (Exception e) {
  1026. error(e);
  1027. return error(-1, "查询失败");
  1028. }
  1029. }
  1030. /**
  1031. * 获取待预约量团队统计则线图
  1032. *
  1033. * @param teamCode
  1034. * @param type
  1035. * @param startDate
  1036. * @param endDate
  1037. * @return
  1038. */
  1039. @RequestMapping("/getTeamResLine")
  1040. @ResponseBody
  1041. public String getTeamResLine(@RequestParam(required = true) String teamCode,
  1042. @RequestParam(required = true) String type,
  1043. @RequestParam(required = true) String startDate,
  1044. @RequestParam(required = true) String endDate) {
  1045. try {
  1046. return write(200, "查询成功", "data", statisticsService.getTeamResLine(teamCode, startDate, endDate, type));
  1047. } catch (Exception e) {
  1048. error(e);
  1049. return error(-1, "查询失败");
  1050. }
  1051. }
  1052. /**
  1053. * 获取团队医生预约量团队统计则线图
  1054. *
  1055. * @param teamCode
  1056. * @param type
  1057. * @param startDate
  1058. * @param endDate
  1059. * @param doctor
  1060. * @return
  1061. */
  1062. @RequestMapping("/getTeamDoctorResLine")
  1063. @ResponseBody
  1064. public String getTeamDoctorResLine(@RequestParam(required = true) String teamCode,
  1065. @RequestParam(required = true) String type,
  1066. @RequestParam(required = true) String startDate,
  1067. @RequestParam(required = true) String endDate,
  1068. @RequestParam(required = true) String doctor) {
  1069. try {
  1070. return write(200, "查询成功", "data", statisticsService.getTeamDoctorResLine(teamCode, startDate, endDate, type, doctor));
  1071. } catch (Exception e) {
  1072. error(e);
  1073. return error(-1, "查询失败");
  1074. }
  1075. }
  1076. /**
  1077. * 获取团队待预约量医生列表信息
  1078. *
  1079. * @param teamCode
  1080. * @param startDate
  1081. * @param endDate
  1082. * @param sort 0为降序,1为升序
  1083. * @param sortType 0为按总数,1为按增数
  1084. * @return
  1085. */
  1086. @RequestMapping("/getTeamDoctorResList")
  1087. @ResponseBody
  1088. public String getTeamDoctorResList(@RequestParam(required = true) String teamCode,
  1089. @RequestParam(required = true) String startDate,
  1090. @RequestParam(required = true) String endDate,
  1091. @RequestParam(required = true) String sort,
  1092. @RequestParam(required = true) String sortType) {
  1093. try {
  1094. return write(200, "查询成功", "data", statisticsService.getTeamDoctorResList(teamCode, startDate, endDate, sort, sortType));
  1095. } catch (Exception e) {
  1096. error(e);
  1097. return error(-1, "查询失败");
  1098. }
  1099. }
  1100. /**
  1101. * 获取团队医生待预信息
  1102. *
  1103. * @param teamCode
  1104. * @param doctor
  1105. * @param startDate
  1106. * @param endDate
  1107. * @return
  1108. */
  1109. @RequestMapping("/getTeamDoctorResTitle")
  1110. @ResponseBody
  1111. public String getTeamDoctorResTitle(@RequestParam(required = true) String teamCode,
  1112. @RequestParam(required = true) String doctor,
  1113. @RequestParam(required = true) String startDate,
  1114. @RequestParam(required = true) String endDate) {
  1115. try {
  1116. return write(200, "查询成功", "data", statisticsService.getTeamDoctorResTitle(teamCode, doctor, startDate, endDate));
  1117. } catch (Exception e) {
  1118. error(e);
  1119. return error(-1, "查询失败");
  1120. }
  1121. }
  1122. /**
  1123. * 获取团队健康指导折线图
  1124. *
  1125. * @param teamCode
  1126. * @param startDate
  1127. * @param endDate
  1128. * @param type 0周,1月
  1129. * @return
  1130. */
  1131. @RequestMapping("/getTeamGuidLine")
  1132. @ResponseBody
  1133. public String getTeamGuidLine(@RequestParam(required = true) String teamCode,
  1134. @RequestParam(required = true) String startDate,
  1135. @RequestParam(required = true) String endDate,
  1136. @RequestParam(required = true) String type) {
  1137. try {
  1138. return write(200, "查询成功", "data", statisticsService.getTeamGuidLine(teamCode, startDate, endDate, type));
  1139. } catch (Exception e) {
  1140. error(e);
  1141. return error(-1, "查询失败");
  1142. }
  1143. }
  1144. /**
  1145. * 获取团队医生则线图
  1146. *
  1147. * @param teamCode
  1148. * @param startDate
  1149. * @param endDate
  1150. * @param type
  1151. * @param doctor
  1152. * @return
  1153. */
  1154. @RequestMapping("/getTeamDoctorGuidLine")
  1155. @ResponseBody
  1156. public String getTeamDoctorGuidLine(@RequestParam(required = true) String teamCode,
  1157. @RequestParam(required = true) String startDate,
  1158. @RequestParam(required = true) String endDate,
  1159. @RequestParam(required = true) String type,
  1160. @RequestParam(required = true) String doctor) {
  1161. try {
  1162. return write(200, "查询成功", "data", statisticsService.getTeamDoctorGuidLine(teamCode, startDate, endDate, type, doctor));
  1163. } catch (Exception e) {
  1164. error(e);
  1165. return error(-1, "查询失败");
  1166. }
  1167. }
  1168. /**
  1169. * 获取团队指导总数List
  1170. *
  1171. * @param teamCode
  1172. * @param startDate
  1173. * @param endDate
  1174. * @param sort
  1175. * @param sortType
  1176. * @return
  1177. */
  1178. @RequestMapping("/getTeamGuidList")
  1179. @ResponseBody
  1180. public String getTeamGuidList(@RequestParam(required = true) String teamCode,
  1181. @RequestParam(required = true) String startDate,
  1182. @RequestParam(required = true) String endDate,
  1183. @RequestParam(required = true) String sort,
  1184. @RequestParam(required = true) String sortType) {
  1185. try {
  1186. return write(200, "查询成功", "data", statisticsService.getTeamGuidList(teamCode, startDate, endDate, sort, sortType));
  1187. } catch (Exception e) {
  1188. error(e);
  1189. return error(-1, "查询失败");
  1190. }
  1191. }
  1192. /**
  1193. * 获取医生健康指导头部信息
  1194. *
  1195. * @param teamCode
  1196. * @param doctor
  1197. * @param startDate
  1198. * @param endDate
  1199. * @return
  1200. */
  1201. @RequestMapping("/getTeamDoctorGuiTitle")
  1202. @ResponseBody
  1203. public String getTeamDoctorGuiTitle(@RequestParam(required = true) String teamCode,
  1204. @RequestParam(required = true) String doctor,
  1205. @RequestParam(required = true) String startDate,
  1206. @RequestParam(required = true) String endDate) {
  1207. try {
  1208. return write(200, "查询成功", "data", statisticsService.getTeamDoctorGuiTitle(teamCode, doctor, startDate, endDate));
  1209. } catch (Exception e) {
  1210. error(e);
  1211. return error(-1, "查询失败");
  1212. }
  1213. }
  1214. /**
  1215. * 获取团队健康教育折线统计
  1216. *
  1217. * @param teamCode
  1218. * @param startDate
  1219. * @param endDate
  1220. * @param type 0按周 1按月
  1221. * @return
  1222. */
  1223. @RequestMapping("/getTeamEduLine")
  1224. @ResponseBody
  1225. public String getTeamEduLine(@RequestParam(required = true) String teamCode,
  1226. @RequestParam(required = true) String startDate,
  1227. @RequestParam(required = true) String endDate,
  1228. @RequestParam(required = true) String type) {
  1229. try {
  1230. return write(200, "查询成功", "data", statisticsService.getTeamEduLine(teamCode, startDate, endDate, type));
  1231. } catch (Exception e) {
  1232. error(e);
  1233. return error(-1, "查询失败");
  1234. }
  1235. }
  1236. /**
  1237. * 获取团队健康
  1238. *
  1239. * @param teamCode
  1240. * @param startDate
  1241. * @param endDate
  1242. * @param type
  1243. * @return
  1244. */
  1245. @RequestMapping("/getTeamDoctorEduLine")
  1246. @ResponseBody
  1247. public String getTeamDoctorEduLine(@RequestParam(required = true) String teamCode,
  1248. @RequestParam(required = true) String startDate,
  1249. @RequestParam(required = true) String endDate,
  1250. @RequestParam(required = true) String type,
  1251. @RequestParam(required = true) String doctor) {
  1252. try {
  1253. return write(200, "查询成功", "data", statisticsService.getTeamDoctorEduLine(teamCode, startDate, endDate, type, doctor));
  1254. } catch (Exception e) {
  1255. error(e);
  1256. return error(-1, "查询失败");
  1257. }
  1258. }
  1259. /**
  1260. * 获取团队成员健康教育列表
  1261. *
  1262. * @param teamCode
  1263. * @param startDate
  1264. * @param endDate
  1265. * @param sort
  1266. * @param sortType
  1267. * @return
  1268. */
  1269. @RequestMapping("/getTeamEduList")
  1270. @ResponseBody
  1271. public String getTeamEduList(@RequestParam(required = true) String teamCode,
  1272. @RequestParam(required = true) String startDate,
  1273. @RequestParam(required = true) String endDate,
  1274. @RequestParam(required = true) String sort,
  1275. @RequestParam(required = true) String sortType) {
  1276. try {
  1277. return write(200, "查询成功", "data", statisticsService.getTeamEduList(teamCode, startDate, endDate, sort, sortType));
  1278. } catch (Exception e) {
  1279. error(e);
  1280. return error(-1, "查询失败");
  1281. }
  1282. }
  1283. @RequestMapping("/getTeamDoctorEduTitle")
  1284. @ResponseBody
  1285. public String getTeamDoctorEduTitle(@RequestParam(required = true) String teamCode,
  1286. @RequestParam(required = true) String startDate,
  1287. @RequestParam(required = true) String endDate,
  1288. @RequestParam(required = true) String doctor) {
  1289. try {
  1290. return write(200, "查询成功", "data", statisticsService.getTeamDoctorEduTitle(teamCode, startDate, endDate, doctor));
  1291. } catch (Exception e) {
  1292. error(e);
  1293. return error(-1, "查询失败");
  1294. }
  1295. }
  1296. @RequestMapping("/getDotorInfo")
  1297. @ResponseBody
  1298. public String getDotorInfo(String code) {
  1299. try {
  1300. return write(200, "查询成功", "data", statisticsService.getDoctorInfo(code));
  1301. } catch (Exception e) {
  1302. error(e);
  1303. return error(-1, "查询失败");
  1304. }
  1305. }
  1306. /**
  1307. * 获取转签率和续签率
  1308. * 前端:续签进展
  1309. *
  1310. * @param level 等级 4 市 3区 2社区 1团队
  1311. * @param code 市 默认是厦门市 350200 区 就是区的code 社区就是社区的code 团队就是团队的code
  1312. * @param year 年份 非比传
  1313. * @return
  1314. */
  1315. @RequestMapping(value = "/getRenewPercentAndChangePercent", method = RequestMethod.GET)
  1316. @ResponseBody
  1317. public String getRenewPercentAndChangePercent(
  1318. @RequestParam(required = true) String level,
  1319. @RequestParam(required = true) String code,
  1320. @RequestParam(required = false) String year) {
  1321. try {
  1322. return write(200, "查询成功", "data", statisticsService.getRenewPercentAndChangePercent(level, code, year));
  1323. } catch (Exception e) {
  1324. error(e);
  1325. return error(-1, "查询失败");
  1326. }
  1327. }
  1328. /**
  1329. * 获取转签人数,转签原因分析,转签分布
  1330. * 前端:签约数据分析,团队转签详情
  1331. *
  1332. * @param level 等级 4 市 3区 2社区 1团队
  1333. * @param code 市 默认是厦门市 350200 区 就是区的code 社区就是社区的code 团队就是团队的code
  1334. * @param year 年份 非比传
  1335. * @return
  1336. */
  1337. @RequestMapping(value = "/getRenewAnalysis", method = RequestMethod.GET)
  1338. @ResponseBody
  1339. public String getRenewAnalysis(
  1340. @RequestParam(required = true) String level,
  1341. @RequestParam(required = true) String code,
  1342. @RequestParam(required = false) String year) {
  1343. try {
  1344. return write(200, "查询成功", "data", statisticsService.getRenewAnalysis(level, code, year));
  1345. } catch (Exception e) {
  1346. error(e);
  1347. return error(-1, "查询失败");
  1348. }
  1349. }
  1350. @RequestMapping("/getTeamRenewChangeLine")
  1351. @ResponseBody
  1352. public String getTeamRenewChangeLine(@RequestParam(required = true)String teamCode,
  1353. @RequestParam(required = true)String startDate,
  1354. @RequestParam(required = true)String endDate,
  1355. @RequestParam(required = true)String type){
  1356. try {
  1357. return write(200, "查询成功", "data", statisticsService.getTeamRenewChangeLine(teamCode,startDate,endDate,type));
  1358. } catch (Exception e) {
  1359. error(e);
  1360. return error(-1, "查询失败");
  1361. }
  1362. }
  1363. }