StatisticsController.java 61 KB

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