Переглянути джерело

Merge branch 'dev_v2.2.0' into release_v2.2.0
merge

wangliang 3 роки тому
батько
коміт
6d99d87824
15 змінених файлів з 277 додано та 113 видалено
  1. 13 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TCStatisticsTemp.java
  2. 42 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/DataSourceEnum.java
  3. 2 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/StatisticsStatusEnum.java
  4. 6 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TCStatisticsMapper.java
  5. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ClientService.java
  6. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskDetailService.java
  7. 23 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TCStatisticsService.java
  8. 6 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientServiceImpl.java
  9. 25 20
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java
  10. 93 7
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCStatisticsServiceImpl.java
  11. 7 42
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  12. 42 20
      distributed-print-business/src/main/resources/mapper/TCStatisticsMapper.xml
  13. 13 11
      distributed-print-business/src/main/resources/mapper/TCStatisticsTempMapper.xml
  14. 2 2
      distributed-print/src/main/java/com/qmth/distributed/print/api/ClientController.java
  15. 1 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/TCStatisticsController.java

+ 13 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TCStatisticsTemp.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.entity;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.enums.DataSourceEnum;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -69,6 +70,9 @@ public class TCStatisticsTemp extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "批次号")
     private String batchNo;
 
+    @ApiModelProperty(value = "数据来源")
+    DataSourceEnum dataSource;
+
     public TCStatisticsTemp() {
 
     }
