严智鑫
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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
package com.northglass.web.cutmanage;
 
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.ResponseBody;
 
import com.northglass.entity.OptPattern;
import com.northglass.entity.RawPackageTxt;
import com.northglass.entity.ReportTask;
import com.northglass.entity.SingalGlass;
import com.northglass.repository.LoadMachineDao;
import com.northglass.repository.LoadMachineTaskDao;
import com.northglass.repository.OptPatternDao;
import com.northglass.repository.ProdLineStateDao;
import com.northglass.repository.RawPackageTxtDao;
import com.northglass.service.cutmachinemanage.GetTaskService;
import com.northglass.service.cutmanage.CutManageService;
import com.northglass.service.device.DeviceService;
import com.northglass.service.manage.ManageService;
import com.northglass.service.orderglassinfo.OrderGlassInfoService;
 
@Controller
@RequestMapping(value="/cutmanage")
public class CutManageController {
    
    @Autowired
    GetTaskService getTaskService;
    
    @Autowired
    RawPackageTxtDao rawPackageTxtDao;
 
    @Autowired
    ProdLineStateDao prodLineStateDao;
    
    @Autowired
    OptPatternDao optPatternDao;
 
    @Autowired
    LoadMachineDao loadMachineDao;
 
    @Autowired
    LoadMachineTaskDao loadMachineTaskDao;
    
    @Autowired
    CutManageService cutManageService;
    
    @Autowired
    ManageService manageService;
    
