李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
/*
 *    Copyright (c) 2018-2025, ztt All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: ztt
 */
 
package com.chinaztt.mes.production.controller;
 
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chinaztt.mes.common.wrapper.QueryWrapperUtil;
import com.chinaztt.mes.production.config.ProductOutputSubmitConfig;
import com.chinaztt.mes.production.dto.*;
import com.chinaztt.mes.production.entity.ProductInput;
import com.chinaztt.mes.production.entity.ProductMain;
import com.chinaztt.mes.production.entity.ProductOutput;
import com.chinaztt.mes.production.excel.ProductOutPutData;
import com.chinaztt.mes.production.service.ProductMainService;
import com.chinaztt.mes.warehouse.dto.StockDTO;
import com.chinaztt.ztt.common.core.util.R;
import com.chinaztt.ztt.common.log.annotation.SysLog;
import com.chinaztt.ztt.common.security.annotation.Inner;
import com.chinaztt.ztt.common.sequence.sequence.Sequence;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
 
 
/**
 * 报工主表
 *
 * @author cxf
 * @date 2020-11-17 10:12:27
 */
@RestController
@AllArgsConstructor
@RequestMapping("/product")
@Api(value = "product", tags = "报工主表管理")
public class ProductMainController {
 
    private final ProductMainService productMainService;
 
    private final ProductOutputSubmitConfig productOutputSubmitConfig;
 
    private Sequence sequence;
 
    /**
     * 根据工单id和工作站id获取报工主表
     *
     * @param productMain productMain
     * @return R
     */
    @ApiOperation(value = "根据工单id和工作站id获取报工主表", notes = "根据工单id和工作站id获取报工主表")
    @GetMapping("/getProductMain")
    public R getProductMain(ProductMain productMain) {
        return R.ok(productMainService.list(Wrappers.query(productMain).orderByDesc("create_time")));
    }
 
    /**
     * 获取报工单列表
     *
     * @param productMain
     * @return
     */
    @ApiOperation(value = "获取报工单列表", notes = "获取报工单列表")
    @GetMapping("/getProductMainV1")
    public R getProductMainV1(Page page, ProductMainListDTO productMain) {
        return R.ok(productMainService.getList(page,QueryWrapperUtil.gen(productMain)));
    }
 
    /**
     * 工作站id获取报工产出
     *
     * @param productOutputDTO productOutputDTO
     * @return R
     */
    @Inner(false)
    @ApiOperation(value = "工作站id获取报工产出", notes = "工作站id获取报工产出")
    @GetMapping("/getProductOut")
    public R getProductOut(Page page, ProductOutputDTO productOutputDTO) {
        Long id = productOutputDTO.getWorkstationId();
        productOutputDTO.setWorkstationId(null);
        return R.ok(productMainService.getProductOut(page, QueryWrapperUtil.gen(productOutputDTO), id));
    }
 
    /**
     * 根据工单id获取绑定的工序的工步
     *
     * @param id
     * @return R
     */
    @ApiOperation(value = "根据工单id获取绑定的工序的工步", notes = "根据工单id获取绑定的工序的工步")
    @GetMapping("/getStep/{id}")
    public R getStep(@PathVariable Long id) {
        return R.ok(productMainService.getStep(id));
    }
 
    /**
     * 根据工单id获取已经绑定的工步
     *
     * @param id
     * @return R
     */
    @ApiOperation(value = "根据工单id获取已经绑定的工步", notes = "根据工单id获取已经绑定的工步")
    @GetMapping("/getProductStep/{id}")
    public R getProductStep(@PathVariable Long id) {
        return R.ok(productMainService.getProductStep(id));
    }
 
 
    /**
     * 根据工单id和sn号获取已经绑定的工步
     *
     * @param id
     * @return R
     */
    @ApiOperation(value = "根据工单id和sn号获取已经绑定的工步", notes = "根据工单id和sn号获取已经绑定的工步")
    @GetMapping("/getProductStepBySn")
    public R getProductStepBySn(@RequestParam("id")Long id,@RequestParam("sn")String sn) {
        return R.ok(productMainService.getProductStepBySn(id,sn));
    }
 
