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 | 393 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 367 insertions(+), 26 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 ef3bc4d..8fc333d 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java
@@ -1,25 +1,56 @@
package com.ruoyi.purchase.service.impl;
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.core.toolkit.ObjectUtils;
+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.enums.SalesLedgerType;
import com.ruoyi.common.exception.base.BaseException;
+import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
-import com.ruoyi.project.system.domain.SysUser;
-import com.ruoyi.project.system.mapper.SysUserMapper;
+import com.ruoyi.other.mapper.TempFileMapper;
+import com.ruoyi.other.pojo.TempFile;
+import com.ruoyi.purchase.dto.PaymentRegistrationDto;
+import com.ruoyi.purchase.dto.PurchaseLedgerDto;
import com.ruoyi.purchase.dto.TicketRegistrationDto;
+import com.ruoyi.purchase.mapper.PaymentRegistrationMapper;
+import com.ruoyi.purchase.mapper.ProductRecordMapper;
import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
import com.ruoyi.purchase.mapper.TicketRegistrationMapper;
+import com.ruoyi.purchase.pojo.ProductRecord;
import com.ruoyi.purchase.pojo.PurchaseLedger;
import com.ruoyi.purchase.pojo.TicketRegistration;
import com.ruoyi.purchase.service.ITicketRegistrationService;
+import com.ruoyi.sales.mapper.CommonFileMapper;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
+import com.ruoyi.sales.pojo.CommonFile;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
-import lombok.AllArgsConstructor;
+import com.ruoyi.sales.service.ISalesLedgerProductService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FilenameUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.IOException;
+import java.math.BigDecimal;
+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.Arrays;
import java.util.List;
+import java.util.Map;
+import java.util.UUID;
import java.util.stream.Collectors;
/**
@@ -29,68 +60,251 @@
* @date 2025-05-13
*/
@Service
-@AllArgsConstructor
+@RequiredArgsConstructor
+@Slf4j
public class TicketRegistrationServiceImpl extends ServiceImpl<TicketRegistrationMapper, TicketRegistration> implements ITicketRegistrationService {
- private TicketRegistrationMapper ticketRegistrationMapper;
+ private final TicketRegistrationMapper ticketRegistrationMapper;
- private PurchaseLedgerMapper purchaseLedgerMapper;
+ private final PurchaseLedgerMapper purchaseLedgerMapper;
- private SalesLedgerProductMapper salesLedgerProductMapper;
+ private final SalesLedgerProductMapper salesLedgerProductMapper;
- private final SysUserMapper userMapper;
+ private final CommonFileMapper commonFileMapper;
+
+ private final TempFileMapper tempFileMapper;
+
+ private final ProductRecordMapper productRecordMapper;
+
+ @Autowired
+ private ISalesLedgerProductService salesLedgerProductService;
+
+ @Autowired
+ private PaymentRegistrationMapper paymentRegistrationMapper;
+
+ @Value("${file.upload-dir}")
+ private String uploadDir;
@Override
public List<TicketRegistration> selectTicketRegistrationList(TicketRegistration ticketRegistration) {
LambdaQueryWrapper<TicketRegistration> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(ticketRegistration.getPurchaseContractNumber())) {
- queryWrapper.like(TicketRegistration::getPurchaseContractNumber,ticketRegistration.getPurchaseContractNumber());
+ queryWrapper.like(TicketRegistration::getPurchaseContractNumber, ticketRegistration.getPurchaseContractNumber())
+ .like(TicketRegistration::getSupplierName, ticketRegistration.getSupplierName())
+ .eq(TicketRegistration::getIssueDate, ticketRegistration.getIssueDate());
}
- return ticketRegistrationMapper.selectList(queryWrapper);
+ List<TicketRegistration> ticketRegistrationList = ticketRegistrationMapper.selectList(queryWrapper);
+ // 璁$畻宸蹭粯娆鹃噾棰�
+ if (CollectionUtils.isNotEmpty(ticketRegistrationList)) {
+ List<Long> ids = ticketRegistrationList.stream().map(TicketRegistration::getId).collect(Collectors.toList());
+ List<PaymentRegistrationDto> paymentRegistrationDtoList = paymentRegistrationMapper.countPaymentTotalByTicketRegId(ids);
+ for (TicketRegistration registration : ticketRegistrationList) {
+ BigDecimal paymentAmountTotal = BigDecimal.ZERO;
+ for (PaymentRegistrationDto paymentRegistrationDto : paymentRegistrationDtoList) {
+ if (registration.getId().equals(paymentRegistrationDto.getTicketRegistrationId())) {
+ paymentAmountTotal = paymentRegistrationDto.getPaymentAmountTotal();
+ break;
+ }
+ }
+ BigDecimal invoiceAmount = registration.getInvoiceAmount();
+ BigDecimal subtractAmount = invoiceAmount.subtract(paymentAmountTotal);
+ registration.setPaymentAmountTotal(paymentAmountTotal);
+ registration.setUnPaymentAmountTotal(subtractAmount);
+ }
+ }
+
+ return ticketRegistrationList;
}
@Override
- public int addOrUpdateRegistration(TicketRegistrationDto ticketRegistrationDto) {
+ @Transactional(rollbackFor = Exception.class)
+ public int addOrUpdateRegistration(TicketRegistrationDto ticketRegistrationDto) throws IOException {
+ // 1. 鏌ヨ閲囪喘鍙拌处璁板綍
PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(ticketRegistrationDto.getPurchaseLedgerId());
- SysUser sysUser = userMapper.selectUserById(ticketRegistrationDto.getBusinessPersonId());
+ if (purchaseLedger == null) {
+ // 澶勭悊閲囪喘鍙拌处涓嶅瓨鍦ㄧ殑鎯呭喌锛屼緥濡傛姏鍑哄紓甯告垨杩斿洖閿欒
+ throw new IllegalArgumentException("閲囪喘鍙拌处璁板綍涓嶅瓨鍦紝ID: " + ticketRegistrationDto.getPurchaseLedgerId());
+ }
+
+
+
+ // 3. 鍒涘缓鎴栨洿鏂扮エ鎹櫥璁板疄浣�
TicketRegistration ticketRegistration = new TicketRegistration();
BeanUtils.copyProperties(ticketRegistrationDto, ticketRegistration);
ticketRegistration.setPurchaseContractNumber(purchaseLedger.getPurchaseContractNumber());
- ticketRegistration.setBusinessPerson(sysUser.getNickName());
ticketRegistration.setTenantId(purchaseLedger.getTenantId());
+ ticketRegistration.setIssueDate(ticketRegistrationDto.getIssueDate());
+ ticketRegistration.setContractAmount(purchaseLedger.getContractAmount());
+ ticketRegistration.setSalesLedgerId(purchaseLedger.getSalesLedgerId());
+ ticketRegistration.setEnterDate(ticketRegistrationDto.getEnterDate());
- // 澶勭悊瀛愯〃鏁版嵁
- List<SalesLedgerProduct> productData = ticketRegistrationDto.getProductData();
- if (productData != null && !productData.isEmpty()) {
+ // 4. 澶勭悊瀛愯〃鏁版嵁
+ List<SalesLedgerProduct> productData = ticketRegistrationDto.getProductData();
+ if (CollectionUtils.isNotEmpty(productData)) {
handleSalesLedgerProducts(purchaseLedger.getId(), productData, 2);
}
- // 鎵ц鎻掑叆鎴栨洿鏂版搷浣�
- if (ticketRegistrationDto.getId() == null) {
- return ticketRegistrationMapper.insert(ticketRegistration);
- } else {
- return ticketRegistrationMapper.updateById(ticketRegistration);
+ // 5. 鎵ц鎻掑叆鎴栨洿鏂版搷浣�
+ int rowsAffected = ticketRegistrationMapper.insert(ticketRegistration);
+
+ // 6. 澧炲姞閲囪喘鍙拌处浜у搧寮�绁ㄨ褰�
+ List<SalesLedgerProduct> salesLedgerProducts = ticketRegistrationDto.getProductData();
+ if (CollectionUtils.isNotEmpty(salesLedgerProducts)) {
+ int insert = 0 ;
+ for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) {
+ //鎺掗櫎鎺夊紑绁ㄤ负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锛岃妫�鏌�");
+ }
+ }
+ }
+ // 杩佺Щ涓存椂鏂囦欢鍒版寮忕洰褰�
+ if (ticketRegistrationDto.getTempFileIds() != null && !ticketRegistrationDto.getTempFileIds().isEmpty()) {
+ migrateTempFilesToFormal(ticketRegistration.getId(), ticketRegistrationDto.getTempFileIds());
+ }
+ return rowsAffected;
+ }
+
+
+ /**
+ * 灏嗕复鏃舵枃浠惰縼绉诲埌姝e紡鐩綍
+ *
+ * @param businessId 涓氬姟ID锛堥攢鍞彴璐D锛�
+ * @param tempFileIds 涓存椂鏂囦欢ID鍒楄〃
+ * @throws IOException 鏂囦欢鎿嶄綔寮傚父
+ */
+ public 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 baseName = FilenameUtils.getBaseName(originalFilename);
+ String formalFilename = businessId + "_" +
+ System.currentTimeMillis() + "_" +
+ 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.copy(Paths.get(tempFile.getTempPath()), formalFilePath, StandardCopyOption.REPLACE_EXISTING);
+ Files.deleteIfExists(Paths.get(tempFile.getTempPath()));
+ 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(4);
+ commonFileMapper.insert(fileRecord);
+
+ log.info("鏂囦欢杩佺Щ鎴愬姛: {} -> {}", tempFile.getTempPath(), formalFilePath);
+ } catch (IOException e) {
+ log.error("鏂囦欢杩佺Щ澶辫触: {}", tempFile.getTempPath(), e);
+ // 鍙�夋嫨鍥炴粴浜嬪姟鎴栬褰曞け璐ユ枃浠�
+ throw new IOException("鏂囦欢杩佺Щ寮傚父", e);
+ }
}
}
+
@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
public TicketRegistrationDto getRegistrationById(TicketRegistrationDto ticketRegistrationDto) {
TicketRegistration ticketRegistration = ticketRegistrationMapper.selectById(ticketRegistrationDto.getId());
LambdaQueryWrapper<PurchaseLedger> purchaseQueryWrapper = new LambdaQueryWrapper<>();
- purchaseQueryWrapper.eq(PurchaseLedger::getId,ticketRegistration.getPurchaseLedgerId());
+ purchaseQueryWrapper.eq(PurchaseLedger::getId, ticketRegistration.getPurchaseLedgerId());
PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(purchaseQueryWrapper);
if (ticketRegistration == null) {
throw new BaseException("閲囪喘鍙拌处涓嶅瓨鍦�");
}
// 鍒涘缓骞跺~鍏匘TO
TicketRegistrationDto resultDto = new TicketRegistrationDto();
- BeanUtils.copyProperties(ticketRegistration,resultDto);
+ BeanUtils.copyProperties(ticketRegistration, resultDto);
// 鏌ヨ骞惰缃叧鑱斾骇鍝�
LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>();
@@ -98,8 +312,87 @@
.eq(SalesLedgerProduct::getType, 2);
List<SalesLedgerProduct> productList = salesLedgerProductMapper.selectList(queryWrapper);
resultDto.setProductData(productList);
-
return resultDto;
+ }
+
+ @Override
+ public List getTicketNo(TicketRegistrationDto ticketRegistrationDto) {
+ LambdaQueryWrapper<TicketRegistration> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.select(TicketRegistration::getId, TicketRegistration::getInvoiceNumber, TicketRegistration::getInvoiceAmount)
+ .eq(TicketRegistration::getPurchaseLedgerId, ticketRegistrationDto.getId());
+ List<Map<String, Object>> result = ticketRegistrationMapper.selectMaps(queryWrapper);
+ // 灏嗕笅鍒掔嚎鍛藉悕杞崲涓洪┘宄板懡鍚�
+ return result.stream().map(map -> map.entrySet().stream()
+ .collect(Collectors.toMap(
+ entry -> underlineToCamel(entry.getKey()),
+ Map.Entry::getValue))
+ ).collect(Collectors.toList());
+ }
+
+ @Override
+ public IPage<TicketRegistration> selectTicketRegistrationListPage(Page page, TicketRegistration ticketRegistration) {
+ LambdaQueryWrapper<TicketRegistration> queryWrapper = new LambdaQueryWrapper<>();
+ 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")));
+ }
+ IPage<TicketRegistration> ticketRegistrationIPage = ticketRegistrationMapper.selectPage(page, queryWrapper);
+ // 璁$畻宸蹭粯娆鹃噾棰�
+ if (CollectionUtils.isNotEmpty(ticketRegistrationIPage.getRecords())) {
+ List<Long> ids = ticketRegistrationIPage.getRecords().stream().map(TicketRegistration::getId).collect(Collectors.toList());
+ List<PaymentRegistrationDto> paymentRegistrationDtoList = paymentRegistrationMapper.countPaymentTotalByTicketRegId(ids);
+ for (TicketRegistration registration : ticketRegistrationIPage.getRecords()) {
+ BigDecimal paymentAmountTotal = BigDecimal.ZERO;
+ for (PaymentRegistrationDto paymentRegistrationDto : paymentRegistrationDtoList) {
+ if (registration.getId().equals(paymentRegistrationDto.getTicketRegistrationId())) {
+ paymentAmountTotal = paymentRegistrationDto.getPaymentAmountTotal();
+ break;
+ }
+ }
+ BigDecimal invoiceAmount = registration.getInvoiceAmount();
+ BigDecimal subtractAmount = invoiceAmount.subtract(paymentAmountTotal);
+ registration.setPaymentAmountTotal(paymentAmountTotal);
+ registration.setUnPaymentAmountTotal(subtractAmount);
+ }
+ }
+ if (!ObjectUtils.isEmpty(ticketRegistration.getStatus())) {
+
+ if (ticketRegistration.getStatus()) {
+ ticketRegistrationIPage.getRecords().removeIf(receiptPaymentDto1 -> new BigDecimal("0.00").equals(receiptPaymentDto1.getUnPaymentAmountTotal()));
+ ticketRegistrationIPage.setTotal(ticketRegistrationIPage.getRecords().size());
+ }
+ }
+ return ticketRegistrationIPage;
+ }
+
+ @Override
+ public PurchaseLedgerDto getPuargeById(Long id) {
+ PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(id);
+ PurchaseLedgerDto purchaseLedgerDto = new PurchaseLedgerDto();
+ BeanUtils.copyProperties(purchaseLedger, purchaseLedgerDto);
+ SalesLedgerProduct salesLedgerProduct = new SalesLedgerProduct();
+ salesLedgerProduct.setSalesLedgerId(id);
+ salesLedgerProduct.setType(SalesLedgerType.SALES_LEDGER_TYPE_SALES_LEDGER.getValue());
+ List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct);
+ purchaseLedgerDto.setProductData(salesLedgerProducts);
+ List<CommonFile> commonFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>()
+ .eq(CommonFile::getType, FileNameType.PURCHASELEDGER.getValue())
+ .eq(CommonFile::getCommonId, id));
+ purchaseLedgerDto.setSalesLedgerFiles(commonFiles);
+ 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) {
@@ -114,14 +407,62 @@
p.setSalesLedgerId(salesLedgerId);
p.setType(type);
})
- .collect(Collectors.toList()); // Java 8 鍏煎鍐欐硶
+ .collect(Collectors.toList());
// 鎵归噺鏇存柊锛堥渶瑕� MyBatis 鎻愪緵鎵归噺鏇存柊鏂规硶锛�
if (!updateList.isEmpty()) {
updateList.forEach(product -> {
+ // 闈炵┖鏍¢獙锛屼换涓�瀛楁涓虹┖鍒欐姏鍑哄紓甯�
+ if (product.getQuantity() == null) {
+ throw new BaseException("鏁伴噺涓嶈兘涓虹┖");
+ }
+ if (product.getTicketsNum() == null) {
+ throw new BaseException("宸插紑绁ㄦ暟閲忎笉鑳戒负绌�");
+ }
+ if (product.getTaxInclusiveTotalPrice() == null) {
+ throw new BaseException("鍚◣鎬讳环涓嶈兘涓虹┖");
+ }
+ if (product.getTicketsAmount() == null) {
+ throw new BaseException("鏈鏉ョエ閲戦(鍏�)涓嶈兘涓虹┖");
+ }
+
+ // 璁$畻 futureTickets锛堢洿鎺ヤ娇鐢� BigDecimal 璁$畻锛岄伩鍏嶇簿搴︿涪澶憋級
+// product.setFutureTickets(
+// product.getQuantity()
+// .subtract(product.getTicketsNum())
+// );
+
+
+ // 璁$畻 futureTicketsAmount
+// product.setFutureTicketsAmount(
+// product.getTaxInclusiveTotalPrice()
+// .subtract(product.getTicketsAmount())
+// );
product.setType(type);
salesLedgerProductMapper.updateById(product);
});
}
}
+
+ /**
+ * 涓嬪垝绾垮懡鍚嶈浆椹煎嘲鍛藉悕
+ */
+ private String underlineToCamel(String param) {
+ if (param == null || "".equals(param.trim())) {
+ return "";
+ }
+ int len = param.length();
+ StringBuilder sb = new StringBuilder(len);
+ for (int i = 0; i < len; i++) {
+ char c = param.charAt(i);
+ if (c == '_') {
+ if (++i < len) {
+ sb.append(Character.toUpperCase(param.charAt(i)));
+ }
+ } else {
+ sb.append(Character.toLowerCase(c));
+ }
+ }
+ return sb.toString();
+ }
}
--
Gitblit v1.9.3