From 49133ae6eafda4d6bd86ed9a9241177a12a47348 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期二, 26 五月 2026 16:07:30 +0800
Subject: [PATCH] Merge branch 'dev_New_pro' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_New_pro
---
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java | 332 +++++++++++++++++--------------------------------------
1 files changed, 102 insertions(+), 230 deletions(-)
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
index a7d5765..6008e69 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -1,36 +1,33 @@
package com.ruoyi.purchase.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.account.pojo.AccountExpense;
-import com.ruoyi.account.pojo.AccountIncome;
-import com.ruoyi.account.service.AccountExpenseService;
-import com.ruoyi.account.service.AccountIncomeService;
+import com.ruoyi.approve.bean.dto.ApprovalInstanceDto;
+import com.ruoyi.approve.mapper.ApprovalTemplateMapper;
+import com.ruoyi.approve.pojo.ApprovalTemplate;
import com.ruoyi.approve.pojo.ApproveProcess;
+import com.ruoyi.approve.service.ApprovalInstanceService;
import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl;
-import com.ruoyi.approve.vo.ApproveProcessVO;
+import com.ruoyi.basic.enums.ApplicationTypeEnum;
+import com.ruoyi.basic.enums.RecordTypeEnum;
import com.ruoyi.basic.mapper.ProductMapper;
import com.ruoyi.basic.mapper.ProductModelMapper;
import com.ruoyi.basic.mapper.SupplierManageMapper;
-import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.basic.pojo.Product;
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.basic.pojo.SupplierManage;
-import com.ruoyi.common.enums.FileNameType;
+import com.ruoyi.basic.utils.FileUtil;
import com.ruoyi.common.exception.base.BaseException;
-import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.other.mapper.TempFileMapper;
-import com.ruoyi.other.pojo.TempFile;
import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper;
import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage;
import com.ruoyi.project.system.domain.SysUser;
@@ -38,36 +35,34 @@
import com.ruoyi.purchase.dto.PurchaseLedgerDto;
import com.ruoyi.purchase.dto.PurchaseLedgerImportDto;
import com.ruoyi.purchase.dto.PurchaseLedgerProductImportDto;
-import com.ruoyi.purchase.mapper.*;
-import com.ruoyi.purchase.pojo.*;
+import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
+import com.ruoyi.purchase.pojo.PurchaseLedger;
import com.ruoyi.purchase.service.IPurchaseLedgerService;
-import com.ruoyi.quality.mapper.*;
-import com.ruoyi.quality.pojo.*;
-import com.ruoyi.sales.dto.SalesLedgerImportDto;
-import com.ruoyi.sales.dto.SalesLedgerProductImportDto;
-import com.ruoyi.sales.mapper.*;
-import com.ruoyi.sales.pojo.CommonFile;
-import com.ruoyi.sales.pojo.InvoiceRegistrationProduct;
+import com.ruoyi.quality.mapper.QualityInspectMapper;
+import com.ruoyi.quality.mapper.QualityInspectParamMapper;
+import com.ruoyi.quality.mapper.QualityTestStandardMapper;
+import com.ruoyi.quality.mapper.QualityTestStandardParamMapper;
+import com.ruoyi.quality.pojo.QualityInspect;
+import com.ruoyi.quality.pojo.QualityInspectParam;
+import com.ruoyi.quality.pojo.QualityTestStandard;
+import com.ruoyi.quality.pojo.QualityTestStandardParam;
+import com.ruoyi.sales.mapper.CommonFileMapper;
+import com.ruoyi.sales.mapper.SalesLedgerMapper;
+import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.pojo.SalesLedger;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import com.ruoyi.sales.service.impl.CommonFileServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
-import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
-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.ZoneId;
@@ -83,53 +78,31 @@
* @date 2025-05-09
*/
@Service
-@RequiredArgsConstructor
@Slf4j
+@RequiredArgsConstructor
public class PurchaseLedgerServiceImpl extends ServiceImpl<PurchaseLedgerMapper, PurchaseLedger> implements IPurchaseLedgerService {
- private final AccountExpenseService accountExpenseService;
- private final PurchaseLedgerMapper purchaseLedgerMapper;
+ private final PurchaseLedgerMapper purchaseLedgerMapper;
private final SalesLedgerMapper salesLedgerMapper;
private final SalesLedgerProductMapper salesLedgerProductMapper;
-
private final SysUserMapper userMapper;
-
private final TempFileMapper tempFileMapper;
-
private final CommonFileMapper commonFileMapper;
-
private final SupplierManageMapper supplierManageMapper;
-
private final ProductMapper productMapper;
-
private final ProductModelMapper productModelMapper;
-
private final SysUserMapper sysUserMapper;
-
- private final TicketRegistrationMapper ticketRegistrationMapper;
-
- private final ProductRecordMapper productRecordMapper;
-
- private final PaymentRegistrationMapper paymentRegistrationMapper;
-
- private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
-
private final StringRedisTemplate redisTemplate;
private final QualityInspectMapper qualityInspectMapper;
- private final QualityTestStandardBindingMapper qualityTestStandardBindingMapper;
+ private final CommonFileServiceImpl commonFileService;
private final QualityTestStandardParamMapper qualityTestStandardParamMapper;
private final QualityTestStandardMapper qualityTestStandardMapper;
private final QualityInspectParamMapper qualityInspectParamMapper;
-
private final ApproveProcessServiceImpl approveProcessService;
-
private final ProcurementRecordMapper procurementRecordStorageMapper;
-
- private final PurchaseLedgerTemplateMapper purchaseLedgerTemplateMapper;
-
- private final SalesLedgerProductTemplateMapper salesLedgerProductTemplateMapper;
- @Value("${file.upload-dir}")
- private String uploadDir;
+ private final FileUtil fileUtil;
+ private final ApprovalInstanceService approvalInstanceService;
+ private final ApprovalTemplateMapper approvalTemplateMapper;
@Override
public List<PurchaseLedger> selectPurchaseLedgerList(PurchaseLedger purchaseLedger) {
@@ -137,22 +110,35 @@
if (StringUtils.isNotBlank(purchaseLedger.getPurchaseContractNumber())) {
queryWrapper.like(PurchaseLedger::getPurchaseContractNumber, purchaseLedger.getPurchaseContractNumber());
}
+ if(purchaseLedger.getSupplierId()!=null){
+ queryWrapper.eq(PurchaseLedger::getSupplierId, purchaseLedger.getSupplierId());
+ }
+ if (purchaseLedger.getApprovalStatus() != null) {
+ queryWrapper.eq(PurchaseLedger::getApprovalStatus, purchaseLedger.getApprovalStatus());
+ }
return purchaseLedgerMapper.selectList(queryWrapper);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int addOrEditPurchase(PurchaseLedgerDto purchaseLedgerDto) throws Exception {
-
+ PurchaseLedger purchaseLedger = new PurchaseLedger();
+ // DTO杞珽ntity
+ BeanUtils.copyProperties(purchaseLedgerDto, purchaseLedger);
SalesLedger salesLedger = salesLedgerMapper.selectById(purchaseLedgerDto.getSalesLedgerId());
//褰曞叆浜�
SysUser sysUser = userMapper.selectUserById(purchaseLedgerDto.getRecorderId());
+ if (ObjectUtils.isNotEmpty(sysUser)) {
+ purchaseLedger.setRecorderName(sysUser.getNickName());
+ purchaseLedger.setPhoneNumber(sysUser.getPhonenumber());
+ }else {
+ purchaseLedger.setRecorderName(SecurityUtils.getLoginUser().getNickName());
+ SysUser sysUser1 = userMapper.selectUserById(SecurityUtils.getUserId());
+ purchaseLedger.setPhoneNumber(sysUser1.getPhonenumber());
+ }
SupplierManage supplierManage = supplierManageMapper.selectById(purchaseLedgerDto.getSupplierId());
- // DTO杞珽ntity
- PurchaseLedger purchaseLedger = new PurchaseLedger();
- BeanUtils.copyProperties(purchaseLedgerDto, purchaseLedger);
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtils.isNotEmpty(loginUser) && null != loginUser.getTenantId()) {
purchaseLedger.setTenantId(loginUser.getTenantId());
@@ -161,8 +147,7 @@
purchaseLedger.setSalesLedgerId(ObjectUtils.isNotEmpty(salesLedger) ? salesLedger.getId() : -1);
purchaseLedger.setSupplierName(supplierManage.getSupplierName());
purchaseLedger.setRecorderId(purchaseLedgerDto.getRecorderId());
- purchaseLedger.setRecorderName(sysUser.getNickName());
- purchaseLedger.setPhoneNumber(sysUser.getPhonenumber());
+
purchaseLedger.setApprovalStatus(1);
// 3. 鏂板鎴栨洿鏂颁富琛�
if (purchaseLedger.getId() == null) {
@@ -179,31 +164,21 @@
}
purchaseLedgerMapper.updateById(purchaseLedger);
}
- // 6.閲囪喘瀹℃牳鏂板
- addApproveByPurchase(loginUser, purchaseLedger);
// 4. 澶勭悊瀛愯〃鏁版嵁
List<SalesLedgerProduct> productList = purchaseLedgerDto.getProductData();
if (productList != null && !productList.isEmpty()) {
handleSalesLedgerProducts(purchaseLedger.getId(), productList, purchaseLedgerDto.getType());
}
- //鏂板鍘熸潗鏂欐楠�
- if (productList != null) {
- for (SalesLedgerProduct saleProduct : productList) {
- //鏄惁鎺ㄩ�佽川妫�锛屽鏋渢rue灏辨坊鍔�
- if (saleProduct.getIsChecked()) {
- addQualityInspect(purchaseLedger, saleProduct);
- }
- }
- }
+ // 6.閲囪喘瀹℃牳鏂板锛涘鎵圭鐞嗘湭閰嶇疆閲囪喘瀹℃壒浜烘椂锛屽鎵规湇鍔′細鑷姩缃负瀹℃壒閫氳繃銆�
+ addApproveByPurchase(loginUser, purchaseLedger);
// 5. 杩佺Щ涓存椂鏂囦欢鍒版寮忕洰褰�
- if (purchaseLedgerDto.getTempFileIds() != null && !purchaseLedgerDto.getTempFileIds().isEmpty()) {
- migrateTempFilesToFormal(purchaseLedger.getId(), purchaseLedgerDto.getTempFileIds());
- }
+ fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.PURCHASE_LEDGER, purchaseLedger.getId(), purchaseLedgerDto.getStorageBlobDTOS());
return 1;
}
- private void addQualityInspect(PurchaseLedger purchaseLedger, SalesLedgerProduct saleProduct) {
+
+ public void addQualityInspect(PurchaseLedger purchaseLedger, SalesLedgerProduct saleProduct) {
QualityInspect qualityInspect = new QualityInspect();
qualityInspect.setInspectType(0);
qualityInspect.setSupplier(purchaseLedger.getSupplierName());
@@ -235,6 +210,7 @@
if (products == null || products.isEmpty()) {
throw new BaseException("浜у搧淇℃伅涓嶅瓨鍦�");
}
+ Integer ledgerType = type == null ? 2 : type;
// 鎻愬墠鏀堕泦鎵�鏈夐渶瑕佹煡璇㈢殑ID
Set<Long> productIds = products.stream()
@@ -286,21 +262,18 @@
// 鎵ц鏇存柊鎿嶄綔
if (!updateList.isEmpty()) {
for (SalesLedgerProduct product : updateList) {
- product.setType(type);
+ product.setType(ledgerType);
salesLedgerProductMapper.updateById(product);
}
}
// 鎵ц鎻掑叆鎿嶄綔
if (!insertList.isEmpty()) {
for (SalesLedgerProduct salesLedgerProduct : insertList) {
- salesLedgerProduct.setType(type);
+ salesLedgerProduct.setType(ledgerType);
Date entryDate = purchaseLedger.getEntryDate();
LocalDateTime localDateTime = entryDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
salesLedgerProduct.setRegisterDate(localDateTime);
- salesLedgerProduct.setFutureTickets(salesLedgerProduct.getQuantity());
- salesLedgerProduct.setFutureTicketsAmount(salesLedgerProduct.getTaxInclusiveTotalPrice());
- salesLedgerProduct.setPendingTicketsTotal(salesLedgerProduct.getTaxInclusiveTotalPrice());
salesLedgerProductMapper.insert(salesLedgerProduct);
}
}
@@ -318,85 +291,17 @@
}
}
- /**
- * 灏嗕复鏃舵枃浠惰縼绉诲埌姝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) +
- (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(FileNameType.PURCHASE.getValue());
- commonFileMapper.insert(fileRecord);
-
- // 鍒犻櫎涓存椂鏂囦欢璁板綍
- tempFileMapper.deleteById(tempFile);
-
- log.info("鏂囦欢杩佺Щ鎴愬姛: {} -> {}", tempFile.getTempPath(), formalFilePath);
- } catch (IOException e) {
- log.error("鏂囦欢杩佺Щ澶辫触: {}", tempFile.getTempPath(), e);
- // 鍙�夋嫨鍥炴粴浜嬪姟鎴栬褰曞け璐ユ枃浠�
- throw new IOException("鏂囦欢杩佺Щ寮傚父", e);
- }
- }
- }
-
@Override
@Transactional(rollbackFor = Exception.class)
public int deletePurchaseLedgerByIds(Long[] ids) {
if (ids == null || ids.length == 0) {
throw new BaseException("璇烽�変腑鑷冲皯涓�鏉℃暟鎹�");
+ }
+ for (Long id : ids) {
+ PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(id);
+ if (purchaseLedger.getApprovalStatus().equals(3)) {
+ throw new BaseException(purchaseLedger.getPurchaseContractNumber()+"宸茬粡瀹℃壒閫氳繃锛屼笉鍏佽鍒犻櫎");
+ }
}
// 鎵归噺鍒犻櫎鍏宠仈鐨勯噰璐叆搴撹褰�
LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductQueryWrapper = new LambdaQueryWrapper<>();
@@ -416,21 +321,10 @@
queryWrapper.in(SalesLedgerProduct::getSalesLedgerId, ids)
.eq(SalesLedgerProduct::getType, 2);
salesLedgerProductMapper.delete(queryWrapper);
- // 鎵归噺鍒犻櫎鍏宠仈鐨勯噰璐彴璐︾殑鏉ョエ鐧昏
- LambdaQueryWrapper<TicketRegistration> ticketRegistrationLambdaQueryWrapper = new LambdaQueryWrapper<>();
- ticketRegistrationLambdaQueryWrapper.in(TicketRegistration::getPurchaseLedgerId,ids);
- ticketRegistrationMapper.delete(ticketRegistrationLambdaQueryWrapper);
- // 鎵归噺鍒犻櫎鍏宠仈鐨勯噰璐彴璐︾殑鏉ョエ鐧昏璁板綍
- LambdaQueryWrapper<ProductRecord> productRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
- productRecordLambdaQueryWrapper.in(ProductRecord::getPurchaseLedgerId,ids);
- productRecordMapper.delete(productRecordLambdaQueryWrapper);
- // 鎵归噺鍒犻櫎浠樻鐧昏
- LambdaQueryWrapper<PaymentRegistration> paymentRegistrationLambdaQueryWrapper = new LambdaQueryWrapper<>();
- paymentRegistrationLambdaQueryWrapper.in(PaymentRegistration::getPurchaseLedgerId, ids);
- paymentRegistrationMapper.delete(paymentRegistrationLambdaQueryWrapper);
//鎵归噺鍒犻櫎妫�楠屾爣鍑�
LambdaQueryWrapper<QualityInspect> materialInspectLambdaQueryWrapper = new LambdaQueryWrapper<>();
materialInspectLambdaQueryWrapper.in(QualityInspect::getPurchaseLedgerId, ids);
+
List<QualityInspect> qualityInspects = qualityInspectMapper.selectList(materialInspectLambdaQueryWrapper);
qualityInspects.stream().forEach(qualityInspect -> {
if (ObjectUtils.isNotEmpty(qualityInspect.getInspectState())&&qualityInspect.getInspectState().equals(1)) {
@@ -462,6 +356,8 @@
}
//鎵归噺鍒犻櫎鍘熸潗鏂欐楠屾暟鎹�
qualityInspectMapper.delete(materialInspectLambdaQueryWrapper);
+ //鍒犻櫎闄勪欢
+ commonFileService.deleteByBusinessIds(Arrays.asList(ids), 2);
// 鎵归噺鍒犻櫎閲囪喘鍙拌处
return purchaseLedgerMapper.deleteBatchIds(Arrays.asList(ids));
}
@@ -480,11 +376,6 @@
.eq(SalesLedgerProduct::getType, purchaseLedgerDto.getType());
List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(productWrapper);
- // 3.鏌ヨ涓婁紶鏂囦欢
- LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>();
- salesLedgerFileWrapper.eq(CommonFile::getCommonId, purchaseLedger.getId())
- .eq(CommonFile::getType,FileNameType.PURCHASE.getValue());
- List<CommonFile> salesLedgerFiles = commonFileMapper.selectList(salesLedgerFileWrapper);
// 4. 杞崲 DTO
PurchaseLedgerDto resultDto = new PurchaseLedgerDto();
@@ -492,7 +383,7 @@
if (!products.isEmpty()) {
resultDto.setHasChildren(true);
resultDto.setProductData(products);
- resultDto.setSalesLedgerFiles(salesLedgerFiles);
+ resultDto.setStorageBlobVOS(fileUtil.getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum.FILE, RecordTypeEnum.PURCHASE_LEDGER, purchaseLedger.getId()));
}
return resultDto;
}
@@ -532,14 +423,6 @@
queryWrapper.eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedger.getId())
.eq(SalesLedgerProduct::getType, 2);
List<SalesLedgerProduct> productList = salesLedgerProductMapper.selectList(queryWrapper);
- productList.forEach(product -> {
- product.setFutureTickets(product.getFutureTickets() != null ? product.getFutureTickets() : product.getQuantity());
- product.setFutureTicketsAmount(product.getFutureTicketsAmount() != null ? product.getFutureTicketsAmount() : product.getTaxInclusiveTotalPrice());
- product.setTicketsNum(null);
- product.setTicketsAmount(null);
- product.setTempFutureTickets(product.getFutureTickets());
- product.setTempFutureTicketsAmount(product.getFutureTicketsAmount());
- });
resultDto.setProductData(productList);
return resultDto;
}
@@ -566,44 +449,22 @@
PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(id);
BeanUtils.copyProperties(purchaseLedger, purchaseLedgerDto);
-// TicketRegistration ticketRegistration = ticketRegistrationMapper.selectOne(new LambdaQueryWrapper<TicketRegistration>().eq(TicketRegistration::getPurchaseLedgerId, id));
-// if (ticketRegistration != null) {
-// purchaseLedgerDto.setInvoiceNumber(ticketRegistration.getInvoiceNumber());
-// purchaseLedgerDto.setInvoiceAmount(ticketRegistration.getInvoiceAmount());
-// purchaseLedgerDto.setTicketRegistrationId(ticketRegistration.getId());
-// }
return purchaseLedgerDto;
}
@Override
public IPage<PurchaseLedgerDto> selectPurchaseLedgerListPage(IPage ipage, PurchaseLedgerDto purchaseLedger) {
- IPage<PurchaseLedgerDto> purchaseLedgerDtoIPage = purchaseLedgerMapper.selectPurchaseLedgerListPage(ipage, purchaseLedger);
- purchaseLedgerDtoIPage.getRecords().forEach(purchaseLedgerDto -> {
- List<CommonFile> commonFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>().eq(CommonFile::getCommonId, purchaseLedgerDto.getId()).eq(CommonFile::getType, FileNameType.PURCHASE.getValue()));
- purchaseLedgerDto.setSalesLedgerFiles(commonFiles);
- });
- return purchaseLedgerDtoIPage;
+ return purchaseLedgerMapper.selectPurchaseLedgerListPage(ipage, purchaseLedger);
}
@Override
- public List<InvoiceRegistrationProduct> getProductBySalesNo(Long id) {
- List<InvoiceRegistrationProduct> invoiceRegistrationProducts = invoiceRegistrationProductMapper.selectList(new LambdaQueryWrapper<InvoiceRegistrationProduct>()
- .select(InvoiceRegistrationProduct::getId, InvoiceRegistrationProduct::getProductCategory, InvoiceRegistrationProduct::getSpecificationModel,
- InvoiceRegistrationProduct::getUnit, InvoiceRegistrationProduct::getQuantity)
- .eq(InvoiceRegistrationProduct::getSalesLedgerId, id));
- if (invoiceRegistrationProducts.isEmpty()) {
- return new ArrayList<>();
- }
- return invoiceRegistrationProducts;
- }
-
- @Override
- public String getPurchaseNo() {
+ public String getPurchaseNo(Date entryDate) {
+ LocalDate localDate = entryDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 鐢熸垚鏃ユ湡鍓嶇紑锛堜緥濡傦細CG20250405锛�
- String purchaseNo = "CG" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
+ String purchaseNo = "CG" + localDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
// 鏋勫缓 Redis Key锛堟寜澶╁垎闅旓級
- String redisKey = "purchase_no:" + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
+ String redisKey = "purchase_no:" + localDate.format(DateTimeFormatter.ISO_LOCAL_DATE);
// 鑾峰彇褰撳墠搴忓彿骞堕�掑锛堝師瀛愭搷浣滐級
Long sequence = redisTemplate.opsForValue().increment(redisKey);
@@ -639,6 +500,12 @@
List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().in(SysUser::getNickName,
salesLedgerImportDtoList.stream().map(PurchaseLedgerImportDto::getRecorderName).collect(Collectors.toList())));
for (PurchaseLedgerImportDto salesLedgerImportDto : salesLedgerImportDtoList) {
+ PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>()
+ .eq(PurchaseLedger::getPurchaseContractNumber, salesLedgerImportDto.getPurchaseContractNumber())
+ .last("limit 1"));
+ if(purchaseLedger != null){
+ continue;
+ }
PurchaseLedger salesLedger = new PurchaseLedger();
BeanUtils.copyProperties(salesLedgerImportDto, salesLedger);
// 閫氳繃渚涘簲鍟嗗悕绉版煡璇D
@@ -671,20 +538,21 @@
if(salesLedger1 != null){
salesLedger.setSalesLedgerId(salesLedger1.getId());
}
- // 閲囪喘瀹℃牳
- // 閫氳繃鏄电О鑾峰彇鐢ㄦ埛ID
- String[] split = salesLedger.getApproveUserIds().split("锛�");
- List<Long> ids = new ArrayList<>();
- for (int i = 0; i < split.length; i++) {
- SysUser sysUser = sysUserMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getNickName, split[i])
- .last("LIMIT 1"));
- if (sysUser != null) {
- ids.add(sysUser.getUserId());
+ if (StringUtils.hasText(salesLedger.getApproveUserIds())) {
+ // 閲囪喘瀹℃牳锛氬巻鍙插鍏ユā鏉夸紶瀹℃壒浜哄鍚嶆椂锛岀户缁吋瀹硅浆鎹负鐢ㄦ埛ID銆�
+ String[] split = salesLedger.getApproveUserIds().split("锛�");
+ List<Long> ids = new ArrayList<>();
+ for (int i = 0; i < split.length; i++) {
+ SysUser sysUser = sysUserMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getNickName, split[i])
+ .last("LIMIT 1"));
+ if (sysUser != null) {
+ ids.add(sysUser.getUserId());
+ }
}
+ // 灏嗛泦鍚堣浆涓哄瓧绗︿覆锛岄殧寮�
+ String collect = ids.stream().map(Object::toString).collect(Collectors.joining(","));
+ salesLedger.setApproveUserIds(collect);
}
- // 灏嗛泦鍚堣浆涓哄瓧绗︿覆锛岄殧寮�
- String collect = ids.stream().map(Object::toString).collect(Collectors.joining(","));
- salesLedger.setApproveUserIds(collect);
purchaseLedgerMapper.insert(salesLedger);
for (PurchaseLedgerProductImportDto salesLedgerProductImportDto : salesLedgerProductImportDtos) {
@@ -694,8 +562,6 @@
salesLedgerProduct.setType(2);
// 璁$畻涓嶅惈绋庢�讳环
salesLedgerProduct.setTaxExclusiveTotalPrice(salesLedgerProduct.getTaxInclusiveTotalPrice().divide(new BigDecimal(1).add(salesLedgerProduct.getTaxRate().divide(new BigDecimal(100))), 2, RoundingMode.HALF_UP));
- salesLedgerProduct.setFutureTickets(salesLedgerProduct.getQuantity());
- salesLedgerProduct.setFutureTicketsAmount(salesLedgerProduct.getTaxExclusiveTotalPrice());
list.stream()
.filter(map -> map.get("productName").equals(salesLedgerProduct.getProductCategory()) && map.get("model").equals(salesLedgerProduct.getSpecificationModel()))
.findFirst()
@@ -706,7 +572,6 @@
salesLedgerProduct.setRegister(loginUser.getNickName());
salesLedgerProduct.setRegisterDate(LocalDateTime.now());
salesLedgerProduct.setApproveStatus(0);
- salesLedgerProduct.setPendingTicketsTotal(salesLedgerProductImportDto.getTaxInclusiveTotalPrice());
// 鏄惁璐ㄦ鍒ゆ柇
salesLedgerProduct.setIsChecked(salesLedgerProductImportDto.getIsChecked() == 1);
if(salesLedgerProductImportDto.getIsChecked() == 1){
@@ -752,14 +617,21 @@
}
public void addApproveByPurchase(LoginUser loginUser,PurchaseLedger purchaseLedger) throws Exception {
- ApproveProcessVO approveProcessVO = new ApproveProcessVO();
- approveProcessVO.setApproveType(5);
- approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
- approveProcessVO.setApproveReason(purchaseLedger.getPurchaseContractNumber());
- approveProcessVO.setApproveUserIds(purchaseLedger.getApproveUserIds());
- approveProcessVO.setApproveUser(loginUser.getUserId());
- approveProcessVO.setApproveTime(LocalDate.now().toString());
- approveProcessService.addApprove(approveProcessVO);
+ if (loginUser == null) {
+ return;
+ }
+ ApprovalInstanceDto approvalInstance = new ApprovalInstanceDto();
+ approvalInstance.setTemplateId(approvalTemplateMapper.selectOne(new LambdaQueryWrapper<ApprovalTemplate>().eq(ApprovalTemplate::getBusinessType,5L).orderByDesc(ApprovalTemplate::getId).last("LIMIT 1")).getId());
+ approvalInstance.setTemplateName(approvalTemplateMapper.selectOne(new LambdaQueryWrapper<ApprovalTemplate>().eq(ApprovalTemplate::getBusinessType,5L).orderByDesc(ApprovalTemplate::getId).last("LIMIT 1")).getTemplateName());
+ approvalInstance.setBusinessId(purchaseLedger.getId());
+ approvalInstance.setBusinessType(5L);
+ approvalInstance.setCurrentLevel(1);
+ approvalInstance.setApplicantId(loginUser.getUserId());
+ approvalInstance.setTitle(purchaseLedger.getPurchaseContractNumber()+"瀹℃壒");
+ approvalInstance.setApplicantName(loginUser.getNickName());
+ approvalInstance.setApplyTime(LocalDateTime.now());
+ approvalInstanceService.add(approvalInstance);
+
}
/**
--
Gitblit v1.9.3