新增每天清理一个月前的设备流水
This commit is contained in:
parent
1be13586d6
commit
aa1c7f7a9f
@ -6,8 +6,10 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
|
||||
@EnableScheduling
|
||||
@EnableCustomConfig
|
||||
@SpringBootApplication
|
||||
@EnableRyFeignClients
|
||||
|
||||
@ -24,4 +24,7 @@ public interface XhpcDeviceMessageMapper {
|
||||
|
||||
|
||||
List<Map<String, Object>> getOrderMessageByParams(@Param("params")Map params);
|
||||
|
||||
|
||||
int deleteMessageByDate(@Param("date")String date);
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package com.xhpc.log.task;
|
||||
|
||||
|
||||
import com.xhpc.common.util.DateUtil;
|
||||
import com.xhpc.log.mapper.XhpcDeviceMessageMapper;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class AutoClearDataTask {
|
||||
|
||||
|
||||
@Resource
|
||||
XhpcDeviceMessageMapper messageMapper;
|
||||
|
||||
/**
|
||||
* 清理一个月前的数据
|
||||
*/
|
||||
@Scheduled(cron = "0 0 5 * * ?")
|
||||
private void autoClearDeviceMessageData(){
|
||||
|
||||
String date = DateUtil.date2String(DateUtil.addDay(new Date(), -30), "yyyy-MM-dd");
|
||||
messageMapper.deleteMessageByDate(date);
|
||||
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,12 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xhpc.log.mapper.XhpcDeviceMessageMapper">
|
||||
|
||||
|
||||
<delete id="deleteMessageByDate">
|
||||
delete from xhpc_device_message where create_time create_time <![CDATA[ <= ]]> #{date}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="selectListByTypeAndSerialNumber" resultType="map">
|
||||
select
|
||||
device_message_id as 'deviceMessageId',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user