盈亏排序

This commit is contained in:
2025-06-20 15:45:53 +08:00
parent f5875180a4
commit 7a1128f316
4 changed files with 62 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
package com.ruoyi.oa.controller;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
@@ -232,14 +233,28 @@ public class SysOaProjectController extends BaseController {
*/
@GetMapping("/projectProfit")
public TableDataInfo<ProjectProfitLossVO> projectProfit(
@RequestParam(required = false) String projectName,
@RequestParam(required = false) String projectNum,
@RequestParam(required = false) String projectStatus,
@RequestParam(required = false) String isDomestic, // 国内外
@RequestParam(required = false) BigDecimal minContractAmount,
@RequestParam(required = false) BigDecimal maxContractAmount,
@RequestParam(required = false) BigDecimal minProfitLoss,
@RequestParam(required = false) BigDecimal maxProfitLoss,
@RequestParam(required = false) String beginTimeStart,
@RequestParam(required = false) String beginTimeEnd,
@RequestParam(required = false) String profitType, // "profit" 只看盈利, "loss" 只看亏损, null看全部
@RequestParam(required = false, defaultValue = "profit_loss") String sortField,
@RequestParam(required = false, defaultValue = "desc") String sortOrder,
PageQuery pageQuery
) {
// 这里PageQuery会自动带上orderByColumn和isAsc
pageQuery.setOrderByColumn(sortField);
pageQuery.setIsAsc(sortOrder);
return iSysOaProjectService.getProjectProfitLossList(sortField, sortOrder, pageQuery);
return iSysOaProjectService.getProjectProfitLossList(
projectName, projectNum, projectStatus, isDomestic,
minContractAmount, maxContractAmount,
minProfitLoss, maxProfitLoss,
beginTimeStart, beginTimeEnd, profitType,sortField, sortOrder, pageQuery);
}

View File

@@ -7,7 +7,9 @@ import com.ruoyi.oa.domain.vo.*;
import com.ruoyi.oa.domain.bo.SysOaProjectBo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import org.springframework.web.bind.annotation.RequestParam;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -22,7 +24,10 @@ public interface ISysOaProjectService {
/**
* 项目盈亏排序
*/
TableDataInfo<ProjectProfitLossVO> getProjectProfitLossList(String sortField, String sortOrder, PageQuery pageQuery);
TableDataInfo<ProjectProfitLossVO> getProjectProfitLossList(String projectName,String projectNum,String projectStatus,String isDomestic,
BigDecimal minContractAmount,BigDecimal maxContractAmount,BigDecimal minProfitLoss,
BigDecimal maxProfitLoss,String beginTimeStart,String beginTimeEnd,String profitType,
String sortField, String sortOrder, PageQuery pageQuery);
/**
* 查询项目管理
*/

View File

@@ -50,18 +50,43 @@ public class SysOaProjectServiceImpl implements ISysOaProjectService {
@Override
public TableDataInfo<ProjectProfitLossVO> getProjectProfitLossList(String sortField, String sortOrder, PageQuery pageQuery) {
// 1. 构建分页对象
public TableDataInfo<ProjectProfitLossVO> getProjectProfitLossList(
String projectName, String projectNum, String projectStatus, String isDomestic,
BigDecimal minContractAmount, BigDecimal maxContractAmount,
BigDecimal minProfitLoss, BigDecimal maxProfitLoss,
String beginTimeStart, String beginTimeEnd, String profitType,
String sortField, String sortOrder,
PageQuery pageQuery
) {
Page<ProjectProfitLossVO> page = pageQuery.build();
// 2. 构建查询条件可根据bo添加筛选
QueryWrapper<SysOaProject> wrapper = new QueryWrapper<>();
// 基础条件
wrapper.like(StringUtils.isNotBlank(projectName), "p.project_name", projectName);
wrapper.like(StringUtils.isNotBlank(projectNum), "p.project_num", projectNum);
wrapper.eq(StringUtils.isNotBlank(projectStatus), "p.project_status", projectStatus);
wrapper.eq(StringUtils.isNotBlank(isDomestic), "p.is_domestic", isDomestic);
wrapper.ge(minContractAmount != null, "p.funds", minContractAmount);
wrapper.le(maxContractAmount != null, "p.funds", maxContractAmount);
wrapper.ge(StringUtils.isNotBlank(beginTimeStart), "p.begin_time", beginTimeStart);
wrapper.le(StringUtils.isNotBlank(beginTimeEnd), "p.begin_time", beginTimeEnd);
// 盈亏区间
if (minProfitLoss != null) {
wrapper.apply("p.funds - COALESCE(wd.total_warehouse_cost,0) - COALESCE(hr.total_hr_cost,0) >= {0}", minProfitLoss);
}
if (maxProfitLoss != null) {
wrapper.apply("p.funds - COALESCE(wd.total_warehouse_cost,0) - COALESCE(hr.total_hr_cost,0) <= {0}", maxProfitLoss);
}
// 盈利/亏损筛选
if ("profit".equals(profitType)) {
wrapper.apply("p.funds - COALESCE(wd.total_warehouse_cost,0) - COALESCE(hr.total_hr_cost,0) > 0");
} else if ("loss".equals(profitType)) {
wrapper.apply("p.funds - COALESCE(wd.total_warehouse_cost,0) - COALESCE(hr.total_hr_cost,0) < 0");
}
// 3. 调用自定义Mapper方法
Page<ProjectProfitLossVO> result = baseMapper.selectProfitLossPage(page, wrapper);
// 4. 返回分页数据
return TableDataInfo.build(result);
}