Browse Source

[feat]采购管理

修改采购报价新增页面页面错乱问题;采购报价物料列表页面加上最新报价历史数据;新增批量插入物料数据,采用异步请求完成对最新报价数据的填充;新增 查找最新的报价数据前端方法;新增最新报价历史前端方法
采购报价Controller层新增 打开采购报价历史弹窗方法,新增 查询客户报价历史列表方法;新增查询最新报价历史数据方法,
采购报价实体类修复不含税单价和含税单价错乱问题
修复所有采购报价历史url错误问题
新增采购报价历史前端列表页面
dev
liuxiaoxu 3 days ago
parent
commit
11c8a0a9f8
  1. 64
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseQuoteController.java
  2. 13
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseQuoteHistoryController.java
  3. 8
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseQuoteHistory.java
  4. 4
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseQuoteServiceImpl.java
  5. 12
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteHistoryMapper.xml
  6. 166
      ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/add.html
  7. 74
      ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/recentQuotationHistory.html
  8. 2
      ruoyi-admin/src/main/resources/templates/purchase/purchaseQuoteHistory/add.html
  9. 2
      ruoyi-admin/src/main/resources/templates/purchase/purchaseQuoteHistory/purchaseQuoteHistory.html

64
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseQuoteController.java

@ -1,7 +1,9 @@
package com.ruoyi.purchase.controller;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
import com.ruoyi.ck.utils.Result;
@ -10,7 +12,10 @@ import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.purchase.domain.PurchaseQuoteChild;
import com.ruoyi.purchase.domain.PurchaseQuoteHistory;
import com.ruoyi.purchase.domain.Vo.PurchaseQuoteVo;
import com.ruoyi.purchase.service.IPurchaseQuoteHistoryService;
import com.ruoyi.system.domain.SysCustomerQuoteHistory;
import com.ruoyi.system.domain.SysSalesOrderChild;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
@ -51,6 +56,10 @@ public class PurchaseQuoteController extends BaseController
@Autowired
private IPurchaseQuoteService purchaseQuoteService;
@Autowired
private IPurchaseQuoteHistoryService purchaseQuoteHistoryService;
@Autowired
private ISysRoleService roleService;
@ -310,4 +319,59 @@ public class PurchaseQuoteController extends BaseController
purchaseQuoteService.restorePurchaseQuoteById(id);
return AjaxResult.success();
}
/**
* 打开采购报价历史弹窗
* */
@GetMapping("/recentQuotationHistory")
public String history(@RequestParam("materialCode") String materialCode ,
@RequestParam("supplierQuoteCode") String supplierQuoteCode,
ModelMap mmap)
{
mmap.put("materialCode", materialCode);
mmap.put("supplierQuoteCode", supplierQuoteCode);
return prefix + "/recentQuotationHistory";
}
/**
* 查询客户报价历史列表
* */
@PostMapping("/recentQuotationHistoryList")
@ResponseBody
public TableDataInfo recentQuotationHistoryList(PurchaseQuoteHistory purchaseQuoteHistory)
{
startPage();
List<PurchaseQuoteHistory> list = purchaseQuoteHistoryService.selectPurchaseQuoteHistoryList(purchaseQuoteHistory);
return getDataTable(list);
}
/**
* 查询最新报价历史数据
* */
@GetMapping("/queryLatestRecentQuotation")
@ResponseBody
public AjaxResult recentQuotationHistoryData(@RequestParam("materialNo") String materialNo, @RequestParam("supplierQuoteCode") String supplierQuoteCode)
{
PurchaseQuoteHistory purchaseQuoteHistory = new PurchaseQuoteHistory();
purchaseQuoteHistory.setMaterialCode(materialNo);
purchaseQuoteHistory.setSupplierCode(supplierQuoteCode);
List<PurchaseQuoteHistory> purchaseQuoteHistories = purchaseQuoteHistoryService.selectPurchaseQuoteHistoryList(purchaseQuoteHistory);
List<PurchaseQuoteHistory> filterPurchaseQuoteHistories = purchaseQuoteHistories.stream().filter(item -> "1".equals(item.getIsLatest())).collect(Collectors.toList());
if (filterPurchaseQuoteHistories.size() == 0)
{
PurchaseQuoteHistory temp = new PurchaseQuoteHistory();
temp.setMaterialRmb(BigDecimal.ZERO);
return AjaxResult.success(temp);
}
return AjaxResult.success(filterPurchaseQuoteHistories.get(0));
}
}

