add
gdg
2021-01-08 0745b70a0368c06670ed327300231b453ee47289
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
package com.nanometer.smartlab.controller;
 
 
import com.nanometer.smartlab.entity.HazardousWaste;
import com.nanometer.smartlab.service.HazardousWasteService;
import org.apache.log4j.Logger;
import org.primefaces.model.LazyDataModel;
import org.primefaces.model.SortOrder;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
 
@Controller
@Scope("session")
public class HazardousWasteController extends BaseController{
 
    private static Logger logger = Logger.getLogger(HazardousWasteController.class);
 
    private LazyDataModel<HazardousWaste> dataModel;
 
    private Date startTime;
    private Date endTime;
 
    private boolean isSearch;
 
    @Resource
    private HazardousWasteService hazardousWasteService;
 
    public LazyDataModel<HazardousWaste> getDataModel() {
        if (this.dataModel == null) {
            this.dataModel = new LazyDataModel<HazardousWaste>() {
 
                public List<HazardousWaste> load
                        (int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
 
                    List<HazardousWaste> list = null;
                    try {
                        int pageCount = hazardousWasteService.countAll(startTime,endTime);
 
                        this.setRowCount(pageCount);
                        if (pageCount > 0)
                            list = hazardousWasteService.selectAll(startTime,endTime, isSearch ? 0 : first, pageSize);
                        //查询更换模式
                        if (isSearch) {
                            isSearch = false;
                        }
 
                    } catch (Exception e) {
                        logger.error("error occured.", e);
                    }
                    return list;
                }
 
                @Override
                public HazardousWaste getRowData(String rowKey) {
                    Iterator<HazardousWaste> iterator = this.iterator();
                    HazardousWaste su = null;
                    while (iterator.hasNext()) {
                        su = iterator.next();
                        if ( su.getId().equals(Long.parseLong(rowKey))) {
                            return su;
                        }
                    }
                    return null;
                }
            };
        }
        return dataModel;
    }
 
    public void modelChange() {
        this.isSearch = true;
    }
 
 
 
    public void setDataModel(LazyDataModel<HazardousWaste> dataModel) {
        this.dataModel = dataModel;
    }
 
    public Date getStartTime() {
        return startTime;
    }
 
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
 
    public Date getEndTime() {
        return endTime;
    }
 
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
 
    public boolean isSearch() {
        return isSearch;
    }
 
    public void setSearch(boolean search) {
        isSearch = search;
    }
}