Merge branch 'master' of http://git.hchbox.com/yuyou/eladmin into master

# Conflicts:
#	eladmin-system/src/main/java/me/zhengjie/modules/taskrecord/domain/TaskRecord.java
#	eladmin-system/src/main/java/me/zhengjie/modules/taskrecord/rest/TaskRecordController.java
增加建立任务包逻辑
master
土豆兄弟 4 years ago
parent b21eed4d72
commit a641a2ab0c

@ -18,11 +18,11 @@ package me.zhengjie.modules.taskrecord.rest;
import me.zhengjie.annotation.Log;
import me.zhengjie.common.CommonResponse;
import me.zhengjie.common.ResponseCode;
import me.zhengjie.modules.abmessage.rest.vo.AbMessageVO;
import me.zhengjie.modules.taskrecord.domain.TaskRecord;
import me.zhengjie.modules.taskrecord.service.TaskRecordService;
import me.zhengjie.modules.taskrecord.service.dto.TaskRecordDto;
import me.zhengjie.modules.taskrecord.service.dto.TaskRecordQueryCriteria;
import me.zhengjie.task.ProduceLocalFileTask;
import me.zhengjie.task.SendRecordTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
@ -53,7 +53,8 @@ public class TaskRecordController {
@Autowired
private SendRecordTask sendRecordTask;
@Autowired
private ProduceLocalFileTask produceLocalFileTask;
@Log("导出数据")
@ApiOperation("导出数据")
@ -63,6 +64,14 @@ public class TaskRecordController {
taskRecordService.download(taskRecordService.queryAll(criteria), response);
}
@PostMapping
@Log("新增taskRecord")
@ApiOperation("新增taskRecord")
@PreAuthorize("@el.check('taskRecord:add')")
public ResponseEntity<Object> create(@Validated @RequestBody TaskRecord resources){
return new ResponseEntity<>(taskRecordService.create(resources),HttpStatus.CREATED);
}
@GetMapping
@Log("查询taskRecord")
@ApiOperation("查询taskRecord")
@ -71,13 +80,6 @@ public class TaskRecordController {
return new ResponseEntity<>(taskRecordService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增taskRecord")
@ApiOperation("新增taskRecord")
@PreAuthorize("@el.check('taskRecord:add')")
public ResponseEntity<Object> create(@Validated @RequestBody TaskRecord resources){
return new ResponseEntity<>(taskRecordService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改taskRecord")
@ -99,6 +101,24 @@ public class TaskRecordController {
// ================ 自定义功能实现 start ================
/**
*
*
* @param resources
* @return
*/
@PostMapping("/buildTask")
@Log("新建课包任务")
@ApiOperation("新建课包任务")
@PreAuthorize("@el.check('taskRecord:add')")
public ResponseEntity<Object> buildTask(@Validated @RequestBody TaskRecord resources){
// 启动建立课包任务
produceLocalFileTask.doRunTask(resources);
// 返回结果
return new ResponseEntity<>(CommonResponse.createBySuccess(), HttpStatus.OK);
}
/**
* ,,
* @param idList

@ -72,7 +72,11 @@ public class TaskRecordServiceImpl implements TaskRecordService {
@Override
@Transactional(rollbackFor = Exception.class)
public TaskRecordDto create(TaskRecord resources) {
return taskRecordMapper.toDto(taskRecordRepository.save(resources));
// todo 增加新建课包的逻辑
TaskRecordDto taskRecordDto = taskRecordMapper.toDto(taskRecordRepository.save(resources));
return taskRecordDto;
}
@Override

@ -1,6 +1,7 @@
package me.zhengjie.task;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.taskrecord.domain.TaskRecord;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
@ -20,17 +21,18 @@ public class ProduceLocalFileTask {
* ,
*
* @return
* @param task
*/
@Async(value = "ProduceLocalFileTaskExecutor")
public void doRunTask(List<T> list){
public void doRunTask(TaskRecord task){
Long satrtMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
log.info("====== [ task start running, task name is {} ] ======", "ProduceLocalFileTask");
runTask(list);
runTask(task);
Long endMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
log.info("====== [ task start end, task name is {},cost milliSecond is {} ] ======", "ProduceLocalFileTask", (endMilliSecond - satrtMilliSecond));
}
private void runTask(List<T> list) {
private void runTask(TaskRecord task) {
}
}

@ -39,7 +39,7 @@ public class SendRecordTask <T> {
* @return
*/
@Async(value = "SendRecordTaskExecutor")
public void doRunTask(List<T> list){
public void doRunTask(List<Integer> list){
Long satrtMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
log.info("====== [ task start running, task name is {} ] ======", "SendRecordTask");
runTask(list);
@ -47,12 +47,12 @@ public class SendRecordTask <T> {
log.info("====== [ task start end, task name is {},cost milliSecond is {} ] ======", "SendRecordTask", (endMilliSecond - satrtMilliSecond));
}
private void runTask(List<T> list) {
private void runTask(List<Integer> list) {
// 准备所有需要发送任务
List<TaskRecordDto> readySendTasks = new ArrayList<>();
list.forEach(
id->{
TaskRecordDto taskRecordDto = taskRecordService.findById((Integer) id);
TaskRecordDto taskRecordDto = taskRecordService.findById(id);
if (BUILD_STATUS == taskRecordDto.getIsBuild() && StringUtils.isNotBlank(taskRecordDto.getLocalFilePath())){
readySendTasks.add(taskRecordDto);
}

Loading…
Cancel
Save