1.1.64 销售合同仪表盘接口。
parent
64ff1ef519
commit
01ec290297
@ -0,0 +1,35 @@
|
||||
package org.dromara.oa.erp.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.oa.erp.domain.bo.SalesContractDashboardBo;
|
||||
import org.dromara.oa.erp.domain.vo.SalesContractDashboardVo;
|
||||
import org.dromara.oa.erp.service.ISalesContractDashboardService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 销售合同仪表盘
|
||||
* 前端访问路由地址为:/oa/erp/salesContractDashboard
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/erp/salesContractDashboard")
|
||||
public class SalesContractDashboardController extends BaseController {
|
||||
|
||||
private final ISalesContractDashboardService salesContractDashboardService;
|
||||
|
||||
/**
|
||||
* 查询销售合同仪表盘数据
|
||||
*/
|
||||
@SaCheckPermission("oa/erp:salesContractDashboard:query")
|
||||
@GetMapping("/data")
|
||||
public R<SalesContractDashboardVo> getDashboardData(SalesContractDashboardBo bo) {
|
||||
return R.ok(salesContractDashboardService.queryDashboard(bo));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package org.dromara.oa.erp.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 销售合同仪表盘视图对象
|
||||
*/
|
||||
@Data
|
||||
public class SalesContractDashboardVo {
|
||||
|
||||
/** 成交总额 */
|
||||
private BigDecimal totalTransactionAmount;
|
||||
|
||||
/** 本周新签合同额 */
|
||||
private BigDecimal weeklyNewContractAmount;
|
||||
|
||||
/** 业务方向销售额占比 */
|
||||
private List<SalesContractDashboardVo> businessDirectionRatios = new ArrayList<>();
|
||||
|
||||
/** 成交额客户分布 */
|
||||
private List<SalesContractDashboardVo> customerTransactionDistribution = new ArrayList<>();
|
||||
|
||||
/** 销售合同额排行 */
|
||||
private List<SalesContractDashboardVo> salesContractRanking = new ArrayList<>();
|
||||
|
||||
/** 业务方向名称 / 通用名称 */
|
||||
private String name;
|
||||
|
||||
/** 业务方向金额 / 通用数值 */
|
||||
private BigDecimal value;
|
||||
|
||||
/** 客户名称 */
|
||||
private String customerName;
|
||||
|
||||
/** 客户成交额 */
|
||||
private BigDecimal amount;
|
||||
|
||||
/** 销售人员名称 */
|
||||
private String salespersonName;
|
||||
|
||||
/** 销售合同金额 */
|
||||
private BigDecimal contractAmount;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package org.dromara.oa.erp.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.oa.erp.domain.vo.SalesContractDashboardVo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 销售合同仪表盘 Mapper
|
||||
*/
|
||||
public interface SalesContractDashboardMapper {
|
||||
|
||||
BigDecimal selectTotalTransactionAmount(@Param("beginDate") String beginDate,
|
||||
@Param("endDate") String endDate);
|
||||
|
||||
BigDecimal selectWeeklyNewContractAmount();
|
||||
|
||||
List<SalesContractDashboardVo> selectBusinessDirectionRatios(@Param("beginDate") String beginDate,
|
||||
@Param("endDate") String endDate);
|
||||
|
||||
List<SalesContractDashboardVo> selectCustomerTransactionDistribution(@Param("beginDate") String beginDate,
|
||||
@Param("endDate") String endDate);
|
||||
|
||||
List<SalesContractDashboardVo> selectSalesContractRanking(@Param("beginDate") String beginDate,
|
||||
@Param("endDate") String endDate);
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.dromara.oa.erp.service;
|
||||
|
||||
import org.dromara.oa.erp.domain.bo.SalesContractDashboardBo;
|
||||
import org.dromara.oa.erp.domain.vo.SalesContractDashboardVo;
|
||||
|
||||
/**
|
||||
* 销售合同仪表盘 Service
|
||||
*/
|
||||
public interface ISalesContractDashboardService {
|
||||
|
||||
/**
|
||||
* 查询仪表盘数据
|
||||
*/
|
||||
SalesContractDashboardVo queryDashboard(SalesContractDashboardBo bo);
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package org.dromara.oa.erp.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.service.DictService;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.oa.erp.domain.bo.SalesContractDashboardBo;
|
||||
import org.dromara.oa.erp.domain.vo.SalesContractDashboardVo;
|
||||
import org.dromara.oa.erp.mapper.SalesContractDashboardMapper;
|
||||
import org.dromara.oa.erp.service.ISalesContractDashboardService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 销售合同仪表盘 Service 实现
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SalesContractDashboardServiceImpl implements ISalesContractDashboardService {
|
||||
|
||||
private static final String BUSINESS_DIRECTION_DICT = "business_direction";
|
||||
|
||||
private final SalesContractDashboardMapper dashboardMapper;
|
||||
private final DictService dictService;
|
||||
|
||||
@Override
|
||||
public SalesContractDashboardVo queryDashboard(SalesContractDashboardBo bo) {
|
||||
String beginDate = bo.getBeginDate();
|
||||
String endDate = bo.getEndDate();
|
||||
if (StringUtils.isBlank(beginDate) || StringUtils.isBlank(endDate)) {
|
||||
int year = LocalDate.now().getYear();
|
||||
beginDate = year + "-01-01";
|
||||
endDate = year + "-12-31";
|
||||
}
|
||||
|
||||
SalesContractDashboardVo dashboardVo = new SalesContractDashboardVo();
|
||||
dashboardVo.setTotalTransactionAmount(defaultAmount(
|
||||
dashboardMapper.selectTotalTransactionAmount(beginDate, endDate)));
|
||||
dashboardVo.setWeeklyNewContractAmount(defaultAmount(
|
||||
dashboardMapper.selectWeeklyNewContractAmount()));
|
||||
|
||||
List<SalesContractDashboardVo> directionRatios =
|
||||
dashboardMapper.selectBusinessDirectionRatios(beginDate, endDate);
|
||||
directionRatios.forEach(item -> item.setName(resolveBusinessDirectionName(item.getName())));
|
||||
dashboardVo.setBusinessDirectionRatios(directionRatios);
|
||||
|
||||
dashboardVo.setCustomerTransactionDistribution(
|
||||
dashboardMapper.selectCustomerTransactionDistribution(beginDate, endDate));
|
||||
dashboardVo.setSalesContractRanking(
|
||||
dashboardMapper.selectSalesContractRanking(beginDate, endDate));
|
||||
|
||||
return dashboardVo;
|
||||
}
|
||||
|
||||
private BigDecimal defaultAmount(BigDecimal amount) {
|
||||
return amount == null ? BigDecimal.ZERO : amount;
|
||||
}
|
||||
|
||||
private String resolveBusinessDirectionName(String businessDirection) {
|
||||
if (StringUtils.isBlank(businessDirection) || "unknown".equals(businessDirection)) {
|
||||
return "未分类";
|
||||
}
|
||||
String label = dictService.getDictLabel(BUSINESS_DIRECTION_DICT, businessDirection);
|
||||
return StringUtils.isNotBlank(label) ? label : businessDirection;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue