Sfoglia il codice sorgente

扫描统计管理

haogh 11 mesi fa
parent
commit
f3cb348c94

+ 79 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/bean/result/ScanStatResult.java

@@ -0,0 +1,79 @@
+package com.qmth.paper.library.business.bean.result;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description 扫描统计返回结果
+ */
+public class ScanStatResult implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "扫描员")
+    private String scanner;
+
+    @ApiModelProperty(value = "扫描图片(张)")
+    private int pictureCount;
+
+    @ApiModelProperty(value = "扫描学生数")
+    private int studentCount;
+
+    @ApiModelProperty(value = "扫描日期")
+    private Long scanDate;
+
+    @ApiModelProperty(value = "扫描日期字符串")
+    private String scanDateStr;
+
+    @ApiModelProperty(value = "扫描员ID")
+    private Long createId;
+
+    public String getScanner() {
+        return scanner;
+    }
+
+    public void setScanner(String scanner) {
+        this.scanner = scanner;
+    }
+
+    public int getPictureCount() {
+        return pictureCount;
+    }
+
+    public void setPictureCount(int pictureCount) {
+        this.pictureCount = pictureCount;
+    }
+
+    public int getStudentCount() {
+        return studentCount;
+    }
+
+    public void setStudentCount(int studentCount) {
+        this.studentCount = studentCount;
+    }
+
+    public Long getScanDate() {
+        return scanDate;
+    }
+
+    public void setScanDate(Long scanDate) {
+        this.scanDate = scanDate;
+    }
+
+    public String getScanDateStr() {
+        return scanDateStr;
+    }
+
+    public void setScanDateStr(String scanDateStr) {
+        this.scanDateStr = scanDateStr;
+    }
+
+    public Long getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(Long createId) {
+        this.createId = createId;
+    }
+}

+ 5 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/mapper/PaperLibraryMapper.java

@@ -3,6 +3,7 @@ package com.qmth.paper.library.business.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.paper.library.business.bean.result.ScanStatResult;
 import com.qmth.paper.library.business.bean.result.TaskStudentResult;
 import com.qmth.paper.library.business.entity.PaperLibrary;
 import org.apache.ibatis.annotations.MapKey;
@@ -24,4 +25,8 @@ public interface PaperLibraryMapper extends BaseMapper<PaperLibrary> {
 
     @MapKey(value = "studentId")
     List<Map> listMaxSequenceByPaperScanTaskId(@Param("paperScanTaskId") Long paperScanTaskId);
+
+    IPage<ScanStatResult> listScanStat(@Param("page") Page<ScanStatResult> page, @Param("schoolId") Long schoolId, @Param("scanDate") String scanDate, @Param("scanner") String scanner);
+
+    int countScanStudentByScannerAndDate(@Param("createId") Long createId, @Param("scanDate") String scanDate);
 }

+ 2 - 1
paper-library-business/src/main/java/com/qmth/paper/library/business/service/PaperLibraryService.java

@@ -3,7 +3,6 @@ package com.qmth.paper.library.business.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.paper.library.business.bean.result.PaperLibraryResult;
-import com.qmth.paper.library.business.bean.result.PaperScanTaskResult;
 import com.qmth.paper.library.business.bean.result.TaskStudentResult;
 import com.qmth.paper.library.business.bean.vo.RecognitionResultVo;
 import com.qmth.paper.library.business.entity.PaperLibrary;
@@ -39,4 +38,6 @@ public interface PaperLibraryService extends IService<PaperLibrary> {
     int countByStudentId(Long studentId);
 
     int countByPaperScanTaskId(Long paperScanTaskId);
+
+    int countScanStudentByScannerAndDate(Long createId, String scanDate);
 }

+ 14 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/service/PaperScanStatService.java

@@ -0,0 +1,14 @@
+package com.qmth.paper.library.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.paper.library.business.bean.result.ScanStatResult;
+import com.qmth.paper.library.business.entity.PaperLibrary;
+
+/**
+ * @Description 扫描统计
+ */
+public interface PaperScanStatService extends IService<PaperLibrary> {
+
+    IPage<ScanStatResult> pageScanStat(Long scanDate, String scanner, Integer pageNumber, Integer pageSize);
+}

