刘力
3 years ago
14 changed files with 324 additions and 19 deletions
-
7APIService/src/main/java/com/storeroom/controller/TestApiServiceController.java
-
5APIService/src/main/java/com/storeroom/service/impl/ApiServiceImpl.java
-
111common/src/main/java/com/storeroom/utils/MacUtil.java
-
11common/src/test/java/IPTest.java
-
47storeroom/src/main/java/com/storeroom/modules/device/controller/BindDeviceController.java
-
9storeroom/src/main/java/com/storeroom/modules/device/domain/DeviceArchivesTag.java
-
2storeroom/src/main/java/com/storeroom/modules/device/repository/DeviceArchivesTagRepository.java
-
2storeroom/src/main/java/com/storeroom/modules/device/service/DeviceArchivesTagService.java
-
6storeroom/src/main/java/com/storeroom/modules/device/service/impl/DeviceArchivesTagImpl.java
-
1storeroom/src/main/java/com/storeroom/modules/device/service/impl/DeviceImpl.java
-
111system/src/main/java/com/storeroom/modules/quartz/controller/QuartzJobController.java
-
3system/src/main/java/com/storeroom/modules/quartz/service/QuartzJobService.java
-
4system/src/main/java/com/storeroom/modules/quartz/service/impl/QuartzJobServiceImpl.java
-
24system/src/main/java/com/storeroom/modules/quartz/utils/FirstJob.java
@ -0,0 +1,11 @@ |
|||||
|
import com.storeroom.utils.MacUtil; |
||||
|
import org.junit.jupiter.api.Test; |
||||
|
|
||||
|
public class IPTest { |
||||
|
|
||||
|
@Test |
||||
|
public void iptest() { |
||||
|
String ip = MacUtil.getIpAddress(); |
||||
|
System.out.println(ip); |
||||
|
} |
||||
|
} |
@ -0,0 +1,111 @@ |
|||||
|
package com.storeroom.modules.quartz.controller; |
||||
|
|
||||
|
|
||||
|
import com.storeroom.annotaion.rest.AnonymousGetMapping; |
||||
|
import com.storeroom.exception.BaseException; |
||||
|
import com.storeroom.modules.quartz.domain.QuartzJob; |
||||
|
import com.storeroom.modules.quartz.service.QuartzJobService; |
||||
|
import com.storeroom.modules.quartz.service.dto.JobQueryCriteria; |
||||
|
import com.storeroom.utils.ApiResponse; |
||||
|
import com.storeroom.utils.enums.ResponseStatus; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.io.IOException; |
||||
|
import java.util.Set; |
||||
|
|
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@RequiredArgsConstructor |
||||
|
@RequestMapping("/api/jobs") |
||||
|
@Api(tags = "系统:定时任务管理") |
||||
|
public class QuartzJobController { |
||||
|
|
||||
|
private static final String ENTITY_NAME = "quartzJob"; |
||||
|
private final QuartzJobService quartzJobService; |
||||
|
|
||||
|
@ApiOperation("查询定时任务") |
||||
|
@AnonymousGetMapping |
||||
|
// @PreAuthorize("@el.check('timing:list')") |
||||
|
public ApiResponse<Object> queryQuartzJob(JobQueryCriteria criteria, Pageable pageable) { |
||||
|
return ApiResponse.success(quartzJobService.queryAll(criteria, pageable)); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("导出任务数据") |
||||
|
@GetMapping(value = "/download") |
||||
|
//@PreAuthorize("@el.check('timing:list')") |
||||
|
public void exportQuartzJob(HttpServletResponse response, JobQueryCriteria criteria) throws IOException { |
||||
|
quartzJobService.download(quartzJobService.queryAll(criteria), response); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("导出日志数据") |
||||
|
@GetMapping(value = "/logs/download") |
||||
|
//@PreAuthorize("@el.check('timing:list')") |
||||
|
public void exportQuartzJobLog(HttpServletResponse response, JobQueryCriteria criteria) throws IOException { |
||||
|
quartzJobService.downloadLog(quartzJobService.queryAllLog(criteria), response); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("查询任务执行日志") |
||||
|
@GetMapping(value = "/logs") |
||||
|
//@PreAuthorize("@el.check('timing:list')") |
||||
|
public ApiResponse<Object> queryQuartzJobLog(JobQueryCriteria criteria, Pageable pageable) { |
||||
|
return ApiResponse.success(quartzJobService.queryAllLog(criteria, pageable)); |
||||
|
} |
||||
|
|
||||
|
// @Log("新增定时任务") |
||||
|
@ApiOperation("新增定时任务") |
||||
|
@PostMapping |
||||
|
// @PreAuthorize("@el.check('timing:add')") |
||||
|
public ApiResponse<Object> createQuartzJob(@Validated @RequestBody QuartzJob resources) { |
||||
|
if (resources.getId() != null) { |
||||
|
throw new BaseException("A new " + ENTITY_NAME + " cannot already have an ID"); |
||||
|
} |
||||
|
quartzJobService.create(resources); |
||||
|
return ApiResponse.success(ResponseStatus.SUCCESS); |
||||
|
} |
||||
|
|
||||
|
// @Log("修改定时任务") |
||||
|
@ApiOperation("修改定时任务") |
||||
|
@PutMapping |
||||
|
// @PreAuthorize("@el.check('timing:edit')") |
||||
|
public ApiResponse<Object> updateQuartzJob(@Validated(QuartzJob.Update.class) @RequestBody QuartzJob resources) { |
||||
|
quartzJobService.update(resources); |
||||
|
return ApiResponse.success(ResponseStatus.SUCCESS); |
||||
|
} |
||||
|
|
||||
|
// @Log("更改定时任务状态") |
||||
|
@ApiOperation("更改定时任务状态") |
||||
|
@PutMapping(value = "/{id}") |
||||
|
// @PreAuthorize("@el.check('timing:edit')") |
||||
|
public ApiResponse<Object> updateQuartzJobStatus(@PathVariable Long id) { |
||||
|
quartzJobService.updateIsPause(quartzJobService.findById(id)); |
||||
|
return ApiResponse.success(ResponseStatus.SUCCESS); |
||||
|
} |
||||
|
|
||||
|
// @Log("执行定时任务") |
||||
|
@ApiOperation("执行定时任务") |
||||
|
@PutMapping(value = "/exec/{id}") |
||||
|
// @PreAuthorize("@el.check('timing:edit')") |
||||
|
public ApiResponse<Object> executionQuartzJob(@PathVariable Long id) { |
||||
|
quartzJobService.execution(quartzJobService.findById(id)); |
||||
|
return ApiResponse.success(ResponseStatus.SUCCESS); |
||||
|
} |
||||
|
|
||||
|
//@Log("删除定时任务") |
||||
|
@ApiOperation("删除定时任务") |
||||
|
@DeleteMapping |
||||
|
// @PreAuthorize("@el.check('timing:del')") |
||||
|
public ApiResponse<Object> deleteQuartzJob(@RequestBody Set<Long> ids) { |
||||
|
quartzJobService.delete(ids); |
||||
|
return ApiResponse.success(ResponseStatus.SUCCESS); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.storeroom.modules.quartz.utils; |
||||
|
|
||||
|
import org.quartz.Job; |
||||
|
import org.quartz.JobExecutionContext; |
||||
|
import org.quartz.JobExecutionException; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
public class FirstJob implements Job { |
||||
|
|
||||
|
private static Logger _log = LoggerFactory.getLogger(FirstJob.class); |
||||
|
|
||||
|
public FirstJob() { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public void execute(JobExecutionContext context) |
||||
|
throws JobExecutionException { |
||||
|
_log.error("Hello Job执行时间: " + new Date()); |
||||
|
|
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue