Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -46,18 +46,22 @@ public class AppApiMethodAspect {
|
||||
// 执行被拦截的方法
|
||||
Object result = pjp.proceed();
|
||||
long end = System.currentTimeMillis();
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
String method = request.getMethod();
|
||||
String requestUrl = request.getRequestURL().toString();
|
||||
String requestIp = IPUtils.getIpAddr(request);
|
||||
long useTime = end - start;
|
||||
ThreadUtil.execAsync(() -> {
|
||||
//请求的参数
|
||||
String resultJson = new Gson().toJson(result);
|
||||
try {
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
if (StringUtils.isNotBlank(resultJson) && !"null".equals(resultJson)) {
|
||||
log.info("\n>>>>>> {} {}" +
|
||||
"\n>>>>>> IP: {} " +
|
||||
"\n>>>>>> execute time:{}ms " +
|
||||
"\n>>>>>> Request: {}" +
|
||||
"\n>>>>>> Response: {}",
|
||||
request.getMethod(), request.getRequestURL(), IPUtils.getIpAddr(request), end - start,
|
||||
"\n>>>>>> IP: {} " +
|
||||
"\n>>>>>> execute time:{}ms " +
|
||||
"\n>>>>>> Request: {}" +
|
||||
"\n>>>>>> Response: {}",
|
||||
method, requestUrl, requestIp, useTime,
|
||||
params,
|
||||
resultJson
|
||||
);
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.sqx.modules.pay.service.PayDetailsService;
|
||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||
import com.sqx.modules.sys.service.SysUserService;
|
||||
import com.sqx.modules.utils.EasyPoi.ExcelUtils;
|
||||
import com.sqx.modules.utils.TimeCompleteUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
@@ -270,7 +271,7 @@ public class UserController {
|
||||
@ApiOperation("短剧分析")
|
||||
public Result courseMessage(Long page, Long limit, String date, int type, Long sysUserId) {
|
||||
Page<Map<String, Object>> iPage = new Page<>(page, limit);
|
||||
IPage<Map<String, Object>> mapIPage = userService.queryCourseOrder(iPage, type, date, sysUserId);
|
||||
IPage<Map<String, Object>> mapIPage = userService.queryCourseOrder(iPage, type, TimeCompleteUtils.completeStartTime(date), sysUserId);
|
||||
return Result.success().put("data", new PageUtils(mapIPage));
|
||||
}
|
||||
|
||||
@@ -280,6 +281,7 @@ public class UserController {
|
||||
@GetMapping("/userMessage")
|
||||
@ApiOperation("用户分析")
|
||||
public Result userMessage(String date, int type, Long sysUserId) {
|
||||
date = TimeCompleteUtils.completeStartTime(date);
|
||||
String qdCode = null;
|
||||
if (sysUserId != null) {
|
||||
qdCode = sysUserService.getById(sysUserId).getQdCode();
|
||||
|
||||
@@ -4,11 +4,16 @@ import com.sqx.common.annotation.SysLog;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.common.validator.ValidatorUtils;
|
||||
import com.sqx.modules.job.dto.RunJobDTO;
|
||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
||||
import com.sqx.modules.job.service.ScheduleJobService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -20,8 +25,15 @@ import java.util.Map;
|
||||
public class ScheduleJobController {
|
||||
@Autowired
|
||||
private ScheduleJobService scheduleJobService;
|
||||
|
||||
/**
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
public ScheduleJobController(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 定时任务列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@@ -30,17 +42,17 @@ public class ScheduleJobController {
|
||||
|
||||
return Result.success().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 定时任务信息
|
||||
*/
|
||||
@RequestMapping("/info/{jobId}")
|
||||
public Result info(@PathVariable("jobId") Long jobId){
|
||||
ScheduleJobEntity schedule = scheduleJobService.getById(jobId);
|
||||
|
||||
|
||||
return Result.success().put("schedule", schedule);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存定时任务
|
||||
*/
|
||||
@@ -48,12 +60,12 @@ public class ScheduleJobController {
|
||||
@RequestMapping("/save")
|
||||
public Result save(@RequestBody ScheduleJobEntity scheduleJob){
|
||||
ValidatorUtils.validateEntity(scheduleJob);
|
||||
|
||||
|
||||
scheduleJobService.saveJob(scheduleJob);
|
||||
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改定时任务
|
||||
*/
|
||||
@@ -61,12 +73,12 @@ public class ScheduleJobController {
|
||||
@RequestMapping("/update")
|
||||
public Result update(@RequestBody ScheduleJobEntity scheduleJob){
|
||||
ValidatorUtils.validateEntity(scheduleJob);
|
||||
|
||||
|
||||
scheduleJobService.update(scheduleJob);
|
||||
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除定时任务
|
||||
*/
|
||||
@@ -74,13 +86,21 @@ public class ScheduleJobController {
|
||||
@RequestMapping("/delete")
|
||||
public Result delete(@RequestBody Long[] jobIds){
|
||||
scheduleJobService.deleteBatch(jobIds);
|
||||
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 立即执行任务
|
||||
*/
|
||||
|
||||
@SysLog("立即执行任务")
|
||||
@RequestMapping("/run")
|
||||
public Result run(@RequestBody Long[] jobIds) throws Exception {
|
||||
|
||||
return Result.success().put("data", scheduleJobService.run(jobIds));
|
||||
}
|
||||
|
||||
// @SysLog("立即执行任务")
|
||||
// @RequestMapping("/run")
|
||||
// public Result run(@RequestBody Long[] jobIds){
|
||||
@@ -88,7 +108,7 @@ public class ScheduleJobController {
|
||||
//
|
||||
// return Result.success();
|
||||
// }
|
||||
//
|
||||
|
||||
// /**
|
||||
// * 暂停定时任务
|
||||
// */
|
||||
|
||||
14
src/main/java/com/sqx/modules/job/dto/RunJobDTO.java
Normal file
14
src/main/java/com/sqx/modules/job/dto/RunJobDTO.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.sqx.modules.job.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RunJobDTO {
|
||||
@NotNull
|
||||
private Integer jobId;
|
||||
private List<?> args;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.sqx.modules.job.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.modules.job.dto.RunJobDTO;
|
||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -18,22 +19,24 @@ public interface ScheduleJobService extends IService<ScheduleJobEntity> {
|
||||
* 保存定时任务
|
||||
*/
|
||||
void saveJob(ScheduleJobEntity scheduleJob);
|
||||
|
||||
|
||||
/**
|
||||
* 更新定时任务
|
||||
*/
|
||||
void update(ScheduleJobEntity scheduleJob);
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除定时任务
|
||||
*/
|
||||
void deleteBatch(Long[] jobIds);
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新定时任务状态
|
||||
*/
|
||||
int updateBatch(Long[] jobIds, int status);
|
||||
|
||||
|
||||
Object run(Long[] jobIds) throws Exception;
|
||||
|
||||
// /**
|
||||
// * 立即执行
|
||||
// */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.sqx.modules.job.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -7,21 +8,27 @@ import com.sqx.common.utils.Constant;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Query;
|
||||
import com.sqx.modules.job.dao.ScheduleJobDao;
|
||||
import com.sqx.modules.job.dto.RunJobDTO;
|
||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
||||
import com.sqx.modules.job.service.ScheduleJobService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
@Service("scheduleJobService")
|
||||
public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService {
|
||||
|
||||
/**
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
public ScheduleJobServiceImpl(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化定时器
|
||||
*/
|
||||
|
||||
@@ -46,7 +53,7 @@ public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, Schedule
|
||||
scheduleJob.setStatus(Constant.ScheduleStatus.NORMAL.getValue());
|
||||
this.save(scheduleJob);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(ScheduleJobEntity scheduleJob) {
|
||||
@@ -68,8 +75,48 @@ public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, Schedule
|
||||
map.put("status", status);
|
||||
return baseMapper.updateBatch(map);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
||||
|
||||
@Override
|
||||
public Object run(Long[] jobIds) throws Exception {
|
||||
ArrayList<Object> result = new ArrayList<>();
|
||||
for(Long jobId : jobIds){
|
||||
ScheduleJobEntity jobEntity = baseMapper.selectById(jobId);
|
||||
if (jobEntity == null) {
|
||||
throw new RuntimeException("任务不存在");
|
||||
}
|
||||
|
||||
// 从Spring容器获取类的实例
|
||||
Object classInstance = applicationContext.getBean(StrUtil.lowerFirst(jobEntity.getBeanName()));
|
||||
if (!"com.sqx.modules.job.task".equals(classInstance.getClass().getPackage().getName())) {
|
||||
throw new RuntimeException("非法调用");
|
||||
}
|
||||
|
||||
// if (jobDTO.getArgs() != null && !jobDTO.getArgs().isEmpty()) {
|
||||
// Class<?>[] argTypes = new Class<?>[jobDTO.getArgs().size()];
|
||||
// for (int i = 0; i < jobDTO.getArgs().size(); i++) {
|
||||
// argTypes[i] = jobDTO.getArgs().get(i).getClass();
|
||||
// }
|
||||
// // 获取指定的Method对象
|
||||
// Method method = classInstance.getClass().getDeclaredMethod(jobDTO.getMethodName(), argTypes);
|
||||
//
|
||||
// // 调用方法并返回结果
|
||||
// return method.invoke(classInstance, jobDTO.getArgs().toArray());
|
||||
// }
|
||||
// 获取指定的Method对象
|
||||
Method method = classInstance.getClass().getDeclaredMethod("run", String.class);
|
||||
|
||||
// 调用方法并返回结果
|
||||
Object invoke = method.invoke(classInstance, jobEntity.getParams());
|
||||
if (invoke != null) {
|
||||
result.add(invoke);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void run(Long[] jobIds) {
|
||||
// for(Long jobId : jobIds){
|
||||
@@ -96,5 +143,5 @@ public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, Schedule
|
||||
//
|
||||
// updateBatch(jobIds, Constant.ScheduleStatus.NORMAL.getValue());
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -67,4 +67,9 @@ public class CashOutTask{
|
||||
}
|
||||
logger.info("提现结束");
|
||||
}
|
||||
|
||||
|
||||
public void test(String name, String age) {
|
||||
logger.info("name: {}, age: {}", name, age);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.sqx.modules.pay.controller.app.AliPayController;
|
||||
import com.sqx.modules.pay.service.DyService;
|
||||
import com.sqx.modules.pay.service.WxService;
|
||||
import com.sqx.modules.utils.AliPayOrderUtil;
|
||||
import com.sqx.modules.utils.TimeCompleteUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -657,8 +658,9 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
||||
Integer flag, String time, String userName, Integer ordersType, String startTime, String endTime,
|
||||
Long sysUserId, String qdCode, String sysUserName) {
|
||||
Page<Orders> pages = new Page<>(page, limit);
|
||||
|
||||
return Result.success().put("data", new PageUtils(baseMapper.selectOrdersByOrdersNo(pages, ordersNo, status, userId, courseId,
|
||||
flag, time, userName, ordersType, startTime, endTime, sysUserId, qdCode, sysUserName)));
|
||||
flag, time, userName, ordersType, TimeCompleteUtils.completeStartTime(startTime), TimeCompleteUtils.completeEndTime(endTime), sysUserId, qdCode, sysUserName)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.modules.pay.dao.PayDetailsDao;
|
||||
import com.sqx.modules.pay.entity.PayDetails;
|
||||
import com.sqx.modules.pay.service.PayDetailsService;
|
||||
import com.sqx.modules.utils.TimeCompleteUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -30,15 +31,15 @@ public class PayDetailsServiceImpl extends ServiceImpl<PayDetailsDao, PayDetails
|
||||
if (state != null && state == -1) {
|
||||
state = null;
|
||||
}
|
||||
return new PageUtils(payDetailsDao.selectPayDetails(pages, startTime, endTime, userId, state,userName,orderId));
|
||||
return new PageUtils(payDetailsDao.selectPayDetails(pages, TimeCompleteUtils.completeStartTime(startTime), TimeCompleteUtils.completeEndTime(endTime), userId, state,userName,orderId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double selectSumPay(String createTime, String endTime, Long userId) {
|
||||
if (userId == null || userId == -1) {
|
||||
return payDetailsDao.selectSumPay(createTime, endTime, null);
|
||||
return payDetailsDao.selectSumPay(TimeCompleteUtils.completeStartTime(createTime), TimeCompleteUtils.completeEndTime(endTime), null);
|
||||
}
|
||||
return payDetailsDao.selectSumPay(createTime, endTime, userId);
|
||||
return payDetailsDao.selectSumPay(TimeCompleteUtils.completeStartTime(createTime), TimeCompleteUtils.completeEndTime(endTime), userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
27
src/main/java/com/sqx/modules/utils/TimeCompleteUtils.java
Normal file
27
src/main/java/com/sqx/modules/utils/TimeCompleteUtils.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.sqx.modules.utils;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
*/
|
||||
public class TimeCompleteUtils {
|
||||
|
||||
public static String completeStartTime(String startTime) {
|
||||
if (startTime == null || startTime.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (startTime.contains(" ")) {
|
||||
return startTime;
|
||||
}
|
||||
return startTime + " 00:00:00";
|
||||
}
|
||||
|
||||
public static String completeEndTime(String endTime) {
|
||||
if (endTime == null || endTime.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (endTime.contains(" ")) {
|
||||
return endTime;
|
||||
}
|
||||
return endTime + " 23:59:59";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user