From 93af3e8027364946e040082cdf0f8fca07beae15 Mon Sep 17 00:00:00 2001 From: jiangxiaoming <jiangxiaoming@seaskysh.com> Date: Wed, 8 Jan 2025 13:56:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6pdf=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/EntryCommandServiceImpl.java | 34 ++++++++++++++++--- .../mapper/api/EntryBillFlowMapper.java | 2 ++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/EntryCommandServiceImpl.java b/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/EntryCommandServiceImpl.java index a3cdea44..2fb8e700 100644 --- a/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/EntryCommandServiceImpl.java +++ b/ServiceSite/src/main/java/com/seasky/ledgerincome/application/command/EntryCommandServiceImpl.java @@ -1166,10 +1166,18 @@ public class EntryCommandServiceImpl implements EntryCommandService { } @Override public void mergePdf(Long incomeId) throws UnsupportedEncodingException { - - //鍒ゆ柇鏄笉鏄壒閲忓叆璐� 鏄殑璇濇煡璇㈠叾浠栫殑鍙戠エ - List<Long> incomeIds = voucherRepository.findIncomeIds(incomeId); - + List<Long> incomeIds = new ArrayList<>(); + EntryBillFlowPo entryBillFlowPo = entryBillFlowMapper.selectByIncomeIdLatest(incomeId); + if(entryBillFlowPo!=null){ + if(entryBillFlowPo.getEntryType().equals(EntryTypeEnum.鍒版杞殏瀛�.getValue())){ + //鍒ゆ柇鏄笉鏄壒閲忓叆璐� 鏄殑璇濇煡璇㈠叾浠栫殑鍙戠エ + incomeIds = voucherRepository.findIncomeIds(incomeId); + }else{ + incomeIds.add(incomeId); + } + }else{ + incomeIds.add(incomeId); + } //1 鏍规嵁鍥炲崟id 鏌ヨ鏂囦欢琛� FileQry fileQry = new FileQry(); fileQry.setIncomeId(incomeIds); @@ -1179,6 +1187,24 @@ public class EntryCommandServiceImpl implements EntryCommandService { if(fileOutList == null ||fileOutList.isEmpty()){ throw new RuntimeException("鏈煡璇㈠埌鏂囦欢"); } + if(incomeIds.size()==1){// 鍘婚噸鍏ヨ处鐢宠鍗曞彧鐣欎竴涓� + fileOutList = fileOutList.stream() + .collect(Collectors.groupingBy( + FileOut::getFileType, LinkedHashMap::new, Collectors.toList() + )) // 鍒嗙粍 + .entrySet() + .stream() + .flatMap(entry -> { + if (FileTypeEmun.鍏ヨ处鐢宠鍗�.getValue().equals(entry.getKey())) { + // "鍏ヨ处鐢宠鍗�" 鍙彇绗竴涓� + return entry.getValue().stream().limit(1); + } else { + // 鍏朵粬绫诲瀷鍏ㄩ儴淇濈暀 + return entry.getValue().stream(); + } + }) + .collect(Collectors.toList()); + } //濡傛灉娌℃湁鍏ヨ处鐢宠鍗曡繕娌$敓鎴� 閭e氨鑷繁鐢熸垚pdf byte[] fileTypeArr = null; List<FileOut> collect = fileOutList.stream().filter(t -> t.fileType.equals(FileTypeEmun.鍏ヨ处鐢宠鍗�.getValue())).collect(Collectors.toList()); diff --git a/ServiceSite/src/main/java/com/seasky/ledgerincome/infrastructure/mapper/api/EntryBillFlowMapper.java b/ServiceSite/src/main/java/com/seasky/ledgerincome/infrastructure/mapper/api/EntryBillFlowMapper.java index d83e8437..72176f16 100644 --- a/ServiceSite/src/main/java/com/seasky/ledgerincome/infrastructure/mapper/api/EntryBillFlowMapper.java +++ b/ServiceSite/src/main/java/com/seasky/ledgerincome/infrastructure/mapper/api/EntryBillFlowMapper.java @@ -26,4 +26,6 @@ public interface EntryBillFlowMapper extends BaseMapper<EntryBillFlowPo> { }) List<Long> findIncomeIds(@Param("entryCodeLong") List<Long> entryCodeLong); + @Select("select * from t_entry_bill_flow where income_id = #{incomeId} order by create_date desc limit 1") + EntryBillFlowPo selectByIncomeIdLatest(@Param("incomeId") Long incomeId); } -- GitLab