    /**
     * 根据工步记录id,查询出工步记录的所有信息
     *
     * @param id
     * @return R
     */
    @ApiOperation(value = "根据工步记录id,查询出工步记录的所有信息", notes = "根据工步记录id,查询出工步记录的所有信息")
    @GetMapping("/getAllProductStep/{id}")
    public R getAllProductStep(@PathVariable Long id) {
        return R.ok(productMainService.getAllProductStep(id));
    }
 
    /**
     * 根据报工主表id获取投入产出明细
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "根据报工主表id获取投入产出明细", notes = "根据报工主表id获取投入产出明细")
    @GetMapping("/getProductMain/{id}")
    public R getProductMainById(@PathVariable Long id) {
        return R.ok(productMainService.getProductMainById(id));
    }
 
    /**
     * 根据产出id获取产出明细
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "根据产出id获取产出明细", notes = "根据产出id获取产出明细")
    @GetMapping("/getProductMain/productOutPut/{id}")
    public R getProductOutPutById(@PathVariable Long id) {
        return R.ok(productMainService.getProductOutPutById(id));
    }
 
    /**
     * 分页查询
     *
     * @param page        分页对象
     * @param productMain 报工主表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    public R getProductMainPage(Page page, ProductMain productMain) {
        return R.ok(productMainService.page(page, Wrappers.query(productMain)));
    }
 
    /**
     * 根据id取消报工
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "根据id取消报工", notes = "根据id取消报工")
    @DeleteMapping("/cancelProductMainById/{id}")
    public R cancelProductMainById(@PathVariable Long id) {
        return R.ok(productMainService.cancelProductMainById(id));
    }
 
    /**
     * 批量取消报工
     *
     * @param ids ids
     * @return R
     */
    @ApiOperation(value = "批量取消报工", notes = "批量取消报工")
    @DeleteMapping("/batchCancelProductMain")
    public R batchCancelProductMain(@RequestBody List<Long> ids) {
        return R.ok(productMainService.batchCancelProductMain(ids));
    }
 
    /**
     * 新增产出
     *
     * @param productMainDTO 报工产出
     * @return R
     */
    @ApiOperation(value = "新增产出", notes = "新增产出")
    @PostMapping("/saveProductOutput")
    public R saveProductOutput(@RequestBody ProductMainDTO productMainDTO) {
        return R.ok(productMainService.saveProductOutput(productMainDTO));
    }
 
 
    /**
     * 批量新增产出 用于拉丝 复绕等工序产出 一对多 这种报工产出的填写
     *
     * @param productMainDTO 批量产出
     * @return R
     */
    @ApiOperation(value = "批量新增产出", notes = "批量新增产出")
    @PostMapping("/batchSaveProductOutput")
    public R batchSaveProductOutput(@RequestBody ProductMainDTO productMainDTO) {
        return R.ok(productMainService.batchSaveProductOutput(productMainDTO));
    }
 
    /**
     * 批量报工
     *
     * @param productMainDTO
     * @return
     */
    @ApiOperation(value = "批量报工", notes = "批量报工")
    @PostMapping("/batchSaveProductMain")
    public R batchSaveProductMain(@RequestBody List<ProductMainDTO> productMainDTOList) {
        return R.ok(productMainService.batchSaveProductMain(productMainDTOList));
    }
 
    /**
     * 报工校验投料是否充足
     * @param productMainDTOList
     * @return
     */
    @ApiOperation(value = "检验投料是否充足", notes = "检验投料是否充足")
    @PostMapping("/validateOverFeed")
    public R validateOverFeed(@RequestBody List<ProductMainDTO> productMainDTOList) {
        return productMainService.validateOverFeed(productMainDTOList);
    }
 
    @ApiOperation(value = "校验报工产量是否超出工单计划数量", notes = "校验报工产量是否超过工单计划数量")
    @PostMapping("/validateOverProduction")
    public R validateOverProduction(@RequestBody List<ProductMainDTO> productMainDTOList) {
        return productMainService.validateOverProduction(productMainDTOList);
    }
 
