zouyu
2023-11-15 27879ae8c1df7ff014858456b17996cf62d34f9b
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
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
/*
 *    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.plan.controller;
 
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.plan.dto.*;
import com.chinaztt.mes.plan.entity.CustomerOrder;
import com.chinaztt.mes.plan.entity.MoTestStandardParam;
import com.chinaztt.mes.plan.service.*;
import com.chinaztt.mes.quality.dto.CustomOrderSyncDTO;
import com.chinaztt.mes.quality.entity.TestStandardParam;
import com.chinaztt.mes.quality.service.TestStandardParamService;
import com.chinaztt.mes.technology.service.BomService;
import com.chinaztt.mes.technology.service.DocumentService;
import com.chinaztt.mes.technology.service.RoutingService;
import com.chinaztt.mes.warehouse.dto.PackagingDTO;
import com.chinaztt.ztt.admin.api.entity.SysDictItem;
import com.chinaztt.ztt.common.core.constant.CacheConstants;
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.xxl.job.core.handler.annotation.XxlJob;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
 
 
/**
 * 客户订单表
 *
 * @author cxf
 * @date 2020-09-14 16:35:26
 */
@RestController
@AllArgsConstructor
@RequestMapping("/plan/customerOrder")
@Api(value = "customerOrder", tags = "客户订单表管理")
@Slf4j
public class CustomerOrderController {
 
    private final CustomerOrderService customerOrderService;
 
    private final ProcessConfigService processConfigService;
 
    private final BomService bomService;
 
    private final RoutingService routingService;
 
    private final DocumentService documentService;
 
    private final MoTestStandardService moTestStandardService;
 
    private final MoTestStandardParamService moTestStandardParamService;
 
    private final TestStandardParamService testStandardParamService;
 
    private final SysDictItemService sysDictItemService;
 
    /**
     * 分页查询
     *
     * @param page              分页对象
     * @param planCustomerOrder 客户订单表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page/{type}")
    public R getCustomerOrderPage(Page page, CustomerOrderDTO planCustomerOrder, @PathVariable("type") String type) {
        return R.ok(customerOrderService.getCustomerOrderPage(page, QueryWrapperUtil.gen(planCustomerOrder), type));
    }
 
    /**
     * 对接志邦国际鹰联 erp 同步合同
     *
     * @param customOrderSyncDTO
     * @return
     */
    @ApiOperation(value = "同步销售订单", notes = "同步销售订单")
    @PostMapping("/syncOrder")
    @XxlJob("syncOrder")
    public R syncOrder(@RequestBody CustomOrderSyncDTO customOrderSyncDTO) {
        return R.ok("共更新" + customerOrderService.syncOrder(customOrderSyncDTO) + "条数据");
    }
 
    /**
     * 对接志邦国际鹰联 erp
     *
     * @param contractNo
     * @return
     */
    @ApiOperation(value = "通过合同编码作废", notes = "通过合同编码作废")
    @GetMapping("/dropByContractNo/{contractNo}")
    public R dropByContractNo(@PathVariable("contractNo") String contractNo) {
        customerOrderService.dropByContractNo(contractNo);
        return R.ok();
    }
 
    /**
     * 通过id查询客户订单表
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public R getById(@PathVariable("id") Long id) {
        return R.ok(customerOrderService.getCustomerOrderById(id));
    }
 
    /**
     * 新增客户订单表
     *
     * @param planCustomerOrder 客户订单表
     * @return R
     */
    @ApiOperation(value = "新增客户订单表", notes = "新增客户订单表")
    @SysLog("新增客户订单表")
    @PostMapping
    public R save(@RequestBody CustomerOrder planCustomerOrder) {
        // 添加订单编号唯一验证
        CustomerOrder customerOrderByFind = customerOrderService.getOne(Wrappers.<CustomerOrder>lambdaQuery().eq(CustomerOrder::getCustomerOrderNo, planCustomerOrder.getCustomerOrderNo()), false);
        if (customerOrderByFind != null) {
            throw new RuntimeException("客户订单号重复:" + customerOrderByFind.getCustomerOrderNo());
        }
        return R.ok(customerOrderService.save(planCustomerOrder));
    }
 
