Commit cfe44e0a36c2ab61c92116ccca1fef666d98b010

Authored by litao
1 parent d187cd9b82

统计详情

Showing 4 changed files with 151 additions and 68 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java View file @ cfe44e0
... ... @@ -57,7 +57,7 @@
57 57  
58 58 Map<String,Object> findHospitalName(Map<String, Object> param);
59 59  
60   - String findUserName(String prodDoctor);
  60 + String findUserName(String userId);
61 61  
62 62 String findPhone(String s);
63 63  
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml View file @ cfe44e0
... ... @@ -345,22 +345,23 @@
345 345  
346 346 <select id="findCouponInfoCount" parameterType="map" resultType="integer">
347 347 select count(1) from (
348   - select c.type, a.sequence_id, d.name
349   - from coupon_info a, coupon_template b, coupon_type c, users d, organization e, hospital_coupon_template_group f
350   - where a.coupon_template_id = b.id and b.type_id = c.id and a.user_id = d.id and a.status=2 and a.create_hospital_id = e.id
351   - and a.used_hospital_id = #{hospitalId} and f.hospital_id = a.used_hospital_id and c.type in
352   - <foreach collection="couponType" open="(" close=")" separator="," item="type">
353   - #{type}
354   - </foreach>
355   - <if test="startDate != null">
356   - and a.create_date >= #{startDate}
357   - </if>
358   - <if test="endDate != null">
359   - and a.create_date <![CDATA[ < ]]> #{endDate}
360   - </if>
361   - <if test="tempId != null and tempId != ''">
362   - and f.coupon_template_group_id = #{tempId}
363   - </if>
  348 + select a.used_hospital_id, c.type, b.coupon_order, a.sequence_id, d.name as send_hospital, a.use_date, a.used_id
  349 + from coupon_info a, coupon_template b, coupon_type c, organization d
  350 + where a.coupon_template_id = b.id and b.type_id = c.id and a.create_hospital_id = d.id
  351 + and a.used_hospital_id in
  352 + <foreach collection="hospitalId" open="(" close=")" separator="," item="hid">
  353 + #{hid}
  354 + </foreach>
  355 + and c.type in
  356 + <foreach collection="couponType" open="(" close=")" separator="," item="type">
  357 + #{type}
  358 + </foreach>
  359 + <if test="startDate != null">
  360 + and a.use_date >= #{startDate}
  361 + </if>
  362 + <if test="endDate != null">
  363 + and a.use_date <![CDATA[ < ]]> #{endDate}
  364 + </if>
364 365 ) a
365 366 </select>
366 367  
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java View file @ cfe44e0
... ... @@ -878,19 +878,23 @@
878 878 return startTime < time && time < endTime ? true : false;
879 879 }
880 880  
881   - public static void main(String[] arg) throws Exception {
882   - Date now = new Date();
883   - Date start = y_m_d_h_m_s.parse("2017-04-30 11:11:11");
884   - Date end = y_m_d_h_m_s.parse("2017-04-30 11:11:11");
885   - System.out.println(isBetween(now, start, end));
  881 + /**
  882 + * 把一段时间 拼成 孕?周+?天
  883 + * @param start
  884 + * @param end
  885 + * @return
  886 + */
  887 + public static String getWeekDesc(Date start, Date end) {
  888 + Integer betweenDay = DateUtil.getDays(start, end);
  889 + Integer week = betweenDay / 7;
  890 + Integer day = betweenDay % 7;
  891 + return "孕" + week + "周+" + day + "天";
  892 + }
886 893  
887   - System.out.println(org.apache.commons.lang3.time.DateUtils.addMonths(start ,1).toLocaleString());
888   - long startTime = 1483372800000l;
889   - long endTime = end.getTime();
890   - System.out.println();
891   -
892   - Date d2 = new Date();
893   - System.out.println(isLtOrEq(start, end));
  894 + 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));
894 898 }
895 899 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ cfe44e0
... ... @@ -702,12 +702,12 @@
702 702 .replace("</div>", "");
703 703 couponInfo.put("type_desc", s);
704 704 }
705   - couponInfo.put("use_date", DateUtil.getYmd((Date) couponInfo.get("use_date")));
706   - setUsedInfo(couponInfo);
  705 + Date useDate = (Date) couponInfo.get("use_date");
  706 + couponInfo.put("use_date", DateUtil.getYmd(useDate));
  707 +// setUsedInfo(couponInfo);
