Commit 21af61b19166754b1d588aabddc1c693a27a4f3f

Authored by yangfei
1 parent cfd344ea7e

开通VIP增值服务

Showing 7 changed files with 506 additions and 3 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/model/PatientService.java View file @ 21af61b
... ... @@ -15,6 +15,15 @@
15 15 private Date updateDate;
16 16 private String updateUserName;
17 17 private String updateUser;
  18 + private String hospitalId;
  19 +
  20 + public String getHospitalId() {
  21 + return hospitalId;
  22 + }
  23 +
  24 + public void setHospitalId(String hospitalId) {
  25 + this.hospitalId = hospitalId;
  26 + }
18 27  
19 28 public String getId() {
20 29 return id;
platform-biz-service/src/main/java/com/lyms/platform/permission/model/PatientServiceQuery.java View file @ 21af61b
... ... @@ -19,6 +19,15 @@
19 19 private Date updateDate;
20 20 private String updateUserName;
21 21 private String updateUser;
  22 + private String hospitalId;
  23 +
  24 + public String getHospitalId() {
  25 + return hospitalId;
  26 + }
  27 +
  28 + public void setHospitalId(String hospitalId) {
  29 + this.hospitalId = hospitalId;
  30 + }
22 31  
23 32 public String getId() {
24 33 return id;
platform-biz-service/src/main/resources/mainOrm/master/PatientService.xml View file @ 21af61b
... ... @@ -15,12 +15,13 @@
15 15 <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
16 16 <result column="update_user_name" property="updateUserName" jdbcType="VARCHAR" />
17 17 <result column="update_user" property="updateUser" jdbcType="VARCHAR" />
  18 +<result column="hospital_id" property="hospitalId" jdbcType="VARCHAR" />
18 19 </resultMap>
19 20  
20 21  
21 22  
22 23 <insert id="addPatientService" parameterType="com.lyms.platform.permission.model.PatientService">
23   -insert into patient_service (id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user) values (#{id},#{parentid},#{pid},#{serType},#{serDoct},#{createDate},#{createUserName},#{createUser},#{serStatus},#{updateDate},#{updateUserName},#{updateUser})
  24 +insert into patient_service (id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id) values (#{id},#{parentid},#{pid},#{serType},#{serDoct},#{createDate},#{createUserName},#{createUser},#{serStatus},#{updateDate},#{updateUserName},#{updateUser},#{hospitalId})
24 25 </insert>
25 26  
26 27  
... ... @@ -59,6 +60,9 @@
59 60 <if test="updateUser != null and updateUser != ''">
60 61 update_user = #{updateUser,jdbcType=VARCHAR},
61 62 </if>
  63 +<if test="hospitalId != null and hospitalId != ''">
  64 + hospital_id = #{hospitalId,jdbcType=VARCHAR},
  65 +</if>
62 66 </set>
63 67 where id = #{id,jdbcType=VARCHAR}
64 68 </update>
... ... @@ -71,7 +75,7 @@
71 75  
72 76  
73 77 <select id="getPatientService" resultMap="PatientServiceResultMap" parameterType="java.lang.String">
74   -select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user
  78 +select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id
75 79 from patient_service where id = #{id,jdbcType=VARCHAR}
76 80 </select>
77 81  
78 82  
... ... @@ -126,13 +130,16 @@
126 130 <if test="updateUser != null and updateUser != ''">
127 131 and update_user = #{updateUser,jdbcType=VARCHAR}
128 132 </if>
  133 +<if test="hospitalId != null and hospitalId != ''">
  134 +and hospital_id = #{hospitalId,jdbcType=VARCHAR}
  135 +</if>
129 136 </where>
130 137 </sql>
131 138  
132 139  
133 140  
134 141 <select id="queryPatientService" resultMap="PatientServiceResultMap" parameterType="com.lyms.platform.permission.model.PatientServiceQuery">
135   -select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user
  142 +select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id
136 143 from patient_service
137 144 <include refid="PatientServiceCondition" />
138 145 <include refid="orderAndLimit" />
platform-common/src/main/java/com/lyms/platform/common/enums/PatientSerEnums.java View file @ 21af61b
  1 +package com.lyms.platform.common.enums;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.HashMap;
  5 +import java.util.List;
  6 +import java.util.Map;
  7 +
  8 +/**
  9 + * @auther yangfei
  10 + * @createTime 2017年09月11日 16时30分
  11 + * @discription 服务开通枚举
  12 + */
  13 +public class PatientSerEnums {
  14 + //服务类型(1-高危精准指导、2-体重、3-血糖、4-血压、5-专家咨询)
  15 + public enum SerTypeEnums{
  16 + gwjzzd(1,"高危精准指导"),
  17 + tz(2,"体重"),
  18 + xt(3, "血糖"),
  19 + xy(4, "血压"),
  20 + zjzx(5, "专家咨询");
  21 + private Integer id;
  22 + private String title;
  23 + private SerTypeEnums(Integer id, String title) {
  24 + this.id = id;
  25 + this.title = title;
  26 + }
  27 + public static String getTitle(Integer id) {
  28 + for (SerTypeEnums e:values()) {
  29 + if (e.getId() == id) {
  30 + return e.getTitle();
  31 + }
  32 + }
  33 + return "";
  34 + }
  35 +
  36 + public Integer getId() {
  37 + return id;
  38 + }
  39 +
  40 + public void setId(Integer id) {
  41 + this.id = id;
  42 + }
  43 +
  44 + public String getTitle() {
  45 + return title;
  46 + }
  47 +
  48 + public void setTitle(String title) {
  49 + this.title = title;
  50 + }
  51 + }
  52 +
  53 + //服务状态(1-开通、2-退订、3-过期、4-暂停)
  54 + public enum SerStatusEnums{
  55 + kt(1,"开通"),
  56 + td(2,"退订"),
  57 + gq(3, "过期"),
  58 + zt(4, "暂停");
  59 + private Integer id;
  60 + private String title;
  61 + private SerStatusEnums(Integer id, String title) {
  62 + this.id = id;
  63 + this.title = title;
  64 + }
  65 + public static String getTitle(Integer id) {
  66 + for (SerStatusEnums e:values()) {
  67 + if (e.getId() == id) {
  68 + return e.getTitle();
  69 + }
  70 + }
  71 + return "";
  72 + }
  73 +
  74 + public Integer getId() {
  75 + return id;
  76 + }
  77 +
  78 + public void setId(Integer id) {
  79 + this.id = id;
  80 + }
  81 +
  82 + public String getTitle() {
  83 + return title;
  84 + }
  85 +
  86 + public void setTitle(String title) {
  87 + this.title = title;
  88 + }
  89 + }
  90 +
  91 + //服务类型
  92 + public static List getSerType() {
  93 + List<Object> list = new ArrayList<>();
  94 + for (SerTypeEnums enums : SerTypeEnums.values()) {
  95 + Map<String, Object> resultMap = new HashMap<>();
  96 + resultMap.put("id", enums.getId());
  97 + resultMap.put("name", enums.getTitle());
  98 + list.add(resultMap);
  99 + }
  100 + return list;
  101 + }
  102 + //服务状态
  103 + public static List getSerStatus() {
  104 + List<Object> list = new ArrayList<>();
  105 + for (SerStatusEnums enums : SerStatusEnums.values()) {
  106 + Map<String, Object> resultMap = new HashMap<>();
  107 + resultMap.put("id", enums.getId());
  108 + resultMap.put("name", enums.getTitle());
  109 + list.add(resultMap);
  110 + }
  111 + return list;
  112 + }
  113 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientServiceController.java View file @ 21af61b
  1 +package com.lyms.platform.operate.web.controller;
  2 +
  3 +import com.lyms.platform.common.annotation.TokenRequired;
  4 +import com.lyms.platform.common.base.BaseController;
  5 +import com.lyms.platform.common.base.LoginContext;
  6 +import com.lyms.platform.common.result.BaseResponse;
  7 +import com.lyms.platform.common.utils.StringUtils;
  8 +import com.lyms.platform.operate.web.facade.PatientServiceFacade;
  9 +import com.lyms.platform.permission.model.PatientService;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Controller;
  12 +import org.springframework.web.bind.annotation.PathVariable;
  13 +import org.springframework.web.bind.annotation.RequestMapping;
  14 +import org.springframework.web.bind.annotation.RequestMethod;
  15 +import org.springframework.web.bind.annotation.ResponseBody;
  16 +
  17 +import javax.servlet.http.HttpServletRequest;
  18 +
  19 +/**
  20 + * @auther yangfei
  21 + * @createTime 2017年09月11日 11时36分
  22 + * @discription
  23 + */
  24 +@Controller
  25 +@RequestMapping("/patient")
  26 +public class PatientServiceController extends BaseController {
  27 +
  28 + @Autowired
  29 + private PatientServiceFacade patientServiceFacade;
  30 +
  31 + /**
  32 + * 初始化接口
  33 + * @return
  34 + */
  35 + @ResponseBody
  36 + @TokenRequired
  37 + @RequestMapping(value = "/patSer/init", method = RequestMethod.GET)
  38 + public BaseResponse patientServiceInit(){
  39 + return patientServiceFacade.patientServiceInit();
  40 + }
  41 + /**
  42 + * 根据孕妇Id查询在当前医院的服务开通记录
  43 + * @param pid 孕妇Id
  44 + * @param request
  45 + * @return
  46 + */
  47 + @ResponseBody
  48 + @TokenRequired
  49 + @RequestMapping(value = "/patSer", method = RequestMethod.GET)
  50 + public BaseResponse findPatientServiceList(String pid,HttpServletRequest request){
  51 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  52 + return patientServiceFacade.findPatientServiceList(pid,loginState.getId());
  53 + }
  54 +
  55 + /**
  56 + * 新增或修改服务开通记录
  57 + * @param ps 服务开通记录
  58 + * @param request
  59 + * @return
  60 + */
  61 + @ResponseBody
  62 + @TokenRequired
  63 + @RequestMapping(value = "/patSer", method = RequestMethod.POST)
  64 + public BaseResponse addOrUpdatePatientService(PatientService ps, HttpServletRequest request){
  65 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  66 + if(StringUtils.isNotEmpty(ps.getId())){
  67 + return patientServiceFacade.addPatientService(ps,loginState.getId());
  68 + }else{
  69 + return patientServiceFacade.updatePatientService(ps,loginState.getId());
  70 + }
  71 + }
  72 +
  73 + /**
  74 + * 根据Id获取开通继续
  75 + * @param id 开通服务id
  76 + * @param request
  77 + * @return
  78 + */
  79 + @ResponseBody
  80 + @TokenRequired
  81 + @RequestMapping(value = "/patSer/{id}", method = RequestMethod.GET)
  82 + public BaseResponse findOnePatientService(@PathVariable String id, HttpServletRequest request){
  83 + return patientServiceFacade.findOnePatientService(id);
  84 + }
  85 +
  86 +
  87 +
  88 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceFacade.java View file @ 21af61b
  1 +package com.lyms.platform.operate.web.facade;
  2 +
  3 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  4 +import com.lyms.platform.common.enums.PatientSerEnums;
  5 +import com.lyms.platform.common.result.BaseObjectResponse;
  6 +import com.lyms.platform.common.result.BaseResponse;
  7 +import com.lyms.platform.common.utils.DateUtil;
  8 +import com.lyms.platform.operate.web.result.PatientSerResult;
  9 +import com.lyms.platform.permission.model.PatientService;
  10 +import com.lyms.platform.permission.model.PatientServiceQuery;
  11 +import com.lyms.platform.permission.model.Users;
  12 +import com.lyms.platform.permission.service.OrganizationService;
  13 +import com.lyms.platform.permission.service.PatientServiceService;
  14 +import com.lyms.platform.permission.service.UsersService;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.stereotype.Component;
  17 +
  18 +import java.util.*;
  19 +
  20 +/**
  21 + * @auther yangfei
  22 + * @createTime 2017年09月11日 14时29分
  23 + * @discription 孕妇服务
  24 + */
  25 +@Component
  26 +public class PatientServiceFacade {
  27 +
  28 + @Autowired
  29 + private AutoMatchFacade autoMatchFacade;
  30 + @Autowired
  31 + private PatientServiceService patientServiceService;
  32 + @Autowired
  33 + private OrganizationService organizationService;
  34 + @Autowired
  35 + private UsersService usersService;
  36 +
  37 + public BaseResponse patientServiceInit() {
  38 + Map map = new HashMap();
  39 + //服务类型
  40 + map.put("serType", PatientSerEnums.getSerType());
  41 + //服务状态
  42 + map.put("serStatus", PatientSerEnums.getSerStatus());
  43 + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION).setData(map);
  44 + }
  45 +
  46 + /**
  47 + * 根据孕妇id查询服务记录
  48 + * @param pid
  49 + * @param id
  50 + * @return
  51 + */
  52 + public BaseResponse findPatientServiceList(String pid, Integer id) {
  53 + //根据用户id获取医院ID
  54 + String hospitalId = autoMatchFacade.getHospitalId(id);
  55 + PatientServiceQuery patientQuery = new PatientServiceQuery();
  56 + patientQuery.setHospitalId(hospitalId);
  57 + patientQuery.setParentid(pid);
  58 +
  59 + List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery);
  60 +
  61 + List<PatientSerResult> patientSerResults = new ArrayList<>();
  62 + for(PatientService ps : patientServices){
  63 + PatientSerResult patientSerResult = convertToResult(ps);
  64 + patientSerResults.add(patientSerResult);
  65 + }
  66 +
  67 + BaseResponse baseResponse = new BaseResponse();
  68 + baseResponse.setObject(patientSerResults);
  69 + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  70 + baseResponse.setErrormsg("成功");
  71 + return baseResponse;
  72 + }
  73 +
  74 + /**
  75 + * 根据id查询一条服务开通记录
  76 + * @param id
  77 + * @return
  78 + */
  79 + public BaseResponse findOnePatientService(String id) {
  80 + PatientService patientService = patientServiceService.getPatientService(id);
  81 + PatientSerResult patientSerResult = convertToResult(patientService);
  82 +
  83 + BaseResponse baseResponse = new BaseResponse();
  84 + baseResponse.setObject(patientSerResult);
  85 + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  86 + baseResponse.setErrormsg("成功");
  87 + return baseResponse;
  88 + }
  89 +
  90 + /**
  91 + * 新增服务开通记录
  92 + * @param ps
  93 + * @param id
  94 + * @return
  95 + */
  96 + public BaseResponse addPatientService(PatientService ps,Integer id){
  97 + //根据用户id获取医院ID
  98 + String hospitalId = autoMatchFacade.getHospitalId(id);
  99 + ps.setHospitalId(hospitalId);
  100 + ps.setCreateDate(new Date());
  101 + ps.setCreateUser(String.valueOf(id));
  102 + patientServiceService.addPatientService(ps);
  103 +
  104 + BaseResponse baseResponse = new BaseResponse();
  105 + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  106 + baseResponse.setErrormsg("成功");
  107 + return baseResponse;
  108 + }
  109 +
  110 +
  111 + /**
  112 + * 修改服务开通记录
  113 + * @param ps 服务对象
  114 + * @param id 用户id
  115 + * @return
  116 + */
  117 + public BaseResponse updatePatientService(PatientService ps,Integer id){
  118 + //根据用户id获取医院ID
  119 + ps.setUpdateDate(new Date());
  120 + ps.setUpdateUser(String.valueOf(id));
  121 + patientServiceService.updatePatientService(ps);
  122 +
  123 + BaseResponse baseResponse = new BaseResponse();
  124 + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  125 + baseResponse.setErrormsg("成功");
  126 + return baseResponse;
  127 + }
  128 +
  129 + /**
  130 + * 数据转换
  131 + * @param ps
  132 + * @return
  133 + */
  134 + public PatientSerResult convertToResult(PatientService ps){
  135 + PatientSerResult result = new PatientSerResult();
  136 + result.setId(ps.getId());
  137 + result.setParentid(ps.getParentid());
  138 + result.setCreateDate(DateUtil.getyyyy_MM_dd(ps.getCreateDate()));
  139 + result.setPid(ps.getPid());
  140 + result.setSerType(ps.getSerType());
  141 + String serType = PatientSerEnums.SerTypeEnums.getTitle(ps.getSerType());
  142 + result.setSerTypeStr(serType);
  143 + result.setSerStatus(ps.getSerStatus());
  144 + String serStatus = PatientSerEnums.SerStatusEnums.getTitle(ps.getSerStatus());
  145 + result.setSerStatusStr(serStatus);
  146 + result.setSerDoct(ps.getSerDoct());
  147 +
  148 + Users users = usersService.getUsers(Integer.parseInt(ps.getSerDoct()));
  149 + if (users != null) {
  150 + result.setSerDoctStr(users.getName());
  151 + } else {
  152 + result.setSerDoctStr("产检医生");
  153 + }
  154 + result.setSerDoct(ps.getSerDoct());
  155 + return result;
  156 + }
  157 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/PatientSerResult.java View file @ 21af61b
  1 +package com.lyms.platform.operate.web.result;
  2 +
  3 +/**
  4 + * @auther yangfei
  5 + * @createTime 2017年09月11日 15时56分
  6 + * @discription 孕妇服务开通记录
  7 + */
  8 +public class PatientSerResult {
  9 + private String id;
  10 + /**
  11 + * 孕妇id
  12 + */
  13 + private String parentid;
  14 + /**
  15 + * personId
  16 + */
  17 + private String pid;
  18 + /**
  19 + * 服务类型(1-高危精准指导、2-体重、3-血糖、4-血压、5-专家咨询)
  20 + */
  21 + private Integer serType;
  22 + private String serTypeStr;
  23 + /**
  24 + * 开通医生
  25 + */
  26 + private String serDoct;
  27 + /**
  28 + * 开通医生
  29 + */
  30 + private String serDoctStr;
  31 + /**
  32 + * 创建时间
  33 + */
  34 + private String createDate;
  35 + /**
  36 + * 服务状态(1-开通、2-退订、3-过期、4-暂停)
  37 + */
  38 + private Integer serStatus;
  39 + private String serStatusStr;
  40 +
  41 + public String getId() {
  42 + return id;
  43 + }
  44 +
  45 + public void setId(String id) {
  46 + this.id = id;
  47 + }
  48 +
  49 + public String getParentid() {
  50 + return parentid;
  51 + }
  52 +
  53 + public void setParentid(String parentid) {
  54 + this.parentid = parentid;
  55 + }
  56 +
  57 + public String getPid() {
  58 + return pid;
  59 + }
  60 +
  61 + public void setPid(String pid) {
  62 + this.pid = pid;
  63 + }
  64 +
  65 + public Integer getSerType() {
  66 + return serType;
  67 + }
  68 +
  69 + public void setSerType(Integer serType) {
  70 + this.serType = serType;
  71 + }
  72 +
  73 + public String getSerTypeStr() {
  74 + return serTypeStr;
  75 + }
  76 +
  77 + public void setSerTypeStr(String serTypeStr) {
  78 + this.serTypeStr = serTypeStr;
  79 + }
  80 +
  81 + public String getSerDoct() {
  82 + return serDoct;
  83 + }
  84 +
  85 + public void setSerDoct(String serDoct) {
  86 + this.serDoct = serDoct;
  87 + }
  88 +
  89 + public String getSerDoctStr() {
  90 + return serDoctStr;
  91 + }
  92 +
  93 + public void setSerDoctStr(String serDoctStr) {
  94 + this.serDoctStr = serDoctStr;
  95 + }
  96 +
  97 + public String getCreateDate() {
  98 + return createDate;
  99 + }
  100 +
  101 + public void setCreateDate(String createDate) {
  102 + this.createDate = createDate;
  103 + }
  104 +
  105 + public Integer getSerStatus() {
  106 + return serStatus;
  107 + }
  108 +
  109 + public void setSerStatus(Integer serStatus) {
  110 + this.serStatus = serStatus;
  111 + }
  112 +
  113 + public String getSerStatusStr() {
  114 + return serStatusStr;
  115 + }
  116 +
  117 + public void setSerStatusStr(String serStatusStr) {
  118 + this.serStatusStr = serStatusStr;
  119 + }
  120 +}