Browse Source

[feat] 采购管理

按照万材要求,采购管理采购计划单新增导出功能,支持部分行和全部行导出,导出更多数据
新增 采购管理采购计划单导出明细实体类
新增导出所有和选择导出后端接口
新增 导出采购管理采购计划单明细方法
新增 根据采购计划单号数组查询采购计划单集合方法
新增 根据采购计划单号集合查询采购计划单详情数据方法
dev
liuxiaoxu 5 days ago
parent
commit
a3d8e081f7
  1. 32
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchasePlanController.java
  2. 142
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/ExportPurchasePlanVo.java
  3. 1
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanChildMapper.java
  4. 3
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanMapper.java
  5. 11
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchasePlanService.java
  6. 77
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java
  7. 9
      ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanMapper.xml
  8. 59
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html

32
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<PurchasePlan> list = purchasePlanService.selectPurchasePlanList(purchasePlan);
ExcelUtil<PurchasePlan> util = new ExcelUtil<PurchasePlan>(PurchasePlan.class);
return util.exportExcel(list, "采购计划单数据");
List<ExportPurchasePlanVo> exportPurchasePlanVos = purchasePlanService.exportPurchasePlanList(list);
ExcelUtil<ExportPurchasePlanVo> util = new ExcelUtil<ExportPurchasePlanVo>(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<PurchasePlan> list = purchasePlanService.selectPurchasePlanByPlanCodes(purchasePlanCodes);
List<ExportPurchasePlanVo> exportPurchasePlanVos = purchasePlanService.exportPurchasePlanList(list);
ExcelUtil<ExportPurchasePlanVo> util = new ExcelUtil<ExportPurchasePlanVo>(ExportPurchasePlanVo.class);
return util.exportExcel(exportPurchasePlanVos, "采购计划单数据");
}
/**
* 新增采购计划单
*/

142
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;
}

1
ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanChildMapper.java

@ -115,5 +115,4 @@ public interface PurchasePlanChildMapper
* */
List<PurchasePlanChild> selectBatchPurchasePlanChildByIdList(List<Long> collectPurchasePlanChildId);
}

3
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<PurchasePlan> selectPurchasePlanByPlanCodes(String[] planCode);
/**

11
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<ExportPurchasePlanVo> exportPurchasePlanList(List<PurchasePlan> list);
/**
* 通过采购计划单号数组查询采购计划单集合
* */
List<PurchasePlan> selectPurchasePlanByPlanCodes(String[] purchasePlanCodes);
}

77
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<PurchasePlan> selectPurchasePlanByPlanCodes(String[] purchasePlanCodes) {
List<PurchasePlan> purchasePlans = purchasePlanMapper.selectPurchasePlanByPlanCodes(purchasePlanCodes);
return purchasePlans;
}
/**
* 导出采购计划单明细
* */
@Override
public List<ExportPurchasePlanVo> exportPurchasePlanList(List<PurchasePlan> list) {
// 获取所有的采购计划单号
List<String> collectPurchasePlanCodes = list.stream().map(PurchasePlan::getPurchasePlanCode).collect(Collectors.toList());
// 根据采购计划单号查询对应的详情列表
List<PurchasePlanChild> purchasePlanChildList = purchasePlanChildMapper.selectPurchasePlanChildPlanCodeList(collectPurchasePlanCodes);
// 创建一个采购计划VO的Map,键为采购计划单号
Map<String, PurchasePlan> purchasePlanMap = list.stream()
.collect(Collectors.toMap(PurchasePlan::getPurchasePlanCode, Function.identity()));
// 初始化导出列表
List<ExportPurchasePlanVo> 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;
}
/*
* 生产订单采购审核后生成采购计划
* */

9
ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanMapper.xml

@ -64,6 +64,15 @@
where purchase_plan_code = #{purchasePlanCode}
</select>
<select id="selectPurchasePlanByPlanCodes" parameterType="String" resultMap="PurchasePlanResult">
<include refid="selectPurchasePlanVo"/>
where purchase_plan_code in
<foreach item="purchasePlanCode" collection="array" separator="," open="(" close=")">
#{purchasePlanCode}
</foreach>
</select>
<insert id="insertPurchasePlan" parameterType="PurchasePlan" useGeneratedKeys="true" keyProperty="purchasePlanId">
insert into purchase_plan
<trim prefix="(" suffix=")" suffixOverrides=",">

59
ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html

@ -51,6 +51,9 @@
<a class="btn btn-success" onclick="addPurchaseOrder()" shiro:hasPermission="purchase:purchasePlan:add">
<i class="fa fa-download"></i> 添加采购单
</a>
<a class="btn btn-success" onclick="exportExcel()" shiro:hasPermission="purchase:purchasePlan:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
@ -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<selections.length;i++){
purchasePlanCodeData.push(selections[i].purchasePlanCode);
}
var purchasePlanCodes = JSON.stringify(purchasePlanCodeData);
// console.log(bomNos);
$.modal.loading("正在导出数据,请稍后...");
var config = {
url: prefix + '/export',
type: "post",
dataType: "json",
contentType: "application/json;charset=utf-8",
data: purchasePlanCodes,
success: function(result) {
window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
$.modal.alertSuccess("导出成功!")
$.modal.closeLoading();
},
error: function (result){
$.modal.alertError(result.msg);
}
};
$.ajax(config)
});
}
};
</script>
</body>
</html>
Loading…
Cancel
Save