Commit f489d0352977acc107f93eee7cbb9672b7e8df4a
1 parent
55c7636d0b
Exists in
master
and in
6 other branches
孕妇学校
Showing 3 changed files with 132 additions and 9 deletions
platform-dal/src/main/java/com/lyms/platform/query/CourseQuery.java
View file @
f489d03
| ... | ... | @@ -70,9 +70,12 @@ |
| 70 | 70 | private Integer yn; |
| 71 | 71 | |
| 72 | 72 | private String hospitalId; |
| 73 | + private List<String> hospitalIds; | |
| 73 | 74 | |
| 74 | 75 | private Date courseEndTime; |
| 75 | 76 | |
| 77 | + private String keyword; | |
| 78 | + | |
| 76 | 79 | @Override |
| 77 | 80 | public MongoQuery convertToQuery() { |
| 78 | 81 | MongoCondition condition = MongoCondition.newInstance(); |
| ... | ... | @@ -112,6 +115,10 @@ |
| 112 | 115 | condition = condition.and("status", status, MongoOper.IS); |
| 113 | 116 | } |
| 114 | 117 | |
| 118 | + if (null != hospitalIds && hospitalIds.size() > 0) { | |
| 119 | + condition = condition.and("hospitalId", hospitalIds, MongoOper.IN); | |
| 120 | + } | |
| 121 | + | |
| 115 | 122 | Criteria c1 = null; |
| 116 | 123 | |
| 117 | 124 | if (null != courseTimeStart) { |
| ... | ... | @@ -157,6 +164,24 @@ |
| 157 | 164 | condition = condition.andCondition(new MongoCondition(c1)); |
| 158 | 165 | } |
| 159 | 166 | return condition.toMongoQuery(); |
| 167 | + } | |
| 168 | + | |
| 169 | + @Override | |
| 170 | + public String getKeyword() { | |
| 171 | + return keyword; | |
| 172 | + } | |
| 173 | + | |
| 174 | + @Override | |
| 175 | + public void setKeyword(String keyword) { | |
| 176 | + this.keyword = keyword; | |
| 177 | + } | |
| 178 | + | |
| 179 | + public List<String> getHospitalIds() { | |
| 180 | + return hospitalIds; | |
| 181 | + } | |
| 182 | + | |
| 183 | + public void setHospitalIds(List<String> hospitalIds) { | |
| 184 | + this.hospitalIds = hospitalIds; | |
| 160 | 185 | } |
| 161 | 186 | |
| 162 | 187 | public Date getCourseEndTime() { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientCourseController.java
View file @
f489d03
| ... | ... | @@ -135,19 +135,23 @@ |
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * 获取小程序的孕妇学校列表 |
| 138 | - * @param patientCourseId | |
| 139 | - * @param courseId | |
| 138 | + * @param hospitalIds 相关医院id | |
| 139 | + * @param patientId 患者id | |
| 140 | 140 | * @param request |
| 141 | 141 | * @return |
| 142 | 142 | */ |
| 143 | 143 | @RequestMapping(method = RequestMethod.GET, value = "/getAppPatientCourseList") |
| 144 | 144 | @ResponseBody |
| 145 | 145 | public BaseResponse getAppPatientCourseList( |
| 146 | - @RequestParam(required = true) String patientCourseId, | |
| 147 | - @RequestParam(required = true) String courseId, | |
| 146 | + @RequestParam(required = true) String hospitalIds, | |
| 147 | + @RequestParam(required = true) String patientId, | |
| 148 | + @RequestParam(required = false) String keyword, | |
| 149 | + @RequestParam(required = true) Integer status, | |
| 150 | + @RequestParam("page") Integer page, | |
| 151 | + @RequestParam("limit") Integer limit, | |
| 148 | 152 | HttpServletRequest request) { |
| 149 | 153 | |
| 150 | - return patientCourseFacade.signCourse(patientCourseId,courseId,getUserId(request)); | |
| 154 | + return patientCourseFacade.getAppPatientCourseList(status,hospitalIds, patientId,keyword,page,limit); | |
| 151 | 155 | } |
| 152 | 156 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseFacade.java
View file @
f489d03
| ... | ... | @@ -11,12 +11,17 @@ |
| 11 | 11 | import com.lyms.platform.common.result.BaseObjectResponse; |
| 12 | 12 | import com.lyms.platform.common.result.BaseResponse; |
| 13 | 13 | import com.lyms.platform.common.utils.DateUtil; |
| 14 | +import com.lyms.platform.operate.web.result.CourseTypeResult; | |
| 14 | 15 | import com.lyms.platform.operate.web.result.PatientCourseResult; |
| 16 | +import com.lyms.platform.permission.model.Organization; | |
| 17 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 15 | 18 | import com.lyms.platform.permission.service.UsersService; |
| 16 | 19 | import com.lyms.platform.pojo.CourseModel; |
| 20 | +import com.lyms.platform.pojo.CourseTypeModel; | |
| 17 | 21 | import com.lyms.platform.pojo.PatientCourseModel; |
| 18 | 22 | import com.lyms.platform.pojo.Patients; |
| 19 | 23 | import com.lyms.platform.query.CourseQuery; |
| 24 | +import com.lyms.platform.query.CourseTypeQuery; | |
| 20 | 25 | import com.lyms.platform.query.PatientCourseQuery; |
| 21 | 26 | import com.lyms.platform.query.PatientsQuery; |
| 22 | 27 | import org.apache.commons.collections.CollectionUtils; |
| ... | ... | @@ -24,9 +29,7 @@ |
| 24 | 29 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | 30 | import org.springframework.stereotype.Component; |
| 26 | 31 | |
| 27 | -import java.util.ArrayList; | |
| 28 | -import java.util.Date; | |
| 29 | -import java.util.List; | |
| 32 | +import java.util.*; | |
| 30 | 33 | |
| 31 | 34 | |
| 32 | 35 | /** |
| 33 | 36 | |
| ... | ... | @@ -54,7 +57,10 @@ |
| 54 | 57 | @Autowired |
| 55 | 58 | private CourseService courseService; |
| 56 | 59 | |
| 60 | + @Autowired | |
| 61 | + private OrganizationService organizationService; | |
| 57 | 62 | |
| 63 | + | |
| 58 | 64 | public BaseResponse getPatientCourseList(Integer status,String courseId, Integer page, |
| 59 | 65 | Integer limit, Integer userId) { |
| 60 | 66 | |
| ... | ... | @@ -176,6 +182,13 @@ |
| 176 | 182 | objectResponse.setErrormsg("该课程预约时间已截止,请刷新后重试"); |
| 177 | 183 | return objectResponse; |
| 178 | 184 | } |
| 185 | + | |
| 186 | + if (model != null && model.getLimitNum() != null && model.getLimitNum() < (model.getEnrolmentNum() == null? 1 : model.getEnrolmentNum()+1)) | |
| 187 | + { | |
| 188 | + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE); | |
| 189 | + objectResponse.setErrormsg("该课程预约人数已达上限,不能预约该课程了!"); | |
| 190 | + return objectResponse; | |
| 191 | + } | |
| 179 | 192 | } |
| 180 | 193 | |
| 181 | 194 | Patients patients = patientsService.findOnePatientById(patientId); |
| ... | ... | @@ -265,7 +278,7 @@ |
| 265 | 278 | } |
| 266 | 279 | } |
| 267 | 280 | |
| 268 | - if (patientCourseId == null) | |
| 281 | + if (patientCourseId != null) | |
| 269 | 282 | { |
| 270 | 283 | PatientCourseModel model = new PatientCourseModel(); |
| 271 | 284 | model.setId(patientCourseId); |
| ... | ... | @@ -275,6 +288,87 @@ |
| 275 | 288 | patientCourseService.updatePatientCourse(model); |
| 276 | 289 | } |
| 277 | 290 | |
| 291 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 292 | + objectResponse.setErrormsg("成功"); | |
| 293 | + return objectResponse; | |
| 294 | + } | |
| 295 | + | |
| 296 | + public BaseResponse getAppPatientCourseList(Integer status,String hospitalIds, String patientId, | |
| 297 | + String keyword, Integer page, Integer limit) { | |
| 298 | + | |
| 299 | + List<String> hospitalIdList = new ArrayList<>(); | |
| 300 | + | |
| 301 | + if (StringUtils.isNotEmpty(hospitalIds)) | |
| 302 | + { | |
| 303 | + hospitalIdList = Arrays.asList(hospitalIds.split(",")); | |
| 304 | + } | |
| 305 | + | |
| 306 | + CourseQuery query = new CourseQuery(); | |
| 307 | + query.setStatus(status); | |
| 308 | + query.setYn(YnEnums.YES.getId()); | |
| 309 | + query.setPage(page); | |
| 310 | + query.setLimit(limit); | |
| 311 | + query.setNeed("true"); | |
| 312 | + query.setHospitalIds(hospitalIdList); | |
| 313 | + List<CourseModel> courseModels = courseService.queryCourseList(query); | |
| 314 | + | |
| 315 | + List<Map> results = new ArrayList<>(); | |
| 316 | + CourseTypeQuery courseTypeQuery = new CourseTypeQuery(); | |
| 317 | + query.setYn(YnEnums.YES.getId()); | |
| 318 | + | |
| 319 | + if (CollectionUtils.isNotEmpty(courseModels)) | |
| 320 | + { | |
| 321 | + for (CourseModel model : courseModels) | |
| 322 | + { | |
| 323 | + Map<String,String> result = new HashMap<>(); | |
| 324 | + //课程名称 | |
| 325 | + result.put("courseName",model.getCourseName()); | |
| 326 | + //课程描述 | |
| 327 | + result.put("courseDesc",model.getCourseDesc() == null ? "" : model.getCourseDesc()); | |
| 328 | + //课程时间 | |
| 329 | + result.put("courseTime",DateUtil.gety_m_dhm(model.getCourseTime())); | |
| 330 | + //课程地址 | |
| 331 | + result.put("courseAddress", model.getCourseAddress() == null ? "" : model.getCourseAddress()); | |
| 332 | + //主讲 | |
| 333 | + result.put("courseSpeaker",model.getCourseSpeaker() == null ? "" : model.getCourseSpeaker()); | |
| 334 | + | |
| 335 | + String hospitalName = ""; | |
| 336 | + if (org.apache.commons.lang.StringUtils.isNotEmpty(model.getHospitalId())) { | |
| 337 | + Organization organization = organizationService.getOrganization(Integer.parseInt(model.getHospitalId())); | |
| 338 | + if (organization != null && organization.getYn() == YnEnums.YES.getId()) { | |
| 339 | + hospitalName = organization.getName(); | |
| 340 | + } | |
| 341 | + } | |
| 342 | + | |
| 343 | + result.put("hospitalName",hospitalName); | |
| 344 | + //报名人数 | |
| 345 | + result.put("enrolmentNum", model.getEnrolmentNum() == null ? "0" : String.valueOf(model.getEnrolmentNum())); | |
| 346 | + | |
| 347 | + courseTypeQuery.setId(model.getCourseTypeId()); | |
| 348 | + | |
| 349 | + //课程类型名称 | |
| 350 | + String courseType = ""; | |
| 351 | + List<CourseTypeModel> typeModels = courseTypeService.queryCourseTypeList(courseTypeQuery); | |
| 352 | + if (CollectionUtils.isNotEmpty(typeModels)) | |
| 353 | + { | |
| 354 | + courseType = typeModels.get(0).getCourseTypeName(); | |
| 355 | + } | |
| 356 | + result.put("courseType",courseType); | |
| 357 | + | |
| 358 | + | |
| 359 | + //课程上限人数 | |
| 360 | + result.put("limitNum",model.getLimitNum() == null ? "0" : String.valueOf(model.getLimitNum())); | |
| 361 | + | |
| 362 | + //孕妇与课程的状态 | |
| 363 | + result.put("status",""); | |
| 364 | + | |
| 365 | + results.add(result); | |
| 366 | + } | |
| 367 | + } | |
| 368 | + | |
| 369 | + BaseListResponse objectResponse = new BaseListResponse(); | |
| 370 | + objectResponse.setData(results); | |
| 371 | + objectResponse.setPageInfo(query.getPageInfo()); | |
| 278 | 372 | objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); |
| 279 | 373 | objectResponse.setErrormsg("成功"); |
| 280 | 374 | return objectResponse; |