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 4af442067e0356440f6a82e6aed1ebd6b0ab858f..e7c0253d94b7a8a1644eaa47f98f6308f96a6b18 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 @@ -1188,10 +1188,7 @@ public class EntryCommandServiceImpl implements EntryCommandService { fileQry.setFileType(Arrays.asList(FileTypeEmun.鍏ヨ处鐢宠鍗�.getValue(), FileTypeEmun.鏀舵鍥炲崟.getValue(),FileTypeEmun.澧炲€肩◣鏅€氬彂绁�.getValue(),FileTypeEmun.澧炲€肩◣鍙戠エ.getValue())); List<FileOut> fileOutList = fileQueryService.getFileListAndImage(fileQry); - if(fileOutList == null ||fileOutList.isEmpty()){ - throw new RuntimeException("鏈煡璇㈠埌鏂囦欢"); - } - if(incomeIds.size()==1){// 鍘婚噸鍏ヨ处鐢宠鍗曞彧鐣欎竴涓� + if(incomeIds.size()==1 && fileOutList!=null && fileOutList.size() >0){// 鍘婚噸鍏ヨ处鐢宠鍗曞彧鐣欎竴涓� fileOutList = fileOutList.stream() .collect(Collectors.groupingBy( FileOut::getFileType, LinkedHashMap::new, Collectors.toList() @@ -1211,46 +1208,49 @@ public class EntryCommandServiceImpl implements EntryCommandService { } //濡傛灉娌℃湁鍏ヨ处鐢宠鍗曡繕娌$敓鎴� 閭e氨鑷繁鐢熸垚pdf byte[] fileTypeArr = null; - List<FileOut> collect = fileOutList.stream().filter(t -> t.fileType.equals(FileTypeEmun.鍏ヨ处鐢宠鍗�.getValue())).collect(Collectors.toList()); - //濡傛灉鍏ヨ处鐢宠鍗曟槸鏆傚瓨鍏ヨ处鐨� 涓嶇畻銆� - if(collect!=null && collect.size()>0){ - collect.removeIf(o -> { - if (o.getBatchId() != null) { + if(fileOutList != null && !fileOutList.isEmpty()){ + List<FileOut> collect = fileOutList.stream().filter(t -> t.fileType.equals(FileTypeEmun.鍏ヨ处鐢宠鍗�.getValue())).collect(Collectors.toList()); + //濡傛灉鍏ヨ处鐢宠鍗曟槸鏆傚瓨鍏ヨ处鐨� 涓嶇畻銆� + if(collect!=null && collect.size()>0){ + collect.removeIf(o -> { + if (o.getBatchId() != null) { + QueryWrapper<EntryBillFlowPo> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("batch_id", o.getBatchId()); + queryWrapper.last("order by create_date desc limit 1"); + EntryBillFlowPo flowPo = entryBillFlowMapper.selectOne(queryWrapper); + return flowPo != null && flowPo.getEntryType().equals(EntryTypeEnum.鍒版杞殏瀛�.getValue()); + } + return false; + }); + if(collect==null ||collect.size()==0){ + //閲嶆柊鐢熸垚鍏ヨ处鐢宠鍗� + IncomeAggregate incomeAggregate = incomeRepository.findById(incomeId); + String userName = userInfoUtil.getLoginInfoOut().getUserName(); QueryWrapper<EntryBillFlowPo> queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("batch_id", o.getBatchId()); + queryWrapper.eq("income_id",incomeId); queryWrapper.last("order by create_date desc limit 1"); EntryBillFlowPo flowPo = entryBillFlowMapper.selectOne(queryWrapper); - return flowPo != null && flowPo.getEntryType().equals(EntryTypeEnum.鍒版杞殏瀛�.getValue()); - } - return false; - }); - } - if(collect==null ||collect.size()==0){ - //閲嶆柊鐢熸垚鍏ヨ处鐢宠鍗� - IncomeAggregate incomeAggregate = incomeRepository.findById(incomeId); - String userName = userInfoUtil.getLoginInfoOut().getUserName(); - QueryWrapper<EntryBillFlowPo> queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("income_id",incomeId); - queryWrapper.last("order by create_date desc limit 1"); - EntryBillFlowPo flowPo = entryBillFlowMapper.selectOne(queryWrapper); - if(flowPo!=null){ - String entryType = flowPo.getEntryType(); - try{ - String smallTile = "鏀跺叆鍏ヨ处"; - if(entryType.equals(EntryTypeEnum.鍒版杞殏瀛�.getValue())){ - smallTile ="鏆傚瓨鍏ヨ处"; - } - if(entryType.contains("琛ュ紑绁ㄥ叆璐�")){ - smallTile ="琛ュ紑绁ㄥ叆璐�"; + if(flowPo!=null){ + String entryType = flowPo.getEntryType(); + try{ + String smallTile = "鏀跺叆鍏ヨ处"; + if(entryType.equals(EntryTypeEnum.鍒版杞殏瀛�.getValue())){ + smallTile ="鏆傚瓨鍏ヨ处"; + } + if(entryType.contains("琛ュ紑绁ㄥ叆璐�")){ + smallTile ="琛ュ紑绁ㄥ叆璐�"; + } + Long batId = flowPo.getBatchId(); + fileTypeArr = FileUtil.downloadVoucherPDFNotSave(smallTile, userName, Arrays.asList(incomeAggregate),batId,pdfResource); + }catch (Exception e){ + e.printStackTrace(); + } } - Long batId = flowPo.getBatchId(); - fileTypeArr = FileUtil.downloadVoucherPDFNotSave(smallTile, userName, Arrays.asList(incomeAggregate),batId,pdfResource); - }catch (Exception e){ - e.printStackTrace(); + } } - } + if(incomeIds.size()>0){//鏄壒閲忔殏瀛樺叆璐︾殑 鍏ヨ处鐢宠鍗曞彧闇€灞曠ず涓€涓嵆鍙� && 闇€瑕佺Щ鍑�"鏆傚瓨鍏ヨ处鐢宠鍗�" 濡傛灉鏈夌殑璇�(鏃堕棿鍊掑簭) boolean found = false; // 浣跨敤 Iterator 閬嶅巻骞剁Щ闄ゅ浣欑殑 "鍏ヨ处鐢宠鍗�"