StatisticsController.java 61 KB

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