parent
fd9a20a400
commit
b1d580117d
2 changed files with 78 additions and 0 deletions
@ -0,0 +1,76 @@ |
||||
package com.msdw.tms.controller; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.msdw.tms.entity.ExperimentalTeachingEntity; |
||||
import com.msdw.tms.service.ExperimentalTeachingService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.scheduling.annotation.Scheduled; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.time.LocalDateTime; |
||||
import java.time.format.DateTimeFormatter; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* @ProjectName: gzedu |
||||
* @Package: com.huoran.user.controller |
||||
* @ClassName: test |
||||
* @Description: java类作用描述 |
||||
* @Author: Maureen.Rong |
||||
* @CreateDate: 2020/12/7 11:35 |
||||
* @UpdateDate: 2020/12/7 11:35 |
||||
* @Version: 1.0 |
||||
*/ |
||||
@Component |
||||
@RestController |
||||
public class ClockScheduledController { |
||||
|
||||
@Autowired |
||||
public ExperimentalTeachingService service; |
||||
|
||||
//考核自启动
|
||||
@Scheduled(fixedRate = 1000) |
||||
public void timer1() { |
||||
QueryWrapper<ExperimentalTeachingEntity> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.eq("type", 2); |
||||
queryWrapper.eq("is_del", 0); |
||||
queryWrapper.eq("status", 1); |
||||
queryWrapper.last(" AND start_time = now() "); |
||||
List<ExperimentalTeachingEntity> list = service.list(queryWrapper); |
||||
if (list.size() > 0) { |
||||
for (ExperimentalTeachingEntity experimentalTeaching : list) { |
||||
//启动考核
|
||||
ExperimentalTeachingEntity update = new ExperimentalTeachingEntity(); |
||||
update.setStatus(2); |
||||
update.setId(experimentalTeaching.getId()); |
||||
service.updateById(update); |
||||
} |
||||
} |
||||
|
||||
|
||||
QueryWrapper<ExperimentalTeachingEntity> queryWrapper1 = new QueryWrapper<>(); |
||||
queryWrapper1.eq("type", 2); |
||||
queryWrapper1.eq("is_del", 0); |
||||
queryWrapper1.eq("status", 2); |
||||
queryWrapper1.last(" AND start_time = now() "); |
||||
List<ExperimentalTeachingEntity> list1 = service.list(queryWrapper); |
||||
if (list1.size() > 0) { |
||||
for (ExperimentalTeachingEntity experimentalTeaching : list1) { |
||||
//停止考核
|
||||
ExperimentalTeachingEntity update = new ExperimentalTeachingEntity(); |
||||
update.setStatus(3); |
||||
update.setId(experimentalTeaching.getId()); |
||||
service.updateById(update); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
public static void main(String[] args) { |
||||
new ClockScheduledController().timer1(); |
||||
} |
||||
} |
Loading…
Reference in new issue