+ 9 - 2
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperLibraryServiceImpl.java

@@ -25,13 +25,15 @@ import com.qmth.paper.library.common.entity.BasicExam;
 import com.qmth.paper.library.common.entity.BasicSchool;
 import com.qmth.paper.library.common.entity.BasicSemester;
 import com.qmth.paper.library.common.entity.ExamStudent;
-import com.qmth.paper.library.common.enums.*;
+import com.qmth.paper.library.common.enums.ExceptionResultEnum;
+import com.qmth.paper.library.common.enums.RecognitionTypeEnum;
+import com.qmth.paper.library.common.enums.StoreTypeEnum;
+import com.qmth.paper.library.common.enums.UploadFileEnum;
 import com.qmth.paper.library.common.service.BasicSchoolService;
 import com.qmth.paper.library.common.service.BasicSemesterService;
 import com.qmth.paper.library.common.service.CommonCacheService;
 import com.qmth.paper.library.common.util.*;
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.json.JSONArray;
 import org.springframework.stereotype.Service;
@@ -356,4 +358,9 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
         return this.count(queryWrapper);
     }
 
+    @Override
+    public int countScanStudentByScannerAndDate(Long createId, String scanDate) {
+        return baseMapper.countScanStudentByScannerAndDate(createId, scanDate);
+    }
+
 }

+ 60 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperScanStatServiceImpl.java

@@ -0,0 +1,60 @@
+package com.qmth.paper.library.business.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.paper.library.business.bean.result.ScanStatResult;
+import com.qmth.paper.library.business.entity.PaperLibrary;
+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.util.ServletUtil;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+import java.util.Date;
+
+@Service
+public class PaperScanStatServiceImpl extends ServiceImpl<PaperLibraryMapper, PaperLibrary> implements PaperScanStatService {
+
+    private final Logger logger = LoggerFactory.getLogger(PaperScanStatServiceImpl.class);
+
+    @Resource
+    private PaperLibraryService paperLibraryService;
+
+    @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);
+        for (ScanStatResult scanStatResult : scanStatPage.getRecords()) {
+            //设置扫描学生数
+            int studentCount = paperLibraryService.countScanStudentByScannerAndDate(scanStatResult.getCreateId(), scanStatResult.getScanDateStr());
+            scanStatResult.setStudentCount(studentCount);
+            scanStatResult.setScanDate(getLongDate(scanStatResult.getScanDateStr()));
+        }
+        return scanStatPage;
+    }
+
+    private Long getLongDate(String dateStr) {
+        Date date;
+        try {
+            date = DateUtils.parseDate(dateStr+" 00:00:00", SystemConstant.DEFAULT_DATE_PATTERN);
+        } catch (ParseException e) {
+            logger.error(String.format("[扫描统计管理]日期转换失败,dateStr:%s", dateStr), e);
+            return null;
+        }
+        return date.getTime();
+    }
+
+}

+ 6 - 0
paper-library-business/src/main/resources/db/log/hgh_update_log.sql

