Commit f890f67950a6da031c394fc80a7958b0fcdd1174

Authored by gengxiaokai
1 parent 03fd15f9d1

婚检统计

Showing 1 changed file with 250 additions and 4 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PremaritalCheckupFacade.java View file @ f890f67
... ... @@ -2190,8 +2190,8 @@
2190 2190 }
2191 2191  
2192 2192  
2193   - //婚检统计
2194   - public BaseResponse queryPremaritalReport(String provinceId,String cityId,String areaId,String streetId,String time,Integer userId){
  2193 + //婚检导出
  2194 + public BaseResponse queryPremaritalExcel(String provinceId,String cityId,String areaId,String streetId,String time,Integer userId){
2195 2195 //获取用户权限医院和筛选条件的交集
2196 2196 List<String> currentUserHospPermissions = areaCountFacade.getCurrentUserHospPermissions2(userId, provinceId,
2197 2197 cityId, areaId);
... ... @@ -2428,7 +2428,6 @@
2428 2428 } else {
2429 2429 woman = 1;
2430 2430 }
2431   - xAxis.add(orgs.get(0).getName());
2432 2431 if(man == 1){
2433 2432 hjList.add("0");
2434 2433 item.add("0");
2435 2434  
... ... @@ -2470,9 +2469,256 @@
2470 2469 result.add(item);
2471 2470 }
2472 2471 hjMap.put("data",hjList);
2473   - hqwsMap.put("data",hqwsList);
  2472 + hqwsMap.put("data", hqwsList);
2474 2473 series.add(hjMap);
2475 2474 series.add(hqwsMap);
  2475 + }
  2476 + }
  2477 +
  2478 + Map<String, Object> datas = new HashMap<>();
  2479 + datas.put("legend",titleItems);
  2480 + datas.put("series", series);
  2481 + datas.put("tableDatas",result);
  2482 + datas.put("xAxis", xAxis);
  2483 + return new BaseObjectResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(datas);
  2484 +
  2485 + }
  2486 +
  2487 +
  2488 +
  2489 + //婚检统计
  2490 + public BaseResponse queryPremaritalReport(String provinceId,String cityId,String areaId,String streetId,String time,Integer userId){
  2491 + //获取用户权限医院和筛选条件的交集
  2492 + List<String> currentUserHospPermissions = areaCountFacade.getCurrentUserHospPermissions2(userId, provinceId,
  2493 + cityId, areaId);
  2494 + int xuhao = 1;
  2495 + //图标数据
  2496 + List<Map<String, Object>> series = new LinkedList<>();
  2497 + Map<String,Object> hjTotalMap = new HashMap<String,Object>();
  2498 + hjTotalMap.put("name","总数");
  2499 + hjTotalMap.put("type","bar");
  2500 + Map<String,Object> hjManMap = new HashMap<String,Object>();
  2501 + hjManMap.put("name","男");
  2502 + hjManMap.put("type","bar");
  2503 + Map<String,Object> hjWomanMap = new HashMap<String,Object>();
  2504 + hjWomanMap.put("name","女");
  2505 + hjWomanMap.put("type","bar");
  2506 + List<String> hjManList = new ArrayList<String>();
  2507 + List<String> hjWomanList = new ArrayList<String>();
  2508 + List<String> hjTotalList = new ArrayList<String>();
  2509 + List<List<String>> result = new ArrayList<>();
  2510 + //标题名称
  2511 + List<String> titleItems = new LinkedList<>();
  2512 + titleItems.add("总数");
  2513 + titleItems.add("男");
  2514 + titleItems.add("女");
  2515 + //x轴标题数据
  2516 + List<String> xAxis = new ArrayList<>();
  2517 + String[] dates = null;
  2518 + if (StringUtils.isNotEmpty(time)) {
  2519 + dates = time.split(" - ");
  2520 + }
  2521 + if(StringUtils.isNotEmpty(areaId)){//按照医院统计
  2522 +
  2523 + for(String hospitalId : currentUserHospPermissions){
  2524 + List<String> item = new ArrayList<String>();
  2525 + //查询X轴标题数据
  2526 + OrganizationQuery idQuery = new OrganizationQuery();
  2527 + idQuery.setYn(YnEnums.YES.getId());
  2528 + idQuery.setId(Integer.parseInt(hospitalId));
  2529 + List<Organization> orgs = organizationService.queryOrganization(idQuery);
  2530 + //序号
  2531 + item.add(String.valueOf(xuhao));
  2532 + item.add(orgs.get(0).getName());
  2533 + item.add("1");
  2534 +
  2535 + PremaritalCheckupQuery query = new PremaritalCheckupQuery();
  2536 + if (dates != null) {
  2537 + query.setPremaritalUpTimeStart(DateUtil.parseYMD(dates[0]));
  2538 + if (dates.length == 2) {
  2539 + query.setPremaritalUpTimeEnd(DateUtil.parseYMD(dates[1]));
  2540 + }
  2541 + }
  2542 + query.setHospitalId(hospitalId);
  2543 + query.setSexType(2);//男性
  2544 + List<PremaritalCheckup> dataNan = premaritalCheckupService.queryPremaritalCheckup(query);
  2545 + int totalMan = 0;
  2546 + int totalWoman = 0;
  2547 + if (dataNan != null && dataNan.size() > 0) {
  2548 + hjManList.add(String.valueOf(dataNan.size()));
  2549 + totalMan=dataNan.size();
  2550 + } else {
  2551 + hjManList.add("0");
  2552 + }
  2553 +
  2554 + query.setSexType(1);//女性
  2555 + List<PremaritalCheckup> dataNv = premaritalCheckupService.queryPremaritalCheckup(query);
  2556 + if (dataNv != null && dataNv.size() > 0) {
  2557 + hjWomanList.add(String.valueOf(dataNv.size()));
  2558 + totalWoman=dataNv.size();
  2559 + }else {
  2560 + hjWomanList.add("0");
  2561 + }
  2562 + xuhao++;
  2563 + item.add(String.valueOf(totalMan+totalWoman));
  2564 + if(dataNan != null && dataNan.size() > 0){
  2565 + item.add(String.valueOf(dataNan.size()));
  2566 + }else{
  2567 + item.add("0");
  2568 + }
  2569 + if(dataNv != null && dataNv.size() > 0){
  2570 + item.add(String.valueOf(dataNv.size()));
  2571 + }else{
  2572 + item.add("0");
  2573 + }
  2574 + hjTotalList.add(String.valueOf(totalMan+totalWoman));
  2575 + xAxis.add(orgs.get(0).getName());
  2576 + result.add(item);
  2577 + }
  2578 + hjTotalMap.put("data",hjTotalList);
  2579 + hjManMap.put("data",hjManList);
  2580 + hjWomanMap.put("data", hjWomanList);
  2581 + series.add(hjTotalMap);
  2582 + series.add(hjManMap);
  2583 + series.add(hjWomanMap);
  2584 + }else{
  2585 + BasicConfigQuery basicQuery = new BasicConfigQuery();
  2586 + basicQuery.setYn(YnEnums.YES.getId());
  2587 + basicQuery.setTypeId("b7ea005c-dfac-4c2a-bdae-25239b3f44fd");
  2588 + //用来存放省、市、县的ID的集合
  2589 + List<String> ids = new ArrayList<>();
  2590 + //查询当前登录用户管辖的所有医院
  2591 + DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery();
  2592 + dataPermissionsModelQuery.setUserId(userId);
  2593 + List<DataPermissionsModel> permissionsModels = dataPermissionService.queryPermission(dataPermissionsModelQuery);
  2594 +
  2595 + int addrType = 0;
  2596 + if (StringUtils.isNotEmpty(provinceId)) {
  2597 + ids = new ArrayList<>();
  2598 + if (CollectionUtils.isNotEmpty(permissionsModels)) {
  2599 + List<AddressBean> addressBeanList = JsonUtil.toList(permissionsModels.get(0).getAreaPermission(), AddressBean.class);
  2600 + if (CollectionUtils.isNotEmpty(addressBeanList))
  2601 + {
  2602 + for (AddressBean bean : addressBeanList)
  2603 + {
  2604 + if (bean != null && bean.getP() != null && bean.getP().equals(provinceId) && StringUtils.isNotEmpty(bean.getC()))
  2605 + {
  2606 + //省不为空,赋值所有市的id
  2607 + ids.add(bean.getC());
  2608 + }
  2609 + }
  2610 + }
  2611 + }
  2612 + basicQuery.setIds(ids);
  2613 + addrType = 1;
  2614 + }
  2615 + if (StringUtils.isNotEmpty(cityId)) {
  2616 + ids = new ArrayList<>();
  2617 + if (CollectionUtils.isNotEmpty(permissionsModels)) {
  2618 + List<AddressBean> addressBeanList = JsonUtil.toList(permissionsModels.get(0).getAreaPermission(), AddressBean.class);
  2619 + if (CollectionUtils.isNotEmpty(addressBeanList))
  2620 + {
  2621 + for (AddressBean bean : addressBeanList)
  2622 + {
  2623 + if (bean != null && bean.getC() != null && bean.getC().equals(cityId) && StringUtils.isNotEmpty(bean.getA()))
  2624 + {
  2625 + //市不为空,赋值所有县的id
  2626 + ids.add(bean.getA());
  2627 + }
  2628 + }
  2629 + }
  2630 + }
  2631 + basicQuery.setIds(ids);
  2632 + addrType = 2;
  2633 + }
  2634 +
  2635 + //获取地址列表
  2636 + List<BasicConfig> configList = new ArrayList<>();
  2637 + if (CollectionUtils.isNotEmpty(ids))
  2638 + {
  2639 + configList = basicConfigService.queryBasicConfig(basicQuery);
  2640 + }
  2641 + if (CollectionUtils.isNotEmpty(configList)) {
  2642 + for (BasicConfig addr : configList) {
  2643 + xAxis.add(addr.getName());
  2644 + }
  2645 + }
  2646 +
  2647 + if (CollectionUtils.isNotEmpty(configList)) {
  2648 +
  2649 +
  2650 + for (BasicConfig c : configList) {
  2651 + List<String> item = new ArrayList<String>();
  2652 + OrganizationQuery idQuery = new OrganizationQuery();
  2653 + idQuery.setYn(YnEnums.YES.getId());
  2654 + //序号
  2655 + item.add(String.valueOf(xuhao));
  2656 + item.add(c.getName());
  2657 +
  2658 + //查询机构数
  2659 + if (addrType == 1) {
  2660 + idQuery.setCityId(c.getId());
  2661 + } else if (addrType == 2) {
  2662 + idQuery.setAreaId(c.getId());
  2663 + }
  2664 + List<Organization> orgs = organizationService.queryOrganization(idQuery);
  2665 + //机构总数
  2666 + int orgSize = CollectionUtils.isNotEmpty(orgs) ? orgs.size() : 0;
  2667 + item.add(String.valueOf(orgSize));
  2668 +
  2669 + List<String> hids = getConditionHospitalIds(currentUserHospPermissions, orgs);
  2670 +
  2671 + if (CollectionUtils.isNotEmpty(hids)) {
  2672 +
  2673 + PremaritalCheckupQuery query = new PremaritalCheckupQuery();
  2674 + if (dates != null) {
  2675 + query.setPremaritalUpTimeStart(DateUtil.parseYMD(dates[0]));
  2676 + if (dates.length == 2) {
  2677 + query.setPremaritalUpTimeEnd(DateUtil.parseYMD(dates[1]));
  2678 + }
  2679 + }
  2680 + query.setHospitalIds(hids);
  2681 + query.setSexType(2);//男性
  2682 + List<PremaritalCheckup> dataNan = premaritalCheckupService.queryPremaritalCheckup(query);
  2683 + int totalMan = 0;
  2684 + int totalWoman = 0;
  2685 + if (dataNan != null && dataNan.size() > 0) {
  2686 + hjManList.add(String.valueOf(dataNan.size()));
  2687 + totalMan=dataNan.size();
  2688 + } else {
  2689 + hjManList.add("0");
  2690 + }
  2691 +
  2692 + query.setSexType(1);//女性
  2693 + List<PremaritalCheckup> dataNv = premaritalCheckupService.queryPremaritalCheckup(query);
  2694 + if (dataNv != null && dataNv.size() > 0) {
  2695 + hjWomanList.add(String.valueOf(dataNv.size()));
  2696 + totalWoman=dataNv.size();
  2697 + } else {
  2698 + hjWomanList.add("0");
  2699 + }
  2700 + item.add(String.valueOf(totalMan+totalWoman));
  2701 + if(dataNan != null && dataNan.size() > 0){
  2702 + item.add(String.valueOf(dataNan.size()));
  2703 + }else{
  2704 + item.add("0");
  2705 + }
  2706 + if(dataNv != null && dataNv.size() > 0){
  2707 + item.add(String.valueOf(dataNv.size()));
  2708 + }else{
  2709 + item.add("0");
  2710 + }
  2711 + hjTotalList.add(String.valueOf(totalMan+totalWoman));
  2712 + }
  2713 + xuhao++;
  2714 + result.add(item);
  2715 + }
  2716 + hjTotalMap.put("data",hjTotalList);
  2717 + hjManMap.put("data",hjManList);
  2718 + hjWomanMap.put("data", hjWomanList);
  2719 + series.add(hjTotalMap);
  2720 + series.add(hjManMap);
  2721 + series.add(hjWomanMap);
2476 2722 }
2477 2723 }
2478 2724