feat(wms): 新增收货报表统计功能

- 在 IWmsDeliveryPlanService 接口中新增 getReceivingReport 方法
- 在 WmsDeliveryPlanController 控制器中新增 /receivingReport 接口
- 在 WmsDeliveryPlanMapper 中新增收货报表相关查询方法
- 在 WmsDeliveryPlanMapper.xml 中新增收货报表的 SQL 查询语句
- 新增 WmsReceivingReportByTypeVo、WmsReceivingReportResultVo 和
  WmsReceivingReportSummaryVo 三个 VO 类用于收货报表数据传输
- 完善了送货报表 SQL 查询逻辑,增加与 wms_delivery_plan 表的关联及 plan_type 过滤条件
This commit is contained in:
2025-12-12 10:38:55 +08:00
parent c4b5797537
commit d80a3b2cc9
8 changed files with 219 additions and 0 deletions

View File

@@ -127,6 +127,17 @@ public class WmsDeliveryPlanController extends BaseController {
return R.ok(report); return R.ok(report);
} }
/**
* 获取收货报表统计信息planType=1对应钢卷待操作actionType=401
*/
@GetMapping("/receivingReport")
public R<WmsReceivingReportResultVo> getReceivingReport(
@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) {
WmsReceivingReportResultVo report = iWmsDeliveryPlanService.getReceivingReport(startTime, endTime);
return R.ok(report);
}
/** /**
* 根据计划ID获取可选钢卷列表计划绑定钢卷 - 明细已绑定钢卷 * 根据计划ID获取可选钢卷列表计划绑定钢卷 - 明细已绑定钢卷

View File

@@ -0,0 +1,45 @@
package com.klp.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* 收货报表按类型统计VO
*/
@Data
public class WmsReceivingReportByTypeVo {
/**
* 类型(品名)
*/
private String productName;
/**
* 待操作记录数量
*/
private Integer taskCount = 0;
/**
* 钢卷数量
*/
private Integer coilCount = 0;
/**
* 总重量(吨)
*/
private BigDecimal totalWeight = BigDecimal.ZERO;
/**
* 日均待操作数量
*/
private BigDecimal dailyTaskCount = BigDecimal.ZERO;
/**
* 日均钢卷数量
*/
private BigDecimal dailyCoilCount = BigDecimal.ZERO;
/**
* 日均重量(吨)
*/
private BigDecimal dailyWeight = BigDecimal.ZERO;
}

View File

@@ -0,0 +1,20 @@
package com.klp.domain.vo;
import lombok.Data;
import java.util.List;
/**
* 收货报表结果VO
*/
@Data
public class WmsReceivingReportResultVo {
/**
* 汇总统计
*/
private WmsReceivingReportSummaryVo summary;
/**
* 按类型统计明细
*/
private List<WmsReceivingReportByTypeVo> details;
}

View File

@@ -0,0 +1,51 @@
package com.klp.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 收货报表汇总统计VO
*/
@Data
public class WmsReceivingReportSummaryVo {
/**
* 待操作记录数量
*/
private Integer taskCount = 0;
/**
* 钢卷数量
*/
private Integer coilCount = 0;
/**
* 总重量(吨)
*/
private BigDecimal totalWeight = BigDecimal.ZERO;
/**
* 日均待操作数量
*/
private BigDecimal dailyTaskCount = BigDecimal.ZERO;
/**
* 日均钢卷数量
*/
private BigDecimal dailyCoilCount = BigDecimal.ZERO;
/**
* 日均重量(吨)
*/
private BigDecimal dailyWeight = BigDecimal.ZERO;
/**
* 统计开始时间
*/
private Date startTime;
/**
* 统计结束时间
*/
private Date endTime;
}

View File