@@ -95,6 +99,7 @@ public class TCStatisticsTemp extends BaseEntity implements Serializable {
         this.clazzId = clazzId;
         this.clazzName = clazzName;
         this.batchNo = batchNo;
+        this.dataSource = DataSourceEnum.IMPORT;
     }
 
     public TCStatisticsTemp(Long collegeId,
@@ -137,6 +142,14 @@ public class TCStatisticsTemp extends BaseEntity implements Serializable {
         updateInfo(userId);
     }
 
+    public DataSourceEnum getDataSource() {
+        return dataSource;
+    }
+
+    public void setDataSource(DataSourceEnum dataSource) {
+        this.dataSource = dataSource;
+    }
+
     public Long getCollegeId() {
         return collegeId;
     }

+ 42 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/DataSourceEnum.java

@@ -0,0 +1,42 @@
+package com.qmth.distributed.print.business.enums;
+
+import java.util.Objects;
+
+/**
+ * @Description: 数据来源 enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/9/9
+ */
+public enum DataSourceEnum {
+
+    IMPORT("导入"),
+
+    JOIN("关联查询的数据");
+
+    private String title;
+
+    private DataSourceEnum(String title) {
+        this.title = title;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * 状态转换 toName
+     *
+     * @param title
+     * @return
+     */
+    public static String convertToName(String title) {
+        for (DataSourceEnum e : DataSourceEnum.values()) {
+            if (Objects.equals(title, e.getTitle())) {
+                return e.name();
+            }
+        }
+        return null;
+    }
+}

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/StatisticsStatusEnum.java

@@ -13,6 +13,8 @@ public enum StatisticsStatusEnum {
 
     FINISH("已完成"),
 
+    UN_JOIN("未关联"),
+
     UN_FINISH("未完成");
 
     private String title;

+ 6 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TCStatisticsMapper.java

@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * <p>
@@ -29,6 +30,7 @@ public interface TCStatisticsMapper extends BaseMapper<TCStatistics> {
      * @param courseName
      * @param teacherName
      * @param schoolId
+     * @param userId
      * @return
      */
     public IPage<TCStatisticsDto> list(IPage<Map> iPage,
@@ -37,14 +39,16 @@ public interface TCStatisticsMapper extends BaseMapper<TCStatistics> {
                                        @Param("status") String status,
                                        @Param("courseName") String courseName,
                                        @Param("teacherName") String teacherName,
-                                       @Param("schoolId") Long schoolId);
+                                       @Param("schoolId") Long schoolId,
+                                       @Param("userId") Long userId);
 
     /**
      * 根据batchNo统计信息
      *
      * @param schoolId
      * @param batchNo
+     * @param orgIds
      * @return
      */
-    public List<TCStatisticsDto> findByBatchNoCount(@Param("schoolId") Long schoolId, @Param("batchNo") String batchNo);
+    public List<TCStatisticsDto> findByBatchNoCount(@Param("schoolId") Long schoolId, @Param("batchNo") String batchNo, @Param("orgIds") Set<Long> orgIds);
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ClientService.java

@@ -13,7 +13,7 @@ import java.util.Map;
 public interface ClientService {
     IPage<ClientExamTaskDto> listTryTask(String machineCode, Long orgId, Long printPlanId, String courseCode, String paperNumber, Boolean isTry, Boolean isPass, Integer pageNumber, Integer pageSize);
 
-    Map<String, String> getUrl(Long printPlanId, Long examTaskId);
+    List<Map<String, String>> getUrl(Long printPlanId, Long examTaskId);
 
     Boolean tagPass(Long printPlanId, String courseCode, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId);
 

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskDetailService.java

@@ -35,7 +35,7 @@ public interface ExamTaskDetailService extends IService<ExamTaskDetail> {
 
     List<ExamTaskDetail> listByTemplateId(Long templateId);
 
-    Map<String, String>  getUrl(Long schoolId, Long printPlanId, Long examTaskId);
+    List<Map<String, String>>  getUrl(Long schoolId, Long printPlanId, Long examTaskId);
 
     boolean paperUpdate(ExamTaskDetail examTaskDetail);
 

+ 23 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TCStatisticsService.java

@@ -5,9 +5,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.bean.dto.TCStatisticsDto;
 import com.qmth.distributed.print.business.entity.TCStatistics;
 import com.qmth.distributed.print.business.enums.StatisticsStatusEnum;
+import com.qmth.teachcloud.common.entity.SysUser;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * <p>
@@ -29,6 +31,7 @@ public interface TCStatisticsService extends IService<TCStatistics> {
      * @param courseName
      * @param teacherName
      * @param schoolId
+     * @param userId
      * @return
      */
     public IPage<TCStatisticsDto> list(IPage<Map> iPage,
@@ -37,14 +40,32 @@ public interface TCStatisticsService extends IService<TCStatistics> {
                                        StatisticsStatusEnum status,
                                        String courseName,
                                        String teacherName,
-                                       Long schoolId);
+                                       Long schoolId,
+                                       Long userId);
 
     /**
      * 根据batchNo统计信息
      *
      * @param schoolId
      * @param batchNo
+     * @param orgIds
      * @return
      */
-    public List<TCStatisticsDto> findByBatchNoCount(Long schoolId, String batchNo);
+    public List<TCStatisticsDto> findByBatchNoCount(Long schoolId, String batchNo, Set<Long> orgIds);
+
+    /**
+     * 导入关联数据
+     *
+     * @param sysUser
+     * @param batchNo
+     */
+    public void importJoinData(SysUser sysUser, String batchNo);
+
+    /**
+     * 删除导入数据
+     *
+     * @param courseSet
+     * @param setCollections
+     */
+    public void removeImportData(Set<String> courseSet, Set<Long>... setCollections);
 }

+ 6 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientServiceImpl.java

@@ -76,7 +76,7 @@ public class ClientServiceImpl implements ClientService {
     }
 
     @Override
-    public Map<String, String> getUrl(Long printPlanId, Long examTaskId) {
+    public List<Map<String, String>> getUrl(Long printPlanId, Long examTaskId) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         return examTaskDetailService.getUrl(schoolId, printPlanId, examTaskId);
     }
@@ -526,9 +526,11 @@ public class ClientServiceImpl implements ClientService {
             map.put("courseCode", clientExamTaskDto.getCourseCode());
             map.put("courseName", clientExamTaskDto.getCourseName());
             map.put("paperNumber", clientExamTaskDto.getPaperNumber());
-            Map<String, String> stringMap = examTaskDetailService.getUrl(schoolId, Long.valueOf(clientExamTaskDto.getPrintPlanId()), Long.valueOf(clientExamTaskDto.getExamTaskId()));
-            map.putAll(stringMap);
-            list.add(map);
+            List<Map<String, String>> mapList = examTaskDetailService.getUrl(schoolId, Long.valueOf(clientExamTaskDto.getPrintPlanId()), Long.valueOf(clientExamTaskDto.getExamTaskId()));
+            for (Map<String, String> stringMap : mapList) {
+                stringMap.putAll(map);
+                list.add(stringMap);
+            }
         }
         return list;
     }

+ 25 - 20
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java

@@ -10,7 +10,6 @@ import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto;
 import com.qmth.distributed.print.business.bean.params.RelatePaperParam;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
-import com.qmth.distributed.print.business.enums.ExamStatusEnum;
 import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.mapper.ExamTaskDetailMapper;
 import com.qmth.distributed.print.business.service.*;
@@ -290,31 +289,37 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     }
 
     @Override
-    public Map<String, String> getUrl(Long schoolId, Long printPlanId, Long examTaskId) {
+    public List<Map<String, String>> getUrl(Long schoolId, Long printPlanId, Long examTaskId) {
         ExamTask examTask = examTaskService.getById(examTaskId);
         List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, examTask.getCourseCode(), examTask.getPaperNumber());
         if (!CollectionUtils.isEmpty(examDetailCourses)) {
-            ExamDetailCourse examDetailCourse = examDetailCourses.get(0);
-            QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
-            examTaskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
-            ExamTaskDetail examTaskDetail = this.getOne(examTaskDetailQueryWrapper);
-            if (examTaskDetail != null) {
-                String relatePaperType = examTaskDetail.getRelatePaperType();
-                if (StringUtils.isNotBlank(relatePaperType)) {
-                    String paperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
-                    List<Map> list = JSONObject.parseArray(paperAttachmentIds, Map.class);
-                    String attachmentId = null;
-                    for (Map map : list) {
-                        String name = map.get("name").toString();
-                        if (name.equals(examDetailCourse.getPaperType())) {
-                            attachmentId = map.get("attachmentId").toString();
+            List<Map<String, String>> paperList = new ArrayList<>();
+            for (ExamDetailCourse examDetailCourse : examDetailCourses) {
+                QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
+                examTaskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
+                ExamTaskDetail examTaskDetail = this.getOne(examTaskDetailQueryWrapper);
+                if (examTaskDetail != null) {
+                    String relatePaperType = examDetailCourse.getPaperType();
+                    if (StringUtils.isNotBlank(relatePaperType)) {
+                        String[] paperTypes = relatePaperType.split(",");
+                        String paperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
+                        List<Map> list = JSONObject.parseArray(paperAttachmentIds, Map.class);
+                        String attachmentId;
+                        for (Map map : list) {
+                            String name = map.get("name").toString();
+                            for (String paperType : paperTypes) {
+                                if (name.equals(paperType)) {
+                                    attachmentId = map.get("attachmentId").toString();
+                                    if (StringUtils.isNotBlank(attachmentId)) {
+                                        paperList.add(teachcloudCommonService.filePreviewByAttachmentId(Long.valueOf(attachmentId), false));
+                                    }
+                                }
+                            }
                         }
                     }
-                    if (StringUtils.isNotBlank(attachmentId)) {
-                        return teachcloudCommonService.filePreviewByAttachmentId(Long.valueOf(attachmentId), false);
-                    }
                 }
             }
+            return paperList;
         }
         return null;
     }
@@ -347,7 +352,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
 
         ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
         List<ExamDetail> examDetails = examDetailService.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getCourseCode(), examTask.getPaperNumber());
-        if(!CollectionUtils.isEmpty(examDetails)) {
+        if (!CollectionUtils.isEmpty(examDetails)) {
             List<ExamDetail> examDetailList = examDetails.stream().filter(m -> m.getStatus().equals(ExamDetailStatusEnum.WAITING)).collect(Collectors.toList());
             for (ExamDetail examDetail : examDetailList) {
                 examDetail.setStatus(ExamDetailStatusEnum.NEW);

+ 93 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCStatisticsServiceImpl.java

@@ -1,18 +1,31 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
 import com.qmth.distributed.print.business.bean.dto.TCStatisticsDto;
 import com.qmth.distributed.print.business.entity.TCStatistics;
+import com.qmth.distributed.print.business.entity.TCStatisticsTemp;
 import com.qmth.distributed.print.business.enums.StatisticsStatusEnum;
 import com.qmth.distributed.print.business.mapper.TCStatisticsMapper;
+import com.qmth.distributed.print.business.mapper.TCStatisticsTempMapper;
 import com.qmth.distributed.print.business.service.TCStatisticsService;
+import com.qmth.distributed.print.business.service.TCStatisticsTempService;
+import com.qmth.teachcloud.common.contant.SpringContextHolder;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysOrg;
+import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.service.SysOrgService;
+import com.qmth.teachcloud.common.util.JacksonUtil;
+import org.springframework.boot.SpringApplication;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -28,6 +41,12 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
     @Resource
     TCStatisticsMapper tcStatisticsMapper;
 
+    @Resource
+    TCStatisticsTempService tcStatisticsTempService;
+
+    @Resource
+    SysOrgService sysOrgService;
+
     /**
      * 查找印刷计划信息
      *
@@ -38,11 +57,12 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
      * @param courseName
      * @param teacherName
      * @param schoolId
+     * @param userId
      * @return
      */
     @Override
-    public IPage<TCStatisticsDto> list(IPage<Map> iPage, Long collegeId, Long teachingRoomId, StatisticsStatusEnum status, String courseName, String teacherName, Long schoolId) {
-        return tcStatisticsMapper.list(iPage, collegeId, teachingRoomId, Objects.nonNull(status) ? status.name() : null, courseName, teacherName, schoolId);
+    public IPage<TCStatisticsDto> list(IPage<Map> iPage, Long collegeId, Long teachingRoomId, StatisticsStatusEnum status, String courseName, String teacherName, Long schoolId, Long userId) {
+        return tcStatisticsMapper.list(iPage, collegeId, teachingRoomId, Objects.nonNull(status) ? status.name() : null, courseName, teacherName, schoolId, userId);
     }
 
     /**
@@ -50,10 +70,76 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
      *
      * @param schoolId
      * @param batchNo
+     * @param orgIds
      * @return
      */
     @Override
-    public List<TCStatisticsDto> findByBatchNoCount(Long schoolId, String batchNo) {
-        return tcStatisticsMapper.findByBatchNoCount(schoolId, batchNo);
+    public List<TCStatisticsDto> findByBatchNoCount(Long schoolId, String batchNo, Set<Long> orgIds) {
+        return tcStatisticsMapper.findByBatchNoCount(schoolId, batchNo, orgIds);
+    }
+
+    /**
+     * 导入关联数据
+     *
+     * @param sysUser
+     * @param batchNo
+     */
+    @Override
+    @Transactional
+    public void importJoinData(SysUser sysUser, String batchNo) {
+        List<TCStatisticsTemp> tcStatisticsTempList = tcStatisticsTempService.findByBatchNo(sysUser.getSchoolId(), batchNo);
+        if (Objects.nonNull(tcStatisticsTempList) && tcStatisticsTempList.size() > 0) {
+            batchNo = SystemConstant.getUuid();
+            Set<Long> collegeIdSet = new HashSet<>();
+            for (TCStatisticsTemp t : tcStatisticsTempList) {
+                collegeIdSet.add(t.getCollegeId());
+                t.insertInfo(sysUser.getId());
+                t.setBatchNo(batchNo);
+            }
+            tcStatisticsTempService.saveBatch(tcStatisticsTempList);
+
+            Set<Long> orgIds = new HashSet<>();
+            for (Long l : collegeIdSet) {
+                List<SysOrg> sysOrgList = sysOrgService.findByConnectByRootOrgId(l);
+                Set<Long> orgTempIds = sysOrgList.stream().map(s -> s.getId()).collect(Collectors.toSet());
+                orgIds.addAll(orgTempIds);
+            }
+            List<TCStatisticsDto> tcStatisticsDtoList = this.findByBatchNoCount(sysUser.getSchoolId(), batchNo, orgIds);
+            if (Objects.nonNull(tcStatisticsDtoList) && tcStatisticsDtoList.size() > 0) {
+                Gson gson = new Gson();
+                List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(tcStatisticsDtoList), new TypeToken<List<TCStatistics>>() {
+                }.getType());
+                for (TCStatistics t : tcStatisticsList) {
+                    t.insertInfo(sysUser.getId());
+                }
+                TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
+                tcStatisticsService.saveBatch(tcStatisticsList);
+            }
+        }
+    }
+
+    /**
+     * 删除导入数据
+     *
+     * @param courseSet
+     * @param setCollections
+     */
+    @Override
+    @Transactional
+    public void removeImportData(Set<String> courseSet, Set<Long>... setCollections) {
+        TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
+        QueryWrapper<TCStatistics> tcStatisticsQueryWrapper = new QueryWrapper<>();
+        tcStatisticsQueryWrapper.lambda().in(TCStatistics::getCollegeId, setCollections[0])
+                .in(TCStatistics::getTeachingRoomId, setCollections[1])
+                .in(TCStatistics::getCourseCode, courseSet)
+                .in(TCStatistics::getClazzId, setCollections[2]);
+        tcStatisticsService.remove(tcStatisticsQueryWrapper);
+
+        QueryWrapper<TCStatisticsTemp> tcStatisticsTempQueryWrapper = new QueryWrapper<>();
+        tcStatisticsTempQueryWrapper.lambda().in(TCStatisticsTemp::getCollegeId, setCollections[0])
+                .in(TCStatisticsTemp::getTeachingRoomId, setCollections[1])
+                .in(TCStatisticsTemp::getCourseCode, courseSet)
+                .in(TCStatisticsTemp::getClazzId, setCollections[2]);
+        tcStatisticsTempService.remove(tcStatisticsTempQueryWrapper);
     }
 }

+ 7 - 42
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -353,8 +353,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             for (ExamStudent t : examStudentList) {
                                 basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, examDetail, examDetailCourse, sysUser.getId(), examStudentTempPdfList));
                             }
-                            // 试卷
-                            list[2].addAll(paperPdfTempList);
                             // 题卡
                             list[3].addAll(examStudentTempPdfList);
                             jsonObject.put("card", jsonArray);
@@ -1359,12 +1357,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     String teacherName = statisticsImportDto.getTeacherName();
                     BasicClazz basicClazz = this.validBasicClazzExists(clazzMap, statisticsImportDto.getClazzName(), sysUser.getSchoolId(), excelErrorTemp, (y + 1), (i + 1), "班级名称");
 
-                    collegeIdSet.add(collegeOrg.getId());
-                    teachingRoomIdSet.add(teachingRoomOrg.getId());
-                    courseSet.add(basicCourse.getCode());
-                    ClazzIdSet.add(basicClazz.getId());
-
                     if (excelErrorTemp.size() == 0) {
+                        collegeIdSet.add(collegeOrg.getId());
+                        teachingRoomIdSet.add(teachingRoomOrg.getId());
+                        courseSet.add(basicCourse.getCode());
+                        ClazzIdSet.add(basicClazz.getId());
+
                         TCStatisticsTemp tcStatistics = new TCStatisticsTemp(collegeOrg.getId(),
                                 collegeOrg.getName(),
                                 teachingRoomOrg.getId(),
@@ -1385,43 +1383,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
             }
             //加入删除
-            QueryWrapper<TCStatistics> tcStatisticsQueryWrapper = new QueryWrapper<>();
-            tcStatisticsQueryWrapper.lambda().in(TCStatistics::getCollegeId, collegeIdSet)
-                    .in(TCStatistics::getTeachingRoomId, teachingRoomIdSet)
-                    .in(TCStatistics::getCourseCode, courseSet)
-                    .in(TCStatistics::getClazzId, ClazzIdSet);
-            tcStatisticsService.remove(tcStatisticsQueryWrapper);
-
-            QueryWrapper<TCStatisticsTemp> tcStatisticsTempQueryWrapper = new QueryWrapper<>();
-            tcStatisticsTempQueryWrapper.lambda().in(TCStatisticsTemp::getCollegeId, collegeIdSet)
-                    .in(TCStatisticsTemp::getTeachingRoomId, teachingRoomIdSet)
-                    .in(TCStatisticsTemp::getCourseCode, courseSet)
-                    .in(TCStatisticsTemp::getClazzId, ClazzIdSet);
-            tcStatisticsTempService.remove(tcStatisticsTempQueryWrapper);
-
+            tcStatisticsService.removeImportData(courseSet, collegeIdSet, teachingRoomIdSet, ClazzIdSet);
             tcStatisticsTempService.saveBatch(tcStatisticsImportTempList);
             map.put("dataCount", tcStatisticsImportTempList.size());
-
-            List<TCStatisticsTemp> tcStatisticsTempList = tcStatisticsTempService.findByBatchNo(sysUser.getSchoolId(), batchNo);
-            if (Objects.nonNull(tcStatisticsTempList) && tcStatisticsTempList.size() > 0) {
-                batchNo = SystemConstant.getUuid();
-                for (TCStatisticsTemp t : tcStatisticsTempList) {
-                    t.insertInfo(sysUser.getId());
-                    t.setBatchNo(batchNo);
-                }
-                tcStatisticsTempService.saveBatch(tcStatisticsTempList);
-
-                List<TCStatisticsDto> tcStatisticsDtoList = tcStatisticsService.findByBatchNoCount(sysUser.getSchoolId(), batchNo);
-                if (Objects.nonNull(tcStatisticsDtoList) && tcStatisticsDtoList.size() > 0) {
-                    Gson gson = new Gson();
-                    List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(tcStatisticsDtoList), new TypeToken<List<TCStatistics>>() {
-                    }.getType());
-                    for (TCStatistics t : tcStatisticsList) {
-                        t.insertInfo(sysUser.getId());
-                    }
-                    tcStatisticsService.saveBatch(tcStatisticsList);
-                }
-            }
+            tcStatisticsService.importJoinData(sysUser, batchNo);
             return finalExcelList;
         });
         return map;

+ 42 - 20
distributed-print-business/src/main/resources/mapper/TCStatisticsMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.qmth.distributed.print.business.mapper.TCStatisticsMapper">
 
     <select id="list" resultType="com.qmth.distributed.print.business.bean.dto.TCStatisticsDto">
-        select temp.* from(select
+        select
         t.id,
         t.collegeId,
         t.collegeName,
@@ -16,6 +16,7 @@
         t.clazzName,
         IF(t.examStudentCount = 0,null,t.paperNumber) as paperNumber,
         t.printPlanId,
+        t.createId,
         IF(t.examStudentCount = 0,null,t.printPlanName) as printPlanName,
         t.examStudentCount,
         IF(t.examStudentCount = 0,null,t.examStudentCount + (t.drawCount * t.backupCount)) as printSum,
@@ -35,6 +36,7 @@
         tcs.clazz_name as clazzName,
         tcs.batch_no as batchNo,
         tcs.paper_number as paperNumber,
+        tcs.create_id as createId,
         epp.id as printPlanId,
         epp.name as printPlanName,
         (
@@ -55,31 +57,38 @@
         and es.clazz_id = tcs.clazz_id
         and es.school_id = #{schoolId}),0) as examStudentCount,
         case
+        when epp.status is null then 'UN_JOIN'
         when epp.status = 'PRINT_FINISH'
         or epp.status = 'END' then 'FINISH'
         else 'UN_FINISH'
         end status
         from
         t_c_statistics tcs
-        join exam_print_plan epp on
+        left join exam_print_plan epp on
         epp.id = tcs.print_plan_id
-        where
-        epp.school_id = #{schoolId}) t) temp
+        where 1 = 1
+            and IF(epp.id is null, true,
+        <if test="schoolId != null and schoolId != ''">
+             epp.school_id = #{schoolId}
+        </if>)) t
         <where>
+            <if test="userId != null and userId != ''">
+                and t.createId = #{userId}
+            </if>
             <if test="collegeId != null and collegeId != ''">
-                and temp.collegeId = #{collegeId}
+                and t.collegeId = #{collegeId}
             </if>
             <if test="teachingRoomId != null and teachingRoomId != ''">
-                and temp.teachingRoomId = #{teachingRoomId}
+                and t.teachingRoomId = #{teachingRoomId}
             </if>
             <if test="status != null and status != ''">
-                and temp.status = #{status}
+                and t.status = #{status}
             </if>
             <if test="courseName != null and courseName != ''">
-                and temp.courseName like concat('%',#{courseName},'%')
+                and t.courseName like concat('%',#{courseName},'%')
             </if>
             <if test="teacherName != null and teacherName != ''">
-                and temp.teacherName like concat('%',#{teacherName},'%')
+                and t.teacherName like concat('%',#{teacherName},'%')
             </if>
         </where>
     </select>
@@ -113,8 +122,8 @@
                 tcst.college_id as collegeId,
                 tcst.college_name as collegeName,
                 tcst.course_name as courseName,
-                et.course_code as courseCode,
-                et.teaching_room_id as teachingRoomId,
+                tcst.course_code as courseCode,
+                tcst.teaching_room_id as teachingRoomId,
                 tcst.teaching_room_name as teachingRoomName,
                 tcst.teacher_name as teacherName,
                 tcst.clazz_id as clazzId,
@@ -137,30 +146,43 @@
                     and es.school_id = #{schoolId}),0) as examStudentCount,
                 IFNULL(epp.backup_count, 0) as backupCount,
                     case
+                        when epp.status is null then 'UN_JOIN'
                         when epp.status = 'PRINT_FINISH'
                     or epp.status = 'END' then 'FINISH'
                     else 'UN_FINISH'
                 end status
             from
                     t_c_statistics_temp tcst
-            join exam_task et on
+            left join exam_task et on
                     et.course_code = tcst.course_code
                 and et.teaching_room_id = tcst.teaching_room_id
-            join exam_task_detail etd on
+            left join exam_task_detail etd on
                     etd.exam_task_id = et.id
-            join exam_detail_course edc on
+            left join exam_detail_course edc on
                     edc.course_code = tcst.course_code
                 and edc.paper_number = et.paper_number
                 and edc.school_id = et.school_id
-            join exam_detail ed on
+            left join exam_detail ed on
                     ed.id = edc.exam_detail_id
-            join exam_print_plan epp on
+            left join exam_print_plan epp on
                     epp.id = ed.print_plan_id
-            where
-                    et.enable = true
+            <where>
+                <if test="batchNo != null and batchNo != ''">
+                    and tcst.batch_no = #{batchNo}
+                </if>
+                and IF(epp.id is null, true,
+                et.enable = true
                 and etd.enable = true
-                and et.school_id = #{schoolId}
-                and tcst.batch_no = #{batchNo}) t
+                <if test="schoolId != null and schoolId != ''">
+                    and et.school_id = #{schoolId}
+                </if>
+                <if test="orgIds != null and orgIds.size() > 0">
+                    and epp.org_id IN
+                    <foreach collection="orgIds" item="item" index="index" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+            </where>)) t
         group by
             t.collegeId,
             t.collegeName,

+ 13 - 11
distributed-print-business/src/main/resources/mapper/TCStatisticsTempMapper.xml

@@ -16,31 +16,33 @@
         et.paper_number as paperNumber,
         epp.id as printPlanId,
         edc.id as examDetailCourseId,
-        etd.id as examTaskDetailId
+        etd.id as examTaskDetailId,
+        'JOIN' as dataSource
         from
         t_c_statistics_temp tcst
-        join exam_task et on
+        left join exam_task et on
         et.course_code = tcst.course_code
         and et.teaching_room_id = tcst.teaching_room_id
-        join exam_task_detail etd on
+        left join exam_task_detail etd on
         etd.exam_task_id = et.id
-        join exam_detail_course edc on
+        left join exam_detail_course edc on
         edc.course_code = tcst.course_code
         and edc.paper_number = et.paper_number
         and edc.school_id = et.school_id
-        join exam_detail ed on
+        left join exam_detail ed on
         ed.id = edc.exam_detail_id
-        join exam_print_plan epp on
+        left join exam_print_plan epp on
         epp.id = ed.print_plan_id
         <where>
-            and et.enable = true
-            and etd.enable = true
-            <if test="schoolId != null and schoolId != ''">
-                and et.school_id = #{schoolId}
-            </if>
             <if test="batchNo != null and batchNo != ''">
                 and tcst.batch_no = #{batchNo}
             </if>
+            and IF(epp.id is null, true,
+            et.enable = true
+            and etd.enable = true
+            <if test="schoolId != null and schoolId != ''">
+                and et.school_id = #{schoolId}
+            </if>)
         </where>
     </select>
 </mapper>

+ 2 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/ClientController.java

@@ -124,8 +124,8 @@ public class ClientController {
     @RequestMapping(value = "/paper_try/print", method = RequestMethod.POST)
     public Result paperTryPrint(@RequestParam("printPlanId") Long printPlanId,
                                 @RequestParam("examTaskId") Long examTaskId) {
-        Map<String, String> map = clientService.getUrl(printPlanId, examTaskId);
-        return ResultUtil.ok(map);
+        List<Map<String, String>> list = clientService.getUrl(printPlanId, examTaskId);
+        return ResultUtil.ok(list);
     }
 
     /**

+ 1 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/TCStatisticsController.java

@@ -77,6 +77,6 @@ public class TCStatisticsController {
                        @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) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        return ResultUtil.ok(tcStatisticsService.list(new Page<>(pageNumber, pageSize), SystemConstant.convertIdToLong(collegeId), SystemConstant.convertIdToLong(teachingRoomId), status, courseName, teacherName, sysUser.getSchoolId()));
+        return ResultUtil.ok(tcStatisticsService.list(new Page<>(pageNumber, pageSize), SystemConstant.convertIdToLong(collegeId), SystemConstant.convertIdToLong(teachingRoomId), status, courseName, teacherName, sysUser.getSchoolId(), sysUser.getId()));
     }
 }