@@ -27,3 +27,9 @@ INSERT INTO `sys_privilege`(`id`, `name`, `url`, `type`, `parent_id`, `sequence`
 INSERT INTO `sys_privilege`(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (564, '查询', '/api/admin/basic/filetype/page', 'URL', 560, 1, 'AUTH', NULL, 1, 1, 1);
 INSERT INTO `sys_privilege`(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (565, '新增', '/api/admin/basic/filetype/save', 'URL', 560, 2, 'AUTH', NULL, 1, 1, 1);
 INSERT INTO `sys_privilege`(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (566, '删除', '/api/admin/basic/filetype/delete', 'URL', 560, 3, 'AUTH', NULL, 1, 1, 1);
+
+INSERT INTO `sys_privilege`(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (570, '扫描统计管理', 'ScanStatManage', 'MENU', 8, 7, NULL, NULL, 1, 0, 1);
+INSERT INTO `sys_privilege`(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (571, '列表', 'List', 'LIST', 570, 1, 'AUTH', '573', 1, 0, 1);
+INSERT INTO `sys_privilege`(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (572, '导出', 'Add', 'BUTTON', 570, 1, 'AUTH', '574', 1, 0, 1);
+INSERT INTO `sys_privilege`(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (573, '查询', '/api/admin/basic/scan/stat/page', 'URL', 570, 1, 'AUTH', NULL, 1, 1, 1);
+INSERT INTO `sys_privilege`(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (574, '导出', '/api/admin/basic/scan/stat/export', 'URL', 570, 2, 'AUTH', NULL, 1, 1, 1);

+ 37 - 0
paper-library-business/src/main/resources/mapper/PaperLibraryMapper.xml

@@ -65,4 +65,41 @@
         where pl.paper_scan_task_id = #{paperScanTaskId}
         group by es.id, es.student_code
     </select>
+
+    <select id="listScanStat" resultType="com.qmth.paper.library.business.bean.result.ScanStatResult">
+        SELECT
+            u.login_name scanner,
+            p.create_id createId,
+            date_format( FROM_UNIXTIME( p.create_time / 1000 ), '%Y-%m-%d' ) scanDateStr,
+            count( 1 ) pictureCount
+        FROM
+            paper_library p,
+            paper_scan_task t,
+            sys_user u
+        WHERE
+          p.paper_scan_task_id = t.id
+          AND u.id = p.create_id
+          AND t.school_id = #{schoolId}
+        <if test="scanDate != null and scanDate != ''">
+            and  date_format( FROM_UNIXTIME( p.create_time / 1000 ), '%Y-%m-%d')=#{scanDate}
+        </if>
+        <if test="scanner != null and scanner != ''">
+            and  u.login_name=#{scanner}
+        </if>
+        GROUP BY
+        u.login_name,
+        p.create_id,
+        date_format( FROM_UNIXTIME( p.create_time / 1000 ), '%Y-%m-%d')
+        order by date_format( FROM_UNIXTIME( p.create_time / 1000 ), '%Y-%m-%d')
+    </select>
+
+    <select id="countScanStudentByScannerAndDate" resultType="java.lang.Integer">
+        SELECT
+            COUNT( DISTINCT pl.student_id )
+        FROM
+            paper_library pl
+        WHERE
+            pl.create_id = #{createId} and  date_format( FROM_UNIXTIME( pl.create_time / 1000 ), '%Y-%m-%d')=#{scanDate}
+    </select>
+
 </mapper>

+ 1 - 0
paper-library-common/src/main/java/com/qmth/paper/library/common/contant/SystemConstant.java

@@ -68,6 +68,7 @@ public class SystemConstant {
     public static final String TMP_DIR = "java.io.tmpdir";
 
     public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss";
+    public static final String SHORT_DATE_PATTERN = "yyyy-MM-dd";
     public static final int PAGE_SIZE_MIN = 10;
     public static final int PAGE_SIZE_MAX = 500;
     public static final int PAGE_NUMBER_MIN = 1;

+ 40 - 0
paper-library/src/main/java/com/qmth/paper/library/api/PaperScanStatController.java

@@ -0,0 +1,40 @@
+package com.qmth.paper.library.api;
+
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.paper.library.business.service.PaperScanStatService;
+import com.qmth.paper.library.common.contant.ApiPrefixConstant;
+import com.qmth.paper.library.common.contant.SystemConstant;
+import com.qmth.paper.library.common.util.Result;
+import com.qmth.paper.library.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
+/**
+ * @Description 扫描统计控制类
+ */
+@Api(tags = "扫描统计Controller")
+@RestController
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + ApiPrefixConstant.PREFIX_BASIC + "/scan/stat")
+public class PaperScanStatController {
+
+    @Resource
+    private PaperScanStatService paperScanStatService;
+
+    @ApiOperation(value = "分页查询")
+    @PostMapping("/page")
+    @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = Result.class) })
+    public Result page(@ApiParam(value = "扫描日期") @RequestParam(value = "scanDate", required = false) Long scanDate,
+            @ApiParam(value = "扫描员") @RequestParam(value = "scanner", required = false) String scanner,
+            @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+            @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+        return ResultUtil.ok(paperScanStatService.pageScanStat(scanDate, scanner, pageNumber, pageSize));
+    }
+
+}