StatisticsController.java 61 KB

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