1、前端页面工具模块历史上的今天功能实现

2、预警服务启动or(定时任务)清空上一日的当日调用次数
pull/254/head
xjs 4 years ago
parent 66675bcc87
commit 1df4784507

@ -15,6 +15,7 @@
<el-form label-width="80px" label-position="right">
<el-form-item label="节假日" label-width="auto">
<el-popover
v-loading="loading1"
placement="bottom"
width="400"
v-model="holidayVisible">
@ -39,6 +40,7 @@
<el-form-item label="MM图片" label-width="auto">
<el-popover
v-loading="loading2"
placement="bottom"
width="988"
v-model="beautyPictureVisible">
@ -61,10 +63,22 @@
<el-form-item label="历史今天" label-width="auto">
<el-popover
placement="bottom"
width="988"
v-loading="loading3"
placement="right"
width="400"
v-model="historyTodayVisible">
<div v-for="data in historyTodayData" v-loading="loading3">
<span>
{{ data.date }}
</span>
<br>
<span style="font-size: 12px">
{{ data.title }}
</span>
<el-divider><i class="el-icon-chat-round"></i></el-divider>
</div>
<el-button type="primary" icon="el-icon-search" @click="getHistoryToday()" size="mini"
slot="reference">搜索
</el-button>
@ -199,6 +213,7 @@ export default {
//
loading1: false,
loading2: false,
loading3: false,
}
@ -211,8 +226,12 @@ export default {
methods: {
//
getHistoryToday() {
this.loading3 = true
getHistoryToday().then(res => {
this.loading3 = false
this.historyTodayData = res.data
}).catch(err =>{
this.loading3 = false
})
},
@ -222,7 +241,9 @@ export default {
getHoliday().then(res => {
this.loading1 = false
this.holidayData = res.data
});
}).catch(err =>{
this.loading3 = false
})
},
//mm
@ -236,6 +257,8 @@ export default {
res.data.forEach(data => {
this.pictureList.push(data.imageUrl)
})
}).catch(err =>{
this.loading3 = false
})
},

@ -1,19 +0,0 @@
package com.xjs.run;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
/**
* springboot
* @author xiejs
* @since 2022-01-19
*/
@Component
public class ApplicationRunnerImpl implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
System.out.println("-----------------启动成功!!!---------------------");
}
}

@ -165,7 +165,7 @@ public class ApiToolsServiceImpl implements ApiToolsService {
public List<ApiHistoryToday> getHistoryTodayList() {
List<ApiHistoryToday> historyTodayList = historyTodayFactory.apiDataList();
if (CollUtil.isNotEmpty(historyTodayList)) {
return historyTodayList.stream().limit(5).collect(Collectors.toList());
return historyTodayList.stream().limit(7).collect(Collectors.toList());
}else {
throw new ApiException("获取历史上的今天api调用异常");
}

@ -30,10 +30,10 @@ public class DeleteRepeatTask {
/**
* 2022-01-07 07:00:00
* 2022-01-07 08:00:00
* 2022-01-07 09:00:00
* 2022-01-07 10:00:00
* 2022-01-07 07:00:00<br>
* 2022-01-07 08:00:00<br>
* 2022-01-07 09:00:00<br>
* 2022-01-07 10:00:00<br>
*/
@Scheduled(cron = "0 0 10,14,20 * * ? ")
public void execute() {

@ -5,6 +5,7 @@ import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* @author xiejs
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@EnableScheduling
public class XjsWarningApp {
public static void main(String[] args) {
SpringApplication.run(XjsWarningApp.class, args);

@ -0,0 +1,33 @@
package com.xjs.handler;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.xjs.domain.ApiRecord;
import java.util.Date;
import java.util.List;
/**
*
* @author xiejs
* @since 2022-01-21
*/
public class RecordDateHandler {
protected List<ApiRecord> handleDate(List<ApiRecord> apiRecordList) {
if (CollUtil.isNotEmpty(apiRecordList)) {
apiRecordList.forEach(apiRecord -> {
String dateTime = DateUtil.formatDateTime(apiRecord.getUpdateTime());
Date date = DateUtil.parseDate(dateTime).toJdkDate();
//当前时间和最后一次修改时间间隔天数超过1 就清零)
long compareTime = DateUtil.between(date, new Date(), DateUnit.DAY);
if (compareTime > 0) {
apiRecord.setDayCount(0L);
}
});
}
return apiRecordList;
}
}

@ -0,0 +1,35 @@
package com.xjs.run;
import com.xjs.domain.ApiRecord;
import com.xjs.handler.RecordDateHandler;
import com.xjs.service.ApiWarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* springboot
* @author xiejs
* @since 2022-01-19
*/
@Component
public class ApplicationRunnerImpl extends RecordDateHandler implements ApplicationRunner {
@Autowired
private ApiWarningService apiWarningService;
@Override
public void run(ApplicationArguments args) throws Exception {
System.out.println("-----------------启动成功!!!---------------------");
//启动后处理每日预警数量
List<ApiRecord> apiRecordList = apiWarningService.selectApiRecordList(new ApiRecord());
List<ApiRecord> handleDate = super.handleDate(apiRecordList);
handleDate.forEach(data ->{
apiWarningService.updateApiRecordByUrl(data);
});
}
}

@ -0,0 +1,50 @@
package com.xjs.task;
import com.xjs.domain.ApiRecord;
import com.xjs.handler.RecordDateHandler;
import com.xjs.service.ApiWarningService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
* @author xiejs
* @since 2022-01-21
*/
@Component
@Log4j2
public class WarningTask extends RecordDateHandler {
@Autowired
private ApiWarningService apiWarningService;
/**
* api<br>
* 10:<br>
* 2022-01-22 00:00:10<br>
* 2022-01-23 00:00:10<br>
* 2022-01-24 00:00:10<br>
* 2022-01-25 00:00:10<br>
* 2022-01-26 00:00:10<br>
* 2022-01-27 00:00:10<br>
* 2022-01-28 00:00:10<br>
* 2022-01-29 00:00:10<br>
* 2022-01-30 00:00:10<br>
* 2022-01-31 00:00:10<br>
*/
@Scheduled(cron = "10 0 0 * * ? ")
public void handleRecordDate() {
List<ApiRecord> apiRecordList = apiWarningService.selectApiRecordList(new ApiRecord());
List<ApiRecord> handleDate = super.handleDate(apiRecordList);
handleDate.forEach(data ->{
apiWarningService.updateApiRecordByUrl(data);
});
log.info("定时任务处理预警api信息的每天调用次数完毕");
}
}
Loading…
Cancel
Save