StatisticsController.java 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543
  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. //sort=1&date=2017-07-13&level=4&index=17&area=350200&lowLevel=1&lowCode=3
  476. result.put("index_" + index, statisticsAllService.getLevelTwoLowLevelTotalTeamLeader(date, area, level, index, sort, lowLevel, lowCode,year));
  477. } else {
  478. result.put("index_" + index, statisticsAllService.getLevelTwoLowLevelTotal(date, area, level, index, sort, lowLevel, lowCode,year));
  479. }
  480. } else {
  481. // 未指定level下特定查询级别
  482. for (String idx : indexes) {
  483. if (idx.equals("18") || index.equals("19")) {
  484. result.put("index_" + idx, statisticsAllService.getLowLevelTotalSpecial(date, area, level, idx, sort, lowLevel));
  485. } else if ( index.equals("21")) {
  486. result.put("index_" + idx, statisticsAllService.getLowLevelTotal2(date, area, level, idx, sort, lowLevel));
  487. } else if (idx.equals("28")) {
  488. //level=4&area=350200&sort=1&index=28&date=undefined&lowLevel=2
  489. result.put("index_" + idx, statisticsService.getAvgAllInfo(level, area, lowLevel));
  490. } else if (idx.equals("13")) {
  491. // sort=1&date=2017-07-13&level=4&index=13&area=350200&lowCode=
  492. result.put("index_" + idx, statisticsAllService.getLowLevelTotalTeamLeader(date, area, level, idx, sort, lowLevel,year));
  493. } else {
  494. result.put("index_" + idx, statisticsAllService.getLowLevelTotal(date, area, level, idx, sort, lowLevel,year));
  495. }
  496. }
  497. }
  498. return write(200, "查询成功", "data", result);
  499. } catch (Exception e) {
  500. e.printStackTrace();
  501. return error(-1, "查询失败");
  502. }
  503. }
  504. /**
  505. * 获取三师转签或高危人群
  506. *
  507. * @param endDate
  508. * @param area
  509. * @param level
  510. * @return
  511. */
  512. @RequestMapping(value = "/sszq_qwrq_info")
  513. @ResponseBody
  514. public String getSszqAndGwrq(@RequestParam(required = true) String endDate,
  515. @RequestParam(required = true) String area,
  516. @RequestParam(required = true) int level) {
  517. try {
  518. JSONObject result = new JSONObject();
  519. JSONObject sszq = statisticsAllService.getSszqAndGwrq(endDate, area, level, "18");
  520. JSONObject gwrq = statisticsAllService.getSszqAndGwrq(endDate, area, level, "19");
  521. result.put("sszq", sszq);
  522. result.put("gwrq", gwrq);
  523. return write(200, "查询成功", "data", result);
  524. } catch (Exception e) {
  525. e.printStackTrace();
  526. return error(-1, "查询失败");
  527. }
  528. }
  529. /**
  530. * 指标截止日期 到达量
  531. *
  532. * @param endDate
  533. * @param area
  534. * @param level
  535. * @param index
  536. * @return
  537. */
  538. @RequestMapping("/index_all")
  539. @ResponseBody
  540. public String getIndexAll(@RequestParam(required = true) String endDate,
  541. @RequestParam(required = true) String area,
  542. @RequestParam(required = true) int level,
  543. @RequestParam(required = true) String index,
  544. @RequestParam(required = false) String year) {
  545. try {
  546. String[] indexes = index.split(",");
  547. JSONObject result = new JSONObject();
  548. for (String idx : indexes) {
  549. // if((idx.equals("21"))||(idx.equals("20"))){
  550. // //如果是21或者20的指标 默认找最新的日期
  551. // endDate= DateUtil.getStringDate("yyyy-MM-dd");
  552. // }
  553. Long total = statisticsAllService.getIndexTotal(endDate, area, level, idx);
  554. // super.infoMessage("原来的总数:" + total);
  555. //如果year不为空 那么因为是到达量 所以要加上一年的数据 21和20的指标不安年度统计 所以不用累加
  556. // if (!org.springframework.util.StringUtils.isEmpty(year) && !"2016".equals(year)&&!(idx.equals("21")||(idx.equals("20")))) {
  557. // //得到上一个年份的的最后一天的统计数据
  558. // String date = year + "-06-30";//固定是 6月三十号 为一个年份的最后一天,如果是2017年份 那么就是2017-7-1 到 2018-6-30
  559. // WlyyQuotaResult wlyyQuotaResult = statisticsService.findOneQuotaResult(date, level, idx, area);
  560. // if (wlyyQuotaResult != null) {
  561. // super.infoMessage("需要添加的数目:" + wlyyQuotaResult.getResult());
  562. // total = total + Long.valueOf(wlyyQuotaResult.getResult());
  563. // }
  564. // }
  565. result.put("index_" + idx, total);
  566. }
  567. return write(200, "查询成功", "data", result);
  568. } catch (Exception e) {
  569. e.printStackTrace();
  570. return error(-1, "查询失败");
  571. }
  572. }
  573. /**
  574. * 咨询统计
  575. * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
  576. * ①回复及时率------医生首次回复24小时内比例
  577. * ②未回复数(数、率)----------当前未回复咨询数、以及相应比例
  578. * ③处理咨询回复时间分布---------全部咨询的首次回复咨询时间分布
  579. *
  580. * @param level 查询的等级,按市、区、机构
  581. * @param area 查询的等级对应Code
  582. * @return
  583. */
  584. @RequestMapping("/Consulting_Stat")
  585. @ResponseBody
  586. public String getConsultingStatistics(@RequestParam(required = true) Integer level,
  587. @RequestParam(required = true) String area) {
  588. try {
  589. return write(200, "查询成功", "data", statisticsService.getConsultingStatistics(level, area));
  590. } catch (Exception e) {
  591. return error(-1, "查询失败");
  592. }
  593. }
  594. /**
  595. * 咨询统计
  596. * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
  597. * ①回复及时率------医生首次回复24小时内比例
  598. * ②未回复数(数、率)----------当前未回复咨询数、以及相应比例
  599. * ③处理咨询回复时间分布---------全部咨询的首次回复咨询时间分布
  600. *
  601. * @param level 查询的等级,按市、区、机构
  602. * @return
  603. */
  604. @RequestMapping("/Consulting_StatList")
  605. @ResponseBody
  606. public String getConsultingStatisticsList(@RequestParam(required = true) Integer level,
  607. @RequestParam(required = true) String area,
  608. @RequestParam(required = false) String lowlevel,
  609. @RequestParam(required = false) String year) {
  610. try {
  611. JSONObject data = null;
  612. if (Constant.getNowYear().equals(year)) {
  613. data = statisticsService.getConsultingStatisticsList(level, area, lowlevel);
  614. } else if (org.springframework.util.StringUtils.isEmpty(year)) {
  615. data = statisticsService.getConsultingStatisticsListAll(level, area, lowlevel, year);
  616. } else {
  617. data = statisticsService.getConsultingStatisticsListYear(level, area, lowlevel, year);
  618. }
  619. if (data != null) {
  620. return write(200, "查询成功", "data", data);
  621. } else {
  622. return error(-1, "查询失败");
  623. }
  624. } catch (Exception e) {
  625. e.printStackTrace();
  626. return error(-1, "查询失败");
  627. }
  628. }
  629. /**
  630. * 咨询统计
  631. * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
  632. * ①回复及时率------医生首次回复24小时内比例
  633. * ②未回复数(数、率)----------当前未回复咨询数、以及相应比例
  634. * ③处理咨询回复时间分布---------全部咨询的首次回复咨询时间分布
  635. *
  636. * @param level 查询的等级,按市、区、机构
  637. * @return
  638. */
  639. @RequestMapping("/Consulting_Title")
  640. @ResponseBody
  641. public String getConsultingTitle(@RequestParam(required = true) Integer level,
  642. @RequestParam(required = true) String area,
  643. @RequestParam(required = false) String year) {
  644. try {
  645. JSONObject data = null;
  646. if (Constant.getNowYear().equals(year)) {
  647. //查今年的查找redis即可
  648. data = statisticsService.getConsultingTitle(level, area);
  649. } else if (org.springframework.util.StringUtils.isEmpty(year)) {
  650. //为空默认查询全部
  651. //查找redis的然后再添加去年年度的
  652. data = statisticsService.getConsultingTitleAll(level, area, year);
  653. } else {
  654. //去数据库查找年份
  655. data = statisticsService.getConsultingTitleWithYear(level, area, year);
  656. }
  657. if (data != null) {
  658. return write(200, "查询成功", "data", data);
  659. } else {
  660. return error(-1, "查询失败");
  661. }
  662. } catch (Exception e) {
  663. e.printStackTrace();
  664. return error(-1, "查询失败");
  665. }
  666. }
  667. /**
  668. * 获取回复数时间分布数
  669. *
  670. * @param level
  671. * @param area
  672. * @return
  673. */
  674. @RequestMapping("/getCoutListByTime")
  675. @ResponseBody
  676. public String getCoutListByTime(
  677. @RequestParam(required = true) String level,
  678. @RequestParam(required = true) String area,
  679. @RequestParam(required = false) String year) {
  680. try {
  681. if (Constant.getNowYear().equals(year)) {
  682. return write(200, "查询成功", "data", statisticsService.getCoutListByTime(level, area));
  683. } else if (org.springframework.util.StringUtils.isEmpty(year)) {
  684. return write(200, "查询成功", "data", statisticsService.getCoutListByTimeAll(level, area));
  685. } else {
  686. return write(200, "查询成功", "data", statisticsService.getCoutListByTimeYear(level, area, year));
  687. }
  688. } catch (Exception e) {
  689. e.printStackTrace();
  690. return error(-1, "查询失败");
  691. }
  692. }
  693. /**
  694. * 获取绑定率
  695. * 1、选定绑定微信指标,下面排行内,在绑定微信数后新增:"绑定率:xx.22%"
  696. * 2、绑定率=绑定数/已签约数
  697. *
  698. * @return
  699. */
  700. @RequestMapping("/bindingRate_stat")
  701. @ResponseBody
  702. public String getBindingRate() {
  703. try {
  704. return write(200, "查询成功", "data", statisticsService.getBindingRate());
  705. } catch (Exception e) {
  706. e.printStackTrace();
  707. return error(-1, "查询失败");
  708. }
  709. }
  710. /**
  711. * 获取得分平均数
  712. *
  713. * @param level
  714. * @param area
  715. * @return
  716. */
  717. @RequestMapping("/getAVGSocre")
  718. @ResponseBody
  719. public String getAVGSocre(@RequestParam(required = true) String level, @RequestParam(required = true) String area) {
  720. try {
  721. return write(200, "查询成功", "data", statisticsService.getAVGSocre(level, area));
  722. } catch (Exception e) {
  723. e.printStackTrace();
  724. return error(-1, "查询失败");
  725. }
  726. }
  727. /**
  728. * 获取得分平均数按月份
  729. *
  730. * @return
  731. */
  732. @RequestMapping("/getAVGSocreByMonth")
  733. @ResponseBody
  734. public String getAVGSocreByMonth(@RequestParam(required = true) String level,
  735. @RequestParam(required = true) String area,
  736. @RequestParam(required = true) String statDate,
  737. @RequestParam(required = true) String endDate) {
  738. try {
  739. return write(200, "查询成功", "data", statisticsService.getAVGSocreByMonth(level, area, statDate, endDate));
  740. } catch (Exception e) {
  741. error(e);
  742. return error(-1, "查询失败");
  743. }
  744. }
  745. /**
  746. * 统计当前团队,签约人数,服务次数,平均满意度
  747. *
  748. * @return
  749. */
  750. @RequestMapping("/getStatTitleInfo")
  751. @ResponseBody
  752. public String getStatTitleInfo(@RequestParam(required = true) String startDate,
  753. @RequestParam(required = true) String endDate) {
  754. try {
  755. return write(200, "查询成功", "data", statisticsService.getStatTitleInfo(getUID(), startDate, endDate));
  756. //return write(200, "查询成功", "data", statisticsService.getStatTitleInfo("zbqD201703150228",startDate,endDate));
  757. } catch (Exception e) {
  758. error(e);
  759. return error(-1, "查询失败");
  760. }
  761. }
  762. /**
  763. * 获取签约折线图
  764. *
  765. * @param startDate
  766. * @param endDate
  767. * @param signType 0 签约,1 续签
  768. * @param type 0 按周,1 按月
  769. * @return
  770. */
  771. @RequestMapping("/getSignCountLineByType")
  772. @ResponseBody
  773. public String getSignCountLineByType(@RequestParam(required = true) String startDate,
  774. @RequestParam(required = true) String endDate,
  775. @RequestParam(required = true) String signType,
  776. @RequestParam(required = true) String type) {
  777. try {
  778. //判断是签约还是续签
  779. if ("0".equals(signType)) {
  780. return write(200, "查询成功", "data", statisticsService.getSignCountLineByType(getUID(), type, startDate, endDate));
  781. //return write(200, "查询成功", "data", statisticsService.getSignCountLineByType("xh1D201703150222",type,startDate,endDate));
  782. } else {
  783. return write(200, "查询成功", "data", statisticsService.getRenewCountLineByType(getUID(), type, startDate, endDate));
  784. //return write(200, "查询成功", "data", statisticsService.getRenewCountLineByType("xh1D201703150222",type,startDate,endDate));
  785. }
  786. } catch (Exception e) {
  787. error(e);
  788. return error(-1, "查询失败");
  789. }
  790. }
  791. /**
  792. * 获取咨询数和未回复数
  793. *
  794. * @param startDate
  795. * @param endDate
  796. * @param isNow 1 为当前;2为非当前
  797. * @return
  798. */
  799. @RequestMapping("/getReyStatbyTeam")
  800. @ResponseBody
  801. public String getReyStatbyTeam(@RequestParam(required = true) String startDate,
  802. @RequestParam(required = true) String endDate,
  803. @RequestParam(required = true) String isNow) {
  804. try {
  805. return write(200, "查询成功", "data", statisticsService.getReyStatbyTeamNow(getUID(), startDate, endDate, isNow));
  806. //return write(200, "查询成功", "data", statisticsService.getReyStatbyTeamNow("zbqD201703150228",startDate,endDate,isNow));
  807. } catch (Exception e) {
  808. error(e);
  809. return error(-1, "查询失败");
  810. }
  811. }
  812. /**
  813. * 获取机构内服务排行
  814. *
  815. * @param startDate
  816. * @param endDate
  817. * @return
  818. */
  819. @RequestMapping("/getServiceRankingList")
  820. @ResponseBody
  821. public String getServiceRankingList(@RequestParam(required = true) String startDate,
  822. @RequestParam(required = true) String endDate) {
  823. try {
  824. return write(200, "查询成功", "data", statisticsService.getServiceRankingList(getUID(), startDate, endDate));
  825. //return write(200, "查询成功", "data", statisticsService.getServiceRankingList("xh1D201703150222",startDate,endDate));
  826. } catch (Exception e) {
  827. error(e);
  828. return error(-1, "查询失败");
  829. }
  830. }
  831. /**
  832. * 获取平均值统计折线图
  833. *
  834. * @param startDate
  835. * @param endDate
  836. * @param type 0周,1月
  837. * @return
  838. */
  839. @RequestMapping("/getAvgLine")
  840. @ResponseBody
  841. public String getAvgLine(@RequestParam(required = true) String startDate,
  842. @RequestParam(required = true) String endDate,
  843. @RequestParam(required = true) String type) {
  844. try {
  845. return write(200, "查询成功", "data", statisticsService.getAvgLine(getUID(), startDate, endDate, type));
  846. // return write(200, "查询成功", "data", statisticsService.getAvgLine("xh1D201703150222",startDate,endDate,type));
  847. } catch (Exception e) {
  848. error(e);
  849. return error(-1, "查询失败");
  850. }
  851. }
  852. /**
  853. * 判断团队是否是团队长
  854. *
  855. * @return
  856. */
  857. @RequestMapping("/checkDoctorIsTeamLeder")
  858. @ResponseBody
  859. public String checkDoctorIsTeamLeder() {
  860. try {
  861. return write(200, "查询成功", "data", statisticsService.checkDoctorIsTeamleader(getUID()));
  862. } catch (Exception e) {
  863. error(e);
  864. return error(-1, "查询失败");
  865. }
  866. }
  867. /**
  868. * 获取团队月或周咨询未回复和总数折线图
  869. *
  870. * @param teamCode 团队id
  871. * @param startDate
  872. * @param endDate
  873. * @param type 0周,1月
  874. * @return
  875. */
  876. @RequestMapping("/getTeamConsultCount")
  877. @ResponseBody
  878. public String getTeamConsultCount(@RequestParam(required = true) String teamCode,
  879. @RequestParam(required = true) String startDate,
  880. @RequestParam(required = true) String endDate,
  881. @RequestParam(required = true) String type) {
  882. try {
  883. return write(200, "查询成功", "data", statisticsService.getTeamConsultCount(teamCode, startDate, endDate, type));
  884. } catch (Exception e) {
  885. error(e);
  886. return error(-1, "查询失败");
  887. }
  888. }
  889. /**
  890. * 计算团队医生月或周咨询未回复和总数折线图
  891. *
  892. * @param teamCode
  893. * @param startDate
  894. * @param endDate
  895. * @param type 0周,1月
  896. * @param doctor
  897. * @return
  898. */
  899. @RequestMapping("/getTeamDoctorConsultCount")
  900. @ResponseBody
  901. public String getTeamDoctorConsultCount(@RequestParam(required = true) String teamCode,
  902. @RequestParam(required = true) String startDate,
  903. @RequestParam(required = true) String endDate,
  904. @RequestParam(required = true) String type,
  905. @RequestParam(required = true) String doctor) {
  906. try {
  907. return write(200, "查询成功", "data", statisticsService.getTeamDoctorConsultCount(teamCode, startDate, endDate, type, doctor));
  908. } catch (Exception e) {
  909. error(e);
  910. return error(-1, "查询失败");
  911. }
  912. }
  913. /**
  914. * 获取团队内这成员,未回复数,总数,结束咨询数
  915. *
  916. * @param teamCode
  917. * @param startDate
  918. * @param endDate
  919. * @param sort 0降序,1升序
  920. * @return
  921. */
  922. @RequestMapping("/getMemberConsultList")
  923. @ResponseBody
  924. public String getMemberConsultList(@RequestParam(required = true) String teamCode,
  925. @RequestParam(required = true) String startDate,
  926. @RequestParam(required = true) String endDate,
  927. @RequestParam(required = true) String sort,
  928. @RequestParam(required = true) String sortType) {
  929. try {
  930. return write(200, "查询成功", "data", statisticsService.getMemberConsultList(teamCode, startDate, endDate, sort, sortType));
  931. } catch (Exception e) {
  932. error(e);
  933. return error(-1, "查询失败");
  934. }
  935. }
  936. /**
  937. * 获取Doctor咨询结果
  938. *
  939. * @param doctor
  940. * @param teamCode
  941. * @param startDate
  942. * @param endDate
  943. * @return
  944. */
  945. @RequestMapping("/getDoctorConsultTitle")
  946. @ResponseBody
  947. public String getDoctorConsultTitle(@RequestParam(required = true) String doctor,
  948. @RequestParam(required = true) String teamCode,
  949. @RequestParam(required = true) String startDate,
  950. @RequestParam(required = true) String endDate) {
  951. try {
  952. return write(200, "查询成功", "data", statisticsService.getDoctorConsultTitle(doctor, teamCode, startDate, endDate));
  953. } catch (Exception e) {
  954. error(e);
  955. return error(-1, "查询失败");
  956. }
  957. }
  958. /**
  959. * 获取团队随访量折线统计图
  960. *
  961. * @param type
  962. * @param teamCode
  963. * @param startDate
  964. * @param endDate
  965. * @return
  966. */
  967. @RequestMapping("/getTeamFollowupLine")
  968. @ResponseBody
  969. public String getTeamFollowupLine(@RequestParam(required = true) String type,
  970. @RequestParam(required = true) String teamCode,
  971. @RequestParam(required = true) String startDate,
  972. @RequestParam(required = true) String endDate) {
  973. try {
  974. return write(200, "查询成功", "data", statisticsService.getTeamFollowupLine(teamCode, startDate, endDate, type));
  975. } catch (Exception e) {
  976. error(e);
  977. return error(-1, "查询失败");
  978. }
  979. }
  980. @RequestMapping("/getTeamDoctorFollowupLine")
  981. @ResponseBody
  982. public String getTeamDoctorFollowupLine(@RequestParam(required = true) String type,
  983. @RequestParam(required = true) String teamCode,
  984. @RequestParam(required = true) String startDate,
  985. @RequestParam(required = true) String endDate,
  986. @RequestParam(required = true) String doctor) {
  987. try {
  988. return write(200, "查询成功", "data", statisticsService.getTeamDoctorFollowupLine(teamCode, startDate, endDate, type, doctor));
  989. } catch (Exception e) {
  990. error(e);
  991. return error(-1, "查询失败");
  992. }
  993. }
  994. /**
  995. * 根据团队获取团队底下用户列表
  996. *
  997. * @param sort 0为降序,1为升序
  998. * @param teamCode
  999. * @param startDate
  1000. * @param endDate
  1001. * @param sortType 0为总数排序,1为增量排序,2为计划中排序
  1002. * @return
  1003. */
  1004. @RequestMapping("/getDoctorTeamFolList")
  1005. @ResponseBody
  1006. public String getDoctorTeamFolList(@RequestParam(required = true) String sort,
  1007. @RequestParam(required = true) String teamCode,
  1008. @RequestParam(required = true) String startDate,
  1009. @RequestParam(required = true) String endDate,
  1010. @RequestParam(required = true) String sortType) {
  1011. try {
  1012. return write(200, "查询成功", "data", statisticsService.getDoctorTeamFolList(startDate, endDate, teamCode, sort, sortType));
  1013. } catch (Exception e) {
  1014. error(e);
  1015. return error(-1, "查询失败");
  1016. }
  1017. }
  1018. /**
  1019. * 获取医生随访头信息
  1020. *
  1021. * @param teamCode
  1022. * @param doctor
  1023. * @param startDate
  1024. * @param endDate
  1025. * @return
  1026. */
  1027. @RequestMapping("/getTeamDoctorFolTitle")
  1028. @ResponseBody
  1029. public String getTeamDoctorFolTitle(@RequestParam(required = true) String teamCode,
  1030. @RequestParam(required = true) String doctor,
  1031. @RequestParam(required = true) String startDate,
  1032. @RequestParam(required = true) String endDate) {
  1033. try {
  1034. return write(200, "查询成功", "data", statisticsService.getTeamDoctorFolTitle(teamCode, doctor, startDate, endDate));
  1035. } catch (Exception e) {
  1036. error(e);
  1037. return error(-1, "查询失败");
  1038. }
  1039. }
  1040. /**
  1041. * 获取待预约量团队统计则线图
  1042. *
  1043. * @param teamCode
  1044. * @param type
  1045. * @param startDate
  1046. * @param endDate
  1047. * @return
  1048. */
  1049. @RequestMapping("/getTeamResLine")
  1050. @ResponseBody
  1051. public String getTeamResLine(@RequestParam(required = true) String teamCode,
  1052. @RequestParam(required = true) String type,
  1053. @RequestParam(required = true) String startDate,
  1054. @RequestParam(required = true) String endDate) {
  1055. try {
  1056. return write(200, "查询成功", "data", statisticsService.getTeamResLine(teamCode, startDate, endDate, type));
  1057. } catch (Exception e) {
  1058. error(e);
  1059. return error(-1, "查询失败");
  1060. }
  1061. }
  1062. /**
  1063. * 获取团队医生预约量团队统计则线图
  1064. *
  1065. * @param teamCode
  1066. * @param type
  1067. * @param startDate
  1068. * @param endDate
  1069. * @param doctor
  1070. * @return
  1071. */
  1072. @RequestMapping("/getTeamDoctorResLine")
  1073. @ResponseBody
  1074. public String getTeamDoctorResLine(@RequestParam(required = true) String teamCode,
  1075. @RequestParam(required = true) String type,
  1076. @RequestParam(required = true) String startDate,
  1077. @RequestParam(required = true) String endDate,
  1078. @RequestParam(required = true) String doctor) {
  1079. try {
  1080. return write(200, "查询成功", "data", statisticsService.getTeamDoctorResLine(teamCode, startDate, endDate, type, doctor));
  1081. } catch (Exception e) {
  1082. error(e);
  1083. return error(-1, "查询失败");
  1084. }
  1085. }
  1086. /**
  1087. * 获取团队待预约量医生列表信息
  1088. *
  1089. * @param teamCode
  1090. * @param startDate
  1091. * @param endDate
  1092. * @param sort 0为降序,1为升序
  1093. * @param sortType 0为按总数,1为按增数
  1094. * @return
  1095. */
  1096. @RequestMapping("/getTeamDoctorResList")
  1097. @ResponseBody
  1098. public String getTeamDoctorResList(@RequestParam(required = true) String teamCode,
  1099. @RequestParam(required = true) String startDate,
  1100. @RequestParam(required = true) String endDate,
  1101. @RequestParam(required = true) String sort,
  1102. @RequestParam(required = true) String sortType) {
  1103. try {
  1104. return write(200, "查询成功", "data", statisticsService.getTeamDoctorResList(teamCode, startDate, endDate, sort, sortType));
  1105. } catch (Exception e) {
  1106. error(e);
  1107. return error(-1, "查询失败");
  1108. }
  1109. }
  1110. /**
  1111. * 获取团队医生待预信息
  1112. *
  1113. * @param teamCode
  1114. * @param doctor
  1115. * @param startDate
  1116. * @param endDate
  1117. * @return
  1118. */
  1119. @RequestMapping("/getTeamDoctorResTitle")
  1120. @ResponseBody
  1121. public String getTeamDoctorResTitle(@RequestParam(required = true) String teamCode,
  1122. @RequestParam(required = true) String doctor,
  1123. @RequestParam(required = true) String startDate,
  1124. @RequestParam(required = true) String endDate) {
  1125. try {
  1126. return write(200, "查询成功", "data", statisticsService.getTeamDoctorResTitle(teamCode, doctor, startDate, endDate));
  1127. } catch (Exception e) {
  1128. error(e);
  1129. return error(-1, "查询失败");
  1130. }
  1131. }
  1132. /**
  1133. * 获取团队健康指导折线图
  1134. *
  1135. * @param teamCode
  1136. * @param startDate
  1137. * @param endDate
  1138. * @param type 0周,1月
  1139. * @return
  1140. */
  1141. @RequestMapping("/getTeamGuidLine")
  1142. @ResponseBody
  1143. public String getTeamGuidLine(@RequestParam(required = true) String teamCode,
  1144. @RequestParam(required = true) String startDate,
  1145. @RequestParam(required = true) String endDate,
  1146. @RequestParam(required = true) String type) {
  1147. try {
  1148. return write(200, "查询成功", "data", statisticsService.getTeamGuidLine(teamCode, startDate, endDate, type));
  1149. } catch (Exception e) {
  1150. error(e);
  1151. return error(-1, "查询失败");
  1152. }
  1153. }
  1154. /**
  1155. * 获取团队医生则线图
  1156. *
  1157. * @param teamCode
  1158. * @param startDate
  1159. * @param endDate
  1160. * @param type
  1161. * @param doctor
  1162. * @return
  1163. */
  1164. @RequestMapping("/getTeamDoctorGuidLine")
  1165. @ResponseBody
  1166. public String getTeamDoctorGuidLine(@RequestParam(required = true) String teamCode,
  1167. @RequestParam(required = true) String startDate,
  1168. @RequestParam(required = true) String endDate,
  1169. @RequestParam(required = true) String type,
  1170. @RequestParam(required = true) String doctor) {
  1171. try {
  1172. return write(200, "查询成功", "data", statisticsService.getTeamDoctorGuidLine(teamCode, startDate, endDate, type, doctor));
  1173. } catch (Exception e) {
  1174. error(e);
  1175. return error(-1, "查询失败");
  1176. }
  1177. }
  1178. /**
  1179. * 获取团队指导总数List
  1180. *
  1181. * @param teamCode
  1182. * @param startDate
  1183. * @param endDate
  1184. * @param sort
  1185. * @param sortType
  1186. * @return
  1187. */
  1188. @RequestMapping("/getTeamGuidList")
  1189. @ResponseBody
  1190. public String getTeamGuidList(@RequestParam(required = true) String teamCode,
  1191. @RequestParam(required = true) String startDate,
  1192. @RequestParam(required = true) String endDate,
  1193. @RequestParam(required = true) String sort,
  1194. @RequestParam(required = true) String sortType) {
  1195. try {
  1196. return write(200, "查询成功", "data", statisticsService.getTeamGuidList(teamCode, startDate, endDate, sort, sortType));
  1197. } catch (Exception e) {
  1198. error(e);
  1199. return error(-1, "查询失败");
  1200. }
  1201. }
  1202. /**
  1203. * 获取医生健康指导头部信息
  1204. *
  1205. * @param teamCode
  1206. * @param doctor
  1207. * @param startDate
  1208. * @param endDate
  1209. * @return
  1210. */
  1211. @RequestMapping("/getTeamDoctorGuiTitle")
  1212. @ResponseBody
  1213. public String getTeamDoctorGuiTitle(@RequestParam(required = true) String teamCode,
  1214. @RequestParam(required = true) String doctor,
  1215. @RequestParam(required = true) String startDate,
  1216. @RequestParam(required = true) String endDate) {
  1217. try {
  1218. return write(200, "查询成功", "data", statisticsService.getTeamDoctorGuiTitle(teamCode, doctor, startDate, endDate));
  1219. } catch (Exception e) {
  1220. error(e);
  1221. return error(-1, "查询失败");
  1222. }
  1223. }
  1224. /**
  1225. * 获取团队健康教育折线统计
  1226. *
  1227. * @param teamCode
  1228. * @param startDate
  1229. * @param endDate
  1230. * @param type 0按周 1按月
  1231. * @return
  1232. */
  1233. @RequestMapping("/getTeamEduLine")
  1234. @ResponseBody
  1235. public String getTeamEduLine(@RequestParam(required = true) String teamCode,
  1236. @RequestParam(required = true) String startDate,
  1237. @RequestParam(required = true) String endDate,
  1238. @RequestParam(required = true) String type) {
  1239. try {
  1240. return write(200, "查询成功", "data", statisticsService.getTeamEduLine(teamCode, startDate, endDate, type));
  1241. } catch (Exception e) {
  1242. error(e);
  1243. return error(-1, "查询失败");
  1244. }
  1245. }
  1246. /**
  1247. * 获取团队健康
  1248. *
  1249. * @param teamCode
  1250. * @param startDate
  1251. * @param endDate
  1252. * @param type
  1253. * @return
  1254. */
  1255. @RequestMapping("/getTeamDoctorEduLine")
  1256. @ResponseBody
  1257. public String getTeamDoctorEduLine(@RequestParam(required = true) String teamCode,
  1258. @RequestParam(required = true) String startDate,
  1259. @RequestParam(required = true) String endDate,
  1260. @RequestParam(required = true) String type,
  1261. @RequestParam(required = true) String doctor) {
  1262. try {
  1263. return write(200, "查询成功", "data", statisticsService.getTeamDoctorEduLine(teamCode, startDate, endDate, type, doctor));
  1264. } catch (Exception e) {
  1265. error(e);
  1266. return error(-1, "查询失败");
  1267. }
  1268. }
  1269. /**
  1270. * 获取团队成员健康教育列表
  1271. *
  1272. * @param teamCode
  1273. * @param startDate
  1274. * @param endDate
  1275. * @param sort
  1276. * @param sortType
  1277. * @return
  1278. */
  1279. @RequestMapping("/getTeamEduList")
  1280. @ResponseBody
  1281. public String getTeamEduList(@RequestParam(required = true) String teamCode,
  1282. @RequestParam(required = true) String startDate,
  1283. @RequestParam(required = true) String endDate,
  1284. @RequestParam(required = true) String sort,
  1285. @RequestParam(required = true) String sortType) {
  1286. try {
  1287. return write(200, "查询成功", "data", statisticsService.getTeamEduList(teamCode, startDate, endDate, sort, sortType));
  1288. } catch (Exception e) {
  1289. error(e);
  1290. return error(-1, "查询失败");
  1291. }
  1292. }
  1293. @RequestMapping("/getTeamDoctorEduTitle")
  1294. @ResponseBody
  1295. public String getTeamDoctorEduTitle(@RequestParam(required = true) String teamCode,
  1296. @RequestParam(required = true) String startDate,
  1297. @RequestParam(required = true) String endDate,
  1298. @RequestParam(required = true) String doctor) {
  1299. try {
  1300. return write(200, "查询成功", "data", statisticsService.getTeamDoctorEduTitle(teamCode, startDate, endDate, doctor));
  1301. } catch (Exception e) {
  1302. error(e);
  1303. return error(-1, "查询失败");
  1304. }
  1305. }
  1306. @RequestMapping("/getDotorInfo")
  1307. @ResponseBody
  1308. public String getDotorInfo(String code) {
  1309. try {
  1310. return write(200, "查询成功", "data", statisticsService.getDoctorInfo(code));
  1311. } catch (Exception e) {
  1312. error(e);
  1313. return error(-1, "查询失败");
  1314. }
  1315. }
  1316. /**
  1317. * 获取转签率和续签率
  1318. * 前端:续签进展
  1319. *
  1320. * @param index 42,43,44
  1321. * @param level 等级 4 市 3区 2社区 1团队
  1322. * @param code 市 默认是厦门市 350200 区 就是区的code 社区就是社区的code 团队就是团队的code
  1323. * @param year 年份 非比传
  1324. * @return
  1325. */
  1326. @RequestMapping(value = "/getRenewPercentAndChangePercent", method = RequestMethod.GET)
  1327. @ResponseBody
  1328. public String getRenewPercentAndChangePercent(
  1329. @RequestParam(required = true) String index,//续签index
  1330. @RequestParam(required = true) String level,
  1331. @RequestParam(required = true) String code,
  1332. @RequestParam(required = false) String year) {
  1333. try {
  1334. return write(200, "查询成功", "data", statisticsService.getRenewPercentAndChangePercent(index,level, code, year));
  1335. } catch (Exception e) {
  1336. error(e);
  1337. return error(-1, "查询失败");
  1338. }
  1339. }
  1340. /**
  1341. * 获取转签人数,转签原因分析,转签分布
  1342. * 前端:签约数据分析,团队转签详情
  1343. *
  1344. * @param level 等级 4 市 3区 2社区 1团队
  1345. * @param code 市 默认是厦门市 350200 区 就是区的code 社区就是社区的code 团队就是团队的code
  1346. * @return
  1347. */
  1348. @RequestMapping(value = "/getRenewAnalysis", method = RequestMethod.GET)
  1349. @ResponseBody
  1350. public String getRenewAnalysis(
  1351. @RequestParam(required = true) String level,
  1352. @RequestParam(required = true) String code) {
  1353. try {
  1354. String switchIndex = "";
  1355. String switchIndexReson = "";
  1356. String signIn = "";
  1357. String signOut = "";
  1358. if ("1".equals(level)) {
  1359. //团队的转签人数
  1360. switchIndex = "35";
  1361. //团队的转签原因
  1362. switchIndexReson = "30";
  1363. //团队的签入
  1364. signIn = "34";
  1365. //团队的签出
  1366. signOut = "35";
  1367. } else if ("2".equals(level)) {
  1368. //社区的转签人数
  1369. switchIndex = "35";
  1370. //社区的转签原因
  1371. switchIndexReson = "30";
  1372. //社区的签入
  1373. signIn = "38";
  1374. //社区的签出
  1375. signOut = "39";
  1376. } else {
  1377. //区和市的转签人数
  1378. switchIndex = "35";
  1379. //区和市的转签原因
  1380. switchIndexReson = "30";
  1381. //区和市的签入
  1382. signIn = "40";
  1383. //区和市的签出
  1384. signOut = "41";
  1385. }
  1386. return write(200, "查询成功", "data", statisticsService.getRenewAnalysis(switchIndex, switchIndexReson, signIn, signOut, level, code));
  1387. } catch (Exception e) {
  1388. error(e);
  1389. return error(-1, "查询失败");
  1390. }
  1391. }
  1392. @RequestMapping("/getTeamRenewChangeLine")
  1393. @ResponseBody
  1394. public String getTeamRenewChangeLine(@RequestParam(required = true) String teamCode,
  1395. @RequestParam(required = true) String startDate,
  1396. @RequestParam(required = true) String endDate,
  1397. @RequestParam(required = true) String type) {
  1398. try {
  1399. return write(200, "查询成功", "data", statisticsService.getTeamRenewChangeLine(teamCode, startDate, endDate, type));
  1400. } catch (Exception e) {
  1401. error(e);
  1402. return error(-1, "查询失败");
  1403. }
  1404. }
  1405. /**
  1406. * 去年的签约量,续签量和续签率 列表
  1407. *
  1408. * @param index 42,43,44
  1409. * @param area 每个层级大的code 例如湖里区 350206 xx社区 3502060100
  1410. * @param level level1_type等级 1:团队 2社区机构 3区级 4市级
  1411. * @param sort 0:升序 1:降序
  1412. * @param lowLevel 只有可能是 1,2,3,不传默认是level-1
  1413. * @param year 不管根据当前时间找年度
  1414. * @return
  1415. */
  1416. @RequestMapping("/lowlevel_all_sign_renew")
  1417. @ResponseBody
  1418. public String getIndexLowLevelTotalSignAndRenew(
  1419. @RequestParam(required = true) String index,
  1420. @RequestParam(required = true) String area,
  1421. @RequestParam(required = true) int level,
  1422. @RequestParam(required = true) int sort,
  1423. @RequestParam(required = false) String lowLevel,
  1424. @RequestParam(required = false) String year) {
  1425. try {
  1426. JSONObject result = new JSONObject();
  1427. //如果年度是空,按当前时间计算是年度是属于那个年度
  1428. if (org.springframework.util.StringUtils.isEmpty(year)) {
  1429. year = Constant.getNowYear();
  1430. }
  1431. //lowLevel不传默认是 level-1
  1432. if (org.springframework.util.StringUtils.isEmpty(lowLevel)) {
  1433. lowLevel = level - 1 + "";
  1434. }
  1435. result.put("index_"+index, statisticsAllService.getLevelTwoLowLevelTotalSignAndRenew(area, level, index, sort, lowLevel, year));
  1436. return write(200, "查询成功", "data", result);
  1437. } catch (Exception e) {
  1438. e.printStackTrace();
  1439. return error(-1, "查询失败");
  1440. }
  1441. }
  1442. }