|
@@ -3,6 +3,8 @@ package com.fjhx.wms.service.monthly.impl;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
+import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.wms.entity.monthly.dto.MonthlyInventoryReportSelectDto;
|
|
|
import com.fjhx.wms.entity.monthly.po.MonthlyInventoryReport;
|
|
|
import com.fjhx.wms.entity.monthly.vo.MonthlyInventoryReportVo;
|
|
@@ -11,8 +13,10 @@ import com.fjhx.wms.entity.stock.vo.StockJournalDetailsVo;
|
|
|
import com.fjhx.wms.mapper.monthly.MonthlyInventoryReportMapper;
|
|
|
import com.fjhx.wms.service.monthly.MonthlyInventoryReportService;
|
|
|
import com.fjhx.wms.service.stock.StockService;
|
|
|
+import com.fjhx.wms.service.warehouse.WarehouseService;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -35,22 +39,55 @@ import java.util.stream.Collectors;
|
|
|
public class MonthlyInventoryReportServiceImpl extends ServiceImpl<MonthlyInventoryReportMapper, MonthlyInventoryReport> implements MonthlyInventoryReportService {
|
|
|
@Autowired
|
|
|
private StockService stockService;
|
|
|
+ @Autowired
|
|
|
+ private ProductInfoService productInfoService;
|
|
|
+ @Autowired
|
|
|
+ private WarehouseService warehouseService;
|
|
|
|
|
|
@Override
|
|
|
public Page<MonthlyInventoryReportVo> getPage(MonthlyInventoryReportSelectDto dto) {
|
|
|
IWrapper<MonthlyInventoryReport> wrapper = getWrapper();
|
|
|
+ wrapper.eq("date_format(mir.daily_report_date,'%Y')", dto.getYear());
|
|
|
+ wrapper.eq("date_format(mir.daily_report_date,'%m')", dto.getMonth());
|
|
|
+ wrapper.eq(MonthlyInventoryReport::getWarehouseId, dto.getWarehouseId());
|
|
|
+
|
|
|
+ //关键字搜索
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
|
+ List<Long> productInfoIds = productInfoService.listObject(ProductInfo::getId, q -> q
|
|
|
+ .like(ProductInfo::getCode, dto.getKeyword())
|
|
|
+ .or().like(ProductInfo::getName, dto.getKeyword())
|
|
|
+ .or().like(ProductInfo::getSpec, dto.getKeyword())
|
|
|
+ );
|
|
|
+ productInfoIds.add(null);//插入一个空元素防止为空in条件被忽略
|
|
|
+ wrapper.in(MonthlyInventoryReport::getProductId, productInfoIds);
|
|
|
+ }
|
|
|
+
|
|
|
wrapper.orderByDesc("mir", MonthlyInventoryReport::getId);
|
|
|
Page<MonthlyInventoryReportVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ List<MonthlyInventoryReportVo> records = page.getRecords();
|
|
|
+ //赋值产品名称
|
|
|
+ productInfoService.attributeAssign(records, MonthlyInventoryReportVo::getProductId, (item, productInfo) -> {
|
|
|
+ item.setProductCode(productInfo.getCode());
|
|
|
+ item.setProductName(productInfo.getName());
|
|
|
+ item.setProductSpec(productInfo.getSpec());
|
|
|
+ item.setProductUnit(productInfo.getUnit());
|
|
|
+ });
|
|
|
+ //赋值仓库名称
|
|
|
+ warehouseService.attributeAssign(records, MonthlyInventoryReportVo::getWarehouseId, (item, warehouse) -> {
|
|
|
+ item.setWarehouseName(warehouse.getName());
|
|
|
+ });
|
|
|
+
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 每月1日0点自动生成上月报表
|
|
|
+ * 每月1号的0:10:00执行自动生成上月报表
|
|
|
*/
|
|
|
+ @Scheduled(cron = "0 10 0 1 * ?")
|
|
|
public void generateReport() {
|
|
|
List<MonthlyInventoryReport> monthlyInventoryReportList = new ArrayList<>();
|
|
|
|
|
|
- //获取上月的报表获取初期数量
|
|
|
+ //获取上上月的报表的 结存数量为上月报表的初期数量
|
|
|
List<MonthlyInventoryReportVo> olDmonthlyInventoryReportList = baseMapper.getLastMonthMonthlyInventoryReport();
|
|
|
|
|
|
List<StockJournalDetailsVo> lastMonthStockJournal = baseMapper.getLastMonthStockJournal();
|
|
@@ -79,7 +116,7 @@ public class MonthlyInventoryReportServiceImpl extends ServiceImpl<MonthlyInvent
|
|
|
monthlyInventoryReport.setProductId(stock.getProductId());
|
|
|
monthlyInventoryReport.setInitialQuantity(BigDecimal.ZERO);//初期数量
|
|
|
if (ObjectUtil.isNotEmpty(initialQuantityList)) {
|
|
|
- //初期数量=上月日报 结存数量
|
|
|
+ //初期数量=上上月报表的结存数量
|
|
|
monthlyInventoryReport.setInitialQuantity(initialQuantityList.get(0).getBalanceQuantity());
|
|
|
}
|
|
|
monthlyInventoryReport.setReceiptQuantity(receiptQuantity);//入库数量
|