Compare commits

...

2 Commits

Author SHA1 Message Date
34ae138199 检查未寄卖的逻辑 2026-04-26 09:36:21 +08:00
54a48d7d59 调整报表的风格 2026-04-25 23:39:18 +08:00
2 changed files with 84 additions and 6 deletions

View File

@@ -30,8 +30,11 @@ import org.apache.poi.ss.usermodel.ComparisonOperator;
import org.apache.poi.ss.usermodel.ConditionalFormattingRule;
import org.apache.poi.ss.usermodel.FontFormatting;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.awt.Color;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
@@ -333,6 +336,81 @@ public class LbDailyUserTradeReportController {
}
}
@GetMapping("/list/yestoday-buy-positive-and-daily-sell-zero")
@Operation(summary = "按日期范围查询昨日买入大于0且当日卖出为0的报表", description = "根据开始日期、结束日期和租户ID查询 reportDate 范围内 yestodayBuyAmt > 0 且 dailySellAmt = 0 的记录")
public ResponseEntity<Map<String, Object>> listByDateRangeWithBuyPositiveAndSellZero(
@Parameter(description = "开始日期格式yyyy-MM-dd", required = true)
@RequestParam String startDate,
@Parameter(description = "结束日期格式yyyy-MM-dd", required = true)
@RequestParam String endDate,
@Parameter(description = "租户ID", required = true)
@RequestParam String tenantId) {
Map<String, Object> result = new HashMap<>();
try {
if (tenantId == null || tenantId.trim().isEmpty()) {
result.put("success", false);
result.put("message", "tenantId不能为空");
return ResponseEntity.badRequest().body(result);
}
if (startDate == null || startDate.trim().isEmpty()) {
result.put("success", false);
result.put("message", "startDate不能为空");
return ResponseEntity.badRequest().body(result);
}
if (endDate == null || endDate.trim().isEmpty()) {
result.put("success", false);
result.put("message", "endDate不能为空");
return ResponseEntity.badRequest().body(result);
}
LocalDate parsedStartDate;
LocalDate parsedEndDate;
try {
parsedStartDate = LocalDate.parse(startDate.trim());
} catch (Exception e) {
result.put("success", false);
result.put("message", "startDate格式错误请使用 yyyy-MM-dd");
return ResponseEntity.badRequest().body(result);
}
try {
parsedEndDate = LocalDate.parse(endDate.trim());
} catch (Exception e) {
result.put("success", false);
result.put("message", "endDate格式错误请使用 yyyy-MM-dd");
return ResponseEntity.badRequest().body(result);
}
if (parsedEndDate.isBefore(parsedStartDate)) {
result.put("success", false);
result.put("message", "endDate不能早于startDate");
return ResponseEntity.badRequest().body(result);
}
LocalDateTime start = parsedStartDate.atStartOfDay();
LocalDateTime end = parsedEndDate.atTime(23, 59, 59);
LambdaQueryWrapper<LbDailyUserTradeReport> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(LbDailyUserTradeReport::getTenantId, tenantId.trim())
.ge(LbDailyUserTradeReport::getReportDate, start)
.le(LbDailyUserTradeReport::getReportDate, end)
.gt(LbDailyUserTradeReport::getYestodayBuyAmt, BigDecimal.ZERO)
.eq(LbDailyUserTradeReport::getDailySellAmt, BigDecimal.ZERO)
.orderByDesc(LbDailyUserTradeReport::getReportDate)
.orderByDesc(LbDailyUserTradeReport::getCreatedAt);
List<LbDailyUserTradeReport> rows = lbDailyUserTradeReportService.list(queryWrapper);
result.put("success", true);
result.put("message", "查询成功");
result.put("data", rows);
result.put("total", rows.size());
return ResponseEntity.ok(result);
} catch (Exception e) {
result.put("success", false);
result.put("message", "查询异常:" + e.getMessage());
return ResponseEntity.internalServerError().body(result);
}
}
@PostMapping("/calculate-report-sum/by-date-and-tenant")
@Operation(summary = "按日期和租户汇总报表", description = "根据报表日期和租户ID汇总报表字段并新增一条 report_sum 记录")
public ResponseEntity<Map<String, Object>> calculateReportSumByDateAndTenant(
@@ -458,7 +536,6 @@ public class LbDailyUserTradeReportController {
CellStyle zebraTextStyle = workbook.createCellStyle();
zebraTextStyle.cloneStyleFrom(textStyle);
zebraTextStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
zebraTextStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
CellStyle intStyle = workbook.createCellStyle();
@@ -472,9 +549,13 @@ public class LbDailyUserTradeReportController {
CellStyle zebraIntStyle = workbook.createCellStyle();
zebraIntStyle.cloneStyleFrom(intStyle);
zebraIntStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
zebraIntStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
// 更淡的斑马纹底色(接近白色)
XSSFColor zebraFill = new XSSFColor(new Color(242, 244, 248), null);
((XSSFCellStyle) zebraTextStyle).setFillForegroundColor(zebraFill);
((XSSFCellStyle) zebraIntStyle).setFillForegroundColor(zebraFill);
CellStyle summaryTextStyle = workbook.createCellStyle();
summaryTextStyle.cloneStyleFrom(textStyle);
summaryTextStyle.setFillForegroundColor(IndexedColors.LEMON_CHIFFON.getIndex());

View File

@@ -414,10 +414,7 @@ public class LbDailyUserTradeServiceImpl extends ServiceImpl<LbDailyUserTradeMap
}
}
if (userId.isEmpty()) {
userId = nickname;
}
if (userId.isEmpty()) {
userId = "AUTO_" + UUID.randomUUID().toString().replace("-", "");
userId = "AUTO_USERID_" + UUID.randomUUID().toString().replace("-", "");
}
LbDailyUserTrade trade = new LbDailyUserTrade();