    /**
     * 修改客户订单表
     *
     * @param customerOrderDTO 客户订单表
     * @return R
     */
    @ApiOperation(value = "修改客户订单表", notes = "修改客户订单表")
    @SysLog("修改客户订单表")
    @PutMapping
    public R updateById(@RequestBody CustomerOrderDTO customerOrderDTO) {
        return customerOrderService.fullUpdate(customerOrderDTO);
    }
 
    /**
     * 批量修改销售件
     *
     * @param
     * @return R
     */
    @ApiOperation(value = "批量修改销售件", notes = "批量修改销售件")
    @SysLog("批量修改销售件")
    @PostMapping("/batchUpdateSalePartNo")
    public R batchUpdateSalePartNo(@RequestBody CustomerOrderDTO customerOrderDTO) {
        return R.ok(customerOrderService.batchUpdateSalePartNo(customerOrderDTO));
    }
 
 
    /**
     * 通过id删除客户订单表
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除客户订单表", notes = "通过id删除客户订单表")
    @SysLog("通过id删除客户订单表")
    @DeleteMapping("/{id}")
    public R removeById(@PathVariable Long id) {
        return R.ok(customerOrderService.removeById(id));
    }
 
    /**
     * Description: 创建主生产计划
     *
     * @param: customerOrderDTO
     * @return: R
     */
    @ApiOperation(value = "创建主生产计划", notes = "创建主生产计划")
    @PostMapping("/createMasterProductionSchedule")
    public R createMasterProductionSchedule(@RequestBody List<CustomerOrderDTO> customerOrderDTO) {
        return R.ok(customerOrderService.createMasterProductionSchedule(customerOrderDTO));
    }
 
    /**
     * Description: 创建主生产计划前校验
     *
     * @param: customerOrderDTO
     * @return: R
     */
    @ApiOperation(value = "创建主生产计划前校验", notes = "创建主生产计划前校验")
    @PostMapping("/createScheduleCheck")
    public R createScheduleCheck(@RequestBody List<CustomerOrderDTO> customerOrderDTO) {
        return customerOrderService.createScheduleCheck(customerOrderDTO);
    }
 
    /**
     * 创建主生产计划需求
     *
     * @param mpsRequirements 主生产计划需求
     * @return R
     */
    @ApiOperation(value = "创建主生产计划需求", notes = "创建主生产计划需求")
    @SysLog("创建主生产计划需求")
    @PostMapping("/createMpsRequirements")
    public R createMpsRequirements(@RequestBody List<MpsRequirementsDTO> mpsRequirements) {
        return R.ok(customerOrderService.createMpsRequirements(mpsRequirements));
    }
 
 
    /**
     * Description: 绑定工艺文件
     *
     * @param: mpsRequirementsDTOList
     * @return: R
     */
    @ApiOperation(value = "绑定工艺文件", notes = "绑定工艺文件")
    @PostMapping("/handleDocument/{docId}")
    public R handleDocument(@RequestBody List<Long> ids, @PathVariable Long docId) {
        return customerOrderService.handleDocument(ids, docId);
    }
 
    /**
     * Description: 取消关联工艺文件
     *
     * @param: mpsRequirementsDTOList
     * @return: R
     */
    @ApiOperation(value = "取消绑定工艺文件", notes = "取消绑定工艺文件")
    @PostMapping("/rejectHandleDocument")
    public R rejectHandleDocument(@RequestBody List<Long> ids) {
        return customerOrderService.rejectHandleDocument(ids);
    }
 
    /**
     * 手动修改审核状态
     *
     * @param ids     id
     * @param isAudit 状态
     * @return
     */
    @ApiOperation(value = "状态修改", notes = "状态修改")
    @PostMapping("/changeAudit/{isAudit}")
    public R changeAudit(@RequestBody List<Long> ids, @PathVariable("isAudit") String isAudit) {
        return R.ok(customerOrderService.changeCheckState(ids, isAudit));
    }
 
    /**
     * 标记已计划
     *
     * @param ids
     * @return R
     */
    @ApiOperation(value = "标记已计划", notes = "标记已计划")
    @SysLog("标记已计划")
    @PostMapping("/markPlanned/{coState}")
    public R changeMarkPlanned(@RequestBody List<Long> ids, @PathVariable("coState") String coState) {
        return R.ok(customerOrderService.changeMarkPlanned(ids, coState));
    }
 
