diff --git a/src/main/java/com/spring/modules/quote/service/impl/QuoteServiceImpl.java b/src/main/java/com/spring/modules/quote/service/impl/QuoteServiceImpl.java index 5ace98c3..b32dfbbb 100644 --- a/src/main/java/com/spring/modules/quote/service/impl/QuoteServiceImpl.java +++ b/src/main/java/com/spring/modules/quote/service/impl/QuoteServiceImpl.java @@ -252,6 +252,8 @@ public class QuoteServiceImpl extends ServiceImpl implements @Transactional public List batchSaveQuoteByQuotation(List list) { List ids = new ArrayList<>();// 获取保存成功的报价单ID + // 按 site 缓存下一个可用报价序号,避免批量处理时重复扫描 plm_quote 获取最大号 + Map siteNextQuoteNoMap = new HashMap<>(); for (QuotationInformationVo quotation : list) { if (Objects.isNull(quotation.getCurrency())){ throw new RuntimeException("币种不能为空"); @@ -278,8 +280,16 @@ public class QuoteServiceImpl extends ServiceImpl implements quote.setCreateDate(new Date()); quote.setQuoteDate(new Date()); // quote.setCustomerInquiryNo(quotation.getCustomer()); - // 2、获取报价单号 - String quoteNo = Constant.BJ+baseMapper.queryQuoteNo(quote); + // 2、获取报价单号(按站点批量缓存起始号,循环内递增) + Integer nextQuoteNo = siteNextQuoteNoMap.get(quote.getSite()); + if (Objects.isNull(nextQuoteNo)) { + Quote seedQuote = new Quote(); + seedQuote.setSite(quote.getSite()); + String quoteNoSeed = baseMapper.queryQuoteNo(seedQuote); + nextQuoteNo = StringUtils.hasText(quoteNoSeed) ? Integer.parseInt(quoteNoSeed) : 1; + } + String quoteNo = Constant.BJ + String.format("%08d", nextQuoteNo); + siteNextQuoteNoMap.put(quote.getSite(), nextQuoteNo + 1); quote.setQuoteNo(quoteNo); quote.setVersionNo("A001"); quote.setQuoteVersionNo(quote.getQuoteNo() + "-" + quote.getVersionNo()); diff --git a/src/main/resources/mapper/quotation/QuotationInformationMapper.xml b/src/main/resources/mapper/quotation/QuotationInformationMapper.xml index b5386f6b..a3a3ada2 100644 --- a/src/main/resources/mapper/quotation/QuotationInformationMapper.xml +++ b/src/main/resources/mapper/quotation/QuotationInformationMapper.xml @@ -285,7 +285,12 @@ left join plm_customer_part_info pcpi on a.site = pcpi.site and a.test_part_no = pcpi.part_no and a.customer_no = pcpi.customer_no a.site = #{query.site} and d.node_id = '400' - and a.quotation_no not in (select inside_inquiry_no from plm_quote where site = #{query.site}) + and not exists ( + select 1 + from plm_quote + where site = #{query.site} + and inside_inquiry_no = a.quotation_no + ) and vpp.bu_no in (select bu_No from dbo.Get_Now_BU_chooseAble(a.site, #{query.createBy}))