| | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.constant.OrderNumConstants; |
| | | import com.ruoyi.common.utils.CodeGenerateUtils; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.system.domain.TOrderSaleGoods; |
| | | import com.ruoyi.system.domain.TOrderStock; |
| | | import com.ruoyi.system.domain.TOrderStockGoods; |
| | | import com.ruoyi.system.dto.TOrderSaleDTO; |
| | | import com.ruoyi.system.dto.TOrderStockDTO; |
| | | import com.ruoyi.system.mapper.TOrderStockMapper; |
| | | import com.ruoyi.system.query.TDataGeneratorQuery; |
| | | import com.ruoyi.system.query.TDataGeneratorStockQuery; |
| | | import com.ruoyi.system.query.TOrderStockQuery; |
| | | import com.ruoyi.system.service.TOrderStockGoodsService; |
| | | import com.ruoyi.system.service.TOrderStockService; |
| | | import com.ruoyi.system.vo.TDataGeneratorVO; |
| | | import com.ruoyi.system.vo.TOrderStockVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | switch (query.getTimeType()){ |
| | | case 1: |
| | | // 今日 |
| | | startTime = LocalDateTime.MIN; |
| | | endTime = LocalDateTime.MAX; |
| | | startTime = DateUtils.getDayStart(LocalDateTime.now()); |
| | | endTime = DateUtils.getDayEnd(LocalDateTime.now()); |
| | | break; |
| | | case 2: |
| | | // 昨日 |
| | | startTime = LocalDateTime.now().minusDays(1); |
| | | endTime = LocalDateTime.now().minusDays(1); |
| | | startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1)); |
| | | endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1)); |
| | | break; |
| | | case 3: |
| | | // 近7天 |
| | | startTime = LocalDateTime.now().minusDays(7); |
| | | endTime = LocalDateTime.now(); |
| | | startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7)); |
| | | endTime = DateUtils.getDayEnd(LocalDateTime.now()); |
| | | break; |
| | | case 4: |
| | | // 近30天 |
| | | startTime = LocalDateTime.now().minusDays(30); |
| | | endTime = LocalDateTime.now(); |
| | | startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30)); |
| | | endTime = DateUtils.getDayEnd(LocalDateTime.now()); |
| | | break; |
| | | } |
| | | query.setStartTime(startTime); |
| | | query.setEndTime(endTime); |
| | | query.setStartTime(DateUtils.localDateTimeToDate(startTime)); |
| | | query.setEndTime(DateUtils.localDateTimeToDate(endTime)); |
| | | } |
| | | PageInfo<TOrderStockVO> pageInfo = new PageInfo<>(query.getPageNum(),query.getPageSize()); |
| | | List<TOrderStockVO> list = this.baseMapper.pageList(query,pageInfo); |
| | |
| | | if(!CollectionUtils.isEmpty(orderIds)){ |
| | | List<TOrderStockGoods> orderStockGoods = tOrderStockGoodsService.list(Wrappers.lambdaQuery(TOrderStockGoods.class) |
| | | .in(TOrderStockGoods::getOrderId, orderIds)); |
| | | list.forEach(orderSale -> { |
| | | List<TOrderStockGoods> collect = orderStockGoods.stream().filter(orderSaleGoods -> orderSaleGoods.getOrderId().equals(orderSale.getId())).collect(Collectors.toList()); |
| | | list.forEach(orderStockVO -> { |
| | | List<TOrderStockGoods> collect = orderStockGoods.stream().filter(orderSaleGoods -> orderSaleGoods.getOrderId().equals(orderStockVO.getId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(collect)){ |
| | | orderSale.setOrderStockGoods(collect); |
| | | orderSale.setTotalPrice(collect.stream().map(TOrderStockGoods::getCostPrice).reduce(BigDecimal::add).get()); |
| | | orderStockVO.setOrderStockGoods(collect); |
| | | orderStockVO.setOrderStockCount(collect.size()); |
| | | orderStockVO.setTotalPrice(collect.stream().map(TOrderStockGoods::getCostPrice).reduce(BigDecimal::add).get()); |
| | | } |
| | | }); |
| | | } |
| | |
| | | switch (query.getTimeType()){ |
| | | case 1: |
| | | // 今日 |
| | | startTime = LocalDateTime.MIN; |
| | | endTime = LocalDateTime.MAX; |
| | | startTime = DateUtils.getDayStart(LocalDateTime.now()); |
| | | endTime = DateUtils.getDayEnd(LocalDateTime.now()); |
| | | break; |
| | | case 2: |
| | | // 昨日 |
| | | startTime = LocalDateTime.now().minusDays(1); |
| | | endTime = LocalDateTime.now().minusDays(1); |
| | | startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(1)); |
| | | endTime = DateUtils.getDayEnd(LocalDateTime.now().minusDays(1)); |
| | | break; |
| | | case 3: |
| | | // 近7天 |
| | | startTime = LocalDateTime.now().minusDays(7); |
| | | endTime = LocalDateTime.now(); |
| | | startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(7)); |
| | | endTime = DateUtils.getDayEnd(LocalDateTime.now()); |
| | | break; |
| | | case 4: |
| | | // 近30天 |
| | | startTime = LocalDateTime.now().minusDays(30); |
| | | endTime = LocalDateTime.now(); |
| | | startTime = DateUtils.getDayStart(LocalDateTime.now().minusDays(30)); |
| | | endTime = DateUtils.getDayEnd(LocalDateTime.now()); |
| | | break; |
| | | } |
| | | query.setStartTime(startTime); |
| | | query.setEndTime(endTime); |
| | | query.setStartTime(DateUtils.localDateTimeToDate(startTime)); |
| | | query.setEndTime(DateUtils.localDateTimeToDate(endTime)); |
| | | } |
| | | List<TOrderStockVO> list = this.baseMapper.stockGeneratorExport(query); |
| | | // 查询商品 |