whycrzh
2021-01-23 452d29df782fb1a91ce16d565fcb6e5cccadb82e
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package com.fgkj.services;
 
import com.fgkj.dto.BattInf;
import com.fgkj.dto.Batt_Devdischarge;
import com.fgkj.dto.Batt_Devdischarge_all;
import com.fgkj.dto.ServiceModel;
import com.fgkj.mapper.impl.Batt_DevdischargeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
import javax.annotation.Resource;
@Service
public class Batt_DevdischargeService {
 
 
    @Resource
    private Batt_DevdischargeMapper mapper;;
 
    public ServiceModel add(Batt_Devdischarge bd){
    ServiceModel model = new ServiceModel();
        Boolean bl=mapper.add(bd)>0;
        if(bl){
            model.setCode(1);
            model.setMsg("添加成功!");
        }else{
            model.setCode(0);
            model.setMsg("添加失败!");
        }
        return model;
    }
    public ServiceModel update(Batt_Devdischarge obj){
        ServiceModel model = new ServiceModel();
        Boolean bl=mapper.update(obj)>0;
        if(bl){
            model.setCode(1);
            model.setMsg("修改成功!");
        }else{
            model.setCode(0);
            model.setMsg("修改失败!");
        }
        return model;
    }
    public ServiceModel del(Batt_Devdischarge obj){
        ServiceModel model = new ServiceModel();
        Boolean bl=mapper.del(obj)>0;
        if(bl){
            model.setCode(1);
            model.setMsg("删除成功!");
        }else{
            model.setCode(0);
            model.setMsg("删除失败!");
        }
        return model;
    }
    public ServiceModel searchAll(){
        ServiceModel model = new ServiceModel();
        List list=mapper.searchAll();
        if(list!=null&&list.size()>0){
            model.setCode(1);
            model.setMsg("查询成功!");
            model.setData(list);
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
    //10.1根据设备id连battinf和batt_devdischarge表
    /*
     * 记录时间放在battinf的battproducer
     * MonCount:当前页
     * MonNum :页面的大小
     */
    public ServiceModel serchByCondition(BattInf obj){
        ServiceModel model = new ServiceModel();
        BattInf binf=(BattInf) obj;
        binf.setNum(0);
        binf.setMonCount(0);
        binf.setMonNum(0);
        List<Batt_Devdischarge> listN=mapper.serchMaxAndMinNum(binf);
        if(listN!=null&&listN.size()>0){
            float number=listN.get(listN.size()-1).getDev_curr();
            float maxnum=listN.get(listN.size()-1).getDev_power();
            float minnum=listN.get(listN.size()-1).getDev_vol();
            binf.setNum((int) number);
            binf.setMonCount((int) maxnum);
            binf.setMonNum((int) minnum);
        }//LIMIT 1 只有一条数据
        List<Batt_Devdischarge_all> list=mapper.serchByCondition(binf);
        //System.out.println(list.size());
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setMsg("查询成功!");
            model.setData(list);
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        //System.out.println(model);
        return model;
    }
 
    /*public static void main(String[] args) throws ParseException {
        Batt_DevdischargeService bservice=new Batt_DevdischargeService();
        Batt_DevdischargeImpl bimpl=new Batt_DevdischargeImpl();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = sdf.parse("2000-01-01");
        Date date2 = sdf.parse("2020-01-01");
        BattInf binf=new BattInf();
        binf.setStationName("");
        binf.setStationName1("");
        binf.setStationId("42070450");
        binf.setMonCount(1);
        binf.setMonNum(100);
        binf.setBattProductDate(ActionUtil.getSimpDate(date1));
        binf.setBattProductDate1(ActionUtil.getSimpDate(date2));
        bservice.serchByCondition(binf);
    }*/
}