CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package com.ld.igds.pest.view;
 
import java.util.*;
 
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.models.Gas;
import com.ld.igds.models.Pest;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import com.bstek.bdf2.core.model.DefaultDept;
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.data.provider.Page;
import com.ld.igds.pest.dto.PestData;
import com.ld.igds.pest.service.HPestDataService;
import com.ld.igds.sys.service.SysDeptService;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
 
/**
 * 
 * @author: andy.jia
 * @description: 
 * @version: 
 * @data:2020年1月16日
 *
 */
@Component
public class PestDataPR {
    
    @Autowired
    private HPestDataService pestDataService;
    
    @Autowired
    private SysDeptService sysDeptService;
    
    /**
     * pestDataPR#getQuery 根据报表类型,获取默认查询信息,比如表头信息等
     * 
     * @param type
     * @return
     */
    @DataProvider
    public Map<String, Object> getQuery(String type) {
        Map<String, Object> result = new HashMap<String, Object>();
 
        DefaultDept subDept = sysDeptService.getSubDept(null,null);
        result.put("title", "虫害检测数据");
        if (null != subDept) {
            result.put("title", subDept.getName() + "虫害检测数据");
            result.put("deptId", subDept.getId());
        }
 
        result.put("end", new Date());
        Date start = DateUtil.getNewByDay(new Date(), -90);
        result.put("start", start);
 
        result.put("timeDesc",
                DateFormatUtils.format(start, "yyyy-MM-dd") + "   截至:"
                        + DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
        
        result.put("createUser", ContextUtil.getLoginUserCName());
        return result;
    }
    
    /**
     * pestDataPR#getDataReport
     * 根据条件分页获取虫害数据信息
     * @param page
     * @param parameter
     * @throws Exception
     */
    @DataProvider
    public void getDataReport(Page<PestData> page,Map<String,Object> parameter)throws Exception{
        pestDataService.getDataReport(page,parameter);
    }
 
    /**
     * pestDataPR#getData
     * 根据条件分页获取虫害数据信息
     * @param page
     * @param parameter
     * @throws Exception
     */
    @DataProvider
    public void getData(Page<PestData> page,Map<String,Object> parameter)throws Exception{
        pestDataService.getData(page,parameter);
    }
 
 
    /**
     * 检查虫害方法
     * ${dorado.getDataProvider("pestDataPR#triggerMethod").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerMethod() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
 
        list.add(new DicTrigger("0", "粮堆扦样"));
        list.add(new DicTrigger("1", "墙面粮面检查"));
 
        return list;
    }
 
    /**
     * 虫害等级判定
     * ${dorado.getDataProvider("pestDataPR#triggerPestLevel").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerPestLevel() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
 
        list.add(new DicTrigger("531", "基本无虫粮"));
        list.add(new DicTrigger("532", "一般虫粮"));
        list.add(new DicTrigger("533", "严重虫粮"));
        list.add(new DicTrigger("534", "危险虫粮"));
 
        return list;
    }
 
    /**
     * pestDataPR#pageData
     *
     * @param page
     * @param param
     * @throws Exception
     */
    @DataProvider
    public void pageData(Page<Pest> page, Map<String, Object> param)
            throws Exception {
        pestDataService.pageData(page, param);
    }
 
    /**
     * pestDataPR#saveData
     *
     * @param data
     */
    @DataResolver
    public void saveData(Pest data) {
        pestDataService.saveData(data);
    }
 
    /**
     * pestDataPR#delData
     *
     * @param data
     * @return
     */
    @Expose
    public String delData(Pest data) {
        return pestDataService.delData(data);
    }
}