@@ -6,6 +6,8 @@ import com.klp.domain.vo.WmsDeliveryPlanVo;
import com.klp.common.core.mapper.BaseMapperPlus; import com.klp.common.core.mapper.BaseMapperPlus;
import com.klp.domain.vo.WmsDeliveryReportByTypeVo; import com.klp.domain.vo.WmsDeliveryReportByTypeVo;
import com.klp.domain.vo.WmsDeliveryReportSummaryVo; import com.klp.domain.vo.WmsDeliveryReportSummaryVo;
import com.klp.domain.vo.WmsReceivingReportByTypeVo;
import com.klp.domain.vo.WmsReceivingReportSummaryVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date; import java.util.Date;
@@ -24,4 +26,10 @@ public interface WmsDeliveryPlanMapper extends BaseMapperPlus<WmsDeliveryPlanMap
List<WmsDeliveryReportByTypeVo> selectDeliveryReportByType(@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); WmsDeliveryReportSummaryVo selectDeliveryReportSummary(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
List<WmsReceivingReportByTypeVo> selectReceivingReportByType(@Param("startTime") Date startTime,
@Param("endTime") Date endTime);
WmsReceivingReportSummaryVo selectReceivingReportSummary(@Param("startTime") Date startTime,
@Param("endTime") Date endTime);
} }

View File

@@ -8,6 +8,7 @@ import com.klp.common.core.page.TableDataInfo;
import com.klp.common.core.domain.PageQuery; import com.klp.common.core.domain.PageQuery;
import com.klp.domain.vo.WmsDeliveryReportResultVo; import com.klp.domain.vo.WmsDeliveryReportResultVo;
import com.klp.domain.vo.WmsMaterialCoilVo; import com.klp.domain.vo.WmsMaterialCoilVo;
import com.klp.domain.vo.WmsReceivingReportResultVo;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@@ -63,4 +64,9 @@ public interface IWmsDeliveryPlanService {
List<WmsMaterialCoilVo> getSelectableCoilsByPlanId(Long planId); List<WmsMaterialCoilVo> getSelectableCoilsByPlanId(Long planId);
/**
* 获取收货报表统计信息(包含汇总和按类型统计)
*/
WmsReceivingReportResultVo getReceivingReport(Date startTime, Date endTime);
} }

View File

