bobol
7 months ago
10 changed files with 176 additions and 68 deletions
@ -0,0 +1,38 @@ |
|||||
|
package com.lzbi.quartz.controller; |
||||
|
|
||||
|
import com.lzbi.common.core.domain.AjaxResult; |
||||
|
import com.lzbi.quartz.service.IBizJobService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/bizJob") |
||||
|
public class BizJobController { |
||||
|
|
||||
|
@Autowired |
||||
|
private IBizJobService bizJobService; |
||||
|
|
||||
|
/** |
||||
|
* 执行同步iot数据任务 |
||||
|
* @param startDate |
||||
|
* @param endDate |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/syncIotSystemTask") |
||||
|
public AjaxResult syncIotSystemTask(String startDate, String endDate) { |
||||
|
bizJobService.syncIotSystemTask(startDate, endDate); |
||||
|
return AjaxResult.success(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 执行自动审核任务 |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/autoAuditTask") |
||||
|
public AjaxResult autoAuditTask() { |
||||
|
bizJobService.autoAuditTask(); |
||||
|
return AjaxResult.success(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.lzbi.quartz.service; |
||||
|
|
||||
|
public interface IBizJobService { |
||||
|
|
||||
|
/** |
||||
|
* 执行同步iot数据 |
||||
|
* @param startDateStr |
||||
|
* @param endDateStr |
||||
|
*/ |
||||
|
void syncIotSystemTask(String startDateStr, String endDateStr); |
||||
|
|
||||
|
/** |
||||
|
* 执行自动审核任务 |
||||
|
*/ |
||||
|
void autoAuditTask(); |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package com.lzbi.quartz.service.impl; |
||||
|
|
||||
|
import com.lzbi.quartz.service.IBizJobService; |
||||
|
import com.lzbi.quartz.task.AutoAuditTask; |
||||
|
import com.lzbi.quartz.task.SyncIotSystemTask; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.scheduling.annotation.Async; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
|
||||
|
@Service |
||||
|
public class BizJobServiceImpl implements IBizJobService { |
||||
|
|
||||
|
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
||||
|
|
||||
|
@Autowired |
||||
|
private SyncIotSystemTask syncIotSystemTask; |
||||
|
|
||||
|
@Autowired |
||||
|
private AutoAuditTask autoAuditTask; |
||||
|
|
||||
|
@Async |
||||
|
@Override |
||||
|
public void syncIotSystemTask(String startDateStr, String endDateStr) { |
||||
|
LocalDate endDate = LocalDate.parse(endDateStr, DATE_FORMATTER); |
||||
|
for (LocalDate startDate = LocalDate.parse(startDateStr, DATE_FORMATTER); startDate.isBefore(endDate) ; startDate = startDate.plusDays(1)) { |
||||
|
syncIotSystemTask.syncIotParams(false, startDate.format(DATE_FORMATTER)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Async |
||||
|
@Override |
||||
|
public void autoAuditTask() { |
||||
|
autoAuditTask.auditParamsBill(); |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue