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.annotation.Log;
import me.zhengjie.common.CommonResponse; import me.zhengjie.common.CommonResponse;
import me.zhengjie.common.ResponseCode; 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.domain.TaskRecord;
import me.zhengjie.modules.taskrecord.service.TaskRecordService; import me.zhengjie.modules.taskrecord.service.TaskRecordService;
import me.zhengjie.modules.taskrecord.service.dto.TaskRecordDto; import me.zhengjie.modules.taskrecord.service.dto.TaskRecordDto;
import me.zhengjie.modules.taskrecord.service.dto.TaskRecordQueryCriteria; import me.zhengjie.modules.taskrecord.service.dto.TaskRecordQueryCriteria;
import me.zhengjie.task.ProduceLocalFileTask;
import me.zhengjie.task.SendRecordTask; import me.zhengjie.task.SendRecordTask;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -53,7 +53,8 @@ public class TaskRecordController {
@Autowired @Autowired
private SendRecordTask sendRecordTask; private SendRecordTask sendRecordTask;
@Autowired
private ProduceLocalFileTask produceLocalFileTask;
@Log("导出数据") @Log("导出数据")
@ApiOperation("导出数据") @ApiOperation("导出数据")
@ -63,6 +64,14 @@ public class TaskRecordController {
taskRecordService.download(taskRecordService.queryAll(criteria), response); 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 @GetMapping
@Log("查询taskRecord") @Log("查询taskRecord")
@ApiOperation("查询taskRecord") @ApiOperation("查询taskRecord")
@ -71,13 +80,6 @@ public class TaskRecordController {
return new ResponseEntity<>(taskRecordService.queryAll(criteria,pageable),HttpStatus.OK); 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 @PutMapping
@Log("修改taskRecord") @Log("修改taskRecord")
@ -99,6 +101,24 @@ public class TaskRecordController {
// ================ 自定义功能实现 start ================ // ================ 自定义功能实现 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 * @param idList

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

@ -1,6 +1,7 @@
package me.zhengjie.task; package me.zhengjie.task;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.taskrecord.domain.TaskRecord;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -20,17 +21,18 @@ public class ProduceLocalFileTask {
* , * ,
* *
* @return * @return
* @param task
*/ */
@Async(value = "ProduceLocalFileTaskExecutor") @Async(value = "ProduceLocalFileTaskExecutor")
public void doRunTask(List<T> list){ public void doRunTask(TaskRecord task){
Long satrtMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli(); Long satrtMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
log.info("====== [ task start running, task name is {} ] ======", "ProduceLocalFileTask"); log.info("====== [ task start running, task name is {} ] ======", "ProduceLocalFileTask");
runTask(list); runTask(task);
Long endMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli(); Long endMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
log.info("====== [ task start end, task name is {},cost milliSecond is {} ] ======", "ProduceLocalFileTask", (endMilliSecond - satrtMilliSecond)); 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 * @return
*/ */
@Async(value = "SendRecordTaskExecutor") @Async(value = "SendRecordTaskExecutor")
public void doRunTask(List<T> list){ public void doRunTask(List<Integer> list){
Long satrtMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli(); Long satrtMilliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
log.info("====== [ task start running, task name is {} ] ======", "SendRecordTask"); log.info("====== [ task start running, task name is {} ] ======", "SendRecordTask");
runTask(list); runTask(list);
@ -47,12 +47,12 @@ public class SendRecordTask <T> {
log.info("====== [ task start end, task name is {},cost milliSecond is {} ] ======", "SendRecordTask", (endMilliSecond - satrtMilliSecond)); 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<TaskRecordDto> readySendTasks = new ArrayList<>();
list.forEach( list.forEach(
id->{ id->{
TaskRecordDto taskRecordDto = taskRecordService.findById((Integer) id); TaskRecordDto taskRecordDto = taskRecordService.findById(id);
if (BUILD_STATUS == taskRecordDto.getIsBuild() && StringUtils.isNotBlank(taskRecordDto.getLocalFilePath())){ if (BUILD_STATUS == taskRecordDto.getIsBuild() && StringUtils.isNotBlank(taskRecordDto.getLocalFilePath())){
readySendTasks.add(taskRecordDto); readySendTasks.add(taskRecordDto);
} }

Loading…
Cancel
Save