zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
package com.shlanbao.tzsc.pms.sch.stat.controller;
 
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.shlanbao.tzsc.pms.sch.workorder.beans.WorkOrderBean;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.alibaba.fastjson.JSON;
import com.shlanbao.tzsc.base.controller.BaseController;
import com.shlanbao.tzsc.base.model.DataGrid;
import com.shlanbao.tzsc.base.model.Json;
import com.shlanbao.tzsc.base.model.PageParams;
import com.shlanbao.tzsc.pms.md.unit.beans.UnitBean;
import com.shlanbao.tzsc.pms.sch.stat.beans.InputBean;
import com.shlanbao.tzsc.pms.sch.stat.beans.OutputBean;
import com.shlanbao.tzsc.pms.sch.stat.service.StatServiceI;
import com.shlanbao.tzsc.pms.sch.workorder.service.WorkOrderServiceI;
/**
 * 生产 统计
 * @author Leejean
 * @create 2014年11月25日下午1:31:32
 */
import com.shlanbao.tzsc.utils.tools.DateUtil;
 
/**
 *
 */
@Controller
@RequestMapping("/pms/stat")
public class StatController extends BaseController {
    @Autowired
    private StatServiceI statService;
    @Autowired
    private WorkOrderServiceI workOrderService;
    /**
     * 查询所有产出数据
     * @author Leejean
     * @create 2014年12月3日上午9:00:25
     * @param outputBean 查询条件
     * @param pageParams 参数
     * @return datagrid
     */
    @RequestMapping("/getAllOutputs")
    @ResponseBody
    public DataGrid getAllOutputs(OutputBean outputBean,PageParams pageParams){
        return statService.getAllOutputs(outputBean, pageParams);
    }
 
 
    /**
     * @Description 查询所有待反馈数据
     * @Author bsw
     * @Date 2020/6/13 15:08
     * @Param [outputBean, pageParams]
     * @return com.shlanbao.tzsc.base.model.DataGrid
     **/
    @RequestMapping("/getAllOutputsFb")
    @ResponseBody
    public DataGrid getAllOutputsFb(OutputBean outputBean,PageParams pageParams){
        return statService.getAllOutputsFb(outputBean, pageParams);
    }
 
    /**
     * 查询成型生产实绩
     * @author 张璐
     * @create 2015年10月12日
     * @param outputBean 查询条件
     * @param pageParams 参数
     * @return datagrid
     */
    @RequestMapping("/getAllForming")
    @ResponseBody
    public DataGrid getAllForming(OutputBean outputBean,PageParams pageParams){
        return statService.getAllForming(outputBean, pageParams);
    }
 
/**
 * @Description //成型实绩反馈查询
 * @Author bsw
 * @Date 2020/9/15 9:07
 * @Param [outputBean, pageParams]
 * @return com.shlanbao.tzsc.base.model.DataGrid
 **/
    @RequestMapping("/getAllFormingFb")
    @ResponseBody
    public DataGrid getAllFormingFb(OutputBean outputBean,PageParams pageParams){
        return statService.getAllFormingFb(outputBean, pageParams);
    }
    /**
     * 根据产出获得消耗集合
     * @author Leejean
     * @create 2014年12月3日上午9:01:13
     * @param id 产出ID
     * @return datagrid
     */
    @RequestMapping("/getAllInputsByOutput")
    @ResponseBody
    public DataGrid getAllInputsByOutput(String id){
        try {
            return statService.getAllInputsByOutput(id);
        } catch (Exception e) {
            super.setMessage("根据产出ID:"+id+"查询消耗数据");
            log.error(super.message, e);
        }
        return null;
    }
 
 
/**
 * @Description //根据产出id获取待反馈消耗
 * @Author bsw
 * @Date 2020/6/13 15:30
 * @Param [id]
 * @return com.shlanbao.tzsc.base.model.DataGrid
 **/
    @RequestMapping("/getAllInputsFbByOutput")
    @ResponseBody
    public DataGrid getAllInputsFbByOutput(String id){
        try {
            return statService.getAllInputsFbByOutput(id);
        } catch (Exception e) {
            super.setMessage("根据产出ID:"+id+"查询消耗数据");
            log.error(super.message, e);
        }
        return null;
    }
 