    /**
     * @param response
     * @param customerOrderExportDTO
     * @throws IOException
     */
    @GetMapping("/exportCustomerOrderSplit")
    public void export(HttpServletResponse response, CustomerOrderExportDTO customerOrderExportDTO) throws IOException {
        customerOrderService.exportCustomerOrderSplit(response, customerOrderExportDTO);
    }
 
    /**
     * 校验箱码和SN对应销售订单是否一致
     */
    @ApiOperation(value = "根据箱码和SN校验对应销售订单是否一致", notes = "根据箱码和SN校验对应销售订单是否一致")
    @PostMapping("/validatePackageCodeSnCustomerOrder")
    public R validatePackageCodeSnCustomerOrder(@RequestBody PackagingDTO packagingDTO) {
        return R.ok(customerOrderService.validatePackageCodeSnCustomerOrder(packagingDTO));
    }
 
    /**
     * 同步otc订单数据
     *
     * @param selectTime 选择日期,查询该日期后至当前时间的数据
     * @param orderNo   订单编号
     * @return
     */
    @GetMapping("/otcCustomerOrderSync")
    public R otcCustomerOrderSync(@RequestParam("selectTime") String selectTime, @RequestParam("orderNo") String orderNo) {
        return customerOrderService.otcCustomerOrderSync(selectTime, orderNo);
    }
 
 
    /**
     * 更新订单行说明
     *
     * @param customerOrder
     * @return
     */
    @ApiOperation(value = "更新订单行说明", notes = "更新订单行说明")
    @SysLog("更新订单行说明")
    @PostMapping("/updateOrderDescription")
    public R updateOrderDescription(@RequestBody CustomerOrderDTO customerOrder) {
        return R.ok(customerOrderService.updateOrderDescription(customerOrder));
    }
 
    /**
     * 自动同步otc订单数据用于定时任务
     *
     * @return
     */
    @GetMapping("/otcCustomerOrderSyncAuto")
    @XxlJob("otcCustomerOrderSyncAutoHandler")
    public R otcCustomerOrderSyncAuto() {
        return customerOrderService.otcCustomerOrderSyncAuto();
    }
 
    /**
     * 查询库存件
     *
     * @param salesPartDTO
     * @return
     */
    @ApiOperation(value = "查询库存件", notes = "查询库存件")
    @SysLog("查询库存件")
    @PostMapping("/querySalesPartStd")
    public R querySalesPartStd(@RequestBody SalesPartDTO salesPartDTO) {
        return customerOrderService.querySalesPartStd(salesPartDTO);
    }
 
    /**
     * 同步ifs行和交货数据
     *
     * @param ids
     * @return R
     */
    @ApiOperation(value = "同步ifs行和交货数据", notes = "同步ifs行和交货数据")
    @SysLog("同步ifs行和交货数据")
    @PostMapping("/syncIfsLineNo")
    public R syncIfsLineNo(@RequestBody List<Long> ids) {
        return customerOrderService.syncIfsLineNo(ids);
    }
 
    /**
     * 自动同步ifs行和交货数据 用于定时任务
     *
     * @return R
     */
    @ApiOperation(value = "自动同步ifs行和交货数据", notes = "自动同步ifs行和交货数据")
    @SysLog("同步ifs行和交货数据")
    @PostMapping("/syncIfsLineNoAuto")
    public R syncIfsLineNoAuto() {
        return customerOrderService.syncIfsLineNoAuto();
    }
 
    /**
     * OA对接
     *
     * @param ids
     */
    @PostMapping("/oa")
    public R oa(@RequestBody List<Long> ids) {
        return R.ok().setMsg(customerOrderService.oa(ids));
    }
 