    @ApiOperation(value = "校验提交密码", notes = "校验提交密码")
    @PostMapping("/checkSubmitPassword")
    public R checkSubmitPassword(String password) {
        return R.ok(StringUtils.equals(productOutputSubmitConfig.getSubmitPassword(), password));
    }
 
 
    @ApiOperation(value = "校验零件是否为原材料", notes = "校验零件是否为原材料")
    @PostMapping("/checkRawPart")
    public R checkRawPart(@RequestBody List<String> partNoList) {
        return productMainService.checkRawPart(partNoList);
    }
    /**
     * 批量更新报工
     *
     * @param productMainDTOList
     * @return
     */
    @ApiOperation(value = "批量更新报工", notes = "批量更新报工")
    @PutMapping("/batchUpdateProductMain")
    public R batchUpdateProductMain(@RequestBody List<ProductMainDTO> productMainDTOList) {
        return R.ok(productMainService.batchUpdateProductMain(productMainDTOList));
    }
 
    /**
     * 新增或修改工步信息
     *
     * @param productStepDTO 工步
     * @param productStepDTO 工步
     * @return R
     */
    @ApiOperation(value = "新增或修改工步信息", notes = "新增或修改工步信息")
    @PostMapping("/addOrUpdateStep")
    public R addOrUpdateStep(@RequestBody ProductStepDTO productStepDTO) {
        return R.ok(productMainService.addOrUpdateStep(productStepDTO));
    }
 
    /**
     * @param id
     * @param event
     * @return
     */
    @ApiOperation(value = "更改状态", notes = "更改状态")
    @SysLog("更改状态")
    @PostMapping("/state/{id}/{event}")
    public R changeState(@PathVariable Long id, @PathVariable String event) {
        return productMainService.changeState(id, event);
    }
 
    @ApiOperation(value = "更新报工单状态为处理中", notes = "更新报工单状态为处理中")
    @PostMapping("/state/process")
    public R process(@RequestBody List<Long> ids) {
        return productMainService.process(ids);
    }
 
    /**
     * 批量更改报工单状态
     *
     * @param ids
     * @param event
     * @return
     */
    @ApiOperation(value = "批量更改报工单状态", notes = "批量更改报工单状态")
    @SysLog("批量更改报工单状态")
    @PostMapping("/state/batchChange/{event}")
    public R batchChange(@RequestBody List<Long> ids, @PathVariable String event) {
        return R.ok(this.productMainService.batchChange(ids, event));
    }
 
    /**
     * 更新产出
     *
     * @param productMainDTO 报工产出
     * @return R
     */
    @ApiOperation(value = "更新产出", notes = "更新产出")
    @PostMapping("/updateProductOutput")
    public R updateProductOutput(@RequestBody ProductMainDTO productMainDTO) {
        return R.ok(productMainService.updateProductOutput(productMainDTO));
    }
 
    /**
     * 根据产出id删除产出
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "根据产出id删除产出", notes = "根据产出id删除产出")
    @DeleteMapping("/deleteProductOutputById/{id}")
    public R deleteProductOutputById(@PathVariable Long id) {
        return R.ok(productMainService.deleteProductOutputById(id));
    }
 
    /**
     * 根据产出ids删除产出
     *
     * @param ids id
     * @return R
     */
    @ApiOperation(value = "批量删除产出", notes = "批量删除删除产出")
    @PostMapping("/deleteProductOutputByIds")
    public R deleteProductOutputByIds(@RequestBody List<Long> ids) {
        return R.ok(productMainService.deleteProductOutputByIds(ids));
    }
 
 
    /**
     * 查询交班产出
     *
     * @param workstationId   工作站id
     * @param opeartionTaskId 工单id
     * @return
     */
    @ApiOperation(value = "查询交班产出", notes = "查询交班产出")
    @GetMapping("/getShiftProductOutByOpIdAndWsId/{workstationId}/{opeartionTaskId}")
    public R getShiftProductOutByOpIdAndWsId(@PathVariable Long workstationId, @PathVariable Long opeartionTaskId) {
        return R.ok(productMainService.getShiftedProductByWidAndOpId(workstationId, opeartionTaskId));
    }
 
