From f489d0352977acc107f93eee7cbb9672b7e8df4a Mon Sep 17 00:00:00 2001 From: liquanyu Date: Mon, 12 Feb 2018 14:11:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=95=E5=A6=87=E5=AD=A6=E6=A0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lyms/platform/query/CourseQuery.java | 25 +++++ .../web/controller/PatientCourseController.java | 14 ++- .../operate/web/facade/PatientCourseFacade.java | 102 ++++++++++++++++++++- 3 files changed, 132 insertions(+), 9 deletions(-) diff --git a/platform-dal/src/main/java/com/lyms/platform/query/CourseQuery.java b/platform-dal/src/main/java/com/lyms/platform/query/CourseQuery.java index a901651..5954ef2 100644 --- a/platform-dal/src/main/java/com/lyms/platform/query/CourseQuery.java +++ b/platform-dal/src/main/java/com/lyms/platform/query/CourseQuery.java @@ -70,9 +70,12 @@ public class CourseQuery extends BaseQuery implements IConvertToNativeQuery { private Integer yn; private String hospitalId; + private List hospitalIds; private Date courseEndTime; + private String keyword; + @Override public MongoQuery convertToQuery() { MongoCondition condition = MongoCondition.newInstance(); @@ -112,6 +115,10 @@ public class CourseQuery extends BaseQuery implements IConvertToNativeQuery { condition = condition.and("status", status, MongoOper.IS); } + if (null != hospitalIds && hospitalIds.size() > 0) { + condition = condition.and("hospitalId", hospitalIds, MongoOper.IN); + } + Criteria c1 = null; if (null != courseTimeStart) { @@ -159,6 +166,24 @@ public class CourseQuery extends BaseQuery implements IConvertToNativeQuery { return condition.toMongoQuery(); } + @Override + public String getKeyword() { + return keyword; + } + + @Override + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + public List getHospitalIds() { + return hospitalIds; + } + + public void setHospitalIds(List hospitalIds) { + this.hospitalIds = hospitalIds; + } + public Date getCourseEndTime() { return courseEndTime; } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientCourseController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientCourseController.java index 9b7d05c..0996d29 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientCourseController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientCourseController.java @@ -135,18 +135,22 @@ public class PatientCourseController extends BaseController { /** * 获取小程序的孕妇学校列表 - * @param patientCourseId - * @param courseId + * @param hospitalIds 相关医院id + * @param patientId 患者id * @param request * @return */ @RequestMapping(method = RequestMethod.GET, value = "/getAppPatientCourseList") @ResponseBody public BaseResponse getAppPatientCourseList( - @RequestParam(required = true) String patientCourseId, - @RequestParam(required = true) String courseId, + @RequestParam(required = true) String hospitalIds, + @RequestParam(required = true) String patientId, + @RequestParam(required = false) String keyword, + @RequestParam(required = true) Integer status, + @RequestParam("page") Integer page, + @RequestParam("limit") Integer limit, HttpServletRequest request) { - return patientCourseFacade.signCourse(patientCourseId,courseId,getUserId(request)); + return patientCourseFacade.getAppPatientCourseList(status,hospitalIds, patientId,keyword,page,limit); } } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseFacade.java index 65d1a0f..4d9b21d 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseFacade.java @@ -11,12 +11,17 @@ import com.lyms.platform.common.result.BaseListResponse; import com.lyms.platform.common.result.BaseObjectResponse; import com.lyms.platform.common.result.BaseResponse; import com.lyms.platform.common.utils.DateUtil; +import com.lyms.platform.operate.web.result.CourseTypeResult; import com.lyms.platform.operate.web.result.PatientCourseResult; +import com.lyms.platform.permission.model.Organization; +import com.lyms.platform.permission.service.OrganizationService; import com.lyms.platform.permission.service.UsersService; import com.lyms.platform.pojo.CourseModel; +import com.lyms.platform.pojo.CourseTypeModel; import com.lyms.platform.pojo.PatientCourseModel; import com.lyms.platform.pojo.Patients; import com.lyms.platform.query.CourseQuery; +import com.lyms.platform.query.CourseTypeQuery; import com.lyms.platform.query.PatientCourseQuery; import com.lyms.platform.query.PatientsQuery; import org.apache.commons.collections.CollectionUtils; @@ -24,9 +29,7 @@ import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; /** @@ -54,6 +57,9 @@ public class PatientCourseFacade { @Autowired private CourseService courseService; + @Autowired + private OrganizationService organizationService; + public BaseResponse getPatientCourseList(Integer status,String courseId, Integer page, Integer limit, Integer userId) { @@ -176,6 +182,13 @@ public class PatientCourseFacade { objectResponse.setErrormsg("该课程预约时间已截止,请刷新后重试"); return objectResponse; } + + if (model != null && model.getLimitNum() != null && model.getLimitNum() < (model.getEnrolmentNum() == null? 1 : model.getEnrolmentNum()+1)) + { + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE); + objectResponse.setErrormsg("该课程预约人数已达上限,不能预约该课程了!"); + return objectResponse; + } } Patients patients = patientsService.findOnePatientById(patientId); @@ -265,7 +278,7 @@ public class PatientCourseFacade { } } - if (patientCourseId == null) + if (patientCourseId != null) { PatientCourseModel model = new PatientCourseModel(); model.setId(patientCourseId); @@ -279,4 +292,85 @@ public class PatientCourseFacade { objectResponse.setErrormsg("成功"); return objectResponse; } + + public BaseResponse getAppPatientCourseList(Integer status,String hospitalIds, String patientId, + String keyword, Integer page, Integer limit) { + + List hospitalIdList = new ArrayList<>(); + + if (StringUtils.isNotEmpty(hospitalIds)) + { + hospitalIdList = Arrays.asList(hospitalIds.split(",")); + } + + CourseQuery query = new CourseQuery(); + query.setStatus(status); + query.setYn(YnEnums.YES.getId()); + query.setPage(page); + query.setLimit(limit); + query.setNeed("true"); + query.setHospitalIds(hospitalIdList); + List courseModels = courseService.queryCourseList(query); + + List results = new ArrayList<>(); + CourseTypeQuery courseTypeQuery = new CourseTypeQuery(); + query.setYn(YnEnums.YES.getId()); + + if (CollectionUtils.isNotEmpty(courseModels)) + { + for (CourseModel model : courseModels) + { + Map result = new HashMap<>(); + //课程名称 + result.put("courseName",model.getCourseName()); + //课程描述 + result.put("courseDesc",model.getCourseDesc() == null ? "" : model.getCourseDesc()); + //课程时间 + result.put("courseTime",DateUtil.gety_m_dhm(model.getCourseTime())); + //课程地址 + result.put("courseAddress", model.getCourseAddress() == null ? "" : model.getCourseAddress()); + //主讲 + result.put("courseSpeaker",model.getCourseSpeaker() == null ? "" : model.getCourseSpeaker()); + + String hospitalName = ""; + if (org.apache.commons.lang.StringUtils.isNotEmpty(model.getHospitalId())) { + Organization organization = organizationService.getOrganization(Integer.parseInt(model.getHospitalId())); + if (organization != null && organization.getYn() == YnEnums.YES.getId()) { + hospitalName = organization.getName(); + } + } + + result.put("hospitalName",hospitalName); + //报名人数 + result.put("enrolmentNum", model.getEnrolmentNum() == null ? "0" : String.valueOf(model.getEnrolmentNum())); + + courseTypeQuery.setId(model.getCourseTypeId()); + + //课程类型名称 + String courseType = ""; + List typeModels = courseTypeService.queryCourseTypeList(courseTypeQuery); + if (CollectionUtils.isNotEmpty(typeModels)) + { + courseType = typeModels.get(0).getCourseTypeName(); + } + result.put("courseType",courseType); + + + //课程上限人数 + result.put("limitNum",model.getLimitNum() == null ? "0" : String.valueOf(model.getLimitNum())); + + //孕妇与课程的状态 + result.put("status",""); + + results.add(result); + } + } + + BaseListResponse objectResponse = new BaseListResponse(); + objectResponse.setData(results); + objectResponse.setPageInfo(query.getPageInfo()); + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + return objectResponse; + } } \ No newline at end of file -- 1.8.3.1