    //待领取任务界面(1号切割机)
    @RequestMapping(method=RequestMethod.GET, value="/gettask/{line}")
    public String getTask(Model model,@PathVariable("line") String line){
        return cutManageService.getTask(line, model);
    }       
    /**
     * 领取任务前校验数据库中是否还有可以领取的任务,是否已进入单机模式,是否该任务已被领取,该任务库存是否满足生产
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/checktask")
    @ResponseBody
    public String checkTask(HttpServletRequest request,HttpServletResponse response){
        return cutManageService.checktask(request);
    }
    
    /**
     * 删除当前的任务(默认完成)
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/deletetask")
    @ResponseBody
    public String deletetask(HttpServletRequest request,HttpServletResponse response){
        return cutManageService.deletetask(request);
    }
    
    /**
     * 领取任务,生成单片任务表,放到loadmachinetask中,一条记录默认片数是1
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/gottask/{id}")
    public String gotTask(@PathVariable("id") String id,HttpServletRequest request,HttpServletResponse response,Model model){
        return cutManageService.getTaskInterface(request, response, Long.valueOf(id), model);
    }
    
    @Autowired
    private OrderGlassInfoService orderGlassInfoService;
    /**
     * 任务下发
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/renwuxiafa")
    public String renwuxiafa(Model model){
        model.addAttribute("allGlasseshtmls", orderGlassInfoService.getAllGlassHtmls());
        model.addAttribute("groupshtmls", orderGlassInfoService.groupshtmls());
        return "cutmanage/renwuxiafa";
        
    }
    
    @RequestMapping(method=RequestMethod.POST, value="/renwuxiafaa")
    public String renwuxiafaa(Model model,HttpServletRequest request){
        cutManageService.renwuxiafaas(request);
        
        model.addAttribute("allGlasseshtmls", orderGlassInfoService.getAllGlassHtmls());
        return "cutmanage/renwuxiafa";
        
    }
    
    /**
     * 机器管理
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/shelfguanli")
    public String shelfguanli(Model model){
        model.addAttribute("shelfhtmls", orderGlassInfoService.shelfhtmls());
        return "cutmanage/shelfguanli";
        
    }
    
    /**
     * 修改任务状态
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/updateshelfguanli/{id}")
    public String updateshelfguanli(Model model,@PathVariable("id") String id){
        orderGlassInfoService.updateshelf(id);
        return "redirect:/cutmanage/shelfguanli";
        
    }
    
    /**
     * 修改任务状态
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/updateshelfguanli1/{id}")
    public String updateshelfguanli1(Model model,@PathVariable("id") String id){
        orderGlassInfoService.updateshelf1(id);
        return "redirect:/cutmanage/shelfguanli";
        
    }
 
    /**
     * 领取任务,生成单片任务表,放到loadmachinetask中,一条记录默认片数是1(2号线)
     * @param request
     * @param response
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/gottask2")
    public String gotTask2(HttpServletRequest request,HttpServletResponse response,Model model){
        return cutManageService.getTaskInterface(request, response, (long) 2, model);
    }
    
    
    /**
     * 显示任务列表界面
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/tasklist/{id}")
    public String getTaskList(@PathVariable("id") String id,Model model){
        model.addAttribute("patterns", cutManageService.getTaskList(Long.valueOf(id)));
        model.addAttribute("sumPiece", cutManageService.countPiece(cutManageService.getTaskList(Long.valueOf(id))).get(0));
        model.addAttribute("comPiece", cutManageService.countPiece(cutManageService.getTaskList(Long.valueOf(id))).get(1));
        model.addAttribute("line", id);
        model.addAttribute("taskhtml", cutManageService.getTasks(Long.parseLong(id)));
        return "cutmanage/gottask";
        
    }
    
    /**
     * 显示任务列表界面(2号)
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/tasklist2")
    public String getTaskList2(Model model){
        model.addAttribute("patterns", cutManageService.getTaskList(2L));
        model.addAttribute("sumPiece", cutManageService.countPiece(cutManageService.getTaskList(2L)).get(0));
        model.addAttribute("comPiece", cutManageService.countPiece(cutManageService.getTaskList(2L)).get(1));
        return "cutmanage/gottask2";
        
    }
    
    
    /**
     * 结束任务前校验任务完成情况
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/checkdata/{id}")
    @ResponseBody
    public String checkData(@PathVariable("id") String id){
        //根据ID判断当前生产线状态   为有任务时返回:     否则返回:
        return cutManageService.checkEnd(id);
    }
    
    
    /**
     * 结束任务前校验任务完成情况(2号)
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/checkdata2")
    @ResponseBody
    public String checkData2(){
        return cutManageService.checkEnd2();
    }
    
    
    /**
     * 切割机结束任务
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/completetask/{id}")
    public String completeTask(Model model,HttpServletResponse response,@PathVariable("id") String id){
//        cutManageService.print(id);
        return cutManageService.endTask(id,model);
    }
    
    
    //exitTask
    @RequestMapping(method=RequestMethod.GET, value="/exitTask/{id}")
    public String exitTask(Model model,@PathVariable("id") String id){
        return cutManageService.exitTask(id);
    }
    /**
     * 填写原因后结束任务(异常结束)
     * @return
     * @throws UnsupportedEncodingException 
     */
    @RequestMapping(method=RequestMethod.GET, value="/exceptionendtask")
    public String exceptionEndTask(HttpServletRequest request) throws UnsupportedEncodingException{
        String prodLine = request.getParameter("prodLine");// 获取产线
        cutManageService.exceptionEndTask(request,prodLine);
        return "redirect:/cutmanage/gettask/"+prodLine;
        
    }
    
    
    /**
     * 查看当前正在切割的玻璃信息
     * @param model
     * @return
     */
    @RequestMapping(method=RequestMethod.GET, value="/lookworkingglass")
    @ResponseBody
    public String lookGlass(HttpServletRequest request){
        return cutManageService.workingGlass(request);
    }
    
