Quellcode durchsuchen

课表数据同步逻辑调整

dzx vor 2 Monaten
Ursprung
Commit
764478511d

+ 10 - 0
src/main/java/com/xjrsoft/module/activity/controller/ActivityInfoController.java

@@ -89,6 +89,16 @@ public class ActivityInfoController {
         return RT.ok(pageOutput);
     }
 
+    @GetMapping(value = "/today-schedule")
+    @ApiOperation(value="今日安排(分页)")
+    @SaCheckPermission("activityinfo:detail")
+    public RT<PageOutput<ActivityInfoPageVo>> todaySchedule(@Valid ActivityInfoPageDto dto){
+
+        Page<ActivityInfoPageVo> page = activityInfoService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
+        PageOutput<ActivityInfoPageVo> pageOutput = ConventPage.getPageOutput(page, ActivityInfoPageVo.class);
+        return RT.ok(pageOutput);
+    }
+
     @GetMapping(value = "/info")
     @ApiOperation(value="根据id查询活动信息信息")
     @SaCheckPermission("activityinfo:detail")

+ 2 - 2
src/main/java/com/xjrsoft/module/activity/vo/ActivityInfoPageVo.java

@@ -99,9 +99,9 @@ public class ActivityInfoPageVo {
     @ApiModelProperty("合作企业")
     private Long enterpriseId;
     /**
-    * 1:校企合作活动 2:赛事活动
+    * 1:校企合作活动 2:赛事活动 3:社团活动 4:思政德育活动 5:教研培训 6:党建活动
     */
-    @ApiModelProperty("1:校企合作活动 2:赛事活动")
+    @ApiModelProperty("1:校企合作活动 2:赛事活动 3:社团活动 4:思政德育活动 5:教研培训 6:党建活动 7:课表数据 8:会议")
     private Integer category;
 
     @ApiModelProperty("合作企业名称")

+ 30 - 4
src/main/java/com/xjrsoft/module/job/JianyuekbScheduleTask.java

@@ -1,11 +1,14 @@
 package com.xjrsoft.module.job;
 
 import cn.hutool.extra.spring.SpringUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.gson.JsonArray;
 import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
-import com.xjrsoft.module.schedule.entity.CourseReceiveMsg;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.service.IBaseClassService;
 import com.xjrsoft.module.schedule.util.DataUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
@@ -17,6 +20,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 
 /**
@@ -26,6 +30,9 @@ import java.util.Set;
 @Component
 @Slf4j
 public class JianyuekbScheduleTask {
+    @Autowired
+    private IBaseClassService classService;
+
     @Scheduled(cron = "0 */10 * * * ?")
     public void execute() throws Exception {
         RefreshConnectionPool();
@@ -37,18 +44,37 @@ public class JianyuekbScheduleTask {
             return;
         }
         String sql = "SELECT * FROM course_receive_msg WHERE delete_mark = 0 AND is_callback IS NULL";
-        List<Map<String, Object>> receiveMsgs = SqlRunnerAdapter.db().selectList(sql, CourseReceiveMsg.class);
+        List<Map<String, Object>> receiveMsgs = SqlRunnerAdapter.db().selectList(sql);
         JsonArray allScheduleInfo = new JsonArray();
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         DataUtil dataUtil = new DataUtil();
+        //查询出传入排课系统的年级和班级
+        sql = "SELECT * FROM jianyue_data WHERE source_id IS NOT NULL AND jianyue_id != '' and table_name = 'base_grade'";
+        List<Map<String, Object>> jianyueData = SqlRunnerAdapter.db().selectList(sql);
+        Map<String, List<Long>> gradeClassMaps = new HashMap<>();//存入对应年级的所有班级id
+        for (Map<String, Object> el : jianyueData) {
+            String gradeId = el.get("source_id").toString().split("_")[1];
+            List<BaseClass> classList = classService.list(new QueryWrapper<BaseClass>().lambda().eq(BaseClass::getGradeId, gradeId));
+            List<Long> classIds = classList.stream().map(BaseClass::getId).collect(Collectors.toList());
+
+            gradeClassMaps.put(el.get("jianyue_id").toString(), classIds);
+        }
+
         for (Map<String, Object> receiveMsg : receiveMsgs) {
             String updSql = "update course_receive_msg set is_callback = 0 where id = " + receiveMsg.get("id").toString();
             SqlRunnerAdapter.db().update(updSql);
 
             String eduYearSerialNo = receiveMsg.get("edu_year_serial_no").toString();
+            String startDateStr = receiveMsg.get("start_date").toString();
+            String endDateStr = receiveMsg.get("end_date").toString();
+            //删除课表信息
+            String delSql = "delete from course_table where schedule_date between '" + startDateStr + "'" +
+                    " and '" + endDateStr + "'" +
+                    " and class_id in (" + gradeClassMaps.get(eduYearSerialNo).toString().replace("[","").replace("]","")+ ")";
+            SqlRunnerAdapter.db().delete(delSql);
 
-            LocalDate startDateObj = LocalDate.parse(receiveMsg.get("start_date").toString());
-            LocalDate endDateObj = LocalDate.parse(receiveMsg.get("end_date").toString());
+            LocalDate startDateObj = LocalDate.parse(startDateStr);
+            LocalDate endDateObj = LocalDate.parse(endDateStr);
             long between = ChronoUnit.DAYS.between(startDateObj, endDateObj);
             int times = Integer.parseInt(((between / 7) + 1) + "");
 

+ 55 - 0
src/main/resources/mapper/activity/ActivityInfoMapper.xml

@@ -84,4 +84,59 @@
         participant_teacher_name LIKE CONCAT('%',#{dto.loginUserId},'%') OR participant_student_name LIKE CONCAT('%',#{dto.loginUserId},'%')
         )
     </select>
+    <select id="getTodaySchedule" parameterType="com.xjrsoft.module.activity.dto.ActivityInfoPageDto" resultType="com.xjrsoft.module.activity.vo.ActivityInfoPageVo">
+        SELECT t1.id,t1.name,t1.place,t1.start_date,t1.end_date,
+        t1.type, t4.name AS org_name, t1.enroll_end_time, t1.cover_file_id,
+        t1.status,t1.content,t1.category,t5.status AS enroll_status,t2.name as type_cn, 1 as is_enroll FROM activity_info t1
+        LEFT JOIN xjr_dictionary_detail t2 ON t1.type = t2.code
+        LEFT JOIN company_coop t3 ON t1.enterprise_id = t3.id
+        LEFT JOIN xjr_department t4 ON t1.org_id = t4.id
+        LEFT JOIN activity_enroll t5 ON t1.id = t5.activity_info_id
+        WHERE t1.delete_mark = 0 AND t5.user_id = #{dto.loginUserId}
+        <if test="dto.category != null">
+            and t1.category = #{dto.category}
+        </if>
+        <if test="dto.isEffective != null and dto.isEffective == 1">
+            and (t1.status = 1 or t1.status = 2) and NOW() between t1.start_date and t1.end_date
+        </if>
+        UNION
+        SELECT a1.id, a1.club_activities_name AS NAME,a1.activity_location AS place,a1.start_time AS start_date,a1.end_time AS end_date,
+        NULL AS TYPE,NULL AS org_name,NULL AS enroll_end_time,NULL AS cover_file_id,1 AS STATUS,
+        a1.club_activities_content AS content,3 AS category,2 AS enroll_status,
+        a1.activity_type AS type_cn, 1 AS is_enroll
+        FROM club_activities a1 WHERE a1.delete_mark = 0 AND a1.student_id IN
+        (SELECT credential_number FROM xjr_user WHERE id = #{dto.loginUserId})
+        UNION
+        SELECT a2.id, a2.moral_event_name AS NAME,a2.event_address AS place,
+        a2.event_start_time AS start_date,a2.event_end_time AS end_date,NULL AS TYPE,NULL AS org_name,NULL AS enroll_end_time,
+        NULL AS cover_file_id,1 AS status,
+        a2.event_content AS content,4 AS category,2 AS enroll_status
+        , a2.event_type AS type_cn, 1 as is_enroll
+        FROM moral_event a2 WHERE a2.delete_mark = 0 AND
+        (a2.attend_teacher like concat('%',#{dto.loginUserId},'%') OR FIND_IN_SET((
+        SELECT class_id FROM base_student_school_roll WHERE user_id = #{dto.loginUserId}
+        ),a2.attend_class) > 0
+        )
+        UNION
+        SELECT a3.id,a3.training_name AS NAME,a3.training_address AS place,a3.start_time AS start_date, a3.end_time AS end_date,
+        NULL AS TYPE,NULL AS org_name,NULL AS enroll_end_time,NULL AS cover_file_id, STATUS,
+        a3.training_topic AS content,5 AS category,2 AS enroll_status,  NULL AS type_cn, 1 as is_enroll FROM wf_teacher_training a3
+        INNER JOIN wf_teacher_training_participant a4 ON a3.id = a4.wf_teacher_training_id
+        WHERE a3.delete_mark = 0 AND a4.participant_id = #{dto.loginUserId}
+        UNION
+        SELECT id,party_tissue_name AS NAME,event_address AS place,event_start_time AS start_date, event_end_time AS end_date,event_type AS TYPE,
+        NULL AS org_name,NULL AS enroll_end_time,NULL AS cover_file_id,1 AS STATUS, event_content AS content, 6 AS category,
+        2 AS enroll_status, NULL AS type_cn, 1 as is_enroll FROM party_build_event
+        WHERE delete_mark = 0 AND (
+        participant_teacher_name LIKE CONCAT('%',#{dto.loginUserId},'%') OR participant_student_name LIKE CONCAT('%',#{dto.loginUserId},'%')
+        )
+
+        UNION
+        SELECT id,party_tissue_name AS NAME,event_address AS place,event_start_time AS start_date, event_end_time AS end_date,event_type AS TYPE,
+        NULL AS org_name,NULL AS enroll_end_time,NULL AS cover_file_id,1 AS STATUS, event_content AS content, 6 AS category,
+        2 AS enroll_status, NULL AS type_cn, 1 as is_enroll FROM party_build_event
+        WHERE delete_mark = 0 AND (
+        participant_teacher_name LIKE CONCAT('%',#{dto.loginUserId},'%') OR participant_student_name LIKE CONCAT('%',#{dto.loginUserId},'%')
+        )
+    </select>
 </mapper>