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