@@ -30,8 +30,11 @@ import org.apache.poi.ss.usermodel.ComparisonOperator;
import org.apache.poi.ss.usermodel.ConditionalFormattingRule ;
import org.apache.poi.ss.usermodel.ConditionalFormattingRule ;
import org.apache.poi.ss.usermodel.FontFormatting ;
import org.apache.poi.ss.usermodel.FontFormatting ;
import org.apache.poi.ss.util.CellRangeAddress ;
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 org.apache.poi.xssf.usermodel.XSSFWorkbook ;
import java.awt.Color ;
import java.math.BigDecimal ;
import java.math.BigDecimal ;
import java.math.RoundingMode ;
import java.math.RoundingMode ;
import java.net.URLEncoder ;
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 " )
@PostMapping ( " /calculate-report-sum/by-date-and-tenant " )
@Operation ( summary = " 按日期和租户汇总报表 " , description = " 根据报表日期和租户ID汇总报表字段并新增一条 report_sum 记录 " )
@Operation ( summary = " 按日期和租户汇总报表 " , description = " 根据报表日期和租户ID汇总报表字段并新增一条 report_sum 记录 " )
public ResponseEntity < Map < String , Object > > calculateReportSumByDateAndTenant (
public ResponseEntity < Map < String , Object > > calculateReportSumByDateAndTenant (
@@ -458,7 +536,6 @@ public class LbDailyUserTradeReportController {
CellStyle zebraTextStyle = workbook . createCellStyle ( ) ;
CellStyle zebraTextStyle = workbook . createCellStyle ( ) ;
zebraTextStyle . cloneStyleFrom ( textStyle ) ;
zebraTextStyle . cloneStyleFrom ( textStyle ) ;
zebraTextStyle . setFillForegroundColor ( IndexedColors . GREY_25_PERCENT . getIndex ( ) ) ;
zebraTextStyle . setFillPattern ( FillPatternType . SOLID_FOREGROUND ) ;
zebraTextStyle . setFillPattern ( FillPatternType . SOLID_FOREGROUND ) ;
CellStyle intStyle = workbook . createCellStyle ( ) ;
CellStyle intStyle = workbook . createCellStyle ( ) ;
@@ -472,9 +549,13 @@ public class LbDailyUserTradeReportController {
CellStyle zebraIntStyle = workbook . createCellStyle ( ) ;
CellStyle zebraIntStyle = workbook . createCellStyle ( ) ;
zebraIntStyle . cloneStyleFrom ( intStyle ) ;
zebraIntStyle . cloneStyleFrom ( intStyle ) ;
zebraIntStyle . setFillForegroundColor ( IndexedColors . GREY_25_PERCENT . getIndex ( ) ) ;
zebraIntStyle . setFillPattern ( FillPatternType . SOLID_FOREGROUND ) ;
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 ( ) ;
CellStyle summaryTextStyle = workbook . createCellStyle ( ) ;
summaryTextStyle . cloneStyleFrom ( textStyle ) ;
summaryTextStyle . cloneStyleFrom ( textStyle ) ;
summaryTextStyle . setFillForegroundColor ( IndexedColors . LEMON_CHIFFON . getIndex ( ) ) ;
summaryTextStyle . setFillForegroundColor ( IndexedColors . LEMON_CHIFFON . getIndex ( ) ) ;