智慧农业后台管理
guoshilong
2022-08-01 08afeadee3b2a73266a0a43c899f86cd474a274d
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
82
83
84
package org.springblade.modules.traceability.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.traceability.dto.SweepRecordDTO;
import org.springblade.modules.traceability.entity.SweepRecord;
import org.springblade.modules.traceability.mapper.SweepRecordMapper;
import org.springblade.modules.traceability.service.SweepRecordService;
import org.springblade.modules.traceability.vo.SweepRecordVO;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
/**
 * 溯源码扫描记录表服务实现类
 * @since 2022-05-19
 * @author zhongrj
 */
@Service
public class SweepRecordServiceImpl extends ServiceImpl<SweepRecordMapper, SweepRecord> implements SweepRecordService {
 
    /**
     * 自定义分页
     *
     * @param page
     * @param sweepRecord
     * @return
     */
    @Override
    public IPage<SweepRecordVO> selectSweepRecordPage(IPage<SweepRecordVO> page, SweepRecordVO sweepRecord) {
        return page.setRecords(baseMapper.selectSweepRecordPage(page, sweepRecord));
    }
 
    /**
     * 获取扫描次数统计数据
     * @param sweepRecord
     * @return
     */
    @Override
    public SweepRecordDTO getSweepRecordStatistics(SweepRecordVO sweepRecord) {
        List<Integer> statistics = baseMapper.getSweepRecordStatistics(sweepRecord);
        //数据装换
        SweepRecordDTO dto = new SweepRecordDTO();
        dto.setTodayNum(statistics.get(0));
        dto.setYesterdayNum(statistics.get(1));
        dto.setThisWeekNum(statistics.get(2));
        dto.setLastWeekNum(statistics.get(3));
        dto.setThisMonthNum(statistics.get(4));
        dto.setLastMonthNum(statistics.get(5));
        //返回
        return dto;
    }
 
    /**
     * 获取扫描次数统计数据(日,月,年统计)
     * @param sweepRecord
     * @return
     */
    @Override
    public Object getSweepRecordStatisticsByDayOrMonthOrYear(SweepRecordVO sweepRecord) {
        //按年统计
        if (sweepRecord.getTime().length()==4){
            return baseMapper.getSweepRecordStatisticsByYear(sweepRecord);
        }
        //按月统计
        if (sweepRecord.getTime().length()==7){
            return baseMapper.getSweepRecordStatisticsByMonth(sweepRecord);
        }
        //按日统计
        if (sweepRecord.getTime().length()==10){
            return baseMapper.getSweepRecordStatisticsByDay(sweepRecord);
        }
        return null;
    }
 
    /**
     * 累计扫描统计
     * @param sweepRecord
     * @return
     */
    @Override
    public Object getSweepRecordStatisticCount(SweepRecordVO sweepRecord) {
        return baseMapper.getSweepRecordStatisticCount(sweepRecord);
    }
}