Commit c6d8c5da83fe2d86b37be4026749338676db364d

Authored by dongqin
1 parent 98e30a9759

个案支持update

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 @ c6d8c5d
  1 +package com.lyms.platform.operate.web.controller;
  2 +
  3 +import org.springframework.beans.factory.annotation.Autowired;
  4 +import org.springframework.stereotype.Controller;
  5 +import org.springframework.web.bind.annotation.RequestMapping;
  6 +import org.springframework.web.bind.annotation.RequestMethod;
  7 +import org.springframework.web.bind.annotation.ResponseBody;
  8 +
  9 +import com.fasterxml.jackson.annotation.JsonAlias;
  10 +import com.lyms.platform.common.annotation.TokenRequired;
  11 +import com.lyms.platform.common.base.BaseController;
  12 +import com.lyms.platform.common.result.BaseListResponse;
  13 +import com.lyms.platform.common.result.BaseResponse;
  14 +import com.lyms.platform.operate.web.request.CommonRequest;
  15 +import com.lyms.platform.operate.web.request.DefectiveChildListRequest;
  16 +import com.lyms.platform.operate.web.service.ICommonServer;
  17 +
  18 +/**
  19 + * @author dongqin
  20 + * @description
  21 + * @date 15:14 2019/12/2
  22 + **/
  23 +@Controller
  24 +@RequestMapping("/common")
  25 +public class CommonController extends BaseController {
  26 +
  27 + @Autowired
  28 + private ICommonServer commonServer;
  29 +
  30 + /**
  31 + * 根据 cardNo、pid、womenId检索
  32 + *
  33 + * @param param
  34 + * @return
  35 + */
  36 + @RequestMapping(method = RequestMethod.GET, value = "/searchByKeyword")
  37 + @ResponseBody
  38 + @TokenRequired
  39 + public BaseResponse searchByKeyword(@JsonAlias CommonRequest param) {
  40 + return commonServer.searchByKeyword(param);
  41 + }
  42 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/CommonRequest.java View file @ c6d8c5d
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +public class CommonRequest implements Serializable, Cloneable {
  6 +
  7 + private static final long serialVersionUID = 2248940647114350872L;
  8 +
  9 + /**
  10 + * 身份证号码
  11 + */
  12 + private String cardNo;
  13 +
  14 + /**
  15 + * 孕妇人对应的id
  16 + */
  17 + private String pid;
  18 +
  19 + /**
  20 + * 妇女id
  21 + */
  22 + private String womenId;
  23 +
  24 + public Object clone() throws CloneNotSupportedException {
  25 + return super.clone();
  26 + }
  27 +
  28 + public String getCardNo() {
  29 + return cardNo;
  30 + }
  31 +
  32 + public void setCardNo(String cardNo) {
  33 + this.cardNo = cardNo;
  34 + }
  35 +
  36 + public String getPid() {
  37 + return pid;
  38 + }
  39 +
  40 + public void setPid(String pid) {
  41 + this.pid = pid;
  42 + }
  43 +
  44 + public String getWomenId() {
  45 + return womenId;
  46 + }
  47 +
  48 + public void setWomenId(String womenId) {
  49 + this.womenId = womenId;
  50 + }
  51 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/ICommonServer.java View file @ c6d8c5d
  1 +package com.lyms.platform.operate.web.service;
  2 +
  3 +import com.lyms.platform.common.result.BaseResponse;
  4 +import com.lyms.platform.operate.web.request.CommonRequest;
  5 +
  6 +public interface ICommonServer {
  7 +
  8 +
  9 + /**
  10 + * 根据 cardNo、pid、womenId检索
  11 + *
  12 + * @param param
  13 + * @return
  14 + */
  15 + BaseResponse searchByKeyword(CommonRequest param);
  16 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/CommonServerImpl.java View file @ c6d8c5d
  1 +package com.lyms.platform.operate.web.service.impl;
  2 +
  3 +import org.slf4j.Logger;
  4 +import org.slf4j.LoggerFactory;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.data.mongodb.core.MongoTemplate;
  7 +import org.springframework.data.mongodb.core.query.Criteria;
  8 +import org.springframework.data.mongodb.core.query.Query;
  9 +import org.springframework.stereotype.Service;
  10 +
  11 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  12 +import com.lyms.platform.common.result.BaseResponse;
  13 +import com.lyms.platform.common.utils.StringUtils;
  14 +import com.lyms.platform.operate.web.request.CommonRequest;
  15 +import com.lyms.platform.operate.web.service.ICommonServer;
  16 +import com.lyms.platform.pojo.PersonModel;
  17 +import com.lyms.platform.pojo.ResidentsArchiveModel;
  18 +
  19 +/**
  20 + * @author dongqin
  21 + * @description
  22 + * @date 15:21 2019/12/2
  23 + **/
  24 +@Service
  25 +public class CommonServerImpl implements ICommonServer {
  26 +
  27 + @Autowired
  28 + private MongoTemplate mongoTemplate;
  29 +
  30 + private static final Logger log = LoggerFactory.getLogger(CommonServerImpl.class);
  31 +
  32 + /**
  33 + * 根据 指定一个cardNo、pid、womenId,检索出其他2个字段的值
  34 + *
  35 + * @param param
  36 + * @return
  37 + */
  38 + @Override
  39 + public BaseResponse searchByKeyword(CommonRequest param) {
  40 +
  41 + CommonRequest result = new CommonRequest();
  42 + try {
  43 + result = (CommonRequest) param.clone();
  44 + } catch (CloneNotSupportedException e) {
  45 + log.error("CloneNotSupportedException", e.fillInStackTrace());
  46 + return new BaseResponse( ErrorCodeConstants.SYSTEM_ERROR_DESCRIPTION, ErrorCodeConstants.SYSTEM_ERROR);
  47 + }
  48 + BaseResponse baseResponse = new BaseResponse();
  49 + String cardNo = param.getCardNo();
  50 + if (StringUtils.isNotEmpty(cardNo)) {
  51 + result.setCardNo(cardNo);
  52 + PersonModel personModel = mongoTemplate.findOne(Query.query(Criteria.where("cardNo").is(cardNo)), PersonModel.class);
  53 + if (personModel != null) {
  54 + result.setPid(personModel.getId());
  55 + ResidentsArchiveModel archiveModel = mongoTemplate.findOne(Query.query(Criteria.where("certificateNum").is(cardNo)), ResidentsArchiveModel.class);
  56 + if (archiveModel != null) {
  57 + result.setWomenId(archiveModel.getId());
  58 + }
  59 + }
  60 + baseResponse.setObject(result);
  61 + return baseResponse;
  62 + }
  63 +
  64 + String pid = param.getPid();
  65 + if (StringUtils.isNotEmpty(pid)) {
  66 + result.setPid(pid);
  67 + PersonModel personModel = mongoTemplate.findOne(Query.query(Criteria.where("id").is(pid)), PersonModel.class);
  68 + if (personModel != null) {
  69 + String personModelCardNo = personModel.getCardNo();
  70 + result.setCardNo(personModelCardNo);
  71 + ResidentsArchiveModel archiveModel = mongoTemplate.findOne(Query.query(Criteria.where("certificateNum").is(personModelCardNo)), ResidentsArchiveModel.class);
  72 + if (archiveModel != null) {
  73 + result.setWomenId(archiveModel.getId());
  74 + }
  75 + }
  76 + baseResponse.setObject(result);
  77 + return baseResponse;
  78 + }
  79 +
  80 + String womenId = param.getWomenId();
  81 + if (StringUtils.isNotEmpty(womenId)) {
  82 + result.setWomenId(womenId);
  83 + ResidentsArchiveModel archiveModel = mongoTemplate.findOne(Query.query(Criteria.where("id").is(womenId)), ResidentsArchiveModel.class);
  84 + if (archiveModel != null) {
  85 + result.setCardNo(archiveModel.getCertificateNum());
  86 + PersonModel personModel = mongoTemplate.findOne(Query.query(Criteria.where("cardNo").is(archiveModel.getCertificateNum())), PersonModel.class);
  87 + if (personModel != null) {
  88 + result.setPid(personModel.getId());
  89 + }
  90 + }
  91 + baseResponse.setObject(result);
  92 + return baseResponse;
  93 + }
  94 +
  95 + return new BaseResponse("参数缺失",ErrorCodeConstants.PARAMETER_ERROR);
  96 + }
  97 +}