ソースを参照

Merge branch 'dev_v2.2.0' of http://git.qmth.com.cn/wangliang/distributed-print-service into dev_v2.2.0

xiaof 3 年 前
コミット
8e82cee32a

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

@@ -1331,6 +1331,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     public Map<String, Object> executeImportStatisticsLogic(Map<String, Object> map) throws Exception {
         InputStream inputStream = (InputStream) map.get("inputStream");
         SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
+
         List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(StatisticsImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
             // 只允许导入一个sheet
             if (finalExcelList.size() > 1) {
@@ -1345,6 +1346,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             Map<String, BasicClazz> clazzMap = new HashMap<>();//班级
             String batchNo = SystemConstant.getUuid();
             List<TCStatisticsTemp> tcStatisticsImportTempList = new ArrayList<>();
+            Set<Long> collegeIdSet = new HashSet<>(), teachingRoomIdSet = new HashSet<>(), ClazzIdSet = new HashSet<>();
+            Set<String> courseSet = new HashSet<>();
             for (int i = 0; i < finalExcelList.size(); i++) {
                 LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
                 List<Object> statisticsTempList = excelMap.get(i);
@@ -1356,6 +1359,11 @@ 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) {
                         TCStatisticsTemp tcStatistics = new TCStatisticsTemp(collegeOrg.getId(),
                                 collegeOrg.getName(),
@@ -1376,6 +1384,21 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 List<String> errors = excelErrorTemp.stream().map(m -> m.getExcelErrorType()).collect(Collectors.toList());
                 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);
+
             tcStatisticsTempService.saveBatch(tcStatisticsImportTempList);
             map.put("dataCount", tcStatisticsImportTempList.size());
 

+ 23 - 16
distributed-print-business/src/main/resources/mapper/TCStatisticsMapper.xml

@@ -3,19 +3,23 @@
 <mapper namespace="com.qmth.distributed.print.business.mapper.TCStatisticsMapper">
 
     <select id="list" resultType="com.qmth.distributed.print.business.bean.dto.TCStatisticsDto">
-        select
+        select temp.* from(select
         t.id,
+        t.collegeId,
+        t.collegeName,
+        t.teachingRoomId,
+        t.teachingRoomName,
         t.courseName,
         t.courseCode,
         t.teacherName,
         t.clazzId,
         t.clazzName,
-        t.paperNumber,
+        IF(t.examStudentCount = 0,null,t.paperNumber) as paperNumber,
         t.printPlanId,
-        t.printPlanName,
+        IF(t.examStudentCount = 0,null,t.printPlanName) as printPlanName,
         t.examStudentCount,
-        IFNULL(t.examStudentCount, 0) + (t.drawCount * t.backupCount) as printSum,
-        t.status
+        IF(t.examStudentCount = 0,null,t.examStudentCount + (t.drawCount * t.backupCount)) as printSum,
+        IF(t.examStudentCount = 0,null,t.status) as status
         from
         (
         select
@@ -41,7 +45,7 @@
         where
         FIND_IN_SET(etd.id, tcs.exam_task_detail_ids)) as drawCount,
         IFNULL(epp.backup_count, 0) as backupCount,
-        (
+        IFNULL((
         select
         count(1)
         from
@@ -49,7 +53,7 @@
         where
         FIND_IN_SET(es.exam_detail_course_id, tcs.exam_detail_course_ids)
         and es.clazz_id = tcs.clazz_id
-        and es.school_id = 137) as examStudentCount,
+        and es.school_id = #{schoolId}),0) as examStudentCount,
         case
         when epp.status = 'PRINT_FINISH'
         or epp.status = 'END' then 'FINISH'
@@ -60,22 +64,22 @@
         join exam_print_plan epp on
         epp.id = tcs.print_plan_id
         where
-        epp.school_id = #{schoolId}) t
+        epp.school_id = #{schoolId}) t) temp
         <where>
             <if test="collegeId != null and collegeId != ''">
-                and t.collegeId = #{collegeId}
+                and temp.collegeId = #{collegeId}
             </if>
             <if test="teachingRoomId != null and teachingRoomId != ''">
-                and t.teachingRoomId = #{teachingRoomId}
+                and temp.teachingRoomId = #{teachingRoomId}
             </if>
             <if test="status != null and status != ''">
-                and t.status = #{status}
+                and temp.status = #{status}
             </if>
             <if test="courseName != null and courseName != ''">
-                and t.courseName like concat('%',#{courseName},'%')
+                and temp.courseName like concat('%',#{courseName},'%')
             </if>
             <if test="teacherName != null and teacherName != ''">
-                and t.teacherName like concat('%',#{teacherName},'%')
+                and temp.teacherName like concat('%',#{teacherName},'%')
             </if>
         </where>
     </select>
@@ -96,7 +100,10 @@
             t.printPlanName,
             t.batchNo,
             t.status,
-            IFNULL(sum(t.examStudentCount),0) + (t.drawCount * t.backupCount) as printSum,
+            case
+                when sum(t.examStudentCount) = 0 then 0
+                else sum(t.examStudentCount) + (t.drawCount * t.backupCount)
+            end printSum,
             GROUP_CONCAT(distinct t.examDetailCourseId) as examDetailCourseIds,
             GROUP_CONCAT(distinct t.examTaskDetailId) as examTaskDetailIds
         from
@@ -119,7 +126,7 @@
                 epp.id as printPlanId,
                 epp.name as printPlanName,
                 IFNULL(etd.draw_count, 0) as drawCount,
-                (
+                IFNULL((
                 select
                     count(1)
                 from
@@ -127,7 +134,7 @@
                 where
                     es.exam_detail_course_id = edc.id
                     and es.clazz_id = tcst.clazz_id
-                    and es.school_id = #{schoolId}) as examStudentCount,
+                    and es.school_id = #{schoolId}),0) as examStudentCount,
                 IFNULL(epp.backup_count, 0) as backupCount,
                     case
                         when epp.status = 'PRINT_FINISH'