StatisticsController.java 60 KB

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