Commit a5f1184445072f47d6ff569a9de9a71678b8ad0c
1 parent
0019f33ecb
Exists in
master
and in
6 other branches
孕妇学校统计
Showing 5 changed files with 186 additions and 4 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CourseService.java
 - platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientCourseService.java
 - platform-dal/src/main/java/com/lyms/platform/query/PatientCourseQuery.java
 - platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CourseController.java
 - platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CourseFacade.java
 
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CourseService.java
View file @
a5f1184
| ... | ... | @@ -39,6 +39,12 @@ | 
| 39 | 39 | return courseDao.queryCourseList(query.addOrder(Sort.Direction.DESC, "modified")); | 
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | + | |
| 43 | + public int queryCourseCount(CourseQuery courseQuery) { | |
| 44 | + return courseDao.queryCourseListCount(courseQuery.convertToQuery()); | |
| 45 | + } | |
| 46 | + | |
| 47 | + | |
| 42 | 48 | public void addCourse(CourseModel model) { | 
| 43 | 49 | courseDao.addCourse(model); | 
| 44 | 50 | } | 
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientCourseService.java
View file @
a5f1184
| ... | ... | @@ -29,6 +29,11 @@ | 
| 29 | 29 | return patientCourseDao.queryPatientCourseList(query.addOrder(Sort.Direction.DESC, "modified")); | 
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | + public int queryPatientCourseCount(PatientCourseQuery patientCourseQuery) | |
| 33 | + { | |
| 34 | + return patientCourseDao.queryPatientCourseListCount(patientCourseQuery.convertToQuery()); | |
| 35 | + } | |
| 36 | + | |
| 32 | 37 | public List<PatientCourseModel> queryPatientCourseList(PatientCourseQuery patientCourseQuery,String sort) | 
| 33 | 38 | { | 
| 34 | 39 | MongoQuery query = patientCourseQuery.convertToQuery(); | 
platform-dal/src/main/java/com/lyms/platform/query/PatientCourseQuery.java
View file @
a5f1184
| ... | ... | @@ -66,6 +66,10 @@ | 
| 66 | 66 | |
| 67 | 67 | private String queryNo; | 
| 68 | 68 | |
| 69 | + private Date createdStart; | |
| 70 | + private Date createdEnd; | |
| 71 | + | |
| 72 | + | |
| 69 | 73 | @Override | 
| 70 | 74 | public MongoQuery convertToQuery() { | 
| 71 | 75 | MongoCondition condition = MongoCondition.newInstance(); | 
| 72 | 76 | |
| ... | ... | @@ -134,12 +138,45 @@ | 
| 134 | 138 | } | 
| 135 | 139 | |
| 136 | 140 | |
| 141 | +// if (null != createdStart) { | |
| 142 | +// if (null != c1) { | |
| 143 | +// c1 = c1.and("created").gte(createdStart); | |
| 144 | +// } else { | |
| 145 | +// c1 = Criteria.where("created").gte(createdStart); | |
| 146 | +// } | |
| 147 | +// } | |
| 148 | +// | |
| 149 | +// if (null != createdEnd) { | |
| 150 | +// if (null != c1) { | |
| 151 | +// c1 = c1.lte(createdEnd); | |
| 152 | +// } else { | |
| 153 | +// c1 = Criteria.where("created").lte(createdEnd); | |
| 154 | +// } | |
| 155 | +// } | |
| 156 | + | |
| 157 | + | |
| 137 | 158 | if (null != c1) { | 
| 138 | 159 | condition = condition.andCondition(new MongoCondition(c1)); | 
| 139 | 160 | |
| 140 | 161 | } | 
| 141 | 162 | |
| 142 | 163 | return condition.toMongoQuery(); | 
| 164 | + } | |
| 165 | + | |
| 166 | + public Date getCreatedStart() { | |
| 167 | + return createdStart; | |
| 168 | + } | |
| 169 | + | |
| 170 | + public void setCreatedStart(Date createdStart) { | |
| 171 | + this.createdStart = createdStart; | |
| 172 | + } | |
| 173 | + | |
| 174 | + public Date getCreatedEnd() { | |
| 175 | + return createdEnd; | |
| 176 | + } | |
| 177 | + | |
| 178 | + public void setCreatedEnd(Date createdEnd) { | |
| 179 | + this.createdEnd = createdEnd; | |
| 143 | 180 | } | 
| 144 | 181 | |
| 145 | 182 | public List<String> getPatientIds() { | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CourseController.java
View file @
a5f1184
| ... | ... | @@ -3,6 +3,7 @@ | 
| 3 | 3 | |
| 4 | 4 | import com.lyms.platform.common.annotation.TokenRequired; | 
| 5 | 5 | import com.lyms.platform.common.base.BaseController; | 
| 6 | +import com.lyms.platform.common.base.LoginContext; | |
| 6 | 7 | import com.lyms.platform.common.result.BaseResponse; | 
| 7 | 8 | import com.lyms.platform.operate.web.facade.CourseFacade; | 
| 8 | 9 | import com.lyms.platform.operate.web.request.CourseRequest; | 
| ... | ... | @@ -157,7 +158,22 @@ | 
| 157 | 158 | @TokenRequired | 
| 158 | 159 | public BaseResponse validateCourseName(HttpServletRequest request, @RequestParam(required = true) String courseName | 
| 159 | 160 | , @RequestParam(required = false) String courseId) { | 
| 160 | - return courseFacade.validateCourseName(courseName,getUserId(request),courseId); | |
| 161 | + return courseFacade.validateCourseName(courseName, getUserId(request), courseId); | |
| 162 | + } | |
| 163 | + | |
| 164 | + | |
| 165 | + /** | |
| 166 | + * 孕妇课程统计 | |
| 167 | + * @param request | |
| 168 | + * @param time | |
| 169 | + * @return | |
| 170 | + */ | |
| 171 | + @RequestMapping(method = RequestMethod.GET, value = "/getCourseCount") | |
| 172 | + @ResponseBody | |
| 173 | + @TokenRequired | |
| 174 | + public BaseResponse getCourseCount(HttpServletRequest request, @RequestParam(required = true) String time) { | |
| 175 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 176 | + return courseFacade.getCourseCount(time,loginState.getId()); | |
| 161 | 177 | } | 
| 162 | 178 | } | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CourseFacade.java
View file @
a5f1184
| ... | ... | @@ -14,6 +14,7 @@ | 
| 14 | 14 | import com.lyms.platform.common.utils.DateUtil; | 
| 15 | 15 | import com.lyms.platform.operate.web.request.CourseRequest; | 
| 16 | 16 | import com.lyms.platform.operate.web.result.CourseResult; | 
| 17 | +import com.lyms.platform.operate.web.result.CourseTypeResult; | |
| 17 | 18 | import com.lyms.platform.permission.model.Users; | 
| 18 | 19 | import com.lyms.platform.permission.service.UsersService; | 
| 19 | 20 | import com.lyms.platform.pojo.CourseModel; | 
| ... | ... | @@ -27,9 +28,8 @@ | 
| 27 | 28 | import org.springframework.beans.factory.annotation.Autowired; | 
| 28 | 29 | import org.springframework.stereotype.Component; | 
| 29 | 30 | |
| 30 | -import java.util.ArrayList; | |
| 31 | -import java.util.Date; | |
| 32 | -import java.util.List; | |
| 31 | +import java.text.DecimalFormat; | |
| 32 | +import java.util.*; | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | /** | 
| ... | ... | @@ -344,6 +344,124 @@ | 
| 344 | 344 | } | 
| 345 | 345 | |
| 346 | 346 | } | 
| 347 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 348 | + objectResponse.setErrormsg("成功"); | |
| 349 | + return objectResponse; | |
| 350 | + } | |
| 351 | + | |
| 352 | + /** | |
| 353 | + * 孕妇课程统计 | |
| 354 | + * @param time | |
| 355 | + * @param userId | |
| 356 | + * @return | |
| 357 | + */ | |
| 358 | + public BaseResponse getCourseCount(String time, Integer userId) { | |
| 359 | + BaseObjectResponse objectResponse = new BaseObjectResponse(); | |
| 360 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 361 | + Map resultData = new HashMap(); | |
| 362 | + | |
| 363 | + Map totalData = new HashMap(); | |
| 364 | + | |
| 365 | + CourseQuery query = new CourseQuery(); | |
| 366 | + query.setYn(YnEnums.YES.getId()); | |
| 367 | + query.setHospitalId(hospitalId); | |
| 368 | + | |
| 369 | + int allCourses = courseService.queryCourseCount(query); | |
| 370 | + int allSends = 0; //TODO | |
| 371 | + | |
| 372 | + | |
| 373 | + PatientCourseQuery patientCourseQuery = new PatientCourseQuery(); | |
| 374 | + patientCourseQuery.setYn(YnEnums.YES.getId()); | |
| 375 | + patientCourseQuery.setHospitalId(hospitalId); | |
| 376 | + //状态 1预约,2签到 | |
| 377 | + patientCourseQuery.setStatus(1); | |
| 378 | + | |
| 379 | + int allOrders = patientCourseService.queryPatientCourseCount(patientCourseQuery); | |
| 380 | + | |
| 381 | + patientCourseQuery.setStatus(2); | |
| 382 | + | |
| 383 | + | |
| 384 | + int allSigns = patientCourseService.queryPatientCourseCount(patientCourseQuery); | |
| 385 | + | |
| 386 | + DecimalFormat df = new DecimalFormat("0.00"); | |
| 387 | + | |
| 388 | + resultData.put("allCourses",allCourses); //课程数 | |
| 389 | + resultData.put("allSends",allSends); //总推送数 | |
| 390 | + resultData.put("allOrders",allOrders); //总预约数 | |
| 391 | + resultData.put("allOrderRate",allCourses == 0 ? 0 : df.format((double) allOrders / allCourses * 100) + "%"); //总预约率 | |
| 392 | + resultData.put("allSigns",allSigns);//总签到数 | |
| 393 | + resultData.put("allSignRate",allCourses == 0 ? 0 : df.format((double) allSigns / allCourses * 100) + "%");//总签到率 | |
| 394 | + | |
| 395 | + | |
| 396 | + if (StringUtils.isNotEmpty(time)) { | |
| 397 | + String[] dates = time.split(" - "); | |
| 398 | + query.setCreatedStart(DateUtil.parseYMD(dates[0])); | |
| 399 | + if (dates.length == 2) { | |
| 400 | + query.setCreatedEnd(DateUtil.parseYMDHMS(dates[1] + " 23:59:59")); | |
| 401 | + } | |
| 402 | + } | |
| 403 | + | |
| 404 | + allCourses = courseService.queryCourseCount(query); | |
| 405 | + | |
| 406 | + | |
| 407 | + CourseTypeQuery courseTypeQuery = new CourseTypeQuery(); | |
| 408 | + courseTypeQuery.setHospitalId(hospitalId); | |
| 409 | + courseTypeQuery.setYn(YnEnums.YES.getId()); | |
| 410 | + | |
| 411 | + List<Map> tableData = new ArrayList<>(); | |
| 412 | + | |
| 413 | + Map chartData = new HashMap(); | |
| 414 | + List<CourseModel> courseModelList = courseService.queryCourseList(query); | |
| 415 | + if (CollectionUtils.isNotEmpty(courseModelList)) | |
| 416 | + { | |
| 417 | + List titles = new ArrayList(); | |
| 418 | + List sends = new ArrayList(); | |
| 419 | + List orders = new ArrayList(); | |
| 420 | + List signs = new ArrayList(); | |
| 421 | + for (CourseModel courseModel : courseModelList) | |
| 422 | + { | |
| 423 | + patientCourseQuery.setCourseId(courseModel.getId()); | |
| 424 | + titles.add(courseModel.getCourseName()); | |
| 425 | + | |
| 426 | + patientCourseQuery.setStatus(1); | |
| 427 | + int courseOrders = patientCourseService.queryPatientCourseCount(patientCourseQuery); | |
| 428 | + orders.add(courseOrders); | |
| 429 | + | |
| 430 | + patientCourseQuery.setStatus(2); | |
| 431 | + int courseSigns = patientCourseService.queryPatientCourseCount(patientCourseQuery); | |
| 432 | + signs.add(courseSigns); | |
| 433 | + | |
| 434 | + int courseSends = 0; //TODO | |
| 435 | + sends.add(courseSends); | |
| 436 | + | |
| 437 | + courseTypeQuery.setId(courseModel.getCourseTypeId()); | |
| 438 | + List<CourseTypeModel> typeModels = courseTypeService.queryCourseTypeList(courseTypeQuery); | |
| 439 | + | |
| 440 | + Map tableMap = new HashMap(); | |
| 441 | + | |
| 442 | + tableMap.put("courseTypeId",CollectionUtils.isNotEmpty(typeModels) ? typeModels.get(0).getId() : ""); | |
| 443 | + tableMap.put("courseTypeName",CollectionUtils.isNotEmpty(typeModels) ? typeModels.get(0).getCourseTypeName() : ""); | |
| 444 | + tableMap.put("courseName",courseModel.getCourseName()); | |
| 445 | + | |
| 446 | + tableMap.put("sends",0);//TODO | |
| 447 | + tableMap.put("orders",courseOrders); | |
| 448 | + tableMap.put("ordersRate",allCourses == 0 ? "0" : df.format((double) courseOrders / allCourses * 100) + "%"); | |
| 449 | + tableMap.put("signs",courseSigns); | |
| 450 | + tableMap.put("signsRate",allCourses == 0 ? "0" : df.format((double) courseSigns / allCourses * 100) + "%"); | |
| 451 | + tableData.add(tableMap); | |
| 452 | + } | |
| 453 | + | |
| 454 | + chartData.put("titles",titles); | |
| 455 | + chartData.put("sends",sends); | |
| 456 | + chartData.put("orders",orders); | |
| 457 | + chartData.put("signs",signs); | |
| 458 | + } | |
| 459 | + | |
| 460 | + resultData.put("totalData",totalData); | |
| 461 | + resultData.put("chartData",chartData); | |
| 462 | + resultData.put("tableData",tableData); | |
| 463 | + | |
| 464 | + objectResponse.setData(resultData); | |
| 347 | 465 | objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | 
| 348 | 466 | objectResponse.setErrormsg("成功"); | 
| 349 | 467 | return objectResponse; |