|
@ -1,15 +1,21 @@ |
|
|
package com.example.demo.Export; |
|
|
package com.example.demo.Export; |
|
|
|
|
|
|
|
|
|
|
|
import com.example.demo.Util.JWTUtil; |
|
|
import com.example.demo.domain.DTO.ConsumeDTO; |
|
|
import com.example.demo.domain.DTO.ConsumeDTO; |
|
|
import com.example.demo.domain.DTO.RechargeDTO; |
|
|
import com.example.demo.domain.DTO.RechargeDTO; |
|
|
import com.example.demo.domain.DTO.RefundDTO; |
|
|
import com.example.demo.domain.DTO.RefundDTO; |
|
|
|
|
|
import com.example.demo.domain.entity.Admin; |
|
|
import com.example.demo.domain.vo.Result; |
|
|
import com.example.demo.domain.vo.Result; |
|
|
import com.example.demo.exception.SystemException; |
|
|
import com.example.demo.exception.SystemException; |
|
|
import com.example.demo.mapper.GoldDetailMapper; |
|
|
import com.example.demo.mapper.GoldDetailMapper; |
|
|
import com.example.demo.Util.RedisUtil; |
|
|
import com.example.demo.Util.RedisUtil; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.security.core.userdetails.UserDetails; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder; |
|
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes; |
|
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.time.format.DateTimeFormatter; |
|
@ -33,13 +39,21 @@ public class ExportServiceImpl implements ExportService{ |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Result addExportRecharge(RechargeDTO dto) { |
|
|
public Result addExportRecharge(RechargeDTO dto) { |
|
|
|
|
|
// 获取操作者 jwcode |
|
|
|
|
|
HttpServletRequest request=((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|
|
|
|
|
String token = request.getHeader("token"); |
|
|
|
|
|
try { |
|
|
|
|
|
UserDetails token1= JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class); |
|
|
|
|
|
dto.setAccount(Integer.valueOf(token1.getUsername())); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
|
|
} |
|
|
// 生成文件名 |
|
|
// 生成文件名 |
|
|
String fileName = String.format("%s_%s_%s.xlsx", |
|
|
String fileName = String.format("%s_%s_%s.xlsx", |
|
|
"充值明细", |
|
|
"充值明细", |
|
|
"操作人", |
|
|
"操作人", |
|
|
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
|
|
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
|
|
System.out.println(fileName); |
|
|
System.out.println(fileName); |
|
|
dto.setAccount(123456); |
|
|
|
|
|
dto.setUrl(""); |
|
|
dto.setUrl(""); |
|
|
dto.setFileName(fileName); |
|
|
dto.setFileName(fileName); |
|
|
dto.setDataNum(0); |
|
|
dto.setDataNum(0); |
|
@ -81,13 +95,21 @@ public class ExportServiceImpl implements ExportService{ |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Result addExportRefund(RefundDTO dto) { |
|
|
public Result addExportRefund(RefundDTO dto) { |
|
|
|
|
|
// 获取操作者 jwcode |
|
|
|
|
|
HttpServletRequest request=((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|
|
|
|
|
String token = request.getHeader("token"); |
|
|
|
|
|
try { |
|
|
|
|
|
UserDetails token1= JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class); |
|
|
|
|
|
dto.setAccount(Integer.valueOf(token1.getUsername())); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
|
|
} |
|
|
// 生成文件名 |
|
|
// 生成文件名 |
|
|
String fileName = String.format("%s_%s_%s.xlsx", |
|
|
String fileName = String.format("%s_%s_%s.xlsx", |
|
|
"退款明细", |
|
|
"退款明细", |
|
|
"操作人", |
|
|
"操作人", |
|
|
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
|
|
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
|
|
System.out.println(fileName); |
|
|
System.out.println(fileName); |
|
|
dto.setAccount(123456); |
|
|
|
|
|
dto.setUrl(""); |
|
|
dto.setUrl(""); |
|
|
dto.setFileName(fileName); |
|
|
dto.setFileName(fileName); |
|
|
dto.setDataNum(0); |
|
|
dto.setDataNum(0); |
|
@ -129,13 +151,21 @@ public class ExportServiceImpl implements ExportService{ |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Result addExportConsume(ConsumeDTO dto) { |
|
|
public Result addExportConsume(ConsumeDTO dto) { |
|
|
|
|
|
// 获取操作者 jwcode |
|
|
|
|
|
HttpServletRequest request=((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|
|
|
|
|
String token = request.getHeader("token"); |
|
|
|
|
|
try { |
|
|
|
|
|
UserDetails token1= JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class); |
|
|
|
|
|
dto.setAccount(Integer.valueOf(token1.getUsername())); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
|
|
} |
|
|
// 生成文件名 |
|
|
// 生成文件名 |
|
|
String fileName = String.format("%s_%s_%s.xlsx", |
|
|
String fileName = String.format("%s_%s_%s.xlsx", |
|
|
"消费明细", |
|
|
|
|
|
|
|
|
"消耗明细", |
|
|
"操作人", |
|
|
"操作人", |
|
|
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
|
|
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
|
|
System.out.println(fileName); |
|
|
System.out.println(fileName); |
|
|
dto.setAccount(123456); |
|
|
|
|
|
dto.setUrl(""); |
|
|
dto.setUrl(""); |
|
|
dto.setFileName(fileName); |
|
|
dto.setFileName(fileName); |
|
|
dto.setDataNum(0); |
|
|
dto.setDataNum(0); |
|
@ -167,7 +197,7 @@ public class ExportServiceImpl implements ExportService{ |
|
|
|
|
|
|
|
|
// 3. 发送到 Redis 消息队列 |
|
|
// 3. 发送到 Redis 消息队列 |
|
|
String jsonData = new ObjectMapper().writeValueAsString(exportData); |
|
|
String jsonData = new ObjectMapper().writeValueAsString(exportData); |
|
|
redisUtil.sendMessage("refund:queue:export_queue", jsonData); |
|
|
|
|
|
|
|
|
redisUtil.sendMessage("consume:queue:export_queue", jsonData); |
|
|
}catch (Exception e){ |
|
|
}catch (Exception e){ |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
throw new SystemException("导出数据异常,请稍后重试", e); |
|
|
throw new SystemException("导出数据异常,请稍后重试", e); |
|
|