Commit 375ec3ee548d4fb6b1643c779d71beddbed15d90

Authored by 房远帅
1 parent f0f42258

采购:业务员报价看板-当日成交按区域、品种维度统计

... ... @@ -6,6 +6,8 @@ import com.lframework.starter.web.core.components.resp.InvokeResult;
6 6 import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
7 7 import com.lframework.starter.web.core.components.resp.PageResult;
8 8 import com.lframework.starter.web.core.controller.DefaultBaseController;
  9 +import com.lframework.xingyun.sc.procurement.dto.quotation.SalesmanQuotationDealProductSummaryDto;
  10 +import com.lframework.xingyun.sc.procurement.dto.quotation.SalesmanQuotationDealRegionSummaryDto;
9 11 import com.lframework.xingyun.sc.procurement.entity.SalesmanQuotation;
10 12 import com.lframework.xingyun.sc.procurement.entity.SalesmanQuotationLine;
11 13 import com.lframework.xingyun.sc.procurement.service.quotation.SalesmanQuotationLineService;
... ... @@ -146,4 +148,20 @@ public class SalesmanQuotationController extends DefaultBaseController {
146 148 List<SalesmanQuotationLine> salesmanQuotationLineList = salesmanQuotationLineService.queryCurrentDayList(today, "DEAL_CLOSED");
147 149 return InvokeResultBuilder.success(salesmanQuotationLineList);
148 150 }
  151 +
  152 + @ApiOperation("当日已成交按区域汇总")
  153 + @GetMapping("/statistics/dealClosed/region")
  154 + public InvokeResult<List<SalesmanQuotationDealRegionSummaryDto>> statDealClosedByRegion() {
  155 + LocalDate today = LocalDate.now();
  156 + return InvokeResultBuilder.success(
  157 + salesmanQuotationLineService.statCurrentDayDealClosedByRegion(today));
  158 + }
  159 +
  160 + @ApiOperation("当日已成交按品种汇总")
  161 + @GetMapping("/statistics/dealClosed/product")
  162 + public InvokeResult<List<SalesmanQuotationDealProductSummaryDto>> statDealClosedByProduct() {
  163 + LocalDate today = LocalDate.now();
  164 + return InvokeResultBuilder.success(
  165 + salesmanQuotationLineService.statCurrentDayDealClosedByProduct(today));
  166 + }
149 167 }
... ...
  1 +package com.lframework.xingyun.sc.procurement.dto.quotation;
  2 +
  3 +import java.io.Serializable;
  4 +import java.math.BigDecimal;
  5 +import lombok.Data;
  6 +
  7 +@Data
  8 +public class SalesmanQuotationDealProductSummaryDto implements Serializable {
  9 +
  10 + private static final long serialVersionUID = 1L;
  11 +
  12 + private String productId;
  13 +
  14 + private String productName;
  15 +
  16 + private BigDecimal quantity;
  17 +
  18 + private BigDecimal price;
  19 +}
  20 +
... ...
  1 +package com.lframework.xingyun.sc.procurement.dto.quotation;
  2 +
  3 +import java.io.Serializable;
  4 +import java.math.BigDecimal;
  5 +import lombok.Data;
  6 +
  7 +@Data
  8 +public class SalesmanQuotationDealRegionSummaryDto implements Serializable {
  9 +
  10 + private static final long serialVersionUID = 1L;
  11 +
  12 + private String regionId;
  13 +
  14 + private String regionName;
  15 +
  16 + private BigDecimal quantity;
  17 +}
  18 +
... ...
... ... @@ -9,6 +9,8 @@ import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
9 9 import com.lframework.starter.web.core.utils.IdUtil;
10 10 import com.lframework.starter.web.core.utils.OpLogUtil;
11 11 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  12 +import com.lframework.xingyun.sc.procurement.dto.quotation.SalesmanQuotationDealProductSummaryDto;
  13 +import com.lframework.xingyun.sc.procurement.dto.quotation.SalesmanQuotationDealRegionSummaryDto;
