Commit dea1412b3900befda738a8641fd1706a24d0274f
1 parent
b898f4abaa
Exists in
master
自定义查询
Showing 7 changed files with 174 additions and 19 deletions
- platform-common/src/main/java/com/lyms/platform/common/utils/BeanUtils.java
- platform-common/src/main/java/com/lyms/platform/common/utils/InitBean.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MatDeliverController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/ChildbirthManagerRequest.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/PatientManagerQueryModel.java
platform-common/src/main/java/com/lyms/platform/common/utils/BeanUtils.java
View file @
dea1412
| ... | ... | @@ -193,5 +193,26 @@ | 
| 193 | 193 | } | 
| 194 | 194 | } | 
| 195 | 195 | |
| 196 | + /** | |
| 197 | + * @auther HuJiaqi | |
| 198 | + * @createTime 2016年12月28日 14时27分 | |
| 199 | + * @discription 创建一个String类型的bean | |
| 200 | + */ | |
| 201 | + public static Object createStringBean(Map map) { | |
| 202 | + try { | |
| 203 | + Map<String, Class<?>> temp = new HashMap<>(); | |
| 204 | + for (Object key : map.keySet()) { | |
| 205 | + temp.put(key.toString(), Class.forName("java.lang.String")); | |
| 206 | + } | |
| 207 | + InitBean initBean = new InitBean(temp); | |
| 208 | + for (Object key : map.keySet()) { | |
| 209 | + initBean.set(key.toString(), map.get(key).toString()); | |
| 210 | + } | |
| 211 | + return initBean.create(); | |
| 212 | + } catch (Exception e) { | |
| 213 | + throw new RuntimeException("创建String类型的bean异常" + e); | |
| 214 | + } | |
| 215 | + } | |
| 216 | + | |
| 196 | 217 | } | 
platform-common/src/main/java/com/lyms/platform/common/utils/InitBean.java
View file @
dea1412
| 1 | +package com.lyms.platform.common.utils; | |
| 2 | + | |
| 3 | +import org.springframework.cglib.beans.BeanGenerator; | |
| 4 | +import org.springframework.cglib.beans.BeanMap; | |
| 5 | + | |
| 6 | +import java.util.Map; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * @auther HuJiaqi | |
| 10 | + * @createTime 2016年12月28日 12时54分 | |
| 11 | + * @discription | |
| 12 | + */ | |
| 13 | +public class InitBean { | |
| 14 | + | |
| 15 | + private Object object = null; | |
| 16 | + | |
| 17 | + private BeanMap beanMap = null; | |
| 18 | + | |
| 19 | + public InitBean(Map<String, Class<?>> map) { | |
| 20 | + this.object = getBean(map); | |
| 21 | + this.beanMap = BeanMap.create(this.object); | |
| 22 | + } | |
| 23 | + | |
| 24 | + public void set(String key, Object value) { | |
| 25 | + beanMap.put(key, value); | |
| 26 | + } | |
| 27 | + | |
| 28 | + public Object get(String key) { | |
| 29 | + return beanMap.get(key); | |
| 30 | + } | |
| 31 | + | |
| 32 | + public Object create() { | |
| 33 | + return this.object; | |
| 34 | + } | |
| 35 | + | |
| 36 | + private Object getBean(Map<String, Class<?>> map) { | |
| 37 | + BeanGenerator generator = new BeanGenerator(); | |
| 38 | + for (String key : map.keySet()) { | |
| 39 | + generator.addProperty(key, map.get(key)); | |
| 40 | + } | |
| 41 | + return generator.create(); | |
| 42 | + } | |
| 43 | + | |
| 44 | +} | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MatDeliverController.java
View file @
dea1412
| ... | ... | @@ -26,10 +26,7 @@ | 
| 26 | 26 | import javax.servlet.http.HttpServletRequest; | 
| 27 | 27 | import javax.servlet.http.HttpServletResponse; | 
| 28 | 28 | import javax.validation.Valid; | 
| 29 | -import java.util.ArrayList; | |
| 30 | -import java.util.LinkedHashMap; | |
| 31 | -import java.util.List; | |
| 32 | -import java.util.Map; | |
| 29 | +import java.util.*; | |
| 33 | 30 | |
| 34 | 31 | /** | 
| 35 | 32 | * 产妇分娩记录 | 
| 36 | 33 | |
| ... | ... | @@ -124,12 +121,49 @@ | 
| 124 | 121 | BaseListResponse baseListResponse; | 
| 125 | 122 | try { | 
| 126 | 123 | childbirthManagerRequest.setOperatorId(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId()); | 
| 124 | + | |
| 125 | + Map<String, String> query; | |
| 126 | + if (StringUtils.isNotEmpty(childbirthManagerRequest.getInitQuery())) { | |
| 127 | + // 自定义查询 | |
| 128 | + query = new HashMap<>(); | |
| 129 | + String initQuery = childbirthManagerRequest.getInitQuery(); | |
| 130 | + for (String key : childbirthManagerRequest.getInitQueryMap().keySet()) { | |
| 131 | + if (initQuery.contains(key)) { | |
| 132 | + query.put(key, query.get(key)); | |
| 133 | + } | |
| 134 | + } | |
| 135 | + } else { | |
| 136 | + // 没有自定义查询,开始构造普通查询 | |
| 137 | + if (StringUtils.isEmpty(childbirthManagerRequest.getIsArea())) { | |
| 138 | + // 非区域 | |
| 139 | + query = childbirthManagerRequest.getNormalQueryMap(); | |
| 140 | + } else { | |
| 141 | + // 区域 | |
| 142 | + query = childbirthManagerRequest.getAraeQueryMap(); | |
| 143 | + } | |
| 144 | + String queryStr = ""; | |
| 145 | + for (String key : query.keySet()) { | |
| 146 | + queryStr += key + ","; | |
| 147 | + } | |
| 148 | + childbirthManagerRequest.setInitQuery(queryStr.substring(0, queryStr.length() - 1)); | |
| 149 | + } | |
| 150 | + | |
| 127 | 151 | ChildbirthManagerResult childbirthManagerResult = matDeliverFacade.childbirthManager(childbirthManagerRequest); | 
| 128 | 152 | if (childbirthManagerResult.getErrorcode() != ErrorCodeConstants.SUCCESS) { | 
| 129 | 153 | baseListResponse = new BaseListResponse().setErrorcode(childbirthManagerResult.getErrorcode()).setErrormsg(childbirthManagerResult.getErrormsg()); | 
| 130 | 154 | return baseListResponse; | 
| 131 | 155 | } | 
| 132 | - baseListResponse = new BaseListResponse().setErrorcode(childbirthManagerResult.getErrorcode()).setErrormsg(childbirthManagerResult.getErrormsg()).setData(childbirthManagerResult.getData()).setPageInfo(childbirthManagerResult.getPageInfo()); | |
| 156 | + | |
| 157 | + // 根据查询规则构造返回bean | |
| 158 | + List<Object> objectList = new ArrayList<>(); | |
| 159 | + for (Object temp : childbirthManagerResult.getData()) { | |
| 160 | + for (String key : query.keySet()) { | |
| 161 | + query.put(key, BeanUtils.objectToStringMap(temp).get(key)); | |
| 162 | + } | |
| 163 | + objectList.add(BeanUtils.createStringBean(query)); | |
| 164 | + } | |
| 165 | + | |
| 166 | + baseListResponse = new BaseListResponse().setErrorcode(childbirthManagerResult.getErrorcode()).setErrormsg(childbirthManagerResult.getErrormsg()).setData(objectList).setPageInfo(childbirthManagerResult.getPageInfo()); | |
| 133 | 167 | } catch (Exception e) { | 
| 134 | 168 | baseListResponse = new BaseListResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR).setErrormsg(ErrorCodeConstants.SYSTEM_ERROR_DESCRIPTION); | 
| 135 | 169 | ExceptionUtils.catchException(e, "childbirthManager异常"); | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java
View file @
dea1412
| ... | ... | @@ -1063,16 +1063,16 @@ | 
| 1063 | 1063 | childbirthManagerQueryModel.setPatientId(patients.getId()); | 
| 1064 | 1064 | childbirthManagerQueryModel.setMaternalDeliverId(maternalDeliverModel.getId()); | 
| 1065 | 1065 | // 居住地 | 
| 1066 | - if (StringUtils.isNotEmpty(childbirthManagerRequest.getInitQuery())&&childbirthManagerRequest.getInitQuery().contains("address")) { | |
| 1066 | + if (childbirthManagerRequest.getInitQuery().contains("address")) { | |
| 1067 | 1067 | childbirthManagerQueryModel.setAddress(CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(), patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService)); | 
| 1068 | 1068 | } | 
| 1069 | 1069 | // 电话转换 | 
| 1070 | 1070 | childbirthManagerQueryModel.setPhone(DefenceUtils.getPhone(patients.getPhone())); | 
| 1071 | 1071 | childbirthManagerQueryModel.setHusbandPhone(DefenceUtils.getPhone(patients.getHusbandPhone())); | 
| 1072 | 1072 | // 加密身份证号 | 
| 1073 | - childbirthManagerQueryModel.setCardNo(DefenceUtils.getId(patients.getCardNo())); | |
| 1073 | + childbirthManagerQueryModel.setCardNo(DefenceUtils.getCardNo(patients.getCardNo())); | |
| 1074 | 1074 | // 查询分娩方式 | 
| 1075 | - if (StringUtils.isNotEmpty(childbirthManagerRequest.getInitQuery())&&childbirthManagerRequest.getInitQuery().contains("deliveryMode")) { | |
| 1075 | + if (childbirthManagerRequest.getInitQuery().contains("deliveryMode")) { | |
| 1076 | 1076 | String deliveryModeJson = maternalDeliverModel.getDeliveryMode(); | 
| 1077 | 1077 | Map<String, String> deliveryModeMap = JsonUtil.getMap(deliveryModeJson); | 
| 1078 | 1078 | if (MapUtils.isNotEmpty(deliveryModeMap) && StringUtils.isNotEmpty(deliveryModeMap.get("fmfs"))) { | 
| ... | ... | @@ -1087,7 +1087,7 @@ | 
| 1087 | 1087 | } | 
| 1088 | 1088 | } | 
| 1089 | 1089 | // 产妇情况 | 
| 1090 | - if (StringUtils.isNotEmpty(childbirthManagerRequest.getInitQuery())&&childbirthManagerRequest.getInitQuery().contains("maternalInfo")) { | |
| 1090 | + if (childbirthManagerRequest.getInitQuery().contains("maternalInfo")) { | |
| 1091 | 1091 | if (StringUtils.isNotBlank(maternalDeliverModel.getMaternalInfo())) { | 
| 1092 | 1092 | for (CfEnums cfEnums : CfEnums.values()) { | 
| 1093 | 1093 | if (cfEnums.getId().equals(maternalDeliverModel.getMaternalInfo())) { | 
| ... | ... | @@ -1099,7 +1099,7 @@ | 
| 1099 | 1099 | } | 
| 1100 | 1100 | // 查询接生医生 | 
| 1101 | 1101 | try { | 
| 1102 | - if (StringUtils.isNotEmpty(childbirthManagerRequest.getInitQuery())&&childbirthManagerRequest.getInitQuery().contains("deliverDoctor")) { | |
| 1102 | + if (childbirthManagerRequest.getInitQuery().contains("deliverDoctor")) { | |
| 1103 | 1103 | childbirthManagerQueryModel.setDeliverDoctor(usersService.getUsers(Integer.valueOf(maternalDeliverModel.getDeliverDoctor())).getName()); | 
| 1104 | 1104 | } | 
| 1105 | 1105 | } catch (Exception e) { | 
| ... | ... | @@ -1107,7 +1107,7 @@ | 
| 1107 | 1107 | } | 
| 1108 | 1108 | childbirthManagerQueryModel.setAge(DateUtil.getAge(patients.getBirth())); | 
| 1109 | 1109 | // 查询活产数 | 
| 1110 | - if (StringUtils.isNotEmpty(childbirthManagerRequest.getInitQuery())&&childbirthManagerRequest.getInitQuery().contains("livingNumber")) { | |
| 1110 | + if (childbirthManagerRequest.getInitQuery().contains("livingNumber")) { | |
| 1111 | 1111 | BabyModelQuery babyModelQuery = new BabyModelQuery(); | 
| 1112 | 1112 | babyModelQuery.setYn(YnEnums.YES.getId()); | 
| 1113 | 1113 | babyModelQuery.setParentId(patients.getId()); | 
| ... | ... | @@ -1189,7 +1189,7 @@ | 
| 1189 | 1189 | |
| 1190 | 1190 | // 开始拼装自定义查询结果 | 
| 1191 | 1191 | // 胎方位,胎心率,胎先露 | 
| 1192 | - if (StringUtils.isNotEmpty(childbirthManagerRequest.getInitQuery())&&(childbirthManagerRequest.getInitQuery().contains("fetalPosition") || childbirthManagerRequest.getInitQuery().contains("heartRate") || childbirthManagerRequest.getInitQuery().contains("fetalPresentation"))) { | |
| 1192 | + if (childbirthManagerRequest.getInitQuery().contains("fetalPosition") || childbirthManagerRequest.getInitQuery().contains("heartRate") || childbirthManagerRequest.getInitQuery().contains("fetalPresentation")) { | |
| 1193 | 1193 | // 这个泛型不会出错,传入的就是这个 | 
| 1194 | 1194 | @SuppressWarnings("unchecked") | 
| 1195 | 1195 | List<MatDeliverAddRequest.Placenta> placentaList = maternalDeliverModel.getPlacentas(); | 
| ... | ... | @@ -1260,7 +1260,7 @@ | 
| 1260 | 1260 | childbirthManagerQueryModel.setChBpSzy1(chBpMap.get("szy")); | 
| 1261 | 1261 | } | 
| 1262 | 1262 | // 胎盘娩出方式,胎盘大小,胎盘重量,脐带长度,脐带是否异常,脐带异常类型 | 
| 1263 | - if (StringUtils.isNotEmpty(childbirthManagerRequest.getInitQuery())&&(childbirthManagerRequest.getInitQuery().contains("tpmcType") || childbirthManagerRequest.getInitQuery().contains("tpSize") || childbirthManagerRequest.getInitQuery().contains("tpWeight") || childbirthManagerRequest.getInitQuery().contains("umbilicalCordLength") || childbirthManagerRequest.getInitQuery().contains("umbilicalCordEx") || childbirthManagerRequest.getInitQuery().contains("umbilicalCordExType"))) { | |
| 1263 | + if (childbirthManagerRequest.getInitQuery().contains("tpmcType") || childbirthManagerRequest.getInitQuery().contains("tpSize") || childbirthManagerRequest.getInitQuery().contains("tpWeight") || childbirthManagerRequest.getInitQuery().contains("umbilicalCordLength") || childbirthManagerRequest.getInitQuery().contains("umbilicalCordEx") || childbirthManagerRequest.getInitQuery().contains("umbilicalCordExType")) { | |
| 1264 | 1264 | List<MaternalDeliverModel.ExtPlacenta> extPlacentaList = maternalDeliverModel.getExtPlacentas(); | 
| 1265 | 1265 | if (CollectionUtils.isNotEmpty(extPlacentaList)) { | 
| 1266 | 1266 | String tpmcType = ""; | 
| ... | ... | @@ -1354,7 +1354,7 @@ | 
| 1354 | 1354 | if (maternalDeliverModel.getParentId().equals(babyModel.getParentId())) { | 
| 1355 | 1355 | NewBabyManagerQueryModel newBabyManagerQueryModel = new NewBabyManagerQueryModel(); | 
| 1356 | 1356 | BeanUtils.copy(babyModel, newBabyManagerQueryModel); | 
| 1357 | - newBabyManagerQueryModel.setMcertNo(DefenceUtils.getId(babyModel.getMcertNo())); | |
| 1357 | + newBabyManagerQueryModel.setMcertNo(DefenceUtils.getCardNo(babyModel.getMcertNo())); | |
| 1358 | 1358 | newBabyManagerQueryModel.setAge(DateUtil.getAge(babyModel.getMbirth())); | 
| 1359 | 1359 | newBabyManagerQueryModel.setBirthYMD(DateUtil.getyyyy_MM_dd(babyModel.getBirth())); | 
| 1360 | 1360 | newBabyManagerQueryModel.setBirthHM(new SimpleDateFormat("HH:mm").format(babyModel.getBirth())); | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
View file @
dea1412
| ... | ... | @@ -805,6 +805,7 @@ | 
| 805 | 805 | PatientManagerQueryModel patientManagerQueryModel = new PatientManagerQueryModel(); | 
| 806 | 806 | BeanUtils.copy(patients, patientManagerQueryModel); | 
| 807 | 807 | patientManagerQueryModel.setAge(DateUtil.getAge(patients.getBirth())); | 
| 808 | + patientManagerQueryModel.setpId(patients.getPid()); | |
| 808 | 809 | String dueWeek = ""; | 
| 809 | 810 | try { | 
| 810 | 811 | if (patients.getBookbuildingDate().getTime() - patients.getDueDate().getTime() > 0 && patients.getBuildType() == 2) { | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/ChildbirthManagerRequest.java
View file @
dea1412
| ... | ... | @@ -152,6 +152,10 @@ | 
| 152 | 152 | |
| 153 | 153 | private Map<String, String> initQueryMap; | 
| 154 | 154 | |
| 155 | + private Map<String, String> normalQueryMap; | |
| 156 | + | |
| 157 | + private Map<String, String> araeQueryMap; | |
| 158 | + | |
| 155 | 159 | private boolean isExcel; | 
| 156 | 160 | |
| 157 | 161 | private Integer operatorId; | 
| ... | ... | @@ -340,6 +344,22 @@ | 
| 340 | 344 | this.operatorId = operatorId; | 
| 341 | 345 | } | 
| 342 | 346 | |
| 347 | + public Map<String, String> getNormalQueryMap() { | |
| 348 | + return normalQueryMap; | |
| 349 | + } | |
| 350 | + | |
| 351 | + public void setNormalQueryMap(Map<String, String> normalQueryMap) { | |
| 352 | + this.normalQueryMap = normalQueryMap; | |
| 353 | + } | |
| 354 | + | |
| 355 | + public Map<String, String> getAraeQueryMap() { | |
| 356 | + return araeQueryMap; | |
| 357 | + } | |
| 358 | + | |
| 359 | + public void setAraeQueryMap(Map<String, String> araeQueryMap) { | |
| 360 | + this.araeQueryMap = araeQueryMap; | |
| 361 | + } | |
| 362 | + | |
| 343 | 363 | public ChildbirthManagerRequest() { | 
| 344 | 364 | Map<String, String> initQueryMap = new LinkedHashMap<>(); | 
| 345 | 365 | initQueryMap.put("dueDate", "分娩日期"); | 
| 346 | 366 | |
| ... | ... | @@ -395,7 +415,42 @@ | 
| 395 | 415 | initQueryMap.put("vcCardNo", "卡号"); | 
| 396 | 416 | initQueryMap.put("fileCode", "住院号(暂时塞的档案编号)"); | 
| 397 | 417 | initQueryMap.put("fmHospital", "分娩机构"); | 
| 418 | + initQueryMap.put("maternalDeliverId", ""); | |
| 419 | + initQueryMap.put("patientId", ""); | |
| 420 | + initQueryMap.put("pId", ""); | |
| 421 | + Map<String, String> normalQueryMap = new LinkedHashMap<>(); | |
| 422 | + normalQueryMap.put("dueDate", "分娩日期"); | |
| 423 | + normalQueryMap.put("name", "姓名"); | |
| 424 | + normalQueryMap.put("age", "年龄"); | |
| 425 | + normalQueryMap.put("cardNo", "证件号"); | |
| 426 | + normalQueryMap.put("dueWeek", "分娩孕周"); | |
| 427 | + normalQueryMap.put("deliveryMode", "分娩方式"); | |
| 428 | + normalQueryMap.put("maternalInfo", "产妇情况"); | |
| 429 | + normalQueryMap.put("tireNumber", "胎数"); | |
| 430 | + normalQueryMap.put("livingNumber", "活产数"); | |
| 431 | + normalQueryMap.put("deliverDoctor", "接生医生"); | |
| 432 | + normalQueryMap.put("phone", "联系方式"); | |
| 433 | + normalQueryMap.put("maternalDeliverId", ""); | |
| 434 | + normalQueryMap.put("patientId", ""); | |
| 435 | + normalQueryMap.put("pId", ""); | |
| 436 | + Map<String, String> areaQueryMap = new LinkedHashMap<>(); | |
| 437 | + areaQueryMap.put("dueDate", "分娩日期"); | |
| 438 | + areaQueryMap.put("name", "姓名"); | |
| 439 | + areaQueryMap.put("age", "年龄"); | |
| 440 | + areaQueryMap.put("cardNo", "证件号"); | |
| 441 | + areaQueryMap.put("dueWeek", "分娩孕周"); | |
| 442 | + areaQueryMap.put("deliveryMode", "分娩方式"); | |
| 443 | + areaQueryMap.put("maternalInfo", "产妇情况"); | |
| 444 | + areaQueryMap.put("tireNumber", "胎数"); | |
| 445 | + areaQueryMap.put("livingNumber", "活产数"); | |
| 446 | + areaQueryMap.put("address", "居住地"); | |
| 447 | + areaQueryMap.put("fmHospital", "分娩机构"); | |
| 448 | + areaQueryMap.put("maternalDeliverId", ""); | |
| 449 | + areaQueryMap.put("patientId", ""); | |
| 450 | + areaQueryMap.put("pId", ""); | |
| 398 | 451 | this.initQueryMap = initQueryMap; | 
| 452 | + this.normalQueryMap = normalQueryMap; | |
| 453 | + this.araeQueryMap = areaQueryMap; | |
| 399 | 454 | } | 
| 400 | 455 | } | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/PatientManagerQueryModel.java
View file @
dea1412
| ... | ... | @@ -70,7 +70,7 @@ | 
| 70 | 70 | */ | 
| 71 | 71 | private String bookbuildingDoctor; | 
| 72 | 72 | |
| 73 | - private String id; | |
| 73 | + private String pId; | |
| 74 | 74 | |
| 75 | 75 | private String cardNo; | 
| 76 | 76 | |
| 77 | 77 | |
| ... | ... | @@ -82,12 +82,12 @@ | 
| 82 | 82 | this.cardNo = cardNo; | 
| 83 | 83 | } | 
| 84 | 84 | |
| 85 | - public String getId() { | |
| 86 | - return id; | |
| 85 | + public String getpId() { | |
| 86 | + return pId; | |
| 87 | 87 | } | 
| 88 | 88 | |
| 89 | - public void setId(String id) { | |
| 90 | - this.id = id; | |
| 89 | + public void setpId(String pId) { | |
| 90 | + this.pId = pId; | |
| 91 | 91 | } | 
| 92 | 92 | |
| 93 | 93 | public String getUsername() { |