Commit c2b19a7e5ef09cafedd1f3170989c96030a7d01b
Exists in
master
and in
1 other branch
Merge remote-tracking branch 'origin/master'
Showing 2 changed files
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/StatisticsController.java
View file @
c2b19a7
... | ... | @@ -141,6 +141,7 @@ |
141 | 141 | series.setMapType("china"); |
142 | 142 | series.setRoam(false); |
143 | 143 | series.setData(dataList); |
144 | + series.setLabel(label); | |
144 | 145 | seriesList.add(series); |
145 | 146 | option.setSeries(seriesList); |
146 | 147 | |
... | ... | @@ -283,6 +284,226 @@ |
283 | 284 | ResultUtils.buildSuccessResultAndWrite(response, result); |
284 | 285 | } |
285 | 286 | |
287 | + // TYPE 省数据 | |
288 | + else if (type == 2) { | |
289 | + AreaDataQuery query = new AreaDataQuery(); | |
290 | + query.setProvinceId(pid); | |
291 | + // 地图数据 | |
292 | + List<AreaData> provinceRiskList = statisticsService.queryRisksByProvince(query); | |
293 | + List<AreaData> provincePatientList = statisticsService.queryPatientsByProvince(query); | |
294 | + Map<String, String> kvData = new HashMap<>(); | |
295 | + Map<String, Integer> mapsData = new HashMap<>(); | |
296 | + Map<String, String> riskColorMap = new HashMap<>(); | |
297 | + | |
298 | + Option areaBarOption = buildyBarOption("建档及高危人数", null); | |
299 | + areaBarOption.getLegend().getData().add("近30天建档人数"); | |
300 | + areaBarOption.getLegend().getData().add("当前高危总人数"); | |
301 | + areaBarOption.getLegend().setOrient("horizontal"); | |
302 | + areaBarOption.getLegend().setLeft("3%"); | |
303 | + areaBarOption.getLegend().setTop("55px"); | |
304 | + areaBarOption.getTooltip().setShow(true); | |
305 | + areaBarOption.getGrid().setTop("90px"); | |
306 | + List<Object> areaBarSeriesList = new ArrayList<>(); | |
307 | + Series patientSeries = new Series(); | |
308 | + patientSeries.setName("近30天建档人数"); | |
309 | + patientSeries.setType("bar"); | |
310 | + normal.setPosition("right"); | |
311 | + patientSeries.setLabel(label); | |
312 | + List<Object> patientDataList = new ArrayList<>(); | |
313 | + patientSeries.setData(patientDataList); | |
314 | + Series riskSeries = new Series(); | |
315 | + riskSeries.setName("当前高危总人数"); | |
316 | + riskSeries.setType("bar"); | |
317 | + riskSeries.setLabel(label); | |
318 | + List<Object> riskDataList = new ArrayList<>(); | |
319 | + riskSeries.setData(riskDataList); | |
320 | + areaBarSeriesList.add(riskSeries); | |
321 | + areaBarSeriesList.add(patientSeries); | |
322 | + areaBarOption.setSeries(areaBarSeriesList); | |
323 | + | |
324 | + for (AreaData areaData:provinceRiskList) { | |
325 | + String rigino = areaData.getCityName().replace("市", "").replace("省", ""); | |
326 | + if (mapsData.get(rigino) == null) { | |
327 | + mapsData.put(rigino, areaData.getVal()); | |
328 | + kvData.put(rigino, areaData.getProvinceId()); | |
329 | + } else { | |
330 | + mapsData.put(rigino, mapsData.get(rigino) + areaData.getVal()); | |
331 | + } | |
332 | + } | |
333 | + for (AreaData areaData:provincePatientList) { | |
334 | + String rigino = areaData.getProvinceName().replace("市", "").replace("省", ""); | |
335 | + if (mapsData.get(rigino) == null) { | |
336 | + riskDataList.add(0); | |
337 | + mapsData.put(rigino, areaData.getVal()); | |
338 | + kvData.put(rigino, areaData.getProvinceId()); | |
339 | + } else { | |
340 | + riskDataList.add(mapsData.get(rigino)); | |
341 | + mapsData.put(rigino, mapsData.get(rigino) + areaData.getVal()); | |
342 | + } | |
343 | + areaBarOption.getyAxis().getData().add(rigino); | |
344 | + patientDataList.add(areaData.getVal()); | |
345 | + } | |
346 | + | |
347 | + List<Object> dataList = new ArrayList<>(); | |
348 | + Set<String> set = mapsData.keySet(); | |
349 | + for (String key:set) { | |
350 | + Data data = new Data(); | |
351 | + data.setName(key); | |
352 | + data.setValue(mapsData.get(key)); | |
353 | + dataList.add(data); | |
354 | + } | |
355 | + | |
356 | + Option option = buildMapOption("孕妇建档数", null); | |
357 | + option.getLegend().setTop("50px"); | |
358 | + List<Object> seriesList = new ArrayList<>(); | |
359 | + Series series = new Series(); | |
360 | + series.setName("建档及高危数"); | |
361 | + series.setType("map"); | |
362 | + series.setMapType("china"); | |
363 | + series.setRoam(false); | |
364 | + series.setData(dataList); | |
365 | + series.setLabel(label); | |
366 | + seriesList.add(series); | |
367 | + option.setSeries(seriesList); | |
368 | + | |
369 | + | |
370 | + // 高危数据 | |
371 | + List<AreaData> currentRiskList = statisticsService.queryRisks(new AreaDataQuery()); | |
372 | + Option groupRiskOption = buildyBarOption("当前高危人数", null); | |
373 | + groupRiskOption.getTooltip().setShow(true); | |
374 | + List<Object> groupRiskSeriesList = new ArrayList<>(); | |
375 | + Series groupRiskSeries = new Series(); | |
376 | + groupRiskSeries.setName("高危人数"); | |
377 | + groupRiskSeries.setType("bar"); | |
378 | + mapsData.clear(); | |
379 | + for (AreaData areaData:currentRiskList) { | |
380 | + String groupName = areaData.getGroupName().replace("预警", ""); | |
381 | + if (mapsData.get(areaData.getRiskName()) == null) { | |
382 | + mapsData.put(areaData.getRiskName(),areaData.getVal()); | |
383 | + if (colormap.get(groupName) != null) { | |
384 | + riskColorMap.put(areaData.getRiskName(),colormap.get(groupName)); | |
385 | + } | |
386 | + } else { | |
387 | + mapsData.put(areaData.getRiskName(), mapsData.get(areaData.getRiskName()) + areaData.getVal()); | |
388 | + } | |
389 | + } | |
390 | + | |
391 | + // 按MAP的value排序 | |
392 | + List<Map.Entry<String, Integer>> listData = new ArrayList<Map.Entry<String, Integer>>(mapsData.entrySet()); | |
393 | + Collections.sort(listData, new Comparator<Map.Entry<String, Integer>>() { | |
394 | + public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) { | |
395 | + if (o2.getValue() != null && o1.getValue() != null && o2.getValue().compareTo(o1.getValue()) > 0) { | |
396 | + return -1; | |
397 | + } else { | |
398 | + return 1; | |
399 | + } | |
400 | + } | |
401 | + }); | |
402 | + | |
403 | + List<Object> groupRiskDataList = new ArrayList<>(); | |
404 | + int n = listData.size(); | |
405 | + for (Map.Entry<String, Integer> entry:listData) { | |
406 | + n--; | |
407 | + if (n>28) { | |
408 | + continue; | |
409 | + } | |
410 | + groupRiskOption.getyAxis().getData().add(entry.getKey()); | |
411 | + if (riskColorMap.containsKey(entry.getKey())) { | |
412 | + Data data = new Data(); | |
413 | + data.setValue(entry.getValue()); | |
414 | + data.setItemStyle(new ItemStyle(new Normal(true,riskColorMap.get(entry.getKey())),null)); | |
415 | + groupRiskDataList.add(data); | |
416 | + } else { | |
417 | + groupRiskDataList.add(entry.getValue()); | |
418 | + } | |
419 | + } | |
420 | + groupRiskSeries.setData(groupRiskDataList); | |
421 | + groupRiskSeriesList.add(groupRiskSeries); | |
422 | + groupRiskOption.setSeries(groupRiskSeriesList); | |
423 | + | |
424 | + Map<String, Map<String, Integer>> patientMonthMap = new HashMap<>(); | |
425 | + // 6. 按省或市或地区查询区域内近12个自然月每月产检中历史高危人数(按颜色分组) | |
426 | + query.setDays(12); | |
427 | + List<AreaData> riskMonthList = statisticsService.queryHrefYearRisks(query); | |
428 | + Map<String, Integer> rmap = new HashMap<>(); | |
429 | + for (AreaData areaData:riskMonthList) { | |
430 | + String month = buildMonth(areaData.getYear()); | |
431 | + if (rmap.containsKey(month)) { | |
432 | + rmap.put(month, rmap.get(month) + areaData.getVal()); | |
433 | + } else { | |
434 | + rmap.put(month, areaData.getVal()); | |
435 | + } | |
436 | + } | |
437 | + patientMonthMap.put("高危人数", rmap); | |
438 | + // 4. 按省或市或地区查询区域内近12个自然月每月建档人数 | |
439 | + query = new AreaDataQuery(); | |
440 | + List<AreaData> patientMonthList = statisticsService.queryMonthPatients(query); | |
441 | + Map<String, Integer> pmap = new HashMap<>(); | |
442 | + for (AreaData areaData:patientMonthList) { | |
443 | + String month = buildMonth(areaData.getYear()); | |
444 | + if (pmap.containsKey(month)) { | |
445 | + pmap.put(month, pmap.get(month) + areaData.getVal()); | |
446 | + } else { | |
447 | + pmap.put(month, areaData.getVal()); | |
448 | + } | |
449 | + } | |
450 | + patientMonthMap.put("建档人数", pmap); | |
451 | + Option patientMonthOption = buildLineOption("建档及高危人数", null, patientMonthMap, buildDefaultMonth(12)); | |
452 | + | |
453 | + // 按省或市或地区查询区域内近12个自然月每月初诊人数、复诊人数 | |
454 | + query = new AreaDataQuery(); | |
455 | + List<AreaData> reportMonthList = statisticsService.queryMonthReports(query); | |
456 | + Map<String, Map<String, Integer>> reportMonthMap = new HashMap<>(); | |
457 | + Map<String, Integer> firstmap = new HashMap<>(); | |
458 | + Map<String, Integer> secondmap = new HashMap<>(); | |
459 | + for (AreaData areaData:reportMonthList) { | |
460 | + String month = buildMonth(areaData.getYear()); | |
461 | + if (firstmap.containsKey(month)) { | |
462 | + firstmap.put(month, firstmap.get(month) + areaData.getVal()); | |
463 | + } else { | |
464 | + firstmap.put(month, areaData.getVal()); | |
465 | + } | |
466 | + if (secondmap.containsKey(month)) { | |
467 | + secondmap.put(month, secondmap.get(month) + areaData.getVal2()); | |
468 | + } else { | |
469 | + secondmap.put(month, areaData.getVal2()); | |
470 | + } | |
471 | + } | |
472 | + reportMonthMap.put("复诊人数", secondmap); | |
473 | + reportMonthMap.put("初诊人数", firstmap); | |
474 | + Option reportMonthOption = buildLineOption("初诊及复诊人数", null, reportMonthMap, buildDefaultMonth(12)); | |
475 | + | |
476 | + | |
477 | + // 近6个月高危数据(按颜色分组) | |
478 | + Map<String, Map<String, Integer>> groupRiskMonthMap = new HashMap<>(); | |
479 | + for (AreaData areaData:riskMonthList) { | |
480 | + String groupName = areaData.getGroupName().replace("预警", ""); | |
481 | + Map<String, Integer> grmap = groupRiskMonthMap.get(groupName); | |
482 | + if (grmap == null) { | |
483 | + grmap = new HashMap<>(); | |
484 | + groupRiskMonthMap.put(groupName, grmap); | |
485 | + } | |
486 | + String month = buildMonth(areaData.getYear()); | |
487 | + if (grmap.containsKey(month)) { | |
488 | + grmap.put(month, grmap.get(month) + areaData.getVal()); | |
489 | + } else { | |
490 | + grmap.put(month, areaData.getVal()); | |
491 | + } | |
492 | + } | |
493 | + Option groupRiskMonthOption = buildxBarOption("高危历史人数", null, groupRiskMonthMap, buildDefaultMonth(6), colormap); | |
494 | + | |
495 | + | |
496 | + result.put("type", 1); | |
497 | + result.put("kvData", kvData); | |
498 | + result.put("mapsOption", option); | |
499 | + result.put("areaBarOption", areaBarOption); | |
500 | + result.put("riskOption", groupRiskOption); | |
501 | + result.put("patientMonthOption", patientMonthOption); | |
502 | + result.put("reportMonthOption", reportMonthOption); | |
503 | + result.put("groupRiskMonthOption", groupRiskMonthOption); | |
504 | + ResultUtils.buildSuccessResultAndWrite(response, result); | |
505 | + } | |
506 | + | |
286 | 507 | } |
287 | 508 | |
288 | 509 | |
... | ... | @@ -372,7 +593,7 @@ |
372 | 593 | legend.setTop("20px"); |
373 | 594 | legend.setLeft("left"); |
374 | 595 | List<Object> tempList = new ArrayList<Object>(); |
375 | - tempList.add("建档&高危数"); | |
596 | + tempList.add("建档及高危数"); | |
376 | 597 | legend.setData(tempList); |
377 | 598 | option.setLegend(legend); |
378 | 599 | option.setVisualMap(new VisualMap()); |
platform-reportData/src/main/java/com/lymsh/platform/reportdata/model/echarts/VisualMap.java
View file @
c2b19a7