Commit fec2737215744ad5d469922b6f4309829fd0761d
1 parent
54c7ef4208
Exists in
master
and in
6 other branches
报表数据完善
Showing 2 changed files with 139 additions and 82 deletions
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
fec2737
... | ... | @@ -4,9 +4,7 @@ |
4 | 4 | |
5 | 5 | import java.text.ParseException; |
6 | 6 | import java.text.SimpleDateFormat; |
7 | -import java.util.Calendar; | |
8 | -import java.util.Date; | |
9 | -import java.util.GregorianCalendar; | |
7 | +import java.util.*; | |
10 | 8 | import java.util.concurrent.locks.Lock; |
11 | 9 | import java.util.concurrent.locks.ReentrantLock; |
12 | 10 | |
13 | 11 | |
14 | 12 | |
... | ... | @@ -885,18 +883,89 @@ |
885 | 883 | * @return |
886 | 884 | */ |
887 | 885 | public static String getWeekDesc(Date start, Date end) { |
886 | + if(start == null || end == null) { | |
887 | + return "孕0周+0天"; | |
888 | + } | |
888 | 889 | Integer betweenDay = DateUtil.getDays(start, end); |
889 | 890 | Integer week = betweenDay / 7; |
890 | 891 | Integer day = betweenDay % 7; |
891 | 892 | return "孕" + week + "周+" + day + "天"; |
892 | 893 | } |
893 | 894 | |
895 | + /** | |
896 | + * 获取两个日期相差几个月 | |
897 | + * @param start | |
898 | + * @param end | |
899 | + * @return | |
900 | + */ | |
901 | + public static int getMonth(Date start, Date end) { | |
902 | + int result = 0; | |
903 | + try { | |
904 | + Calendar c1 = Calendar.getInstance(); | |
905 | + Calendar c2 = Calendar.getInstance(); | |
906 | + c1.setTime(start); | |
907 | + c2.setTime(end); | |
908 | + result = c2.get(Calendar.MONTH) - c1.get(Calendar.MONTH); | |
909 | + result += 12 * (c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR)); | |
910 | + if(c2.get(Calendar.DAY_OF_MONTH) - c1.get(Calendar.DAY_OF_MONTH) < 0 && result > 0) { | |
911 | + result -= 1; | |
912 | + } | |
913 | + } catch (Exception e) { | |
914 | + e.printStackTrace(); | |
915 | + } | |
916 | + return Math.abs(result); | |
917 | + } | |
918 | + | |
919 | + /** | |
920 | + * 获取两个日期直接的天数(只算最后的天数) | |
921 | + * 比如 2017-10-10 2017-11-20 返回 10 | |
922 | + * @param start | |
923 | + * @param end | |
924 | + * @return | |
925 | + */ | |
926 | + public static Integer getExcludeMonthDay(Date start, Date end) { | |
927 | + int result = 0; | |
928 | + try { | |
929 | + Calendar c1 = Calendar.getInstance(); | |
930 | + Calendar c2 = Calendar.getInstance(); | |
931 | + c1.setTime(start); | |
932 | + c2.setTime(end); | |
933 | + | |
934 | + int endDay = c2.get(Calendar.DAY_OF_MONTH); | |
935 | + int startDay = c1.get(Calendar.DAY_OF_MONTH); | |
936 | + if(endDay >= startDay) { | |
937 | + result = endDay - startDay; | |
938 | + } else { /** 获取上个月天数 + endDate天数 - startDate天数 */ | |
939 | + c2.add(Calendar.MONTH,-1);/** 得到上个月的月份 */ | |
940 | + result = c2.getActualMaximum(Calendar.DAY_OF_MONTH) + endDay - startDay; | |
941 | + } | |
942 | + | |
943 | + } catch (Exception e) { | |
944 | + e.printStackTrace(); | |
945 | + } | |
946 | + return result; | |
947 | + } | |
948 | + | |
894 | 949 | public static void main(String[] arg) throws Exception { |
895 | - Date start = parseYMD("2016-05-01"); | |
896 | - Date end = parseYMD("2016-05-11"); | |
897 | - System.out.println(getWeekDesc(start, end)); | |
898 | - String s = DateUtil.getyyyy_MM_dd_hms(new Date(1496829600000L)); | |
899 | - System.out.println(s); | |
950 | + Date start = parseYMD("2017-05-11"); | |
951 | + Date end = parseYMD("2017-06-02"); | |
952 | + System.err.println(getMonthDesc(start, end)); | |
953 | + } | |
954 | + | |
955 | + | |
956 | + /** | |
957 | + * 获取月龄描述信息 优惠券使用时间 - 分娩时间 | |
958 | + * @param start | |
959 | + * @param end | |
960 | + * @return | |
961 | + */ | |
962 | + public static String getMonthDesc(Date start, Date end) { | |
963 | + if(start == null || end == null) { | |
964 | + return "0月龄+0天"; | |
965 | + } | |
966 | + int month = getMonth(start, end); | |
967 | + int day = getExcludeMonthDay(start, end); | |
968 | + return month + "月龄+" + day + "天"; | |
900 | 969 | } |
901 | 970 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
fec2737
... | ... | @@ -5,7 +5,6 @@ |
5 | 5 | import com.lyms.platform.common.result.BaseObjectResponse; |
6 | 6 | import com.lyms.platform.common.result.PageResult; |
7 | 7 | import com.lyms.platform.common.result.RespBuilder; |
8 | -import com.lyms.platform.common.result.ResponseCode; | |
9 | 8 | import com.lyms.platform.common.utils.DateUtil; |
10 | 9 | import com.lyms.platform.common.utils.EnumUtil; |
11 | 10 | import com.lyms.platform.operate.web.dao.IReportDao; |
12 | 11 | |
... | ... | @@ -13,11 +12,10 @@ |
13 | 12 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
14 | 13 | import com.lyms.platform.operate.web.service.IReportService; |
15 | 14 | import com.lyms.platform.operate.web.utils.*; |
16 | -import com.lyms.platform.operate.web.utils.CollectionUtils; | |
17 | 15 | import com.lyms.platform.permission.dao.master.CouponMapper; |
18 | 16 | import com.lyms.platform.pojo.*; |
19 | 17 | import com.lymsh.platform.reportdata.model.echarts.Series; |
20 | -import org.apache.commons.collections.*; | |
18 | +import org.apache.commons.collections.MapUtils; | |
21 | 19 | import org.apache.commons.lang.StringUtils; |
22 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
23 | 21 | import org.springframework.data.domain.Sort; |
24 | 22 | |
... | ... | @@ -26,10 +24,8 @@ |
26 | 24 | import org.springframework.data.mongodb.core.query.Query; |
27 | 25 | import org.springframework.stereotype.Service; |
28 | 26 | import org.springframework.util.Assert; |
29 | -import scala.util.parsing.combinator.testing.Str; | |
30 | 27 | |
31 | 28 | import javax.servlet.http.HttpServletResponse; |
32 | -import java.lang.reflect.Method; | |
33 | 29 | import java.sql.PreparedStatement; |
34 | 30 | import java.sql.ResultSet; |
35 | 31 | import java.sql.SQLException; |
... | ... | @@ -777,7 +773,7 @@ |
777 | 773 | String operatorOrgName = null; /** 产检机构 */ |
778 | 774 | String phone = null; /** 联系电话 */ |
779 | 775 | String doctorName = couponMapper.findUserName(operatorUserId); /** 使用医生 */ |
780 | - if(type == 1) { | |
776 | + if(type == 1 || type == 3) { | |
781 | 777 | Patients patients = mongoTemplate.findById(usedId, Patients.class); |
782 | 778 | if(patients != null) { |
783 | 779 | checkDate = patients.getCreated(); |
... | ... | @@ -818,6 +814,56 @@ |
818 | 814 | phone = findPhoneByPid(antenatal.getPid()); |
819 | 815 | } |
820 | 816 | } |
817 | + } else if(type == 4) { | |
818 | + MaternalDeliverModel maternalDeliverModel = mongoTemplate.findById(usedId, MaternalDeliverModel.class); | |
819 | + if(maternalDeliverModel != null) { | |
820 | + /** 使用时间 - 分娩时间 */ | |
821 | + week = DateUtil.getWeekDesc(findLastMensesByPatientId(maternalDeliverModel.getParentId()), useDate); | |
822 | + username = findUserNameByPid(maternalDeliverModel.getPid()); | |
823 | + operatorOrgName = couponMapper.findHospitalNameById(maternalDeliverModel.getHospitalId()); | |
824 | + phone = findPhoneByPid(maternalDeliverModel.getHospitalId()); | |
825 | + } | |
826 | + } else if(type == 5) { | |
827 | + DischargeAbstractMotherModel monther = mongoTemplate.findById(usedId, DischargeAbstractMotherModel.class); | |
828 | + if(monther != null) { | |
829 | + username = findUserNameByPid(monther.getpId()); | |
830 | + phone = findPhoneByPid(monther.getpId()); | |
831 | + String patientId = monther.getPatientId(); | |
832 | + if(StringUtils.isNotEmpty(patientId)) { | |
833 | + Patients patients = mongoTemplate.findById(usedId, Patients.class); | |
834 | + if(patients != null) { | |
835 | + operatorOrgName = couponMapper.findHospitalNameById(patients.getHospitalId()); | |
836 | + week = "产后" + DateUtil.getDays(patients.getFmDate(), useDate) + "天"; | |
837 | + } | |
838 | + } | |
839 | + } | |
840 | + } else if(type == 6) { | |
841 | + PostReviewModel postReviewModel = mongoTemplate.findById(usedId, PostReviewModel.class); | |
842 | + if(postReviewModel != null) { | |
843 | + username = findUserNameByPid(postReviewModel.getPid()); | |
844 | + phone = findPhoneByPid(postReviewModel.getPid()); | |
845 | + operatorOrgName = couponMapper.findHospitalNameById(postReviewModel.getHospitalId()); | |
846 | + week = "产后" + DateUtil.getDays(findLastMensesByPatientId(postReviewModel.getParentId()), useDate) + "天"; | |
847 | + } | |
848 | + } else if(type == 7) { | |
849 | + BabyModel babyModel = mongoTemplate.findById(usedId, BabyModel.class); | |
850 | + if(babyModel != null) { | |
851 | + username = findUserNameByPid(babyModel.getPid()); | |
852 | + phone = findPhoneByPid(babyModel.getPid()); | |
853 | + operatorOrgName = couponMapper.findHospitalNameById(babyModel.getHospitalId()); | |
854 | + week = DateUtil.getMonthDesc(babyModel.getBirth(), useDate); | |
855 | + } | |
856 | + } else if(type == 8) { | |
857 | + BabyCheckModel babyCheckModel = mongoTemplate.findById(usedId, BabyCheckModel.class); | |
858 | + if(babyCheckModel != null) { | |
859 | + operatorOrgName = couponMapper.findHospitalNameById(babyCheckModel.getHospitalId()); | |
860 | + BabyModel babyModel = mongoTemplate.findById(babyCheckModel.getBuildId(), BabyModel.class); | |
861 | + if(babyModel != null) { | |
862 | + week = DateUtil.getMonthDesc(babyModel.getBirth(), useDate); | |
863 | + username = findUserNameByPid(babyModel.getPid()); | |
864 | + phone = findPhoneByPid(babyModel.getPid()); | |
865 | + } | |
866 | + } | |
821 | 867 | } |
822 | 868 | |
823 | 869 | map.put("checkDate", checkDate == null ? null : DateUtil.getyyyy_MM_dd(checkDate)); |
... | ... | @@ -849,6 +895,16 @@ |
849 | 895 | return null; |
850 | 896 | } |
851 | 897 | |
898 | + private Date findLastMensesByPatientId(String id) { | |
899 | + if(StringUtils.isNotEmpty(id)) { | |
900 | + Patients patients = mongoTemplate.findById(id, Patients.class); | |
901 | + if(patients != null) { | |
902 | + return patients.getLastMenses(); | |
903 | + } | |
904 | + } | |
905 | + return null; | |
906 | + } | |
907 | + | |
852 | 908 | private <T> Integer findNumberByList(String sortField, String key, String value, T current, Class<T> clazz) { |
853 | 909 | Integer number = 1; |
854 | 910 | List<T> lists = mongoTemplate.find(Query.query(Criteria.where(key).is(value)).with(new Sort(Sort.Direction.ASC, sortField)), clazz); |
... | ... | @@ -951,74 +1007,6 @@ |
951 | 1007 | } |
952 | 1008 | ResponseUtil.responseExcel(cnames, results, response); |
953 | 1009 | } |
954 | - | |
955 | - /*private void setUsedInfo(Map<String, Object> map) { | |
956 | - String sequenceId = (String) map.get("sequence_id"); | |
957 | - Integer type = (Integer) map.get("type"); | |
958 | - if(StringUtils.isEmpty(sequenceId) || type == null) return; | |
959 | - | |
960 | - | |
961 | - if(type == 1) { | |
962 | - Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("").is(sequenceId)), Patients.class); | |
963 | - if(patients != null) { | |
964 | - map.put("checkDate", patients.getCreated()); *//** 产检日期 *//* | |
965 | - } | |
966 | - } | |
967 | - | |
968 | - AntExChuModel antexc = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequenceId)), AntExChuModel.class); | |
969 | - if(antexc != null) { | |
970 | - map.put("checkDate", antexc.getCheckTime()); *//** 产检日期 *//* | |
971 | - Patients patients = mongoTemplate.findById(antexc.getParentId(), Patients.class); | |
972 | - if(patients != null) { | |
973 | - map.put("username", patients.getUsername()); *//** 姓名 *//* | |
974 | - } | |
975 | - map.put("week", DateUtil.getWeek(antexc.getLastMenses(), antexc.getCheckTime()));*//** 产检孕周 = 产检时间 - 末次月经 *//* | |
976 | - | |
977 | - List<AntExChuModel> antExChuModels = mongoTemplate.find(Query.query(Criteria.where("pid").is(antexc.getPid())).with(new Sort(Sort.Direction.ASC, "checkTime")), AntExChuModel.class); | |
978 | - if(org.apache.commons.collections.CollectionUtils.isNotEmpty(antExChuModels)) { | |
979 | - for(int i = 0; i < antExChuModels.size(); i++) { | |
980 | - if(antExChuModels.get(i).getId().equals(antexc.getId())) { | |
981 | - map.put("number", ++i); *//** 产检第几次 *//* | |
982 | - return; | |
983 | - } | |
984 | - } | |
985 | - } | |
986 | - | |
987 | - map.put("doctorName", couponMapper.findUserName(antexc.getProdDoctor())); *//** 产检医生 *//* | |
988 | - map.put("operatorOrgName", couponMapper.findUserName(antexc.getOperator() + "")); *//** 产检机构 *//* | |
989 | - PersonModel personModel = mongoTemplate.findById(map.get("user_id"), PersonModel.class); | |
990 | - if(personModel != null) { | |
991 | - map.put("phone", personModel.getPhone()); | |
992 | - } else { | |
993 | - map.put("phone", null); | |
994 | - } | |
995 | - } else { | |
996 | - AntenatalExaminationModel antenatal = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequenceId)), AntenatalExaminationModel.class); | |
997 | - if(antenatal != null) { | |
998 | - map.put("checkDate", antenatal.getCheckDate()); *//** 产检日期 *//* | |
999 | - Patients patients = mongoTemplate.findById(antenatal.getParentId(), Patients.class); | |
1000 | - if(patients != null) { | |
1001 | - map.put("username", patients.getUsername()); *//** 姓名 *//* | |
1002 | - } | |
1003 | - map.put("week", antenatal.getCurrentDueDate());*//** 产检孕周 = 产检时间 - 末次月经 *//* | |
1004 | - map.put("number", antenatal.getYn()); *//** 产检第几次 *//* | |
1005 | - map.put("doctorName", couponMapper.findUserName(antenatal.getCheckDoctor())); *//** 产检医生 *//* | |
1006 | - map.put("operatorOrgName", couponMapper.findUserName(antenatal.getOperator() + "")); *//** 产检机构 *//* | |
1007 | - map.put("phone", couponMapper.findPhone(antenatal.getOperator() + "")); | |
1008 | - } | |
1009 | - } | |
1010 | - | |
1011 | - Date useDate = (Date) map.get("use_date"); | |
1012 | - String usedId = (String) map.get("used_id"); | |
1013 | - if(StringUtils.isNotBlank(usedId)) { | |
1014 | - BabyModel babyModel = mongoTemplate.findById(usedId, BabyModel.class); | |
1015 | - if (babyModel != null) { | |
1016 | - Date birth = babyModel.getBirth(); | |
1017 | - Integer day = DateUtil.getDays(birth, useDate); | |
1018 | - map.put("use_day", "产后" + day + "天"); | |
1019 | - } | |
1020 | - } | |
1021 | - }*/ | |
1022 | 1010 | |
1023 | 1011 | private String findName(Object id) { |
1024 | 1012 | if(id != null) { |