Browse Source

[feat] 采购管理:采购单动态采购数据。修改分类供应商方法。供应商获取数据,添加非空判断。

dev
zhangsiqi 5 months ago
parent
commit
5cdb04477b
  1. 50
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  2. 15
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/addPurchaseOrder.html

50
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java

@ -116,38 +116,42 @@ public class PurchaseOrderController extends BaseController
@ResponseBody @ResponseBody
public AjaxResult addSave(@RequestBody PurchaseOrder purchaseOrder) throws Exception{ public AjaxResult addSave(@RequestBody PurchaseOrder purchaseOrder) throws Exception{
//获取采购订单子表中的供应商,核算供应商数量和采购物料合计以及采购数量合计,采购不含税报价合计,采购含税报价合计 //获取采购订单子表中的供应商,核算供应商数量和采购物料合计以及采购数量合计,采购不含税报价合计,采购含税报价合计
List<PurchaseOrderChild> purchaseMaterials = purchaseOrder.getPurchaseOrderChildList();
purchaseOrder.setPurchaseOrderCode(redisCache.generateBillNo("CG")); purchaseOrder.setPurchaseOrderCode(redisCache.generateBillNo("CG"));
BigDecimal materialNoRmb = BigDecimal.valueOf(0.0); BigDecimal materialNoRmb = BigDecimal.valueOf(0.0);
BigDecimal materialRmb = BigDecimal.valueOf(0.0); BigDecimal materialRmb = BigDecimal.valueOf(0.0);
BigDecimal materialNoRmbSum = BigDecimal.valueOf(0.0); BigDecimal materialNoRmbSum = BigDecimal.valueOf(0.0);
BigDecimal materialRmbSum = BigDecimal.valueOf(0.0); BigDecimal materialRmbSum = BigDecimal.valueOf(0.0);
BigDecimal materialSum = BigDecimal.valueOf(0.0); BigDecimal materialSum = BigDecimal.valueOf(0.0);
List<PurchaseOrderChild> purchaseMaterials = new ArrayList<>();
Long materialNum = 0L; Long materialNum = 0L;
int supplierNum = 0; int supplierNum = 0;
for (PurchaseOrderChild purchaseOrderChild : purchaseMaterials) { int purOdersize = purchaseOrder.getPurchaseOrderChildList().size();
purchaseOrderChild.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); if(purOdersize > 1){
for (PurchaseQuoteChild purchaseSupplierQuote : purchaseOrderChild.getPurchaseQuoteChildList()){ purchaseMaterials = purchaseOrder.getPurchaseOrderChildList();
BigDecimal suplierMaterialNoRmb = purchaseSupplierQuote.getMaterialNoRmb(); for (PurchaseOrderChild purchaseOrderChild : purchaseMaterials) {
BigDecimal suplierMaterialRmb = purchaseSupplierQuote.getMaterialRmb(); purchaseOrderChild.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
Long suplierMaterialNum = purchaseSupplierQuote.getMaterialNum(); for (PurchaseQuoteChild purchaseSupplierQuote : purchaseOrderChild.getPurchaseQuoteChildList()){
BigDecimal suplierMaterialNoRmbSum = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); BigDecimal suplierMaterialNoRmb = purchaseSupplierQuote.getMaterialNoRmb();
BigDecimal suplierMaterialRmbSum = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); BigDecimal suplierMaterialRmb = purchaseSupplierQuote.getMaterialRmb();
materialNum = materialNum + suplierMaterialNum; Long suplierMaterialNum = purchaseSupplierQuote.getMaterialNum();
materialNoRmb = materialNoRmb.add(purchaseSupplierQuote.getMaterialNoRmb()); BigDecimal suplierMaterialNoRmbSum = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum));
materialRmb = materialRmb.add(purchaseSupplierQuote.getMaterialRmb()); BigDecimal suplierMaterialRmbSum = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum));
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSum); materialNum = materialNum + suplierMaterialNum;
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSum); materialNoRmb = materialNoRmb.add(purchaseSupplierQuote.getMaterialNoRmb());
purchaseSupplierQuote.setPurchaseQuoteCode(purchaseOrder.getPurchaseOrderCode()); materialRmb = materialRmb.add(purchaseSupplierQuote.getMaterialRmb());
if (purchaseSupplierQuote.getSupplierCode() != null){ materialRmbSum = materialRmbSum.add(suplierMaterialRmbSum);
supplierNum ++; materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSum);
} purchaseSupplierQuote.setPurchaseQuoteCode(purchaseOrder.getPurchaseOrderCode());
if (purchaseSupplierQuote.getSupplierCode() != null){
supplierNum ++;
}
}
purchaseOrderChild.setMaterialNormb(materialNoRmb);
purchaseOrderChild.setMaterialRmb(materialRmb);
purchaseOrderChild.setMaterialNum(materialNum);
} }
purchaseOrderChild.setMaterialNormb(materialNoRmb); purchaseOrder.setSupplierNum(supplierNum);
purchaseOrderChild.setMaterialRmb(materialRmb); }
purchaseOrderChild.setMaterialNum(materialNum);
}
purchaseOrder.setSupplierNum(supplierNum);
return toAjax(purchaseOrderService.insertPurchaseOrder(purchaseOrder)); return toAjax(purchaseOrderService.insertPurchaseOrder(purchaseOrder));
} }

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