      /**
       * 下载opt文件
       * @param request
       * @param model
     * @return 
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/downopt1")
      public String downOptOne(HttpServletRequest request,Model model,HttpServletResponse response){
          return cutManageService.downModelLoad(request,response, (long) 1);          
      }       
      
      /**
       * 下载opt文件(2)
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/downopt2")
      public void downOptTwo(HttpServletRequest request,Model model,HttpServletResponse response){
          //下载服务器上的opt文件到本地
          cutManageService.downModelLoad(request,response, (long) 2);
      } 
      
      
      /**
       * 手动完成任务
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/manual")
      public String manual(Model model){
          //下载服务器上的opt文件到本地
          cutManageService.manual();
          return "redirect:/cutmanage/gottask";
      } 
      
      
      /**
       * 暂停/开启任务
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/stoptask/{id}")
      public String stoptask(Model model,@PathVariable("id") String id){
          cutManageService.stoptask(id);
          return "redirect:/cutmanage/gottask/"+id;
      } 
      
      /**
       * 打印所有的标签
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/jbarprint/{id}")
      public String jbarprint(Model model,@PathVariable("id") String id){
          cutManageService.jbarprint(id);
          return "redirect:/cutmanage/gottask";
      } 
      
      /**
       * 任务修改界面
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/errordeal/{id}")
      public String errordeal(Model model,@PathVariable("id") String id){
          model.addAttribute("erroedealhtml", cutManageService.errordeal(id));
          model.addAttribute("id", id);
          return "cutmanage/errordeal";
      } 
      
      
      /**
       * 下发单个小片
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/getoneglass/{id}/{line}")
      public String getoneglass(Model model,@PathVariable("id") String id,@PathVariable("line") String line){
          cutManageService.getoneglass(id);
          return "redirect:/cutmanage/errordeal/"+line;
      } 
      
      /**
       * 下发所以小片
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/getglass/{id}")
      public String getglass(Model model,@PathVariable("id") String id){
          cutManageService.getglass(id);
          return "redirect:/cutmanage/errordeal/"+id;
      } 
      
      
      /**
       * 任务设置已完成
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/finishtask/{id}/{line}")
      public String finishtask(Model model,@PathVariable("id") String id,@PathVariable("line") String line){
          cutManageService.finishtask(id);
          return "redirect:/cutmanage/errordeal/"+line;
      } 
      
      
      /**
       * 当前小片信息
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/getsingalglass/{id}/{line}")
      public String getsingalglass(Model model,@PathVariable("id") String id,@PathVariable("line") String line){
          model.addAttribute("erroedealhtml", cutManageService.getsingalglass(id));
          model.addAttribute("id", line);
          return "cutmanage/getsingalglass";
      } 
      
      /**
       * 任务设置等待中
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/againtask/{id}/{line}")
      public String againtask(Model model,@PathVariable("id") String id,@PathVariable("line") String line){
          cutManageService.againtask(id);
          return "redirect:/cutmanage/errordeal/"+line;
      } 
      
      
      /**
       * 切割TV
       * @param request
       * @param model
       * @return
       */
      @RequestMapping(method=RequestMethod.GET,value="/getview/{id}")
      public String getview(Model model,@PathVariable("id") String id) throws IOException{
          model.addAttribute("getviewhtml", cutManageService.getview(id));
          model.addAttribute("id", id);
          return "cutmanage/getview";
      } 
      
        //上片机显示
        @RequestMapping(method=RequestMethod.GET,value="/loadmachinemanager")
        public String loadmachinemanager(Model model) {
            model.addAttribute("LoadMachineOne", manageService.getLoadMachineHtml((long)1));
            return "cutmanage/loadmachinemanager";
        }
        
        @RequestMapping(method=RequestMethod.GET, value="/qaz")
        public String qaz(Model model){
            return cutManageService.getShelfRankInfos(model);
            
        }
        
        @RequestMapping(method=RequestMethod.POST, value="/selectreport")
        public String selectreport(HttpServletRequest request,Model model){
            List<OptPattern> reportTasks = cutManageService.selectReport(request);
            model.addAttribute("rawPackageTxts", reportTasks);
            return "cutmanage/qaz";
        }
      
}