| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package com.template.controller;
- import com.alibaba.fastjson.JSONArray;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.template.model.pojo.ClassSchedule;
- import com.template.model.pojo.TbCourseScheduling;
- import com.template.model.result.CommonResult;
- import com.template.services.ClassScheduleService;
- import com.template.services.TbCourseSchedulingService;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- import java.util.Map;
- /**
- * <p>
- * 课程安排 前端控制器
- * </p>
- *
- * @author ceshi
- * @since 2024-07-09
- */
- @RestController
- @RequestMapping("/auto/tb-course-scheduling")
- public class TbCourseSchedulingController {
- private static final Logger log = LoggerFactory.getLogger(TbCourseSchedulingController.class);
- @Autowired
- private TbCourseSchedulingService tbCourseSchedulingService;
- @Autowired
- private ClassScheduleService classScheduleService;
- @GetMapping("/queryGridPreDetail")
- @Scheduled(cron="0 30 0/2 * * ?")
- // @Scheduled(cron="0/20 * * * * ?")
- public void energyConsumption() {
- String xuenian="2024-2025";
- String xueqi="1";
- String deleteFlag="自动导入";
- List<Map<String,Object>> tbList=tbCourseSchedulingService.listAll(xuenian,xueqi);
- log.info("查询条数"+tbList.size());
- if (tbList.isEmpty()){
- log.info("课表导入失败,获取课表为空");
- return;
- }
- int a=classScheduleService.removeByRemark(deleteFlag);
- log.info("彻底删除条数"+a);
- JSONArray jsonArray = new JSONArray();
- jsonArray.addAll(tbList);
- List<ClassSchedule> list = jsonArray.toJavaList(ClassSchedule.class);
- log.info("导入条数"+list.size());
- boolean b=classScheduleService.saveBatch(list);
- log.info("课表导入执行结果"+b);
- }
- }
|