zhitong.yu
2024-10-11 4f58a93c95ff123d51adcb8fa2e521333e8ab022
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.hxzk.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxzk.mapper.HeartDao;
import com.hxzk.pojo.TbAchor;
import com.hxzk.pojo.TbHeartRecord;
import com.hxzk.pojo.TbHistoryinwarning;
import com.hxzk.service.HeartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
@Service
public class HeartServiceImpl extends ServiceImpl<HeartDao, TbHeartRecord> implements HeartService {
 
    @Autowired
    HeartDao heartDao;
    @Override
    public PageInfo<TbHeartRecord> findAll(Integer page, Integer limit) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        PageHelper.startPage(page,limit);
        queryWrapper.orderByDesc("time");
        List<TbHeartRecord> cardList = baseMapper.selectList(queryWrapper);
        PageInfo<TbHeartRecord> info = new PageInfo<>(cardList);
        return info;
    }
 
    @Override
    public PageInfo<TbHeartRecord> findSearch(Integer page, Integer limit, TbHeartRecord achor) {
        QueryWrapper<TbHeartRecord> queryWrapper = new QueryWrapper<>();
        PageHelper.startPage(page,limit);
        queryWrapper.like("tagid",achor.getTagid()).or().eq("name",achor.getTagid());
        queryWrapper.orderByDesc("time");
        List<TbHeartRecord> cardList = baseMapper.selectList(queryWrapper);
        PageInfo<TbHeartRecord> info = new PageInfo<>(cardList);
        return info;
    }
 
    @Override
    public void deleteanchor(Integer id) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);
        baseMapper.delete(queryWrapper);
    }
 
    @Override
    public List FindHeartZongCount() {
        List list = new ArrayList<>();
        list.add(heartDao.findChaoGao());
        list.add(heartDao.findChaoDi());
        list.add(heartDao.findZengChang());
        return list;
    }
 
    @Override
    public List<TbHeartRecord> FindTopCount() {
        TbHeartRecord chaogao1 = heartDao.findChaoGaoYi();
        if (chaogao1 != null){
            Integer chaogao1s = heartDao.findChaoGaoYis(chaogao1.getName());
            chaogao1.setHeart(String.valueOf(chaogao1s));
            chaogao1.setOkheart(heartDao.GuoQuDay(chaogao1.getName()));
            chaogao1.setState(heartDao.GuoQuYue(chaogao1.getName()));
        }
 
        TbHeartRecord chaogao2 = heartDao.findChaoGaoEr();
        if (chaogao2!=null){
            Integer chaogao2s = heartDao.findChaoGaoErs(chaogao2.getName());
            chaogao2.setHeart(String.valueOf(chaogao2s));
            chaogao2.setOkheart(heartDao.GuoQuDay(chaogao2.getName()));
            chaogao2.setState(heartDao.GuoQuYue(chaogao2.getName()));
        }
 
        //已获取前两位
        TbHeartRecord chaodi1 = heartDao.findChaoDiYi();
        if (chaodi1!=null){
            Integer chaodi1s = heartDao.findChaoDiYis(chaodi1.getName());
            chaodi1.setHeart(String.valueOf(chaodi1s));
            chaodi1.setOkheart(heartDao.GuoQuDay(chaodi1.getName()));
            chaodi1.setState(heartDao.GuoQuYue(chaodi1.getName()));
        }
 
        TbHeartRecord chaodi2 = heartDao.findChaoDiEr();
        if (chaodi2!=null){
            Integer chaodi2s = heartDao.findChaoDiErs(chaodi2.getName());
            chaodi2.setHeart(String.valueOf(chaodi2s));
            chaodi2.setOkheart(heartDao.GuoQuDay(chaodi2.getName()));
            chaodi2.setState(heartDao.GuoQuYue(chaodi2.getName()));
        }
 
        //后两位
 
        List<TbHeartRecord> heartRecords = new ArrayList<>();
        heartRecords.add(chaogao1);
        heartRecords.add(chaogao2);
        heartRecords.add(chaodi1);
        heartRecords.add(chaodi2);
 
        return heartRecords;
    }
}