master:档口销售出库下载功能完善;

pull/1121/head
liujiang 2025-07-09 23:20:10 +08:00
parent 8807c870a8
commit cd0ae25ec1
3 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package com.ruoyi.web.controller.xkt.vo.storeSale;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -25,7 +26,9 @@ public class StoreSaleExportVO {
@ApiModelProperty(value = "storeSaleIdList")
private List<Long> storeSaleIdList;
@ApiModelProperty(value = "导出开始时间")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date voucherDateStart;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "导出结束时间")
private Date voucherDateEnd;

View File

@ -1,5 +1,6 @@
package com.ruoyi.xkt.dto.storeSale;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -33,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
@ -218,6 +219,16 @@ public class StoreSaleServiceImpl implements IStoreSaleService {
if (ObjectUtils.isEmpty(exportDTO.getVoucherDateStart()) && ObjectUtils.isEmpty(exportDTO.getVoucherDateEnd())) {
throw new ServiceException("全量导出时,开始时间和结束时间不能为空!", HttpStatus.ERROR);
}
// 开始时间和结束时间相间隔不能超过6个月
LocalDate start = exportDTO.getVoucherDateStart().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate end = exportDTO.getVoucherDateEnd().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 计算两个日期之间的年、月、日差值
Period period = Period.between(start, end);
// 如果总月数超过6个月则返回 true
int totalMonths = period.getYears() * 12 + period.getMonths();
if (Math.abs(totalMonths) > 6) {
throw new ServiceException("导出时间间隔不能超过6个月!", HttpStatus.ERROR);
}
return this.storeSaleMapper.selectExportListVoucherDateBetween(exportDTO.getVoucherDateStart(), exportDTO.getVoucherDateEnd());
}
}