@@ -188,6 +188,19 @@ public class WmsDeliveryPlanServiceImpl implements IWmsDeliveryPlanService {
return result; return result;
} }
/**
* 获取收货报表统计信息
*/
@Override
public WmsReceivingReportResultVo getReceivingReport(Date startTime, Date endTime) {
WmsReceivingReportResultVo result = new WmsReceivingReportResultVo();
WmsReceivingReportSummaryVo summary = baseMapper.selectReceivingReportSummary(startTime, endTime);
result.setSummary(summary);
List<WmsReceivingReportByTypeVo> details = baseMapper.selectReceivingReportByType(startTime, endTime);
result.setDetails(details);
return result;
}
@Override @Override
public List<WmsMaterialCoilVo> getSelectableCoilsByPlanId(Long planId) { public List<WmsMaterialCoilVo> getSelectableCoilsByPlanId(Long planId) {
if (planId == null) { if (planId == null) {

View File

@@ -84,7 +84,9 @@
END as dailyWeight END as dailyWeight
FROM wms_delivery_waybill_detail dwd FROM wms_delivery_waybill_detail dwd
LEFT JOIN wms_delivery_waybill dw ON dwd.waybill_id = dw.waybill_id AND dw.del_flag = 0 LEFT JOIN wms_delivery_waybill dw ON dwd.waybill_id = dw.waybill_id AND dw.del_flag = 0
LEFT JOIN wms_delivery_plan dp ON dw.plan_id = dp.plan_id AND dp.del_flag = 0
WHERE dwd.del_flag = 0 WHERE dwd.del_flag = 0
AND dp.plan_type = 0
<if test="startTime != null"> <if test="startTime != null">
AND dw.create_time >= #{startTime} AND dw.create_time >= #{startTime}
</if> </if>
@@ -118,7 +120,9 @@
#{endTime} as endTime #{endTime} as endTime
FROM wms_delivery_waybill_detail dwd FROM wms_delivery_waybill_detail dwd
LEFT JOIN wms_delivery_waybill dw ON dwd.waybill_id = dw.waybill_id AND dw.del_flag = 0 LEFT JOIN wms_delivery_waybill dw ON dwd.waybill_id = dw.waybill_id AND dw.del_flag = 0
LEFT JOIN wms_delivery_plan dp ON dw.plan_id = dp.plan_id AND dp.del_flag = 0
WHERE dwd.del_flag = 0 WHERE dwd.del_flag = 0
AND dp.plan_type = 0
<if test="startTime != null"> <if test="startTime != null">
AND dw.create_time >= #{startTime} AND dw.create_time >= #{startTime}
</if> </if>
@@ -128,4 +132,65 @@
</select> </select>
<!-- 收货报表按计划统计基于钢卷待操作action_type=401wcpa.warehouse_id -> 收货计划ID统计全量收货计划 -->
<select id="selectReceivingReportByType" resultType="com.klp.domain.vo.WmsReceivingReportByTypeVo">
SELECT
dp.plan_name AS productName,
COUNT(wcpa.action_id) AS taskCount,
COUNT(DISTINCT wcpa.coil_id) AS coilCount,
COALESCE(SUM(mc.net_weight), 0) AS totalWeight,
CASE WHEN #{startTime} IS NOT NULL AND #{endTime} IS NOT NULL THEN
ROUND(COUNT(wcpa.action_id) / (DATEDIFF(#{endTime}, #{startTime}) + 1), 2)
ELSE 0 END AS dailyTaskCount,
CASE WHEN #{startTime} IS NOT NULL AND #{endTime} IS NOT NULL THEN
ROUND(COUNT(DISTINCT wcpa.coil_id) / (DATEDIFF(#{endTime}, #{startTime}) + 1), 2)
ELSE 0 END AS dailyCoilCount,
CASE WHEN #{startTime} IS NOT NULL AND #{endTime} IS NOT NULL THEN
ROUND(COALESCE(SUM(mc.net_weight), 0) / (DATEDIFF(#{endTime}, #{startTime}) + 1), 2)
ELSE 0 END AS dailyWeight
FROM wms_coil_pending_action wcpa
LEFT JOIN wms_delivery_plan dp ON dp.plan_id = wcpa.warehouse_id AND dp.del_flag = 0 AND dp.plan_type = 1
LEFT JOIN wms_material_coil mc ON mc.coil_id = wcpa.coil_id AND mc.del_flag = 0
WHERE wcpa.del_flag = 0
AND wcpa.action_type = 401
<if test="startTime != null">
AND wcpa.create_time &gt;= #{startTime}
</if>
<if test="endTime != null">
AND wcpa.create_time &lt;= #{endTime}
</if>
GROUP BY dp.plan_name
ORDER BY taskCount DESC
</select>
<!-- 收货报表汇总统计基于钢卷待操作action_type=401统计全量收货计划 -->
<select id="selectReceivingReportSummary" resultType="com.klp.domain.vo.WmsReceivingReportSummaryVo">
SELECT
COUNT(wcpa.action_id) AS taskCount,
COUNT(DISTINCT wcpa.coil_id) AS coilCount,
COALESCE(SUM(mc.net_weight), 0) AS totalWeight,
CASE WHEN #{startTime} IS NOT NULL AND #{endTime} IS NOT NULL THEN
ROUND(COUNT(wcpa.action_id) / (DATEDIFF(#{endTime}, #{startTime}) + 1), 2)
ELSE 0 END AS dailyTaskCount,
CASE WHEN #{startTime} IS NOT NULL AND #{endTime} IS NOT NULL THEN
ROUND(COUNT(DISTINCT wcpa.coil_id) / (DATEDIFF(#{endTime}, #{startTime}) + 1), 2)
ELSE 0 END AS dailyCoilCount,
CASE WHEN #{startTime} IS NOT NULL AND #{endTime} IS NOT NULL THEN
ROUND(COALESCE(SUM(mc.net_weight), 0) / (DATEDIFF(#{endTime}, #{startTime}) + 1), 2)
ELSE 0 END AS dailyWeight,
#{startTime} AS startTime,
#{endTime} AS endTime
FROM wms_coil_pending_action wcpa
LEFT JOIN wms_delivery_plan dp ON dp.plan_id = wcpa.warehouse_id AND dp.del_flag = 0 AND dp.plan_type = 1
LEFT JOIN wms_material_coil mc ON mc.coil_id = wcpa.coil_id AND mc.del_flag = 0
WHERE wcpa.del_flag = 0
AND wcpa.action_type = 401
<if test="startTime != null">
AND wcpa.create_time &gt;= #{startTime}
</if>
<if test="endTime != null">
AND wcpa.create_time &lt;= #{endTime}
</if>
</select>
</mapper> </mapper>