707 708 /** 设置产检日期、姓名、产检孕周、产检第次、产检机构、产检医生、联系电话 */
708   - setUsedInfo((String) couponInfo.get("type"),
709   - (String) couponInfo.get("used_id"),
710   - (String) couponInfo.get("sequence_id")
  709 + setUsedInfo((Integer) couponInfo.get("type"), (String) couponInfo.get("used_id"),
  710 + (String) couponInfo.get("sequence_id"), useDate, couponInfo
711 711 );
712 712 }
713 713 }
714 714  
715 715  
... ... @@ -716,15 +716,105 @@
716 716 return RespBuilder.buildSuccess(pageResult);
717 717 }
718 718  
719   - private void setUsedInfo(String type, String used_id, String sequence_id) {
720   - Date checkDate = null;
721   - String name = null;
722   - Integer number = null;
723   - if("1".equals(type)) {
724   - Patients one = mongoTemplate.findOne(Query.query(Criteria.where("1").is("1")), Patients.class);
  719 + /**
  720 + * type
  721 + * 1=孕妇建档 lyms_patient
  722 + * 2=孕妇产检 lyms_antexc(初诊),lyms_antex(复诊)
  723 + * 3=产妇建档 lyms_patient
  724 + * 4=产妇分娩 lyms_matdeliver
  725 + * 5=产妇出院小结 lyms_discharge_abstract_mother
  726 + * 6=产妇产后复查 lyms_postreview
  727 + * 7=儿童建档 lyms_baby
  728 + * 8=儿童保健 lyms_babycheck
  729 + */
  730 + private void setUsedInfo(Integer type, String usedId, String sequence_id, Date useDate, Map<String, Object> map) {
  731 + Date checkDate = null; /** 产检日期 */
  732 + String username = null; /** 姓名 */
  733 + String week = null; /** 产检孕周 = 产检时间 - 末次月经 */
  734 + Integer number = null; /** 产检第次 */
  735 + String operatorOrgName = null; /** 产检机构 */
  736 + String doctorName = null; /** 产检医生 */
  737 + String phone = null; /** 联系电话 */
  738 + if(type == 1) {
  739 + Patients patients = mongoTemplate.findById(usedId, Patients.class);
  740 + if(patients != null) {
  741 + checkDate = patients.getCreated();
  742 + username = patients.getUsername();
  743 + week = DateUtil.getWeekDesc(patients.getLastMenses(), checkDate);
  744 + List<Patients> patientsList = mongoTemplate.find(Query.query(Criteria.where("pid").is(patients.getPid())).with(new Sort(Sort.Direction.ASC, "created")), Patients.class);
  745 + for(int i = 0; i < patientsList.size(); i++) {
  746 + if(patientsList.get(i).getId().equals(patients.getId())) {
  747 + number = ++i;
  748 + }
  749 + }
  750 + operatorOrgName = couponMapper.findHospitalNameById(patients.getHospitalId());
  751 + doctorName = couponMapper.findUserName(patients.getLastCheckEmployeeId());
  752 + phone = patients.getPhone();
  753 + }
  754 + } else if(type == 2) {
  755 + AntExChuModel antexc = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequence_id)), AntExChuModel.class);
  756 + if(antexc != null) {
  757 + map.put("checkDate", antexc.getCheckTime()); /** 产检日期 */
  758 + Patients patients = mongoTemplate.findById(antexc.getParentId(), Patients.class);
  759 + if(patients != null) {
  760 + map.put("username", patients.getUsername()); /** 姓名 */
  761 + }
  762 + map.put("week", DateUtil.getWeek(antexc.getLastMenses(), antexc.getCheckTime()));/** 产检孕周 = 产检时间 - 末次月经 */
  763 +
  764 + List<AntExChuModel> antExChuModels = mongoTemplate.find(Query.query(Criteria.where("pid").is(antexc.getPid())).with(new Sort(Sort.Direction.ASC, "checkTime")), AntExChuModel.class);
  765 + if(org.apache.commons.collections.CollectionUtils.isNotEmpty(antExChuModels)) {
  766 + for(int i = 0; i < antExChuModels.size(); i++) {
  767 + if(antExChuModels.get(i).getId().equals(antexc.getId())) {
  768 + map.put("number", ++i); /** 产检第几次 */
  769 + return;
  770 + }
  771 + }
  772 + }
  773 +
  774 + map.put("doctorName", couponMapper.findUserName(antexc.getProdDoctor())); /** 产检医生 */
  775 + map.put("operatorOrgName", couponMapper.findUserName(antexc.getOperator() + "")); /** 产检机构 */
  776 + PersonModel personModel = mongoTemplate.findById(map.get("user_id"), PersonModel.class);
  777 + if(personModel != null) {
  778 + map.put("phone", personModel.getPhone());
  779 + } else {
  780 + map.put("phone", null);
  781 + }
  782 + } else {
  783 + AntenatalExaminationModel antenatal = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequenceId)), AntenatalExaminationModel.class);
  784 + if(antenatal != null) {
  785 + map.put("checkDate", antenatal.getCheckDate()); /** 产检日期 */
  786 + Patients patients = mongoTemplate.findById(antenatal.getParentId(), Patients.class);
  787 + if(patients != null) {
  788 + map.put("username", patients.getUsername()); /** 姓名 */
  789 + }
  790 + map.put("week", antenatal.getCurrentDueDate());/** 产检孕周 = 产检时间 - 末次月经 */
  791 + map.put("number", antenatal.getYn()); /** 产检第几次 */
  792 + map.put("doctorName", couponMapper.findUserName(antenatal.getCheckDoctor())); /** 产检医生 */
  793 + map.put("operatorOrgName", couponMapper.findUserName(antenatal.getOperator() + "")); /** 产检机构 */
  794 + map.put("phone", couponMapper.findPhone(antenatal.getOperator() + ""));
  795 + }
  796 + }
