Commit b98e71701429e2dc12c5328bcbdd7e7f1c88a97b

Authored by dongqin
1 parent 71df14e88b

缺陷儿模块

Showing 8 changed files with 869 additions and 1 deletions

platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java View file @ b98e717
... ... @@ -108,7 +108,8 @@
108 108 MatdeliverFollowPushModel("MatdeliverFollowPushModel", -5956731779920504355L),
109 109 PreEugenicsBaseModel("PreEugenicsBaseModel", 7673224106500008116L),
110 110 PregnantDeathModel("PregnantDeathModel", 7244731601920572967L),
111   - CervicalCancerModel("CervicalCancerModel", 4302505773278441592L)
  111 + CervicalCancerModel("CervicalCancerModel", 4302505773278441592L),
  112 + DefectiveChildModel("DefectiveChildModel", 1684816144240073408L)
112 113 ;
113 114  
114 115 private String cname;
platform-dal/src/main/java/com/lyms/platform/pojo/DefectiveChildModel.java View file @ b98e717
  1 +package com.lyms.platform.pojo;
  2 +
  3 +import java.util.Date;
  4 +import java.util.Map;
  5 +
  6 +import org.springframework.data.mongodb.core.mapping.Document;
  7 +
  8 +import com.lyms.platform.beans.SerialIdEnum;
  9 +import com.lyms.platform.common.result.BaseModel;
  10 +
  11 +/**
  12 + * @author dongqin
  13 + * @description 医疗机构出生缺陷儿登记卡
  14 + * @date 11:11 2019/12/2
  15 + **/
  16 +@Document(collection = "lyms_defective_child")
  17 +public class DefectiveChildModel extends BaseModel {
  18 +
  19 + private static final long serialVersionUID = SerialIdEnum.DefectiveChildModel.getCid();
  20 + private String id;
  21 +
  22 + private String createUser;
  23 +
  24 + private Date created;
  25 +
  26 + private String hospitalId;
  27 +
  28 + /**
  29 + * 省市区街道
  30 + */
  31 + private String province;
  32 + private String city;
  33 + private String area;
  34 + private String street;
  35 +
  36 + /**
  37 + * 医院编码
  38 + */
  39 + private String hospitalNo;
  40 +
  41 + /**
  42 + * 住院号
  43 + */
  44 + private String inHospitalNo;
  45 +
  46 + /**
  47 + * 产妇姓名
  48 + */
  49 + private String name;
  50 +
  51 + /**
  52 + * babyBirth
  53 + */
  54 + private Date babyBirth;
  55 +
  56 + /**
  57 + * 胎龄
  58 + */
  59 + private String gestationalAge;
  60 +
  61 + /**
  62 + * 儿童体重
  63 + */
  64 + private String weight;
  65 +
  66 + /**
  67 + * 孕次
  68 + */
  69 + private String yunSize;
  70 +
  71 + /**
  72 + * 产次
  73 + */
  74 + private String chanSize;
  75 +
  76 + /**
  77 + * 表单自定义数据
  78 + */
  79 + private Map<String, Object> formData;
  80 +
  81 + public String getId() {
  82 + return id;
  83 + }
  84 +
  85 + public void setId(String id) {
  86 + this.id = id;
  87 + }
  88 +
  89 + public String getCreateUser() {
  90 + return createUser;
  91 + }
  92 +
  93 + public void setCreateUser(String createUser) {
  94 + this.createUser = createUser;
  95 + }
  96 +
  97 + public Date getCreated() {
  98 + return created;
  99 + }
  100 +
  101 + public void setCreated(Date created) {
  102 + this.created = created;
  103 + }
  104 +
  105 + public String getHospitalId() {
  106 + return hospitalId;
  107 + }
  108 +
  109 + public void setHospitalId(String hospitalId) {
  110 + this.hospitalId = hospitalId;
  111 + }
  112 +
  113 + public String getProvince() {
  114 + return province;
  115 + }
  116 +
  117 + public void setProvince(String province) {
  118 + this.province = province;
  119 + }
  120 +
  121 + public String getCity() {
  122 + return city;
  123 + }
  124 +
  125 + public void setCity(String city) {
  126 + this.city = city;
  127 + }
  128 +
  129 + public String getArea() {
  130 + return area;
  131 + }
  132 +
  133 + public void setArea(String area) {
  134 + this.area = area;
  135 + }
  136 +
  137 + public String getStreet() {
  138 + return street;
  139 + }
  140 +
  141 + public void setStreet(String street) {
  142 + this.street = street;
  143 + }
  144 +
  145 + public String getHospitalNo() {
  146 + return hospitalNo;
  147 + }
  148 +
  149 + public void setHospitalNo(String hospitalNo) {
  150 + this.hospitalNo = hospitalNo;
  151 + }
  152 +
  153 + public String getInHospitalNo() {
  154 + return inHospitalNo;
  155 + }
  156 +
  157 + public void setInHospitalNo(String inHospitalNo) {
  158 + this.inHospitalNo = inHospitalNo;
  159 + }
  160 +
  161 + public String getName() {
  162 + return name;
  163 + }
  164 +
  165 + public void setName(String name) {
  166 + this.name = name;
  167 + }
  168 +
  169 + public Date getBabyBirth() {
  170 + return babyBirth;
  171 + }
  172 +
  173 + public void setBabyBirth(Date babyBirth) {
  174 + this.babyBirth = babyBirth;
  175 + }
  176 +
  177 + public String getGestationalAge() {
  178 + return gestationalAge;
  179 + }
  180 +
  181 + public void setGestationalAge(String gestationalAge) {
  182 + this.gestationalAge = gestationalAge;
  183 + }
  184 +
  185 + public String getWeight() {
  186 + return weight;
  187 + }
  188 +
  189 + public void setWeight(String weight) {
  190 + this.weight = weight;
  191 + }
  192 +
  193 + public String getYunSize() {
  194 + return yunSize;
  195 + }
  196 +
  197 + public void setYunSize(String yunSize) {
  198 + this.yunSize = yunSize;
  199 + }
  200 +
  201 + public String getChanSize() {
  202 + return chanSize;
  203 + }
  204 +
  205 + public void setChanSize(String chanSize) {
  206 + this.chanSize = chanSize;
  207 + }
  208 +
  209 + public Map<String, Object> getFormData() {
  210 + return formData;
  211 + }
  212 +
  213 + public void setFormData(Map<String, Object> formData) {
  214 + this.formData = formData;
  215 + }
  216 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/DefectiveChildController.java View file @ b98e717
  1 +package com.lyms.platform.operate.web.controller;
  2 +
  3 +import javax.servlet.http.HttpServletRequest;
  4 +
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.stereotype.Controller;
  7 +import org.springframework.web.bind.annotation.RequestBody;
  8 +import org.springframework.web.bind.annotation.RequestMapping;
  9 +import org.springframework.web.bind.annotation.RequestMethod;
  10 +import org.springframework.web.bind.annotation.ResponseBody;
  11 +
  12 +import com.fasterxml.jackson.annotation.JsonAlias;
  13 +import com.lyms.platform.common.annotation.TokenRequired;
  14 +import com.lyms.platform.common.base.BaseController;
  15 +import com.lyms.platform.common.result.BaseListResponse;
  16 +import com.lyms.platform.common.result.BaseResponse;
  17 +import com.lyms.platform.operate.web.request.CommonParamRequest;
  18 +import com.lyms.platform.operate.web.request.DefectiveChildListRequest;
  19 +import com.lyms.platform.operate.web.request.DefectiveChildRequest;
  20 +import com.lyms.platform.operate.web.service.DefectiveChildService;
  21 +
  22 +/**
  23 + * @author dongqin
  24 + * @description
  25 + * @date 11:40 2019/12/2
  26 + **/
  27 +@Controller
  28 +@RequestMapping("/defectiveChild")
  29 +public class DefectiveChildController extends BaseController {
  30 +
  31 + @Autowired
  32 + private DefectiveChildService defectiveChildService;
  33 +
  34 + /**
  35 + *
  36 + * 根据?获取对应的信息
  37 + *
  38 + * @param param
  39 + * @return
  40 + */
  41 + @RequestMapping(method = RequestMethod.GET, value = "/getPatientInfoByIdCard")
  42 + @ResponseBody
  43 + @TokenRequired
  44 + public BaseResponse getPatientInfoByIdCard(@JsonAlias CommonParamRequest param) {
  45 + return defectiveChildService.getPatientInfoByIdCard(param);
  46 + }
  47 +
  48 +
  49 + /**
  50 + * 保存单个
  51 + *
  52 + * @param param
  53 + * @return
  54 + */
  55 + @RequestMapping(method = RequestMethod.POST, value = "/add")
  56 + @ResponseBody
  57 + @TokenRequired
  58 + public BaseResponse add(@RequestBody DefectiveChildRequest param, HttpServletRequest request) {
  59 + param.setCreateUser(getUserId(request).toString());
  60 + return defectiveChildService.add(param);
  61 + }
  62 +
  63 + /**
  64 + * 编辑单个
  65 + *
  66 + * @param param
  67 + * @return
  68 + */
  69 + @RequestMapping(method = RequestMethod.POST, value = "/edit")
  70 + @ResponseBody
  71 + @TokenRequired
  72 + public BaseResponse edit( @RequestBody DefectiveChildRequest param) {
  73 + return defectiveChildService.edit(param);
  74 + }
  75 +
  76 + /**
  77 + * 列表
  78 + *
  79 + * @param param
  80 + * @return
  81 + */
  82 + @RequestMapping(method = RequestMethod.GET, value = "/listPage")
  83 + @ResponseBody
  84 + @TokenRequired
  85 + public BaseListResponse listPage(@JsonAlias DefectiveChildListRequest param) {
  86 + return defectiveChildService.listPage(param);
  87 + }
  88 +
  89 + /**
  90 + * 单个查询
  91 + *
  92 + * @param param
  93 + * @return
  94 + */
  95 + @RequestMapping(method = RequestMethod.GET, value = "/detail")
  96 + @ResponseBody
  97 + @TokenRequired
  98 + public BaseResponse detail( @JsonAlias DefectiveChildRequest param) {
  99 + return defectiveChildService.detail(param);
  100 + }
  101 +
  102 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/DefectiveChildListRequest.java View file @ b98e717
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +import com.lyms.platform.common.dao.BaseQuery;
  4 +
  5 +public class DefectiveChildListRequest extends BaseQuery {
  6 +
  7 + /**
  8 + * 填写人
  9 + */
  10 + private String createUser;
  11 +
  12 + /**
  13 + * 起止时间
  14 + */
  15 + private String startCreateTime;
  16 + private String endCreateTime;
  17 +
  18 + /**
  19 + * 医院id
  20 + */
  21 + private String hospitalId;
  22 +
  23 + /**
  24 + * 省市区街道
  25 + */
  26 + private String province;
  27 + private String city;
  28 + private String area;
  29 + private String street;
  30 +
  31 +
  32 + /**
  33 + * 住院号
  34 + */
  35 + private String inHospitalNo;
  36 +
  37 + /**
  38 + * 产妇姓名
  39 + */
  40 + private String name;
  41 +
  42 + /**
  43 + * babyBirth
  44 + */
  45 + private String startBabyBirth;
  46 + private String endBabyBirth;
  47 +
  48 + /**
  49 + * 胎龄
  50 + */
  51 + private String gestationalAge;
  52 +
  53 + /**
  54 + * 儿童体重
  55 + */
  56 + private String weight;
  57 +
  58 + /**
  59 + * 孕次
  60 + */
  61 + private String yunSize;
  62 +
  63 + /**
  64 + * 产次
  65 + */
  66 + private String chanSize;
  67 +
  68 + public String getCreateUser() {
  69 + return createUser;
  70 + }
  71 +
  72 + public void setCreateUser(String createUser) {
  73 + this.createUser = createUser;
  74 + }
  75 +
  76 + public String getStartBabyBirth() {
  77 + return startBabyBirth;
  78 + }
  79 +
  80 + public void setStartBabyBirth(String startBabyBirth) {
  81 + this.startBabyBirth = startBabyBirth;
  82 + }
  83 +
  84 + public String getEndBabyBirth() {
  85 + return endBabyBirth;
  86 + }
  87 +
  88 + public void setEndBabyBirth(String endBabyBirth) {
  89 + this.endBabyBirth = endBabyBirth;
  90 + }
  91 +
  92 + public String getStartCreateTime() {
  93 + return startCreateTime;
  94 + }
  95 +
  96 + public void setStartCreateTime(String startCreateTime) {
  97 + this.startCreateTime = startCreateTime;
  98 + }
  99 +
  100 + public String getEndCreateTime() {
  101 + return endCreateTime;
  102 + }
  103 +
  104 + public void setEndCreateTime(String endCreateTime) {
  105 + this.endCreateTime = endCreateTime;
  106 + }
  107 +
  108 + public String getHospitalId() {
  109 + return hospitalId;
  110 + }
  111 +
  112 + public void setHospitalId(String hospitalId) {
  113 + this.hospitalId = hospitalId;
  114 + }
  115 +
  116 + public String getProvince() {
  117 + return province;
  118 + }
  119 +
  120 + public void setProvince(String province) {
  121 + this.province = province;
  122 + }
  123 +
  124 + public String getCity() {
  125 + return city;
  126 + }
  127 +
  128 + public void setCity(String city) {
  129 + this.city = city;
  130 + }
  131 +
  132 + public String getArea() {
  133 + return area;
  134 + }
  135 +
  136 + public void setArea(String area) {
  137 + this.area = area;
  138 + }
  139 +
  140 + public String getStreet() {
  141 + return street;
  142 + }
  143 +
  144 + public void setStreet(String street) {
  145 + this.street = street;
  146 + }
  147 +
  148 + public String getInHospitalNo() {
  149 + return inHospitalNo;
  150 + }
  151 +
  152 + public void setInHospitalNo(String inHospitalNo) {
  153 + this.inHospitalNo = inHospitalNo;
  154 + }
  155 +
  156 + public String getName() {
  157 + return name;
  158 + }
  159 +
  160 + public void setName(String name) {
  161 + this.name = name;
  162 + }
  163 +
  164 + public String getGestationalAge() {
  165 + return gestationalAge;
  166 + }
  167 +
  168 + public void setGestationalAge(String gestationalAge) {
  169 + this.gestationalAge = gestationalAge;
  170 + }
  171 +
  172 + public String getWeight() {
  173 + return weight;
  174 + }
  175 +
  176 + public void setWeight(String weight) {
  177 + this.weight = weight;
  178 + }
  179 +
  180 + public String getYunSize() {
  181 + return yunSize;
  182 + }
  183 +
  184 + public void setYunSize(String yunSize) {
  185 + this.yunSize = yunSize;
  186 + }
  187 +
  188 + public String getChanSize() {
  189 + return chanSize;
  190 + }
  191 +
  192 + public void setChanSize(String chanSize) {
  193 + this.chanSize = chanSize;
  194 + }
  195 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/DefectiveChildRequest.java View file @ b98e717
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +import com.lyms.platform.pojo.DefectiveChildModel;
  4 +
  5 +/**
  6 + * @author dongqin
  7 + * @description
  8 + * @date 11:41 2019/12/2
  9 + **/
  10 +public class DefectiveChildRequest extends DefectiveChildModel {
  11 +
  12 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/DefectiveChildModelResult.java View file @ b98e717
  1 +package com.lyms.platform.operate.web.result;
  2 +
  3 +import com.lyms.platform.pojo.DefectiveChildModel;
  4 +
  5 +public class DefectiveChildModelResult extends DefectiveChildModel {
  6 +
  7 + /**
  8 + * 填表人
  9 + */
  10 + private String createUserStr;
  11 +
  12 + /**
  13 + * 填表医院
  14 + */
  15 + private String hospitalStr;
  16 +
  17 + /**
  18 + * 创建时间
  19 + */
  20 + private String createStr;
  21 +
  22 + /**
  23 + * 省+市+区+街道
  24 + */
  25 + private String addressStr;
  26 +
  27 + /**
  28 + * 缺陷儿的生日
  29 + */
  30 + private String babyBirthStr;
  31 +
  32 + public String getCreateUserStr() {
  33 + return createUserStr;
  34 + }
  35 +
  36 + public void setCreateUserStr(String createUserStr) {
  37 + this.createUserStr = createUserStr;
  38 + }
  39 +
  40 + public String getHospitalStr() {
  41 + return hospitalStr;
  42 + }
  43 +
  44 + public void setHospitalStr(String hospitalStr) {
  45 + this.hospitalStr = hospitalStr;
  46 + }
  47 +
  48 + public String getCreateStr() {
  49 + return createStr;
  50 + }
  51 +
  52 + public void setCreateStr(String createStr) {
  53 + this.createStr = createStr;
  54 + }
  55 +
  56 + public String getAddressStr() {
  57 + return addressStr;
  58 + }
  59 +
  60 + public void setAddressStr(String addressStr) {
  61 + this.addressStr = addressStr;
  62 + }
  63 +
  64 + public String getBabyBirthStr() {
  65 + return babyBirthStr;
  66 + }
  67 +
  68 + public void setBabyBirthStr(String babyBirthStr) {
  69 + this.babyBirthStr = babyBirthStr;
  70 + }
  71 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/DefectiveChildService.java View file @ b98e717
  1 +package com.lyms.platform.operate.web.service;
  2 +
  3 +import com.lyms.platform.operate.web.request.DefectiveChildListRequest;
  4 +import com.lyms.platform.operate.web.request.DefectiveChildRequest;
  5 +
  6 +public interface DefectiveChildService extends IFormReportService<DefectiveChildRequest, DefectiveChildListRequest> {
  7 +
  8 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/DefectiveChildServiceImpl.java View file @ b98e717
  1 +package com.lyms.platform.operate.web.service.impl;
  2 +
  3 +import java.util.Date;
  4 +import java.util.LinkedList;
  5 +import java.util.List;
  6 +
  7 +import org.springframework.beans.BeanUtils;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.data.domain.Sort;
  10 +import org.springframework.data.mongodb.core.MongoTemplate;
  11 +import org.springframework.data.mongodb.core.query.Criteria;
  12 +import org.springframework.data.mongodb.core.query.Query;
  13 +import org.springframework.data.mongodb.core.query.Update;
  14 +import org.springframework.stereotype.Service;
  15 +
  16 +import com.lyms.platform.biz.service.BasicConfigService;
  17 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  18 +import com.lyms.platform.common.result.BaseListResponse;
  19 +import com.lyms.platform.common.result.BaseResponse;
  20 +import com.lyms.platform.common.utils.DateUtil;
  21 +import com.lyms.platform.common.utils.MongoConvertHelper;
  22 +import com.lyms.platform.common.utils.ReflectionUtils;
  23 +import com.lyms.platform.common.utils.StringUtils;
  24 +import com.lyms.platform.operate.web.request.CommonParamRequest;
  25 +import com.lyms.platform.operate.web.request.DefectiveChildListRequest;
  26 +import com.lyms.platform.operate.web.request.DefectiveChildRequest;
  27 +import com.lyms.platform.operate.web.result.DefectiveChildModelResult;
  28 +import com.lyms.platform.operate.web.service.DefectiveChildService;
  29 +import com.lyms.platform.operate.web.utils.CommonsHelper;
  30 +import com.lyms.platform.permission.model.Organization;
  31 +import com.lyms.platform.permission.model.Users;
  32 +import com.lyms.platform.permission.service.OrganizationService;
  33 +import com.lyms.platform.permission.service.UsersService;
  34 +import com.lyms.platform.pojo.DefectiveChildModel;
  35 +
  36 +/**
  37 + * @author dongqin
  38 + * @description
  39 + * @date 11:44 2019/12/2
  40 + **/
  41 +@Service
  42 +public class DefectiveChildServiceImpl implements DefectiveChildService {
  43 +
  44 + @Autowired
  45 + private MongoTemplate mongoTemplate;
  46 +
  47 + @Autowired
  48 + private BasicConfigService basicConfigService;
  49 +
  50 + @Autowired
  51 + private UsersService usersService;
  52 +
  53 + @Autowired
  54 + private OrganizationService organizationService;
  55 +
  56 + /**
  57 + * 保存单个
  58 + *
  59 + * @param param
  60 + * @return
  61 + */
  62 + @Override
  63 + public BaseResponse add(DefectiveChildRequest param) {
  64 + DefectiveChildModel model = param;
  65 + mongoTemplate.insert(model);
  66 + return new BaseResponse();
  67 + }
  68 +
  69 + /**
  70 + * 编辑单个
  71 + *
  72 + * @param param
  73 + * @return
  74 + */
  75 + @Override
  76 + public BaseResponse edit(DefectiveChildRequest param) {
  77 + DefectiveChildModel model = param;
  78 + String id = model.getId();
  79 + if (StringUtils.isEmpty(id)) {
  80 + return new BaseResponse("参数缺失", ErrorCodeConstants.PARAMETER_ERROR);
  81 + }
  82 + Query query = Query.query(Criteria.where("id").is(param.getId()));
  83 + Update update = MongoConvertHelper
  84 + .convertToNativeUpdate(ReflectionUtils.getUpdateField(param));
  85 + mongoTemplate.updateFirst(query, update, DefectiveChildModel.class);
  86 + return new BaseResponse();
  87 + }
  88 +
  89 + /**
  90 + * 列表
  91 + *
  92 + * @param param
  93 + * @return
  94 + */
  95 + @Override
  96 + public BaseListResponse listPage(DefectiveChildListRequest param) {
  97 + Query query = new Query();
  98 + String createUser = param.getCreateUser();
  99 + if (StringUtils.isNotEmpty(createUser)) {
  100 + query.addCriteria(Criteria.where("createUser").is(createUser));
  101 + }
  102 + String startCreateTime = param.getStartCreateTime();
  103 + String endCreateTime = param.getEndCreateTime();
  104 + if (StringUtils.isNotEmpty(startCreateTime) && StringUtils.isNotEmpty(endCreateTime)) {
  105 + Date dayFirstSecond = DateUtil.getDayFirstSecond(DateUtil.parseYMD(startCreateTime));
  106 + Date dayLastSecond = DateUtil.getDayLastSecond(DateUtil.parseYMD(endCreateTime));
  107 + query.addCriteria(Criteria.where("created").gte(dayFirstSecond).lte(dayLastSecond));
  108 + }
  109 + String hospitalId = param.getHospitalId();
  110 + if (StringUtils.isNotEmpty(hospitalId)) {
  111 + query.addCriteria(Criteria.where("hospitalId").is(hospitalId));
  112 + }
  113 + String province = param.getProvince();
  114 + if (StringUtils.isNotEmpty(province)) {
  115 + query.addCriteria(Criteria.where("province").is(province));
  116 + String city = param.getCity();
  117 + if (StringUtils.isNotEmpty(city)) {
  118 + query.addCriteria(Criteria.where("city").is(city));
  119 + String area = param.getArea();
  120 + if (StringUtils.isNotEmpty(area)) {
  121 + query.addCriteria(Criteria.where("area").is(area));
  122 + String street = param.getStreet();
  123 + if (StringUtils.isNotEmpty(street)) {
  124 + query.addCriteria(Criteria.where("street").is(street));
  125 + }
  126 + }
  127 + }
  128 + }
  129 + String inHospitalNo = param.getInHospitalNo();
  130 + if (StringUtils.isNotEmpty(inHospitalNo)) {
  131 + query.addCriteria(Criteria.where("inHospitalNo").is(inHospitalNo));
  132 + }
  133 + String name = param.getName();
  134 + if (StringUtils.isNotEmpty(name)) {
  135 + query.addCriteria(Criteria.where("name").is(name));
  136 + }
  137 + String startBabyBirth = param.getStartBabyBirth();
  138 + String endBabyBirth = param.getEndBabyBirth();
  139 + if (StringUtils.isNotEmpty(startBabyBirth) && StringUtils.isNotEmpty(endBabyBirth)) {
  140 + Date start = DateUtil.getDayFirstSecond(DateUtil.parseYMD(startBabyBirth));
  141 + Date end = DateUtil.getDayLastSecond(DateUtil.parseYMD(endBabyBirth));
  142 + query.addCriteria(Criteria.where("babyBirth").gte(start).lte(end));
  143 + }
  144 + String gestationalAge = param.getGestationalAge();
  145 + if (StringUtils.isNotEmpty(gestationalAge)) {
  146 + query.addCriteria(Criteria.where("gestationalAge").is(gestationalAge));
  147 + }
  148 + String weight = param.getWeight();
  149 + if (StringUtils.isNotEmpty(weight)) {
  150 + query.addCriteria(Criteria.where("weight").is(weight));
  151 + }
  152 + String yunSize = param.getYunSize();
  153 + if (StringUtils.isNotEmpty(yunSize)) {
  154 + query.addCriteria(Criteria.where("yunSize").is(yunSize));
  155 + }
  156 + String chanSize = param.getChanSize();
  157 + if (StringUtils.isNotEmpty(chanSize)) {
  158 + query.addCriteria(Criteria.where("chanSize").is(chanSize));
  159 + }
  160 + query.with(new Sort(Sort.Direction.DESC, "created"));
  161 + long count = mongoTemplate.count(query, DefectiveChildModel.class);
  162 + param.mysqlBuild((int) count);
  163 + query.skip(param.getOffset()).limit(param.getLimit());
  164 + List<DefectiveChildModelResult> results = new LinkedList<>();
  165 + List<DefectiveChildModel> defectiveChildModels = mongoTemplate.find(query, DefectiveChildModel.class);
  166 + for (DefectiveChildModel model : defectiveChildModels) {
  167 + DefectiveChildModelResult result = getResultByModel(model);
  168 + results.add(result);
  169 + }
  170 + BaseListResponse baseListResponse = new BaseListResponse();
  171 + baseListResponse.setData(results);
  172 + baseListResponse.setPageInfo(param.getPageInfo());
  173 + return baseListResponse;
  174 + }
  175 +
  176 + /**
  177 + * 单个查询
  178 + *
  179 + * @param param
  180 + * @return
  181 + */
  182 + @Override
  183 + public BaseResponse detail(DefectiveChildRequest param) {
  184 + String id = param.getId();
  185 + if (StringUtils.isNotEmpty(id)) {
  186 + DefectiveChildModel model = mongoTemplate.findOne(Query.query(Criteria.where("id").is(id)), DefectiveChildModel.class);
  187 + DefectiveChildModelResult result = getResultByModel(model);
  188 + BaseResponse baseResponse = new BaseResponse();
  189 + baseResponse.setObject(result);
  190 + return baseResponse;
  191 + }
  192 + return new BaseResponse("参数缺失", ErrorCodeConstants.PARAMETER_ERROR);
  193 + }
  194 +
  195 + /**
  196 + * 将实体类转换为result
  197 + *
  198 + * @param model
  199 + * @return
  200 + */
  201 + private DefectiveChildModelResult getResultByModel(DefectiveChildModel model) {
  202 + if (model == null) {
  203 + return new DefectiveChildModelResult();
  204 + }
  205 + DefectiveChildModelResult result = new DefectiveChildModelResult();
  206 + BeanUtils.copyProperties(model, result);
  207 + String createUser = result.getCreateUser();
  208 + if (StringUtils.isNotEmpty(createUser)) {
  209 + Users users = usersService.getUsers(Integer.parseInt(createUser));
  210 + if (users != null) {
  211 + result.setCreateUserStr(users.getName());
  212 + }
  213 + }
  214 + String hospitalId = result.getHospitalId();
  215 + if (StringUtils.isNotEmpty(hospitalId)) {
  216 + Organization organization = organizationService.getOrganization(Integer.parseInt(hospitalId));
  217 + if (organization != null) {
  218 + result.setHospitalStr(organization.getName());
  219 + }
  220 + }
  221 + Date created = result.getCreated();
  222 + if (created != null) {
  223 + result.setCreateStr(DateUtil.getyyyy_MM_dd(created));
  224 + }
  225 +
  226 + String addressStr = CommonsHelper.getResidence(
  227 + result.getProvince(),
  228 + result.getCity(),
  229 + result.getArea(),
  230 + result.getStreet(),
  231 + null,
  232 + basicConfigService);
  233 + result.setAddressStr(addressStr);
  234 + Date babyBirth = result.getBabyBirth();
  235 + if (babyBirth != null) {
  236 + result.setBabyBirthStr(DateUtil.getyyyy_MM_dd(babyBirth));
  237 + }
  238 +
  239 + return result;
  240 + }
  241 +
  242 + /**
  243 + * 根据住院号号获取对应的信息
  244 + *
  245 + * @param param 检索的条件
  246 + * @return
  247 + */
  248 + @Override
  249 + public BaseResponse getPatientInfoByIdCard(CommonParamRequest param) {
  250 + String inHospitalId = param.getCardNo();
  251 + List<DefectiveChildModelResult> results = new LinkedList<>();
  252 + if (StringUtils.isNotEmpty(inHospitalId)) {
  253 + List<DefectiveChildModel> defectiveChildModels = mongoTemplate.find(Query.query(Criteria.where("inHospitalId").is(inHospitalId)), DefectiveChildModel.class);
  254 + for (DefectiveChildModel model : defectiveChildModels) {
  255 + DefectiveChildModelResult result = getResultByModel(model);
  256 + results.add(result);
  257 + }
  258 + }
  259 + BaseResponse baseResponse = new BaseResponse();
  260 + baseResponse.setObject(results);
  261 + return baseResponse;
  262 + }
  263 +}