    /**
     * 零件推送到otc
     *
     * @param ids
     */
    @PostMapping("/pushotc")
    public R pushotc(@RequestBody List<Long> ids, @RequestParam("pathCode") String pathCode) {
        return R.ok(customerOrderService.pushotc(ids, pathCode));
    }
 
 
    /**
     * 下载附件
     *
     * @param id
     * @param response
     */
    @GetMapping("/otcDownload/{id}")
    public void otcDownload(@PathVariable Long id, HttpServletResponse response) {
        customerOrderService.otcDownload(id, response);
    }
 
 
    /**
     * @param orderNumber
     * @return
     */
    @GetMapping("getOtcCustomerOrderFileList")
    public R getOtcFiles(String orderNumber) {
        return customerOrderService.getOtcCustomerOrderFileList(orderNumber);
    }
 
 
    /**
     * 导出
     *
     * @return
     */
    @ApiOperation(value = "导出", notes = "导出")
    @GetMapping("/export")
    public void export(HttpServletResponse response, CustomerOrderDTO planCustomerOrder) throws IOException {
        customerOrderService.export(response, QueryWrapperUtil.gen(planCustomerOrder));
    }
 
    /**
     * 零件属性查询
     *
     * @return
     */
    @ApiOperation(value = "零件属性查询", notes = "零件属性查询")
    @GetMapping("/queryPartPropertiesStd")
    public R queryPartPropertiesStd(String key, String value) {
        return R.ok(customerOrderService.queryPartPropertiesStd(key, value));
    }
 
    /**
     * @param file
     * @param orderNumber
     * @param lineNumber
     * @return
     */
    @PostMapping("/upload")
    @ApiOperation(value = "上传附件", notes = "上传附件")
    public R upload(@RequestParam("file") MultipartFile file,
                    @RequestParam("orderNumber") String orderNumber,
                    @RequestParam("lineNumber") String lineNumber) {
        return customerOrderService.uploadProcessConfigFile(file, orderNumber, lineNumber);
    }
 
    /**
     * @param orderNumber
     * @param lineNumber
     * @return
     */
    @GetMapping("/processConfigFiles")
    @ApiOperation("获取附件上传记录")
    @Inner(false)
    public R processConfigFiles(String orderNumber, String lineNumber) {
        try {
            orderNumber = URLDecoder.decode(orderNumber, StandardCharsets.UTF_8.name());
            return R.ok(customerOrderService.getProcessConfigFiles(orderNumber, lineNumber));
        } catch (UnsupportedEncodingException e) {
            return R.failed(e.getMessage());
        }
    }
 
    //@PostMapping("/updateRange")
    //@ApiOperation("修改工艺配置单适用范围")
    // public R updateRange(@RequestBody OrderProcessConfigFileDTO configFileDTO){
    //    return R.ok(customerOrderService.updateRange(configFileDTO.getId()    , configFileDTO.getEffectiveRange()));
    //}
 
    /**
     * @param fileAssociatedOrderDTO
     * @return
     */
    @PostMapping("/fileAssociatedOrder")
    @ApiOperation("工艺配置单关联销售订单")
    public R fileAssociatedOrder(@RequestBody FileAssociatedOrderDTO fileAssociatedOrderDTO) {
        return R.ok(customerOrderService.fileAssociatedOrder(fileAssociatedOrderDTO));
    }
 
    /**
     * @param id
     * @return
     */
    @GetMapping("/processConfigMapping")
    @ApiOperation("获取当前工艺配置单适用销售订单")
    public R processConfigMapping(@RequestParam("id") Long id) {
        return R.ok(customerOrderService.processConfigMapping(id));
    }
 
    /**
     * @param bucket
     * @param fileName
     * @param response
     */
    @PostMapping("/processConfig/{bucket}/{fileName}")
    @Inner(false)
    public void file(@PathVariable String bucket, @PathVariable String fileName, HttpServletResponse response) {
        customerOrderService.getFile(bucket, fileName, response);
    }
 
    /**
     * @param id
     * @return
     */
    @DeleteMapping("/processConfigFile/{id}")
    public R processConfigFile(@PathVariable Long id) {
        return customerOrderService.deleteProcessConfigFile(id);
    }
 
