jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
package com.ld.igds.verb.controller;
 
import com.bstek.bdf2.core.business.IUser;
import com.ld.igds.common.manager.CommonManager;
import com.ld.igds.constant.BizType;
import com.ld.igds.constant.Constant;
import com.ld.igds.constant.DepotType;
import com.ld.igds.data.ConfigVerbImg;
import com.ld.igds.data.PageResponse;
import com.ld.igds.io.response.DeviceControlResponse;
import com.ld.igds.models.Depot;
import com.ld.igds.models.Device;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.verb.dto.VerbParam;
import com.ld.igds.verb.manager.VerbManager;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
import java.util.List;
 
/**
 * 通风模块管理-手动通风
 *
 * 包括通风相关页面入口
 */
@RestController
@RequestMapping("basic/verb")
public class VerbController {
 
    @Autowired
    private VerbManager verbManager;
    @Autowired
    private CommonManager commonManager;
    @Autowired
    private ConfigVerbImg verbImg;
 
 
    /**
     * 根据仓库信息获取仓库配置等,跳转不同的显示页面
     *
     * @param depotId   仓库编码
     * @param depotType 仓库类型
     * @param deptId    所属分库
     * @return
     */
    @RequestMapping("/gateway")
    public ModelAndView gateway(
            @RequestParam(value = "depotId", required = false) String depotId,
            @RequestParam(value = "depotType", required = true) String depotType,
            @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);
        }
 
        // 获取当前用户所在的分库名称
//        DefaultDept dept = commonManager.getSubDept(user, deptId);
//        view.addObject("dept", dept);
 
        view.addObject("deptId", deptId);
 
        // 获取当前部门,所有仓库列表
        List<Depot> listDepot = commonManager.listDepot(deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
 
        view.addObject("bizType", BizType.AREATION.getCode());
        view.addObject("depotType", depotType);
        view.addObject("depotId", depotId);
 
        if (StringUtils.isEmpty(depotType)) {
            view.setViewName("admin/verb/verb-hand1");
        }
 
        if (DepotType.TYPE_02.getCode().equals(depotType) || DepotType.TYPE_04.getCode().equals(depotType)) {
            view.setViewName("admin/verb/verb-hand2");
        } else {
            view.setViewName("admin/verb/verb-hand1");
        }
        // 每个仓库正面和背面图片
        view.addObject("verbImgMap", verbImg.getVerbImg(listDepot, deptId));
 
        return view;
    }
 
 
    /**
     * 页面控制--手动通风页面-平房仓
     *
     * @param depotId
     * @return
     */
    @RequestMapping("/verb-hand1")
    public ModelAndView verbHand(@RequestParam(value = "depotId", required = false) String depotId) {
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
 
        //当前人所在分库
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("deptId", deptId);
 
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listDepot(deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        view.addObject("depotId", depotId);
 
 
        view.addObject("depotType", DepotType.TYPE_01.getCode());
 
        // 每个仓库正面和背面图片
        view.addObject("verbImgMap", verbImg.getVerbImg(listDepot, deptId));
 
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
        view.addObject(Constant.MODEL_KEY_BIZ_TYPE, BizType.AREATION.getCode());
 
        view.setViewName("admin/verb/verb-hand1");
        return view;
    }
 
    /**
     * 页面控制--手动通风页面-筒仓
     *
     * @param depotId
     * @return
     */
    @RequestMapping("/verb-hand2")
    public ModelAndView verbHand2(@RequestParam(value = "depotId", required = false) String depotId) {
        ModelAndView view = new ModelAndView();
 
        IUser user = ContextUtil.getLoginUser();
 
        //当前人所在分库
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("deptId", deptId);
 
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listDepot(deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        view.addObject("depotId", depotId);
 
        view.addObject("depotType", DepotType.TYPE_02.getCode());
 
        // 每个仓库正面和背面图片
        view.addObject("verbImgMap", verbImg.getVerbImg(listDepot, deptId));
 
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
        view.addObject(Constant.MODEL_KEY_BIZ_TYPE, BizType.AREATION.getCode());
 
        view.setViewName("admin/verb/verb-hand2");
        return view;
    }
 
    /**
     * 自动通风配置页面
     *
     * @param depotId
     * @return
     */
    @RequestMapping("/verb-auto")
    public ModelAndView verbAuto(
            @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);
 
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("deptId", deptId);
 
        // 通风目的
        List<DicTrigger> listTrigger = commonManager.getListByParent(
                Constant.TRIGGER_PARENT_AREATION_TARGIT, user.getCompanyId());
        view.addObject("listTrigger", listTrigger);
 
        //获取模式标签
        List<DicTrigger> listModelTag = verbManager.listAreationModelTag();
        view.addObject("listModelTag", listModelTag);
        view.addObject("bizType", BizType.AREATION.getCode());
 
        view.setViewName("admin/verb/verb-auto");
        return view;
    }
 
    /**
     * 通风标准
     *
     * @param
     * @return
     */
    @RequestMapping("/verb-standard")
    public ModelAndView verbStandard() {
        ModelAndView view = new ModelAndView();
        view.setViewName("admin/verb/verb-standard");
        return view;
    }
 
    /**
     * 根据仓库编号,获取与当前仓库相同建筑的所有设备列表
     *
     * @param param
     * @return
     */
    @RequestMapping("/list-device-manual")
    public PageResponse<List<Device>> listDeviceManual(@RequestBody VerbParam param) {
 
        if (null == param.getDepotType()) {
            param.setDepotType(DepotType.TYPE_01.getCode());
        }
        param.setCompanyId(ContextUtil.getCompanyId());
 
        if (DepotType.TYPE_01.getCode().equals(param.getDepotType())) {
            param.setOnlyCurDepot(false);
        } else {
            param.setOnlyCurDepot(true);
        }
 
        return verbManager.listDeviceManual(param);
    }
 
    /**
     * 设备操作接口
     *
     * @param param
     * @return
     */
    @RequestMapping("/control-device")
    public DeviceControlResponse controlDevice(@RequestBody VerbParam param) {
        return verbManager.controlDevice(param);
    }
 
    /***
     * 设备状态查询
     *
     * @param param
     * @return
     */
    @RequestMapping("/query-status")
    public DeviceControlResponse queryStatus(@RequestBody VerbParam param) {
        return verbManager.queryDeviceStatus(param);
    }
 
}