Commit ddbf1296be2a1851ce6df89ff69f59dbbf716edb
1 parent
f9912ca03b
Exists in
dev
孕妇学校功能开发
Showing 2 changed files with 342 additions and 0 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientCourseWxController.java
View file @
ddbf129
| 1 | +package com.lyms.platform.operate.web.controller; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.lyms.platform.common.base.BaseController; | |
| 5 | +import com.lyms.platform.common.result.BaseResponse; | |
| 6 | +import com.lyms.platform.operate.web.facade.PatientCourseWxFacade; | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.stereotype.Controller; | |
| 9 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 11 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 12 | +import org.springframework.web.bind.annotation.ResponseBody; | |
| 13 | + | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * 孕妇预约和签到课程 | |
| 17 | + */ | |
| 18 | +@Controller | |
| 19 | +@RequestMapping("/patientCourseWx") | |
| 20 | +public class PatientCourseWxController extends BaseController { | |
| 21 | + | |
| 22 | + @Autowired | |
| 23 | + private PatientCourseWxFacade patientCourseWxFacade; | |
| 24 | + | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 搜索签到详情 | |
| 28 | + * @param queryNo | |
| 29 | + * @return | |
| 30 | + */ | |
| 31 | + @RequestMapping(method = RequestMethod.GET, value = "/queryWxSignPatient") | |
| 32 | + @ResponseBody | |
| 33 | + public BaseResponse queryWxSignPatient( | |
| 34 | + @RequestParam(required = true) String queryNo, | |
| 35 | + @RequestParam(required = true) String courseId, | |
| 36 | + @RequestParam(required = true) String hospitalId) { | |
| 37 | + | |
| 38 | + return patientCourseWxFacade.querySignPatient(queryNo, courseId,hospitalId); | |
| 39 | + } | |
| 40 | + | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * 院内系统和小程序孕妇预约课程 | |
| 44 | + * @param courseId 课程id | |
| 45 | + * @param hospitalId 医院id | |
| 46 | + * @return | |
| 47 | + */ | |
| 48 | + @RequestMapping(method = RequestMethod.GET, value = "/orderWxCourse") | |
| 49 | + @ResponseBody | |
| 50 | + public BaseResponse orderCourse( | |
| 51 | + @RequestParam(required = true) String courseId, | |
| 52 | + @RequestParam(required = true) String patientId, | |
| 53 | + @RequestParam(required = true) String hospitalId, | |
| 54 | + @RequestParam(required = false) Integer type) { | |
| 55 | + // 目前接口进来都是小程序 直接写2 orderType 预约类型 1 院内 2 小程序 | |
| 56 | + return patientCourseWxFacade.orderCourse(courseId, patientId, hospitalId, 2,type); | |
| 57 | + } | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 孕妇签到 | |
| 61 | + * @param patientCourseId | |
| 62 | + * @return | |
| 63 | + */ | |
| 64 | + @RequestMapping(method = RequestMethod.GET, value = "/signWxCourse") | |
| 65 | + @ResponseBody | |
| 66 | + public BaseResponse signCourse( | |
| 67 | + @RequestParam(required = true) String patientCourseId, | |
| 68 | + @RequestParam(required = true) String courseId, | |
| 69 | + @RequestParam(required = false) Integer type) { | |
| 70 | + | |
| 71 | + return patientCourseWxFacade.signCourse(patientCourseId, courseId,type); | |
| 72 | + } | |
| 73 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseWxFacade.java
View file @
ddbf129
| 1 | +package com.lyms.platform.operate.web.facade; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.lyms.platform.biz.service.CourseService; | |
| 5 | +import com.lyms.platform.biz.service.PatientCourseService; | |
| 6 | +import com.lyms.platform.biz.service.PatientsService; | |
| 7 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 10 | +import com.lyms.platform.common.result.BaseObjectResponse; | |
| 11 | +import com.lyms.platform.common.result.BaseResponse; | |
| 12 | +import com.lyms.platform.common.utils.DateUtil; | |
| 13 | +import com.lyms.platform.operate.web.result.PatientCourseResult; | |
| 14 | +import com.lyms.platform.pojo.CourseModel; | |
| 15 | +import com.lyms.platform.pojo.PatientCourseModel; | |
| 16 | +import com.lyms.platform.pojo.Patients; | |
| 17 | +import com.lyms.platform.query.CourseQuery; | |
| 18 | +import com.lyms.platform.query.PatientCourseQuery; | |
| 19 | +import com.lyms.platform.query.PatientsQuery; | |
| 20 | +import org.apache.commons.collections.CollectionUtils; | |
| 21 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 22 | +import org.springframework.stereotype.Component; | |
| 23 | + | |
| 24 | +import java.util.Date; | |
| 25 | +import java.util.List; | |
| 26 | + | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * | |
| 30 | + */ | |
| 31 | +@Component | |
| 32 | +public class PatientCourseWxFacade { | |
| 33 | + | |
| 34 | + @Autowired | |
| 35 | + private PatientCourseService patientCourseService; | |
| 36 | + | |
| 37 | + @Autowired | |
| 38 | + private PatientsService patientsService; | |
| 39 | + | |
| 40 | + @Autowired | |
| 41 | + private CourseService courseService; | |
| 42 | + | |
| 43 | + public BaseResponse orderCourse(String courseId, String patientId,String hospitalId,Integer orderType,Integer type) { | |
| 44 | + | |
| 45 | + BaseObjectResponse objectResponse = new BaseObjectResponse(); | |
| 46 | + CourseQuery query = new CourseQuery(); | |
| 47 | + query.setYn(YnEnums.YES.getId()); | |
| 48 | + query.setId(courseId); | |
| 49 | + // 先查课程表 | |
| 50 | + List<CourseModel> courseModels = courseService.queryCourseList(query); | |
| 51 | + if (CollectionUtils.isNotEmpty(courseModels)) | |
| 52 | + { | |
| 53 | + CourseModel model = courseModels.get(0); | |
| 54 | + if (model != null && model.getCourseEndTime().getTime() < new Date().getTime()) | |
| 55 | + { | |
| 56 | + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE); | |
| 57 | + objectResponse.setErrormsg("该课程预约时间已截止,请刷新后重试"); | |
| 58 | + return objectResponse; | |
| 59 | + } | |
| 60 | + | |
| 61 | + if (model != null && model.getLimitNum() != null && model.getLimitNum() < (model.getEnrolmentNum() == null? 1 : model.getEnrolmentNum()+1)) | |
| 62 | + { | |
| 63 | + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE); | |
| 64 | + objectResponse.setErrormsg("该课程预约人数已达上限,不能预约该课程了!"); | |
| 65 | + return objectResponse; | |
| 66 | + } | |
| 67 | + } | |
| 68 | + else | |
| 69 | + { | |
| 70 | + objectResponse.setErrorcode(ErrorCodeConstants.NO_DATA); | |
| 71 | + objectResponse.setErrormsg("该课程不存在"); | |
| 72 | + return objectResponse; | |
| 73 | + } | |
| 74 | + | |
| 75 | + // 目前这个接口进来的都是小程序端的 | |
| 76 | + if (orderType == 2) | |
| 77 | + { | |
| 78 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
| 79 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
| 80 | + patientsQuery.setId(patientId); | |
| 81 | + List<Patients> patientses = patientsService.queryPatient(patientsQuery); | |
| 82 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
| 83 | + | |
| 84 | + Patients patients = patientses.get(0); | |
| 85 | + patientsQuery.setId(null); | |
| 86 | + patientsQuery.setPid(patients.getPid()); | |
| 87 | + patientsQuery.setHospitalId(courseModels.get(0).getHospitalId()); | |
| 88 | + patientsQuery.setDesc("true"); | |
| 89 | + patientsQuery.setSort("created"); | |
| 90 | + patientses = patientsService.queryPatient(patientsQuery); | |
| 91 | + if (CollectionUtils.isNotEmpty(patientses)) | |
| 92 | + { | |
| 93 | + patientId = patientses.get(0).getId(); | |
| 94 | + } | |
| 95 | + } | |
| 96 | + } | |
| 97 | + | |
| 98 | + PatientCourseQuery patientCourseQuery = new PatientCourseQuery(); | |
| 99 | + patientCourseQuery.setCourseId(courseId); | |
| 100 | + patientCourseQuery.setYn(YnEnums.YES.getId()); | |
| 101 | + patientCourseQuery.setPatientId(patientId); | |
| 102 | + List<PatientCourseModel> patientCourseModels = patientCourseService.queryPatientCourseList(patientCourseQuery); | |
| 103 | + | |
| 104 | + if (CollectionUtils.isNotEmpty(patientCourseModels)) | |
| 105 | + { | |
| 106 | + PatientCourseModel model = patientCourseModels.get(0); | |
| 107 | + if (model.getStatus() != null && model.getStatus() == 1) | |
| 108 | + { | |
| 109 | + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE); | |
| 110 | + objectResponse.setErrormsg("您已经预约该课程了!"); | |
| 111 | + return objectResponse; | |
| 112 | + } | |
| 113 | + else if (model.getStatus() != null && model.getStatus() == 2) | |
| 114 | + { | |
| 115 | + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE); | |
| 116 | + objectResponse.setErrormsg("您已经签到该课程了!"); | |
| 117 | + return objectResponse; | |
| 118 | + } | |
| 119 | + } | |
| 120 | + | |
| 121 | + Patients patients = patientsService.findOnePatientById(patientId); | |
| 122 | + if (patients != null) | |
| 123 | + { | |
| 124 | + PatientCourseModel model = new PatientCourseModel(); | |
| 125 | + model.setPatientId(patients.getId()); | |
| 126 | + model.setBirthday(patients.getBirth()); | |
| 127 | + model.setCardNo(patients.getCardNo()); | |
| 128 | + model.setUserName(patients.getUsername()); | |
| 129 | + model.setPhone(patients.getPhone()); | |
| 130 | + model.setVcCardNo(patients.getVcCardNo()); | |
| 131 | + model.setOrderTime(new Date()); | |
| 132 | + model.setOrderType(orderType); | |
| 133 | + model.setHospitalId(hospitalId); | |
| 134 | + model.setCourseId(courseId); | |
| 135 | + model.setCreated(new Date()); | |
| 136 | + model.setModified(new Date()); | |
| 137 | + model.setYn(YnEnums.YES.getId()); | |
| 138 | + model.setStatus(1); | |
| 139 | + if (type!=null){ | |
| 140 | + model.setType(type); | |
| 141 | + } | |
| 142 | + | |
| 143 | + patientCourseService.addPatientCourse(model); | |
| 144 | + objectResponse.setData(model.getId()); | |
| 145 | + CourseModel courseModel = new CourseModel(); | |
| 146 | + courseModel.setId(courseId); | |
| 147 | + // 1是线上 2是线下 | |
| 148 | + if (null==type||type==1){ | |
| 149 | + courseModel.setEnrolmentNum(courseModels.get(0).getEnrolmentNum() == null ? 1 : courseModels.get(0).getEnrolmentNum()+1); | |
| 150 | + }else { | |
| 151 | + courseModel.setEnrolmentUnderNum(courseModels.get(0).getEnrolmentUnderNum() == null ? 1 : courseModels.get(0).getEnrolmentUnderNum()+1); | |
| 152 | + } | |
| 153 | + | |
| 154 | + courseService.updateCourse(courseModel); | |
| 155 | + | |
| 156 | + } | |
| 157 | + | |
| 158 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 159 | + objectResponse.setErrormsg("成功"); | |
| 160 | + return objectResponse; | |
| 161 | + } | |
| 162 | + | |
| 163 | + | |
| 164 | + public BaseResponse querySignPatient(String queryNo,String courseId,String hospitalId) { | |
| 165 | + | |
| 166 | + PatientCourseQuery patientCourseQuery = new PatientCourseQuery(); | |
| 167 | + patientCourseQuery.setCourseId(courseId); | |
| 168 | + patientCourseQuery.setYn(YnEnums.YES.getId()); | |
| 169 | + patientCourseQuery.setHospitalId(hospitalId); | |
| 170 | + patientCourseQuery.setQueryNo(queryNo); | |
| 171 | + //状态 1预约,2签到 | |
| 172 | +// patientCourseQuery.setStatus(2); | |
| 173 | + | |
| 174 | + List<PatientCourseModel> patientCourseModels = patientCourseService.queryPatientCourseList(patientCourseQuery); | |
| 175 | + if (CollectionUtils.isEmpty(patientCourseModels)) { | |
| 176 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
| 177 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
| 178 | + patientsQuery.setPvc(queryNo); | |
| 179 | + patientsQuery.setHospitalId(hospitalId); | |
| 180 | + patientsQuery.setDesc("true"); | |
| 181 | + patientsQuery.setSort("created"); | |
| 182 | + List<Patients> patientses = patientsService.queryPatient(patientsQuery); | |
| 183 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
| 184 | + Patients patients = patientses.get(0); | |
| 185 | + PatientCourseResult result = new PatientCourseResult(); | |
| 186 | + result.setAge(DateUtil.getAge(patients.getBirth(), new Date())); | |
| 187 | + result.setCardNo(patients.getCardNo()); | |
| 188 | + result.setUserName(patients.getUsername()); | |
| 189 | + result.setPhone(patients.getPhone()); | |
| 190 | + result.setVcCardNo(patients.getVcCardNo()); | |
| 191 | + result.setPatientId(patients.getId()); | |
| 192 | + | |
| 193 | + BaseObjectResponse objectResponse = new BaseObjectResponse(); | |
| 194 | + objectResponse.setData(result); | |
| 195 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 196 | + objectResponse.setErrormsg("成功"); | |
| 197 | + return objectResponse; | |
| 198 | + } | |
| 199 | + } | |
| 200 | + BaseListResponse objectResponse = new BaseListResponse(); | |
| 201 | + objectResponse.setData(patientCourseModels); | |
| 202 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 203 | + objectResponse.setErrormsg("成功"); | |
| 204 | + return objectResponse; | |
| 205 | + } | |
| 206 | + | |
| 207 | + public BaseResponse signCourse(String patientCourseId,String courseId,Integer type) { | |
| 208 | + | |
| 209 | + BaseResponse objectResponse = new BaseResponse(); | |
| 210 | + CourseQuery query = new CourseQuery(); | |
| 211 | + query.setYn(YnEnums.YES.getId()); | |
| 212 | + query.setId(courseId); | |
| 213 | + List<CourseModel> courseModels = courseService.queryCourseList(query); | |
| 214 | + if (CollectionUtils.isNotEmpty(courseModels)) | |
| 215 | + { | |
| 216 | + CourseModel model = courseModels.get(0); | |
| 217 | + if (model != null && model.getCourseEndTime().getTime() < new Date().getTime()) | |
| 218 | + { | |
| 219 | + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE); | |
| 220 | + objectResponse.setErrormsg("该课程签到时间已截止,请刷新后重试"); | |
| 221 | + return objectResponse; | |
| 222 | + } | |
| 223 | + } | |
| 224 | + PatientCourseQuery patientCourseQuery = new PatientCourseQuery(); | |
| 225 | + patientCourseQuery.setYn(YnEnums.YES.getId()); | |
| 226 | + //状态 1预约,2签到 | |
| 227 | + patientCourseQuery.setStatus(1); | |
| 228 | + patientCourseQuery.setId(patientCourseId); | |
| 229 | + List<PatientCourseModel> patientCourseModels = patientCourseService.queryPatientCourseList(patientCourseQuery); | |
| 230 | + if (!CollectionUtils.isNotEmpty(patientCourseModels)) | |
| 231 | + { | |
| 232 | + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE); | |
| 233 | + objectResponse.setErrormsg("您签到的课程还没有预约,请预约后签到!"); | |
| 234 | + return objectResponse; | |
| 235 | + } | |
| 236 | + | |
| 237 | + if (patientCourseId != null) | |
| 238 | + { | |
| 239 | + PatientCourseModel model = new PatientCourseModel(); | |
| 240 | + model.setSignTime(new Date()); | |
| 241 | + model.setId(patientCourseId); | |
| 242 | + model.setModified(new Date()); | |
| 243 | + model.setYn(YnEnums.YES.getId()); | |
| 244 | + model.setStatus(2); | |
| 245 | + if (type!=null){ | |
| 246 | + model.setType(type); | |
| 247 | + } | |
| 248 | + patientCourseService.updatePatientCourse(model); | |
| 249 | + | |
| 250 | + | |
| 251 | + CourseModel courseModel = new CourseModel(); | |
| 252 | + courseModel.setId(courseId); | |
| 253 | + //1是线上 2是线下 | |
| 254 | + if (null==type||type==1){ | |
| 255 | + courseModel.setSignNum(courseModels.get(0).getSignNum() == null ? 1 : courseModels.get(0).getSignNum() + 1); | |
| 256 | + }else { | |
| 257 | + courseModel.setSignUnderNum(courseModels.get(0).getSignUnderNum() == null ? 1 : courseModels.get(0).getSignUnderNum() + 1); | |
| 258 | + | |
| 259 | + } | |
| 260 | + courseService.updateCourse(courseModel); | |
| 261 | + } | |
| 262 | + | |
| 263 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 264 | + objectResponse.setErrormsg("成功"); | |
| 265 | + return objectResponse; | |
| 266 | + } | |
| 267 | +} |