Browse Source

[feat] 采购管理:采购单计划添加采购单,。添加计划添加采购单页面修改。修改动态生成采购单数据,采购单动态采购数据。修改分类供应商方法。供应商获取数据,数据转换位采购单对象格式数据传入。获取物料信息子表,字段子表计算 物料数量和,物料料号数,不含税单价,含税单价,实际采购含税单价。

dev
zhangsiqi 5 months ago
parent
commit
6a2d518640
  1. 5
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderChildController.java
  2. 27
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  3. 1
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java
  4. 27
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/add.html
  5. 172
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/addPurchaseOrder.html
  6. 6
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html

5
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderChildController.java

@ -1,6 +1,10 @@
package com.ruoyi.purchase.controller;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.ruoyi.quality.domain.QualityOrderDetail;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -99,7 +103,6 @@ public class PurchaseOrderChildController extends BaseController
mmap.put("purchaseOrderChild", purchaseOrderChild);
return prefix + "/edit";
}
/**
* 修改保存采购订单子表
*/

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

@ -22,8 +22,10 @@ import com.ruoyi.purchase.domain.PurchaseOrderChild;
import com.ruoyi.purchase.domain.PurchaseQuoteChild;
import com.ruoyi.purchase.domain.exportDto.PurchaseMaterialDto;
import com.ruoyi.purchase.domain.exportDto.PurchaseOrderDto;
import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper;
import com.ruoyi.purchase.service.IPurchaseMaterialService;
import com.ruoyi.purchase.service.IPurchaseOrderService;
import com.ruoyi.quality.domain.QualityOrderDetail;
import com.ruoyi.storehouse.utils.CustomRowWriteCellHandler;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -37,6 +39,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import static com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder.log;
@ -56,7 +59,8 @@ public class PurchaseOrderController extends BaseController
private IPurchaseOrderService purchaseOrderService;
@Autowired
private IPurchaseMaterialService purchaseMaterialService;
@Autowired
private PurchaseOrderChildMapper purchaseOrderChildService;;
@Autowired
private RedisCache redisCache;
@ -120,7 +124,7 @@ public class PurchaseOrderController extends BaseController
BigDecimal materialRmbSum = BigDecimal.valueOf(0.0);
BigDecimal materialSum = BigDecimal.valueOf(0.0);
Long materialNum = 0L;
Long supplierNum = 0L;
int supplierNum = 0;
for (PurchaseOrderChild purchaseOrderChild : purchaseMaterials) {
purchaseOrderChild.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
for (PurchaseQuoteChild purchaseSupplierQuote : purchaseOrderChild.getPurchaseQuoteChildList()){
@ -143,7 +147,7 @@ public class PurchaseOrderController extends BaseController
purchaseOrderChild.setMaterialRmb(materialRmb);
purchaseOrderChild.setMaterialNum(materialNum);
}
purchaseOrder.setSupplierNum(Math.toIntExact(supplierNum));
purchaseOrder.setSupplierNum(supplierNum);
return toAjax(purchaseOrderService.insertPurchaseOrder(purchaseOrder));
}
@ -157,7 +161,24 @@ public class PurchaseOrderController extends BaseController
mmap.put("purchaseOrder", purchaseOrder);
return prefix + "/edit";
}
@GetMapping("/detail/{purchaseOrderChildId}")
public String detail(@PathVariable("purchaseOrderChildId") Long purchaseOrderChildId, ModelMap mmap)
{
PurchaseOrderChild purchaseOrderChild = purchaseOrderChildService.selectPurchaseOrderChildById(purchaseOrderChildId);
mmap.put("purchaseOrderChild", purchaseOrderChild);
return prefix + "/detail";
}
@ResponseBody
@RequestMapping("/detailListGroupedBySupplier")
public Map<String, List<PurchaseOrderChild>> detailListGroupedBySupplier(String qualityOrderCode) {
PurchaseOrderChild purchaseOrderChild = new PurchaseOrderChild();
purchaseOrderChild.setPurchaseOrderCode(qualityOrderCode);
List<PurchaseOrderChild> allDetails = purchaseOrderChildService.selectPurchaseOrderChildList(purchaseOrderChild);
Map<String, List< PurchaseOrderChild>> groupedDetails = allDetails.stream()
.collect(Collectors.groupingBy(PurchaseOrderChild::getSupplierCode));
return groupedDetails;
}
/**
* 修改保存采购订单
*/

