diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java index 450a4781..4ca7831b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java @@ -11,6 +11,7 @@ import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.process.general.service.IProcessService; import com.ruoyi.purchase.domain.*; import com.ruoyi.purchase.domain.Vo.*; @@ -98,6 +99,41 @@ public class PurchaseOrderController extends BaseController return getDataTable(list); } + + /** + * 导出全部采购订单子表列表 + */ + @RequiresPermissions("purchase:purchaseOrderChild:export") + @Log(title = "采购订单子表", businessType = BusinessType.EXPORT) + @PostMapping("/exportAll") + @ResponseBody + public AjaxResult exportAll(PurchaseOrder purchaseOrder) + { + List list = purchaseOrderService.selectAllPurchaseOrderList(purchaseOrder); + List exportPurchaseOrderVos = purchaseOrderService.getExportPurchaseOrderList(list); + ExcelUtil util = new ExcelUtil(ExportPurchaseOrderVo.class); + return util.exportExcel(exportPurchaseOrderVos, "采购订单数据"); + } + + + /** + * 导出采购订单子表列表 + */ + @RequiresPermissions("purchase:purchaseOrderChild:export") + @Log(title = "采购订单子表", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(@RequestBody String[] purchaseOrderCodes) + { + List list = purchaseOrderService.selectPurchaseOrderChildListByCodes(purchaseOrderCodes); + + List exportPurchaseOrderVos = purchaseOrderService.getExportPurchaseOrderList(list); + ExcelUtil util = new ExcelUtil(ExportPurchaseOrderVo.class); + return util.exportExcel(exportPurchaseOrderVos, "采购订单数据"); + } + + + /** * * 导出采购订单合同 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java index 95928245..55ddc6e9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java @@ -2,6 +2,8 @@ package com.ruoyi.purchase.domain; import java.math.BigDecimal; import java.util.Date; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -78,39 +80,30 @@ public class PurchaseOrder extends BaseEntity /** 到货时间 */ @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "到货时间", width = 30, dateFormat = "yyyy-MM-dd") private Date arrivedTime; /** 仓库ID */ - @Excel(name = "仓库ID") private String stockNo; /** 仓库名称 */ - @Excel(name = "仓库名称") private String stockName; /** 收货人 */ - @Excel(name = "收货人") private String receivePerson; /** 收货电话 */ - @Excel(name = "收货电话") private String receivePersonPhone; /** 收货地址 */ - @Excel(name = "收货地址") private String receiveAddress; /** 采购员 */ - @Excel(name = "采购员") private String purchaseBuyer; /** 使用状态 (0未使用,1使用,2已作废) */ - @Excel(name = "使用状态",dictType = "useStatus") private String useStatus; /** 审核状态(0待审核、1审核通过、2审核拒绝) */ - @Excel(name = "审核状态",dictType = "auditStatus") private String auditStatus; /** 删除标志 */ @@ -140,6 +133,9 @@ public class PurchaseOrder extends BaseEntity /** 申请时间 */ private Date applyTime; + private List purchaseOrderChildList; + + public void setPurchaseOrderId(Long purchaseOrderId) { this.purchaseOrderId = purchaseOrderId; @@ -438,6 +434,14 @@ public class PurchaseOrder extends BaseEntity return applyTime; } + public List getPurchaseOrderChildList() { + return purchaseOrderChildList; + } + + public void setPurchaseOrderChildList(List purchaseOrderChildList) { + this.purchaseOrderChildList = purchaseOrderChildList; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -478,6 +482,7 @@ public class PurchaseOrder extends BaseEntity .append("applyTitle", getApplyTitle()) .append("applyUser", getApplyUser()) .append("applyTime", getApplyTime()) + .append("purchaseOrderChildList", getPurchaseOrderChildList()) .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java index af62adee..5a569f99 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java @@ -22,7 +22,6 @@ public class PurchaseOrderChild extends BaseEntity private Long purchaseOrderChildId; /** 采购订单号 */ - @Excel(name = "采购订单号") private String purchaseOrderCode; /** 料号 */ @@ -34,11 +33,9 @@ public class PurchaseOrderChild extends BaseEntity private String materialName; /** 物料类型 */ - @Excel(name = "物料类型") private String materialType; /** 物料图片地址 */ - @Excel(name = "物料图片地址") private String materialPhotourl; /** 物料品牌 */ @@ -46,7 +43,7 @@ public class PurchaseOrderChild extends BaseEntity private String materialBrand; /** 物料单位 */ - @Excel(name = "物料单位") + @Excel(name = "物料单位", dictType = "sys_unit_class") private String materialUnit; /** 物料描述 */ @@ -54,7 +51,7 @@ public class PurchaseOrderChild extends BaseEntity private String materialDescribe; /** 物料加工方式 */ - @Excel(name = "物料加工方式") + @Excel(name = "物料加工方式", dictType = "processMethod") private String materialProcessMethod; /** 物料型号 */ @@ -62,15 +59,14 @@ public class PurchaseOrderChild extends BaseEntity private String materialModel; /** 入库部门(0仓库、1采购) */ - @Excel(name = "入库部门(0仓库、1采购)") private String warehouseDept; /** 物料不含税总价(RMB) */ - @Excel(name = "物料不含税总价(RMB)") + @Excel(name = "物料不含税总价") private BigDecimal materialNormbSum; /** 物料含税总价(RMB) */ - @Excel(name = "物料含税总价(RMB)") + @Excel(name = "物料含税总价") private BigDecimal materialRmbSum; /** 计划采购数 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/ExportPurchaseOrderVo.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/ExportPurchaseOrderVo.java new file mode 100644 index 00000000..fb1a86a5 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/ExportPurchaseOrderVo.java @@ -0,0 +1,90 @@ +package com.ruoyi.purchase.domain.Vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** +* 以供应商和物料为主要数据展示导出的采购订单Vo +* */ +@Data +public class ExportPurchaseOrderVo{ + + /** 采购订购单号 */ + @Excel(name = "采购订购单号") + private String purchaseOrderCode; + + /** 供应商ID */ + @Excel(name = "供应商ID") + private String supplierCode; + + /** 供应商名称 */ + @Excel(name = "供应商名称") + private String supplierName; + + /** 不含税总价(RMB) */ + @Excel(name = "不含税总价(RMB)") + private BigDecimal noRmbSum; + + /** 含税总价(RMB) */ + @Excel(name = "含税总价(RMB)") + private BigDecimal rmbSum; + + /** 料号 */ + @Excel(name = "料号") + private String materialNo; + + /** 物料名称 */ + @Excel(name = "物料名称") + private String materialName; + + /** 物料品牌 */ + @Excel(name = "物料品牌") + private String materialBrand; + + /** 物料单位 */ + @Excel(name = "物料单位", dictType = "sys_unit_class") + private String materialUnit; + + /** 物料描述 */ + @Excel(name = "物料描述") + private String materialDescribe; + + /** 物料加工方式 */ + @Excel(name = "物料加工方式", dictType = "processMethod") + private String materialProcessMethod; + + /** 物料型号 */ + @Excel(name = "物料型号") + private String materialModel; + + + /** 物料不含税总价(RMB) */ + @Excel(name = "物料不含税总价") + private BigDecimal materialNormbSum; + + /** 物料含税总价(RMB) */ + @Excel(name = "物料含税总价") + private BigDecimal materialRmbSum; + + /** 计划采购数 */ + @Excel(name = "计划采购数") + private Integer planPurchaseNum; + + /** 实际采购数 */ + @Excel(name = "实际采购数") + private Integer actualPurchaseNum; + + /** 共享库存占用数 */ + @Excel(name = "共享库存占用数") + private Integer sharedInventoryOccupancyNum; + + /** 计划交付时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "计划交付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date planDeliveryTime; + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderChildMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderChildMapper.java index 11ebb52a..c7a27278 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderChildMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderChildMapper.java @@ -29,6 +29,15 @@ public interface PurchaseOrderChildMapper */ public List selectPurchaseOrderChildList(PurchaseOrderChild purchaseOrderChild); + /** + * 通过采购订单号集合查询采购订单子表列表 + * + * @param purchaseOrderCodes 采购订单号集合 + * @return 采购订单子表集合 + */ + + List selectPurchaseOrderChildListByCodes(List purchaseOrderCodes); + /** * 新增采购订单子表 * @@ -120,4 +129,6 @@ public interface PurchaseOrderChildMapper * 批量新增采购订单子表数据 * */ int batchInsertPurchaseOrderChild(List purchaseOrderChildren); + + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderMapper.java index c157885e..32c095ba 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderMapper.java @@ -29,6 +29,20 @@ public interface PurchaseOrderMapper */ public List selectPurchaseOrderList(PurchaseOrder purchaseOrder); + + /** + * 查询所有可用的采购订单数据 + * */ + List selectAllPurchaseOrderList(PurchaseOrder purchaseOrder); + + + + /** + * 通过采购订单号数组查询采购订单集合 + * */ + List selectPurchaseOrderChildListByCodes(String[] purchaseOrderCodes); + + /** * 新增采购订单 * @@ -68,4 +82,5 @@ public interface PurchaseOrderMapper PurchaseOrder selectPurchaseOrderByOrderCode(String purchaseOrderCode); //校验采购订单编号是否唯一 public Integer checkPurchaseOrderCodeUnique(String purchaseOrderCode); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java index b54006c2..cc56fd33 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java @@ -5,6 +5,7 @@ import com.ruoyi.purchase.domain.PurchaseOrder; import com.ruoyi.purchase.domain.PurchaseOrderVo; import com.ruoyi.purchase.domain.PurchasePlan; import com.ruoyi.purchase.domain.Vo.AddPurchaseOrder; +import com.ruoyi.purchase.domain.Vo.ExportPurchaseOrderVo; import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import org.activiti.engine.runtime.ProcessInstance; import org.springframework.transaction.annotation.Transactional; @@ -37,6 +38,26 @@ public interface IPurchaseOrderService */ public List selectPurchaseOrderList(PurchaseOrder purchaseOrder); + + /** + * 查询所有可用的采购订单数据 + * */ + List selectAllPurchaseOrderList(PurchaseOrder purchaseOrder); + + + /** + * 通过采购订单号数组查询采购订单集合 + * */ + List selectPurchaseOrderChildListByCodes(String[] purchaseOrderCodes); + + + + /** + * 处理需要导出的采购订单数据 + * */ + List getExportPurchaseOrderList(List list); + + /** * 新增采购订单 * @@ -105,4 +126,6 @@ public interface IPurchaseOrderService * 采购计划添加采购订单 * */ int addPurchasePlanToPurchaseOrder(AddPurchaseOrder addPurchaseOrder); + + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java index 4cf9739c..4589d900 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java @@ -228,6 +228,84 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService return returnList; } + + /** + * 查询所有可用的采购订单数据 + * */ + @Override + public List selectAllPurchaseOrderList(PurchaseOrder purchaseOrder) { + List purchaseOrderList = purchaseOrderMapper.selectAllPurchaseOrderList(purchaseOrder); + return purchaseOrderList; + } + + /** + * 通过采购订单号数组查询采购订单集合 + * */ + @Override + public List selectPurchaseOrderChildListByCodes(String[] purchaseOrderCodes) { + List purchaseOrderList = purchaseOrderMapper.selectPurchaseOrderChildListByCodes(purchaseOrderCodes); + return purchaseOrderList; + } + + + /** + * 处理需要导出的采购订单数据 + * */ + @Override + public List getExportPurchaseOrderList(List list) { + + if (!CollectionUtils.isEmpty(list)){ + + List purchaseOrderCodes = list.stream().map(PurchaseOrder::getPurchaseOrderCode).collect(Collectors.toList()); + List purchaseOrderChildList = purchaseOrderChildMapper.selectPurchaseOrderChildListByCodes(purchaseOrderCodes); + + // 创建一个 map 用于快速查找主表数据 + Map purchaseOrderMap = list.stream() + .collect(Collectors.toMap(PurchaseOrder::getPurchaseOrderCode, Function.identity())); + + // 创建一个 map 用于快速查找子表数据 + Map> purchaseOrderChildMap = purchaseOrderChildList.stream() + .collect(Collectors.groupingBy(PurchaseOrderChild::getPurchaseOrderCode)); + + // 生成 ExportPurchaseOrderVo 列表 + List exportPurchaseOrderVoList = new ArrayList<>(); + + for (String purchaseOrderCode : purchaseOrderCodes) { + PurchaseOrder purchaseOrder = purchaseOrderMap.get(purchaseOrderCode); + List children = purchaseOrderChildMap.getOrDefault(purchaseOrderCode, Collections.emptyList()); + + for (PurchaseOrderChild child : children) { + ExportPurchaseOrderVo exportPurchaseOrderVo = new ExportPurchaseOrderVo(); + exportPurchaseOrderVo.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); + exportPurchaseOrderVo.setSupplierName(purchaseOrder.getSupplierName()); + exportPurchaseOrderVo.setSupplierCode(purchaseOrder.getSupplierCode()); + exportPurchaseOrderVo.setNoRmbSum(purchaseOrder.getNoRmbSum()); + exportPurchaseOrderVo.setRmbSum(purchaseOrder.getRmbSum()); + // 填充子表数据 + exportPurchaseOrderVo.setMaterialNo(child.getMaterialNo()); + exportPurchaseOrderVo.setMaterialName(child.getMaterialName()); + exportPurchaseOrderVo.setMaterialBrand(child.getMaterialBrand()); + exportPurchaseOrderVo.setMaterialDescribe(child.getMaterialDescribe()); + exportPurchaseOrderVo.setMaterialModel(child.getMaterialModel()); + exportPurchaseOrderVo.setMaterialProcessMethod(child.getMaterialProcessMethod()); + exportPurchaseOrderVo.setMaterialUnit(child.getMaterialUnit()); + exportPurchaseOrderVo.setMaterialNormbSum(child.getMaterialNormbSum()); + exportPurchaseOrderVo.setMaterialRmbSum(child.getMaterialRmbSum()); + exportPurchaseOrderVo.setPlanPurchaseNum(child.getPlanPurchaseNum()); + exportPurchaseOrderVo.setActualPurchaseNum(child.getActualPurchaseNum()); + exportPurchaseOrderVo.setSharedInventoryOccupancyNum(child.getSharedInventoryOccupancyNum()); + exportPurchaseOrderVo.setPlanDeliveryTime(child.getPlanDeliveryTime()); + + exportPurchaseOrderVoList.add(exportPurchaseOrderVo); + } + } + + return exportPurchaseOrderVoList; + } + + return Collections.emptyList(); + } + /** * 新增采购订单 * diff --git a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml index bbfc9939..28160d70 100644 --- a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml @@ -45,6 +45,14 @@ where purchase_order_child_id = #{purchaseOrderChildId} + + insert into purchase_order_child diff --git a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml index b4a81b1a..600cd364 100644 --- a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml @@ -66,6 +66,20 @@ where purchase_order_id = #{purchaseOrderId} + + + + + insert into purchase_order diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html b/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html index 74482c48..f15d2baa 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html @@ -56,16 +56,7 @@ @@ -214,6 +205,64 @@ }; $.table.init(options); }); + + + + // 导出 + function exportExcel(formId) { + // $.table.set(); + var purchaseOrderCodeData = []; + var selections = $("#bootstrap-table").bootstrapTable("getSelections"); + if(selections.length === 0){ + $.modal.confirm("确定导出所有采购订单吗?", function() { + var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId; + var params = $("#bootstrap-table").bootstrapTable('getOptions'); + var dataParam = $("#" + currentId).serializeArray(); + dataParam.push({ "name": "orderByColumn", "value": params.sortName }); + dataParam.push({ "name": "isAsc", "value": params.sortOrder }); + $.modal.loading("正在导出数据,请稍后..."); + $.post(prefix + '/exportAll', dataParam, function(result) { + if (result.code == web_status.SUCCESS) { + window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true; + } else if (result.code == web_status.WARNING) { + $.modal.alertWarning(result.msg) + } else { + $.modal.alertError(result.msg); + } + $.modal.closeLoading(); + }); + }); + }else { + $.modal.confirm("确定导出选中的所有采购订单吗?", function () { + //·拼接单号 + for(let i=0;i \ No newline at end of file