| | |
| | | package com.ruoyi.sales.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.pojo.AccountIncome; |
| | | import com.ruoyi.account.service.AccountIncomeService; |
| | | import com.ruoyi.basic.mapper.CustomerMapper; |
| | | import com.ruoyi.basic.mapper.ProductMapper; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.pojo.Product; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.other.mapper.TempFileMapper; |
| | | import com.ruoyi.other.pojo.TempFile; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.pojo.*; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | |
| | | |
| | | private final ShippingInfoServiceImpl shippingInfoServiceImpl; |
| | | |
| | | private final CommonFileServiceImpl commonFileService; |
| | | |
| | | private final ShippingInfoMapper shippingInfoMapper; |
| | | |
| | | private final InvoiceLedgerMapper invoiceLedgerMapper; |
| | |
| | | private ProductMapper productMapper; |
| | | @Autowired |
| | | private ProductStructureMapper productStructureMapper; |
| | | ; |
| | | |
| | | @Override |
| | | public List<SalesLedger> selectSalesLedgerList(SalesLedgerDto salesLedgerDto) { |
| | |
| | | |
| | | @Override |
| | | public List<MonthlyAmountDto> getAmountHalfYear(Integer type) { |
| | | |
| | | LocalDate now = LocalDate.now(); |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | |
| | | // 根据 type 确定查询的时间间隔(天数)和总查询天数 |
| | | int daysPerPeriod; |
| | | int totalDays; |
| | | switch (type) { |
| | | case 1: |
| | | daysPerPeriod = 5; // 每5天查一次 |
| | | totalDays = 30; // 6次 × 5天 = 30天 |
| | | break; |
| | | case 2: |
| | | daysPerPeriod = 15; // 每15天查一次 |
| | | totalDays = 90; // 6次 × 15天 = 90天 |
| | | break; |
| | | case 3: |
| | | daysPerPeriod = 30; // 每30天查一次 |
| | | totalDays = 180; // 6次 × 30天 = 180天 |
| | | break; |
| | | default: |
| | | throw new IllegalArgumentException("Invalid type value: " + type); |
| | | } |
| | | |
| | | List<MonthlyAmountDto> result = new ArrayList<>(); |
| | | |
| | | // 循环6次,每次查询一个时间段的数据 |
| | | for (int i = 0; i < 6; i++) { |
| | | // 计算当前时间段的起始和结束时间 |
| | | LocalDateTime endTime = currentDateTime.minusDays(i * daysPerPeriod); |
| | | LocalDateTime startTime = endTime.minusDays(daysPerPeriod); |
| | | for (int i = 5; i >= 0; i--) { |
| | | YearMonth yearMonth = YearMonth.from(now.minusMonths(i)); |
| | | LocalDateTime startTime = yearMonth.atDay(1).atStartOfDay(); |
| | | LocalDateTime endTime = yearMonth.atEndOfMonth().atTime(23, 59, 59); |
| | | |
| | | // 查询回款金额 |
| | | // 回款金额 |
| | | LambdaQueryWrapper<ReceiptPayment> receiptPaymentQuery = new LambdaQueryWrapper<>(); |
| | | receiptPaymentQuery |
| | | .ge(ReceiptPayment::getCreateTime, startTime) |
| | | .lt(ReceiptPayment::getCreateTime, endTime); |
| | | List<ReceiptPayment> receiptPayments = receiptPaymentMapper.selectList(receiptPaymentQuery); |
| | | .le(ReceiptPayment::getCreateTime, endTime); |
| | | |
| | | // 查询开票金额 |
| | | LambdaQueryWrapper<InvoiceLedger> invoiceLedgerQuery = new LambdaQueryWrapper<>(); |
| | | invoiceLedgerQuery |
| | | .ge(InvoiceLedger::getCreateTime, startTime) |
| | | .lt(InvoiceLedger::getCreateTime, endTime); |
| | | List<InvoiceLedger> invoiceLedgers = invoiceLedgerMapper.selectList(invoiceLedgerQuery); |
| | | List<ReceiptPayment> receiptPayments = |
| | | receiptPaymentMapper.selectList(receiptPaymentQuery); |
| | | |
| | | // 计算回款总额 |
| | | BigDecimal receiptAmount = receiptPayments.stream() |
| | | .map(ReceiptPayment::getReceiptPaymentAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | // 计算开票总额 |
| | | // 开票金额 |
| | | LambdaQueryWrapper<InvoiceLedger> invoiceLedgerQuery = new LambdaQueryWrapper<>(); |
| | | invoiceLedgerQuery |
| | | .ge(InvoiceLedger::getCreateTime, startTime) |
| | | .le(InvoiceLedger::getCreateTime, endTime); |
| | | |
| | | List<InvoiceLedger> invoiceLedgers = |
| | | invoiceLedgerMapper.selectList(invoiceLedgerQuery); |
| | | |
| | | BigDecimal invoiceAmount = invoiceLedgers.stream() |
| | | .map(InvoiceLedger::getInvoiceTotal) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | // 构造返回的 DTO |
| | | MonthlyAmountDto dto = new MonthlyAmountDto(); |
| | | dto.setMonth(startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " ~ " + |
| | | endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | dto.setMonth(yearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"))); |
| | | dto.setReceiptAmount(receiptAmount); |
| | | dto.setInvoiceAmount(invoiceAmount); |
| | | |
| | | result.add(dto); |
| | | } |
| | | |
| | | // 反转列表,使时间顺序从早到晚 |
| | | Collections.reverse(result); |
| | | return result; |
| | | } |
| | | |
| | |
| | | List<SysUser> sysUsers = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().in(SysUser::getNickName, |
| | | salesLedgerImportDtoList.stream().map(SalesLedgerImportDto::getEntryPerson).collect(Collectors.toList()))); |
| | | for (SalesLedgerImportDto salesLedgerImportDto : salesLedgerImportDtoList) { |
| | | SalesLedger salesLedger1 = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>() |
| | | .eq(SalesLedger::getSalesContractNo, salesLedgerImportDto.getSalesContractNo()) |
| | | .last("LIMIT 1")); |
| | | if(salesLedger1 != null){ |
| | | continue; |
| | | } |
| | | SalesLedger salesLedger = new SalesLedger(); |
| | | BeanUtils.copyProperties(salesLedgerImportDto, salesLedger); |
| | | salesLedger.setExecutionDate(DateUtils.toLocalDate(salesLedgerImportDto.getExecutionDate())); |
| | |
| | | if(CollectionUtils.isNotEmpty(shippingInfos)){ |
| | | shippingInfoServiceImpl.delete(shippingInfos.stream().map(ShippingInfo::getId).collect(Collectors.toList())); |
| | | } |
| | | // 删除附件表 |
| | | commonFileService.deleteByBusinessIds(idList, FileNameType.SALE.getValue()); |
| | | |
| | | // 删除生产管控数据 |
| | | // 删除生产订单数据 |