    /**
     * 新增投入
     *
     * @param productInputDTO 报工投入
     * @return R
     */
    @ApiOperation(value = "新增投入", notes = "新增投入")
    @PostMapping("/saveProductInput")
    public R saveProductInput(@RequestBody ProductInputDTO productInputDTO) {
        return R.ok(productMainService.saveProductInput(productInputDTO));
    }
 
    /**
     * 更新投入
     *
     * @param productInput 报工投入
     * @return R
     */
    @ApiOperation(value = "更新投入", notes = "更新投入")
    @PostMapping("/updateProductInput")
    public R updateProductInput(@RequestBody ProductInput productInput) {
        return R.ok(productMainService.updateProductInput(productInput));
    }
 
    /**
     * 根据投入id删除投入
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "根据投入id删除投入", notes = "根据投入id删除投入")
    @DeleteMapping("/deleteProductInputById/{id}")
    public R deleteProductInputById(@PathVariable Long id) {
        return R.ok(productMainService.deleteProductInputById(id));
    }
 
    /**
     * 根据工步记录id,删除工步记录的所有信息
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "根据工步记录id,删除工步记录的所有信息", notes = "根据工步记录id,删除工步记录的所有信息")
    @DeleteMapping("/deleteProductStep/{id}")
    public R deleteProductStep(@PathVariable Long id) {
        return R.ok(productMainService.deleteProductStep(id));
    }
 
    /**
     * 分页查询生产进度
     *
     * @param page             分页
     * @param productOutputDTO 生产进度
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/getProductionProgress/page")
    public R getProductionProgress(Page page, ProductOutputDTO productOutputDTO) {
        return R.ok(productMainService.getProductionProgress(page, QueryWrapperUtil.gen(productOutputDTO)));
    }
 
    /**
     * 分页查询汇报产出
     *
     * @param page             分页
     * @param productOutputDTO 汇报产出
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/getOutputList")
    public R getOutputList(Page page, ProductOutputDTO productOutputDTO) {
        return R.ok(productMainService.getOutputList(page, QueryWrapperUtil.gen(productOutputDTO), productOutputDTO));
    }
 
    /**
     * 扫码产出列表
     *
     * @param productOutputDTO 扫码产出列表
     * @return
     */
    @ApiOperation(value = "扫码产出列表", notes = "扫码产出列表")
    @GetMapping("/getOutputListByScan")
    public R getOutputListByScan(ProductOutputDTO productOutputDTO) {
        return R.ok(productMainService.getOutputListByScan(productOutputDTO));
    }
 
    /**
     * @param productMain
     * @return
     */
    @GetMapping("/productMain")
    @Inner(value = false)
    public R loadProductMain(ProductMain productMain) {
        return R.ok(productMainService.list(Wrappers.query(productMain)));
    }
 
    /**
     * @param ids
     * @param event
     * @return
     */
    @ApiOperation(value = "更改报工产出状态", notes = "更改报工产出状态")
    @SysLog("更改报工产出状态")
    @PostMapping("/productOutPutState/{event}")
    public R changeProductOutPutState(@RequestBody List<Long> ids, @PathVariable String event) {
        return productMainService.changeProductOutPutState(ids, event);
    }
 
    /**
     * 根据报工单id交班或取消
     *
     * @param id
     * @param event
     * @return
     */
    @ApiOperation(value = "根据报工单id交班或取消", notes = "根据报工单id交班或取消")
    @SysLog("根据报工单id交班或取消")
    @PostMapping("/productOutPutStateByMainId/{id}/{event}")
    public R changeProductOutPutStateByMainId(@PathVariable Long id, @PathVariable String event) {
        return productMainService.changeProductOutPutStateByMainId(id, event);
    }
 
