Commit 9448718c authored by Ryan Loong's avatar Ryan Loong

update 分数统计增加最大和最小分的限制

parent 68f03ce7
...@@ -11,10 +11,7 @@ import cn.exploring.engine.server.db.util.SqlUtil; ...@@ -11,10 +11,7 @@ import cn.exploring.engine.server.db.util.SqlUtil;
import cn.exploring.engine.server.db.util.StrUtil; import cn.exploring.engine.server.db.util.StrUtil;
import cn.zhxu.bs.BeanSearcher; import cn.zhxu.bs.BeanSearcher;
import cn.zhxu.bs.SearchResult; import cn.zhxu.bs.SearchResult;
import cn.zhxu.bs.operator.Contain; import cn.zhxu.bs.operator.*;
import cn.zhxu.bs.operator.Equal;
import cn.zhxu.bs.operator.GreaterEqual;
import cn.zhxu.bs.operator.LessEqual;
import cn.zhxu.bs.util.MapBuilder; import cn.zhxu.bs.util.MapBuilder;
import cn.zhxu.bs.util.MapUtils; import cn.zhxu.bs.util.MapUtils;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
...@@ -54,20 +51,20 @@ public class StudentPointService { ...@@ -54,20 +51,20 @@ public class StudentPointService {
@Autowired @Autowired
BeanSearcher beanSearcher; BeanSearcher beanSearcher;
public Map<String, Object> selectPointByWeb( String studentName, String studentUniqueId, Integer classId, String startTime, String endTime, Integer page, Integer limit, String sort, String order) { public Map<String, Object> selectPointByWeb( String studentName, String studentUniqueId, Integer classId, String startTime, String endTime, Integer page, Integer limit, String sort, String order, Integer min, Integer max) {
SearchResult<StudentPointWithStudentInfoVo> result = beanSearcher.search(StudentPointWithStudentInfoVo.class, SqlUtil.page(voWrapper(studentName, studentUniqueId, classId, startTime, endTime), page, limit, sort, order).build()); SearchResult<StudentPointWithStudentInfoVo> result = beanSearcher.search(StudentPointWithStudentInfoVo.class, SqlUtil.page(voWrapper(studentName, studentUniqueId, classId, startTime, endTime, min, max), page, limit, sort, order).build());
return ImmutableMap.of("total", result.getTotalCount().longValue(), "items", result.getDataList()); return ImmutableMap.of("total", result.getTotalCount().longValue(), "items", result.getDataList());
} }
public File exportList(String studentName, String studentUniqueId, Integer classId, String startTime, String endTime) { public File exportList(String studentName, String studentUniqueId, Integer classId, String startTime, String endTime, String sort, String order, Integer min, Integer max) {
List<StudentPointExcelExportVo> list = beanSearcher.searchAll(StudentPointWithStudentInfoVo.class, voWrapper(studentName, studentUniqueId, classId, startTime, endTime).build()) List<StudentPointExcelExportVo> list = beanSearcher.searchAll(StudentPointWithStudentInfoVo.class, SqlUtil.page(voWrapper(studentName, studentUniqueId, classId, startTime, endTime, min, max), null, null, sort, order).build())
.stream().map(StudentPointExcelExportVo::new).collect(Collectors.toList()); .stream().map(StudentPointExcelExportVo::new).collect(Collectors.toList());
return transToExcelFile(list); return transToExcelFile(list);
} }
public MapBuilder voWrapper(String studentName, String studentUniqueId, Integer classId, String startTime, String endTime) { public MapBuilder voWrapper(String studentName, String studentUniqueId, Integer classId, String startTime, String endTime, Integer min, Integer max) {
LocalDateTime start = Optional.ofNullable(startTime).filter(StringUtils::isNotBlank).map(s -> LocalDateTime.parse(s, DateTimeUtil.DATE_TIME_FORMATTER3)).orElse(null); LocalDateTime start = Optional.ofNullable(startTime).filter(StringUtils::isNotBlank).map(s -> LocalDateTime.parse(s, DateTimeUtil.DATE_TIME_FORMATTER3)).orElse(null);
LocalDateTime end = Optional.ofNullable(endTime).filter(StringUtils::isNotBlank).map(s -> LocalDateTime.parse(s, DateTimeUtil.DATE_TIME_FORMATTER3)).orElse(null); LocalDateTime end = Optional.ofNullable(endTime).filter(StringUtils::isNotBlank).map(s -> LocalDateTime.parse(s, DateTimeUtil.DATE_TIME_FORMATTER3)).orElse(null);
...@@ -77,7 +74,8 @@ public class StudentPointService { ...@@ -77,7 +74,8 @@ public class StudentPointService {
.field(StudentPointWithStudentInfoVo::getStudentUniqueId, studentUniqueId).op(Contain.class) .field(StudentPointWithStudentInfoVo::getStudentUniqueId, studentUniqueId).op(Contain.class)
.field(StudentPointWithStudentInfoVo::getClassId, classId).op(Equal.class) .field(StudentPointWithStudentInfoVo::getClassId, classId).op(Equal.class)
.field(StudentPointWithStudentInfoVo::getRecordTime, start).op(GreaterEqual.class) .field(StudentPointWithStudentInfoVo::getRecordTime, start).op(GreaterEqual.class)
.field(StudentPointWithStudentInfoVo::getRecordTime, end).op(LessEqual.class); .field(StudentPointWithStudentInfoVo::getRecordTime, end).op(LessEqual.class)
.field(StudentPointWithStudentInfoVo::getPoint, min, max).op(Between.class);
} }
/** /**
......
...@@ -36,23 +36,25 @@ public class PointController { ...@@ -36,23 +36,25 @@ public class PointController {
@GetMapping("selectPoint") @GetMapping("selectPoint")
public Object selectPoint(@RequestParam String studentName, @RequestParam String studentUniqueId, @RequestParam Integer classId, @RequestParam String startTime, @RequestParam String endTime, public Object selectPoint(@RequestParam String studentName, @RequestParam String studentUniqueId, @RequestParam Integer classId, @RequestParam String startTime, @RequestParam String endTime,
@RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer limit, @RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer limit,
@RequestParam(required = false, defaultValue = "addTime") String sort, @RequestParam(required = false, defaultValue = "desc") String order) { @RequestParam(required = false, defaultValue = "addTime") String sort, @RequestParam(required = false, defaultValue = "desc") String order,
@RequestParam Integer min, @RequestParam Integer max) {
studentUniqueId = StringUtils.isEmpty(studentUniqueId) ? null : studentUniqueId; studentUniqueId = StringUtils.isEmpty(studentUniqueId) ? null : studentUniqueId;
studentName = StringUtils.isEmpty(studentName) ? null : studentName; studentName = StringUtils.isEmpty(studentName) ? null : studentName;
startTime = StringUtils.isEmpty(startTime) ? null : startTime; startTime = StringUtils.isEmpty(startTime) ? null : startTime;
endTime = StringUtils.isEmpty(endTime) ? null : endTime; endTime = StringUtils.isEmpty(endTime) ? null : endTime;
return ResponseUtil.ok(pointService.selectPointByWeb(studentName, studentUniqueId, classId, startTime, endTime, page, limit, sort, order)); return ResponseUtil.ok(pointService.selectPointByWeb(studentName, studentUniqueId, classId, startTime, endTime, page, limit, sort, order, min, max));
} }
@GetMapping("export") @GetMapping("export")
public Object export(@RequestParam String studentName, @RequestParam String studentUniqueId, @RequestParam Integer classId, @RequestParam String startTime, @RequestParam String endTime, public Object export(@RequestParam String studentName, @RequestParam String studentUniqueId, @RequestParam Integer classId, @RequestParam String startTime, @RequestParam String endTime,
@RequestParam(required = false, defaultValue = "addTime") String sort, @RequestParam(required = false, defaultValue = "desc") String order) { @RequestParam(required = false, defaultValue = "addTime") String sort, @RequestParam(required = false, defaultValue = "desc") String order,
@RequestParam Integer min, @RequestParam Integer max) {
studentUniqueId = StringUtils.isEmpty(studentUniqueId) ? null : studentUniqueId; studentUniqueId = StringUtils.isEmpty(studentUniqueId) ? null : studentUniqueId;
studentName = StringUtils.isEmpty(studentName) ? null : studentName; studentName = StringUtils.isEmpty(studentName) ? null : studentName;
startTime = StringUtils.isEmpty(startTime) ? null : startTime; startTime = StringUtils.isEmpty(startTime) ? null : startTime;
endTime = StringUtils.isEmpty(endTime) ? null : endTime; endTime = StringUtils.isEmpty(endTime) ? null : endTime;
File file = pointService.exportList(studentName, studentUniqueId, classId, startTime, endTime); File file = pointService.exportList(studentName, studentUniqueId, classId, startTime, endTime, sort, order, min, max);
FileInputStream in = null; FileInputStream in = null;
try { try {
in = new FileInputStream(file); in = new FileInputStream(file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment