whycrzg
2021-02-03 f628be11a131a262855908b7815c3027d6bafb4c
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
package com.fgkj.services;
 
import com.fgkj.dto.*;
import com.fgkj.mapper.impl.Batt_attentionMapper;
import com.fgkj.mapper.impl.BatttestdatastopMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
@Service
public class Batt_attentionService {
 
    @Resource
    private Batt_attentionMapper mapper;
 
    @Resource
    private BatttestdatastopMapper battTestDataStopmapper;
    
    //添加关注
    public ServiceModel add(Batt_attention attention) {
        ServiceModel model = new ServiceModel();
        Boolean bl = null;
        try {
            bl = mapper.add(attention)>0;
        } catch (Exception e) {
            e.printStackTrace();
            model.setMsg("添加失败!");
            return model;
        }
        if (bl) {
            model.setCode(1);
            model.setMsg("添加成功!");
        } else {
            model.setMsg("添加失败!");
        }
        return model;
 
    }
 
    /*public ServiceModel update(Object obj) {
        Boolean bl = mapper.update(obj);
        if (bl) {
            model.setCode(1);
            model.setMsg("修改成功!");
        } else {
            model.setMsg("修改失败!");
        }
        return model;
    }*/
    //取消关注
    public ServiceModel delete(Batt_attention attention) {
        ServiceModel model = new ServiceModel();
        Boolean bl = mapper.del(attention)>0;
        if (bl) {
            model.setCode(1);
        }
        return model;
    }
    //根据电池组的筛选条件,查询单体的实际电压
    public ServiceModel serchByCondition(Batt_Maint_Dealarm bmd) {
        ServiceModel model = new ServiceModel();
        PageHelper.startPage(bmd.getPageBean().getPageNum(),bmd.getPageBean().getPageSize(),true);
        List<BattInf> list = mapper.serchByCondition(bmd);
        PageInfo<BattInf> pageInfo = new PageInfo<>(list);
        if(list!=null&&list.size()>0){
            for (int i=0;i<list.size();i++) {
                BattInf binf=list.get(i);
                //最近一笔的实际容量
                double realcap=battTestDataStopmapper.serchRealCapByMon_num(binf);
                binf.setMonSerStd((float) realcap);//实际容量
            }
            model.setData(pageInfo);
        }
        model.setCode(1);
        return model;
    }
     //关注之前识别是否关注过
    public ServiceModel judgeInOrNot(Batt_attention attention) {
        ServiceModel model = new ServiceModel();
        int flag = mapper.judgeInOrNot(attention);
        if (flag==1) {
 
            model.setMsg("该信息已经被关注!");
        }else{
            model.setMsg("该信息未被关注!");
        }
        model.setCode(1);
        return model;
    }
 
}