严智鑫
2025-11-13 945bc394f40d8af1072a53da9a94f24207124e6d
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
package com.northglass.web.shelfmanager;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.northglass.constants.StateConstants.ShelfRankState;
import com.northglass.entity.RawPackage;
import com.northglass.entity.ShelfRank;
import com.northglass.service.shelfmanager.ShelfManagerService;
 
@Controller
@RequestMapping(value="/shelfmanager")
public class ShelfManagerController {
    private static final Logger LOGGER = LoggerFactory.getLogger(ShelfManagerController.class);
    
    @Autowired
    private ShelfManagerService  shelfManagerService;
    
    /**
     * 任务导入
     * @param model
     * @param request
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/taskimport")
    public String taskImport(Model model,HttpServletRequest request){
        //shelfManagerService.getRawPackage(request);
        model.addAttribute("RawPackageTxtesWait", shelfManagerService.getRawPackageTxtesWait());
        model.addAttribute("isCenterDisplay", shelfManagerService.isCenterDisplay());
        model.addAttribute("shelfManagerPrecent", shelfManagerService.getPrecent());
        model.addAttribute("Precent", shelfManagerService.getcount());
        model.addAttribute("shelfRankInfo", shelfManagerService.getShelfRankInfo());
        model.addAttribute("getShelfHoistInfo", shelfManagerService.getShelfHoistInfo());
        model.addAttribute("LoadMachineRackInfo", shelfManagerService.getLoadMachineRackInfo());
        model.addAttribute("RawPackageTxtesSend", shelfManagerService.getRawPackageTxtesSend());
        model.addAttribute("loadAndShelfHoistInfo", shelfManagerService.getLoadAndShelfHoistInfo());
        return "shelfmanager/taskimport";
    }
    
    //料架管理
      @RequestMapping(method=RequestMethod.GET,value="/rankmanager")
      public String rank(Model model) {
          model.addAttribute("working", ShelfRankState.IN_WORK);
          model.addAttribute("free", ShelfRankState.FREE);
          model.addAttribute("rawPackage", new RawPackage());
          model.addAttribute("addrawPackage", new RawPackage());
          model.addAttribute("shelfRankInfo", shelfManagerService.getShelfRankInfo());
          model.addAttribute("action", "createAction");
         model.addAttribute("addaction", "addcreateAction");
          model.addAttribute("shelfRankNumberList", shelfManagerService.getFreeShelfRankNumberList());
          model.addAttribute("optionHtml",shelfManagerService.getoptionHtml());
          return "shelfmanager/rankmanager";
      }
      
      //入库
      @RequestMapping(method=RequestMethod.POST, value="/createAction")
      public String createAction(@Valid RawPackage rawPackage, HttpServletRequest request,@RequestParam(value="shelfRankNumber") String shelfRankNumber) {
          shelfManagerService.SaveShelfRankByNumber(rawPackage, shelfRankNumber);
          return "redirect:/shelfmanager/rankmanager";
      }
      
      //添加原片
      @RequestMapping(method=RequestMethod.POST, value="/addcreateAction")
      public String addcreateAction(@Valid RawPackage rawPackage, HttpServletRequest request,@RequestParam("Ids") String Ids,@Valid RawPackage addrawPackage) {
          shelfManagerService.addrawPackage(addrawPackage, Ids);
          return "redirect:/shelfmanager/rankmanager";    
      }
    
    @RequestMapping(method=RequestMethod.GET, value="/taskAssigned")
    public String Assigned(Model model,HttpServletRequest request){
        model.addAttribute("shelfManagerTask", shelfManagerService.getRawPackageTxt());
        model.addAttribute("shelfManagerPrecent", shelfManagerService.getPrecent());
        model.addAttribute("shelfRankInfo", shelfManagerService.getShelfRankInfo());
        model.addAttribute("Precent", shelfManagerService.getcount());
        model.addAttribute("loadAndShelfHoistInfo", shelfManagerService.getLoadAndShelfHoistInfo());
        return "shelfmanager/taskimport";
    }
    
    
    /**
     * 显示opt文件的详细信息
     * @param model
     * @param txtName
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/filename/{txtName}")
    public String filename(Model model, @PathVariable("txtName") String txtName){
        model.addAttribute("optPatternes", shelfManagerService.fileName(txtName));
        return "shelfmanager/filename";
    }
    
    /**
     * 显示已下发opt文件的详细信息
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/assigned")
    public String assigned(Model model){
        model.addAttribute("raPackageTxtes", shelfManagerService.assigned());
        model.addAttribute("shelfManagerPrecent", shelfManagerService.getPrecent());
        return "shelfmanager/assigned";
    }
    
    /**
     * 从左边栏选择任务到右边栏
     * @param model
     * @param leftvalue
     * @return
     */
    @RequestMapping(method=RequestMethod.GET,value="/lefttoright")
    @ResponseBody
    public String leftToRight(Model model,@RequestParam("leftvalue") String leftvalue){
//        model.addAttribute("result", shelfManagerService.leftToRight(leftvalue));
        return shelfManagerService.leftToRight(leftvalue);
    }
    
