Commit 7d488592 authored by Ryan Loong's avatar Ryan Loong

fix 点名次数筛选失效的bug

parent 3783b0bc
...@@ -174,12 +174,17 @@ public class StudentInfoService { ...@@ -174,12 +174,17 @@ public class StudentInfoService {
} }
Map<Integer, Integer> callTimeMap = studentPointService.countByClassGroupByStudent(classId); Map<Integer, Integer> callTimeMap = studentPointService.countByClassGroupByStudent(classId);
if (Objects.nonNull(minCall) || Objects.nonNull(maxCall)) { if (Objects.nonNull(minCall)) {
List<Integer> excluded = callTimeMap.entrySet().stream() List<Integer> included = callTimeMap.entrySet().stream().filter(entry -> entry.getValue() >= minCall).map(Map.Entry::getKey).collect(Collectors.toList());
.filter(entry -> (Objects.nonNull(minCall) && entry.getValue() < minCall) if (CollectionUtils.isEmpty(included)) {
|| (Objects.nonNull(maxCall) && entry.getValue() > maxCall)) criteria.andIdEqualTo(-1);
.map(Map.Entry::getKey).collect(Collectors.toList()); } else {
criteria.andIdIn(included);
}
}
if (Objects.nonNull(maxCall)) {
List<Integer> excluded = callTimeMap.entrySet().stream().filter(entry -> entry.getValue() > maxCall).map(Map.Entry::getKey).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(excluded)) { if (!CollectionUtils.isEmpty(excluded)) {
criteria.andIdNotIn(excluded); criteria.andIdNotIn(excluded);
} }
......
...@@ -5,10 +5,12 @@ import cn.exploring.engine.server.db.dao.StudentPointInfoMapper; ...@@ -5,10 +5,12 @@ import cn.exploring.engine.server.db.dao.StudentPointInfoMapper;
import cn.exploring.engine.server.db.domain.StudentInfo; import cn.exploring.engine.server.db.domain.StudentInfo;
import cn.exploring.engine.server.db.domain.StudentPointInfo; import cn.exploring.engine.server.db.domain.StudentPointInfo;
import cn.exploring.engine.server.db.domain.StudentPointInfoExample; import cn.exploring.engine.server.db.domain.StudentPointInfoExample;
import cn.exploring.engine.server.db.domain.vo.StudentInfoExcelImportVo;
import cn.exploring.engine.server.db.domain.vo.StudentPointExcelExportVo; import cn.exploring.engine.server.db.domain.vo.StudentPointExcelExportVo;
import cn.exploring.engine.server.db.util.StrUtil;
import cn.exploring.engine.server.db.util.Util; import cn.exploring.engine.server.db.util.Util;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -16,7 +18,6 @@ import org.springframework.util.CollectionUtils; ...@@ -16,7 +18,6 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.print.attribute.IntegerSyntax;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -27,6 +28,8 @@ import java.util.stream.Collectors; ...@@ -27,6 +28,8 @@ import java.util.stream.Collectors;
@Service @Service
public class StudentPointService { public class StudentPointService {
public static final Log log = LogFactory.getLog(StudentPointService.class);
@Resource @Resource
StudentPointInfoMapper studentPointInfoMapper; StudentPointInfoMapper studentPointInfoMapper;
...@@ -117,13 +120,17 @@ public class StudentPointService { ...@@ -117,13 +120,17 @@ public class StudentPointService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void removeByStudentId(Integer studentId) { public void removeByStudentId(Integer studentId) {
studentPointInfoMapper.updateByExampleSelective(new StudentPointInfo(){{ StudentPointInfo record = new StudentPointInfo();
setUpdateTime(LocalDateTime.now()); record.setUpdateTime(LocalDateTime.now());
setDeleted(StudentPointInfo.IS_DELETED); record.setDeleted(true);
}}, new StudentPointInfoExample().createCriteria()
int i = studentPointInfoMapper.updateByExampleSelective(record,
new StudentPointInfoExample().createCriteria()
.andDeletedEqualTo(StudentPointInfo.NOT_DELETED) .andDeletedEqualTo(StudentPointInfo.NOT_DELETED)
.andStudentIdEqualTo(studentId) .andStudentIdEqualTo(studentId)
.example()); .example());
log.info(StrUtil.format("【成绩服务】已批量删除成绩 学生ID:'{}' 删除数量: '{}'", studentId, i));
} }
@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true) @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
......
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