Commit 101f9f8e51b067dfbe2b4d1b142dde5e68ef3d02
1 parent
bc0b0873fb
Exists in
master
and in
6 other branches
1河北省0-6岁儿童保健系统管理登记表 导出分sheet
Showing 3 changed files with 339 additions and 1 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyHealthController.java
View file @
101f9f8
... | ... | @@ -92,7 +92,7 @@ |
92 | 92 | @RequestParam(value = "checkDoctorId", required = false) String checkDoctorId, |
93 | 93 | @RequestParam(value = "level", required = false) String level, |
94 | 94 | Integer page, Integer limit, HttpServletRequest request, HttpServletResponse response) { |
95 | - BaseResponse baseResponse=babyHealthFacade.babystatListReport(checkTime, queryNo, startCheckMonthAge, endCheckMonthAge, | |
95 | + BaseResponse baseResponse=babyHealthFacade.babystatListReport2(checkTime, queryNo, startCheckMonthAge, endCheckMonthAge, | |
96 | 96 | nextDate, highRisk, waskSon, checkDoctorId, page, limit, getUserId(request), level,response); |
97 | 97 | System.out.println(baseResponse); |
98 | 98 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyHealthFacade.java
View file @
101f9f8
... | ... | @@ -558,6 +558,344 @@ |
558 | 558 | |
559 | 559 | |
560 | 560 | } |
561 | + public BaseResponse babystatListReport2(String checkTime, String queryNo, Integer checkMonthAge, Integer endCheckMonthAge, String nextDate, | |
562 | + Integer highRisk, Integer waskSon, String checkDoctorId, Integer page, Integer limit, Integer userId, String level, HttpServletResponse response) { | |
563 | + boolean flag = false; | |
564 | + // List<String> hospital = groupsFacade.findGroupHospital(userId, false); | |
565 | + int[] monthArr = {0, 3, 4, 8, 12, 18, 24, 30, 36, 48, 60, 72};//月龄 | |
566 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
567 | + Criteria criteria = Criteria.where("yn").ne(0).and("hospitalId").is(hospitalId); | |
568 | + Criteria pCriteria = Criteria.where("yn").ne(0).and("hospitalId").is(hospitalId); | |
569 | + if (org.apache.commons.lang.StringUtils.isNotBlank(queryNo)) { | |
570 | + pCriteria.orOperator(Criteria.where("mcertNo").regex(queryNo), Criteria.where("name").regex(queryNo), | |
571 | + Criteria.where("fphone").regex(queryNo), Criteria.where("vcCardNo").regex(queryNo), Criteria.where("mname").regex(queryNo)); | |
572 | + flag = true; | |
573 | + } | |
574 | + PageResult pageResult = new PageResult(); | |
575 | + | |
576 | + try { | |
577 | + response.setContentType("application/force-download"); | |
578 | + response.setHeader("Content-Disposition", "attachment;filename=" + new String(("年报表.xls").getBytes("UTF-8"), "ISO-8859-1")); | |
579 | + String path = this.getClass().getResource("/").getPath() + "babyhealthstat2.xls"; | |
580 | + | |
581 | + // 导出excel | |
582 | + File file = new File(path); | |
583 | + InputStream in = new FileInputStream(file); | |
584 | + Workbook wb = Workbook.getWorkbook(in); | |
585 | + | |
586 | + | |
587 | + WritableWorkbook book = wb.createWorkbook(response.getOutputStream(), wb); | |
588 | + WritableSheet ws = book.getSheet(0); | |
589 | + WritableSheet ws1 = book.getSheet(1); | |
590 | + WritableSheet ws2 = book.getSheet(2); | |
591 | + | |
592 | + WritableCellFormat contentFormt = new WritableCellFormat(); | |
593 | + contentFormt.setAlignment(jxl.format.Alignment.CENTRE); | |
594 | + contentFormt.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); | |
595 | + contentFormt.setVerticalAlignment(VerticalAlignment.CENTRE); | |
596 | + | |
597 | + int lastPage = 0, pageSize = 0; | |
598 | + | |
599 | + pageResult = findMongoPage(BabyModel.class, new Query(pCriteria).with(new Sort(Sort.Direction.DESC, "created")), page, limit); | |
600 | +// lastPage = pageResult.getLastPage(); | |
601 | +// pageSize = pageResult.getSize(); | |
602 | +// for (int n = 0; n < lastPage; n++) { | |
603 | +// pageResult = findMongoPage(BabyModel.class, new Query(pCriteria).with(new Sort(Sort.Direction.DESC, "created")), n, pageSize); | |
604 | + List<BabyModel> babykModelsList = (List<BabyModel>) pageResult.getGrid(); | |
605 | +// PageResult pageResult=new PageResult(); | |
606 | +// babykModelsList = this.mongoTemplate.find(new Query(pCriteria).with(new Sort(Sort.Direction.DESC, "created")),BabyModel.class); | |
607 | + List<Map<String, Object>> grid = new ArrayList<>(); | |
608 | + | |
609 | + if (com.lyms.platform.operate.web.utils.CollectionUtils.isNotEmpty(babykModelsList)) { | |
610 | + for (int j=0; j<babykModelsList.size();j++) { | |
611 | + BabyModel babyModel = babykModelsList.get(j); | |
612 | + Map<String, Object> row = new HashMap<>(); | |
613 | + Map<String, Object> babyMap = new HashMap<>(); | |
614 | + babyMap.put("babyName", babyModel.getName()); | |
615 | + babyMap.put("sex", babyModel.getSex()); | |
616 | + babyMap.put("birth", babyModel.getBirth()); | |
617 | + babyMap.put("mname", babyModel.getMname()); | |
618 | + babyMap.put("address", babyModel.getAddress()); | |
619 | + babyMap.put("mphone", babyModel.getMphone()); | |
620 | + row.put("baby", babyMap); | |
621 | + Criteria criteriaCheck = Criteria.where("buildId").in(babyModel.getId()); | |
622 | +// pageResult = findMongoPage(BabyCheckModel.class, new Query(criteriaCheck).with(new Sort(Sort.Direction.DESC, "created")), page, limit); | |
623 | + List<BabyCheckModel> babyCheckModelList = mongoTemplate.find(new Query(criteriaCheck).with(new Sort(Sort.Direction.DESC, "created")), BabyCheckModel.class); | |
624 | + | |
625 | + List<Map<String, Object>> listAge = new ArrayList<>(); | |
626 | + | |
627 | + for (BabyCheckModel babyCheckModel : babyCheckModelList) { | |
628 | + Map<String, Object> map = new HashMap<>(); | |
629 | + String feedType = ""; | |
630 | + String feedTypeId = babyCheckModel.getFeedType(); | |
631 | + if (StringUtils.isNotEmpty(feedTypeId)) { | |
632 | + feedType = WyTypeEnums.getNameById(Integer.parseInt(feedTypeId)); | |
633 | + } | |
634 | + map.put("feedType", feedType); | |
635 | + | |
636 | + for (int i = 0; i < monthArr.length; i++) { | |
637 | + Map<String, Object> mapAge = new HashMap<>(); | |
638 | + if (monthArr[i] == babyCheckModel.getCheckMonth().intValue()) { | |
639 | + mapAge.put("height", babyCheckModel.getHeight()); | |
640 | + mapAge.put("heightEvaluate", babyCheckModel.getHeightEvaluate()); | |
641 | + mapAge.put("weight", babyCheckModel.getWeight()); | |
642 | + mapAge.put("weightEvaluate", babyCheckModel.getWeightEvaluate()); | |
643 | + mapAge.put("hemoglobin", babyCheckModel.getHemoglobin()); | |
644 | + } else { | |
645 | + mapAge.put("height", ""); | |
646 | + mapAge.put("heightEvaluate", ""); | |
647 | + mapAge.put("weight", ""); | |
648 | + mapAge.put("weightEvaluate", ""); | |
649 | + mapAge.put("hemoglobin", ""); | |
650 | + } | |
651 | + mapAge.put("age", monthArr[i]); | |
652 | + listAge.add(mapAge); | |
653 | + } | |
654 | + | |
655 | + row.put("monthChk", listAge); | |
656 | + | |
657 | + row.put("height", babyCheckModel.getHeight()); | |
658 | + row.put("weight", babyCheckModel.getWeight()); | |
659 | + //秦皇岛需求,查询最后一次检查的高危详情 | |
660 | + row.put("qhdHighRiskInfo", babyCheckModel.getQhdHighRiskInfo()); | |
661 | + } | |
662 | + if(babyCheckModelList.size()<1){ | |
663 | + for (int i = 0; i < monthArr.length; i++) { | |
664 | + Map<String, Object> mapAge = new HashMap<>(); | |
665 | + mapAge.put("height", ""); | |
666 | + mapAge.put("heightEvaluate", ""); | |
667 | + mapAge.put("weight", ""); | |
668 | + mapAge.put("weightEvaluate", ""); | |
669 | + mapAge.put("hemoglobin", ""); | |
670 | + listAge.add(mapAge); | |
671 | + } | |
672 | + } | |
673 | + | |
674 | +// 访视 | |
675 | + List<NewbornVisit> newbornVisits = mongoTemplate.find(Query.query(Criteria.where("babyId").is(babyModel.getId()).and("hospitalId").in(hospitalId).and("yn").ne("0")) | |
676 | + .with(new Sort(Sort.Direction.ASC, "checkTime")), NewbornVisit.class); | |
677 | + List<Map<String, Object>> rest = new ArrayList<>(); | |
678 | + for (NewbornVisit newbornVisit : newbornVisits) { | |
679 | + Map<String, Object> temp = new HashMap<>(); | |
680 | + temp.put("id", newbornVisit.getId()); | |
681 | + temp.put("hospitalId", newbornVisit.getHospitalId()); | |
682 | + temp.put("pid", newbornVisit.getPid()); | |
683 | + temp.put("checkTime", newbornVisit.getCheckTime() == null ? null : DateUtil.getyyyy_MM_dd(newbornVisit.getCheckTime())); | |
684 | + temp.put("checkTimeDesc", newbornVisit.getCheckTimeDesc()); | |
685 | + rest.add(temp); | |
686 | + } | |
687 | + row.put("visitcnt", newbornVisits.size()); | |
688 | + row.put("instWeight", ""); | |
689 | + if (newbornVisits.size() > 1) { | |
690 | + int size = newbornVisits.size(); | |
691 | + String wn1 = newbornVisits.get(size - 1).getWeightNow(); | |
692 | + String wn2 = newbornVisits.get(size - 2).getWeightNow(); | |
693 | + if (null == wn1) wn1 = "0"; | |
694 | + if (null == wn2) wn2 = "0"; | |
695 | + | |
696 | + row.put("instWeight", (Float.parseFloat(wn1) - Float.parseFloat(wn2))); | |
697 | + } | |
698 | + | |
699 | +// 写入excel | |
700 | + Label label = new Label(0, j + 5, (j + 1) + "", contentFormt); | |
701 | + ws.addCell(label); | |
702 | + | |
703 | + | |
704 | + label = new Label(1, j + 5, babyModel.getName(), contentFormt); | |
705 | + ws.addCell(label); | |
706 | + | |
707 | + label = new Label(2, j + 5, SexEnum.getTextById(babyModel.getSex()), contentFormt); | |
708 | + ws.addCell(label); | |
709 | + | |
710 | + label = new Label(3, j + 5, DateUtil.getyyyy_MM_dd(babyModel.getBirth()), contentFormt); | |
711 | + ws.addCell(label); | |
712 | + | |
713 | + label = new Label(4, j + 5, babyModel.getMname(), contentFormt); | |
714 | + ws.addCell(label); | |
715 | + | |
716 | + label = new Label(5, j + 5, babyModel.getAddress()==null?"":babyModel.getAddress(), contentFormt); | |
717 | + ws.addCell(label); | |
718 | +// 访视 | |
719 | + label = new Label(6, j + 5, newbornVisits.size()+"", contentFormt); | |
720 | + ws.addCell(label); | |
721 | + | |
722 | + label = new Label(7, j + 5,row.get("instWeight")+"", contentFormt); | |
723 | + ws.addCell(label); | |
724 | +// 喂养方式 | |
725 | + label = new Label(8, j + 5,row.get("feedType")==null?"":row.get("feedType")+"", contentFormt); | |
726 | + ws.addCell(label); | |
727 | + | |
728 | + | |
729 | + Map<String,Object> aRow=listAge.get(0); | |
730 | + label = new Label(9, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
731 | + ws.addCell(label); | |
732 | + label = new Label(10, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
733 | + ws.addCell(label); | |
734 | + | |
735 | + aRow=listAge.get(1); | |
736 | + label = new Label(11, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
737 | + ws.addCell(label); | |
738 | + label = new Label(12, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
739 | + ws.addCell(label); | |
740 | + | |
741 | + aRow=listAge.get(2); | |
742 | + label = new Label(13, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
743 | + ws.addCell(label); | |
744 | + label = new Label(14, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
745 | + ws.addCell(label); | |
746 | + | |
747 | + aRow=listAge.get(3); | |
748 | + label = new Label(15, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
749 | + ws.addCell(label); | |
750 | + label = new Label(16, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
751 | + ws.addCell(label); | |
752 | + | |
753 | + aRow=listAge.get(4); | |
754 | + label = new Label(17, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
755 | + ws.addCell(label); | |
756 | + label = new Label(18, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
757 | + ws.addCell(label); | |
758 | + label = new Label(19, j + 5,aRow.get("hemoglobin")+"", contentFormt); | |
759 | + ws.addCell(label); | |
760 | + label = new Label(20, j + 5,babyModel.getMphone(), contentFormt); | |
761 | + ws.addCell(label); | |
762 | + | |
763 | +// 第二个sheet | |
764 | + label = new Label(0, j + 5, (j + 1) + "", contentFormt); | |
765 | + ws1.addCell(label); | |
766 | + | |
767 | + | |
768 | + label = new Label(1, j + 5, babyModel.getName(), contentFormt); | |
769 | + ws1.addCell(label); | |
770 | + | |
771 | + label = new Label(2, j + 5, SexEnum.getTextById(babyModel.getSex()), contentFormt); | |
772 | + ws1.addCell(label); | |
773 | + | |
774 | + label = new Label(3, j + 5, DateUtil.getyyyy_MM_dd(babyModel.getBirth()), contentFormt); | |
775 | + ws1.addCell(label); | |
776 | + | |
777 | + label = new Label(4, j + 5, babyModel.getMname(), contentFormt); | |
778 | + ws1.addCell(label); | |
779 | + | |
780 | + label = new Label(5, j + 5, babyModel.getAddress()==null?"":babyModel.getAddress(), contentFormt); | |
781 | + ws1.addCell(label); | |
782 | +// 访视 | |
783 | + label = new Label(6, j + 5, newbornVisits.size()+"", contentFormt); | |
784 | + ws1.addCell(label); | |
785 | + | |
786 | + label = new Label(7, j + 5,row.get("instWeight")+"", contentFormt); | |
787 | + ws1.addCell(label); | |
788 | +// 喂养方式 | |
789 | + label = new Label(8, j + 5,row.get("feedType")==null?"":row.get("feedType")+"", contentFormt); | |
790 | + ws1.addCell(label); | |
791 | + | |
792 | + | |
793 | + aRow=listAge.get(5); | |
794 | + label = new Label(9, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
795 | + ws1.addCell(label); | |
796 | + label = new Label(10, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
797 | + ws1.addCell(label); | |
798 | + | |
799 | + aRow=listAge.get(6); | |
800 | + label = new Label(11, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
801 | + ws1.addCell(label); | |
802 | + label = new Label(12, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
803 | + ws1.addCell(label); | |
804 | + | |
805 | + aRow=listAge.get(7); | |
806 | + label = new Label(13, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
807 | + ws1.addCell(label); | |
808 | + label = new Label(14, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
809 | + ws1.addCell(label); | |
810 | + | |
811 | + aRow=listAge.get(8); | |
812 | + label = new Label(15, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
813 | + ws1.addCell(label); | |
814 | + label = new Label(16, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
815 | + ws1.addCell(label); | |
816 | + label = new Label(17, j + 5,aRow.get("hemoglobin")+"", contentFormt); | |
817 | + ws1.addCell(label); | |
818 | + | |
819 | + | |
820 | + label = new Label(18, j + 5,babyModel.getMphone(), contentFormt); | |
821 | + ws1.addCell(label); | |
822 | + | |
823 | +// 第3个sheet | |
824 | + label = new Label(0, j + 5, (j + 1) + "", contentFormt); | |
825 | + ws2.addCell(label); | |
826 | + | |
827 | + | |
828 | + label = new Label(1, j + 5, babyModel.getName(), contentFormt); | |
829 | + ws2.addCell(label); | |
830 | + | |
831 | + label = new Label(2, j + 5, SexEnum.getTextById(babyModel.getSex()), contentFormt); | |
832 | + ws2.addCell(label); | |
833 | + | |
834 | + label = new Label(3, j + 5, DateUtil.getyyyy_MM_dd(babyModel.getBirth()), contentFormt); | |
835 | + ws2.addCell(label); | |
836 | + | |
837 | + label = new Label(4, j + 5, babyModel.getMname(), contentFormt); | |
838 | + ws2.addCell(label); | |
839 | + | |
840 | + label = new Label(5, j + 5, babyModel.getAddress()==null?"":babyModel.getAddress(), contentFormt); | |
841 | + ws2.addCell(label); | |
842 | +// 访视 | |
843 | + label = new Label(6, j + 5, newbornVisits.size()+"", contentFormt); | |
844 | + ws2.addCell(label); | |
845 | + | |
846 | + label = new Label(7, j + 5,row.get("instWeight")+"", contentFormt); | |
847 | + ws2.addCell(label); | |
848 | +// 喂养方式 | |
849 | + label = new Label(8, j + 5,row.get("feedType")==null?"":row.get("feedType")+"", contentFormt); | |
850 | + ws2.addCell(label); | |
851 | + | |
852 | + aRow=listAge.get(9); | |
853 | + label = new Label(9, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
854 | + ws2.addCell(label); | |
855 | + label = new Label(10, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
856 | + ws2.addCell(label); | |
857 | + label = new Label(11, j + 5,aRow.get("hemoglobin")+"", contentFormt); | |
858 | + ws2.addCell(label); | |
859 | + | |
860 | + aRow=listAge.get(10); | |
861 | + label = new Label(12, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
862 | + ws2.addCell(label); | |
863 | + label = new Label(13, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
864 | + ws2.addCell(label); | |
865 | + label = new Label(14, j + 5,aRow.get("hemoglobin")+"", contentFormt); | |
866 | + ws2.addCell(label); | |
867 | + | |
868 | + aRow=listAge.get(11); | |
869 | + label = new Label(15, j + 5,aRow.get("weight")+"/"+aRow.get("height"), contentFormt); | |
870 | + ws2.addCell(label); | |
871 | + label = new Label(16, j + 5,aRow.get("weightEvaluate")+"/"+aRow.get("heightEvaluate"), contentFormt); | |
872 | + ws2.addCell(label); | |
873 | + label = new Label(17, j + 5,aRow.get("hemoglobin")+"", contentFormt); | |
874 | + ws2.addCell(label); | |
875 | + | |
876 | + | |
877 | + label = new Label(18, j + 5,babyModel.getMphone(), contentFormt); | |
878 | + ws2.addCell(label); | |
879 | + | |
880 | + } | |
881 | + | |
882 | + } | |
883 | + | |
884 | +// } | |
885 | + | |
886 | + | |
887 | + book.write(); | |
888 | + book.close(); | |
889 | + wb.close(); | |
890 | + | |
891 | + } catch (Exception e) { | |
892 | + e.printStackTrace(); | |
893 | + } | |
894 | +// pageResult.setGrid(grid); | |
895 | + return RespBuilder.buildSuccess(pageResult); | |
896 | + | |
897 | + | |
898 | + } | |
561 | 899 | |
562 | 900 | |
563 | 901 | public BaseResponse query(Integer userId, String babyId) { |
platform-operate-api/src/main/resources/babyhealthstat2.xls
View file @
101f9f8