    /**
     * 新工艺配置单批量新增(接口停用)
     *
     * @param processConfigDTO
     * @return R
     */
    @ApiOperation(value = "新工艺配置单批量新增(接口停用)", notes = "新工艺配置单批量新增(接口停用)")
    @SysLog("新工艺配置单批量新增(接口停用)")
    @PostMapping("/processConfig")
    public R saveProcessConfig(@RequestBody ProcessConfigDTO processConfigDTO) {
        return R.ok(processConfigService.fullSave(processConfigDTO));
    }
 
 
    /**
     * 新工艺配置单单条新增
     *
     * @param processConfigDTO
     * @return R
     */
    @ApiOperation(value = "新工艺配置单单条新增", notes = "新工艺配置单单条新增")
    @SysLog("新工艺配置单单条新增")
    @PostMapping("/oneProcessConfig")
    public R saveOneProcessConfig(@RequestBody ProcessConfigDTO processConfigDTO) {
        return R.ok(processConfigService.saveOneProcessConfig(processConfigDTO));
    }
 
 
    /**
     * 新工艺配置单单条编辑
     *
     * @param processConfigDTO
     * @return R
     */
    @ApiOperation(value = "新工艺配置单单条编辑", notes = "新工艺配置单单条编辑")
    @SysLog("新工艺配置单单条编辑")
    @PutMapping("/oneProcessConfig")
    public R updateOneProcessConfig(@RequestBody ProcessConfigDTO processConfigDTO) {
        return R.ok(processConfigService.updateById(processConfigDTO));
    }
 
    /**
     * 新工艺配置单应用至所选订单行
     *
     * @param processConfigDTO
     * @return R
     */
    @ApiOperation(value = "新工艺配置单应用至所选订单行", notes = "新工艺配置单应用至所选订单行")
    @SysLog("新工艺配置单应用至所选订单行")
    @PutMapping("/processConfig")
    public R updateProcessConfig(@RequestBody ProcessConfigDTO processConfigDTO) {
        return R.ok(processConfigService.updateBatch(processConfigDTO));
    }
 
    /**
     * 新工艺配置单删除
     *
     * @param id
     * @return R
     */
    @ApiOperation(value = "新工艺配置单删除", notes = "新工艺配置单删除")
    @SysLog("新工艺配置单删除")
    @DeleteMapping("/processConfig/{id}")
    public R deleteProcessConfig(@PathVariable Long id) {
        return R.ok(processConfigService.deleteById(id));
    }
 
