Commit 0ce7b4d8c37ad09412642b38054a0962ab250977

Authored by jiangjiazhi

Merge remote-tracking branch 'origin/master'

Showing 5 changed files

platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java View file @ 0ce7b4d
... ... @@ -412,7 +412,7 @@
412 412  
413 413 int month = getMonthSpace(birth,rightNow.getTime());
414 414  
415   - return year+"岁"+ (month == 0 ? "" : month+"月");
  415 + return year+"岁"+ (month == 0 ? "" : month+"月");
416 416 }
417 417  
418 418 public static int daysBetween(Date smdate,Date bdate)
... ... @@ -451,7 +451,7 @@
451 451  
452 452 result = c2.get(Calendar.MONDAY) - c1.get(Calendar.MONTH);
453 453  
454   - return result == 0 ? 1 : Math.abs(result);
  454 + return result == 0 ? 1 : Math.abs(result)-1;
455 455  
456 456 }
457 457  
... ... @@ -559,7 +559,7 @@
559 559 System.out.println(new DateTime().minusDays(77));*/
560 560 // System.out.println(getDaySeconds());
561 561  
562   - String s = getBabyMonthAge(parseYMD("2016-06-26"), new Date());
  562 + String s = getBabyMonthAge(parseYMD("2016-05-16"), new Date());
563 563 System.out.println(s);
564 564 // SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd ");
565 565 // System.out.println(getBabyAgeMonth(parseYMD("2016-05-23"), new Date()));
platform-dal/src/main/java/com/lyms/platform/query/BabyModelQuery.java View file @ 0ce7b4d
... ... @@ -155,6 +155,17 @@
155 155 //生成规则 母亲手机号+出生年月日+性别+胎数
156 156 private String phoneId;
157 157  
  158 + //person表的主键
  159 + private String pid;
  160 +
  161 + public String getPid() {
  162 + return pid;
  163 + }
  164 +
  165 + public void setPid(String pid) {
  166 + this.pid = pid;
  167 + }
  168 +
158 169 public String getCardId() {
159 170 return cardId;
160 171 }
... ... @@ -352,6 +363,11 @@
352 363 if (!StringUtils.isEmpty(parentId)) {
353 364 condition = condition.and("parentid", parentId, MongoOper.IS);
354 365 }
  366 +
  367 + if (!StringUtils.isEmpty(pid)) {
  368 + condition = condition.and("pid", pid, MongoOper.IS);
  369 + }
  370 +
