feat(wms): 重构发货报表统计功能
- 修改发货报表返回结构,支持汇总和按类型统计 - 新增WmsDeliveryReportResultVo用于封装报表结果 - 新增WmsDeliveryReportSummaryVo用于汇总统计 - 新增WmsDeliveryReportByTypeVo用于按类型统计 - 调整Mapper层SQL查询逻辑,分离汇总与明细查询 - 更新Controller层接口返回类型 - 优化Service层实现,组装新的报表数据结构
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.Arrays;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.klp.domain.vo.WmsDeliveryPlanStatisticsVo;
|
||||
import com.klp.domain.vo.WmsDeliveryReportResultVo;
|
||||
import com.klp.domain.vo.WmsDeliveryReportVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -122,10 +123,10 @@ public class WmsDeliveryPlanController extends BaseController {
|
||||
* @param endTime 结束时间
|
||||
*/
|
||||
@GetMapping("/report")
|
||||
public R<List<WmsDeliveryReportVo>> getDeliveryReport(
|
||||
public R<WmsDeliveryReportResultVo> getDeliveryReport(
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
List<WmsDeliveryReportVo> report = iWmsDeliveryPlanService.getDeliveryReport(startTime, endTime);
|
||||
WmsDeliveryReportResultVo report = iWmsDeliveryPlanService.getDeliveryReport(startTime, endTime);
|
||||
return R.ok(report);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.klp.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 发货报表按钢卷类型统计VO
|
||||
*/
|
||||
@Data
|
||||
public class WmsDeliveryReportByTypeVo {
|
||||
/**
|
||||
* 钢卷类型(品名)
|
||||
*/
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 发货单数量
|
||||
*/
|
||||
private Integer waybillCount = 0;
|
||||
|
||||
/**
|
||||
* 钢卷数量
|
||||
*/
|
||||
private Integer coilCount = 0;
|
||||
|
||||
/**
|
||||
* 总重量(吨)
|
||||
*/
|
||||
private BigDecimal totalWeight = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 日均发货单数量
|
||||
*/
|
||||
private BigDecimal dailyWaybillCount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 日均钢卷数量
|
||||
*/
|
||||
private BigDecimal dailyCoilCount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 日均重量(吨)
|
||||
*/
|
||||
private BigDecimal dailyWeight = BigDecimal.ZERO;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.klp.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 发货报表结果VO
|
||||
*/
|
||||
@Data
|
||||
public class WmsDeliveryReportResultVo {
|
||||
/**
|
||||
* 汇总统计
|
||||
*/
|
||||
private WmsDeliveryReportSummaryVo summary;
|
||||
|
||||
/**
|
||||
* 按钢卷类型统计明细
|
||||
*/
|
||||
private List<WmsDeliveryReportByTypeVo> details;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.klp.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 发货报表汇总统计VO
|
||||
*/
|
||||
@Data
|
||||
public class WmsDeliveryReportSummaryVo {
|
||||
/**
|
||||
* 发货单数量
|
||||
*/
|
||||
private Integer waybillCount = 0;
|
||||
|
||||
/**
|
||||
* 钢卷数量
|
||||
*/
|
||||
private Integer coilCount = 0;
|
||||
|
||||
/**
|
||||
* 总重量(吨)
|
||||
*/
|
||||
private BigDecimal totalWeight = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 日均发货单数量
|
||||
*/
|
||||
private BigDecimal dailyWaybillCount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 日均钢卷数量
|
||||
*/
|
||||
private BigDecimal dailyCoilCount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 日均重量(吨)
|
||||
*/
|
||||
private BigDecimal dailyWeight = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 统计开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 统计结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
}
|
||||
@@ -4,7 +4,8 @@ import com.klp.domain.WmsDeliveryPlan;
|
||||
import com.klp.domain.vo.WmsDeliveryPlanStatisticsVo;
|
||||
import com.klp.domain.vo.WmsDeliveryPlanVo;
|
||||
import com.klp.common.core.mapper.BaseMapperPlus;
|
||||
import com.klp.domain.vo.WmsDeliveryReportVo;
|
||||
import com.klp.domain.vo.WmsDeliveryReportByTypeVo;
|
||||
import com.klp.domain.vo.WmsDeliveryReportSummaryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -20,5 +21,7 @@ public interface WmsDeliveryPlanMapper extends BaseMapperPlus<WmsDeliveryPlanMap
|
||||
|
||||
List<WmsDeliveryPlanStatisticsVo> selectDeliveryPlanStatistics(Long planId);
|
||||
|
||||
List<WmsDeliveryReportVo> selectDeliveryReport(@Param("startTime")Date startTime, @Param("endTime")Date endTime);
|
||||
List<WmsDeliveryReportByTypeVo> selectDeliveryReportByType(@Param("startTime")Date startTime, @Param("endTime")Date endTime);
|
||||
|
||||
WmsDeliveryReportSummaryVo selectDeliveryReportSummary(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.klp.domain.vo.WmsDeliveryPlanVo;
|
||||
import com.klp.domain.bo.WmsDeliveryPlanBo;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.domain.vo.WmsDeliveryReportVo;
|
||||
import com.klp.domain.vo.WmsDeliveryReportResultVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
@@ -50,7 +50,13 @@ public interface IWmsDeliveryPlanService {
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 获取发货计划统计信息
|
||||
*/
|
||||
List<WmsDeliveryPlanStatisticsVo> getDeliveryPlanStatistics(Long planId);
|
||||
|
||||
List<WmsDeliveryReportVo> getDeliveryReport(Date startTime, Date endTime);
|
||||
/**
|
||||
* 获取发货报表统计信息(包含汇总和按类型统计)
|
||||
*/
|
||||
WmsDeliveryReportResultVo getDeliveryReport(Date startTime, Date endTime);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.klp.common.utils.StringUtils;
|
||||
import com.klp.domain.vo.WmsDeliveryPlanStatisticsVo;
|
||||
import com.klp.domain.vo.WmsDeliveryReportVo;
|
||||
import com.klp.domain.vo.WmsDeliveryReportByTypeVo;
|
||||
import com.klp.domain.vo.WmsDeliveryReportResultVo;
|
||||
import com.klp.domain.vo.WmsDeliveryReportSummaryVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.klp.domain.bo.WmsDeliveryPlanBo;
|
||||
@@ -124,9 +126,19 @@ public class WmsDeliveryPlanServiceImpl implements IWmsDeliveryPlanService {
|
||||
*
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 报表统计信息列表
|
||||
* @return 报表统计信息(包含汇总和按类型统计)
|
||||
*/
|
||||
public List<WmsDeliveryReportVo> getDeliveryReport(Date startTime, Date endTime) {
|
||||
return baseMapper.selectDeliveryReport(startTime, endTime);
|
||||
public WmsDeliveryReportResultVo getDeliveryReport(Date startTime, Date endTime) {
|
||||
WmsDeliveryReportResultVo result = new WmsDeliveryReportResultVo();
|
||||
|
||||
// 获取汇总数据
|
||||
WmsDeliveryReportSummaryVo summary = baseMapper.selectDeliveryReportSummary(startTime, endTime);
|
||||
result.setSummary(summary);
|
||||
|
||||
// 获取按钢卷类型分类的数据
|
||||
List<WmsDeliveryReportByTypeVo> details = baseMapper.selectDeliveryReportByType(startTime, endTime);
|
||||
result.setDetails(details);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
ORDER BY dp.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectDeliveryReport" resultType="com.klp.domain.vo.WmsDeliveryReportVo">
|
||||
<select id="selectDeliveryReportByType" resultType="com.klp.domain.vo.WmsDeliveryReportByTypeVo">
|
||||
SELECT
|
||||
dwd.product_name as productName,
|
||||
COUNT(DISTINCT dw.waybill_id) as waybillCount,
|
||||
@@ -89,7 +89,38 @@
|
||||
GROUP BY dwd.product_name
|
||||
ORDER BY totalWeight DESC
|
||||
</select>
|
||||
|
||||
<select id="selectDeliveryReportSummary" resultType="com.klp.domain.vo.WmsDeliveryReportSummaryVo">
|
||||
SELECT
|
||||
COUNT(DISTINCT dw.waybill_id) as waybillCount,
|
||||
SUM(dwd.quantity) as coilCount,
|
||||
SUM(dwd.weight) as totalWeight,
|
||||
CASE
|
||||
WHEN #{startTime} IS NOT NULL AND #{endTime} IS NOT NULL THEN
|
||||
ROUND(COUNT(DISTINCT dw.waybill_id) / (DATEDIFF(#{endTime}, #{startTime}) + 1), 2)
|
||||
ELSE 0
|
||||
END as dailyWaybillCount,
|
||||
CASE
|
||||
WHEN #{startTime} IS NOT NULL AND #{endTime} IS NOT NULL THEN
|
||||
ROUND(SUM(dwd.quantity) / (DATEDIFF(#{endTime}, #{startTime}) + 1), 2)
|
||||
ELSE 0
|
||||
END as dailyCoilCount,
|
||||
CASE
|
||||
WHEN #{startTime} IS NOT NULL AND #{endTime} IS NOT NULL THEN
|
||||
ROUND(SUM(dwd.weight) / (DATEDIFF(#{endTime}, #{startTime}) + 1), 2)
|
||||
ELSE 0
|
||||
END as dailyWeight,
|
||||
#{startTime} as startTime,
|
||||
#{endTime} as endTime
|
||||
FROM wms_delivery_waybill_detail dwd
|
||||
LEFT JOIN wms_delivery_waybill dw ON dwd.waybill_id = dw.waybill_id AND dw.del_flag = 0
|
||||
WHERE dwd.del_flag = 0
|
||||
<if test="startTime != null">
|
||||
AND dw.create_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND dw.create_time <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user