12 14 import com.lframework.xingyun.sc.procurement.entity.SalesmanQuotationLine;
13 15 import com.lframework.xingyun.sc.procurement.mappers.quotation.SalesmanQuotationLineMapper;
14 16 import com.lframework.xingyun.sc.procurement.service.quotation.SalesmanQuotationLineService;
... ... @@ -53,6 +55,28 @@ public class SalesmanQuotationLineServiceImpl
53 55 }
54 56
55 57 /**
  58 + * 查询当日业务报价成交区域汇总
  59 + *
  60 + * @param day 日期
  61 + * @return 业务员报价区域汇总列表
  62 + */
  63 + @Override
  64 + public List<SalesmanQuotationDealRegionSummaryDto> statCurrentDayDealClosedByRegion(LocalDate day) {
  65 + return getBaseMapper().statCurrentDayDealClosedByRegion(day);
  66 + }
  67 +
  68 + /**
  69 + * 查询当日业务报价成交品种汇总
  70 + *
  71 + * @param day 日期
  72 + * @return 业务员报价品种汇总列表
  73 + */
  74 + @Override
  75 + public List<SalesmanQuotationDealProductSummaryDto> statCurrentDayDealClosedByProduct(LocalDate day) {
  76 + return getBaseMapper().statCurrentDayDealClosedByProduct(day);
  77 + }
  78 +
  79 + /**
56 80 * 根据ID查询
57 81 *
58 82 * @param id 主键ID
... ...
1 1 package com.lframework.xingyun.sc.procurement.mappers.quotation;
2 2
3 3 import com.lframework.starter.web.core.mapper.BaseMapper;
  4 +import com.lframework.xingyun.sc.procurement.dto.quotation.SalesmanQuotationDealProductSummaryDto;
  5 +import com.lframework.xingyun.sc.procurement.dto.quotation.SalesmanQuotationDealRegionSummaryDto;
4 6 import com.lframework.xingyun.sc.procurement.entity.SalesmanQuotationLine;
5 7 import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySalesmanQuotationLineVo;
6 8 import java.time.LocalDate;
... ... @@ -27,4 +29,20 @@ public interface SalesmanQuotationLineMapper extends BaseMapper<SalesmanQuotatio
27 29 * @return 业务员报价明细表列表
28 30 */
29 31 List<SalesmanQuotationLine> queryCurrentDayList(@Param("day") LocalDate day, @Param("status") String status);
  32 +
  33 + /**
  34 + * 查询当日业务报价成交区域汇总
  35 + *
  36 + * @param day 日期
  37 + * @return 业务员报价区域汇总列表
  38 + */
  39 + List<SalesmanQuotationDealRegionSummaryDto> statCurrentDayDealClosedByRegion(@Param("day") LocalDate day);
  40 +
  41 + /**
  42 + * 查询当日业务报价成交品种汇总
  43 + *
  44 + * @param day 日期
  45 + * @return 业务员报价品种汇总列表
  46 + */
  47 + List<SalesmanQuotationDealProductSummaryDto> statCurrentDayDealClosedByProduct(@Param("day") LocalDate day);
30 48 }
... ...
1 1 package com.lframework.xingyun.sc.procurement.service.quotation;
2 2
3 3 import com.lframework.starter.web.core.service.BaseMpService;
  4 +import com.lframework.xingyun.sc.procurement.dto.quotation.SalesmanQuotationDealProductSummaryDto;
  5 +import com.lframework.xingyun.sc.procurement.dto.quotation.SalesmanQuotationDealRegionSummaryDto;
4 6 import com.lframework.xingyun.sc.procurement.entity.SalesmanQuotationLine;
5 7 import com.lframework.xingyun.sc.procurement.vo.quotation.CreateSalesmanQuotationLineVo;
6 8 import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySalesmanQuotationLineVo;
... ... @@ -30,6 +32,22 @@ public interface SalesmanQuotationLineService extends BaseMpService<SalesmanQuot
30 32 List<SalesmanQuotationLine> queryCurrentDayList(LocalDate day, String status);
31 33
32 34 /**
  35 + * 查询当日业务报价成交区域汇总
  36 + *
  37 + * @param day 日期
  38 + * @return 业务员报价区域汇总列表
  39 + */
  40 + List<SalesmanQuotationDealRegionSummaryDto> statCurrentDayDealClosedByRegion(LocalDate day);
  41 +
  42 + /**
  43 + * 查询当日业务报价成交品种汇总
  44 + *
  45 + * @param day 日期
  46 + * @return 业务员报价品种汇总列表
  47 + */
  48 + List<SalesmanQuotationDealProductSummaryDto> statCurrentDayDealClosedByProduct(LocalDate day);
  49 +
  50 + /**
33 51 * 根据ID查询
34 52 *
35 53 * @param id 主键ID
... ...
... ... @@ -94,4 +94,39 @@
94 94 </where>
95 95 ORDER BY tb.create_time DESC, tb.quotation_id DESC
96 96 </select>
  97 +
  98 + <select id="statCurrentDayDealClosedByRegion"
  99 + resultType="com.lframework.xingyun.sc.procurement.dto.quotation.SalesmanQuotationDealRegionSummaryDto">
  100 + SELECT
  101 + sq.region AS regionId,
  102 + sd1.name AS regionName,
  103 + SUM(tb.quantity) AS quantity
  104 + FROM procurement_salesman_quotation_line tb
  105 + INNER JOIN procurement_salesman_quotation sq ON sq.id = tb.quotation_id
  106 + LEFT JOIN sys_dept sd1 ON sd1.id = sq.region
  107 + <where>
  108 + DATE(sq.create_time) = #{day}
  109 + AND sq.status = 'DEAL_CLOSED'
  110 + </where>
  111 + GROUP BY sq.region, sd1.name
  112 + ORDER BY quantity DESC
  113 + </select>
  114 +
  115 + <select id="statCurrentDayDealClosedByProduct"
  116 + resultType="com.lframework.xingyun.sc.procurement.dto.quotation.SalesmanQuotationDealProductSummaryDto">
  117 + SELECT
  118 + tb.product_id AS productId,
  119 + br.product_name AS productName,
  120 + SUM(tb.quantity) AS quantity,
  121 + (SUM(tb.quantity * tb.purchase_price) / NULLIF(SUM(tb.quantity), 0)) AS price
  122 + FROM procurement_salesman_quotation_line tb
  123 + INNER JOIN procurement_salesman_quotation sq ON sq.id = tb.quotation_id
  124 + LEFT JOIN base_data_breed_relationship br ON br.id = tb.product_id
  125 + <where>
  126 + DATE(sq.create_time) = #{day}
  127 + AND sq.status = 'DEAL_CLOSED'
  128 + </where>
  129 + GROUP BY tb.product_id, br.product_name
  130 + ORDER BY quantity DESC
  131 + </select>
97 132 </mapper>
... ...