浏览代码

BUG修复

wangliang 3 年之前
父节点
当前提交
8eabcf041f

+ 12 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TCStatistics.java

@@ -76,6 +76,10 @@ public class TCStatistics extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "完成状态,FINISH:已完成,UN_FINISH:未完成")
     private StatisticsStatusEnum status;
 
+    @ApiModelProperty(name = "命题明细id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long examDetailId;
+
     public TCStatistics() {
 
     }
@@ -144,6 +148,14 @@ public class TCStatistics extends BaseEntity implements Serializable {
         updateInfo(userId);
     }
 
+    public Long getExamDetailId() {
+        return examDetailId;
+    }
+
+    public void setExamDetailId(Long examDetailId) {
+        this.examDetailId = examDetailId;
+    }
+
     public Integer getPrintSum() {
         return printSum;
     }

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

@@ -73,6 +73,10 @@ public class TCStatisticsTemp extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "数据来源")
     DataSourceEnum dataSource;
 
+    @ApiModelProperty(name = "命题明细id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long examDetailId;
+
     public TCStatisticsTemp() {
 
     }
@@ -142,6 +146,14 @@ public class TCStatisticsTemp extends BaseEntity implements Serializable {
         updateInfo(userId);
     }
 
+    public Long getExamDetailId() {
+        return examDetailId;
+    }
+
+    public void setExamDetailId(Long examDetailId) {
+        this.examDetailId = examDetailId;
+    }
+
     public DataSourceEnum getDataSource() {
         return dataSource;
     }

+ 45 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCStatisticsServiceImpl.java

@@ -22,6 +22,7 @@ import com.qmth.teachcloud.common.service.SysOrgService;
 import com.qmth.teachcloud.common.util.*;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.LinkedMultiValueMap;
 
 import javax.annotation.Resource;
 import java.util.*;
@@ -122,8 +123,29 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
             }
             List<TCStatisticsDto> tcStatisticsDtoList = this.findByBatchNoCount(sysUser.getSchoolId(), batchNo, orgIds);
             if (Objects.nonNull(tcStatisticsDtoList) && tcStatisticsDtoList.size() > 0) {
+                //进行过滤
+                Map<String, TCStatisticsDto> map = new LinkedHashMap<>();
+                for (TCStatisticsDto t : tcStatisticsDtoList) {
+                    String key = t.getCollegeId() + ":" +
+                            t.getTeachingRoomId() + ":" +
+                            t.getCourseCode() + ":" +
+                            t.getPaperNumber() + ":" +
+                            t.getPrintPlanId() + ":" +
+                            t.getClazzId();
+                    if (!map.containsKey(key)) {
+                        map.computeIfAbsent(key, v -> t);
+                    } else {
+                        TCStatisticsDto temp = map.get(key);
+                        if (t.getPrintSum().intValue() > temp.getPrintSum().intValue()) {
+                            map.put(key, t);
+                        } else if (t.getPrintSum().intValue() == temp.getPrintSum().intValue()) {
+                            temp.setExamDetailId(null);
+                            temp.setStatus(StatisticsStatusEnum.UN_JOIN);
+                        }
+                    }
+                }
                 Gson gson = new Gson();
-                List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(tcStatisticsDtoList), new TypeToken<List<TCStatistics>>() {
+                List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(map.values()), new TypeToken<List<TCStatistics>>() {
                 }.getType());
                 for (TCStatistics t : tcStatisticsList) {
                     t.insertInfo(sysUser.getId());
@@ -197,8 +219,29 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
                     tcStatisticsQueryWrapper.lambda().eq(TCStatistics::getBatchNo, batchNo);
                     tcStatisticsService.remove(tcStatisticsQueryWrapper);
 
+                    //进行过滤
+                    Map<String, TCStatisticsDto> map = new LinkedHashMap<>();
+                    for (TCStatisticsDto t : tcStatisticsDtoList) {
+                        String key = t.getCollegeId() + ":" +
+                                t.getTeachingRoomId() + ":" +
+                                t.getCourseCode() + ":" +
+                                t.getPaperNumber() + ":" +
+                                t.getPrintPlanId() + ":" +
+                                t.getClazzId();
+                        if (!map.containsKey(key)) {
+                            map.computeIfAbsent(key, v -> t);
+                        } else {
+                            TCStatisticsDto temp = map.get(key);
+                            if (t.getPrintSum().intValue() > temp.getPrintSum().intValue()) {
+                                map.put(key, t);
+                            } else if (t.getPrintSum().intValue() == temp.getPrintSum().intValue()) {
+                                temp.setExamDetailId(null);
+                                temp.setStatus(StatisticsStatusEnum.UN_JOIN);
+                            }
+                        }
+                    }
                     Gson gson = new Gson();
-                    List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(tcStatisticsDtoList), new TypeToken<List<TCStatistics>>() {
+                    List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(map.values()), new TypeToken<List<TCStatistics>>() {
                     }.getType());
                     for (TCStatistics t : tcStatisticsList) {
                         t.insertInfo(sysUser.getId());

+ 17 - 12
distributed-print-business/src/main/resources/mapper/TCStatisticsMapper.xml

@@ -58,15 +58,16 @@
         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'
+        when ed.status is null then 'UN_JOIN'
+        when ed.status = 'FINISH' then 'FINISH'
         else 'UN_FINISH'
         end status
         from
         t_c_statistics tcs
         left join exam_print_plan epp on
         epp.id = tcs.print_plan_id
+        left join exam_detail ed on
+        ed.id = tcs.exam_detail_id and ed.print_plan_id = epp.id
         where 1 = 1
             and IF(epp.id is null, true,
         <if test="schoolId != null and schoolId != ''">
@@ -115,6 +116,7 @@
                 when sum(t.examStudentCount) = 0 then 0
                 else sum(t.examStudentCount) + (t.drawCount * t.backupCount)
             end printSum,
+            t.examDetailId,
             GROUP_CONCAT(distinct t.examDetailCourseId) as examDetailCourseIds,
             GROUP_CONCAT(distinct t.examTaskDetailId) as examTaskDetailIds
         from
@@ -136,6 +138,7 @@
                 etd.id as examTaskDetailId,
                 epp.id as printPlanId,
                 epp.name as printPlanName,
+                ed.id as examDetailId,
                 IFNULL(etd.draw_count, 0) as drawCount,
                 IFNULL((
                 select
@@ -147,10 +150,9 @@
                     and es.clazz_id = tcst.clazz_id
                     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'
+                case
+                    when ed.status is null then 'UN_JOIN'
+                    when ed.status = 'FINISH' then 'FINISH'
                     else 'UN_FINISH'
                 end status
             from
@@ -200,7 +202,8 @@
             t.printPlanName,
             t.status,
             t.drawCount,
-            t.batchNo
+            t.batchNo,
+            t.examDetailId
         order by
             t.printPlanId,
             t.clazzId
@@ -226,6 +229,7 @@
         when sum(t.examStudentCount) = 0 then 0
         else sum(t.examStudentCount) + (t.drawCount * t.backupCount)
         end printSum,
+        t.examDetailId,
         GROUP_CONCAT(distinct t.examDetailCourseId) as examDetailCourseIds,
         GROUP_CONCAT(distinct t.examTaskDetailId) as examTaskDetailIds
         from
@@ -247,6 +251,7 @@
         etd.id as examTaskDetailId,
         epp.id as printPlanId,
         epp.name as printPlanName,
+        ed.id as examDetailId,
         IFNULL(etd.draw_count, 0) as drawCount,
         IFNULL((
         select
@@ -259,9 +264,8 @@
         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'
+        when ed.status is null then 'UN_JOIN'
+        when ed.status = 'FINISH' then 'FINISH'
         else 'UN_FINISH'
         end status
         from
@@ -311,7 +315,8 @@
         t.printPlanName,
         t.status,
         t.drawCount,
-        t.batchNo
+        t.batchNo,
+        t.examDetailId
         order by
         t.printPlanId,
         t.clazzId

+ 2 - 0
distributed-print-business/src/main/resources/mapper/TCStatisticsTempMapper.xml

@@ -17,6 +17,7 @@
         epp.id as printPlanId,
         edc.id as examDetailCourseId,
         etd.id as examTaskDetailId,
+        ed.id as examDetailId,
         'JOIN' as dataSource
         from
         t_c_statistics_temp tcst
@@ -61,6 +62,7 @@
         epp.id as printPlanId,
         edc.id as examDetailCourseId,
         etd.id as examTaskDetailId,
+        ed.id as examDetailId,
         'JOIN' as dataSource
         from
         t_c_statistics_temp tcst