Ver Fonte

BUG修复

wangliang há 3 anos atrás
pai
commit
3112cc9dc3

+ 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;

+ 23 - 17
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,
@@ -57,6 +57,7 @@
         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'
@@ -65,26 +66,29 @@
         t_c_statistics tcs
         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 temp.createId = #{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>
@@ -118,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,
@@ -142,6 +146,7 @@
                     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'
@@ -162,21 +167,22 @@
             left join exam_print_plan epp on
                     epp.id = ed.print_plan_id
             <where>
-                and et.enable = true
+                <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>
-                <if test="batchNo != null and batchNo != ''">
-                    and tcst.batch_no = #{batchNo}
-                </if>
                 <if test="orgIds != null and orgIds.size() > 0">
-                    AND epp.org_id IN
+                    and epp.org_id IN
                     <foreach collection="orgIds" item="item" index="index" open="(" separator="," close=")">
                         #{item}
                     </foreach>
                 </if>
-            </where>) t
+            </where>)) t
         group by
             t.collegeId,
             t.collegeName,

+ 8 - 6
distributed-print-business/src/main/resources/mapper/TCStatisticsTempMapper.xml

@@ -16,7 +16,8 @@
         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
         left join exam_task et on
@@ -33,14 +34,15 @@
         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>