    /**
     * 删除产出数据
     * @author Leejean
     * @create 2014年12月3日上午9:01:17
     * @param id ID
     * @return
     */
    @RequestMapping("/deleteOutput")
    @ResponseBody
    public Json deleteOutput(String id){
        Json json=new Json();
        try {
            statService.deleteOutput(id);
            json.setMsg("删除产出数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            super.setMessage("删除产出数据失败!");
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
 
    /**
     * 批量产出产出数据
     * @param ids
     * @return
     */
    @RequestMapping("/batchDeleteOutput")
    @ResponseBody
    public Json batchDeleteOutput(String ids){
        Json json=new Json();
        try {
            statService.batchDeleteOutput(ids);
            json.setMsg("删除产出数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            super.setMessage("删除产出数据失败!");
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
    /**
     * 删除消耗数据
     * @author Leejean
     * @create 2014年12月3日上午9:01:21
     * @param id ID
     * @return
     */
    @RequestMapping("/deleteInput")
    @ResponseBody
    public Json deleteInput(String id){
        Json json=new Json();
        try {
            statService.deleteInput(id);
            json.setMsg("删除消耗数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            super.setMessage("删除消耗数据失败!");
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
 
    /**
     * 批量删除消耗数据
     * @param ids
     * @return
     */
    @RequestMapping("/batchDeleteInput")
    @ResponseBody
    public Json batchDeleteInput(String ids){
        Json json=new Json();
        try {
            statService.batchDeleteInput(ids);
            json.setMsg("删除消耗数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            super.setMessage("删除消耗数据失败!");
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
    /**
     * 跳转到产出新增页面
     * @author Leejean
     * @create 2014年12月3日上午9:01:24
     * @param request
     * @param workshop 车间代码
     * @return
     */
    @RequestMapping("/goToOutputAddJsp")
    public String goToOutputAddJsp(HttpServletRequest request,String workshop){
        request.setAttribute("workshop", workshop);
        return "/pms/sch/stat/outputAdd";
    }
    /**
     * 张璐
     * 成型生产实绩添加页面跳转
     * @param request
     * @param workshop
     * @return
     */
    @RequestMapping("/goToOutputAddJspCX")
    public String goToOutputAddJspCX(HttpServletRequest request,String workshop){
        request.setAttribute("workshop", workshop);
        return "/pms/sch/stat/outputAddCX";
    }
    /**
     * 新增产出数据
     * @author Leejean
     * @create 2014年12月3日上午9:01:27
     * @param outputBean
     * @return
     */
    @RequestMapping("/addOutput")
    @ResponseBody
    public Json addOutput(OutputBean outputBean){
        Json json=new Json();
        try {
            int result = statService.addOutput(outputBean,1);
            if(result==0){
                json.setMsg("已经存在本工单产出信息!");
                return json;
            }
            if (result == 3) {
                json.setMsg("该工单还未运行!");
                return json;
            }
            json.setMsg("添加产出数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            super.message = "添加产出数据失败!";
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
    /**
     * 跳转到产出数据编辑页面
     * @author Leejean
     * @create 2014年12月3日上午9:01:32
     * @param request
     * @param id
     * @return
     */
    @RequestMapping("/goToOutputEditJsp")
    public String goToOutputEditJsp(HttpServletRequest request,String id){
        request.setAttribute("output", statService.getOutputById(id));
        return "/pms/sch/stat/outputEdit";
    }
 
    /**
     * @Description // 待反馈产出数据编辑跳转
     * @Author bsw
     * @Date 2020/6/13 16:06
     * @Param [request, id]
     * @return java.lang.String
     **/
    @RequestMapping("/goToOutputFbEditJsp")
    public String goToOutputFbEditJsp(HttpServletRequest request,String id){
        request.setAttribute("output", statService.getOutputFbById(id));
        return "/pms/sch/stat/outputEdit";
    }
    /**
     * 编辑产出
     */
    @RequestMapping("/editOutput")
    @ResponseBody
    public Json editOutput(OutputBean outputBean){
        Json json=new Json();
        try {
            statService.editOutput(outputBean);
            json.setMsg("编辑数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            super.message = "编辑消耗数据失败!";
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
 
 
    /**
     * @Description //编辑待反馈产出
     * @Author bsw
     * @Date 2020/6/13 15:25
     * @Param [outputBean]
     * @return com.shlanbao.tzsc.base.model.Json
     **/
    @RequestMapping("/editOutputFb")
    @ResponseBody
    public Json editOutputFb(OutputBean outputBean){
        Json json=new Json();
        try {
            statService.editOutputFb(outputBean);
            json.setMsg("编辑数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            super.message = "编辑消耗数据失败!";
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
    /**
     * 跳转到消耗数据新增页面
     * @author Leejean
     * @create 2014年12月3日上午9:01:35
     * @return
     * @throws Exception
     */
    @RequestMapping("/goToInputAddJsp")
    public String goToInputAddJsp(HttpServletRequest request,OutputBean outputBean) throws Exception{
        WorkOrderBean schWorkorder = workOrderService.getWorkOrderById(outputBean.getWorkorder());
        request.setAttribute("outputId", outputBean.getId());
        request.setAttribute("workorder",schWorkorder);
        //根据产出ID得到工单,根据工单得到物料清单bom集合,供页面选择辅料新增。
        request.setAttribute("boms",JSON.toJSONString(statService.getBomsWorkorderId(schWorkorder)));
        return "/pms/sch/stat/inputAdd";
    }
    /**
     * 根据工单和物料,获取该获取在bom中的单位
     * @author Leejean
     * @create 2014年12月4日上午11:53:39
     * @param bomVersion
     * @param matId
     * @return
     */
    @RequestMapping("/getUnitByMatId")
    @ResponseBody
    public UnitBean getUnitByMatId(String bomVersion,String matId){
        return statService.getUnitByMatId(bomVersion,matId);
    }
    /**
     * 新增消耗数据
     * @author Leejean
     * @create 2014年12月4日下午2:50:36
     * @param inputBean
     * @return
     */
    @RequestMapping("/addInput")
    @ResponseBody
    public Json addInput(InputBean inputBean){
        Json json=new Json();
        try {
            statService.addInput(inputBean);
            json.setMsg("新增消耗数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            super.message = "新增消耗数据失败!";
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
    /**
     * 跳转到消耗数据编辑页面
     * @author Leejean
     * @create 2014年12月3日上午9:01:39
     * @param request
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping("/goToInputEditJsp")
    public String goToInputEditJsp(HttpServletRequest request,String iid,OutputBean outputBean) throws Exception{
 
        request.setAttribute("outputId", outputBean.getId());
 
        request.setAttribute("workorder",workOrderService.getWorkOrderById(outputBean.getWorkorder()));
 
        request.setAttribute("input", statService.getInputById(iid));
 
        return "/pms/sch/stat/inputEdit";
    }
 
    /**
     * @Description //待反馈辅料消耗编辑跳转
     * @Author bsw
     * @Date 2020/6/13 16:03
     * @Param [request, iid, outputBean]
     * @return java.lang.String
     **/
    @RequestMapping("/goToInputFbEditJsp")
    public String goToInputFbEditJsp(HttpServletRequest request,String iid,OutputBean outputBean) throws Exception{
 
        request.setAttribute("outputId", outputBean.getId());
 
        request.setAttribute("workorder",workOrderService.getWorkOrderById(outputBean.getWorkorder()));
 
        request.setAttribute("input", statService.getInputFbById(iid));
 
        return "/pms/sch/stat/inputEdit";
    }
    /**
     * 编辑消耗
     */
    @RequestMapping("/editInput")
    @ResponseBody
    public Json editInput(InputBean inputBean){
        Json json=new Json();
        try {
            statService.editInput(inputBean);
            json.setMsg("编辑消耗数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            super.message = "编辑消耗数据失败!";
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
 
    /**
     * @Description 待反馈消耗编辑
     * @Author bsw
     * @Date 2020/6/13 15:35
     * @Param [inputBean]
     * @return com.shlanbao.tzsc.base.model.Json
     **/
    @RequestMapping("/editInputFb")
    @ResponseBody
    public Json editInputFb(InputBean inputBean){
        Json json=new Json();
        try {
            statService.editInputFb(inputBean);
            json.setMsg("编辑消耗数据成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            super.message = "编辑消耗数据失败!";
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
    /**
     * 反馈数据到MES系统
     * @author Leejean
     * @create 2014年12月4日下午2:53:48
     * @param idOrIds
     * @return
     */
    @RequestMapping("/sendDataToMES")
    @ResponseBody
    public Json sendDataToMES(String idOrIds,String feedbackUser){
        Json json=new Json();
        try {
            int result = statService.sendDataToMES(idOrIds, feedbackUser);
            if(result>0){
                json.setMsg("反馈成功!");
                json.setSuccess(true);
            }else{
                json.setMsg("反馈失败!");
                json.setSuccess(false);
            }
        } catch (Exception e) {
            super.message = "反馈失败!请稍后再试!";
            log.error(super.message, e);
            json.setMsg(super.message);
        }
        return json;
    }
    /**
     * 导出PMS卷包产量信息
     * TODO
     * @param date
     * @param date2
     * @param response
     * @throws Exception
     * TRAVLER
     * 2015年12月2日下午2:47:53
     */
    @ResponseBody
    @RequestMapping("/exportQtyInfo")
    public void exportQtyInfo(String date,String date2,String team,String shift,String equipment,String eqpType,HttpServletResponse response) throws Exception{
        HSSFWorkbook wb =statService.exportQtyInfo(date,date2,shift,team,equipment,eqpType);
        String addtime=DateUtil.getNowDateTime("yyyyMMddHHmmSSS");
        response.reset();
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition","attachment; filename="+addtime+".xls");
        ServletOutputStream os = response.getOutputStream();
        wb.write(os);
        os.flush();
        os.close();
    }
 
 
}