新增统计相关接口

新增ocr相关功能
单据列表修改为/listWithDetail,之前的list和listGroup不再使用
This commit is contained in:
2025-12-07 16:42:33 +08:00
parent f1e7868ae1
commit 4bcd655827
13 changed files with 922 additions and 204 deletions

View File

@@ -5,18 +5,11 @@ import javax.servlet.http.HttpServletResponse;
import com.delivery.project.document.domain.dto.DeliveryOrderCreateDTO;
import com.delivery.project.document.domain.dto.DeliveryOrderSaveDTO;
import com.delivery.project.document.domain.vo.DeliveryBillVO;
import com.delivery.project.document.domain.vo.DeliveryOrderGroupVO;
import com.delivery.project.document.domain.dto.DeliveryOrderStatQuery;
import com.delivery.project.document.domain.vo.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.delivery.framework.aspectj.lang.annotation.Log;
import com.delivery.framework.aspectj.lang.enums.BusinessType;
import com.delivery.project.document.domain.DeliveryOrder;
@@ -34,33 +27,45 @@ import com.delivery.framework.web.page.TableDataInfo;
*/
@RestController
@RequestMapping("/document/order")
public class DeliveryOrderController extends BaseController
{
public class DeliveryOrderController extends BaseController {
@Autowired
private IDeliveryOrderService deliveryOrderService;
/**
* 查询配送单据主列表
*/
@PreAuthorize("@ss.hasPermi('document:order:list')")
@GetMapping("/list")
public TableDataInfo list(DeliveryOrder deliveryOrder)
{
// @PreAuthorize("@ss.hasPermi('document:order:list')")
@PostMapping("/list")
public TableDataInfo list(@RequestBody DeliveryOrder deliveryOrder) {
startPage();
List<DeliveryOrder> list = deliveryOrderService.selectDeliveryOrderList(deliveryOrder);
return getDataTable(list);
}
/**
* 新增:详细列表(表头 + 货物明细 + 照片),不分页
*/
// @PreAuthorize("@ss.hasPermi('document:order:list')")
@GetMapping("/listWithDetail")
public TableDataInfo listWithDetail(DeliveryOrder deliveryOrder) {
startPage();
List<DeliveryOrderVo> list = deliveryOrderService.selectDeliveryOrderVoList(deliveryOrder);
return getDataTable(list);
}
/**
* 导出配送单据主列表
*/
@PreAuthorize("@ss.hasPermi('document:order:export')")
@Log(title = "配送单据主", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DeliveryOrder deliveryOrder)
{
public void export(HttpServletResponse response, DeliveryOrder deliveryOrder) {
List<DeliveryOrder> list = deliveryOrderService.selectDeliveryOrderList(deliveryOrder);
ExcelUtil<DeliveryOrder> util = new ExcelUtil<DeliveryOrder>(DeliveryOrder.class);
ExcelUtil<DeliveryOrder> util = new ExcelUtil<>(DeliveryOrder.class);
util.exportExcel(response, list, "配送单据主数据");
}
@@ -69,8 +74,7 @@ public class DeliveryOrderController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('document:order:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(deliveryOrderService.selectDeliveryOrderById(id));
}
@@ -80,8 +84,7 @@ public class DeliveryOrderController extends BaseController
@PreAuthorize("@ss.hasPermi('document:order:add')")
@Log(title = "配送单据主", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DeliveryOrder deliveryOrder)
{
public AjaxResult add(@RequestBody DeliveryOrder deliveryOrder) {
return toAjax(deliveryOrderService.insertDeliveryOrder(deliveryOrder));
}
@@ -100,17 +103,13 @@ public class DeliveryOrderController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('document:order:remove')")
@Log(title = "配送单据主", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(deliveryOrderService.deleteDeliveryOrderByIds(ids));
}
/**
* 保存配送单
* @param dto
* @return
* 保存配送单(含附件)
*/
@PreAuthorize("@ss.hasPermi('document:order:add')")
@Log(title = "配送单据主-保存(含附件)", businessType = BusinessType.INSERT)
@@ -121,7 +120,6 @@ public class DeliveryOrderController extends BaseController
return toAjax(rows);
}
/** 发布配送单据:同一单号多行写入 */
@PreAuthorize("@ss.hasPermi('document:order:add')")
@Log(title = "配送单据", businessType = BusinessType.INSERT)
@@ -144,19 +142,49 @@ public class DeliveryOrderController extends BaseController
// @PreAuthorize("@ss.hasPermi('document:order:query')")
@GetMapping("/detail/{orderNo}")
public AjaxResult detail(@PathVariable String orderNo) {
return success(deliveryOrderService.listByOrderNo(orderNo));
}
/**
* 从智慧实物系统拉取待配送出库单据列表
*/
@GetMapping("/wisdom/rk/list")
public AjaxResult listRkFromWisdom() {
// 这里直接返回一对多结构
List<DeliveryBillVO> list = deliveryOrderService.listWisdomRkForDelivery();
return AjaxResult.success(list);
}
// ======================== 统计接口 ========================
/** 总览统计 */
//@PreAuthorize("@ss.hasPermi('document:order:stat')")
@PostMapping("/stat/overview")
public AjaxResult statOverview(@RequestBody DeliveryOrderStatQuery query) {
DeliveryOverviewStatVO vo = deliveryOrderService.statOverview(query);
return AjaxResult.success(vo);
}
/** 按配送状态统计 */
//@PreAuthorize("@ss.hasPermi('document:order:stat')")
@PostMapping("/stat/status")
public AjaxResult statByStatus(@RequestBody DeliveryOrderStatQuery query) {
List<DeliveryStatusStatVO> list = deliveryOrderService.statByStatus(query);
return AjaxResult.success(list);
}
/** 按车辆类型统计 */
//@PreAuthorize("@ss.hasPermi('document:order:stat')")
@PostMapping("/stat/vehicleType")
public AjaxResult statByVehicleType(@RequestBody DeliveryOrderStatQuery query) {
List<DeliveryVehicleTypeStatVO> list = deliveryOrderService.statByVehicleType(query);
return AjaxResult.success(list);
}
/** 按日期(日维度)统计 */
//@PreAuthorize("@ss.hasPermi('document:order:stat')")
@PostMapping("/stat/daily")
public AjaxResult statByDaily(@RequestBody DeliveryOrderStatQuery query) {
List<DeliveryDailyStatVO> list = deliveryOrderService.statByDaily(query);
return AjaxResult.success(list);
}
}

View File

@@ -0,0 +1,40 @@
package com.delivery.project.document.domain.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 配送统计查询条件
*/
@Data
public class DeliveryOrderStatQuery {
/** 开始日期(按配送日期过滤) */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date beginDate;
/** 结束日期(按配送日期过滤) */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endDate;
/** 配送状态单选0待接单 1已接单 2配送中 3已签收 */
private String orderStatus;
/** 配送状态(多选) */
private List<String> orderStatusList;
/** 车辆类型ID */
private Long vehicleTypeId;
/** 车牌号(可选,用于后续扩展) */
private String plateNo;
/** 起始地点名称模糊查询 */
private String originName;
/** 目的地名称模糊查询 */
private String destName;
}

View File

@@ -0,0 +1,33 @@
package com.delivery.project.document.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 按日期(日)统计
*/
@Data
public class DeliveryDailyStatVO {
/** 统计日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date statDate;
/** 订单数 */
private Long orderCount;
/** 总配送吨位 */
private BigDecimal totalDeliveryTon;
/** 总货物面积 */
private BigDecimal totalGoodsSize;
/** 总实际费用 */
private BigDecimal totalActualFee;
/** 总行驶公里数 */
private BigDecimal totalKm;
}

View File

@@ -0,0 +1,124 @@
package com.delivery.project.document.domain.vo;
import com.delivery.project.document.domain.DeliveryAttachment;
import com.delivery.project.document.domain.dto.DeliveryOrderLineDTO;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 配送单据返回视图对象(头 + 行明细 + 照片)
*/
@Data
public class DeliveryOrderVo {
/** 配送单据号(可空,后台自动生成) */
private String orderNo;
/** 出库单据号 */
private String billNoCk;
/** 起始地点名称 */
private String originName;
/** 起始地点经度 */
private BigDecimal originLng;
/** 起始地点纬度 */
private BigDecimal originLat;
/** 目的地点名称 */
private String destName;
/** 目的地点经度 */
private BigDecimal destLng;
/** 目的地点纬度 */
private BigDecimal destLat;
/** 配送日期 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date deliveryDate;
/** 车牌号 */
private String plateNo;
/** 发货人名称 */
private String shipperName;
/** 发货人联系方式 */
private String shipperPhone;
/** 接收人名称 */
private String receiverName;
/** 接收人联系方式 */
private String receiverPhone;
/** 接收单位 */
private String receiverOrgName;
/** 配送吨位 */
private BigDecimal deliveryTon;
/** 货物尺寸 */
private BigDecimal goodsSize;
/**
* 接收物资状态:
* 1数量齐全、状态完好默认
* 2存在问题
*/
private Integer receiveStatus;
/**
* 接收物资问题描述receiveStatus = 2 时必填)
*/
private String receiveProblem;
/** 制单人ID前端可传如果为空则后台自动取当前登录用户ID */
private Long makerId;
/** 配送状态默认1 已接单 / 后续会调整) */
private String orderStatus;
/** 车型 ID */
private Long vehicleTypeId;
/** 车型名称 */
private String vehicleTypeName;
/** 建议费用 */
private BigDecimal suggestFee;
/** 实际费用 */
private BigDecimal actualFee;
/** 高速费用 */
private BigDecimal tollFee;
/** 总公里数 */
private BigDecimal totalKm;
/** 备注 */
private String remark;
// ==================== 行明细(多物料行) ====================
/**
* 物料明细项列表(同一单号下多条记录)
* 每条记录包含项目、物料、数量、单位等信息
*/
private List<DeliveryOrderLineDTO> items;
// ==================== 照片 / 附件 ====================
/**
* 当前配送单据下的所有附件
* (现场照片 / 司机签字 / 收货签字 / 单据照片等)
*/
private List<DeliveryAttachment> attachments;
}

View File

@@ -0,0 +1,45 @@
package com.delivery.project.document.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* 配送总览统计
*/
@Data
public class DeliveryOverviewStatVO {
/** 总订单数 */
private Long totalOrderCount;
/** 总配送吨位 */
private BigDecimal totalDeliveryTon;
/** 总货物面积(㎡) */
private BigDecimal totalGoodsSize;
/** 总建议费用 */
private BigDecimal totalSuggestFee;
/** 总实际费用 */
private BigDecimal totalActualFee;
/** 总高速费用 */
private BigDecimal totalTollFee;
/** 总行驶公里数 */
private BigDecimal totalKm;
/** 待接单数量status=0 */
private Long waitCount;
/** 已接单数量status=1 */
private Long acceptedCount;
/** 配送中数量status=2 */
private Long deliveringCount;
/** 已签收数量status=3 */
private Long signedCount;
}

View File

@@ -0,0 +1,30 @@
package com.delivery.project.document.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* 按配送状态统计
*/
@Data
public class DeliveryStatusStatVO {
/** 配送状态0待接单 1已接单 2配送中 3已签收 */
private String orderStatus;
/** 订单数 */
private Long orderCount;
/** 总配送吨位 */
private BigDecimal totalDeliveryTon;
/** 总货物面积 */
private BigDecimal totalGoodsSize;
/** 总实际费用 */
private BigDecimal totalActualFee;
/** 总行驶公里数 */
private BigDecimal totalKm;
}

View File

@@ -0,0 +1,33 @@
package com.delivery.project.document.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* 按车辆类型统计
*/
@Data
public class DeliveryVehicleTypeStatVO {
/** 车辆类型ID */
private Long vehicleTypeId;
/** 车辆类型名称 */
private String vehicleTypeName;
/** 订单数 */
private Long orderCount;
/** 总配送吨位 */
private BigDecimal totalDeliveryTon;
/** 总货物面积 */
private BigDecimal totalGoodsSize;
/** 总实际费用 */
private BigDecimal totalActualFee;
/** 总行驶公里数 */
private BigDecimal totalKm;
}

View File

@@ -2,7 +2,8 @@ package com.delivery.project.document.mapper;
import java.util.List;
import com.delivery.project.document.domain.DeliveryOrder;
import com.delivery.project.document.domain.vo.DeliveryOrderGroupVO;
import com.delivery.project.document.domain.dto.DeliveryOrderStatQuery;
import com.delivery.project.document.domain.vo.*;
import org.apache.ibatis.annotations.Param;
/**
@@ -92,4 +93,21 @@ public interface DeliveryOrderMapper
* @return
*/
List<DeliveryOrder> selectDeliveryOrderByOrderNo(String orderNo);
// ======================== 统计 ========================
/** 总览统计 */
DeliveryOverviewStatVO selectOverviewStat(@Param("q") DeliveryOrderStatQuery query);
/** 按配送状态统计 */
List<DeliveryStatusStatVO> selectStatusStat(@Param("q") DeliveryOrderStatQuery query);
/** 按车辆类型统计 */
List<DeliveryVehicleTypeStatVO> selectVehicleTypeStat(@Param("q") DeliveryOrderStatQuery query);
/** 按日期(日维度)统计 */
List<DeliveryDailyStatVO> selectDailyStat(@Param("q") DeliveryOrderStatQuery query);
/** 配送单VO列表 */
List<DeliveryOrderVo> selectDeliveryOrderVoList(DeliveryOrder deliveryOrder);
}

View File

@@ -1,12 +1,12 @@
package com.delivery.project.document.service;
import java.util.List;
import com.delivery.project.document.domain.DeliveryOrder;
import com.delivery.project.document.domain.dto.DeliveryOrderCreateDTO;
import com.delivery.project.document.domain.dto.DeliveryOrderSaveDTO;
import com.delivery.project.document.domain.vo.DeliveryBillVO;
import com.delivery.project.document.domain.vo.DeliveryOrderDetailVO;
import com.delivery.project.document.domain.vo.DeliveryOrderGroupVO;
import com.delivery.project.document.domain.dto.DeliveryOrderStatQuery;
import com.delivery.project.document.domain.vo.*;
/**
* 配送单据主Service接口
@@ -14,94 +14,46 @@ import com.delivery.project.document.domain.vo.DeliveryOrderGroupVO;
* @author delivery
* @date 2025-10-15
*/
public interface IDeliveryOrderService
{
/**
* 查询配送单据主
*
* @param id 配送单据主主键
* @return 配送单据主
*/
public DeliveryOrder selectDeliveryOrderById(Long id);
public interface IDeliveryOrderService {
/**
* 查询配送单据主列表
*
* @param deliveryOrder 配送单据主
* @return 配送单据主集合
*/
public List<DeliveryOrder> selectDeliveryOrderList(DeliveryOrder deliveryOrder);
DeliveryOrder selectDeliveryOrderById(Long id);
/**
* 新增配送单据主
*
* @param deliveryOrder 配送单据主
* @return 结果
*/
public int insertDeliveryOrder(DeliveryOrder deliveryOrder);
List<DeliveryOrder> selectDeliveryOrderList(DeliveryOrder deliveryOrder);
/**
* 修改配送单据主
*
* @param deliveryOrder 配送单据主
* @return 结果
*/
public int updateDeliveryOrder(DeliveryOrder deliveryOrder);
int insertDeliveryOrder(DeliveryOrder deliveryOrder);
/**
* 批量删除配送单据主
*
* @param ids 需要删除的配送单据主主键集合
* @return 结果
*/
public int deleteDeliveryOrderByIds(Long[] ids);
int updateDeliveryOrder(DeliveryOrder deliveryOrder);
/**
* 删除配送单据主信息
*
* @param id 配送单据主主键
* @return 结果
*/
public int deleteDeliveryOrderById(Long id);
int deleteDeliveryOrderByIds(Long[] ids);
int deleteDeliveryOrderById(Long id);
/**
* 保存配送单据,并保存附件
*
* @param dto
* @param username
* @return
*/
int saveOrderWithAttachments(DeliveryOrderSaveDTO dto, String username);
/**
* 新建配送单据:同一单号多行写入
* @param dto
* @return
*/
String createOrder(DeliveryOrderCreateDTO dto);
/**
* 列表:按单号分组(分页)
* @param query
* @return
*/
List<DeliveryOrderGroupVO> listGroup(DeliveryOrder query);
/**
* 详情:按单号查询所有行
* @param plateNo
* @return
*/
/** 详情:按单号查行 */
List<DeliveryOrderDetailVO> listByOrderNo(String orderNo);
/**
* 从智慧实物系统查询待配送出库单据
*
* @return rk_info 列表
*/
/** 从智慧实物系统查询待配送出库单据 */
List<DeliveryBillVO> listWisdomRkForDelivery();
// ======================== 统计 ========================
/** 总览统计 */
DeliveryOverviewStatVO statOverview(DeliveryOrderStatQuery query);
/** 按配送状态统计 */
List<DeliveryStatusStatVO> statByStatus(DeliveryOrderStatQuery query);
/** 按车辆类型统计 */
List<DeliveryVehicleTypeStatVO> statByVehicleType(DeliveryOrderStatQuery query);
/** 按日期(日维度)统计 */
List<DeliveryDailyStatVO> statByDaily(DeliveryOrderStatQuery query);
/** 配送单VO列表 */
List<DeliveryOrderVo> selectDeliveryOrderVoList(DeliveryOrder deliveryOrder);
}

View File

@@ -15,13 +15,8 @@ import com.delivery.framework.web.domain.AjaxResult;
import com.delivery.project.document.domain.DeliveryAttachment;
import com.delivery.project.document.domain.Mtd;
import com.delivery.project.document.domain.RkInfo;
import com.delivery.project.document.domain.dto.DeliveryAttachUploadDTO;
import com.delivery.project.document.domain.dto.DeliveryOrderCreateDTO;
import com.delivery.project.document.domain.dto.DeliveryOrderLineDTO;
import com.delivery.project.document.domain.dto.DeliveryOrderSaveDTO;
import com.delivery.project.document.domain.vo.DeliveryBillVO;
import com.delivery.project.document.domain.vo.DeliveryOrderDetailVO;
import com.delivery.project.document.domain.vo.DeliveryOrderGroupVO;
import com.delivery.project.document.domain.dto.*;
import com.delivery.project.document.domain.vo.*;
import com.delivery.project.document.mapper.DeliveryAttachmentMapper;
import com.delivery.project.document.mapper.MtdMapper;
import com.delivery.project.document.mapper.RkInfoMapper;
@@ -83,6 +78,12 @@ public class DeliveryOrderServiceImpl implements IDeliveryOrderService
return deliveryOrderMapper.selectDeliveryOrderList(deliveryOrder);
}
@Override
public List<DeliveryOrderVo> selectDeliveryOrderVoList(DeliveryOrder deliveryOrder) {
return deliveryOrderMapper.selectDeliveryOrderVoList(deliveryOrder);
}
/**
* 新增配送单据主
*
@@ -472,4 +473,26 @@ public class DeliveryOrderServiceImpl implements IDeliveryOrderService
return list;
}
// ======================== 统计 ========================
@Override
public DeliveryOverviewStatVO statOverview(DeliveryOrderStatQuery query) {
return deliveryOrderMapper.selectOverviewStat(query);
}
@Override
public List<DeliveryStatusStatVO> statByStatus(DeliveryOrderStatQuery query) {
return deliveryOrderMapper.selectStatusStat(query);
}
@Override
public List<DeliveryVehicleTypeStatVO> statByVehicleType(DeliveryOrderStatQuery query) {
return deliveryOrderMapper.selectVehicleTypeStat(query);
}
@Override
public List<DeliveryDailyStatVO> statByDaily(DeliveryOrderStatQuery query) {
return deliveryOrderMapper.selectDailyStat(query);
}
}

View File

@@ -24,28 +24,4 @@ public class QwenProperties {
* 模型名称例如qwen-vl-ocr-latest
*/
private String model;
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public String getBaseUrl() {
return baseUrl;
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
}

View File

@@ -127,7 +127,7 @@ upload:
base-url: http://192.168.1.250/files
wisdom:
base-url: http://192.168.1.251:8086
base-url: http://192.168.1.5:8086
# =============== OCR 服务核心配置 ===============
ocr:

View File

@@ -103,6 +103,62 @@
resultMap="DeliveryAttachmentInlineResult"/>
</resultMap>
<!-- ======================== VO头 + items + 附件 ======================== -->
<!-- 这个是 listWithDetail 用的 VO类型请按你的类名建好 -->
<!-- class 路径假定为 com.delivery.project.document.domain.vo.DeliveryOrderVo -->
<resultMap id="DeliveryOrderVoResult"
type="com.delivery.project.document.domain.vo.DeliveryOrderVo">
<!-- 这里用单号作为主键标识 -->
<id property="orderNo" column="order_no"/>
<result property="makerId" column="maker_id"/>
<result property="receiveStatus" column="receive_status"/>
<result property="receiveProblem" column="receive_problem"/>
<result property="billNoCk" column="bill_no_ck"/>
<result property="originName" column="origin_name"/>
<result property="originLng" column="origin_lng" jdbcType="DECIMAL"/>
<result property="originLat" column="origin_lat" jdbcType="DECIMAL"/>
<result property="destName" column="dest_name"/>
<result property="destLng" column="dest_lng" jdbcType="DECIMAL"/>
<result property="destLat" column="dest_lat" jdbcType="DECIMAL"/>
<result property="deliveryDate" column="delivery_date"/>
<result property="plateNo" column="plate_no"/>
<result property="shipperName" column="shipper_name"/>
<result property="shipperPhone" column="shipper_phone"/>
<result property="receiverName" column="receiver_name"/>
<result property="receiverPhone" column="receiver_phone"/>
<result property="receiverOrgName" column="receiver_org_name"/>
<result property="deliveryTon" column="delivery_ton"/>
<result property="goodsSize" column="goods_size" jdbcType="DECIMAL"/>
<result property="orderStatus" column="order_status"/>
<result property="vehicleTypeId" column="vehicle_type_id"/>
<result property="vehicleTypeName" column="vehicle_type_name"/>
<result property="suggestFee" column="suggest_fee"/>
<result property="actualFee" column="actual_fee"/>
<result property="tollFee" column="toll_fee"/>
<result property="totalKm" column="total_km"/>
<result property="remark" column="remark"/>
<!-- 明细行items -->
<collection property="items"
ofType="com.delivery.project.document.domain.dto.DeliveryOrderLineDTO"
column="order_no"
select="selectLinesByOrderNo"/>
<!-- 附件attachments这里用简单查询不走 inline resultMap -->
<collection property="attachments"
ofType="com.delivery.project.document.domain.DeliveryAttachment"
column="order_no"
select="selectAttachmentsByOrderNo"/>
</resultMap>
<!-- ======================== 带附件的查询列(别名统一 dor ======================== -->
<sql id="selectDeliveryOrderVoWithAttach">
select
@@ -181,94 +237,332 @@
from delivery_order
</sql>
<!-- 仅用于列表:只查配送单据头字段,不查货物明细 -->
<sql id="selectDeliveryOrderHeader">
SELECT
dor.id,
dor.order_no,
-- 制单人 / 接收状态
dor.maker_id,
dor.receive_status,
dor.receive_problem,
-- 起始 / 目的地点
dor.origin_name,
dor.origin_lng,
dor.origin_lat,
dor.dest_name,
dor.dest_lng,
dor.dest_lat,
-- 配送信息
dor.delivery_date,
dor.plate_no,
dor.shipper_name,
dor.shipper_phone,
dor.receiver_name,
dor.receiver_phone,
dor.receiver_org_name,
dor.delivery_ton,
dor.goods_size,
dor.order_status,
-- 车型
dor.vehicle_type_id,
dor.vehicle_type_name,
-- 费用 / 里程
dor.suggest_fee,
dor.actual_fee,
dor.toll_fee,
dor.total_km,
-- 备注 + 通用字段
dor.remark,
dor.create_by,
dor.create_time,
dor.update_by,
dor.update_time,
dor.is_delete
FROM delivery_order dor
</sql>
<!-- ========== 新增:列表 + 明细 + 附件listWithDetail 用) ========== -->
<select id="selectDeliveryOrderVoList"
parameterType="com.delivery.project.document.domain.DeliveryOrder"
resultMap="DeliveryOrderVoResult">
SELECT
dor.order_no AS order_no,
MAX(dor.bill_no_ck) AS bill_no_ck,
MAX(dor.rk_info_id) AS rk_info_id,
MAX(dor.maker_id) AS maker_id,
MAX(dor.receive_status) AS receive_status,
MAX(dor.receive_problem) AS receive_problem,
MAX(dor.origin_name) AS origin_name,
MAX(dor.origin_lng) AS origin_lng,
MAX(dor.origin_lat) AS origin_lat,
MAX(dor.dest_name) AS dest_name,
MAX(dor.dest_lng) AS dest_lng,
MAX(dor.dest_lat) AS dest_lat,
MAX(dor.delivery_date) AS delivery_date,
MAX(dor.plate_no) AS plate_no,
MAX(dor.shipper_name) AS shipper_name,
MAX(dor.shipper_phone) AS shipper_phone,
MAX(dor.receiver_name) AS receiver_name,
MAX(dor.receiver_phone) AS receiver_phone,
MAX(dor.receiver_org_name) AS receiver_org_name,
MAX(dor.delivery_ton) AS delivery_ton,
MAX(dor.goods_size) AS goods_size,
MAX(dor.order_status) AS order_status,
MAX(dor.vehicle_type_id) AS vehicle_type_id,
MAX(dor.vehicle_type_name) AS vehicle_type_name,
MAX(dor.suggest_fee) AS suggest_fee,
MAX(dor.actual_fee) AS actual_fee,
MAX(dor.toll_fee) AS toll_fee,
MAX(dor.total_km) AS total_km,
MAX(dor.remark) AS remark
FROM
delivery_order dor
<where>
(dor.is_delete = '0' OR dor.is_delete = 0 OR dor.is_delete IS NULL)
<!-- 单号 -->
<if test="orderNo != null and orderNo != ''">
AND dor.order_no = #{orderNo}
</if>
<!-- 出库单据号 -->
<if test="billNoCk != null and billNoCk != ''">
AND dor.bill_no_ck = #{billNoCk}
</if>
<!-- 制单人 -->
<if test="makerId != null">
AND dor.maker_id = #{makerId}
</if>
<!-- 接收物资状态 -->
<if test="receiveStatus != null">
AND dor.receive_status = #{receiveStatus}
</if>
<!-- 项目描述(模糊) -->
<if test="xmMs != null and xmMs != ''">
AND dor.xm_ms LIKE CONCAT('%', #{xmMs}, '%')
</if>
<!-- 项目号 -->
<if test="xmNo != null and xmNo != ''">
AND dor.xm_no LIKE CONCAT('%', #{xmNo}, '%')
</if>
<!-- 物料号 -->
<if test="wlNo != null and wlNo != ''">
AND dor.wl_no LIKE CONCAT('%', #{wlNo}, '%')
</if>
<!-- 物料描述 -->
<if test="wlMs != null and wlMs != ''">
AND dor.wl_ms LIKE CONCAT('%', #{wlMs}, '%')
</if>
<!-- SAP订单编号 -->
<if test="sapNo != null and sapNo != ''">
AND dor.sap_no LIKE CONCAT('%', #{sapNo}, '%')
</if>
<!-- 供应商名称 -->
<if test="gysMc != null and gysMc != ''">
AND dor.gys_mc LIKE CONCAT('%', #{gysMc}, '%')
</if>
<!-- 起始 / 目的地点模糊 -->
<if test="originName != null and originName != ''">
AND dor.origin_name LIKE CONCAT('%', #{originName}, '%')
</if>
<if test="destName != null and destName != ''">
AND dor.dest_name LIKE CONCAT('%', #{destName}, '%')
</if>
<!-- 配送日期 -->
<if test="deliveryDate != null">
AND dor.delivery_date = #{deliveryDate}
</if>
<!-- 车牌 -->
<if test="plateNo != null and plateNo != ''">
AND dor.plate_no = #{plateNo}
</if>
<!-- 配送状态:优先用多选列表 -->
<if test="orderStatusList != null and orderStatusList.size > 0">
AND dor.order_status IN
<foreach collection="orderStatusList" item="st" open="(" separator="," close=")">
#{st}
</foreach>
</if>
<!-- 如果没有多选,再用单个状态 -->
<if test="(orderStatusList == null or orderStatusList.size == 0)
and orderStatus != null and orderStatus != ''">
AND dor.order_status = #{orderStatus}
</if>
</where>
GROUP BY dor.order_no
ORDER BY MAX(dor.create_time) DESC
</select>
<!-- 供 VO 使用:按单号查所有行明细 -->
<select id="selectLinesByOrderNo"
parameterType="java.lang.String"
resultType="com.delivery.project.document.domain.dto.DeliveryOrderLineDTO">
SELECT
dor.id,
dor.rk_info_id AS rkInfoId,
dor.bill_no_ck AS billNoCk,
dor.xm_ms AS xmMs,
dor.xm_no AS xmNo,
dor.wl_no AS wlNo,
dor.wl_ms AS wlMs,
dor.real_qty AS realQty,
dor.dw AS dw,
dor.sap_no AS sapNo,
dor.gys_mc AS gysMc,
dor.remark AS remark
FROM delivery_order dor
WHERE (dor.is_delete = '0' OR dor.is_delete = 0 OR dor.is_delete IS NULL)
AND dor.order_no = #{value}
ORDER BY dor.id ASC
</select>
<!-- 供 VO 使用:按单号查附件 -->
<select id="selectAttachmentsByOrderNo"
parameterType="java.lang.String"
resultType="com.delivery.project.document.domain.DeliveryAttachment">
SELECT
id,
order_no,
scene,
biz_type,
url,
status,
sort_no,
remark,
create_by,
create_time,
update_by,
update_time,
is_delete
FROM delivery_attachment
WHERE is_delete = '0'
AND order_no = #{value}
ORDER BY sort_no ASC, id ASC
</select>
<!-- ======================== 列表查询(使用 dor 别名) ======================== -->
<select id="selectDeliveryOrderList"
parameterType="com.delivery.project.document.domain.DeliveryOrder"
resultMap="DeliveryOrderWithAttachResult">
<include refid="selectDeliveryOrderVoWithAttach"/>
resultMap="DeliveryOrderResult">
<include refid="selectDeliveryOrderHeader"/>
<where>
<!-- 删除标记 -->
<choose>
<when test="isDelete != null and isDelete != ''">
and dor.is_delete = #{isDelete}
AND dor.is_delete = #{isDelete}
</when>
<otherwise>
and dor.is_delete = '0'
AND (dor.is_delete = '0' OR dor.is_delete = 0 OR dor.is_delete IS NULL)
</otherwise>
</choose>
<!-- 制单人ID / 接收状态筛选(可选) -->
<!-- 单号 -->
<if test="orderNo != null and orderNo != ''">
AND dor.order_no = #{orderNo}
</if>
<!-- 制单人 -->
<if test="makerId != null">
and dor.maker_id = #{makerId}
AND dor.maker_id = #{makerId}
</if>
<!-- 接收状态 -->
<if test="receiveStatus != null">
and dor.receive_status = #{receiveStatus}
AND dor.receive_status = #{receiveStatus}
</if>
<if test="xmMs != null and xmMs != ''"> and dor.xm_ms = #{xmMs}</if>
<if test="xmNo != null and xmNo != ''"> and dor.xm_no = #{xmNo}</if>
<if test="wlNo != null and wlNo != ''"> and dor.wl_no = #{wlNo}</if>
<if test="wlMs != null and wlMs != ''"> and dor.wl_ms = #{wlMs}</if>
<if test="realQty != null "> and dor.real_qty = #{realQty}</if>
<if test="dw != null and dw != ''"> and dor.dw = #{dw}</if>
<if test="sapNo != null and sapNo != ''"> and dor.sap_no = #{sapNo}</if>
<if test="gysMc != null and gysMc != ''"> and dor.gys_mc = #{gysMc}</if>
<if test="originName != null and originName != ''">
and dor.origin_name like concat('%', #{originName}, '%')
<!-- 起始 / 目的地点模糊 -->
<if test="originName != null and originName != ''">
AND dor.origin_name LIKE CONCAT('%', #{originName}, '%')
</if>
<if test="originLng != null "> and dor.origin_lng = #{originLng}</if>
<if test="originLat != null "> and dor.origin_lat = #{originLat}</if>
<if test="destName != null and destName != ''">
and dor.dest_name like concat('%', #{destName}, '%')
</if>
<if test="destLng != null "> and dor.dest_lng = #{destLng}</if>
<if test="destLat != null "> and dor.dest_lat = #{destLat}</if>
<if test="deliveryDate != null "> and dor.delivery_date = #{deliveryDate}</if>
<if test="plateNo != null and plateNo != ''"> and dor.plate_no = #{plateNo}</if>
<!-- 司机筛选 -->
<if test="driverName != null and driverName != ''">
and dor.driver_name like concat('%', #{driverName}, '%')
</if>
<if test="driverPhone != null and driverPhone != ''">
and dor.driver_phone = #{driverPhone}
<if test="destName != null and destName != ''">
AND dor.dest_name LIKE CONCAT('%', #{destName}, '%')
</if>
<if test="shipperName != null and shipperName != ''">
and dor.shipper_name like concat('%', #{shipperName}, '%')
<!-- 经纬度(可选) -->
<if test="originLng != null">
AND dor.origin_lng = #{originLng}
</if>
<if test="shipperPhone != null and shipperPhone != ''">
and dor.shipper_phone = #{shipperPhone}
<if test="originLat != null">
AND dor.origin_lat = #{originLat}
</if>
<if test="receiverName != null and receiverName != ''">
and dor.receiver_name like concat('%', #{receiverName}, '%')
<if test="destLng != null">
AND dor.dest_lng = #{destLng}
</if>
<if test="receiverPhone != null and receiverPhone != ''">
and dor.receiver_phone = #{receiverPhone}
</if>
<if test="receiverOrgName != null and receiverOrgName != ''">
and dor.receiver_org_name like concat('%', #{receiverOrgName}, '%')
<if test="destLat != null">
AND dor.dest_lat = #{destLat}
</if>
<if test="deliveryTon != null "> and dor.delivery_ton = #{deliveryTon}</if>
<if test="goodsSize != null"> and dor.goods_size = #{goodsSize}</if>
<!-- 配送日期 -->
<if test="deliveryDate != null">
AND dor.delivery_date = #{deliveryDate}
</if>
<!-- 车牌 -->
<if test="plateNo != null and plateNo != ''">
AND dor.plate_no = #{plateNo}
</if>
<!-- 发货人 / 收货人 -->
<if test="shipperName != null and shipperName != ''">
AND dor.shipper_name LIKE CONCAT('%', #{shipperName}, '%')
</if>
<if test="shipperPhone != null and shipperPhone != ''">
AND dor.shipper_phone = #{shipperPhone}
</if>
<if test="receiverName != null and receiverName != ''">
AND dor.receiver_name LIKE CONCAT('%', #{receiverName}, '%')
</if>
<if test="receiverPhone != null and receiverPhone != ''">
AND dor.receiver_phone = #{receiverPhone}
</if>
<if test="receiverOrgName != null and receiverOrgName != ''">
AND dor.receiver_org_name LIKE CONCAT('%', #{receiverOrgName}, '%')
</if>
<!-- 配送吨位 / 尺寸(可选) -->
<if test="deliveryTon != null">
AND dor.delivery_ton = #{deliveryTon}
</if>
<if test="goodsSize != null">
AND dor.goods_size = #{goodsSize}
</if>
<!-- 配送状态 -->
<if test="orderStatus != null and orderStatus != ''">
and dor.order_status = #{orderStatus}
AND dor.order_status = #{orderStatus}
</if>
<!-- 车型筛选 -->
<if test="vehicleTypeId != null"> and dor.vehicle_type_id = #{vehicleTypeId}</if>
<!-- 车型 -->
<if test="vehicleTypeId != null">
AND dor.vehicle_type_id = #{vehicleTypeId}
</if>
<if test="vehicleTypeName != null and vehicleTypeName != ''">
and dor.vehicle_type_name like concat('%', #{vehicleTypeName}, '%')
AND dor.vehicle_type_name LIKE CONCAT('%', #{vehicleTypeName}, '%')
</if>
<!-- 费用/里程筛选 -->
<if test="suggestFee != null"> and dor.suggest_fee = #{suggestFee}</if>
<if test="actualFee != null"> and dor.actual_fee = #{actualFee}</if>
<if test="tollFee != null"> and dor.toll_fee = #{tollFee}</if>
<if test="totalKm != null"> and dor.total_km = #{totalKm}</if>
</where>
ORDER BY dor.create_time DESC
</select>
<!-- 主键查询(别名 dor -->
@@ -573,4 +867,126 @@
#{id}
</foreach>
</delete>
<!-- 公共统计 where 条件(按 q 传参) -->
<sql id="statWhere">
<where>
(dor.is_delete = '0' OR dor.is_delete = 0 OR dor.is_delete IS NULL)
<!-- 配送日期范围 -->
<if test="q.beginDate != null">
AND DATE(dor.delivery_date) <![CDATA[>=]]> DATE(#{q.beginDate})
</if>
<if test="q.endDate != null">
AND DATE(dor.delivery_date) <![CDATA[<=]]> DATE(#{q.endDate})
</if>
<!-- 状态多选优先 -->
<if test="q.orderStatusList != null and q.orderStatusList.size > 0">
AND dor.order_status IN
<foreach collection="q.orderStatusList" item="st" open="(" separator="," close=")">
#{st}
</foreach>
</if>
<!-- 单个状态 -->
<if test="(q.orderStatusList == null or q.orderStatusList.size == 0)
and q.orderStatus != null and q.orderStatus != ''">
AND dor.order_status = #{q.orderStatus}
</if>
<!-- 车辆类型 -->
<if test="q.vehicleTypeId != null">
AND dor.vehicle_type_id = #{q.vehicleTypeId}
</if>
<!-- 车牌号 -->
<if test="q.plateNo != null and q.plateNo != ''">
AND dor.plate_no = #{q.plateNo}
</if>
<!-- 起始地点模糊 -->
<if test="q.originName != null and q.originName != ''">
AND dor.origin_name LIKE CONCAT('%', #{q.originName}, '%')
</if>
<!-- 目的地点模糊 -->
<if test="q.destName != null and q.destName != ''">
AND dor.dest_name LIKE CONCAT('%', #{q.destName}, '%')
</if>
</where>
</sql>
<!-- 总览统计 -->
<select id="selectOverviewStat"
parameterType="com.delivery.project.document.domain.dto.DeliveryOrderStatQuery"
resultType="com.delivery.project.document.domain.vo.DeliveryOverviewStatVO">
SELECT
COUNT(1) AS totalOrderCount,
IFNULL(SUM(dor.delivery_ton), 0) AS totalDeliveryTon,
IFNULL(SUM(dor.goods_size), 0) AS totalGoodsSize,
IFNULL(SUM(dor.suggest_fee), 0) AS totalSuggestFee,
IFNULL(SUM(dor.actual_fee), 0) AS totalActualFee,
IFNULL(SUM(dor.toll_fee), 0) AS totalTollFee,
IFNULL(SUM(dor.total_km), 0) AS totalKm,
SUM(CASE WHEN dor.order_status = '0' THEN 1 ELSE 0 END) AS waitCount,
SUM(CASE WHEN dor.order_status = '1' THEN 1 ELSE 0 END) AS acceptedCount,
SUM(CASE WHEN dor.order_status = '2' THEN 1 ELSE 0 END) AS deliveringCount,
SUM(CASE WHEN dor.order_status = '3' THEN 1 ELSE 0 END) AS signedCount
FROM delivery_order dor
<include refid="statWhere"/>
</select>
<!-- 按配送状态统计 -->
<select id="selectStatusStat"
parameterType="com.delivery.project.document.domain.dto.DeliveryOrderStatQuery"
resultType="com.delivery.project.document.domain.vo.DeliveryStatusStatVO">
SELECT
dor.order_status AS orderStatus,
COUNT(1) AS orderCount,
IFNULL(SUM(dor.delivery_ton), 0) AS totalDeliveryTon,
IFNULL(SUM(dor.goods_size), 0) AS totalGoodsSize,
IFNULL(SUM(dor.actual_fee), 0) AS totalActualFee,
IFNULL(SUM(dor.total_km), 0) AS totalKm
FROM delivery_order dor
<include refid="statWhere"/>
GROUP BY dor.order_status
ORDER BY dor.order_status
</select>
<!-- 按车辆类型统计 -->
<select id="selectVehicleTypeStat"
parameterType="com.delivery.project.document.domain.dto.DeliveryOrderStatQuery"
resultType="com.delivery.project.document.domain.vo.DeliveryVehicleTypeStatVO">
SELECT
dor.vehicle_type_id AS vehicleTypeId,
dor.vehicle_type_name AS vehicleTypeName,
COUNT(1) AS orderCount,
IFNULL(SUM(dor.delivery_ton), 0) AS totalDeliveryTon,
IFNULL(SUM(dor.goods_size), 0) AS totalGoodsSize,
IFNULL(SUM(dor.actual_fee), 0) AS totalActualFee,
IFNULL(SUM(dor.total_km), 0) AS totalKm
FROM delivery_order dor
<include refid="statWhere"/>
GROUP BY dor.vehicle_type_id, dor.vehicle_type_name
ORDER BY orderCount DESC
</select>
<!-- 按日期(日维度)统计 -->
<select id="selectDailyStat"
parameterType="com.delivery.project.document.domain.dto.DeliveryOrderStatQuery"
resultType="com.delivery.project.document.domain.vo.DeliveryDailyStatVO">
SELECT
DATE(dor.delivery_date) AS statDate,
COUNT(1) AS orderCount,
IFNULL(SUM(dor.delivery_ton), 0) AS totalDeliveryTon,
IFNULL(SUM(dor.goods_size), 0) AS totalGoodsSize,
IFNULL(SUM(dor.actual_fee), 0) AS totalActualFee,
IFNULL(SUM(dor.total_km), 0) AS totalKm
FROM delivery_order dor
<include refid="statWhere"/>
GROUP BY DATE(dor.delivery_date)
ORDER BY statDate ASC
</select>
</mapper>