| | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> productInOutAnalysis(Integer type) { |
| | | String targetName; |
| | | // 0-原材料 1-半成品 2-成品 |
| | | Integer modelType; |
| | | if (type == 1) { |
| | | targetName = "原材料"; |
| | | modelType = 0; |
| | | } else if (type == 2) { |
| | | targetName = "成品"; |
| | | modelType = 2; |
| | | } else if (type == 3) { |
| | | targetName = "半成品"; |
| | | modelType = 1; |
| | | } else { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Product::getProductName, targetName).isNull(Product::getParentId); |
| | | Product rootCategory = productMapper.selectOne(queryWrapper); |
| | | |
| | | if (rootCategory == null) { |
| | | log.warn("未找到名称为 {} 的顶级产品分类", targetName); |
| | | return new ArrayList<>(); |
| | | } |
| | | Long rootCategoryId = rootCategory.getId(); |
| | | |
| | | LocalDate now = LocalDate.now(); |
| | | DateTimeFormatter displayDtf = DateTimeFormatter.ofPattern("M/d"); |
| | |
| | | String startDate = now.minusDays(6).toString(); |
| | | String endDate = now.toString(); |
| | | |
| | | List<Map<String, Object>> inCounts = stockInventoryMapper.selectDailyStockInCounts(rootCategoryId, startDate, |
| | | List<Map<String, Object>> inCounts = stockInventoryMapper.selectDailyStockInCounts(modelType, startDate, |
| | | endDate + " 23:59:59"); |
| | | |
| | | List<Map<String, Object>> outCounts = stockInventoryMapper.selectDailyStockOutCounts(rootCategoryId, startDate, |
| | | List<Map<String, Object>> outCounts = stockInventoryMapper.selectDailyStockOutCounts(modelType, startDate, |
| | | endDate + " 23:59:59"); |
| | | |
| | | Map<LocalDate, BigDecimal> inMap = inCounts.stream() |