    /**
     * 通过订单编号和行号查询工艺配置单
     *
     * @param orderNo
     * @param otcLineNo
     * @return R
     */
    @ApiOperation(value = "通过订单编号和行号查询工艺配置单", notes = "通过订单编号和行号查询工艺配置单")
    @SysLog("通过订单编号和行号查询工艺配置单")
    @GetMapping("/processConfig/getByOrderNoAndOtcNo")
    @Inner(value = false)
    public R getByOrderNoAndOtcNo(@RequestParam("orderNo") String orderNo, @RequestParam("otcLineNo") String otcLineNo) {
        try {
            orderNo = URLDecoder.decode(orderNo, StandardCharsets.UTF_8.name());
            return R.ok(processConfigService.getByOrderNoAndOtcNo(orderNo, otcLineNo));
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }
 
    /**
     * 通过销售订单id查询工艺配置单
     *
     * @param id
     * @return R
     */
    @ApiOperation(value = "通过销售订单id查询工艺配置单", notes = "通过销售订单id查询工艺配置单")
    @SysLog("通过销售订单id查询工艺配置单")
    @GetMapping("/processConfig/{id}")
    public R getProcessConfigByOrderId(@PathVariable Long id) {
        return R.ok(processConfigService.getProcessConfig(id));
 
    }
 
    /**
     * 工艺配置单分页查询
     *
     * @param page             分页对象
     * @param processConfigDTO 工艺配置单
     * @return
     */
    @ApiOperation(value = "工艺配置单分页查询", notes = "工艺配置单分页查询")
    @GetMapping("/getProcessConfigPage")
    public R getProcessConfigPage(Page page, ProcessConfigDTO processConfigDTO) {
        return R.ok(processConfigService.getProcessConfigPage(page, QueryWrapperUtil.gen(processConfigDTO)));
    }
 
    /**
     * OA流程审核
     *
     * @param ids
     * @return
     */
    @ApiOperation(value = "OA流程审核", notes = "OA流程审核")
    @PostMapping("/checkOA")
    @Inner(false)
    public R checkOA(@RequestBody List<Long> ids) {
        return customerOrderService.checkOA(ids);
    }
 
    /**
     * 查询OA工艺详情页面
     *
     * @param ids
     * @return
     */
    @ApiOperation(value = "查询OA工艺详情页面", notes = "查询OA工艺详情页面")
    @PostMapping("OA/getOADetailDTO")
    @Inner(false)
    public R getOADetailDTOPage(@RequestBody List<Long> ids) {
        return R.ok(customerOrderService.getOADetailDTO(ids));
    }
 
    /**
     * 查询OA工艺附件
     *
     * @param customerOrderNo
     * @return
     */
    @ApiOperation(value = "查询OA工艺附件", notes = "查询OA工艺附件")
    @GetMapping("OA/getProcessConfigFiles")
    @Inner(false)
    public R getProcessConfigFiles(String customerOrderNo) {
        return customerOrderService.getProcessConfigFiles(customerOrderNo);
    }
 
    /**
     * 查询OA工艺结构
     *
     * @param technologyDocumentId
     * @return
     */
    @ApiOperation(value = "查询OA工艺结构", notes = "查询OA工艺结构")
    @GetMapping("OA/getTechnologyDocument")
    @Inner(false)
    public R getTechnologyDocument(Long technologyDocumentId) {
        return customerOrderService.getTechnologyDocument(technologyDocumentId);
    }
 
    /**
     * 查询OA工艺文件结构图
     *
     * @param technologyDocumentId
     * @return
     */
    @ApiOperation(value = "查询OA工艺文件结构图", notes = "查询OA工艺文件结构图")
    @GetMapping("OA/getDocumentJgt")
    @Inner(false)
    public R getDocumentJgt(Long technologyDocumentId) {
        return customerOrderService.getDocumentJgt(technologyDocumentId);
    }
 
 
    /**
     * 通过id查询完整bom树
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询完整bom树", notes = "通过id查询完整bom树")
    @GetMapping("OA/getBom/{id}")
    @Inner(false)
    public R getBomById(@PathVariable("id") Long id) {
        return R.ok(bomService.getBomDtoById(id));
    }
 
 
    /**
     * 通过id查询工序参数
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询工序参数", notes = "通过id查询工序参数")
    @GetMapping("OA/getRouting/{id}")
    @Inner(false)
    public R getRoutingById(@PathVariable("id") Long id) {
        return R.ok(routingService.getRoutingById(id));
    }
 
 
    /**
     * 查询模板与参数
     *
     * @param routingOperationId
     * @return
     */
    @ApiOperation(value = "查询模板与参数", notes = "查询模板与参数")
    @GetMapping("OA/templateAndParam/{routingOperationId}")
    @Inner(false)
    public R getOperationTemplateAndParam(@PathVariable Long routingOperationId) {
        return routingService.getOperationTemplateAndParam(routingOperationId);
    }
 
    /**
     * 根据工艺文件-工艺路线-工序id查询检测标准
     *
     * @param docBomId           工艺文件与BOM关系表id
     * @param routingOperationId 工艺工序id
     * @return
     */
    @ApiOperation(value = "根据工艺文件-工艺路线-查询检测标准", notes = "传参:工艺文件与BOM关系表id&工序id")
    @GetMapping("oa/qryDocTestStandard")
    @Inner(false)
    public R qryDocTestStandard(@RequestParam("docBomId") Long docBomId, @RequestParam("routingOperationId") Long
            routingOperationId) {
        return documentService.qryDocTestStandard(docBomId, routingOperationId);
    }
 
    /**
     * OA下载otc附件
     *
     * @param id
     * @param response
     */
    @ApiOperation(value = "OA下载otc附件", notes = "OA下载otc附件")
    @GetMapping("oa/otcDownload/{id}")
    @Inner(false)
    public void otcDownloadByOA(@PathVariable Long id, HttpServletResponse response) {
        customerOrderService.otcDownload(id, response);
    }
 
    /**
     * OA查询otc附件
     *
     * @param orderNumber
     * @return
     */
    @ApiOperation(value = "OA查询otc附件", notes = "OA查询otc附件")
    @GetMapping("oa/getOtcCustomerOrderFileList")
    @Inner(false)
    public R getOaOtcFiles(String orderNumber) {
        return customerOrderService.getOtcCustomerOrderFileList(orderNumber);
    }
 
    /**
     * 根据工艺id和工序id获取复制的检测标准
     *
     * @param manufacturingOrderDTO 制造订单表
     * @return
     */
    @ApiOperation(value = "根据工艺id和工序id获取复制的检测标准", notes = "根据工艺id和工序id获取复制的检测标准")
    @GetMapping("oa/getRoutingTestStandardList")
    @Inner(false)
    public R getRoutingTestStandardList(ManufacturingOrderDTO manufacturingOrderDTO) {
        return R.ok(moTestStandardService.getRoutingTestStandardList(manufacturingOrderDTO));
    }
 
    /**
     * 根据工序检测标准id获取检测标准参数
     *
     * @param moTestStandardParam 检测标准参数
     * @return
     */
    @ApiOperation(value = "根据工序检测标准id获取检测标准参数", notes = "根据工序检测标准id获取检测标准参数")
    @GetMapping("oa/getOperationTestStandardParam")
    @Inner(false)
    public R getOperationTestStandardParam(MoTestStandardParam moTestStandardParam) {
        return R.ok(moTestStandardParamService.list(Wrappers.query(moTestStandardParam).orderByAsc("index")));
    }
 
    /**
     * 查询
     *
     * @param testStandardParam 检测标准参数
     * @return
     */
    @ApiOperation(value = "查询", notes = "查询")
    @GetMapping("oa/testStandardParam/list")
    @Inner(false)
    public R getQualityTestStandardParamList(TestStandardParam testStandardParam) {
        return R.ok(testStandardParamService.list(QueryWrapperUtil.gen(testStandardParam)));
    }
 
    /**
     * 根据工艺文件-工艺路线-工序-检测标准id查询检测参数明细
     *
     * @param standardId 检测标准id
     * @return
     */
    @ApiOperation(value = "根据工艺文件-工艺路线-工序-查询检测参数明细", notes = "传参:检测标准id")
    @GetMapping("oa/qryDocTestStandardDetailsByStandardId")
    @Inner(false)
    public R qryDocTestStandardDetailsByStandardId(@RequestParam("standardId") Long standardId) {
        return documentService.qryDocTestStandardDetailsByStandardId(standardId);
    }
 
    /**
     * 通过字典类型查找字典
     *
     * @param type 类型
     * @return 同类型字典
     */
    @GetMapping("dict/type/{type}")
    @Cacheable(value = CacheConstants.DICT_DETAILS, key = "#type", unless = "#result.data.isEmpty()")
    @Inner(false)
    public R getDictByType(@PathVariable String type) {
        return R.ok(sysDictItemService.list(Wrappers.<SysDictItem>query().lambda().eq(SysDictItem::getType, type).orderByAsc(SysDictItem::getSort)));
    }
 
    /**
     * 销售订单行状态为零件待选,则发送消息
     */
    @GetMapping("sendWxMsgAuto")
    @XxlJob("sendWxMsgAutoHandler")
    public R sendWxMsgAuto() {
        customerOrderService.sendWxMsgAuto();
        return R.ok();
    }
 
    /**
     * 同步更新工艺配置单订单行待选列表
     *
     * @param customerOrderNo
     * @param id
     * @return R
     */
    @ApiOperation(value = "同步更新工艺配置单订单行待选列表", notes = "同步更新工艺配置单订单行待选列表")
    @SysLog("同步更新工艺配置单订单行待选列表")
    @GetMapping("/getBeSelectedLineNoList")
    public R getBeSelectedLineNoList(@RequestParam String customerOrderNo, @RequestParam Long id) {
        return R.ok(customerOrderService.getBeSelectedLineNoList(customerOrderNo, id));
 
    }
 
    /**
     * 订单退回
     */
    @ApiOperation(value = "订单退回", notes = "订单退回")
    @PostMapping("/returnOrder")
    @PreAuthorize("@pms.hasPermission('plan_customerorder_return')")
    public R returnOrder(@RequestBody CustomerOrderDTO customerOrderDTO) {
        return R.ok(customerOrderService.returnOrder(customerOrderDTO));
    }
 
    /**
     * 获取已审核的订单号
     *
     * @param customerOrderNo
     * @param page
     */
    @ApiOperation(value = "获取已审核的订单号", notes = "获取已审核的订单号")
    @GetMapping("/getAuditedOrderNoList")
    public R getAuditedOrderNoPage(String customerOrderNo, Page page) {
        return R.ok(customerOrderService.getAuditedOrderNoPage(customerOrderNo, page));
    }
}