|
@@ -1,5 +1,6 @@
|
|
|
package com.qmth.paper.library.business.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -10,9 +11,13 @@ import com.qmth.paper.library.business.mapper.PaperLibraryMapper;
|
|
|
import com.qmth.paper.library.business.service.PaperLibraryService;
|
|
|
import com.qmth.paper.library.business.service.PaperScanStatService;
|
|
|
import com.qmth.paper.library.common.contant.SystemConstant;
|
|
|
+import com.qmth.paper.library.common.entity.SysUser;
|
|
|
+import com.qmth.paper.library.common.service.SysUserService;
|
|
|
import com.qmth.paper.library.common.util.ServletUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
+import org.jetbrains.annotations.Nullable;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -30,15 +35,22 @@ public class PaperScanStatServiceImpl extends ServiceImpl<PaperLibraryMapper, Pa
|
|
|
@Resource
|
|
|
private PaperLibraryService paperLibraryService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private SysUserService sysUserService;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<ScanStatResult> pageScanStat(Long scanDate, String scanner, Integer pageNumber, Integer pageSize) {
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
+ //日期转换
|
|
|
String scanDateStr = null;
|
|
|
if(scanDate != null && scanDate > 0) {
|
|
|
scanDateStr = DateFormatUtils.format(scanDate, SystemConstant.SHORT_DATE_PATTERN);
|
|
|
}
|
|
|
|
|
|
- IPage<ScanStatResult> scanStatPage = baseMapper.listScanStat(new Page<>(pageNumber, pageSize), schoolId, scanDateStr, scanner);
|
|
|
+ //获取查询条件中的用户
|
|
|
+ Long userId = getUserId(scanner);
|
|
|
+
|
|
|
+ IPage<ScanStatResult> scanStatPage = baseMapper.listScanStat(new Page<>(pageNumber, pageSize), schoolId, scanDateStr, userId);
|
|
|
for (ScanStatResult scanStatResult : scanStatPage.getRecords()) {
|
|
|
//设置扫描学生数
|
|
|
int studentCount = paperLibraryService.countScanStudentByScannerAndDate(scanStatResult.getCreateId(), scanStatResult.getScanDateStr());
|
|
@@ -56,7 +68,10 @@ public class PaperScanStatServiceImpl extends ServiceImpl<PaperLibraryMapper, Pa
|
|
|
scanDateStr = DateFormatUtils.format(scanDate, SystemConstant.SHORT_DATE_PATTERN);
|
|
|
}
|
|
|
|
|
|
- List<ScanStatExportResult> scanStatList = baseMapper.listScanStatExport(schoolId, scanDateStr, scanner);
|
|
|
+ //获取查询条件中的用户
|
|
|
+ Long userId = getUserId(scanner);
|
|
|
+
|
|
|
+ List<ScanStatExportResult> scanStatList = baseMapper.listScanStatExport(schoolId, scanDateStr, userId);
|
|
|
for(ScanStatExportResult scanStatExportResult : scanStatList) {
|
|
|
//设置扫描学生数
|
|
|
int studentCount = paperLibraryService.countScanStudentByScannerAndDate(scanStatExportResult.getCreateId(), scanStatExportResult.getScanDateStr());
|
|
@@ -66,6 +81,21 @@ public class PaperScanStatServiceImpl extends ServiceImpl<PaperLibraryMapper, Pa
|
|
|
return scanStatList;
|
|
|
}
|
|
|
|
|
|
+ private @Nullable Long getUserId(String scanner) {
|
|
|
+ Long userId = null;
|
|
|
+ if (StringUtils.isNotEmpty(scanner)) {
|
|
|
+ LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SysUser::getLoginName, scanner.trim());
|
|
|
+ SysUser user = sysUserService.getOne(queryWrapper);
|
|
|
+ if (user != null) {
|
|
|
+ userId = user.getId();
|
|
|
+ } else {
|
|
|
+ userId = -1L;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return userId;
|
|
|
+ }
|
|
|
+
|
|
|
private Long getLongDate(String dateStr) {
|
|
|
Date date;
|
|
|
try {
|