@ -230,14 +230,15 @@
materialRmbSum: 0, materialRmbSum: 0,
purchaseOrderChildList: [] purchaseOrderChildList: []
}; };
// 遍历每个物料容器 // 遍历每个物料容器
$('.table-materialCode').each(function(index, tableElement) { $('.table-materialCode').each(function(index, tableElement) {
console.log(tableElement); console.log(tableElement);
var tableId = tableIdList[index]; // 从table ID中提取tableId var tableId = tableIdList[index]; // 从table ID中提取tableId
var materialTable = "bootstrap-table_" + tableId;
var data = $('#' + materialTable).bootstrapTable('getData');
var materialData = { var materialData = {
materialCode: , // 确保能正确获取物料编码 materialCode:'' , // 假设'materialCode'是你要获取的字段名}) , // 确保能正确获取物料编码
materialNum: 0, materialNum:10,
materialNoRmbSum: 0, materialNoRmbSum: 0,
materialRmbSum: 0, materialRmbSum: 0,
purchaseQuoteChildList: [] purchaseQuoteChildList: []
@ -246,8 +247,8 @@
var materialNoRmbTotal = $('#' + 'materialNoRmbSum_' + tableId).val(); var materialNoRmbTotal = $('#' + 'materialNoRmbSum_' + tableId).val();
var materialRmbTotal = $('#' + 'materialRmbSum_' + tableId).val(); var materialRmbTotal = $('#' + 'materialRmbSum_' + tableId).val();
materialData.materialNum = parseInt(materialActualNum); materialData.materialNum = parseInt(materialActualNum);
materialData.materialNoRmbSum = materialNoRmbTotal; materialData.materialNoRmbSum = parseFloat(materialNoRmbTotal);
materialData.materialRmbSum = materialRmbTotal; materialData.materialRmbSum = parseFloat(materialRmbTotal);
// 遍历该物料下的供应商信息 // 遍历该物料下的供应商信息
$('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) { $('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) {
var supplierQuote = { var supplierQuote = {
@ -261,8 +262,8 @@
materialData.purchaseQuoteChildList.push(supplierQuote); materialData.purchaseQuoteChildList.push(supplierQuote);
purchaseOrder.supplierNum += 1; // 累加供应商数量 purchaseOrder.supplierNum += 1; // 累加供应商数量
}); });
purchaseOrder.materialNoRmbSum += $("#" + 'material-'+ tableId ).find("supplierTotal_" + tableId).find("input[name='materialNoRmbSum']"); purchaseOrder.materialNoRmbSum += parseFloat(materialNoRmbTotal) ;
purchaseOrder.materialRmbSum += $("#" + 'material-'+ tableId ).find("supplierTotal_" + tableId).find("input[name='materialNoRmbSum']"); // 累加含税总价 purchaseOrder.materialRmbSum += parseFloat(materialRmbTotal); // 累加含税总价
purchaseOrder.purchaseOrderChildList.push(materialData); purchaseOrder.purchaseOrderChildList.push(materialData);
}); });

Loading…
Cancel
Save