13
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseQuoteHistoryController.java

@ -1,15 +1,13 @@
package com.ruoyi.purchase.controller;
import java.util.List;
import com.ruoyi.system.domain.SysCustomerQuoteHistory;
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.domain.PurchaseQuoteHistory;
@ -26,10 +24,10 @@ import com.ruoyi.common.core.page.TableDataInfo;
* @date 2024-08-28
*/
@Controller
@RequestMapping("/purchaseQuoteHistory/purchaseQuoteHistory")
@RequestMapping("/purchase/purchaseQuoteHistory")
public class PurchaseQuoteHistoryController extends BaseController
{
private String prefix = "purchaseQuoteHistory/purchaseQuoteHistory";
private String prefix = "purchase/purchaseQuoteHistory";
@Autowired
private IPurchaseQuoteHistoryService purchaseQuoteHistoryService;
@ -147,5 +145,4 @@ public class PurchaseQuoteHistoryController extends BaseController
return toAjax(purchaseQuoteHistoryService.restorePurchaseQuoteHistoryById(id));
}
}

8
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseQuoteHistory.java

@ -72,12 +72,12 @@ public class PurchaseQuoteHistory extends BaseEntity
@Excel(name = "物料的对外报价")
private Long materialSole;
/** 物料的不含税单价(RMB) */
@Excel(name = "物料的不含税单价(RMB)")
private BigDecimal materialRmb;
/** 物料的含税单价(RMB) */
@Excel(name = "物料的含税单价(RMB)")
private BigDecimal materialRmb;
/** 物料的不含税单价(RMB) */
@Excel(name = "物料的不含税单价(RMB)")
private BigDecimal materialNormb;
/** 供应商编号 */

4
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseQuoteServiceImpl.java

@ -397,9 +397,7 @@ public class PurchaseQuoteServiceImpl implements IPurchaseQuoteService
SysUser user = ShiroUtils.getSysUser();
purchaseQuote.setApplyUser(user.getLoginName());
purchaseQuote.setApplyTime(DateUtils.getNowDate());
if(purchaseQuote.getPurchaseQuoteId()==null){
insertPurchaseQuote(purchaseQuote);
}
insertPurchaseQuote(purchaseQuote);
// 启动流程
String applyTitle = user.getUserName()+"发起了客户信息提交审批-"+DateUtils.dateTimeNow();
String instanceType = "submit";

12
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteHistoryMapper.xml

@ -30,12 +30,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" />
<result property="useStatus" column="use_status" />
<result property="auditStatus" column="audit_status" />
<result property="isLatest" column=" is_latest"/>
<result property="isLatest" column="is_latest"/>
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectPurchaseQuoteHistoryVo">
select purchase_quote_child_id, purchase_quote_code, material_id, material_code, material_name, material_type, processMethod, brand, photoUrl, describe, tax_rate, usd_rate, material_num, material_sole, material_rmb, material_noRmb, supplier_code, supplier_name, create_by, create_time, update_by, update_time, remark, use_status, audit_status, is_latest,del_flag from purchase_quote_history
select purchase_quote_child_id, purchase_quote_code, material_id, material_code, material_name, material_sole, material_rmb, material_noRmb, supplier_code, supplier_name, create_by, create_time, update_by, update_time, remark, use_status, audit_status, is_latest,del_flag from purchase_quote_history
</sql>
<select id="selectPurchaseQuoteHistoryList" parameterType="PurchaseQuoteHistory" resultMap="PurchaseQuoteHistoryResult">
@ -46,14 +46,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
<if test="materialType != null and materialType != ''"> and material_type = #{materialType}</if>
<if test="processMethod != null and processMethod != ''"> and processMethod = #{processMethod}</if>
<if test="brand != null and brand != ''"> and brand = #{brand}</if>
<if test="photoUrl != null and photoUrl != ''"> and photoUrl = #{photoUrl}</if>
<if test="describe != null and describe != ''"> and describe = #{describe}</if>
<if test="taxRate != null "> and tax_rate = #{taxRate}</if>
<if test="usdRate != null "> and usd_rate = #{usdRate}</if>
<if test="materialNum != null "> and material_num = #{materialNum}</if>
<if test="materialSole != null "> and material_sole = #{materialSole}</if>
<if test="materialRmb != null "> and material_rmb = #{materialRmb}</if>
<if test="materialNormb != null "> and material_noRmb = #{materialNormb}</if>