725 797 }
  798 +
  799 + map.put("checkDate", checkDate);
  800 + map.put("username", username);
  801 + map.put("week", week);
  802 + map.put("number", number);
  803 + map.put("operatorOrgName", operatorOrgName);
  804 + map.put("doctorName", doctorName);
  805 + map.put("phone", phone);
726 806 }
727 807  
  808 + private String findUserNameByPid(String pid) {
  809 + if(StringUtils.isNotEmpty(pid)) {
  810 + PersonModel personModel = mongoTemplate.findById(pid, PersonModel.class);
  811 + if(personModel != null) {
  812 + return personModel.getName();
  813 + }
  814 + }
  815 + return null;
  816 + }
  817 +
728 818 @Override
729 819 public void exportCouponInfo(Map<String, Object> param, HttpServletResponse response) {
730 820 BaseObjectResponse resp = couponInfo(param);
731 821  
732 822  
733 823  
734 824  
735 825  
736 826  
737 827  
... ... @@ -808,50 +898,40 @@
808 898 ResponseUtil.responseExcel(cnames, results, response);
809 899 }
810 900  
811   - private void setUsedInfo(Map<String, Object> map) {
  901 + /*private void setUsedInfo(Map<String, Object> map) {
812 902 String sequenceId = (String) map.get("sequence_id");
813 903 Integer type = (Integer) map.get("type");
814 904 if(StringUtils.isEmpty(sequenceId) || type == null) return;
815 905  
816   - /**
817   - * type
818   - 1=孕妇建档 lyms_patient
819   - 2=孕妇产检 lyms_antexc(初诊),lyms_antex(复诊)
820   - 3=产妇建档
821   - 4=产妇分娩 lyms_matdeliver
822   - 5=产妇出院小结 lyms_discharge_abstract_mother
823   - 6=产妇产后复查 lyms_postreview
824   - 7=儿童建档 lyms_baby
825   - 8=儿童保健 lyms_babycheck
826   - */
  906 +
827 907 if(type == 1) {
828 908 Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("").is(sequenceId)), Patients.class);
829 909 if(patients != null) {
830   - map.put("checkDate", patients.getCreated()); /** 产检日期 */
  910 + map.put("checkDate", patients.getCreated()); *//** 产检日期 *//*
831 911 }
832 912 }
833 913  
834 914 AntExChuModel antexc = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequenceId)), AntExChuModel.class);
835 915 if(antexc != null) {
836   - map.put("checkDate", antexc.getCheckTime()); /** 产检日期 */
  916 + map.put("checkDate", antexc.getCheckTime()); *//** 产检日期 *//*
837 917 Patients patients = mongoTemplate.findById(antexc.getParentId(), Patients.class);
838 918 if(patients != null) {
839   - map.put("username", patients.getUsername()); /** 姓名 */
  919 + map.put("username", patients.getUsername()); *//** 姓名 *//*
840 920 }
841   - map.put("week", DateUtil.getWeek(antexc.getLastMenses(), antexc.getCheckTime()));/** 产检孕周 = 产检时间 - 末次月经 */
  921 + map.put("week", DateUtil.getWeek(antexc.getLastMenses(), antexc.getCheckTime()));*//** 产检孕周 = 产检时间 - 末次月经 *//*
842 922  
843 923 List<AntExChuModel> antExChuModels = mongoTemplate.find(Query.query(Criteria.where("pid").is(antexc.getPid())).with(new Sort(Sort.Direction.ASC, "checkTime")), AntExChuModel.class);
844 924 if(org.apache.commons.collections.CollectionUtils.isNotEmpty(antExChuModels)) {
845 925 for(int i = 0; i < antExChuModels.size(); i++) {
846 926 if(antExChuModels.get(i).getId().equals(antexc.getId())) {
847   - map.put("number", ++i); /** 产检第几次 */
  927 + map.put("number", ++i); *//** 产检第几次 *//*
848 928 return;
849 929 }
850 930 }
851 931 }
852 932  
853   - map.put("doctorName", couponMapper.findUserName(antexc.getProdDoctor())); /** 产检医生 */
854   - map.put("operatorOrgName", couponMapper.findUserName(antexc.getOperator() + "")); /** 产检机构 */
  933 + map.put("doctorName", couponMapper.findUserName(antexc.getProdDoctor())); *//** 产检医生 *//*
  934 + map.put("operatorOrgName", couponMapper.findUserName(antexc.getOperator() + "")); *//** 产检机构 *//*
855 935 PersonModel personModel = mongoTemplate.findById(map.get("user_id"), PersonModel.class);
856 936 if(personModel != null) {
857 937 map.put("phone", personModel.getPhone());
858 938  
859 939  
... ... @@ -861,15 +941,15 @@
861 941 } else {
862 942 AntenatalExaminationModel antenatal = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequenceId)), AntenatalExaminationModel.class);
863 943 if(antenatal != null) {
864   - map.put("checkDate", antenatal.getCheckDate()); /** 产检日期 */
  944 + map.put("checkDate", antenatal.getCheckDate()); *//** 产检日期 *//*
865 945 Patients patients = mongoTemplate.findById(antenatal.getParentId(), Patients.class);
866 946 if(patients != null) {
867   - map.put("username", patients.getUsername()); /** 姓名 */
  947 + map.put("username", patients.getUsername()); *//** 姓名 *//*
868 948 }
869   - map.put("week", antenatal.getCurrentDueDate());/** 产检孕周 = 产检时间 - 末次月经 */
870   - map.put("number", antenatal.getYn()); /** 产检第几次 */
871   - map.put("doctorName", couponMapper.findUserName(antenatal.getCheckDoctor())); /** 产检医生 */
872   - map.put("operatorOrgName", couponMapper.findUserName(antenatal.getOperator() + "")); /** 产检机构 */
  949 + map.put("week", antenatal.getCurrentDueDate());*//** 产检孕周 = 产检时间 - 末次月经 *//*
  950 + map.put("number", antenatal.getYn()); *//** 产检第几次 *//*
  951 + map.put("doctorName", couponMapper.findUserName(antenatal.getCheckDoctor())); *//** 产检医生 *//*
  952 + map.put("operatorOrgName", couponMapper.findUserName(antenatal.getOperator() + "")); *//** 产检机构 *//*
873 953 map.put("phone", couponMapper.findPhone(antenatal.getOperator() + ""));
874 954 }
875 955 }
... ... @@ -884,7 +964,7 @@
884 964 map.put("use_day", "产后" + day + "天");
885 965 }
886 966 }
887   - }
  967 + }*/
888 968  
889 969 private String findName(Object id) {
890 970 if(id != null) {
... ... @@ -957,7 +1037,6 @@
957 1037 .append("D.DOCTOR_NAME ")
958 1038 .append("ORDER BY D.INSERT_DATE DESC");
959 1039  
960   - System.out.println(sql.toString());
961 1040 return sql.toString();
962 1041 }
963 1042  
... ... @@ -1217,7 +1296,6 @@
1217 1296 params.add(number);
1218 1297 }
1219 1298  
1220   - System.out.println(sql.toString());
1221 1299 return sql.toString();
1222 1300 }
1223 1301