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