feat: 新增合同、订单明细导出功能,补充业务员字段展示
1. 新增crm订单主、订单明细的导出接口,支持业务精简字段导出 2. 为订单明细VO新增业务员字段,关联查询订单表填充数据 3. 在订单列表页新增业务员表格列展示 4. 为合同编辑页、订单明细页添加导出按钮并实现导出逻辑 5. 新增导出专用的VO类,处理日期格式化和状态转文本
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
package com.klp.crm.controller;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.klp.aps.domain.bo.ApsPlanDetailBo;
|
||||
import com.klp.aps.domain.bo.ApsPlanSheetBo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -23,6 +26,7 @@ import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.crm.domain.vo.CrmOrderVo;
|
||||
import com.klp.crm.domain.vo.CrmOrderExportVo;
|
||||
import com.klp.crm.domain.bo.CrmOrderBo;
|
||||
import com.klp.crm.service.ICrmOrderService;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
@@ -65,6 +69,35 @@ public class CrmOrderController extends BaseController {
|
||||
ExcelUtil.exportExcel(list, "正式订单主", CrmOrderVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出正式订单主列表(业务精简字段,用于合同编辑详情页导出)
|
||||
*/
|
||||
@Log(title = "正式订单主", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/exportDetail")
|
||||
public void exportDetail(@RequestBody CrmOrderBo bo, HttpServletResponse response) {
|
||||
List<CrmOrderVo> list = iCrmOrderService.queryList(bo);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
List<CrmOrderExportVo> exportList = list.stream().map(vo -> {
|
||||
CrmOrderExportVo export = new CrmOrderExportVo();
|
||||
BeanUtil.copyProperties(vo, export);
|
||||
// 日期格式化
|
||||
export.setSignTime(vo.getSignTime() != null ? sdf.format(vo.getSignTime()) : null);
|
||||
export.setDeliveryDate(vo.getDeliveryDate() != null ? sdf.format(vo.getDeliveryDate()) : null);
|
||||
// 状态转文本
|
||||
if (vo.getStatus() != null) {
|
||||
switch (vo.getStatus().intValue()) {
|
||||
case 0: export.setStatus("草稿"); break;
|
||||
case 1: export.setStatus("已生效"); break;
|
||||
case 2: export.setStatus("已作废"); break;
|
||||
case 3: export.setStatus("已完成"); break;
|
||||
default: export.setStatus(String.valueOf(vo.getStatus())); break;
|
||||
}
|
||||
}
|
||||
return export;
|
||||
}).collect(Collectors.toList());
|
||||
ExcelUtil.exportExcel(exportList, "合同编辑详情", CrmOrderExportVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取正式订单主详细信息
|
||||
*
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.klp.crm.controller;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -18,6 +22,7 @@ import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.crm.domain.vo.CrmOrderItemVo;
|
||||
import com.klp.crm.domain.vo.CrmOrderItemExportVo;
|
||||
import com.klp.crm.domain.vo.CrmContractOrderFinanceVo;
|
||||
import com.klp.crm.domain.bo.CrmOrderItemBo;
|
||||
import com.klp.crm.service.ICrmOrderItemService;
|
||||
@@ -56,6 +61,30 @@ public class CrmOrderItemController extends BaseController {
|
||||
ExcelUtil.exportExcel(list, "正式订单明细", CrmOrderItemVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出正式订单明细列表(业务精简字段,用于订单明细列表页导出)
|
||||
*/
|
||||
@Log(title = "正式订单明细", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/exportDetail")
|
||||
public void exportDetail(@RequestBody CrmOrderItemBo bo, HttpServletResponse response) {
|
||||
List<CrmOrderItemVo> list = iCrmOrderItemService.queryList(bo);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
List<CrmOrderItemExportVo> exportList = list.stream().map(vo -> {
|
||||
CrmOrderItemExportVo export = new CrmOrderItemExportVo();
|
||||
BeanUtil.copyProperties(vo, export);
|
||||
// 日期格式化
|
||||
export.setSignTime(vo.getSignTime() != null ? sdf.format(vo.getSignTime()) : null);
|
||||
// 展平 orderInfo 中的 salesman、orderCode、contractName
|
||||
if (vo.getOrderInfo() != null) {
|
||||
export.setSalesman(vo.getOrderInfo().getSalesman());
|
||||
export.setOrderCode(vo.getOrderInfo().getOrderCode());
|
||||
export.setContractName(vo.getOrderInfo().getContractName());
|
||||
}
|
||||
return export;
|
||||
}).collect(Collectors.toList());
|
||||
ExcelUtil.exportExcel(exportList, "订单明细列表", CrmOrderItemExportVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取正式订单明细详细信息
|
||||
*
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.klp.crm.domain.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 合同编辑详情导出视图对象
|
||||
* 仅包含页面表格展示的业务字段(19列)
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-07-06
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CrmOrderExportVo {
|
||||
|
||||
@ExcelProperty(value = "合同号")
|
||||
private String contractCode;
|
||||
|
||||
@ExcelProperty(value = "供方")
|
||||
private String supplier;
|
||||
|
||||
@ExcelProperty(value = "需方")
|
||||
private String customer;
|
||||
|
||||
@ExcelProperty(value = "业务员")
|
||||
private String salesman;
|
||||
|
||||
@ExcelProperty(value = "签订日期")
|
||||
private String signTime;
|
||||
|
||||
@ExcelProperty(value = "交货日期")
|
||||
private String deliveryDate;
|
||||
|
||||
@ExcelProperty(value = "签订地点")
|
||||
private String signLocation;
|
||||
|
||||
@ExcelProperty(value = "供方地址")
|
||||
private String supplierAddress;
|
||||
|
||||
@ExcelProperty(value = "供方电话")
|
||||
private String supplierPhone;
|
||||
|
||||
@ExcelProperty(value = "供方开户行")
|
||||
private String supplierBank;
|
||||
|
||||
@ExcelProperty(value = "供方账号")
|
||||
private String supplierAccount;
|
||||
|
||||
@ExcelProperty(value = "需方地址")
|
||||
private String customerAddress;
|
||||
|
||||
@ExcelProperty(value = "需方电话")
|
||||
private String customerPhone;
|
||||
|
||||
@ExcelProperty(value = "需方开户行")
|
||||
private String customerBank;
|
||||
|
||||
@ExcelProperty(value = "需方账号")
|
||||
private String customerAccount;
|
||||
|
||||
@ExcelProperty(value = "订单金额")
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
@ExcelProperty(value = "已收款")
|
||||
private BigDecimal receivedAmount;
|
||||
|
||||
@ExcelProperty(value = "状态")
|
||||
private String status;
|
||||
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.klp.crm.domain.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 订单明细列表导出视图对象
|
||||
* 仅包含页面表格展示的业务字段(32列)
|
||||
*
|
||||
* @author klp
|
||||
* @date 2026-07-06
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CrmOrderItemExportVo {
|
||||
|
||||
// ========== 合同信息(联表) ==========
|
||||
|
||||
@ExcelProperty(value = "合同号")
|
||||
private String contractCode;
|
||||
|
||||
@ExcelProperty(value = "合同名称")
|
||||
private String contractName;
|
||||
|
||||
@ExcelProperty(value = "需方")
|
||||
private String customer;
|
||||
|
||||
@ExcelProperty(value = "供方")
|
||||
private String supplier;
|
||||
|
||||
@ExcelProperty(value = "业务员")
|
||||
private String salesman;
|
||||
|
||||
@ExcelProperty(value = "签订时间")
|
||||
private String signTime;
|
||||
|
||||
@ExcelProperty(value = "订单编号")
|
||||
private String orderCode;
|
||||
|
||||
// ========== 明细标识 ==========
|
||||
|
||||
@ExcelProperty(value = "明细ID")
|
||||
private Long itemId;
|
||||
|
||||
@ExcelProperty(value = "订单ID")
|
||||
private Long orderId;
|
||||
|
||||
// ========== 产品规格 ==========
|
||||
|
||||
@ExcelProperty(value = "产品类型")
|
||||
private String productType;
|
||||
|
||||
@ExcelProperty(value = "原料规格")
|
||||
private String rawMaterialSpec;
|
||||
|
||||
@ExcelProperty(value = "成品规格")
|
||||
private String finishedProductSpec;
|
||||
|
||||
@ExcelProperty(value = "数量")
|
||||
private Long productNum;
|
||||
|
||||
@ExcelProperty(value = "材质")
|
||||
private String material;
|
||||
|
||||
@ExcelProperty(value = "等级")
|
||||
private String grade;
|
||||
|
||||
@ExcelProperty(value = "宽度")
|
||||
private String width;
|
||||
|
||||
@ExcelProperty(value = "厚度")
|
||||
private String thickness;
|
||||
|
||||
@ExcelProperty(value = "宽度公差")
|
||||
private String widthTolerance;
|
||||
|
||||
@ExcelProperty(value = "厚度公差")
|
||||
private String thicknessTolerance;
|
||||
|
||||
@ExcelProperty(value = "重量")
|
||||
private BigDecimal weight;
|
||||
|
||||
// ========== 价格 ==========
|
||||
|
||||
@ExcelProperty(value = "合同定价")
|
||||
private BigDecimal contractPrice;
|
||||
|
||||
@ExcelProperty(value = "明细金额")
|
||||
private BigDecimal itemAmount;
|
||||
|
||||
// ========== 加工要求 ==========
|
||||
|
||||
@ExcelProperty(value = "表面处理")
|
||||
private String surfaceTreatment;
|
||||
|
||||
@ExcelProperty(value = "包装要求")
|
||||
private String packagingReq;
|
||||
|
||||
@ExcelProperty(value = "切边要求")
|
||||
private String edgeCuttingReq;
|
||||
|
||||
@ExcelProperty(value = "表面质量")
|
||||
private String surfaceQuality;
|
||||
|
||||
// ========== 其他 ==========
|
||||
|
||||
@ExcelProperty(value = "特殊要求")
|
||||
private String specialRequire;
|
||||
|
||||
@ExcelProperty(value = "用途")
|
||||
private String purpose;
|
||||
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty(value = "定制人")
|
||||
private String customizer;
|
||||
|
||||
@ExcelProperty(value = "发货人")
|
||||
private String shipper;
|
||||
|
||||
@ExcelProperty(value = "排产批次")
|
||||
private String productionBatch;
|
||||
}
|
||||
@@ -234,6 +234,12 @@ public class CrmOrderItemVo {
|
||||
@ExcelProperty(value = "交货日期")
|
||||
private Date deliveryDate;
|
||||
|
||||
/**
|
||||
* 销售员(联表查询直接映射)
|
||||
*/
|
||||
@ExcelProperty(value = "销售员")
|
||||
private String salesman;
|
||||
|
||||
/**
|
||||
* 订单信息
|
||||
*/
|
||||
|
||||
@@ -168,7 +168,11 @@ public class CrmOrderItemServiceImpl implements ICrmOrderItemService {
|
||||
Map<Long, CrmOrderVo> orderMap = orderList.stream()
|
||||
.collect(Collectors.toMap(CrmOrderVo::getOrderId, o -> o, (a, b) -> a));
|
||||
for (CrmOrderItemVo item : records) {
|
||||
item.setOrderInfo(orderMap.get(item.getOrderId()));
|
||||
CrmOrderVo order = orderMap.get(item.getOrderId());
|
||||
item.setOrderInfo(order);
|
||||
if (order != null) {
|
||||
item.setSalesman(order.getSalesman());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<result property="customer" column="customer"/>
|
||||
<result property="signTime" column="sign_time"/>
|
||||
<result property="deliveryDate" column="delivery_date"/>
|
||||
<result property="salesman" column="salesman"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 根据订单ID列表查询订单明细 -->
|
||||
@@ -155,7 +156,8 @@
|
||||
o.supplier,
|
||||
o.customer,
|
||||
o.sign_time,
|
||||
o.delivery_date
|
||||
o.delivery_date,
|
||||
o.salesman
|
||||
FROM crm_order_item i
|
||||
LEFT JOIN crm_order o ON i.order_id = o.order_id AND o.del_flag = 0
|
||||
<where>
|
||||
|
||||
Reference in New Issue
Block a user