| | |
| | | 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.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | 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 java.io.IOException; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private final ProductRecordMapper productRecordMapper; |
| | | |
| | | private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper; |
| | | |
| | | private final StringRedisTemplate redisTemplate; |
| | | |
| | | @Value("${file.upload-dir}") |
| | | private String uploadDir; |
| | |
| | | fileRecord.setName(originalFilename); |
| | | fileRecord.setUrl(formalFilePath.toString()); |
| | | fileRecord.setCreateTime(LocalDateTime.now()); |
| | | fileRecord.setType("2"); |
| | | fileRecord.setType(FileNameType.PURCHASE.getValue()); |
| | | commonFileMapper.insert(fileRecord); |
| | | |
| | | // 删除临时文件记录 |
| | |
| | | // 批量删除关联的采购台账产品 |
| | | LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(SalesLedgerProduct::getSalesLedgerId, ids) |
| | | .eq(SalesLedgerProduct::getType, "2"); |
| | | .eq(SalesLedgerProduct::getType, 2); |
| | | salesLedgerProductMapper.delete(queryWrapper); |
| | | // 批量删除关联的采购台账的来票登记 |
| | | LambdaQueryWrapper<TicketRegistration> ticketRegistrationLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | } |
| | | // 创建并填充DTO |
| | | PurchaseLedgerDto resultDto = new PurchaseLedgerDto(); |
| | | resultDto.setSalesLedgerId(purchaseLedger.getSalesLedgerId()); |
| | | resultDto.setSalesContractNoId(purchaseLedger.getSalesLedgerId()); |
| | | resultDto.setSalesContractNo(purchaseLedger.getSalesContractNo()); |
| | | resultDto.setSupplierName(purchaseLedger.getSupplierName()); |
| | |
| | | public PurchaseLedgerDto getPurchaseNoById(Long id) { |
| | | PurchaseLedgerDto purchaseLedgerDto = new PurchaseLedgerDto(); |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(id); |
| | | |
| | | BeanUtils.copyProperties(purchaseLedger, purchaseLedgerDto); |
| | | // TicketRegistration ticketRegistration = ticketRegistrationMapper.selectOne(new LambdaQueryWrapper<TicketRegistration>().eq(TicketRegistration::getPurchaseLedgerId, id)); |
| | | // if (ticketRegistration != null) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<PurchaseLedger> selectPurchaseLedgerListPage(IPage ipage, PurchaseLedger purchaseLedger) { |
| | | LambdaQueryWrapper<PurchaseLedger> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.isNotBlank(purchaseLedger.getPurchaseContractNumber())) { |
| | | queryWrapper.like(PurchaseLedger::getPurchaseContractNumber, purchaseLedger.getPurchaseContractNumber()); |
| | | } |
| | | return purchaseLedgerMapper.selectPage(ipage, queryWrapper); |
| | | 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.PURCHASELEDGER.getValue())); |
| | | purchaseLedgerDto.setSalesLedgerFiles(commonFiles); |
| | | }); |
| | | return purchaseLedgerDtoIPage; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return invoiceRegistrationProducts; |
| | | } |
| | | |
| | | @Override |
| | | public String getPurchaseNo() { |
| | | // 生成日期前缀(例如:CG20250405) |
| | | String purchaseNo = "CG" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | |
| | | // 构建 Redis Key(按天分隔) |
| | | String redisKey = "purchase_no:" + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE); |
| | | |
| | | // 获取当前序号并递增(原子操作) |
| | | Long sequence = redisTemplate.opsForValue().increment(redisKey); |
| | | |
| | | // 设置过期时间(次日失效,防止冗余数据) |
| | | if (sequence == 1) { |
| | | redisTemplate.expire(redisKey, 1, TimeUnit.DAYS); |
| | | } |
| | | |
| | | // 返回完整编号(如 CG202504050001) |
| | | return purchaseNo + String.format("%03d", sequence); |
| | | } |
| | | |
| | | /** |
| | | * 下划线命名转驼峰命名 |
| | | */ |