Commit 46717c901c5f5e8fae7a108c26a3216fa97fdb73

Authored by dongqin
1 parent 2c34c6de41

根据关键字获取孕妇/妇女基本信息

Showing 4 changed files with 206 additions and 0 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommonController.java View file @ 46717c9
... ... @@ -37,5 +37,19 @@
37 37 public BaseResponse searchByKeyword(@JsonAlias CommonRequest param) {
38 38 return commonServer.searchByKeyword(param);
39 39 }
  40 +
  41 + /**
  42 + * 根据 cardNo、pid、womenId检索基本信息
  43 + *
  44 + * @param param
  45 + * @return
  46 + */
  47 + @RequestMapping(method = RequestMethod.GET, value = "/baseInfoByKeyword")
  48 + @ResponseBody
  49 + @TokenRequired
  50 + public BaseResponse baseInfoByKeyword(@JsonAlias CommonRequest param) {
  51 + return commonServer.baseInfoByKeyword(param);
  52 + }
  53 +
40 54 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/PatientBaseInfoRequest.java View file @ 46717c9
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +/**
  6 + * @author dongqin
  7 + * @description 孕妇、妇女基本信息
  8 + * @date 16:10 2019/12/10
  9 + **/
  10 +public class PatientBaseInfoRequest implements Serializable {
  11 +
  12 + private static final long serialVersionUID = 3477323650944830922L;
  13 +
  14 + /**
  15 + * 姓名
  16 + */
  17 + private String name;
  18 +
  19 + /**
  20 + * 生日 yyyy-mm-hh
  21 + */
  22 + private String birth;
  23 +
  24 + /**
  25 + * 年龄
  26 + */
  27 + private String age;
  28 +
  29 + /**
  30 + * 手机号
  31 + */
  32 + private String phone;
  33 +
  34 + /**
  35 + * 证件号
  36 + */
  37 + private String cardNo;
  38 +
  39 + /**
  40 + * 居住地(省市区街道详细地址)
  41 + */
  42 + private String addressStr;
  43 +
  44 + public String getName() {
  45 + return name;
  46 + }
  47 +
  48 + public void setName(String name) {
  49 + this.name = name;
  50 + }
  51 +
  52 + public String getBirth() {
  53 + return birth;
  54 + }
  55 +
  56 + public void setBirth(String birth) {
  57 + this.birth = birth;
  58 + }
  59 +
  60 + public String getAge() {
  61 + return age;
  62 + }
  63 +
  64 + public void setAge(String age) {
  65 + this.age = age;
  66 + }
  67 +
  68 + public String getPhone() {
  69 + return phone;
  70 + }
  71 +
  72 + public void setPhone(String phone) {
  73 + this.phone = phone;
  74 + }
  75 +
  76 + public String getCardNo() {
  77 + return cardNo;
  78 + }
  79 +
  80 + public void setCardNo(String cardNo) {
  81 + this.cardNo = cardNo;
  82 + }
  83 +
  84 + public String getAddressStr() {
  85 + return addressStr;
  86 + }
  87 +
  88 + public void setAddressStr(String addressStr) {
  89 + this.addressStr = addressStr;
  90 + }
  91 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/ICommonServer.java View file @ 46717c9
... ... @@ -13,5 +13,13 @@
13 13 * @return
14 14 */
15 15 BaseResponse searchByKeyword(CommonRequest param);
  16 +
  17 + /**
  18 + * 根据 cardNo、pid、womenId检索基本信息
  19 + *
  20 + * @param param
  21 + * @return
  22 + */
  23 + BaseResponse baseInfoByKeyword(CommonRequest param);
16 24 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/CommonServerImpl.java View file @ 46717c9
1 1 package com.lyms.platform.operate.web.service.impl;
2 2  
  3 +import java.util.Date;
3 4 import java.util.List;
4 5  
5 6 import org.slf4j.Logger;
6 7  
7 8  
8 9  
9 10  
... ... @@ -11,13 +12,19 @@
11 12 import org.springframework.data.mongodb.core.query.Query;
12 13 import org.springframework.stereotype.Service;
13 14  
  15 +import com.lyms.platform.biz.service.BasicConfigService;
14 16 import com.lyms.platform.common.constants.ErrorCodeConstants;
15 17 import com.lyms.platform.common.result.BaseResponse;
  18 +import com.lyms.platform.common.utils.DateUtil;
16 19 import com.lyms.platform.common.utils.StringUtils;
17 20 import com.lyms.platform.operate.web.request.CommonRequest;
  21 +import com.lyms.platform.operate.web.request.PatientBaseInfoRequest;
18 22 import com.lyms.platform.operate.web.service.ICommonServer;
19 23 import com.lyms.platform.operate.web.utils.CollectionUtils;
  24 +import com.lyms.platform.operate.web.utils.CommonsHelper;
  25 +import com.lyms.platform.pojo.BasicConfig;
20 26 import com.lyms.platform.pojo.MaternalDeliverModel;
  27 +import com.lyms.platform.pojo.Patients;
21 28 import com.lyms.platform.pojo.PersonModel;
22 29 import com.lyms.platform.pojo.ResidentsArchiveModel;
23 30  
... ... @@ -32,6 +39,9 @@
32 39 @Autowired
33 40 private MongoTemplate mongoTemplate;
34 41  
  42 + @Autowired
  43 + private BasicConfigService basicConfigService;
  44 +
35 45 private static final Logger log = LoggerFactory.getLogger(CommonServerImpl.class);
36 46  
37 47 /**
... ... @@ -113,6 +123,89 @@
113 123 }
114 124  
115 125 return new BaseResponse("参数缺失",ErrorCodeConstants.PARAMETER_ERROR);
  126 + }
  127 +
  128 + /**
  129 + * 根据 cardNo、pid、womenId检索基本信息
  130 + *
  131 + * @param param
  132 + * @return
  133 + */
  134 + @Override
  135 + public BaseResponse baseInfoByKeyword(CommonRequest param) {
  136 + PatientBaseInfoRequest result = new PatientBaseInfoRequest();
  137 + String cardNo = param.getCardNo();
  138 + // 身份证号
  139 + if (StringUtils.isNotEmpty(cardNo)) {
  140 + getResultByCardNo(result, cardNo);
  141 +
  142 +
  143 + }
  144 +
  145 + // 孕妇id
  146 + String pid = param.getPid();
  147 + if (StringUtils.isNotEmpty(pid)) {
  148 + PersonModel personModel = mongoTemplate.findOne(Query.query(Criteria.where("id").is(pid)), PersonModel.class);
  149 + if (personModel != null) {
  150 + getResultByCardNo(result, personModel.getCardNo());
  151 + }
  152 + }
  153 +
  154 + // 妇女id
  155 + String womenId = param.getWomenId();
  156 + if (StringUtils.isNotEmpty(womenId)) {
  157 + ResidentsArchiveModel archiveModel = mongoTemplate.findOne(Query.query(Criteria.where("id").is(womenId)), ResidentsArchiveModel.class);
  158 + if (archiveModel != null) {
  159 + getResultByCardNo(result, archiveModel.getCertificateNum());
  160 + }
  161 + }
  162 + BaseResponse baseResponse = new BaseResponse();
  163 + baseResponse.setObject(result);
  164 + return baseResponse;
  165 + }
  166 +
  167 + /**
  168 + * 根据身份证号获取孕妇/妇女基本信息
  169 + *
  170 + * @param result
  171 + * @param cardNo
  172 + */
  173 + private void getResultByCardNo(PatientBaseInfoRequest result, String cardNo) {
  174 + // 孕妇
  175 + PersonModel personModel = mongoTemplate.findOne(Query.query(Criteria.where("cardNo").is(cardNo)), PersonModel.class);
  176 + if (personModel != null) {
  177 + result.setName(personModel.getName());
  178 + result.setPhone(personModel.getPhone());
  179 + Date birth = personModel.getBirth();
  180 + if (birth != null) {
  181 + result.setBirth(DateUtil.getyyyy_MM_dd(personModel.getBirth()));
  182 + result.setAge(DateUtil.getAge(birth).toString());
  183 + }
  184 + result.setCardNo(cardNo);
  185 + List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("pid").is(personModel.getId())).with(new Sort(Sort.Direction.DESC, "created")), Patients.class);
  186 + if (CollectionUtils.isNotEmpty(patients)) {
  187 + Patients patient = patients.get(0);
  188 + String addressStr = CommonsHelper.getResidence(patient.getAddressRegister(), patient.getProvinceRegisterId(), patient.getCityRegisterId(),
  189 + patient.getAreaRegisterId(), patient.getStreetRegisterId(), basicConfigService);
  190 + result.setAddressStr(addressStr);
  191 + }
  192 + }
  193 +
  194 + // 妇女
  195 + ResidentsArchiveModel certificateNumModel = mongoTemplate.findOne(Query.query(Criteria.where("certificateNum").is(cardNo)), ResidentsArchiveModel.class);
  196 + if (certificateNumModel != null) {
  197 + result.setName(certificateNumModel.getUsername());
  198 + result.setPhone(certificateNumModel.getPhone());
  199 + Date birthday = certificateNumModel.getBirthday();
  200 + if (birthday != null) {
  201 + result.setBirth(DateUtil.getyyyy_MM_dd(birthday));
  202 + result.setAge(DateUtil.getAge(birthday).toString());
  203 + }
  204 + result.setCardNo(cardNo);
  205 + String addressStr = CommonsHelper.getResidence(certificateNumModel.getProvinceId(), certificateNumModel.getCityId(), certificateNumModel.getAreaId(),
  206 + certificateNumModel.getStreetId(), certificateNumModel.getAddress(),basicConfigService);
  207 + result.setAddressStr(addressStr);
  208 + }
116 209 }
117 210 }