1
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java

@ -97,7 +97,6 @@ public class PurchaseOrderChild extends BaseEntity
/** 备用二 */
@Excel(name = "备用二")
private String standbyTwo;
private List<PurchaseQuoteChild> purchaseQuoteChildList;
public List<PurchaseQuoteChild> getPurchaseQuoteChildList() {

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

@ -21,34 +21,35 @@
<div class="form-group">
<label class="col-sm-3 control-label">采购来源:</label>
<div class="col-sm-8">
<select name="purchasePlanType" class="form-control m-b">
<option value="">所有</option>
<select name="purchasePlanType" th:field="${@dict.getType('sys_purchase_source')}" class="form-control m-b">
<option value="">请选择采购来源</option>
<option th:each="dict : ${@dict.getType('sys_purchase_source')}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
th:selected="(${dict.dictValue} == ${sysPurchaseSource}) ? 'selected' : ''"></option>
</select>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料合计:</label>
<div class="col-sm-8">
<input name="materialAmount" class="form-control" type="text">
<input name="materialAmount" class="form-control" type="number">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">数量总计:</label>
<div class="col-sm-8">
<input name="materialSum" class="form-control" type="text">
<input name="materialSum" class="form-control" type="number">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">不含税总价(RMB):</label>
<div class="col-sm-8">
<input name="noRmbSum" class="form-control" type="text">
<input name="noRmbSum" class="form-control" type="number">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">含税总价(RMB):</label>
<div class="col-sm-8">
<input name="rmbSum" class="form-control" type="text">
<input name="rmbSum" class="form-control" type="number">
</div>
</div>
<div class="form-group">
@ -62,6 +63,18 @@
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "purchase/purchasePlan";
var editFlag = [[${@permission.hasPermi('purchase:plan:edit')}]];
var removeFlag = [[${@permission.hasPermi('purchase:plan:remove')}]];
var cancelFlag = [[${@permission.hasPermi('purchase:plan:cancel')}]];
var restoreFlag = [[${@permission.hasPermi('purchase:plan:restore')}]];
var purchasePlanStatusDatas = [[${@dict.getType('purchase_plan_status')}]];
var auditStatusDatas = [[${@dict.getType('auditStatus')}]];
var useStatusDatas = [[${@dict.getType('useStatus')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var sysUnitClassDatas = [[${@dict.getType('sysUnitClassDatas')}]];
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var purchasePlanTypeDatas = [[${@dict.getType('purchase_plan_source')}]];
var prefix = ctx + "purchase/plan"
$("#form-plan-add").validate({focusCleanup: true});
$(function(){

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

@ -12,47 +12,43 @@
<input id="purchasePlanCodes" th:value="${purchasePlanCodes}" name="purchasePlanCode" class="form-control" type="text">
</div>
</div>
<div class="col-xs-12" id="material">
<div class="container" id="material">
</div>
</form>
<div class="container">
<div class="form-row"><h4 class="card-header">公司地址:</h4></div>
<div class="col-xs-12 form-row">
<div class="row"><h4 class="card-header">公司地址:</h4></div>
<div class="form-group">
<label for="inputWarehouseID" class="col-sm-3 col-form-label">仓库ID:</label>
<div class="col-sm-6">
<label for="inputWarehouseID" class="col-sm-2 col-form-label">仓库ID:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="inputWarehouseID" placeholder="请输入仓库ID">
</div>
</div>
<div class="form-group">
<label for="inputWarehouseName" class="col-sm-3 form-label">仓库名称:</label>
<div class="col-sm-6">
<label for="inputWarehouseName" class="col-sm-2 control-label">仓库名称:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="inputWarehouseName" placeholder="请输入仓库名称">
</div>
</div>
</div>
<div class="col-xs-12 form-row">
<div class="form-group">
<label for="inputReceiver" class="col-sm-3 form-label">收货人:</label>
<div class="col-sm-6">
<label for="inputReceiver" class="col-sm-2 control-label">收货人:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="inputReceiver" placeholder="请输入收货人">
</div>
</div>
<div class="form-group">
<label for="inputPhone" class="col-sm-3 form-label">收货电话:</label>
<div class="col-sm-6">
<label for="inputPhone" class="col-sm-2 control-label">收货电话:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="inputPhone" placeholder="请输入收货电话">
</div>
</div>
</div>
<div class="form-group">
<label for="inputAddressDetails" class="col-sm-3 form-label">详细地址:</label>
<div class="col-sm-6">
<label for="inputAddressDetails" class="col-sm-2 control-label">详细地址:</label>
<div class="col-sm-4">
<textarea class="form-control" id="inputAddressDetails"></textarea>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-table-editable-js" />
@ -81,44 +77,45 @@
// 初始化表格
// 假设purchasePlanChildList已定义并包含了需要处理的数据
purchasePlanChildList.forEach(function (material, index) {
var tableId = 'materialCode_' + index;
var materialTable = "bootstrap_table-" + tableId;
tableIdList.push(materialList);
var tableId = 'materialCode-' + index;
var materialTable = "bootstrap-table_" + tableId;
tableIdList.push(tableId);
// 创建物料信息的容器
var $tableWrapper = $('<div id="material-' + tableId + '""></div>');
// 添加关联销售订单号信息
var $headerDiv =
$('<div class="row">' +
'<div class="form-row"><strong>物料 ' + index + ': </strong> ' + '<strong>关联订单号: </strong>' + '<span id="correlateion-' + tableId + ' ">' + material.correlationCodes + '</span></div>' +
'<div class="form-row">' +
'<div class="col-sm-12 select-table table-striped">' +
'<table class="table table-hover table-striped table-materialCode" id="' + materialTable + '">' + '<br />' +
'<div class="col-xs-12">' +
'<div class="row">' +
'<span><strong>物料 ' + index + ': </strong> ' + '<strong>关联订单号: </strong></span>' + '<span class="correlationCodes" id="correlateion-' + tableId + ' ">' + material.correlationCodes + '</span>' +
'</div>' +
'<div class="col-sm-12">' +
'<table class="table-materialCode" id="' + materialTable + '">' + '<br />' +
'</div>' +
'</div>' +
'</div>'
);
'</div>');
$tableWrapper.append($headerDiv);
// 创建表格的容器
// 循环处理每个供应商的信息
material.purchaseSupplierList.forEach(function (supplier, supplierIndex) {
var $supplierInfo = $('<div class="card mt-12"></div>'); // 卡片样式容器,用于包裹每个供应商的信息
var $supplierInfo = $('<div class="card mt-12 supplier-card" ></div>'); // 卡片样式容器,用于包裹每个供应商的信息
// 构建供应商信息头部
var $headerContent =
$('<div class="card-header">' +
'<h3 class="card-title">供应商 ' + supplierIndex + ': ' + '</h3>' +
'<p class="card-text">' + '<span>' + supplier.supplierCode + '</span>' + '-' + '<span>' + supplier.supplierName + '</span>' + '-最新不含税采购价: ' + supplier.materialNoRmb + ' RMB ' + ' 最新含税采购价: ' + supplier.materialRmb + ' RMB </p>' +
$('<div class="card-header" id = "supplier-' + tableId + '>' +
'<h3 class="card-title">' + '供应商 ' + supplierIndex + ': ' + '</h3>' +
'<p class="card-text ">' + '<span class="supplierCode"">' + supplier.supplierCode + '</span>' + '-' + '<span class="supplierName">' + supplier.supplierName + '</span>' + '-最新不含税采购价: ' + '<span class="supplierMaterialNoRmb">' + supplier.materialNoRmb + '</span>' + ' RMB ' + ' 最新含税采购价: ' + '<span class="supplierMaterialRmb">' + supplier.materialRmb + '</span> RMB </p>' +
'<div class="card-body">' +
'<div class="form-group">' +
'<label class="col-sm-3" for="actualPurchaseNum_' + tableId + '"> 实际采购数: </label>' +
'<label class="col-sm-3"> 实际采购数: </label>' +
'<div class ="col-sm-8">' +
'<input type="text" name="materialNum" class="form-control" id="actualPurchaseNum_' + tableId + '">' +
'<input type="text" name="materialNum" class="form-control supplierMaterialNum" id="actualPurchaseNum_' + tableId + '">' +
'</div>' +
'</div>' +
'<div class="form-group">' +
'<label class="col-sm-3" for="actualPurchaseNum_' + tableId + '">计划交付时间:</label>' +
'<label class="col-sm-3">计划交付时间:</label>' +
'<div class ="col-sm-8">' +
'<div class="input-group date"> ' +
'<input type="text" name="deliveryTime" class="form-control" id="deliveryTime_' + tableId + '">' +
'<input type="text" name="deliveryTime" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '">' +
'<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' +
'</div> ' +
'</div>' +
@ -153,22 +150,28 @@
});
function tableSetup(element, tableId) {
var $totalSection = $('<div class="card mt-8">' +
'<div class="card-header">' +
'<h5 class="card-title">实际采购合计</h5>' +
var $totalSection = $(
'<div class="card mt-8">' +
'<div class="card-body" class="supplierTotal_' + tableId + '">' +
'<div class="form-row">' +
'<label for="actualPurchaseTotal" class="col-sm-3">实际采购数合计:</label>' +
'<div class="col-sm-8">' +
'<input type="number" name="materialAmountSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' +
'</div>' +
'</div>' +
'<div class="card-body">' +
'<div class="form-row">' +
'<label for="actualPurchaseTotal" class="col-sm-3">不含税采购总价:</label>' +
'<div class="col-sm-8">' +
'<input type="number" name="materialNoRmbSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' +
'</div>' +
'</div>' +
'<div class="form-row">' +
'<label for="actualPurchaseTotalTax" class="col-sm-3">含税采购总价:</label>' +
'<div class="col-sm-8">' +
'<input type="number" name="materialRmbSum" class="form-control" id="materialRmbSum_' + tableId + '" readonly>' +
'</div>' +
'</div>' +
'</div>'+
'</div>');
element.append($totalSection);
}
@ -183,7 +186,7 @@
showColumns: false,
showToggle: false,
data: data,
height: 60,
height: 25,
columns: [
{checkbox: false},
{title: '料号', field: 'materialCode'},
@ -219,50 +222,71 @@
});
function submitHandler() {
if ($.validate.form()) {
var allMaterialsData = {
purchaseOrder: {
purchaseOrderChildList: [], // 采购订单下的所有物料信息数组
},
var purchaseOrder = {
purchaseOrderCode: "", // 这里可能需要生成一个临时的或预设的订单号,实际生产环境应由后端生成
supplierNum: 0,
materialNum: 0,
materialNoRmbSum: 0,
materialRmbSum: 0,
purchaseOrderChildList: []
};
// 存储所有物料的汇总信息
// 遍历每个物料容器
var materialData = {};
$('.table-materialCode').each(function(index, tableElement) {
for (tableId in tableIdList) {
var material = materialList[tableId];
materialData = {
materialCode: '', // 物料编码,需要从对应物料信息中获取
materialNum: $('#' + 'actualPurchaseNum_' + tableId).val(), // 实际采购数
purchaseQuoteChildList: [], // 该物料下的供应商信息数组
materialNoRmbSum: $('#' + 'materialNoRmbSum_' + tableId).val(), // 不含税总价
materialRmbSum: $('#' + 'materialRmbSum_' + tableId).val(), // 含税总价
console.log(tableElement);
var tableId = tableIdList[index]; // 从table ID中提取tableId
var materialData = {
materialCode: , // 确保能正确获取物料编码
materialNum: 0,
materialNoRmbSum: 0,
materialRmbSum: 0,
purchaseQuoteChildList: []
};
var $supplierForm = $('#card_body_' + tableId);
$supplierForm.find('.card').each(function (index, element) {
if (index > 0) { // 跳过第一个card,因为它应该是物料头信息
var supplier = {
supplierCode: $(element).find('.card-header span:first').text().trim(),
supplierName: $(element).find('.card-header span:eq(1)').text().trim(),
materialNoRmb: parseFloat($(supplierCard).find('.card-header').text().match(/最新不含税采购价: (\d+(\.\d+)?) RMB/)[1]),
materialRmb: parseFloat($(supplierCard).find('.card-header').text().match(/最新含税采购价: (\d+(\.\d+)?) RMB/)[1]),
materialRmbSum: $(element).find('input[name="materialRmbSum"]').val(),
materialNoRmbSum: $(element).find('input[name="materialNoRmbSum"]').val(),
deliveryTime: $(element).find('input[name="deliveryTime"]').val(),
materialNum: $(element).find('input[name="materialNum"]').val(),
var materialActualNum = $('#' + 'actualPurchaseNum_' + tableId).val();
var materialNoRmbTotal = $('#' + 'materialNoRmbSum_' + tableId).val();
var materialRmbTotal = $('#' + 'materialRmbSum_' + tableId).val();
materialData.materialNum = parseInt(materialActualNum);
materialData.materialNoRmbSum = materialNoRmbTotal;
materialData.materialRmbSum = materialRmbTotal;
// 遍历该物料下的供应商信息
$('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) {
var supplierQuote = {
supplierCode: $(supplierCard).find('.supplierCode').text().trim(),
supplierName: $(supplierCard).find('.supplierName').text().trim(),
materialNoRmb: parseFloat($(supplierCard).find('.supplierMaterialNoRmb').text().trim()),
materialRmb: parseFloat($(supplierCard).find('.supplierMaterialRmb').text().trim()),
materialNum: $(supplierCard).find('.supplierMaterialNum').val().trim(),
deliveryTime: $(supplierCard).find('.supplierDeliveryTime').val()
};
materialData.purchaseOrder.purchaseOrderChildList.purchaseQuoteChildList.push(supplier);
materialData.purchaseQuoteChildList.push(supplierQuote);
purchaseOrder.supplierNum += 1; // 累加供应商数量
});
purchaseOrder.materialNoRmbSum += $("#" + 'material-'+ tableId ).find("supplierTotal_" + tableId).find("input[name='materialNoRmbSum']");
purchaseOrder.materialRmbSum += $("#" + 'material-'+ tableId ).find("supplierTotal_" + tableId).find("input[name='materialNoRmbSum']"); // 累加含税总价
purchaseOrder.purchaseOrderChildList.push(materialData);
});
// 发送数据到后端API
$.ajax({
type: "POST",
url: prefix + "/add", // 这里的prefix应该是之前定义的context路径
data: JSON.stringify(purchaseOrder), // 将构造好的对象转换为JSON字符串
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
if (response.code === 200) {
alert("采购订单添加成功!");
// 可以在这里添加更多成功的处理逻辑,如页面跳转等
} else {
alert("采购订单添加失败:" + response.msg);
}
})
},
error: function (error) {
console.error("请求失败:", error);
alert("提交过程中发生错误,请重试。");
}
});
// 根据实际情况获取物料编码等其他必要信息,这里假设可以从某个地方获取
// 例如:materialData.materialCode = ...;
allMaterialsData.purchaseOrder.purchaseOrderChildList.push(materialData);
}
// 将收集到的所有物料信息转换为JSON,准备发送
var jsonData = JSON.stringify(allMaterialsData);
// 发送数据到后端API
$.operate.saveJson(prefix + "/add", jsonData);
}
</script>
</body>

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

@ -91,9 +91,7 @@
rightFixedColumns:1,
fixedRightNumber: 1, // 冻结右列个数
onExpandRow : function(index,row,$detail){
$detail.html(
'<table class="table-container" id="purchase_plan_'+row.id+'"></table>'
).find('table');
$detail.html('<table class="table-container" id="purchase_plan_'+row.id+'"></table>').find('table');
// 一阶
initChildTable(index,row,$detail);
},
@ -105,7 +103,7 @@
},
{title: '采购计划单号',field: 'purchasePlanCode'},
{title: '关联单号', field: 'correlationCode',},
{title: '采购来源',field: 'purchasePlanType',},
{title: '采购来源',field: 'purchasePlanType',formatter: function(value, row, index) {return $.table.selectDictLabel(purchasePlanTypeDatas, value);}},
{title: '物料合计',field: 'materialAmount',},
{title: '数量总计', field: 'materialSum',},
{title: '不含税总价(RMB)',field: 'noRmbSum',},

Loading…
Cancel
Save