123
This commit is contained in:
@@ -2,22 +2,28 @@ package com.ruoyi.op;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.cai.domain.RechargeOrder;
|
import com.ruoyi.cai.domain.*;
|
||||||
import com.ruoyi.cai.domain.User;
|
|
||||||
import com.ruoyi.cai.domain.VipOrder;
|
|
||||||
import com.ruoyi.cai.pay.PayManager;
|
import com.ruoyi.cai.pay.PayManager;
|
||||||
import com.ruoyi.cai.pay.PayStatusEnum;
|
import com.ruoyi.cai.pay.PayStatusEnum;
|
||||||
import com.ruoyi.cai.service.RechargeOrderService;
|
import com.ruoyi.cai.service.*;
|
||||||
import com.ruoyi.cai.service.UserMemberService;
|
import com.ruoyi.cai.ws.constant.RoomStatusEnums;
|
||||||
import com.ruoyi.cai.service.UserService;
|
import com.ruoyi.common.utils.BeanConvertUtil;
|
||||||
import com.ruoyi.cai.service.VipOrderService;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.system.domain.SysOperLog;
|
||||||
|
import com.ruoyi.system.domain.SysOperLogCopy;
|
||||||
|
import com.ruoyi.system.mapper.SysOperLogMapper;
|
||||||
|
import com.ruoyi.system.mapper.SysOperLogCopyMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -32,6 +38,49 @@ public class BusOp {
|
|||||||
private RechargeOrderService rechargeOrderService;
|
private RechargeOrderService rechargeOrderService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private VipOrderService vipOrderService;
|
private VipOrderService vipOrderService;
|
||||||
|
@Autowired
|
||||||
|
private UserCallService userCallService;
|
||||||
|
@Resource
|
||||||
|
private SysOperLogMapper sysOperLogMapper;
|
||||||
|
@Resource
|
||||||
|
private SysOperLogCopyMapper sysOperLogCopyMapper;
|
||||||
|
|
||||||
|
public void deleteUserCall(int days){
|
||||||
|
LocalDateTime deleteTimeFlag = LocalDateTime.now().plusDays(-days);
|
||||||
|
int current = 0;
|
||||||
|
while (true){
|
||||||
|
List<UserCall> list = userCallService.list(Wrappers.lambdaUpdate(UserCall.class)
|
||||||
|
.lt(UserCall::getCreateTime, deleteTimeFlag)
|
||||||
|
.eq(UserCall::getStatus, RoomStatusEnums.STATUS_CREATE.getCode())
|
||||||
|
.last("limit 100"));
|
||||||
|
if(current > 500 || CollectionUtils.isEmpty(list)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
current++;
|
||||||
|
List<Long> ids = list.stream().map(UserCall::getId).collect(Collectors.toList());
|
||||||
|
userCallService.removeBatchByIds(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copySysLog(int days){
|
||||||
|
Date copyTimeFlag = DateUtils.addDays(new Date(), -days);
|
||||||
|
int current = 0;
|
||||||
|
while (true){
|
||||||
|
List<SysOperLog> list = sysOperLogMapper.selectList(Wrappers.lambdaUpdate(SysOperLog.class)
|
||||||
|
.lt(SysOperLog::getOperTime, copyTimeFlag)
|
||||||
|
.orderByDesc(SysOperLog::getOperTime)
|
||||||
|
.last("limit 300"));
|
||||||
|
if(current > 500 || CollectionUtils.isEmpty(list)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
current++;
|
||||||
|
for (SysOperLog sysOperLog : list) {
|
||||||
|
sysOperLogMapper.deleteById(sysOperLog.getOperId());
|
||||||
|
sysOperLogCopyMapper.insert(BeanConvertUtil.convertTo(sysOperLog, SysOperLogCopy::new));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void checkVipOrder(LocalDateTime startTime, LocalDateTime endTime, String orderNo){
|
public void checkVipOrder(LocalDateTime startTime, LocalDateTime endTime, String orderNo){
|
||||||
if(StringUtils.isNotEmpty(orderNo)){
|
if(StringUtils.isNotEmpty(orderNo)){
|
||||||
|
|||||||
@@ -25,6 +25,23 @@ public class BusOpController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private BusOp busOp;
|
private BusOp busOp;
|
||||||
|
|
||||||
|
@GetMapping("/copySysLog")
|
||||||
|
public R<Void> copySysLog(int days){
|
||||||
|
log.info("备份操作日志-开始");
|
||||||
|
busOp.copySysLog(days);
|
||||||
|
log.info("备份操作日志-结束");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/deleteUserCall")
|
||||||
|
public R<Void> deleteUserCall(){
|
||||||
|
log.info("清洗垃圾通话记录-开始");
|
||||||
|
busOp.deleteUserCall(15);
|
||||||
|
log.info("清洗垃圾通话记录-结束");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/refreshUserVipStatus")
|
@GetMapping("/refreshUserVipStatus")
|
||||||
public R<Void> refreshUserVipStatus(){
|
public R<Void> refreshUserVipStatus(){
|
||||||
busOp.refreshUserVipStatus();
|
busOp.refreshUserVipStatus();
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.ruoyi.test.business;
|
||||||
|
|
||||||
|
import com.ruoyi.op.BusOp;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
@Slf4j
|
||||||
|
public class BusTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BusOp busOp;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void caiLoginManager(){
|
||||||
|
busOp.deleteUserCall(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void joinAnchorInvite(){
|
||||||
|
busOp.copySysLog(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志记录表 oper_log
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("sys_oper_log_bak")
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class SysOperLogCopy implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志主键
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "日志主键")
|
||||||
|
@TableId(value = "oper_id")
|
||||||
|
private Long operId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作模块
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "操作模块")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务类型(0其它 1新增 2修改 3删除)
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "业务类型", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_oper_type")
|
||||||
|
private Integer businessType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务类型数组
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer[] businessTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求方法
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "请求方法")
|
||||||
|
private String method;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求方式
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "请求方式")
|
||||||
|
private String requestMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作类别(0其它 1后台用户 2手机端用户)
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "操作类别", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(readConverterExp = "0=其它,1=后台用户,2=手机端用户")
|
||||||
|
private Integer operatorType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作人员
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "操作人员")
|
||||||
|
private String operName;
|
||||||
|
|
||||||
|
// @ExcelProperty(value = "用户类型")
|
||||||
|
private String userType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "部门名称")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求url
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "请求地址")
|
||||||
|
private String operUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作地址
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "操作地址")
|
||||||
|
private String operIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作地点
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "操作地点")
|
||||||
|
private String operLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求参数
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "请求参数")
|
||||||
|
private String operParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回参数
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "返回参数")
|
||||||
|
private String jsonResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作状态(0正常 1异常)
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_common_status")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误消息
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "错误消息")
|
||||||
|
private String errorMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作时间
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "操作时间")
|
||||||
|
private Date operTime;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求参数
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Map<String, Object> params = new HashMap<>();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
|
import com.ruoyi.system.domain.SysOperLogCopy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志 数据层
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
public interface SysOperLogCopyMapper extends BaseMapperPlus<SysOperLogCopyMapper, SysOperLogCopy, SysOperLogCopy> {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user