StatisticsController.java 60 KB

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