| @@ -121,4 +121,11 @@ public class JobController { | |||||||
|     public Result getJobList(@RequestParam(required = false) Integer type) { |     public Result getJobList(@RequestParam(required = false) Integer type) { | ||||||
|         return jobService.getJobList(type); |         return jobService.getJobList(type); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("/list/v2") | ||||||
|  |     public Result getJobList(@RequestParam(required = false) Integer type, | ||||||
|  |                              @RequestParam(defaultValue = "1") Integer page, | ||||||
|  |                              @RequestParam(defaultValue = "100") Integer size) { | ||||||
|  |         return jobService.getJobList(type, page, size); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,11 +1,9 @@ | |||||||
| package com.weilab.biology.mapper; | package com.weilab.biology.mapper; | ||||||
|  |  | ||||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||||
| import com.weilab.biology.core.data.dto.JobLessDto; |  | ||||||
| import com.weilab.biology.core.data.po.Job; | import com.weilab.biology.core.data.po.Job; | ||||||
| import org.apache.ibatis.annotations.Mapper; | import org.apache.ibatis.annotations.Mapper; | ||||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||||
| import org.python.modules.itertools.count; |  | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| @@ -22,4 +20,8 @@ public interface JobMapper extends BaseMapper<Job> { | |||||||
|  |  | ||||||
|     List<Job> selectJobList(@Param("type") Integer type); |     List<Job> selectJobList(@Param("type") Integer type); | ||||||
|  |  | ||||||
|  |     List<Job> selectJobListByPage(@Param("type") Integer type, | ||||||
|  |                                   @Param("offset") Integer offset, | ||||||
|  |                                   @Param("count") Integer count); | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -172,6 +172,11 @@ public class JobService { | |||||||
|         return Result.success(jobs.stream().map(JobLessDto::parseJob).collect(Collectors.toList())); |         return Result.success(jobs.stream().map(JobLessDto::parseJob).collect(Collectors.toList())); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public Result getJobList(Integer type, Integer page, Integer size) { | ||||||
|  |         List<Job> jobs = jobMapper.selectJobListByPage(type, (page - 1) * size, size); | ||||||
|  |         return Result.success(jobs.stream().map(JobLessDto::parseJob).collect(Collectors.toList())); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 运行下一个job |      * 运行下一个job | ||||||
|      */ |      */ | ||||||
| @@ -232,7 +237,6 @@ public class JobService { | |||||||
|         String param1 = job.getJobId().toString(); |         String param1 = job.getJobId().toString(); | ||||||
|         String param2 = job.getRequestTime().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + job.getJobId(); |         String param2 = job.getRequestTime().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + job.getJobId(); | ||||||
|  |  | ||||||
|  |  | ||||||
|         String content = null; |         String content = null; | ||||||
|         switch (status) { |         switch (status) { | ||||||
|             case WAIT: |             case WAIT: | ||||||
|   | |||||||
| @@ -43,8 +43,7 @@ | |||||||
|     <select id="selectNextWaitingJob" resultMap="BaseResultMap"> |     <select id="selectNextWaitingJob" resultMap="BaseResultMap"> | ||||||
|         <include refid="JobSql"/> |         <include refid="JobSql"/> | ||||||
|         WHERE status = '${@com.weilab.biology.core.data.enums.JobStatusEnum@WAIT.getKey()}' |         WHERE status = '${@com.weilab.biology.core.data.enums.JobStatusEnum@WAIT.getKey()}' | ||||||
|         ORDER BY request_time |         ORDER BY request_time LIMIT 1 | ||||||
|         LIMIT 1 |  | ||||||
|     </select> |     </select> | ||||||
|     <select id="selectJobList" resultMap="BaseResultMap"> |     <select id="selectJobList" resultMap="BaseResultMap"> | ||||||
|         <include refid="JobLessSql"/> |         <include refid="JobLessSql"/> | ||||||
| @@ -52,9 +51,20 @@ | |||||||
|             <if test="type != null"> |             <if test="type != null"> | ||||||
|                 AND type = #{type} |                 AND type = #{type} | ||||||
|             </if> |             </if> | ||||||
|             AND create_time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH) |             AND request_time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH) | ||||||
|         </where> |         </where> | ||||||
|         ORDER BY job_id DESC |         ORDER BY job_id DESC | ||||||
| <!--        LIMIT #{count}--> |         <!--        LIMIT #{count}--> | ||||||
|  |     </select> | ||||||
|  |  | ||||||
|  |     <select id="selectJobListByPage" resultMap="BaseResultMap"> | ||||||
|  |         <include refid="JobLessSql"/> | ||||||
|  |         <where> | ||||||
|  |             <if test="type != null"> | ||||||
|  |                 AND type = #{type} | ||||||
|  |             </if> | ||||||
|  |         </where> | ||||||
|  |         ORDER BY job_id DESC | ||||||
|  |             LIMIT #{offset}, #{count} | ||||||
|     </select> |     </select> | ||||||
| </mapper> | </mapper> | ||||||
		Reference in New Issue
	
	Block a user