Commit 55b6f83275944038fe5db4149e50735737bc2dfb
1 parent
b8aa5c320e
Exists in
master
and in
6 other branches
统计详情bug修复
Showing 2 changed files with 85 additions and 38 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
55b6f83
| ... | ... | @@ -28,6 +28,7 @@ |
| 28 | 28 | import scala.util.parsing.combinator.testing.Str; |
| 29 | 29 | |
| 30 | 30 | import javax.servlet.http.HttpServletResponse; |
| 31 | +import java.lang.reflect.Method; | |
| 31 | 32 | import java.sql.PreparedStatement; |
| 32 | 33 | import java.sql.ResultSet; |
| 33 | 34 | import java.sql.SQLException; |
| ... | ... | @@ -703,7 +704,7 @@ |
| 703 | 704 | couponInfo.put("type_desc", s); |
| 704 | 705 | } |
| 705 | 706 | Date useDate = (Date) couponInfo.get("use_date"); |
| 706 | - couponInfo.put("use_date", DateUtil.getYmd(useDate)); | |
| 707 | + couponInfo.put("use_date", DateUtil.getyyyy_MM_dd(useDate)); | |
| 707 | 708 | // setUsedInfo(couponInfo); |
| 708 | 709 | /** 设置产检日期、姓名、产检孕周、产检第次、产检机构、产检医生、联系电话 */ |
| 709 | 710 | setUsedInfo((Integer) couponInfo.get("type"), (String) couponInfo.get("used_id"), |
| ... | ... | @@ -731,7 +732,7 @@ |
| 731 | 732 | Date checkDate = null; /** 产检日期 */ |
| 732 | 733 | String username = null; /** 姓名 */ |
| 733 | 734 | String week = null; /** 产检孕周 = 产检时间 - 末次月经 */ |
| 734 | - Integer number = null; /** 产检第次 */ | |
| 735 | + Integer number = 1; /** 产检第次 */ | |
| 735 | 736 | String operatorOrgName = null; /** 产检机构 */ |
| 736 | 737 | String doctorName = null; /** 产检医生 */ |
| 737 | 738 | String phone = null; /** 联系电话 */ |
| 738 | 739 | |
| 739 | 740 | |
| 740 | 741 | |
| 741 | 742 | |
| ... | ... | @@ -752,51 +753,37 @@ |
| 752 | 753 | phone = patients.getPhone(); |
| 753 | 754 | } |
| 754 | 755 | } else if(type == 2) { |
| 755 | - AntExChuModel antexc = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequence_id)), AntExChuModel.class); | |
| 756 | + AntExChuModel antexc = mongoTemplate.findById(usedId, AntExChuModel.class); | |
| 756 | 757 | 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 | - } | |
| 758 | + checkDate = antexc.getCheckTime(); | |
| 759 | + username = findUserNameByPid(antexc.getPid()); | |
| 760 | + week = DateUtil.getWeekDesc(antexc.getLastMenses(), antexc.getCheckTime()); | |
| 761 | + number = findNumberByList("checkTime", "pid", antexc.getPid(), antexc, AntExChuModel.class); | |
| 762 | + operatorOrgName = couponMapper.findHospitalNameById(antexc.getHospitalId()); | |
| 763 | + doctorName = couponMapper.findUserName(antexc.getProdDoctor()); | |
| 764 | + phone = findPhoneByPid(antexc.getPid()); | |
| 782 | 765 | } else { |
| 783 | 766 | AntenatalExaminationModel antenatal = mongoTemplate.findOne(Query.query(Criteria.where("barCode").is(sequence_id)), AntenatalExaminationModel.class); |
| 784 | 767 | 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()); /** 姓名 */ | |
| 768 | + checkDate = antenatal.getCheckDate(); | |
| 769 | + username = findUserNameByPid(antenatal.getPid()); | |
| 770 | + week = antenatal.getCurrentDueDate(); | |
| 771 | + List<AntenatalExaminationModel> antExChuModels = mongoTemplate.find(Query.query(Criteria.where("pid").is(antenatal.getPid())).with(new Sort(Sort.Direction.ASC, "created")), AntenatalExaminationModel.class); | |
| 772 | + if(CollectionUtils.isNotEmpty(antExChuModels)) { | |
| 773 | + for(int i = 0; i < antExChuModels.size(); i++) { | |
| 774 | + if(antExChuModels.get(i).getId().equals(antenatal.getId())) { | |
| 775 | + number = ++i; | |
| 776 | + } | |
| 777 | + } | |
| 789 | 778 | } |
| 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() + "")); | |
| 779 | + doctorName = couponMapper.findUserName(antenatal.getCheckDoctor()); | |
| 780 | + operatorOrgName = couponMapper.findHospitalNameById(antenatal.getHospitalId()); | |
| 781 | + phone = findPhoneByPid(antenatal.getPid()); | |
| 795 | 782 | } |
| 796 | 783 | } |
| 797 | 784 | } |
| 798 | 785 | |
| 799 | - map.put("checkDate", checkDate); | |
| 786 | + map.put("checkDate", checkDate == null ? null : DateUtil.getyyyy_MM_dd(checkDate)); | |
| 800 | 787 | map.put("username", username); |
| 801 | 788 | map.put("week", week); |
| 802 | 789 | map.put("number", number); |
| ... | ... | @@ -813,6 +800,36 @@ |
| 813 | 800 | } |
| 814 | 801 | } |
| 815 | 802 | return null; |
| 803 | + } | |
| 804 | + | |
| 805 | + private String findPhoneByPid(String pid) { | |
| 806 | + if(StringUtils.isNotEmpty(pid)) { | |
| 807 | + PersonModel personModel = mongoTemplate.findById(pid, PersonModel.class); | |
| 808 | + if(personModel != null) { | |
| 809 | + return personModel.getPhone(); | |
| 810 | + } | |
| 811 | + } | |
| 812 | + return null; | |
| 813 | + } | |
| 814 | + | |
| 815 | + private <T> Integer findNumberByList(String sortField, String key, String value, T current, Class<T> clazz) { | |
| 816 | + Integer number = 1; | |
| 817 | + List<T> lists = mongoTemplate.find(Query.query(Criteria.where(key).is(value)).with(new Sort(Sort.Direction.ASC, sortField)), clazz); | |
| 818 | + if(CollectionUtils.isNotEmpty(lists)) { | |
| 819 | + try { | |
| 820 | + for(int i = 0; i < lists.size(); i++) { | |
| 821 | + T t = lists.get(i); | |
| 822 | + String tId = ReflectUtil.invoke(t, "getId") + ""; | |
| 823 | + String currentId = ReflectUtil.invoke(current, "getId") + ""; | |
| 824 | + if(StringUtils.isNotEmpty(tId) && StringUtils.isNotEmpty(currentId) && tId.equals(currentId)) { | |
| 825 | + number = ++i; | |
| 826 | + } | |
| 827 | + } | |
| 828 | + } catch (Exception e) { | |
| 829 | + e.printStackTrace(); | |
| 830 | + } | |
| 831 | + } | |
| 832 | + return number; | |
| 816 | 833 | } |
| 817 | 834 | |
| 818 | 835 | @Override |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/ReflectUtil.java
View file @
55b6f83
| 1 | +package com.lyms.platform.operate.web.utils; | |
| 2 | + | |
| 3 | +import java.lang.reflect.Method; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 反射相关工具类 | |
| 7 | + * @Author: litao | |
| 8 | + * @Date: 2017/6/7 0007 17:02 | |
| 9 | + * @Version: V1.0 | |
| 10 | + */ | |
| 11 | +public class ReflectUtil { | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * 调用getxxx获取到值 | |
| 15 | + * @param obj | |
| 16 | + * @param methodName | |
| 17 | + * @return | |
| 18 | + */ | |
| 19 | + public static Object invoke(Object obj, String methodName) { | |
| 20 | + Object rest = null; | |
| 21 | + try { | |
| 22 | + Method method = obj.getClass().getMethod(methodName, null); | |
| 23 | + rest = method.invoke(obj, null); | |
| 24 | + } catch (Exception e) { | |
| 25 | + e.printStackTrace(); | |
| 26 | + } | |
| 27 | + return rest; | |
| 28 | + } | |
| 29 | + | |
| 30 | +} |