From a3d8e081f7d5a583915aeb53f31ba31035923e72 Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Mon, 17 Feb 2025 14:19:15 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E9=87=87=E8=B4=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=E6=8C=89=E7=85=A7=E4=B8=87=E6=9D=90=E8=A6=81=E6=B1=82?= =?UTF-8?q?=EF=BC=8C=E9=87=87=E8=B4=AD=E7=AE=A1=E7=90=86=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E5=8D=95=E6=96=B0=E5=A2=9E=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81=E9=83=A8=E5=88=86?= =?UTF-8?q?=E8=A1=8C=E5=92=8C=E5=85=A8=E9=83=A8=E8=A1=8C=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E5=87=BA=E6=9B=B4=E5=A4=9A=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=20=E9=87=87=E8=B4=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92=E5=8D=95=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E5=AE=9E=E4=BD=93=E7=B1=BB=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=AF=BC=E5=87=BA=E6=89=80=E6=9C=89=E5=92=8C=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=AF=BC=E5=87=BA=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=20=E5=AF=BC=E5=87=BA=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92=E5=8D=95?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E6=96=B9=E6=B3=95=20=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92=E5=8D=95?= =?UTF-8?q?=E5=8F=B7=E6=95=B0=E7=BB=84=E6=9F=A5=E8=AF=A2=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E5=8D=95=E9=9B=86=E5=90=88=E6=96=B9=E6=B3=95?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=20=E6=A0=B9=E6=8D=AE=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E5=8D=95=E5=8F=B7=E9=9B=86=E5=90=88=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=95=B0=E6=8D=AE=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PurchasePlanController.java | 32 ++-- .../domain/Vo/ExportPurchasePlanVo.java | 142 ++++++++++++++++++ .../mapper/PurchasePlanChildMapper.java | 1 - .../purchase/mapper/PurchasePlanMapper.java | 3 + .../service/IPurchasePlanService.java | 11 ++ .../service/impl/PurchasePlanServiceImpl.java | 77 ++++++++++ .../mapper/purchase/PurchasePlanMapper.xml | 9 ++ .../purchase/purchasePlan/purchasePlan.html | 59 ++++++++ 8 files changed, 324 insertions(+), 10 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/ExportPurchasePlanVo.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchasePlanController.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchasePlanController.java index d8bf706a..405af3e6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchasePlanController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchasePlanController.java @@ -8,6 +8,7 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.purchase.domain.PurchasePlan; import com.ruoyi.purchase.domain.PurchasePlanChild; import com.ruoyi.purchase.domain.PurchaseQuoteChild; +import com.ruoyi.purchase.domain.Vo.ExportPurchasePlanVo; import com.ruoyi.purchase.domain.Vo.PurchasePlanOne; import com.ruoyi.purchase.domain.Vo.PurchasePlanSelectSupplierVo; import com.ruoyi.purchase.domain.Vo.PurchasePlanTwo; @@ -17,11 +18,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.purchase.service.IPurchasePlanService; @@ -77,15 +74,32 @@ public class PurchasePlanController extends BaseController */ @RequiresPermissions("purchase:purchasePlan:export") @Log(title = "采购计划单", businessType = BusinessType.EXPORT) - @PostMapping("/export") + @PostMapping("/exportAll") @ResponseBody - public AjaxResult export(PurchasePlan purchasePlan) + public AjaxResult exportAll(PurchasePlan purchasePlan) { List list = purchasePlanService.selectPurchasePlanList(purchasePlan); - ExcelUtil util = new ExcelUtil(PurchasePlan.class); - return util.exportExcel(list, "采购计划单数据"); + List exportPurchasePlanVos = purchasePlanService.exportPurchasePlanList(list); + ExcelUtil util = new ExcelUtil(ExportPurchasePlanVo.class); + return util.exportExcel(exportPurchasePlanVos, "采购计划单数据"); + } + + /** + * 导出采购计划单列表 + */ + @RequiresPermissions("purchase:purchasePlan:export") + @Log(title = "采购计划单", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(@RequestBody String[] purchasePlanCodes) + { + List list = purchasePlanService.selectPurchasePlanByPlanCodes(purchasePlanCodes); + List exportPurchasePlanVos = purchasePlanService.exportPurchasePlanList(list); + ExcelUtil util = new ExcelUtil(ExportPurchasePlanVo.class); + return util.exportExcel(exportPurchasePlanVos, "采购计划单数据"); } + /** * 新增采购计划单 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/ExportPurchasePlanVo.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/ExportPurchasePlanVo.java new file mode 100644 index 00000000..268069d5 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/ExportPurchasePlanVo.java @@ -0,0 +1,142 @@ +package com.ruoyi.purchase.domain.Vo; + +import com.ruoyi.common.annotation.Excel; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** +* 导出采购计划明细 +* */ +@Data +public class ExportPurchasePlanVo { + + /** 采购计划单号 */ + @Excel(name = "采购计划单号") + private String purchasePlanCode; + + /** 采购计划状态(0待申请、1部分申请、2全部申请、3全部作废) */ + @Excel(name = "采购计划状态",dictType = "purchase_plan_status") + private String purchasePlanStatus; + + /** 关联单号 */ + @Excel(name = "关联单号") + private String correlationCode; + + /** 采购来源(1生产单、2请购单、3开发修改单) */ + @Excel(name = "采购来源",dictType = "purchase_plan_source") + private String purchasePlanType; + + /** 物料数合计 */ + @Excel(name = "物料数合计") + private Integer materialSum; + + /** 不含税总价(RMB) */ + @Excel(name = "不含税总价(RMB)") + private BigDecimal noRmbSum; + + /** 含税总价(RMB) */ + @Excel(name = "含税总价(RMB)") + private BigDecimal rmbSum; + + /** 计划采购总数为之前的数量合计 */ + @Excel(name = "计划采购总数") + private Integer planPurchaseSum; + + /** 本次采购总数 */ + @Excel(name = "本次采购总数") + private Integer thisPurchaseSum; + + + /** 待采购总数 */ + @Excel(name = "待采购总数") + private Integer purchaseSum; + + /** 实际采购总数 */ + @Excel(name = "实际采购总数") + private Integer actualPurchaseSum; + + /** 共享库存占用总数 */ + @Excel(name = "共享库存占用总数") + private Integer sharedInventoryOccupancySum; + + /** 作废总数 */ + @Excel(name = "作废总数") + private Integer cancelSum; + + + /** 料号 */ + @Excel(name = "料号") + private String materialNo; + + /** 物料名称 */ + @Excel(name = "物料名称") + private String materialName; + + /** 物料品牌 */ + @Excel(name = "物料品牌") + private String materialBrand; + + /** 物料单位 */ + @Excel(name = "物料单位") + private String materialUnit; + + /** 物料描述 */ + @Excel(name = "物料描述") + private String materialDescribe; + + /** 物料加工方式 */ + @Excel(name = "物料加工方式",dictType = "processMethod") + private String materialProcessMethod; + + /** 物料型号 */ + @Excel(name = "物料型号") + private String materialModel; + + /** 入库部门(0仓库、1采购) */ + @Excel(name = "入库部门",dictType = "warehouseDept") + private String warehouseDept; + + /** 物料不含税总价(RMB) */ + @Excel(name = "物料不含税总价(RMB)") + private BigDecimal materialNoRmbSum; + + /** 物料含税总价(RMB) */ + @Excel(name = "物料含税总价(RMB)") + private BigDecimal materialRmbSum; + + /** 计划采购数 */ + @Excel(name = "计划采购数") + private Integer planPurchaseNum; + + /** 待采购数 */ + @Excel(name = "待采购数") + private Integer purchaseNum; + + /** 实际采购数 */ + @Excel(name = "实际采购数") + private Integer actualPurchaseNum; + + /** 共享库存占用数 */ + @Excel(name = "共享库存占用数") + private Integer sharedInventoryOccupancyNum; + + /** 作废数 */ + @Excel(name = "作废数") + private Integer cancelNum; + + /** 本次采购数 */ + @Excel(name = "本次采购数") + private Integer thisPurchaseNum; + + /** 共享可用库存数 */ + @Excel(name = "共享可用库存数") + private Integer sharedAvailableInventoryNum; + + /** 计划交付时间*/ + @Excel(name = "计划交付时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date planDeliveryTime; + + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanChildMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanChildMapper.java index 4bceb8a2..4eef8d36 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanChildMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanChildMapper.java @@ -115,5 +115,4 @@ public interface PurchasePlanChildMapper * */ List selectBatchPurchasePlanChildByIdList(List collectPurchasePlanChildId); - } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanMapper.java index ffbe7bee..6f3eb90f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanMapper.java @@ -83,6 +83,9 @@ public interface PurchasePlanMapper public int restorePurchasePlanById(Long purchasePlanId); + /** + * 根据计划编号集合查询采购计划单 + * */ public List selectPurchasePlanByPlanCodes(String[] planCode); /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchasePlanService.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchasePlanService.java index e5e88253..a0fe199c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchasePlanService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchasePlanService.java @@ -3,6 +3,7 @@ package com.ruoyi.purchase.service; import com.ruoyi.erp.domain.vo.ErpDevelopModifyorderVo; import com.ruoyi.purchase.domain.PurchasePlan; import com.ruoyi.purchase.domain.PurchasePlanChild; +import com.ruoyi.purchase.domain.Vo.ExportPurchasePlanVo; import com.ruoyi.purchase.domain.Vo.PurchasePlanSelectSupplierVo; import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.domain.SysMakeorderBom; @@ -114,4 +115,14 @@ public interface IPurchasePlanService * 采购计划通用保存 * */ int detailSave(PurchasePlan purchasePlan); + + /** + * 导出采购计划明细 + * */ + List exportPurchasePlanList(List list); + + /** + * 通过采购计划单号数组查询采购计划单集合 + * */ + List selectPurchasePlanByPlanCodes(String[] purchasePlanCodes); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java index 08a0b987..af08ef50 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java @@ -4,6 +4,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import com.ruoyi.common.core.redis.RedisCache; @@ -18,6 +19,7 @@ import com.ruoyi.erp.mapper.ErpDevelopModifyorderDetailMapper; import com.ruoyi.erp.service.IErpBomService; import com.ruoyi.purchase.controller.PurchaseQuoteController; import com.ruoyi.purchase.domain.*; +import com.ruoyi.purchase.domain.Vo.ExportPurchasePlanVo; import com.ruoyi.purchase.domain.Vo.PurchasePlanSelectSupplierVo; import com.ruoyi.purchase.mapper.*; import com.ruoyi.system.domain.*; @@ -439,6 +441,81 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService } + /** + * 通过采购计划单号数组查询采购计划单集合 + * */ + @Override + public List selectPurchasePlanByPlanCodes(String[] purchasePlanCodes) { + List purchasePlans = purchasePlanMapper.selectPurchasePlanByPlanCodes(purchasePlanCodes); + return purchasePlans; + } + + /** + * 导出采购计划单明细 + * */ + @Override + public List exportPurchasePlanList(List list) { + // 获取所有的采购计划单号 + List collectPurchasePlanCodes = list.stream().map(PurchasePlan::getPurchasePlanCode).collect(Collectors.toList()); + + // 根据采购计划单号查询对应的详情列表 + List purchasePlanChildList = purchasePlanChildMapper.selectPurchasePlanChildPlanCodeList(collectPurchasePlanCodes); + + // 创建一个采购计划VO的Map,键为采购计划单号 + Map purchasePlanMap = list.stream() + .collect(Collectors.toMap(PurchasePlan::getPurchasePlanCode, Function.identity())); + + // 初始化导出列表 + List exportPurchasePlanVos = new ArrayList<>(); + + for (PurchasePlanChild child : purchasePlanChildList) { + ExportPurchasePlanVo exportVo = new ExportPurchasePlanVo(); + + // 从PurchasePlanChild填充数据 + exportVo.setMaterialNo(child.getMaterialNo()); + exportVo.setMaterialName(child.getMaterialName()); + exportVo.setMaterialBrand(child.getMaterialBrand()); + exportVo.setMaterialUnit(child.getMaterialUnit()); + exportVo.setMaterialDescribe(child.getMaterialDescribe()); + exportVo.setMaterialProcessMethod(child.getMaterialProcessMethod()); + exportVo.setMaterialModel(child.getMaterialModel()); + exportVo.setWarehouseDept(child.getWarehouseDept()); + exportVo.setMaterialNoRmbSum(child.getMaterialNoRmbSum()); + exportVo.setMaterialRmbSum(child.getMaterialRmbSum()); + exportVo.setPlanPurchaseNum(child.getPlanPurchaseNum()); + exportVo.setPurchaseNum(child.getPurchaseNum()); + exportVo.setActualPurchaseNum(child.getActualPurchaseNum()); + exportVo.setSharedInventoryOccupancyNum(child.getSharedInventoryOccupancyNum()); + exportVo.setCancelNum(child.getCancelNum()); + exportVo.setThisPurchaseNum(child.getThisPurchaseNum()); + exportVo.setSharedAvailableInventoryNum(child.getSharedAvailableInventoryNum()); + exportVo.setPlanDeliveryTime(child.getPlanDeliveryTime()); + + // 从PurchasePlan填充数据,通过采购计划单号进行关联 + PurchasePlan plan = purchasePlanMap.get(child.getPurchasePlanCode()); + if (plan != null) { + exportVo.setPurchasePlanCode(plan.getPurchasePlanCode()); + exportVo.setPurchasePlanStatus(plan.getPurchasePlanStatus()); + exportVo.setCorrelationCode(plan.getCorrelationCode()); + exportVo.setPurchasePlanType(plan.getPurchasePlanType()); + exportVo.setMaterialSum(plan.getMaterialSum()); + exportVo.setNoRmbSum(plan.getNoRmbSum()); + exportVo.setRmbSum(plan.getRmbSum()); + exportVo.setPlanPurchaseSum(plan.getPlanPurchaseSum()); + exportVo.setThisPurchaseSum(plan.getThisPurchaseSum()); + exportVo.setPurchaseSum(plan.getPurchaseSum()); + exportVo.setActualPurchaseSum(plan.getActualPurchaseSum()); + exportVo.setSharedInventoryOccupancySum(plan.getSharedInventoryOccupancySum()); + exportVo.setCancelSum(plan.getCancelSum()); + } + + // 添加到结果列表 + exportPurchasePlanVos.add(exportVo); + } + + return exportPurchasePlanVos; + } + /* * 生产订单采购审核后生成采购计划 * */ diff --git a/ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanMapper.xml b/ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanMapper.xml index 5c7a2d6d..2a41d2c7 100644 --- a/ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanMapper.xml @@ -64,6 +64,15 @@ where purchase_plan_code = #{purchasePlanCode} + + + insert into purchase_plan diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html b/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html index db36fec7..ba6612ef 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html @@ -51,6 +51,9 @@ 添加采购单 + + 导出 +
@@ -217,6 +220,62 @@ $.modal.open("采购计划详情", url); } + + + // 导出 + function exportExcel(formId) { + // $.table.set(); + var purchasePlanCodeData = []; + 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