CZT
2023-11-02 391c534a5ed0a07f8e9feb2ddaf14cfed070300d
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
package com.ld.igds.temp.controller;
 
import java.util.List;
 
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.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.temp.dto.TempParam;
import com.ld.igds.temp.manager.TempControlManager;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
/**
 * 温控管理 控制层只定义控制入口和页面跳转,具体逻辑在Manager中控制。
 */
@RestController
@RequestMapping("basic/temp")
public class TempControlController {
 
    @Autowired
    private TempControlManager tempManager;
    @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.TEMPCONTROL.getCode());
        view.addObject("depotType", depotType);
        view.addObject("depotId", depotId);
 
        if (StringUtils.isEmpty(depotType)) {
            view.setViewName("admin/wkgl/temp-control");
        }
 
        if (DepotType.TYPE_02.getCode().equals(depotType) || DepotType.TYPE_04.getCode().equals(depotType)) {
            view.setViewName("admin/wkgl/temp-control2");
        } else {
            view.setViewName("admin/wkgl/temp-control");
        }
 
        // 每个仓库正面和背面图片
        view.addObject("imgMap", verbImg.getVerbImg(listDepot, deptId));
 
        return view;
    }
 
    /**
     * 页面控制-平房仓
     *
     * @param depotId
     * @return
     */
    @RequestMapping("/view-check")
    public ModelAndView viewCheck(
            @RequestParam(value = "depotId", required = false) String depotId) {
        ModelAndView view = new ModelAndView();
        IUser user = ContextUtil.getLoginUser();
 
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
        //当前人所在分库
        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("depotType", DepotType.TYPE_01.getCode());
 
        view.addObject("depotId", depotId);
 
        // 每个仓库正面和背面图片
        view.addObject("imgMap", verbImg.getVerbImg(listDepot, deptId));
 
        view.addObject("bizType", BizType.TEMPCONTROL.getCode());
 
        view.setViewName("admin/wkgl/temp-control");
        return view;
    }
 
 
    /**
     * 页面控制-平房仓
     *
     * @param depotId
     * @return
     */
    @RequestMapping("/view-check2")
    public ModelAndView viewCheck2(
            @RequestParam(value = "depotId", required = false) String depotId) {
        ModelAndView view = new ModelAndView();
        IUser user = ContextUtil.getLoginUser();
 
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
        //当前人所在分库
        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("depotType", DepotType.TYPE_02.getCode());
 
        view.addObject("depotId", depotId);
 
        // 每个仓库正面和背面图片
        view.addObject("imgMap", verbImg.getVerbImg(listDepot, deptId));
 
        view.addObject("bizType", BizType.TEMPCONTROL.getCode());
 
        view.setViewName("admin/wkgl/temp-control2");
        return view;
    }
 
    /**
     * 根据仓库编号,获取与当前仓库相同建筑的所有设备列表
     *
     * @param param
     * @return
     */
    @RequestMapping("/list-device-manual")
    public PageResponse<List<Device>> listDeviceManual(
            @RequestBody TempParam param) {
        param.setCompanyId(ContextUtil.getCompanyId());
 
        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 tempManager.listDeviceManual(param);
    }
 
    /**
     * 空调操作
     *
     * @param param
     * @return
     */
    @RequestMapping("/control")
    public @ResponseBody
    DeviceControlResponse tempControl(@RequestBody TempParam param) {
 
        return tempManager.tempControl(param);
    }
 
    /**
     * 空调操作
     *
     * @param param
     * @return
     */
    @RequestMapping("/query-status")
    public @ResponseBody
    DeviceControlResponse queryStatus(@RequestBody TempParam param) {
        return tempManager.queryDeviceStatus(param);
    }
 
}