diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java index 3edd45cf..516c4671 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java @@ -269,6 +269,8 @@ public class SysCustomerQuoteController extends BaseController if(!approvedFlag){ // 审核状态-审核拒绝 sysCustomerQuoteVo.setAuditStatus("2"); + //客户报价审核后,修改客户报价历史数据 + quoteHistoryService.updateSysCustomerQuoteHistoryByCustomerQuote(sysCustomerQuoteVo); } // 如果任务已结束更新业务表状态 方法中传入的值为原来的instanceId,只是做了调整 boolean processIsFinish = processService.judgeProcessIsFinish(instanceId); @@ -276,6 +278,10 @@ public class SysCustomerQuoteController extends BaseController // 审核通过 sysCustomerQuoteVo.setAuditStatus("1"); + //客户报价审核后,修改客户报价历史数据 + quoteHistoryService.updateSysCustomerQuoteHistoryByCustomerQuote(sysCustomerQuoteVo); + + // 提交 if("submit".equals(instanceType)){ // 使用状态-是 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomerQuoteHistory.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomerQuoteHistory.java index 60b50b93..19f4ed7a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomerQuoteHistory.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomerQuoteHistory.java @@ -50,8 +50,8 @@ public class SysCustomerQuoteHistory extends BaseEntity private BigDecimal materialUsd; /** 报价时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "报价时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "报价时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date quoteTime; /** 审核状态(0待审核、1审核通过、2审核拒绝) */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerQuoteHistoryMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerQuoteHistoryMapper.java index 955cd98f..bac4756e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerQuoteHistoryMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerQuoteHistoryMapper.java @@ -77,4 +77,14 @@ public interface SysCustomerQuoteHistoryMapper int insertSysCustomerQuoteHistoryListBatch(List sysCustomerQuoteHistoryList); + + int updateSysCustomerQuoteHistoryByCode(SysCustomerQuoteHistory sysCustomerQuoteHistory); + + /** + * 根据供应商编码查询最新一条记录 + * */ + SysCustomerQuoteHistory findLatestQuoteHistory(SysCustomerQuoteHistory sysCustomerQuoteHistory); + + + int updateOtherQuoteHistoryByCode(SysCustomerQuoteHistory sysCustomerQuoteHistory); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerQuoteHistoryService.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerQuoteHistoryService.java index b16572ca..494c76c3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerQuoteHistoryService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerQuoteHistoryService.java @@ -81,4 +81,10 @@ public interface ISysCustomerQuoteHistoryService * @param sysCustomerQuote */ int generateSysCustomerQuoteHistory(SysCustomerQuote sysCustomerQuote); + + /** + * 客户报价审核后更新客户报价历史 + * @param sysCustomerQuoteVo + */ + void updateSysCustomerQuoteHistoryByCustomerQuote(SysCustomerQuoteVo sysCustomerQuoteVo); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerQuoteHistoryServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerQuoteHistoryServiceImpl.java index 6c06892b..86efdfea 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerQuoteHistoryServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerQuoteHistoryServiceImpl.java @@ -1,8 +1,7 @@ package com.ruoyi.system.service.impl; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; + import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.system.domain.SysCustomerQuote; @@ -54,7 +53,18 @@ public class SysCustomerQuoteHistoryServiceImpl implements ISysCustomerQuoteHist @Override public List selectSysCustomerQuoteHistoryList(SysCustomerQuoteHistory sysCustomerQuoteHistory) { - return sysCustomerQuoteHistoryMapper.selectSysCustomerQuoteHistoryList(sysCustomerQuoteHistory); + //最新的报价 + SysCustomerQuoteHistory latestQuoteHistory = sysCustomerQuoteHistoryMapper.findLatestQuoteHistory(sysCustomerQuoteHistory); + List sysCustomerQuoteHistories = sysCustomerQuoteHistoryMapper.selectSysCustomerQuoteHistoryList(sysCustomerQuoteHistory); + sysCustomerQuoteHistories.forEach(customerQuoteHistory -> { + if (Objects.equals(customerQuoteHistory.getQuoteHistoryId(), latestQuoteHistory.getQuoteHistoryId())) { + customerQuoteHistory.setIsLatest("1"); + } else { + customerQuoteHistory.setIsLatest("0"); + } + }); + + return sysCustomerQuoteHistories; } /** @@ -90,6 +100,7 @@ public class SysCustomerQuoteHistoryServiceImpl implements ISysCustomerQuoteHist for (SysCustomerQuoteChild sysCustomerQuoteChild : sysCustomerQuoteChildren) { SysCustomerQuoteHistory sysCustomerQuoteHistory = new SysCustomerQuoteHistory(); sysCustomerQuoteHistory.setCustomerCode(sysCustomerQuote.getCustomerCode()); + sysCustomerQuoteHistory.setSupplierCode(supplierCode); sysCustomerQuoteHistory.setMaterialCode(sysCustomerQuoteChild.getMaterialCode()); sysCustomerQuoteHistory.setMaterialRmb(sysCustomerQuoteChild.getMaterialRmb()); sysCustomerQuoteHistory.setMaterialNoRmb(sysCustomerQuoteChild.getMaterialNoRmb()); @@ -108,6 +119,35 @@ public class SysCustomerQuoteHistoryServiceImpl implements ISysCustomerQuoteHist } + + /** + * 根据客户报价信息更新客户最新报价记录 + * @param sysCustomerQuoteVo + */ + @Override + public void updateSysCustomerQuoteHistoryByCustomerQuote(SysCustomerQuoteVo sysCustomerQuoteVo) { + String loginName = ShiroUtils.getLoginName(); + String supplierCode = sysCustomerQuoteVo.getSupplierCode(); + String auditStatus = sysCustomerQuoteVo.getAuditStatus(); + + // 获取所有的子项 + List sysCustomerQuoteChildren = quoteChildMapper.selectSysCustomerQuoteChildByQuoteId(supplierCode); + for (SysCustomerQuoteChild sysCustomerQuoteChild : sysCustomerQuoteChildren) { + SysCustomerQuoteHistory sysCustomerQuoteHistory = new SysCustomerQuoteHistory(); + + // 设置审核状态 + sysCustomerQuoteHistory.setAuditStatus(auditStatus.equals("1") ? "1" : "2"); + sysCustomerQuoteHistory.setSupplierCode(supplierCode); + // 设置其他字段 + sysCustomerQuoteHistory.setMaterialCode(sysCustomerQuoteChild.getMaterialCode()); + sysCustomerQuoteHistory.setUpdateBy(loginName); + sysCustomerQuoteHistory.setUpdateTime(new Date()); + // 更新报价历史记录 + sysCustomerQuoteHistoryMapper.updateSysCustomerQuoteHistoryByCode(sysCustomerQuoteHistory); + } + } + + /** * 修改客户报价历史 * diff --git a/ruoyi-admin/src/main/resources/mapper/system/SysCustomerQuoteHistoryMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/SysCustomerQuoteHistoryMapper.xml index 30573101..75540eb2 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/SysCustomerQuoteHistoryMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/SysCustomerQuoteHistoryMapper.xml @@ -38,7 +38,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where quote_history_id = #{quoteHistoryId} - + + + + insert into sys_customer_quote_history @@ -78,11 +86,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into sys_customer_quote_history - (customer_code, materialCode, materialRmb, materialNoRmb, materialNoUsd, materialUsd, quote_time, create_by, + (customer_code, materialCode, supplierCode ,materialRmb, materialNoRmb, materialNoUsd, materialUsd, quote_time, create_by, create_time, audit_status, is_latest) values - #{item.customerCode},#{item.materialCode}, #{item.materialRmb}, #{item.materialNoRmb}, + #{item.customerCode},#{item.materialCode}, #{item.supplierCode}, #{item.materialRmb}, #{item.materialNoRmb}, #{item.materialNoUsd}, #{item.materialUsd}, #{item.quoteTime}, #{item.createBy}, #{item.createTime},#{item.auditStatus}, #{item.isLatest} @@ -110,6 +118,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where quote_history_id = #{quoteHistoryId} + + + update sys_customer_quote_history + + customer_code = #{customerCode}, + supplierCode = #{supplierCode}, + materialCode = #{materialCode}, + materialRmb = #{materialRmb}, + materialNoRmb = #{materialNoRmb}, + materialNoUsd = #{materialNoUsd}, + materialUsd = #{materialUsd}, + quote_time = #{quoteTime}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + audit_status = #{auditStatus}, + is_latest = #{isLatest}, + + where supplierCode = #{supplierCode} and materialCode = #{materialCode} + + + + + + update sys_customer_quote_history + + customer_code = #{customerCode}, + supplierCode = #{supplierCode}, + materialCode = #{materialCode}, + materialRmb = #{materialRmb}, + materialNoRmb = #{materialNoRmb}, + materialNoUsd = #{materialNoUsd}, + materialUsd = #{materialUsd}, + quote_time = #{quoteTime}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + audit_status = #{auditStatus}, + is_latest = #{isLatest}, + + where supplierCode = #{supplierCode} and materialCode != #{materialCode} + + + delete from sys_customer_quote_history where quote_history_id = #{quoteHistoryId} diff --git a/ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html b/ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html index 3591f71a..92ccc328 100644 --- a/ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html +++ b/ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html @@ -642,53 +642,79 @@ } }); } - function doSubmit(index, layero,uniqueId){ + function doSubmit(index, layero, uniqueId) { console.log(uniqueId); var iframeWin = window[layero.find('iframe')[0]['name']]; - var rowData = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections')[0]; - console.log("rowData: "+rowData); - //判断是否重复 - var rows = $("#bootstrap-sub-table-1").bootstrapTable('getData').length; - for(var i=0;i 0) { + for (var k = 0; k < newRows.length; k++) { + $("#bootstrap-sub-table-quoteChild").bootstrapTable('insertRow', { index: 1, row: newRows[k] }); } - }) + } + layer.close(index); } + function insertRow() { if ($("#customerCode").val() == null || $("#customerCode").val() == '') { $.modal.alertWarning("请先选择客户"); diff --git a/ruoyi-admin/src/main/resources/templates/system/customerQuote/recentQuotationHistory.html b/ruoyi-admin/src/main/resources/templates/system/customerQuote/recentQuotationHistory.html index 07a88fed..d27fcc3e 100644 --- a/ruoyi-admin/src/main/resources/templates/system/customerQuote/recentQuotationHistory.html +++ b/ruoyi-admin/src/main/resources/templates/system/customerQuote/recentQuotationHistory.html @@ -15,7 +15,7 @@