xuhy
2025-04-23 3061eb22795185ab14925e1f38f4a4b34f51025f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.ruoyi.admin.large.service.impl;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.admin.large.mapper.AnalysisRecycleDataMapper;
import com.ruoyi.admin.large.model.AnalysisRecycleData;
import com.ruoyi.admin.large.model.vo.RecycleLargeVO;
import com.ruoyi.admin.large.service.AnalysisRecycleDataService;
import com.ruoyi.common.core.utils.DateUtils;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Service;
 
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaochen
 * @since 2025-04-21
 */
@Service
public class AnalysisRecycleDataServiceImpl extends ServiceImpl<AnalysisRecycleDataMapper, AnalysisRecycleData> implements AnalysisRecycleDataService {
 
 
    @Override
    public Map<String,Long> recycleLarge(Integer analysisType) {
        Map<String,Long> map = new HashMap<>();
        if (analysisType == 1) {
            // 年份
            int year = LocalDateTime.now().getYear();
            long count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, year));
            map.put(String.valueOf(year),count);
            year = LocalDateTime.now().minusYears(1).getYear();
            count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, year));
            map.put(String.valueOf(year),count);
            year = LocalDateTime.now().minusYears(2).getYear();
            count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, year));
            map.put(String.valueOf(year),count);
            year = LocalDateTime.now().minusYears(3).getYear();
            count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, year));
            map.put(String.valueOf(year),count);
            year = LocalDateTime.now().minusYears(4).getYear();
            count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, year));
            map.put(String.valueOf(year),count);
            year = LocalDateTime.now().minusYears(5).getYear();
            count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, year));
            map.put(String.valueOf(year),count);
            return map;
        } else{
            // 月份
            String month = new SimpleDateFormat("yyyy-MM").format(new Date());
            long count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, month));
            map.put(month,count);
            month = new SimpleDateFormat("yyyy-MM").format(DateUtils.localDateTimeToDate(LocalDateTime.now().minusMonths(1)));
            count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, month));
            map.put(month,count);
            month = new SimpleDateFormat("yyyy-MM").format(DateUtils.localDateTimeToDate(LocalDateTime.now().minusMonths(2)));
            count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, month));
            map.put(month,count);
            month = new SimpleDateFormat("yyyy-MM").format(DateUtils.localDateTimeToDate(LocalDateTime.now().minusMonths(3)));
            count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, month));
            map.put(month,count);
            month = new SimpleDateFormat("yyyy-MM").format(DateUtils.localDateTimeToDate(LocalDateTime.now().minusMonths(4)));
            count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, month));
            map.put(month,count);
            month = new SimpleDateFormat("yyyy-MM").format(DateUtils.localDateTimeToDate(LocalDateTime.now().minusMonths(5)));
            count = this.count(Wrappers.lambdaQuery(AnalysisRecycleData.class).eq(AnalysisRecycleData::getAnalysisValue, month));
            map.put(month,count);
            return map;
        }
    }
 
}