166
ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/add.html

@ -27,15 +27,17 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">供应商名称:</label>
<div class="col-sm-8">
<input name="supplierName" class="form-control select2" required />
<input name="supplierName" class="form-control select2" required readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">定价日期:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="pricingDate" class="form-control" type="text" />
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注说明:</label>
@ -159,6 +161,16 @@
}
},
{title: '最新报价',field: 'materialSole',align: 'center',},
{ title: '最新报价历史',align: 'center',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="recentQuotationHistory(\'' + row.materialCode + '\')"><i class="fa fa-edit"></i>最新报价历史</a> ');
return actions.join('');
}
},
{title: '物料的数量', field: 'materialNum',align: 'center',editable: true,visible: false},
{title: '物料的不含税单价(RMB)',field: 'materialNoRmb',align: 'center',
editable:{
@ -234,48 +246,91 @@
});
getPurchaseQuoteCode();
});
function doSubmit(index, layero,uniqueId){
function doSubmit(index, layero, uniqueId) {
var iframeWin = window[layero.find('iframe')[0]['name']];
var rowData = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections');
var rows = $("#bootstrap-sub-table-1").bootstrapTable('getData').length;
for(var j=0;i<rows;j++){
var data = $("#bootstrap-sub-table-1").bootstrapTable('getData');
for (var i = 0;i<data.length;i++){
if(data[i].materialNo==rowData[j].materialNo){
//如果是物料料号的相同,则从rowData清除相同的料号物料
rowData.splice(j,1);
$.modal.alertError("不能选择已添加过的相同料号" + rowData[j].materialNo);
return;
}
}
var selectedRows = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections');
if (selectedRows.length === 0) {
$.modal.alertWarning("请选择至少一条物料信息");
return;
}
console.log("rowData: "+rowData);
for(var i=0;i<rowData.length;i++){
$("#bootstrap-sub-table-purchaseQuoteChild").bootstrapTable('insertRow', {
index: i,
row: {
materialId:rowData[i].id,
materialCode: rowData[i].materialNo,
materialName: rowData[i].materialName,
materialType: rowData[i].materialType,
describe: rowData[i].describe,
brand: rowData[i].brand,
unit: rowData[i].unit,
processMethod: rowData[i].processMethod,
materialSole: '',
photoUrl: rowData[i].photoUrl,
materialNum: 1,
materialRmb: "",
materialNoRmb: "",
materialNoRmbSum: "",
materialRmbSum: "",
remark: ""
}
var existingData = $("#bootstrap-sub-table-purchaseQuoteChild").bootstrapTable('getData');
var materialCodesSet = new Set(); // 使用 Set 来存储物料号
// 存储所有现有的物料号
existingData.forEach(function(row) {
materialCodesSet.add(row.materialCode);
});
// 存储所有即将插入的料号
var newMaterialCodesSet = new Set();
var promises = selectedRows.map(rowData => {
// 检查是否已经存在相同的料号
if (materialCodesSet.has(rowData.materialNo) || newMaterialCodesSet.has(rowData.materialNo)) {
$.modal.alertError("不能选择已添加过的相同料号 " + rowData.materialNo);
return Promise.reject("Duplicate material number: " + rowData.materialNo);
}
// 标记即将插入的物料号
newMaterialCodesSet.add(rowData.materialNo);
return queryRecentQuotation(rowData.materialNo)
.then(function(quotationData) {
return {
materialId:rowData.id,
materialCode: rowData.materialNo,
materialName: rowData.materialName,
materialType: rowData.materialType,
describe: rowData.describe,
brand: rowData.brand,
unit: rowData.unit,
processMethod: rowData.processMethod,
materialSole: quotationData.data.materialRmb || '',
photoUrl: rowData.photoUrl,
materialNum: 1,
materialRmb: "",
materialNoRmb: "",
materialNoRmbSum: "",
materialRmbSum: "",
remark: ""
};
});
});
// 使用 Promise.all 来等待所有请求完成,并将结果直接存入 newRows
Promise.all(promises)
.then(function(newRows) {
// 批量插入新行
newRows.forEach(function(row) {
$("#bootstrap-sub-table-purchaseQuoteChild").bootstrapTable('insertRow', { index: 1, row: row });
});
layer.close(index);
})
}
layer.close(index);
.catch(function(error) {
console.error('Some requests failed:', error);
layer.close(index);
});
}
function insertRow() {
if ($("#selectSupplierQuoteCode").val() == null || $("#selectSupplierQuoteCode").val() == '') {
$.modal.alertWarning("请先选择供应商ID");
return;
}
var url = ctx + "erp/material/select";
var options = {
title: '选择料号',
@ -378,6 +433,41 @@
values: materialCode
})
}
//最新报价历史
function recentQuotationHistory(materialCode){
var supplierQuoteCode = $("#selectSupplierQuoteCode").val();
var queryParams = new URLSearchParams();
queryParams.append("materialCode", materialCode);
queryParams.append("supplierQuoteCode", encodeURIComponent(supplierQuoteCode));
var url = ctx +'purchase/purchaseQuote/recentQuotationHistory?'+queryParams.toString();
$.modal.open("最新报价历史", url);
}
// 查找最新的报价数据
function queryRecentQuotation(materialNo) {
return new Promise((resolve, reject) => {
// 使用AJAX请求从服务器获取最近的报价信息
$.ajax({
url: prefix + '/queryLatestRecentQuotation',
type: 'GET',
data: { materialNo: materialNo, supplierQuoteCode: $("#selectSupplierQuoteCode").val() },
success: function (data) {
resolve(data); // 成功时解析数据
},
error: function (jqXHR, textStatus, errorThrown) {
reject(new Error('查找最新报价数据失败')); // 失败时抛出错误
}
});
});
}
</script>
</body>
</html>

74
ruoyi-admin/src/main/resources/templates/purchase/purchaseQuote/recentQuotationHistory.html

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('采购报价历史列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var auditStatusDatas = [[${@dict.getType('auditStatus')}]];
var isLatestDatas = [[${@dict.getType('is_latest')}]];
var materialCode = /*[[${materialCode}]]*/ '';
var supplierQuoteCode = /*[[${supplierQuoteCode}]]*/ '';
var prefix = ctx + "purchase/purchaseQuote";
$(function() {
var options = {
url: prefix + "/recentQuotationHistoryList",
modalName: "采购报价历史",
showSearch: false,
showRefresh: false,
showToggle: false,
queryParams: {
materialCode: materialCode,
supplierQuoteCode: supplierQuoteCode
},
columns: [{
checkbox: true
},
{
title: '报价历史id',
field: 'purchaseQuoteChildId',
visible: false
},
{
title: '报价时间',
field: 'createTime',
},
{
title: '物料的含税单价(RMB)',
field: 'materialRmb',
},
{
title: '物料的不含税单价(RMB)',
field: 'materialNormb',
},
{
title: '审核状态',
field: 'auditStatus',
formatter: function(value, row, index) {
return $.table.selectDictLabel(auditStatusDatas, value);
}
},
{
title: '是否是最新报价',
field: 'isLatest',
formatter: function(value, row, index) {
return $.table.selectDictLabel(isLatestDatas, value);
}
},]
};
$.table.init(options);
});
</script>
</body>
</html>

2
ruoyi-admin/src/main/resources/templates/purchase/purchaseQuoteHistory/add.html

@ -147,7 +147,7 @@
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "purchaseQuoteHistory/purchaseQuoteHistory"
var prefix = ctx + "purchase/purchaseQuoteHistory"
$("#form-purchaseQuoteHistory-add").validate({
focusCleanup: true
});

2
ruoyi-admin/src/main/resources/templates/purchase/purchaseQuoteHistory/purchaseQuoteHistory.html

@ -50,7 +50,7 @@
var removeFlag = [[${@permission.hasPermi('purchaseQuoteHistory:purchaseQuoteHistory:remove')}]];
var cancelFlag = [[${@permission.hasPermi('purchaseQuoteHistory:purchaseQuoteHistory:cancel')}]];
var restoreFlag = [[${@permission.hasPermi('purchaseQuoteHistory:purchaseQuoteHistory:restore')}]];
var prefix = ctx + "purchaseQuoteHistory/purchaseQuoteHistory";
var prefix = ctx + "purchase/purchaseQuoteHistory";
$(function() {
var options = {

Loading…
Cancel
Save