123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- package com.yihu.wlyy.statistics.controller;
- import com.yihu.wlyy.statistics.job.business.QuartzHelper;
- import com.yihu.wlyy.statistics.service.JobService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.MediaType;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- /**
- * 任务启动
- *
- * @author chenweida
- */
- @RestController
- @RequestMapping(value = "/job", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
- @Api(description = "后台-任务控制")
- public class JobController extends BaseController {
- @Autowired
- private JobService jobService;
- /**
- * 启动任务
- *
- * @param id id
- * @return
- */
- @ApiOperation(value = "根据ID立即单个任务")
- @RequestMapping(value = "startNowById", method = RequestMethod.GET)
- public String startNowById(
- @ApiParam(name = "id", value = "任务ID", required = true)@RequestParam(value = "id", required = true) String id) {
- try {
- jobService.cleanCache();
- jobService.startNowById(id);
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 生成过去几天的数据
- *
- * @param day
- * @return
- */
- @ApiOperation(value = "生成过去几天的数据")
- @RequestMapping(value = "productDataByDay", method = RequestMethod.GET)
- public String productDataByDay( @ApiParam(name = "day", value = "距离今天的天数(如果是要生成昨天的数据,day=1)")@RequestParam(value = "day", required = true) int day) {
- try {
- jobService.cleanCache();
- jobService.productDataByDay(day);
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 生成过去某一天的全部的数据
- *
- * @param day
- * @return
- */
- @ApiOperation(value = "生成过去某一天的全部的数据")
- @RequestMapping(value = "productDataByOneDay", method = RequestMethod.GET)
- public String productDataByOneDay( @ApiParam(name = "day", value = "yyyy-MM-dd")@RequestParam(value = "day", required = true)String day) {
- try {
- jobService.cleanCache();
- jobService.productDataByOneDay(day);
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 生成过去某一天到某一天的全部的数据
- *
- * @param start
- * @param end
- * @return
- */
- @ApiOperation(value = "生成过去某一天到某一天的全部的数据(包含头尾)")
- @RequestMapping(value = "productDataByDayToDay", method = RequestMethod.GET)
- public String productDataByDayToDay( @ApiParam(name = "start", value = "yyyy-MM-dd", required = true)@RequestParam(value = "start", required = true)String start,
- @ApiParam(name = "end", value = "yyyy-MM-dd", required = true)@RequestParam(value = "end", required = true)String end) {
- try {
- jobService.cleanCache();
- jobService.productDataByDayToDay(start,end);
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 生成过去某一天到某一天的某个指标的数据
- *
- * @param start
- * @param end
- * @return
- */
- @ApiOperation(value = "生成过去某一天到某一天的某个指标的数据(包含头尾)")
- @RequestMapping(value = "productDataByDayToDayAndId", method = RequestMethod.GET)
- public String productDataByDayToDayAndId( @ApiParam(name = "start", value = "yyyy-MM-dd")@RequestParam(value = "start", required = true)String start,
- @ApiParam(name = "end", value = "yyyy-MM-dd")@RequestParam(value = "end", required = true)String end,
- @ApiParam(name = "id", value = "任务id")@RequestParam(value = "id", required = true)String id) {
- try {
- jobService.cleanCache();
- jobService.productDataByDayToDayAndId(start,end,id);
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 生成过去某一天的某一个指标的数据
- *
- * @param day
- * @return
- */
- @ApiOperation(value = "生成过去某一天的全部的数据")
- @RequestMapping(value = "productDataByOneDayWithId", method = RequestMethod.GET)
- public String productDataByOneDayWithId(
- @ApiParam(name = "day", value = "yyyy-MM-dd")@RequestParam(value = "day", required = true)String day,
- @ApiParam(name = "id", value = "任务id")@RequestParam(value = "id", required = true)String id) {
- try {
- jobService.cleanCache();
- jobService.productDataByOneDayWithId(day, id);
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 生成过去到现在的全部的数据
- *
- * @param day
- * @return
- */
- @ApiOperation(value = "生成过去到现在的全部的数据")
- @RequestMapping(value = "productDataByDayAndId", method = RequestMethod.GET)
- public String productDataByDayAndId(
- @ApiParam(name = "day", value = "距离今天的天数(如果是要生成昨天的数据,day=1)")@RequestParam(value = "day", required = true) int day,
- @ApiParam(name="id",required=true)@RequestParam(value = "id", required = true) String id) {
- try {
- jobService.cleanCache();
- jobService.productDataByDayAndId(day, id);
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 启动任务
- *
- * @param id id
- * @return
- */
- @ApiOperation(value = "启动单个任务")
- @RequestMapping(value = "startById", method = RequestMethod.GET)
- public String startById(
- @ApiParam(name="id",value="任务id",required=true)@RequestParam(value = "id", required = true) String id) {
- try {
- jobService.startById(id);
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 停止任务
- *
- * @param id id
- * @return
- */
- @ApiOperation(value = "停止单个任务")
- @RequestMapping(value = "stopById", method = RequestMethod.GET)
- public String stopById(@ApiParam(name="id",value="任务id",required=true)@RequestParam(value = "id", required = true)String id) {
- try {
- jobService.stopById(id);
- return success("停止成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 停止所有任务
- *
- * @return
- */
- @ApiOperation(value = "停止所有任务")
- @RequestMapping(value = "stopAll", method = RequestMethod.GET)
- public String stopAll() {
- try {
- jobService.stopAll();
- return success("停止成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 启动判断的任务
- *
- * @return
- */
- @ApiOperation(value = "启动檢查的任务")
- @RequestMapping(value = "startCheckSignJob", method = RequestMethod.GET)
- public String startCheckSignJob() {
- try {
- jobService.startCheckSignJob();
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 停止判断的任务
- *
- * @return
- */
- @ApiOperation(value = "停止檢查的任务")
- @RequestMapping(value = "stopCheckSignJob", method = RequestMethod.GET)
- public String stopCheckSignJob() {
- try {
- jobService.stopCheckSignJob();
- return success("停止成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 启动判断的任务
- *
- * @return
- */
- @ApiOperation(value = "启动清除缓存的任务")
- @RequestMapping(value = "startCleanCacheJob", method = RequestMethod.GET)
- public String startCleanCacheJob() {
- try {
- jobService.startCleanCacheJob();
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 停止判断的任务
- *
- * @return
- */
- @ApiOperation(value = "停止清除缓存的任务")
- @RequestMapping(value = "stopCleanCacheJob", method = RequestMethod.GET)
- public String stopCleanCacheJob() {
- try {
- jobService.stopCleanCacheJob();
- return success("停止成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 启动所有任务
- *
- * @return
- */
- @ApiOperation(value = "启动所有任务")
- @RequestMapping(value = "startAll", method = RequestMethod.GET)
- public String startAll() {
- try {
- jobService.startAll();
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- @ApiOperation(value = "清除緩存")
- @RequestMapping(value = "cleanCache", method = RequestMethod.GET)
- public String cleanCache() {
- try {
- jobService.cleanCache();
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- @ApiOperation(value = "查看緩存情况")
- @RequestMapping(value = "seeCache", method = RequestMethod.GET)
- public String seeCache() {
- try {
- String message=jobService.seeCache();
- return write(200,message);
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 启动健康信息生成的任务
- *
- * @return
- */
- @ApiOperation(value = "启动健康信息生成的任务")
- @RequestMapping(value = "startHealthMessageJob", method = RequestMethod.GET)
- public String startHealthMessageJob() {
- try {
- jobService.startHealthMessageJob();
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 停止判断的任务
- *
- * @return
- */
- @ApiOperation(value = "停止健康信息生成的任务")
- @RequestMapping(value = "stopHealthMessageJob", method = RequestMethod.GET)
- public String stopHealthMessageJob() {
- try {
- jobService.stopHealthMessageJob();
- return success("停止成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- //@RequestMapping(value = "startaaaa", method = RequestMethod.GET)
- public String startaaaa() {
- try {
- jobService.startaaaa();
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 生成过去某一天的健康消息
- *
- * @param day
- * @return
- */
- @ApiOperation(value = "生成过去某一天的健康消息")
- @RequestMapping(value = "productHealthDataByOneDay", method = RequestMethod.GET)
- public String productHealthDataByOneDay( @ApiParam(name = "day", value = "yyyy-MM-dd")
- @RequestParam(value = "day", required = true)String day) {
- try {
- jobService.productHealthDataByOneDay(day);
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 生成过去某一天到某一天的某个指标的数据
- *
- * @param start
- * @param end
- * @return
- */
- @ApiOperation(value = "生成过去某一天到某一天的健康消息(包含头尾)")
- @RequestMapping(value = "productHealthDataByDayToDay", method = RequestMethod.GET)
- public String productHealthDataByDayToDay( @ApiParam(name = "start", value = "yyyy-MM-dd")@RequestParam(value = "start", required = true)String start,
- @ApiParam(name = "end", value = "yyyy-MM-dd")@RequestParam(value = "end", required = true)String end
- ) {
- try {
- jobService.productHealthDataByDayToDay(start,end);
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 启动每天的统计报表任务
- *
- * @return
- */
- @ApiOperation(value = "启动每天的统计报表任务")
- @RequestMapping(value = "startEveryDayReportJob", method = RequestMethod.GET)
- public String startEveryDayReportJob() {
- try {
- jobService.startEveryDayReportJob();
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 停止每天的统计报表任务
- *
- * @return
- */
- @ApiOperation(value = "停止每天的统计报表任务")
- @RequestMapping(value = "stopEveryDayReportJob", method = RequestMethod.GET)
- public String stopEveryDayReportJob() {
- try {
- jobService.stopEveryDayReportJob();
- return success("停止成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 启动通知任务
- *
- * @return
- */
- @ApiOperation(value = "启动通知任务")
- @RequestMapping(value = "startNoticeJob", method = RequestMethod.GET)
- public String startNoticeJob() {
- try {
- jobService.startNoticeJob();
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- /**
- * 启动通知任务
- *
- * @return
- */
- @ApiOperation(value = "停止通知任务")
- @RequestMapping(value = "stopNoticeJob", method = RequestMethod.GET)
- public String stopNoticeJob() {
- try {
- jobService.stopNoticeJob();
- return success("启动成功!");
- } catch (Exception e) {
- error(e);
- return invalidUserException(e, -1, "启动失败:" + e.getMessage());
- }
- }
- }
|