    /**
     * 从右边栏选择任务到左边栏
     * @param model
     * @param rightvalue
     * @return
     */
    @RequestMapping(method=RequestMethod.GET,value="/righttoleft")
    public String rightToLeft(Model model,@RequestParam("rightvalue") String rightvalue){
        model.addAttribute("result", shelfManagerService.rightToLeft(rightvalue));
        return "ajax/ajax";
    }
    
//    /**
//     * 出库
//     * @param model
//     * @return
//     */
//    @RequestMapping(value="/exit")
//    public String exit(Model model){
//        return "shelfmanager/exit";
//    }
//    
    /**
     * 出库信息数量和时间
     * @param model
     * @return
     */
    @RequestMapping(value="/exit")
    public String exitRankAmount(Model model){
        //model.addAttribute("result", shelfManagerService.exitRankAmount());
        List<RawPackage> rawpackages = shelfManagerService.exitRankAmount();
        model.addAttribute("rawpackages", rawpackages);
        return "shelfmanager/exit";
    }
    
    
    /**
     * 执行出库
     * @param model
     * @param ids
     * @return
     */
    @RequestMapping(value="/exitseparate")
    public String exitSeparate(Model model,@RequestParam("ids") String ids){
        shelfManagerService.exitSeparate(ids);
        model.addAttribute("rawpackages", shelfManagerService.exitRankAmount());
        return "shelfmanager/exit";
    }
    
 
    /**
     * HMI人机界面
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET,value="/hmi")
    public String hmi(Model model, HttpServletRequest request){
        model.addAttribute("rawPackage",shelfManagerService.showHmi());
        model.addAttribute("isDisplayInput", shelfManagerService.isDisplayInput());
        model.addAttribute("shelfShowTask", shelfManagerService.showTask(request));
        return "shelfmanager/hmi";
    }
    
    /**
     * 输入吊装的实际片数
     * @param model
     * @param pieces
     * @return
     */
    @RequestMapping(method=RequestMethod.GET,value="/pieces")
    @ResponseBody
    public String pieces(Model model,@RequestParam("pieces") int pieces){
        String hmiProcess = shelfManagerService.hmiProcess(pieces);
        return hmiProcess; 
        
    }
    
    /**
     * 仓库信息
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET,value="/shelfrank")
    public String shelfRank(Model model){
       model.addAttribute("shelfRankMessage", shelfManagerService.getShelfRank());
       model.addAttribute("shelfRankInfo", shelfManagerService.getShelfRankInfo());
       model.addAttribute("loadAndShelfHoistInfo", shelfManagerService.getLoadAndShelfHoistInfo());
       return "shelfmanager/shelfrank";   
    }
    
    /**
     * 根据条件查询对应的料架
     * @param model
     * @param request
     * @return
     */
    @RequestMapping(method=RequestMethod.POST,value="/condition")
    public String condition(Model model, HttpServletRequest request){
        model.addAttribute("shelfRankMessage", shelfManagerService.filtrate(request));
        model.addAttribute("shelfRankInfo", shelfManagerService.getShelfRankInfo());
        model.addAttribute("loadAndShelfHoistInfo", shelfManagerService.getLoadAndShelfHoistInfo());
        return "shelfmanager/shelfrank"; 
    }
    
    /**
     * 将库存的玻璃信息生成Excel表格
     * @param model
     * @param response
     * @param request
     */
    @RequestMapping(method=RequestMethod.GET,value="/downloadExcel")
    public void downloadExcel(Model model,HttpServletResponse response, HttpServletRequest request){
         shelfManagerService.generateExcelFile(request,response);
    }
    
