jiazx0107@163.com
2023-08-18 3db8bf552742aaa707b381c1ae2b38f9d830a021
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package com.ld.igds.gas.controller;
 
import com.bstek.bdf2.core.business.IUser;
import com.bstek.bdf2.core.model.DefaultDept;
import com.ld.igds.common.manager.CommonManager;
import com.ld.igds.constant.BizType;
import com.ld.igds.constant.Constant;
import com.ld.igds.data.ConfigGasImg;
import com.ld.igds.data.PageResponse;
import com.ld.igds.gas.dto.GasData;
import com.ld.igds.gas.dto.GasParam;
import com.ld.igds.gas.manager.GasManager;
import com.ld.igds.io.response.GasResponse;
import com.ld.igds.models.Depot;
import com.ld.igds.models.DepotConf;
import com.ld.igds.util.ContextUtil;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
 
import java.util.*;
 
/**
 * 气体模块控制层,当前层只定义入口,业务逻辑在Manager中实现
 */
@RestController
@RequestMapping("basic/gas")
public class GasController {
 
    @Autowired
    private CommonManager commonManager;
    @Autowired
    private GasManager gasManager;
    @Autowired
    private ConfigGasImg gasImg;
 
    /**
     * 页面控制
     *
     * @param depotId
     * @return
     */
    @RequestMapping("/view-check")
    public ModelAndView viewCheck(
            @RequestParam(value = "depotId", required = false) String depotId,
            @RequestParam(value = "deptId", required = false) String deptId) {
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        if (StringUtils.isEmpty(deptId)) {
            deptId = ContextUtil.subDeptId(user);
        }
 
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listDepot(deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
 
        view.addObject("bizType", BizType.GAS.getCode());
        //获取当前用户所在的分库名称
        DefaultDept dept = commonManager.getSubDept(user, deptId);
        view.addObject("dept", dept);
 
        // 每个仓库正面和背面图片
        view.addObject("gasImgMap", gasImg.getGasImg(listDepot, deptId));
 
        if (StringUtils.isEmpty(deptId)) {
            deptId = ContextUtil.subDeptId(user);
        }
        view.addObject("deptId", deptId);
 
        view.setViewName("admin/gas/gas-check");
        return view;
    }
 
    /**
     * 实际使用页面
     *
     * @param
     * @return
     */
    @RequestMapping("/gas-line")
    public ModelAndView gasLine() {
        ModelAndView view = new ModelAndView();
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listDepot(null);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
        view.addObject(Constant.MODEL_KEY_BIZ_TYPE, BizType.GAS.getCode());
 
        view.setViewName("admin/gas/gas-line");
        return view;
    }
 
    /**
     * 获取默认列表
     *
     * @param param
     * @return
     */
    @RequestMapping("/list-data")
    public PageResponse<List<GasData>> queryListPest(@RequestBody GasParam param) {
        return gasManager.queryListPest(param);
    }
 
    /**
     * 获取气体配置信息
     *
     * @param param
     * @return
     */
    @RequestMapping("/gas-conf")
    public PageResponse<DepotConf> gasConf(@RequestBody GasParam param) {
        return gasManager.gasConf(param);
    }
 
    /**
     * 页面控制--手动通风页面
     *
     * @param depotId
     * @return
     */
    @RequestMapping("/new-gas")
    public ModelAndView newGas(
            @RequestParam(value = "depotId", required = false) String depotId) {
        ModelAndView view = new ModelAndView();
 
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listDepot(null);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
 
        view.addObject("bizType", BizType.GAS.getCode());
 
        view.setViewName("admin/gas/newGas");
        return view;
    }
 
    /**
     * @return
     */
    @RequestMapping(value = "/flush-gas")
    public @ResponseBody
    PageResponse<GasData> flushGas(@RequestBody GasParam param) {
        return gasManager.flushGas(param);
    }
 
 
    /**
     * 获取当前仓库最新的气体信息
     *
     * @return
     */
    @RequestMapping(value = "/flush-gas-depot")
    public @ResponseBody
    PageResponse<GasData> flushGasByDepot(@RequestBody GasParam param) {
        if (null == param.getDeptId()) {
            param.setDeptId(ContextUtil.subDeptId(null));
        }
        if (StringUtils.isEmpty(param.getCompanyId())) {
            param.setCompanyId(ContextUtil.getCompanyId());
        }
 
        param.setTagPressure(true);
        return gasManager.flushGasByDepot(param);
    }
 
    /**
     * 粮情检测-单仓检测
     *
     * @param param
     * @return
     */
    @RequestMapping("/check-single")
    public @ResponseBody
    GasResponse checkSingle(@RequestBody GasParam param) {
        return gasManager.checkGas(param);
    }
 
    /**
     * 选择采集点检测
     *
     * @param param
     * @return
     */
    @RequestMapping("/check-select")
    public @ResponseBody
    GasResponse checkSelect(@RequestBody GasParam param) {
        return gasManager.checkSelect(param);
    }
 
    /**
     * 根据仓库批量检测
     *
     * @param param
     * @return
     */
    @RequestMapping("/check-batch")
    public @ResponseBody
    GasResponse checkBatch(@RequestBody GasParam param) {
        return gasManager.checkBatch(param);
    }
 
    /**
     * 根据条件获取列表数据 返回根据检测时间内的数据Map
     *
     * @param param
     * @return
     */
    @RequestMapping("/query-checkDate-map")
    public PageResponse<Map<String, GasData>> queryCheckDateMap(
            @RequestBody GasParam param) {
        return gasManager.queryCheckDateMap(param);
    }
 
    /**
     * @return 当前批次的各个采集点信息
     */
    @RequestMapping(value = "/list-chart")
    public @ResponseBody
    Map<String, Object> listChart(
            @RequestBody GasParam param) {
        return gasManager.lineChart(param);
    }
}