    /**
     * 获取打印url
     *
     * @param type 1 装备 2射频 3装备射频sn打印 4射频小页签打印
     * @param id
     * @return
     */
    @ApiOperation(value = "获取打印url", notes = "获取打印url")
    @GetMapping("/getPrintUrl")
    public R getPrintUrl(Integer type, Long id, String sn) {
        return R.ok(productMainService.getPrintUrl(type, id, sn));
    }
 
    /**
     * 根据报工id获取已经绑定的工步
     *
     * @param productStepDTO
     * @return R
     */
    @ApiOperation(value = "根据报工id获取已经绑定的工步", notes = "根据报工id获取已经绑定的工步")
    @GetMapping("/getProductStep")
    public R getProductStep(Page page, ProductStepDTO productStepDTO) {
        productStepDTO.setStaffId(null);
        return R.ok(productMainService.getProductStep(page, QueryWrapperUtil.gen(productStepDTO)));
    }
 
    /**
     * 判断投料是否足够
     *
     * @param productStepDTO 工步
     * @return R
     */
    @ApiOperation(value = "判断投料是否足够", notes = "判断投料是否足够")
    @PostMapping("/autoAddInput")
    public R judgeAddInput(@RequestBody ProductStepDTO productStepDTO) {
        return R.ok(productMainService.judgeAddInput(productStepDTO));
    }
 
    /**
     * 根据工单id获取生成的SN号
     *
     * @param operationTaskId
     * @return
     */
    @ApiOperation(value = "根据工单id获取生成的SN号", notes = "根据工单id获取生成的SN号")
    @GetMapping("/getGenerateSN")
    public R getGenerateSN(Long operationTaskId) {
        return R.ok(productMainService.getGenerateSN(operationTaskId));
    }
 
 
    /**
     * 根据客户订单号查询段产搞的productSns
     *
     * @param customerOrderNo
     * @return
     */
    @ApiOperation(value = "根据客户订单号查询段产搞的productSns", notes = "根据客户订单号查询段产搞的productSns")
    @GetMapping("/getGenerateSnByCustomerOrderNo")
    public R getGenerateSnByCustomerOrderNo(String customerOrderNo) {
        return R.ok(productMainService.getGenerateSnByCustomerOrderNo(customerOrderNo));
    }
 
    /**
     * 导出
     *
     * @param operationTaskId 上班记录-人工明细
     * @return
     */
    @ApiOperation(value = "导出", notes = "导出")
    @Inner(false)
    @PostMapping("/exportProductOutPut")
    public void exportProductOutPut(HttpServletResponse response, Long operationTaskId, Long workstationId) throws IOException {
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("UTF-8");
        // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
        String fileName = URLEncoder.encode("报工产出", "UTF-8");
        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xls");
        try {
            //新建ExcelWriter
            ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build();
            //获取sheet0对象
            WriteSheet mainSheet = EasyExcel.writerSheet(0, "报工产出").head(ProductOutPutData.class).build();
            //向sheet0写入数据 传入空list这样只导出表头
            excelWriter.write(productMainService.exportList(operationTaskId, workstationId), mainSheet);
            //关闭流
            excelWriter.finish();
        } catch (IOException e) {
            throw new RuntimeException("导出失败");
        }
    }
 
    @ApiOperation(value = "根据工单查找SN号", notes = "根据工单查找SN号")
    @GetMapping("/getSNByTaskId")
    public R getSNByTaskId(Long taskId){
        String SN = productMainService.getSNByTaskId(taskId);
        if (StringUtils.isNotBlank(SN)) {
            long count = productMainService.getOutputByBatchNo(SN);
            if (count > 0) {
                return R.failed(SN + "已有产出,无法再次产出");
            } else {
                return R.ok(SN);
            }
        } else {
            return R.ok();
        }
    }
 
    @ApiOperation(value = "多次批量标签打印", notes = "多次批量标签打印")
    @GetMapping("/batchLabelPrintTimes")
    public R batchLabelPrintTimes(@RequestParam("ids") List<Long> ids) {
        return R.ok(productMainService.batchLabelPrintTimes(ids));
    }
 