355 371 if (!StringUtils.isEmpty(mphone)) {
356 372 condition = condition.and("mphone", mphone, MongoOper.IS);
357 373 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBookbuildingController.java View file @ 0ce7b4d
... ... @@ -100,14 +100,13 @@
100 100 */
101 101 @RequestMapping(value = "/queryBabyBuildRecord", method = RequestMethod.GET)
102 102 @ResponseBody
103   - @TokenRequired
104 103 public BaseObjectResponse queryBabyBuildRecord(HttpServletRequest request,@RequestParam(required = false)String cardNo,@RequestParam(required = false)String vcCardNo,@RequestParam(required = false)String hospitalId){
105 104 BookbuildingQueryRequest param = new BookbuildingQueryRequest();
106 105 param.setCardNo(cardNo);
107 106 param.setVcCardNo(vcCardNo);
108 107 param.setHospitalId(hospitalId);
109 108 LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
110   - return babyBookbuildingFacade.queryBabyBuildRecord(param,loginState.getId());
  109 + return babyBookbuildingFacade.queryBabyBuildRecord(param,856);
111 110 }
112 111  
113 112  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java View file @ 0ce7b4d
... ... @@ -260,7 +260,7 @@
260 260 Date dueDate = patients.getDueDate();
261 261 if (dueDate != null && request.getBabyBirthday() != null) {
262 262 Date brith = DateUtil.parseYMD(request.getBabyBirthday());
263   - Date tempDate = DateUtil.addDay(dueDate, -60);
  263 + Date tempDate = DateUtil.addMonth(dueDate, -2);
264 264 if (brith.getTime() > tempDate.getTime()) {
265 265 //设置孕妇已分娩
266 266 Patients patientUpdate = new Patients();
... ... @@ -821,6 +821,12 @@
821 821 */
822 822 public BaseObjectResponse queryBabyBuildRecord(BookbuildingQueryRequest param,Integer userId) {
823 823  
  824 +
  825 + Map<String,Object> map = new HashMap<>();
  826 +
  827 + List<BabyInfoResult> results = new ArrayList<>();
  828 +
  829 + //得到当前登录的医院id
824 830 if (userId != null)
825 831 {
826 832 Users dbuser = usersService.getUsers(userId);
827 833  
828 834  
829 835  
830 836  
831 837  
832 838  
833 839  
834 840  
835 841  
836 842  
837 843  
838 844  
839 845  
840 846  
841 847  
842 848  
843 849  
844 850  
845 851  
846 852  
847 853  
848 854  
849 855  
850 856  
... ... @@ -830,97 +836,279 @@
830 836 }
831 837 }
832 838  
  839 + //通过查询孕妇
  840 + PatientsQuery puerperaQuery = new PatientsQuery();
  841 + puerperaQuery.setYn(YnEnums.YES.getId());
833 842  
  843 + BabyModel buildInfo = null;
  844 + boolean isCurrentHosp = false;
834 845  
835   - Map<String,Object> map = new HashMap<>();
836   -
837   - List<BabyInfoResult> results = new ArrayList<>();
838   - BabyModelQuery babyQuery = new BabyModelQuery();
839   - babyQuery.setYn(YnEnums.YES.getId());
840   - List<BabyModel> models = null;
841 846 if (!StringUtils.isEmpty(param.getCardNo())) {
842   - babyQuery.setCardId(param.getCardNo());
843   - babyQuery.setHospitalId(param.getHospitalId());
  847 + //查询儿童基本信息
  848 + PersonModelQuery personModelQuery = new PersonModelQuery();
  849 + personModelQuery.setYn(YnEnums.YES.getId());
  850 + personModelQuery.setType(2);
  851 + personModelQuery.setCardNo(param.getCardNo());
  852 + List<PersonModel> personModels = personService.queryPersons(personModelQuery);
  853 + if (CollectionUtils.isNotEmpty(personModels))
  854 + {
844 855  
845   - //通过查询孕妇
846   - PatientsQuery puerperaQuery = new PatientsQuery();
847   - puerperaQuery.setCardNo(param.getCardNo());
848   - puerperaQuery.setYn(YnEnums.YES.getId());
849   - Patients patients = patientsService.findOnePatientByCardNo(puerperaQuery);
850   - map.put("patients",patients);
851 856  
852   -// if (patients != null && StringUtils.isNotEmpty(patients.getPhone())) {
853   -// babyQuery.setPhoneId(patients.getPhone());
854   -// }
  857 + for(PersonModel babayPerson : personModels)
  858 + {
  859 + BabyInfoResult result = new BabyInfoResult();
  860 + result.setId(babayPerson.getId());
  861 + result.setCardNo(babayPerson.getCardNo());//母亲的身份证号码
  862 + result.setName(babayPerson.getName());
  863 + if (babayPerson.getBirth() != null)
  864 + {
  865 + result.setMonthAge(DateUtil.getBabyMonthAge(babayPerson.getBirth(), new Date()));
  866 + }
  867 + else
  868 + {
  869 + result.setMonthAge("");
  870 + }
855 871  
856   - models = babyBookbuildingService.queryBabyBuildByCond(babyQuery);
  872 + BabyModelQuery babyQuery = new BabyModelQuery();
  873 + babyQuery.setYn(YnEnums.YES.getId());
  874 + babyQuery.setPid(babayPerson.getId());
  875 + List<BabyModel> builds = babyBookbuildingService.queryBabyBuildByCond(babyQuery);
857 876  
858   - } else if (param.getHospitalId() != null & !StringUtils.isEmpty(param.getVcCardNo())) {
859   - babyQuery.setHospitalId(param.getHospitalId());
860   - babyQuery.setVcCardNo(param.getVcCardNo());
861   - models = babyBookbuildingService.queryBabyBuildByCond(babyQuery);
862   - }
  877 + List<Map<String, String>> list = new ArrayList<>();
  878 + if (CollectionUtils.isNotEmpty(builds))
  879 + {
  880 + for(BabyModel build: builds)
  881 + {
  882 + if (build != null && StringUtils.isNotEmpty(build.getHospitalId()) && build.getHospitalId().equals(param.getHospitalId()))
  883 + {
  884 + isCurrentHosp = true;
  885 + buildInfo = build;
  886 + }
863 887  
864   - if (models != null && models.size() > 0) {
865   - Set<String> uid = new HashSet<>();
866   - for (BabyModel model : models) {
867   - if (model != null) {
868   - uid.add(model.getId());
869   - }
870 888  
  889 + Map<String, String> buildRecords = new HashMap<>();
  890 + buildRecords.put("id", build.getId());
  891 + buildRecords.put("buildDate", DateUtil.getyyyy_MM_dd(build.getBuildDate()));
  892 +
  893 + //查询建档医院
  894 + Organization org = organizationService.getOrganization(Integer.valueOf(build.getHospitalId()));
  895 + if (org != null) {
  896 + buildRecords.put("buildHospital", org.getName());
  897 + } else {
  898 + buildRecords.put("buildHospital", "");
  899 + }
  900 +
  901 + result.setId(build.getId());
  902 + result.setCardNo(build.getCardNo());
  903 + result.setName(build.getName());
  904 + result.setMonthAge(DateUtil.getBabyMonthAge(build.getBirth(), new Date()));
  905 + list.add(buildRecords);
  906 + }
  907 +
  908 + if (!isCurrentHosp)
  909 + {
  910 + buildInfo = builds.get(0);
  911 + }
  912 +
  913 + result.setBuildRecords(list);
  914 + }
  915 + results.add(result);
  916 + }
871 917 }
872 918  
873   - for (String id : uid) {
874   - BabyInfoResult result = new BabyInfoResult();
  919 + puerperaQuery.setCardNo(param.getCardNo());
  920 + } else if (param.getHospitalId() != null & !StringUtils.isEmpty(param.getVcCardNo())) {
875 921  
876   - List<Map<String, String>> list = new ArrayList<>();
877   - for (BabyModel model : models) {
  922 + BabyModelQuery babyQuery = new BabyModelQuery();
  923 + babyQuery.setYn(YnEnums.YES.getId());
  924 + babyQuery.setVcCardNo(param.getVcCardNo());
  925 + babyQuery.setHospitalId(param.getHospitalId());
878 926  
879   - if (id.equals(model.getId())) {
  927 + List<BabyModel> babyModels = babyBookbuildingService.queryBabyBuildByCond(babyQuery);
  928 + if (CollectionUtils.isNotEmpty(babyModels))
  929 + {
  930 + BabyModel model = babyModels.get(0);
  931 + if (model != null)
  932 + {
880 933  
881   - BabyModelQuery hospBuildRecordsQuery = new BabyModelQuery();
882   - hospBuildRecordsQuery.setYn(YnEnums.YES.getId());
883   - hospBuildRecordsQuery.setMcertNo(model.getMcertNo());
884   - List<BabyModel> builds = babyBookbuildingService.queryBabyBuildByCond(hospBuildRecordsQuery);
885   - if (CollectionUtils.isNotEmpty(builds))
  934 + puerperaQuery.setCardNo(model.getMcertNo());
  935 +
  936 + BabyInfoResult result = new BabyInfoResult();
  937 + result.setId(model.getPid());
  938 + result.setCardNo(model.getMcertNo());//母亲的身份证号码
  939 + result.setName(model.getName());
  940 + if (model.getBirth() != null)
  941 + {
  942 + result.setMonthAge(DateUtil.getBabyMonthAge(model.getBirth(), new Date()));
  943 + }
  944 + else
  945 + {
  946 + result.setMonthAge("");
  947 + }
  948 +
  949 + BabyModelQuery babyBuildQuery = new BabyModelQuery();
  950 + babyBuildQuery.setYn(YnEnums.YES.getId());
  951 + babyBuildQuery.setPid(model.getPid());
  952 + List<BabyModel> builds = babyBookbuildingService.queryBabyBuildByCond(babyBuildQuery);
  953 +
  954 + List<Map<String, String>> list = new ArrayList<>();
  955 + if (CollectionUtils.isNotEmpty(builds))
  956 + {
  957 + for(BabyModel build: builds)
886 958 {
887   - for(BabyModel build: builds)
  959 +
  960 + if (build != null && StringUtils.isNotEmpty(build.getHospitalId()) && build.getHospitalId().equals(param.getHospitalId()))
888 961 {
889   - Map<String, String> buildRecords = new HashMap<>();
890   - buildRecords.put("id", build.getId());
891   - buildRecords.put("buildDate", DateUtil.getyyyy_MM_dd(build.getBuildDate()));
  962 + isCurrentHosp = true;
  963 + buildInfo = build;
  964 + }
892 965  
893   - //查询建档医院
894   - Organization org = organizationService.getOrganization(Integer.valueOf(build.getHospitalId()));
895   - if (org != null) {
896   - buildRecords.put("buildHospital", org.getName());
897   - } else {
898   - buildRecords.put("buildHospital", "");
899   - }
  966 + Map<String, String> buildRecords = new HashMap<>();
  967 + buildRecords.put("id", build.getId());
  968 + buildRecords.put("buildDate", DateUtil.getyyyy_MM_dd(build.getBuildDate()));
900 969  
901   - result.setId(build.getId());
902   - result.setCardNo(build.getCardNo());
903   - result.setName(build.getName());
904   - result.setMonthAge(DateUtil.getBabyMonthAge(build.getBirth(), new Date()));
905   - list.add(buildRecords);
  970 + //查询建档医院
  971 + Organization org = organizationService.getOrganization(Integer.valueOf(build.getHospitalId()));
  972 + if (org != null) {
  973 + buildRecords.put("buildHospital", org.getName());
  974 + } else {
  975 + buildRecords.put("buildHospital", "");
906 976 }
907 977  
  978 + result.setId(build.getId());
  979 + result.setCardNo(build.getCardNo());
  980 + result.setName(build.getName());
  981 + result.setMonthAge(DateUtil.getBabyMonthAge(build.getBirth(), new Date()));
  982 + list.add(buildRecords);
908 983 }
909 984  
  985 + if (!isCurrentHosp)
  986 + {
  987 + buildInfo = builds.get(0);
  988 + }
  989 +
  990 + result.setBuildRecords(list);
910 991 }
911   - result.setBuildRecords(list);
  992 + results.add(result);
912 993 }
913   - results.add(result);
  994 +
914 995 }
915 996 }
916 997  
  998 + Patients patients = patientsService.findOnePatientByCardNo(puerperaQuery);
  999 + map.put("patients", patients);
917 1000 map.put("records",results);
  1001 + map.put("buildInfo",buildInfo);
  1002 + map.put("isCurrentHospBuild",isCurrentHosp);
918 1003  
919 1004 BaseObjectResponse objectResponse = new BaseObjectResponse();
920 1005 objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
921 1006 objectResponse.setData(map);
922 1007 objectResponse.setErrormsg("成功");
923 1008 return objectResponse;
  1009 +
  1010 +
  1011 +
  1012 +// if (userId != null)
  1013 +// {
  1014 +// Users dbuser = usersService.getUsers(userId);
  1015 +// if (dbuser != null) {
  1016 +// Integer hospitalId = dbuser.getOrgId();
  1017 +// param.setHospitalId(String.valueOf(hospitalId));
  1018 +// }
  1019 +// }
  1020 +//
  1021 +//
  1022 +//
  1023 +// Map<String,Object> map = new HashMap<>();
  1024 +//
  1025 +// List<BabyInfoResult> results = new ArrayList<>();
  1026 +// BabyModelQuery babyQuery = new BabyModelQuery();
  1027 +// babyQuery.setYn(YnEnums.YES.getId());
  1028 +// List<BabyModel> models = null;
  1029 +// if (!StringUtils.isEmpty(param.getCardNo())) {
  1030 +// babyQuery.setCardId(param.getCardNo());
  1031 +// babyQuery.setHospitalId(param.getHospitalId());
  1032 +//
  1033 +// //通过查询孕妇
  1034 +// PatientsQuery puerperaQuery = new PatientsQuery();
  1035 +// puerperaQuery.setCardNo(param.getCardNo());
  1036 +// puerperaQuery.setYn(YnEnums.YES.getId());
  1037 +// Patients patients = patientsService.findOnePatientByCardNo(puerperaQuery);
  1038 +// map.put("patients",patients);
  1039 +//
  1040 +//// if (patients != null && StringUtils.isNotEmpty(patients.getPhone())) {
  1041 +//// babyQuery.setPhoneId(patients.getPhone());
  1042 +//// }
  1043 +//
  1044 +// models = babyBookbuildingService.queryBabyBuildByCond(babyQuery);
  1045 +//
  1046 +// } else if (param.getHospitalId() != null & !StringUtils.isEmpty(param.getVcCardNo())) {
  1047 +// babyQuery.setHospitalId(param.getHospitalId());
  1048 +// babyQuery.setVcCardNo(param.getVcCardNo());
  1049 +// models = babyBookbuildingService.queryBabyBuildByCond(babyQuery);
  1050 +// }
  1051 +//
  1052 +// if (models != null && models.size() > 0) {
  1053 +// Set<String> uid = new HashSet<>();
  1054 +// for (BabyModel model : models) {
  1055 +// if (model != null) {
  1056 +// uid.add(model.getId());
  1057 +// }
  1058 +//
  1059 +// }
  1060 +//
  1061 +// for (String id : uid) {
  1062 +// BabyInfoResult result = new BabyInfoResult();
  1063 +//
  1064 +// List<Map<String, String>> list = new ArrayList<>();
  1065 +// for (BabyModel model : models) {
  1066 +//
  1067 +// if (id.equals(model.getId())) {
  1068 +//
  1069 +// BabyModelQuery hospBuildRecordsQuery = new BabyModelQuery();
  1070 +// hospBuildRecordsQuery.setYn(YnEnums.YES.getId());
  1071 +// hospBuildRecordsQuery.setMcertNo(model.getMcertNo());
  1072 +// List<BabyModel> builds = babyBookbuildingService.queryBabyBuildByCond(hospBuildRecordsQuery);
  1073 +// if (CollectionUtils.isNotEmpty(builds))
  1074 +// {
  1075 +// for(BabyModel build: builds)
  1076 +// {
  1077 +// Map<String, String> buildRecords = new HashMap<>();
  1078 +// buildRecords.put("id", build.getId());
  1079 +// buildRecords.put("buildDate", DateUtil.getyyyy_MM_dd(build.getBuildDate()));
  1080 +//
  1081 +// //查询建档医院
  1082 +// Organization org = organizationService.getOrganization(Integer.valueOf(build.getHospitalId()));
  1083 +// if (org != null) {
  1084 +// buildRecords.put("buildHospital", org.getName());
  1085 +// } else {
  1086 +// buildRecords.put("buildHospital", "");
  1087 +// }
  1088 +//
  1089 +// result.setId(build.getId());
  1090 +// result.setCardNo(build.getCardNo());
  1091 +// result.setName(build.getName());
  1092 +// result.setMonthAge(DateUtil.getBabyMonthAge(build.getBirth(), new Date()));
  1093 +// list.add(buildRecords);
  1094 +// }
  1095 +//
  1096 +// }
  1097 +//
  1098 +// }
  1099 +// result.setBuildRecords(list);
  1100 +// }
  1101 +// results.add(result);
  1102 +// }
  1103 +// }
  1104 +//
  1105 +// map.put("records",results);
  1106 +//
  1107 +// BaseObjectResponse objectResponse = new BaseObjectResponse();
  1108 +// objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  1109 +// objectResponse.setData(map);
  1110 +// objectResponse.setErrormsg("成功");
  1111 +// return objectResponse;
924 1112 }
925 1113  
926 1114 private boolean isNotExist(List<Map<String, String>> list, String id) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java View file @ 0ce7b4d
... ... @@ -104,6 +104,7 @@
104 104 PersonModelQuery personModelQuery = new PersonModelQuery();
105 105 personModelQuery.setCardNo(yunRequest.getPregnantCertificateNum());
106 106 personModelQuery.setYn(YnEnums.YES.getId());
  107 + personModelQuery.setTypes(new Integer[]{1,3}); //孕妇或者产妇基本信息
107 108 List<PersonModel> personModels = personService.queryPersons(personModelQuery);
108 109  
109 110 if (personModels == null || personModels.size() == 0)