whyclj
2020-07-22 a5729100cb1eaa3584b3a194e46e1b8b52b3ed1a
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
package com.fgkj.services;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
import com.fgkj.actions.ActionUtil;
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.BaseDAOFactory;
import com.fgkj.dto.Batt_history;
import com.fgkj.dto.ServiceModel;
 
public class Batt_historyService {
    private BaseDAO dao;
    private ServiceModel model;
    
    public Batt_historyService() {
        super();
        this.dao=BaseDAOFactory.getBaseDAO(BaseDAO.BATT_HISTORY);
        this.model=new ServiceModel();
    }
    //查询所有的历史实时数据
    public ServiceModel searchAll(){
        List<Batt_history> list=dao.searchAll();
        /*for (Batt_history batt : list) {
            System.out.println(ActionUtil.getDateMonth(batt.getRec_datetime()));
        }*/
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }        
        return model;
    }
    //查询所有的历史实时数据
    public ServiceModel serchByCondition(Object obj){
        List list=dao.serchByCondition(obj);
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
            model.setMsg("查询成功!");
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }        
        return model;
    }
    public static void main(String[] args) throws ParseException {
         Batt_historyService hservice=new Batt_historyService();
         Batt_history bh=new Batt_history();
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date date1 = sdf.parse("2018-01-01 00:00:00");
         Date date2 = sdf.parse("2018-01-03 23:59:59");
         bh.setRec_datetime(new Date());
         bh.setDev_id(910000001);
         bh.setBattGroupId(1005058);
         bh.setRec_datetime(ActionUtil.getSimpDate(date1));
         bh.setRec_datetime1(ActionUtil.getSimpDate(date2));
         System.out.println(bh);
         ServiceModel model=hservice.serchByCondition(bh);
         System.out.println(model.getData());
         //hservice.searchAll();
    }
}