From 0b03e8ab1e3188c4dd8cbf4b38e220f9118ea2f1 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期四, 25 九月 2025 10:34:41 +0800
Subject: [PATCH] yys 修改巡检bug
---
src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java | 106 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 84 insertions(+), 22 deletions(-)
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java
index 1039266..8fc333d 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java
@@ -30,7 +30,6 @@
import com.ruoyi.sales.pojo.CommonFile;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.service.ISalesLedgerProductService;
-import com.ruoyi.sales.service.impl.SalesLedgerProductServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FilenameUtils;
@@ -128,6 +127,8 @@
throw new IllegalArgumentException("閲囪喘鍙拌处璁板綍涓嶅瓨鍦紝ID: " + ticketRegistrationDto.getPurchaseLedgerId());
}
+
+
// 3. 鍒涘缓鎴栨洿鏂扮エ鎹櫥璁板疄浣�
TicketRegistration ticketRegistration = new TicketRegistration();
BeanUtils.copyProperties(ticketRegistrationDto, ticketRegistration);
@@ -136,6 +137,7 @@
ticketRegistration.setIssueDate(ticketRegistrationDto.getIssueDate());
ticketRegistration.setContractAmount(purchaseLedger.getContractAmount());
ticketRegistration.setSalesLedgerId(purchaseLedger.getSalesLedgerId());
+ ticketRegistration.setEnterDate(ticketRegistrationDto.getEnterDate());
// 4. 澶勭悊瀛愯〃鏁版嵁
List<SalesLedgerProduct> productData = ticketRegistrationDto.getProductData();
@@ -149,15 +151,24 @@
// 6. 澧炲姞閲囪喘鍙拌处浜у搧寮�绁ㄨ褰�
List<SalesLedgerProduct> salesLedgerProducts = ticketRegistrationDto.getProductData();
if (CollectionUtils.isNotEmpty(salesLedgerProducts)) {
+ int insert = 0 ;
for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) {
- ProductRecord productRecord = new ProductRecord();
- productRecord.setTicketRegistrationId(ticketRegistration.getId());
- productRecord.setPurchaseLedgerId(ticketRegistrationDto.getPurchaseLedgerId());
- productRecord.setCreatedAt(DateUtils.getNowDate());
- BeanUtils.copyProperties(salesLedgerProduct, productRecord);
- productRecord.setId(null);
- productRecord.setType("2");
- productRecordMapper.insert(productRecord);
+ //鎺掗櫎鎺夊紑绁ㄤ负0鐨勬暟鎹�
+ if (salesLedgerProduct.getTicketsNum() != null && salesLedgerProduct.getTicketsNum().compareTo(BigDecimal.ZERO) > 0) {
+ ProductRecord productRecord = new ProductRecord();
+
+ productRecord.setTicketRegistrationId(ticketRegistration.getId());
+ productRecord.setPurchaseLedgerId(ticketRegistrationDto.getPurchaseLedgerId());
+ productRecord.setCreatedAt(DateUtils.getNowDate());
+ BeanUtils.copyProperties(salesLedgerProduct, productRecord);
+ productRecord.setSaleLedgerProjectId(salesLedgerProduct.getId());
+ productRecord.setId(null);
+ productRecord.setType("2");
+ insert = productRecordMapper.insert(productRecord);
+ }
+ if (insert <= 0) {
+ throw new RuntimeException("浜у搧寮�绁ㄦ暟閮戒负0锛岃妫�鏌�");
+ }
}
}
// 杩佺Щ涓存椂鏂囦欢鍒版寮忕洰褰�
@@ -175,7 +186,7 @@
* @param tempFileIds 涓存椂鏂囦欢ID鍒楄〃
* @throws IOException 鏂囦欢鎿嶄綔寮傚父
*/
- private void migrateTempFilesToFormal(Long businessId, List<String> tempFileIds) throws IOException {
+ public void migrateTempFilesToFormal(Long businessId, List<String> tempFileIds) throws IOException {
if (CollectionUtils.isEmpty(tempFileIds)) {
return;
}
@@ -201,21 +212,25 @@
// 鏋勫缓姝e紡鏂囦欢鍚嶏紙鍖呭惈涓氬姟ID鍜屾椂闂存埑锛岄伩鍏嶅啿绐侊級
String originalFilename = tempFile.getOriginalName();
String fileExtension = FilenameUtils.getExtension(originalFilename);
+ String baseName = FilenameUtils.getBaseName(originalFilename);
String formalFilename = businessId + "_" +
System.currentTimeMillis() + "_" +
- UUID.randomUUID().toString().substring(0, 8) +
+ UUID.randomUUID().toString().substring(0, 8) +baseName+
(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
- );
+// Files.move(
+// Paths.get(tempFile.getTempPath()),
+// formalFilePath,
+// StandardCopyOption.REPLACE_EXISTING,
+// StandardCopyOption.ATOMIC_MOVE
+// );
+ // 鍘熷瓙绉诲姩澶辫触锛屼娇鐢ㄥ鍒�+鍒犻櫎
+ Files.copy(Paths.get(tempFile.getTempPath()), formalFilePath, StandardCopyOption.REPLACE_EXISTING);
+ Files.deleteIfExists(Paths.get(tempFile.getTempPath()));
log.info("鏂囦欢杩佺Щ鎴愬姛: {} -> {}", tempFile.getTempPath(), formalFilePath);
// 鏇存柊鏂囦欢璁板綍锛堝叧鑱斿埌涓氬姟ID锛�
@@ -224,7 +239,7 @@
fileRecord.setName(originalFilename);
fileRecord.setUrl(formalFilePath.toString());
fileRecord.setCreateTime(LocalDateTime.now());
- fileRecord.setType(tempFile.getType());
+ fileRecord.setType(4);
commonFileMapper.insert(fileRecord);
log.info("鏂囦欢杩佺Щ鎴愬姛: {} -> {}", tempFile.getTempPath(), formalFilePath);
@@ -239,7 +254,43 @@
@Override
public int delRegistration(Long[] ids) {
- return ticketRegistrationMapper.deleteBatchIds(Arrays.asList(ids));
+ // 鍒犻櫎閲囪喘鍙拌处浜у搧寮�绁ㄨ褰曞璞�
+ LambdaQueryWrapper<ProductRecord> productRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ productRecordLambdaQueryWrapper.in(ProductRecord::getId, Arrays.asList(ids));
+ List<ProductRecord> productRecords = productRecordMapper.selectList(productRecordLambdaQueryWrapper);
+ if(CollectionUtils.isEmpty(productRecords)){
+ return 0;
+ }
+ LambdaQueryWrapper<TicketRegistration> ticketRegistrationLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ ticketRegistrationLambdaQueryWrapper.in(TicketRegistration::getId, productRecords.stream().map(ProductRecord::getTicketRegistrationId).collect(Collectors.toList()));
+ List<TicketRegistration> ticketRegistrations = ticketRegistrationMapper.selectList(ticketRegistrationLambdaQueryWrapper);
+
+ // 淇敼浜у搧淇℃伅
+ for (ProductRecord productRecord : productRecords) {
+ BigDecimal subtract = ticketRegistrations.get(0).getInvoiceAmount().subtract(productRecords.get(0).getTicketsAmount());
+ // 灏忎簬绛変簬0鍒犻櫎 锛屽ぇ浜�0淇敼
+ if(subtract.compareTo(BigDecimal.ZERO) <= 0){
+ ticketRegistrationMapper.deleteById(ticketRegistrations.get(0));
+ }else if(subtract.compareTo(BigDecimal.ZERO) > 0){
+ ticketRegistrations.get(0).setInvoiceAmount(subtract);
+ ticketRegistrationMapper.updateById(ticketRegistrations.get(0));
+ }
+ LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
+ salesLedgerProductLambdaQueryWrapper.eq(SalesLedgerProduct::getId, productRecord.getSaleLedgerProjectId())
+ .eq(SalesLedgerProduct::getType, 2);
+ List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(salesLedgerProductLambdaQueryWrapper);
+ if(!CollectionUtils.isEmpty(salesLedgerProducts)){
+ for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) {
+ salesLedgerProduct.setFutureTickets(salesLedgerProduct.getFutureTickets().add(productRecord.getTicketsNum()));
+ salesLedgerProduct.setFutureTicketsAmount(salesLedgerProduct.getFutureTicketsAmount().add(productRecord.getTicketsAmount()));
+ salesLedgerProductMapper.updateById(salesLedgerProduct);
+
+ }
+ }
+ }
+ // 鍒犻櫎閲囪喘鍙拌处浜у搧寮�绁ㄨ褰�
+ productRecordMapper.delete(productRecordLambdaQueryWrapper);
+ return 1;
}
@Override
@@ -281,9 +332,13 @@
@Override
public IPage<TicketRegistration> selectTicketRegistrationListPage(Page page, TicketRegistration ticketRegistration) {
LambdaQueryWrapper<TicketRegistration> queryWrapper = new LambdaQueryWrapper<>();
- if (StringUtils.isNotBlank(ticketRegistration.getPurchaseContractNumber())) {
- queryWrapper.like(TicketRegistration::getPurchaseContractNumber, ticketRegistration.getPurchaseContractNumber())
- .like(TicketRegistration::getSupplierName, ticketRegistration.getSupplierName());
+ if (StringUtils.isNotBlank(ticketRegistration.getSupplierNameOrContractNo())) {
+ queryWrapper.and(wrapper -> wrapper
+ .like(TicketRegistration::getPurchaseContractNumber, ticketRegistration.getSupplierNameOrContractNo())
+ .or()
+ .like(TicketRegistration::getSupplierName, ticketRegistration.getSupplierNameOrContractNo())
+ .or()
+ .like(TicketRegistration::getSalesContractNo, ticketRegistration.getSupplierNameOrContractNo()));
}
if (!ObjectUtils.isEmpty(ticketRegistration.getIssueDateStart()) && !ObjectUtils.isEmpty(ticketRegistration.getIssueDateEnd())) {
queryWrapper.between(TicketRegistration::getIssueDate, LocalDate.parse(ticketRegistration.getIssueDateStart(), DateTimeFormatter.ofPattern("yyyy-MM-dd")), LocalDate.parse(ticketRegistration.getIssueDateEnd(), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
@@ -311,6 +366,7 @@
if (ticketRegistration.getStatus()) {
ticketRegistrationIPage.getRecords().removeIf(receiptPaymentDto1 -> new BigDecimal("0.00").equals(receiptPaymentDto1.getUnPaymentAmountTotal()));
+ ticketRegistrationIPage.setTotal(ticketRegistrationIPage.getRecords().size());
}
}
return ticketRegistrationIPage;
@@ -333,6 +389,12 @@
return purchaseLedgerDto;
}
+ @Override
+ public List<PaymentRegistrationDto> getPaymentRegistrationDtoById(Long id) {
+ List<PaymentRegistrationDto> paymentRegistrationDtos =purchaseLedgerMapper.getPaymentRegistrationDtoById(id);
+ return paymentRegistrationDtos;
+ }
+
private void handleSalesLedgerProducts(Long salesLedgerId, List<SalesLedgerProduct> products, Integer type) {
if (products == null || products.isEmpty()) {
return;
--
Gitblit v1.9.3