czt
6 天以前 3b3a2815feec0d2f436749ef450bb1a6eb4f12ca
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
package com.fzzy.sys.controller.grain;
 
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.constant.DepotType;
import com.fzzy.igds.data.*;
import com.fzzy.igds.domain.Depot;
import com.fzzy.igds.request.ExeBaseRequest;
import com.fzzy.igds.response.GrainResponse;
import com.fzzy.igds.utils.ContextUtil;
import com.fzzy.sys.manager.common.CommonManager;
import com.fzzy.sys.manager.grain.GrainManager;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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 javax.annotation.Resource;
import java.util.List;
import java.util.Map;
 
/**
 * @Description 粮情控制器
 * @Author CZT
 * @Date 2025/12/9 9:04
 */
@Slf4j
@Controller
@RequestMapping("grain")
public class GrainController {
 
    private static final String prefix = "grain";
 
    @Resource
    private CommonManager commonManager;
    @Resource
    private GrainManager grainManager;
 
    /**
     * 页面控制--根据仓库类型调整不同页面
     *
     * @param depotId
     * @param deptId
     * @return
     */
    @RequestMapping("/gateway")
    public String gateway(
            @RequestParam(value = "depotId", required = true) String depotId,
            @RequestParam(value = "deptId", required = false) String deptId,
            ModelMap view) {
 
        SysUser user = ContextUtil.getLoginUser();
        view.put(Constant.MODEL_KEY_LOGIN_USER, user);
 
        if(StringUtils.isBlank(deptId)){
            deptId = ContextUtil.subDeptId(user);
        }
        view.put("deptId", deptId);
 
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listDepotByDeptId(deptId);
        view.put(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        String depotType = commonManager.getDepotTypeById(depotId);
        view.put("depotType", depotType);
        view.put("depotId", depotId);
 
        //页面,默认平房仓
        String viewUrl = prefix + "grain-check1";
        if (depotType.equals(DepotType.TYPE_01.getCode()) || depotType.equals(DepotType.TYPE_05.getCode())) {
            viewUrl = prefix + "/grain-check1";
        }
        if (DepotType.TYPE_02.getCode().equals(depotType) || DepotType.TYPE_04.getCode().equals(depotType)) {
            viewUrl = prefix + "/grain-check4";
        }
        if (DepotType.TYPE_03.getCode().equals(depotType)) {
            viewUrl = prefix + "/grain-check3";
        }
 
        return viewUrl;
    }
 
    /**
     * 页面控制--粮情检测页面 - 平房仓
     *
     * @param depotId
     * @return
     */
    @RequestMapping("/view-check1")
    public String viewCheck(
            @RequestParam(value = "depotId", required = false) String depotId,
            @RequestParam(value = "deptId", required = false) String deptId,
            ModelMap view) {
 
        SysUser user = ContextUtil.getLoginUser();
        view.put(Constant.MODEL_KEY_LOGIN_USER, user);
 
        // 获取当前用户所在的分库名称
        if(StringUtils.isBlank(deptId)){
            deptId = ContextUtil.subDeptId(user);
        }
        view.put("deptId", deptId);
 
        // 获取当前部门,所有仓库列表
        List<Depot> listDepot = commonManager.listDepotByDeptId(deptId);
        view.put(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        view.put("depotType", DepotType.TYPE_01.getCode());
        view.put("depotId", depotId);
 
        return prefix + "/grain-check1";
    }
 
    /**
     * 页面控制--粮情检测页面 - 筒仓、浅圆仓
     *
     * @param depotId
     * @param deptId
     * @return
     */
    @RequestMapping("/view-check4")
    public String viewCheck4(
            @RequestParam(value = "depotId", required = false) String depotId,
            @RequestParam(value = "deptId", required = false) String deptId,
            ModelMap view) {
 
        SysUser user = ContextUtil.getLoginUser();
        view.put(Constant.MODEL_KEY_LOGIN_USER, user);
 
        // 获取当前用户所在的分库名称
        if(StringUtils.isBlank(deptId)){
            deptId = ContextUtil.subDeptId(user);
        }
        view.put("deptId", deptId);
 
        // 获取当前部门,所有仓库列表
        List<Depot> listDepot = commonManager.listDepotByDeptId(deptId);
        view.put(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
 
        view.put("depotType", DepotType.TYPE_04.getCode());
        view.put("depotId", depotId);
 
        return prefix + "/grain-check4";
    }
 
    /**
     * 获取执行命令记录
     *
     * @param depotId
     * @param deptId
     * @return
     */
    @RequestMapping("/order-list")
    public String orderList(
            @RequestParam(value = "depotId", required = false) String depotId,
            @RequestParam(value = "deptId", required = false) String deptId,
            ModelMap view) {
 
        SysUser user = ContextUtil.getLoginUser();
        view.put(Constant.MODEL_KEY_LOGIN_USER, user);
 
        // 获取当前用户所在的分库名称
        if (org.apache.commons.lang3.StringUtils.isEmpty(deptId)) {
            deptId = ContextUtil.subDeptId(user);
        }
        view.put("deptId", deptId);
 
        view.put("bizType", "grain");
        view.put("depotId", depotId);
 
        return prefix + "/order-list";
    }
 
    /**
     * 粮情页面 - 根据条件获取集合,默认查询当天的数据
     *
     * @param param
     * @return
     */
    @RequestMapping("/query-list-data")
    @ResponseBody
    public PageResponse<List<GrainData>> queryListGrainData(@RequestBody GrainParam param) {
        if (null == param.getCheckMonth()) {
            param.setLimit(5);
        } else {
            param.setLimit(80);
        }
        return grainManager.queryListGrainData(param);
    }
 
    /**
     * 粮情检测-单仓检测
     *
     * @param param
     * @return
     */
    @RequestMapping("/check-single")
    @ResponseBody
    public GrainResponse checkSingle(@RequestBody GrainParam param) {
        return grainManager.checkSingle(param);
    }
 
    /**
     * 粮情检测-批量检测
     *
     * @param param
     * @return
     */
    @RequestMapping("/check-batch")
    @ResponseBody
    public GrainResponse checkBatch(@RequestBody GrainParam param) {
        return grainManager.checkBatch(param);
    }
 
    /**
     * 根据当前仓库获取检测记录,默认10条,如果检测当前月,默认显示80条
     *
     * @param param
     * @return
     */
    @RequestMapping("/page-list")
    @ResponseBody
    public PageResponse<List<GrainData>> pageList(@RequestBody GrainParam param) {
        if (null == param.getCheckMonth()) {
            param.setLimit(10);
        } else {
            param.setLimit(80);
        }
        return grainManager.pageListGrainData(param);
    }
 
 
    /**
     * 根据参数获取打印的模板
     *
     * @param param
     * @return
     */
    @ResponseBody
    @RequestMapping("/build-print-model")
    public PageResponse<PrintModeData> buildPrintModel(
            @RequestBody GrainParam param) {
        return grainManager.buildPrintModel(param);
    }
 
    /**
     * 根据参数获取打印的模板-ALL
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/build-print-model-all")
    public PageResponse<Map<String, PrintModeData>> buildPrintModelAll(
            @RequestBody GrainParam param) {
        param.setCompanyId(ContextUtil.getCompanyId());
        return grainManager.buildPrintModelAll(param);
    }
 
 
    /**
     * 粮情检测-批量导出EXCEL
     *
     * @param param 包括检测时间和需要导出的IDS
     * @return
     */
    @RequestMapping("/export-batch")
    @ResponseBody
    public GrainResponse exportBatch(@RequestBody GrainParam param) {
        return grainManager.exportBatch(param);
    }
 
 
 
    /**
     * 根据参数获取打印的模板-ALL
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/query-order-list")
    public LayPage<List<ExeBaseRequest>> queryOrderList(@RequestParam(value = "depotId", required = false) String depotId,
                                                     @RequestParam(value = "deptId", required = false) String deptId) {
        // 获取当前用户所在的分库名称
        if(StringUtils.isBlank(deptId)){
            deptId = ContextUtil.subDeptId(null);
        }
 
        List<ExeBaseRequest> result = grainManager.orderList(deptId);
 
        return new LayPage(result);
    }
 
 
    /**
     * 清除执行日志
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/clean-order-list")
    public PageResponse<String> cleanOrderList(@RequestBody IgdsBaseParam param) {
 
        if (StringUtils.isEmpty(param.getCompanyId())) {
            param.setCompanyId(ContextUtil.getCompanyId());
        }
        if (StringUtils.isEmpty(param.getDeptId())) {
            param.setDeptId(ContextUtil.subDeptId(null));
        }
 
        return grainManager.cleanOrderList(param);
    }
}