From 78b0b58d0c0fa4a50b5767136f3bbee8f364fe61 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 26 九月 2025 09:11:08 +0800
Subject: [PATCH] yys 新增配置文件
---
src/main/java/com/ruoyi/purchase/service/impl/InvoicePurchaseServiceImpl.java | 107 ++++++++++++-----------------------------------------
1 files changed, 25 insertions(+), 82 deletions(-)
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/InvoicePurchaseServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/InvoicePurchaseServiceImpl.java
index 5a0a9b4..0187823 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/InvoicePurchaseServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/InvoicePurchaseServiceImpl.java
@@ -2,14 +2,18 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.enums.FileNameType;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.other.mapper.TempFileMapper;
-import com.ruoyi.other.pojo.TempFile;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysUserMapper;
import com.ruoyi.purchase.dto.InvoicePurchaseDto;
+import com.ruoyi.purchase.dto.InvoicePurchaseReportDto;
+import com.ruoyi.purchase.dto.VatDto;
import com.ruoyi.purchase.mapper.InvoicePurchaseMapper;
import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
import com.ruoyi.purchase.pojo.InvoicePurchase;
@@ -19,19 +23,11 @@
import com.ruoyi.sales.pojo.CommonFile;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@@ -93,7 +89,7 @@
// 鎵归噺鏌ヨ杩欎簺鍙戠エ鍏宠仈鐨勬枃浠朵俊鎭�
LambdaQueryWrapper<CommonFile> fileQueryWrapper = new LambdaQueryWrapper<>();
fileQueryWrapper.in(CommonFile::getCommonId, invoiceIds)
- .eq(CommonFile::getType,"3");
+ .eq(CommonFile::getType, FileNameType.INVOICE.getValue());
List<CommonFile> fileList = commonFileMapper.selectList(fileQueryWrapper);
// 灏嗘枃浠朵俊鎭槧灏勫埌瀵瑰簲鐨勫彂绁↖D
@@ -141,79 +137,11 @@
}
// 杩佺Щ涓存椂鏂囦欢鍒版寮忕洰褰�
- if (invoicePurchaseDto.getTempFileIds() != null && !invoicePurchaseDto.getTempFileIds().isEmpty()) {
- migrateTempFilesToFormal(invoicePurchase.getId(), invoicePurchaseDto.getTempFileIds());
- }
+// if (invoicePurchaseDto.getTempFileIds() != null && !invoicePurchaseDto.getTempFileIds().isEmpty()) {
+// migrateTempFilesToFormal(invoicePurchase.getId(), invoicePurchaseDto.getTempFileIds());
+// }
return i;
- }
-
- /**
- * 灏嗕复鏃舵枃浠惰縼绉诲埌姝e紡鐩綍
- *
- * @param businessId 涓氬姟ID锛堥攢鍞彴璐D锛�
- * @param tempFileIds 涓存椂鏂囦欢ID鍒楄〃
- * @throws IOException 鏂囦欢鎿嶄綔寮傚父
- */
- private void migrateTempFilesToFormal(Long businessId, List<String> tempFileIds) throws IOException {
- if (CollectionUtils.isEmpty(tempFileIds)) {
- return;
- }
-
- // 鏋勫缓姝e紡鐩綍璺緞锛堟寜涓氬姟绫诲瀷鍜屾棩鏈熷垎缁勶級
- String formalDir = uploadDir + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
-
- Path formalDirPath = Paths.get(formalDir);
-
- // 纭繚姝e紡鐩綍瀛樺湪锛堥�掑綊鍒涘缓锛�
- if (!Files.exists(formalDirPath)) {
- Files.createDirectories(formalDirPath);
- }
-
- for (String tempFileId : tempFileIds) {
- // 鏌ヨ涓存椂鏂囦欢璁板綍
- TempFile tempFile = tempFileMapper.selectById(tempFileId);
- if (tempFile == null) {
- log.warn("涓存椂鏂囦欢涓嶅瓨鍦紝璺宠繃澶勭悊: {}", tempFileId);
- continue;
- }
-
- // 鏋勫缓姝e紡鏂囦欢鍚嶏紙鍖呭惈涓氬姟ID鍜屾椂闂存埑锛岄伩鍏嶅啿绐侊級
- String originalFilename = tempFile.getOriginalName();
- String fileExtension = FilenameUtils.getExtension(originalFilename);
- String formalFilename = businessId + "_" +
- System.currentTimeMillis() + "_" +
- UUID.randomUUID().toString().substring(0, 8) +
- (com.ruoyi.common.utils.StringUtils.hasText(fileExtension) ? "." + fileExtension : "");
-
- Path formalFilePath = formalDirPath.resolve(formalFilename);
-
- try {
- // 鎵ц鏂囦欢杩佺Щ锛堜娇鐢ㄥ師瀛愭搷浣滅‘淇濆畨鍏ㄦ�э級
- Files.move(
- Paths.get(tempFile.getTempPath()),
- formalFilePath,
- StandardCopyOption.REPLACE_EXISTING,
- StandardCopyOption.ATOMIC_MOVE
- );
- log.info("鏂囦欢杩佺Щ鎴愬姛: {} -> {}", tempFile.getTempPath(), formalFilePath);
-
- // 鏇存柊鏂囦欢璁板綍锛堝叧鑱斿埌涓氬姟ID锛�
- CommonFile fileRecord = new CommonFile();
- fileRecord.setCommonId(businessId);
- fileRecord.setName(originalFilename);
- fileRecord.setUrl(formalFilePath.toString());
- fileRecord.setCreateTime(LocalDateTime.now());
- fileRecord.setType(tempFile.getType());
- commonFileMapper.insert(fileRecord);
-
- log.info("鏂囦欢杩佺Щ鎴愬姛: {} -> {}", tempFile.getTempPath(), formalFilePath);
- } catch (IOException e) {
- log.error("鏂囦欢杩佺Щ澶辫触: {}", tempFile.getTempPath(), e);
- // 鍙�夋嫨鍥炴粴浜嬪姟鎴栬褰曞け璐ユ枃浠�
- throw new IOException("鏂囦欢杩佺Щ寮傚父", e);
- }
- }
}
@Override
@@ -225,7 +153,7 @@
// 鏌ヨ涓婁紶鏂囦欢
LambdaQueryWrapper<CommonFile> commonFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
commonFileLambdaQueryWrapper.eq(CommonFile::getCommonId, invoicePurchaseDto.getId())
- .eq(CommonFile::getType, "3");
+ .eq(CommonFile::getType, FileNameType.INVOICE.getValue());
List<CommonFile> commonFiles = commonFileMapper.selectList(commonFileLambdaQueryWrapper);
resultDto.setCommonFiles(commonFiles);
return resultDto;
@@ -235,4 +163,19 @@
public List<InvoicePurchase> selectInvoicePurchaseLists(InvoicePurchase invoicePurchase) {
return invoicePurchaseMapper.selectList(new LambdaQueryWrapper<>());
}
+
+ @Override
+ public IPage<InvoicePurchaseReportDto> listPurchaseReport(Page page, InvoicePurchaseReportDto invoicePurchaseReportDto) {
+ // 澧炲�肩◣ = 閿�鍞殑锛堝惈绋庢�讳环-涓嶅惈绋庢�讳环锛夊噺鍘婚噰璐殑锛堝惈绋庢�讳环-涓嶅惈绋庢�讳环锛�
+ return invoicePurchaseMapper.selectPurchaseReport(page, invoicePurchaseReportDto);
+ }
+
+ @Override
+ public IPage<VatDto> listVat(Page page, String month) {
+ IPage<VatDto> vatDtos = invoicePurchaseMapper.listVat(page,month);
+ vatDtos.getRecords().forEach(vatDto -> {
+ vatDto.setTaxAmount(vatDto.getJTaxAmount().subtract(vatDto.getXTaxAmount()));
+ });
+ return vatDtos;
+ }
}
--
Gitblit v1.9.3