    @ApiOperation(value = "批量标签打印check", notes = "批量标签打印check")
    @GetMapping("/checkBatchLabelPrint")
    public R checkBatchLabelPrint(@RequestParam("ids") List<Long> ids,@RequestParam("isSubmit") Boolean isSubmit){
        return R.ok(productMainService.checkBatchLabelPrint(ids,isSubmit));
    }
 
    @ApiOperation(value = "批量标签打印密码校验", notes = "批量标签打印密码校验")
    @GetMapping("/checkLabelPrintPassword")
    public R checkLabelPrintPassword(@RequestParam("password")String password,@RequestParam("ids") List<Long> ids,@RequestParam("isSubmit") Boolean isSubmit) {
        return productMainService.checkLabelPrintPassword(password,ids,isSubmit);
    }
 
    @ApiOperation(value = "批量更新打印次数", notes = "批量更新打印次数")
    @GetMapping("/updatePrintNum")
    public R updatePrintNum(@RequestParam("ids") List<Long> ids) {
        return productMainService.updatePrintNum(ids);
    }
 
 
    @ApiOperation(value = "批量标签打印", notes = "批量标签打印")
    @GetMapping("/batchLabelPrint")
    @Inner(false)
    public R batchLabelPrint(@RequestParam("ids") List<Long> ids) {
        return R.ok(productMainService.batchLabelPrint(ids));
    }
 
    @ApiOperation(value = "根据销售订单号查找零件", notes = "根据销售订单号查找零件")
    @GetMapping("/getPartNamesByOrderNo")
    public R getPartNamesByOrderNo(String customerOrderNo) {
        return R.ok(productMainService.getPartNamesByOrderNo(customerOrderNo));
    }
 
    @ApiOperation(value = "根据销售订单号和零件名称查找成品sn", notes = "根据销售订单号和零件名称查找成品sn")
    @GetMapping("/getProductSnByCustomerNoAndPartName")
    public R getProductSnByCustomerNoAndPartName(String customerOrderNo, String partName){
        return R.ok(productMainService.getProductSnByCustomerNoAndPartName(customerOrderNo, partName));
    }
 
    @ApiOperation(value = "校验当前工单是否是最后一道工序工单", notes = "校验当前工单是否是最后一道工序工单")
    @GetMapping("/validateIsLastOperation/{id}")
    public R validateIsLastOperation(@PathVariable Long id) {
        return R.ok(productMainService.validateIsLastOperation(id));
    }
 
    @ApiOperation(value = "校验是否是交班后产出", notes = "校验是否是交班后产出")
    @PostMapping("/validateChangeProductOut")
    public R validateChangeProductOut(@RequestBody List<ProductOutput> list) {
        return R.ok(productMainService.validateChangeProductOut(list));
    }
 
 
    @ApiOperation(value = "报工单状态重置为草稿", notes = "报工单状态重置为草稿")
    @PostMapping("/resetState")
    @PreAuthorize("@pms.hasPermission('product_state_reset')")
    public R resetState(@RequestBody List<Long> ids) {
        return R.ok(productMainService.resetState(ids));
    }
 
 
    @ApiOperation(value = "获取草稿状态的报工产出", notes = "获取草稿状态的报工产出")
    @GetMapping("/getDraftProductOut/{id}")
    public R getDraftProductOut(@PathVariable Long id) {
        return R.ok(productMainService.getDraftProductOut(id));
    }
 
    @ApiOperation(value = "校验工步是否完成", notes = "校验工步是否完成")
    @GetMapping("/validateStepFinish/{outBatchNo}")
    public R validateStepFinish(@PathVariable String outBatchNo) {
        return R.ok(productMainService.validateStepFinish(outBatchNo));
    }
 
    @ApiOperation(value = "新增库存新增SN号校重", notes = "新增库存新增SN号校重")
    @PostMapping("/checkSn")
    public R checkSn(@RequestBody StockDTO stockDTO) {
        return R.ok(productMainService.checkSn(stockDTO));
    }
 
}