Forráskód Böngészése

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

xiaof 3 éve
szülő
commit
cf04f4c07a

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

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

@@ -8,6 +8,7 @@ import com.qmth.distributed.print.business.enums.StatisticsStatusEnum;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * <p>
@@ -29,6 +30,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 +39,16 @@ 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);
 }

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

@@ -13,6 +13,7 @@ import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
 
 /**
  * <p>
@@ -38,11 +39,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 +52,11 @@ 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);
     }
 }

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

@@ -1357,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(),
@@ -1382,6 +1382,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 List<String> errors = excelErrorTemp.stream().map(m -> m.getExcelErrorType()).collect(Collectors.toList());
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
             }
+            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);
+            }
             //加入删除
             QueryWrapper<TCStatistics> tcStatisticsQueryWrapper = new QueryWrapper<>();
             tcStatisticsQueryWrapper.lambda().in(TCStatistics::getCollegeId, collegeIdSet)
@@ -1409,7 +1415,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 }
                 tcStatisticsTempService.saveBatch(tcStatisticsTempList);
 
-                List<TCStatisticsDto> tcStatisticsDtoList = tcStatisticsService.findByBatchNoCount(sysUser.getSchoolId(), batchNo);
+                List<TCStatisticsDto> tcStatisticsDtoList = tcStatisticsService.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>>() {

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

+ 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()));
     }
 }