    /**
     * 增加特殊玻璃
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET,value="/editPackage")
    public String editSpecialColor(Model model){
        model.addAttribute("GlassNumberColorTask", shelfManagerService.getGlassNumberColor());
        return "shelfmanager/editPackage";
    }
    
    /**
     * 删除测试数据
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/clearTestData")
    public String clearTestData(Model model){
        shelfManagerService.deleteTestData();
        model.addAttribute("shelfRankInfo", shelfManagerService.getShelfRankInfo());
        model.addAttribute("loadAndShelfHoistInfo", shelfManagerService.getLoadAndShelfHoistInfo());
        return "shelfmanager/taskimport";
    }
    
    //删除任务
      @RequestMapping(method=RequestMethod.GET, value="/batchCancelRawpackagetxts")
      public String batchCancelRanks(Model model,@RequestParam("rawpackagetxtIds") String rawpackagetxtIds) {
          model.addAttribute("result", shelfManagerService.cancel(rawpackagetxtIds));
          return "ajax/ajax";
      }
      
      //下发任务
      @RequestMapping(method=RequestMethod.GET, value="/batchDeleteRawpackagetxts")
    public String batchDeleteRanks(Model model,@RequestParam("rawpackagetxtIds") String rawpackagetxtIds) {
        model.addAttribute("result", shelfManagerService.push(rawpackagetxtIds));
        return "ajax/ajax";
    }
      
      //退回任务
      @RequestMapping(method=RequestMethod.GET, value="/batchDeleteRawpackagetxt")
      public String batchDeleteRank(Model model,@RequestParam("rawpackagetxtId") String rawpackagetxtId) {
          model.addAttribute("result", shelfManagerService.reverse(rawpackagetxtId));
          return "ajax/ajax";
    }
      
      //料架信息
      @RequestMapping(method=RequestMethod.POST, value="/rawpackagelist")
      @ResponseBody
      public Map<String, Object>  rawpackagelist(Model mode,ShelfRank v,HttpServletRequest request,
              @RequestParam("start") Integer start,@RequestParam("length") Integer length,
              @RequestParam("glassThickness") String glassThickness,@RequestParam("glassId") String glassId) {
          LOGGER.debug(start+"startstartstart//////////////"+length);
        LOGGER.debug(glassThickness+"/glassThicknessglassThickness/////////////"+glassId);
        Map<String, Object> map = new HashMap<String, Object>();
        int count = 0;
        List<ShelfRank> list=null;
        if((glassThickness==null||glassThickness=="")&&(glassId==null||glassId=="")){
              count = shelfManagerService.selectCount();
            list=shelfManagerService.selectAll(start,length);
        }else if((glassThickness!=null&&glassThickness!="")&&(glassId==null||glassId=="")){
            count = shelfManagerService.selectCount1(glassThickness);
            list=shelfManagerService.selectAll1(start,length,glassThickness);
        }else if((glassThickness==null||glassThickness=="")&&(glassId!=null&&glassId!="")){
            count = shelfManagerService.selectCount2(glassId);
            list=shelfManagerService.selectAll2(start,length,glassId);
        }else if((glassThickness!=null&&glassThickness!="")&&(glassId!=null&&glassId!="")){
            count = shelfManagerService.selectCount3(glassThickness,glassId);
            list=shelfManagerService.selectAll3(start,length,glassThickness,glassId);
        }
        LOGGER.debug(count+"???????????????"+list.toString());
        map.put("recordsTotal", count);
        map.put("recordsFiltered", count);
          map.put("aaData", list);
          return map;
      }
    //出库
    @RequestMapping(value="/deleteAll")
    @ResponseBody
    public Map<String, Object> delete(@RequestParam("Ids") String Ids,HttpServletRequest request){
        Map<String, Object> map=new HashMap<String, Object>();
        try {
            shelfManagerService.exitSeparate(Ids);
            map.put("code",1);
        } catch (Exception e) {
            System.out.println("出库失败");
            map.put("code",2);
            map.put("errorInfo", "出库失败");
        }
            
    return map;    
    }
    
    //删除原片
    @RequestMapping(method=RequestMethod.POST, value="/deleteBtn")
    @ResponseBody
    public Map<String, Object>  deleteBtn(@RequestParam("Ids") String Ids) {
        Map<String, Object> map=new HashMap<String, Object>();
        try {
            shelfManagerService.deleteBtn(Ids);
            map.put("code",1);
        } catch (Exception e) {
            map.put("code",2);
            map.put("errorInfo", "失败");
        }
            
        return map;    
    }
    
    //禁用或启用料架
    @RequestMapping(value="/stopOrStart")
    @ResponseBody
    public Map<String, Object> stopOrStart(@RequestParam("Ids") String Ids,HttpServletRequest request){
        Map<String, Object> map=new HashMap<String, Object>();
        try {
            shelfManagerService.stopOrStart(Ids);
            map.put("code",1);
        } catch (Exception e) {
            map.put("code",2);
            map.put("errorInfo", "失败");
        }
            
        return map;    
    }
    
    //生成Excel
    @RequestMapping(value="/export")
    public void export(Model model,HttpServletResponse response, HttpServletRequest request){
        shelfManagerService.exportExcelFile(request,response);
    }
    
    //根据料架号显示当前料架信息
    @RequestMapping(method=RequestMethod.GET, value="/vertical")
    public String value(Model model,@RequestParam("value") String value) {
         model.addAttribute("result", shelfManagerService.findByNumber(value));
         return "ajax/ajax";
    }
    
    //查询
    @RequestMapping(method=RequestMethod.POST, value="/search")
    public String createActionForEditShelfRank(Model model,@RequestParam("glassId") String glassId,
            @RequestParam("glassThickness") String glassThickness) {
        model.addAttribute("working", ShelfRankState.IN_WORK);
        model.addAttribute("free", ShelfRankState.FREE);
        model.addAttribute("shelfRankInfo", shelfManagerService.getShelfRankInfo());
        model.addAttribute("glassId", glassId);
        model.addAttribute("glassThickness", glassThickness);
        model.addAttribute("optionHtml",shelfManagerService.getoptionHtml());
        LOGGER.debug(glassThickness+"///////+++++++++++++++++++///////"+glassId);
        return "shelfmanager/rankmanager";
    }
}