yuxc
2023-12-04 d334ce7945bf6a1243927c3b778d14dd493e9918
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
package com.vci.ubcs.code.controller;
 
 
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vci.ubcs.code.applyjtcodeservice.vo.BaseModelVO;
import com.vci.ubcs.code.dto.*;
import com.vci.ubcs.code.dto.datapush.BaseModelDTO;
import com.vci.ubcs.code.service.MdmEngineService;
import com.vci.ubcs.code.service.MdmIOService;
import com.vci.ubcs.code.vo.pagemodel.*;
import com.vci.ubcs.flow.core.dto.FlowStatusDTO;
import com.vci.ubcs.starter.annotation.VciBusinessLog;
import com.vci.ubcs.starter.revision.model.BaseModel;
import com.vci.ubcs.starter.revision.model.TreeQueryObject;
import com.vci.ubcs.starter.util.LocalFileUtil;
import com.vci.ubcs.starter.util.SaveLogUtil;
import com.vci.ubcs.starter.web.pagemodel.*;
import com.vci.ubcs.starter.web.util.ControllerUtil;
import com.vci.ubcs.starter.web.util.LangBaseUtil;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.rmi.ServerException;
import java.util.*;
 
@RestController
//@AllArgsConstructor
@RequestMapping("/mdmEngineController")
@Api(value = "编码数据管理", tags = "编码数据管理")
public class MdmEngineController {
 
    /**
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(getClass());
    /**
     * 主数据引擎服务
     */
    @Autowired
    private MdmEngineService engineService;
    /**
     * 主数据导入导出服务
     */
    @Autowired
    private MdmIOService mdmIOService;
    /**
     * 日志保存工具类
     */
    @Autowired
    private SaveLogUtil saveLogUtil;
 
    /**
     * 下载批量申请的导入模板
     * @param codeClassifyOid 分类的主键
     * @param response 响应对象
     * @throws IOException 抛出异常
     */
    @GetMapping("/downloadImportExcel")
    @VciBusinessLog(operateName = "下载批量申请编码的导入模板")
    public void downloadImportExcel(String codeClassifyOid, HttpServletResponse response) throws IOException{
        String excelName = mdmIOService.createImportExcel(codeClassifyOid,false);
        try {
            ControllerUtil.writeFileToResponse(response,excelName);
        } catch (Throwable e) {
            //如果出错,把错误信息写到text
            String msg = LangBaseUtil.getErrorMsg(e);
            if(StringUtils.isBlank(msg)){
                msg = "未知错误";
            }
            ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null);
        }
    }
 
    /**
     * 下载批量申请的导入模板
     * @param codeClassifyOid 分类的主键
     * @param response 响应对象
     * @throws IOException 抛出异常
     */
    @GetMapping("/downloadExcelBatchEdit")
    @VciBusinessLog(operateName = "下载批量申请编码的导入模板")
    public void downloadImportExcelBatchEdit(String codeClassifyOid, HttpServletResponse response) throws IOException{
        String excelName = mdmIOService.downloadImportExcelBatchEdit(codeClassifyOid);
        try {
            ControllerUtil.writeFileToResponse(response,excelName);
        } catch (Throwable e) {
            //如果出错,把错误信息写到text
            String msg = LangBaseUtil.getErrorMsg(e);
            if(StringUtils.isBlank(msg)){
                msg = "未知错误";
            }
            ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null);
        }
    }
 
 
    /**
     * 导入批量编辑数据
     * @param codeClassifyOid 分类的主键
     * @param classifyAttr 分类路径使用的属性
     * @param file 文件的内容
     */
    @VciBusinessLog(operateName = "导入批量编辑数据")
    @PostMapping("/batchImportEdit")
    public R batchImportEdit(String codeClassifyOid, String classifyAttr,MultipartFile file,HttpServletResponse response) throws Throwable {
        String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + file.getOriginalFilename();
        File file1 = new File(excelFileName);
        try {
            file.transferTo(new File(excelFileName));
            CodeImProtRusultVO codeImProtRusultVO =mdmIOService.batchImportEdit(codeClassifyOid, classifyAttr,file1);
            if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())||StringUtils.isNotBlank(codeImProtRusultVO.getRedisUuid())){
                //放到map里
                R result = R.fail("导入失败");
                if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())) {
                    String filedUUid = ControllerUtil.putErrorFile(codeImProtRusultVO.getFilePath());
                    codeImProtRusultVO.setFileOid(filedUUid);
                }
                result.setData(codeImProtRusultVO);
                return result;
            }else {
                return R.success("操作成功!");
            }
        }catch (Throwable e) {
            logger.error("导入错误",e);
            String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误.txt";
            LocalFileUtil.writeContentToFile(LangBaseUtil.getErrorMsg(e),errorFile);
            String uuid=ControllerUtil.putErrorFile(errorFile);
            CodeImProtRusultVO codeImProtRusultVO =new CodeImProtRusultVO();
            codeImProtRusultVO.setRedisUuid("");
            codeImProtRusultVO.setFileOid(uuid);
            codeImProtRusultVO.setFilePath(errorFile);
            R r = R.fail("导入失败");
            r.setData(codeImProtRusultVO);
            return r;
        }finally {
            file1.delete();
        }
    }
 
    /**
     * 下载批量申请的导入模板
     * @param codeClassifyOid 分类的主键
     * @param response 响应对象
     * @throws IOException 抛出异常
     */
    @GetMapping("/downloadTopImportExcel")
    @VciBusinessLog(operateName = "下载批量申请编码的导入模板")
    public void downloadTopImportExcel(String codeClassifyOid,HttpServletResponse response) throws IOException{
        String excelName = mdmIOService.downloadTopImportExcel(codeClassifyOid);
        try {
            ControllerUtil.writeFileToResponse(response,excelName);
        } catch (Throwable e) {
            //如果出错,把错误信息写到text
            String msg = LangBaseUtil.getErrorMsg(e);
            if(StringUtils.isBlank(msg)){
                msg = "未知错误";
            }
            ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null);
        }
    }
 
    /**
     * 导出主题库的数据
     * @param exportAttrDTO 导出的相关配置
     */
    @VciBusinessLog(operateName = "导出主题库的数据")
    @PostMapping("/exportCode")
    public void exportCode(CodeExportAttrDTO exportAttrDTO, HttpServletResponse response) throws IOException {
        String excelName = mdmIOService.exportCode(exportAttrDTO);
        try {
            ControllerUtil.writeFileToResponse(response,excelName);
        } catch (Throwable e) {
            //如果出错,把错误信息写到text
            String msg = LangBaseUtil.getErrorMsg(e);
            String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误.txt";
            LocalFileUtil.writeContentToFile(msg,errorFile);
            ControllerUtil.writeFileToResponse(response,errorFile);
        }
    }
 
    /**
     * 下载历史数据导入模板
     * @param codeClassifyOid 分类的主键
     * @param response 响应对象
     * @throws IOException 抛出异常
     */
    @GetMapping("/downloadImportExcelHistory")
    @VciBusinessLog(operateName = "下载历史数据导入模板")
    public void downloadImportExcelHistory(String codeClassifyOid,HttpServletResponse response) throws IOException{
        String excelName = mdmIOService.createImportExcel(codeClassifyOid,true);
        //String excelName = mdmIOService.downloadTopImportExcel(codeClassifyOid);
        try {
            ControllerUtil.writeFileToResponse(response,excelName);
        } catch (Throwable e) {
            //如果出错,把错误信息写到text
            String msg = LangBaseUtil.getErrorMsg(e);
            if(StringUtils.isBlank(msg)){
                msg = "未知错误";
            }
            ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null);
        }
    }
 
    /**
     * 批量申请编码的信息(当前分类上批量申请)
     * @param secDTOList 申请编码的信息,必须包含码段和分类主键的信息
     * @param file 文件的内容
     */
    @VciBusinessLog(operateName = "批量申请编码的信息")
    @PostMapping("/batchImportCode")
    public R batchImportCode(String secDTOList, String codeClassifyOid, MultipartFile file, HttpServletResponse response) throws Throwable {
        CodeOrderDTO orderDTO = new CodeOrderDTO();
        orderDTO.setCodeClassifyOid(codeClassifyOid);
        if(StringUtils.isNotBlank(secDTOList)){
            List<CodeOrderSecDTO> secDTOS = JSONObject.parseArray(secDTOList, CodeOrderSecDTO.class);
            orderDTO.setSecDTOList(secDTOS);
        }
        String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename());
        File file1 = new File(excelFileName);
        try {
            file.transferTo(new File(excelFileName));
            CodeImProtRusultVO codeImProtRusultVO = mdmIOService.batchImportCode(orderDTO,file1);
            if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())||StringUtils.isNotBlank(codeImProtRusultVO.getRedisUuid())){
                //放到map里
                R result = R.fail("导入失败");
                if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())) {
                    String filedUUid = ControllerUtil.putErrorFile(codeImProtRusultVO.getFilePath());
                    codeImProtRusultVO.setFileOid(filedUUid);
                }
                result.setData(codeImProtRusultVO);
                return result;
            }else {
                return R.success("操作成功!");
            }
        }catch (Throwable e) {
            logger.error("导入错误",e);
            String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误.txt";
            LocalFileUtil.writeContentToFile( LangBaseUtil.getErrorMsg(e),errorFile);
            String uuid=ControllerUtil.putErrorFile(errorFile);
            CodeImProtRusultVO codeImProtRusultVO =new CodeImProtRusultVO();
            codeImProtRusultVO.setRedisUuid("");
            codeImProtRusultVO.setFileOid(uuid);
            codeImProtRusultVO.setFilePath(errorFile);
            R result = R.fail("导入失败");
            result.setData(codeImProtRusultVO);
//            result.setObj(codeImProtRusultVO);
            return result;
        }finally {
            file1.delete();
        }
//        return null;
    }
 
    /**
     * 导入历史数据
     * @param codeClassifyOid 分类的主键
     * @param classifyAttr 分类路径使用的属性
     * @param file 文件的内容
     */
    @VciBusinessLog(operateName = "导入编码的历史数据")
    @PostMapping("/batchImportHistoryData")
    public R batchImportHistoryData(String codeClassifyOid, String classifyAttr,MultipartFile file,HttpServletResponse response) throws Throwable {
        String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + file.getOriginalFilename();
        File file1 = new File(excelFileName);
        try {
            file.transferTo(new File(excelFileName));
            CodeImProtRusultVO codeImProtRusultVO =mdmIOService.batchImportHistoryData(codeClassifyOid, classifyAttr,file1);
            if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())||StringUtils.isNotBlank(codeImProtRusultVO.getRedisUuid())){
                //放到map里
                R result = R.fail("导入失败");
                if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())) {
                    String filedUUid = ControllerUtil.putErrorFile(codeImProtRusultVO.getFilePath());
                    codeImProtRusultVO.setFileOid(filedUUid);
                }
                result.setData(codeImProtRusultVO);
                return result;
            }else {
                return R.success("操作成功!");
            }
        }catch (Throwable e) {
            logger.error("导入错误",e);
            String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误.txt";
            LocalFileUtil.writeContentToFile(LangBaseUtil.getErrorMsg(e),errorFile);
            String uuid=ControllerUtil.putErrorFile(errorFile);
            CodeImProtRusultVO codeImProtRusultVO =new CodeImProtRusultVO();
            codeImProtRusultVO.setRedisUuid("");
            codeImProtRusultVO.setFileOid(uuid);
            codeImProtRusultVO.setFilePath(errorFile);
            R r = R.fail("导入失败");
            r.setData(codeImProtRusultVO);
            return r;
        }finally {
            file1.delete();
        }
    }
 
    /**
     * 导入历史数据(从顶层分类导的)
     * @param codeClassifyOid 分类的主键
     * @param classifyAttr 分类路径使用的属性
     * @param file 文件的内容
     */
    @VciBusinessLog(operateName = "批量申请编码的信息")
    @PostMapping("/batchTopImportCode")
    public R batchTopImportCode(String codeClassifyOid, String classifyAttr,MultipartFile file,HttpServletResponse response) throws Throwable {
        String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + file.getOriginalFilename();
        File file1 = new File(excelFileName);
        try {
            file.transferTo(new File(excelFileName));
            CodeImProtRusultVO codeImProtRusultVO =mdmIOService.batchTopImportCode(codeClassifyOid, classifyAttr,file1);
            if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())||StringUtils.isNotBlank(codeImProtRusultVO.getRedisUuid())){
                //放到map里
                R r = R.fail("导入失败!");
                if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())) {
                    String filedUUid = ControllerUtil.putErrorFile(codeImProtRusultVO.getFilePath());
                    codeImProtRusultVO.setFileOid(filedUUid);
                    r = R.success("导入成功!");
                }
                r.setData(codeImProtRusultVO);
                return r;
            }else {
                return R.success("导入成功!");
            }
        }catch (Throwable e) {
            e.printStackTrace();
            logger.error("导入错误",e);
            String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误.txt";
            LocalFileUtil.writeContentToFile(LangBaseUtil.getErrorMsg(e),errorFile);
            String uuid=ControllerUtil.putErrorFile(errorFile);
            CodeImProtRusultVO codeImProtRusultVO =new CodeImProtRusultVO();
            codeImProtRusultVO.setRedisUuid("");
            codeImProtRusultVO.setFileOid(uuid);
            codeImProtRusultVO.setFilePath(errorFile);
 
            R r = R.fail("导入失败");
            r.setData(codeImProtRusultVO);
 
            return r;
        }finally {
            file1.delete();
        }
    }
 
    /**
     * 修改状态
     * @param baseModelDTO 数据传输对象
     * @return 执行结果
     */
    @PostMapping("changeStatus")
    public R changeStatus(@RequestBody BaseModelDTO baseModelDTO) {
        engineService.changeStatus(baseModelDTO);
        return R.success("操作成功!");
    }
 
    /**
     * 申请编码保存
     * @param orderDTO 编码申请相关的信息,需要有属性和码段相关的信息
     * @return 执行结果
     */
    @PostMapping("/addSaveCode")
    @VciBusinessLog(operateName = "申请单个编码")
    public R addSaveCode(@RequestBody CodeOrderDTO orderDTO) throws Exception {
        String s = null;
        try {
            s = engineService.addSaveCode(orderDTO);
            saveLogUtil.operateLog("编码申请",false,orderDTO.toString());
        }catch (Exception e){
            saveLogUtil.operateLog("编码申请",true,e.toString());
            throw e;
        }
        return R.success(s);
    }
 
    /**
     * 使用模板的主键获取表单的定义
     * @param templateOid 模板的主键
     * @param codeClassifyOid 使用模板的分类主键
     * @return UI相关的信息(仅包含表单)
     */
    @GetMapping("/getFormDefineByTemplateOid")
    public MdmUIInfoVO getFormDefineByTemplateOid(String templateOid, String codeClassifyOid){
        return engineService.getFormDefineByTemplateOid(templateOid,codeClassifyOid);
    }
 
    /**
     * 相似项查询
     * @param orderDTO 编码的相关信息
     * @return 数据列表
     */
    @PostMapping("/resembleQuery")
    public DataGrid<Map<String,String>> resembleQuery(@RequestBody CodeOrderDTO orderDTO){
        return engineService.resembleQuery(orderDTO);
    }
 
    /**
     * 修改单条主题库的数据
     * @param orderDTO 编码申请相关的信息,不需要码段的信息
     * @return 执行结果
     */
    @PutMapping("/editSaveCode")
    @VciBusinessLog(operateName = "修改编码数据")
    public R editSaveCode(@RequestBody CodeOrderDTO orderDTO){
        engineService.editSaveCode(orderDTO);
        return  R.success("修改成功!");
    }
 
    /**
     * 批量删除主题库的数据
     * @param deleteBatchDTO 删除的信息,必须要有主键和分类的主键
     * @return 执行结果
     */
    @VciBusinessLog(operateName = "批量删除主题库的数据")
    @DeleteMapping("/deleteCode")
    public R deleteCode(@RequestBody CodeDeleteBatchDTO deleteBatchDTO){
        engineService.deleteCode(deleteBatchDTO);
        return R.success("删除成功!");
    }
 
    /**
     * 使用分类和阶段的编号,获取包含的属性
     * @param codeClassifyOid 分类的主键
     * @param phase 阶段的名称
     * @return 包含的属性,请获取obj属性
     */
    @VciBusinessLog(operateName = "获取阶段的属性信息")
    @GetMapping("/listPhaseAttrByClassifyOid")
    public R listPhaseAttrByClassifyOid(String codeClassifyOid,String phase){
        return R.data(engineService.listPhaseAttrByClassifyOid(codeClassifyOid,phase));
    }
 
    /**
     * 获取当前分类所在路径上的分类属性
     * @param codeClassifyOid 分类的主键
     * @return 包含了当前分类的上级和所有层级的下级
     */
    @GetMapping("/hasSelfClassifyTree")
    public List<Tree> hasSelfClassifyTree(String codeClassifyOid){
        return engineService.hasSelfClassifyTree(codeClassifyOid);
    }
 
    /**
     * 使用分类获取对应的数据
     * @param codeClassifyOid 分类的主键
     * @param templateOid 模板的主键
     * @param queryObject 基础查询对象
     * @return 数据的信息(包含下级分类)
     */
    @GetMapping("/gridTableDataByClassifyOid")
    @VciBusinessLog(operateName = "查询主题库分类的数据")
    public DataGrid<Map<String,String>> gridTableDataByClassifyOid(String codeClassifyOid, String templateOid, BaseQueryObject queryObject){
        //TODO后续可以定义查询模板来查询
        return engineService.gridTableDataByClassifyOid(codeClassifyOid,templateOid,queryObject.getConditionMap(),queryObject.getPageHelper());
    }
 
    /***
     * 获取分类对象
     * @param redisOid
     * @return
     */
    @GetMapping("/gridclassifys")
    public R gridclassifys(String redisOid){
        List<CodeImportTemplateVO> codeImportTemplateVOs=mdmIOService.gridclassifys(redisOid);
        return R.data(codeImportTemplateVOs);
    }
 
    /***
     * 从redis缓存里获取到导入正确的数据
     * @param codeClassifyOid
     * @param redisOid
     * @return
     */
    @GetMapping("/gridValidata")
    public DataGrid<Map<String,String>> gridValidata(String codeClassifyOid,String redisOid){
        return mdmIOService.gridDatas(codeClassifyOid,redisOid);
    }
 
    /***
     * 从redis缓存里获取到导入行相似项的数据
     * @param dataOid
     * @param redisOid
     * @return
     */
    @GetMapping("/gridRowResemble")
    public DataGrid<Map<String,String>> gridRowResemble(String dataOid,String redisOid){
        return mdmIOService.gridRowResemble(dataOid,redisOid);
    }
 
    /***
     * 从redis缓存里获取到导入具有相似项的数据
     * @param codeClassifyOid
     * @param redisOid
     * @return
     */
    @GetMapping("/gridResemble")
    public DataGrid<Map<String,String>> gridResemble(String codeClassifyOid,String redisOid){
        return mdmIOService.gridDatas(codeClassifyOid,redisOid);
    }
 
    /***
     * 导入数据
     * @param codeImprotSaveDatVO//数据对象
     * @return
     */
    @PostMapping("/batchImportData")
    public R batchImportData(@RequestBody CodeImprotParmaDatVO codeImprotSaveDatVO){
        return mdmIOService.batchImportData(codeImprotSaveDatVO.getCodeImprotSaveDatVOList(),codeImprotSaveDatVO.getClassifyAttr(),codeImprotSaveDatVO.getImprot());
    }
 
    /***
     * 根据数据oid从缓存中移除数据
     * @param redisOid redisid
     * @param codeClassifyOid 存储规则的oid
     * @param dataOids  所需删除的数据
     * @return
     */
    @GetMapping("/deleteDatas")
    public  R deleteDatas(String redisOid,String codeClassifyOid,String dataOids){
        return mdmIOService.deleteDatas(redisOid,codeClassifyOid,dataOids);
    }
 
    /**
     * 批量保存流程执行页面修改的内容
     * @param orderDTOList 编码相关的信息,不需要码段的信息
     * @return 执行结果
     */
    @PostMapping("/batchUpdateCode")
    public R batchUpdateCode(@RequestBody List<CodeOrderDTO> orderDTOList){
        return engineService.batchUpdateCode(orderDTOList);
    }
 
    /**
     * 标记流程中业务数据是否通过
     * @param oid 业务数据主键
     * @param btmName 业务类型
     * @param pass 是否通过 true-通过;false-不通过
     * @return 执行结果
     */
    @PostMapping("/markPass")
    public R markDataPassing(String oid,String btmName,Boolean pass){
        return engineService.markDataPassing(oid,btmName,pass);
    }
 
    /**
     * 组合规则的预览的内容
     * @param orderDTO 申请编码信息
     * @return 公式转换后的值
     */
    @PostMapping("/previewCompRule")
    public R previewCompRule(@RequestBody CodeOrderDTO orderDTO){
        return R.data(engineService.previewCompRule(orderDTO));
    }
 
    /**
     * 分类注入的内容
     * @param orderDTO 申请编码的信息,包含分类的主键和模板的主键
     * @return 执行结果
     */
    @PostMapping("/previewClassify")
    public R previewClassify(@RequestBody CodeOrderDTO orderDTO){
        VciBaseUtil.alertNotNull(orderDTO,"申请的信息",orderDTO.getCodeClassifyOid(),"分类主键",orderDTO.getTemplateOid(),"模板的主键");
        Map<String,String> classifyMap = engineService.previewClassify(orderDTO.getCodeClassifyOid(),orderDTO.getTemplateOid());
        return R.data(classifyMap);
    }
 
    /**
     * 下载错误的文件信息
     * @param uuid 唯一标识
     * @param response 响应对象
     * @throws IOException 抛出异常
     */
    @GetMapping("/downloadErrorFile")
    public void downloadErrorFile(String uuid,HttpServletResponse response) throws IOException {
        ControllerUtil.downloadErrorFile(response,uuid);
    }
 
    /**
     * 升版编码数据
     * @param orderDTO 编码相关的信息,不需要码段的信息
     * @return 执行结果
     */
    @VciBusinessLog(operateName = "升版编码数据")
    @PostMapping("/upSaveCode")
    public R upSaveCode(@RequestBody CodeOrderDTO orderDTO){
        engineService.upSaveCode(orderDTO);
        return R.success("操作成功!");
    }
 
    /**
     * 使用码段的主键获取分类的码值内容
     * @param classifySecOid 码段的主键
     * @param parentClassifyValueOid 上级分类的主键
     * @return 分类码值的内容
     */
    @GetMapping("/listCodeClassifyValueBySecOid")
    public IPage<CodeClassifyValueVO> listCodeClassifyValueBySecOid(String classifySecOid, String parentClassifyValueOid){
        List<CodeClassifyValueVO> valueVOS = engineService.listCodeClassifyValueBySecOid(classifySecOid, parentClassifyValueOid);
        IPage<CodeClassifyValueVO> valueVOIPage = new Page<>();
        valueVOIPage.setRecords(valueVOS);
        valueVOIPage.setTotal(valueVOS==null?0:valueVOS.size());
        return valueVOIPage;
    }
 
    /**
     * 使用分类的主键来获取编码规则
     * @param codeClassifyOid 分类的主键
     * @return 编码规则的内容
     */
    @GetMapping("/getCodeRuleByClassifyOid")
    //    @VciUnCheckRight
    public R<CodeRuleVO> getCodeRuleByClassifyOid(String codeClassifyOid){
        return R.data(engineService.getCodeRuleByClassifyOid(codeClassifyOid));
    }
 
    /**
     * 使用主键获取数据
     * @param oid 数据主键
     * @param templateOid 模板的主键
     * @return 数据内容
     */
    @GetMapping("/getDataByOid")
    public R<List<Map<String,String>>> getDataByOid(String oid,String templateOid){
        return engineService.getDataByOid(oid,templateOid);
    }
 
    /**
     * 使用分类模板主键+模板流程名称获取在审批页面上左侧显示的属性
     * @param templateOid 分类模板的主键
     * @param executionId 流程执行id
     * @param processUse 流程的用途
     * @return 树节点显示的名称
     */
    @GetMapping("/getFieldByProcessTemplate")
    public List<String> getFieldByProcessTemplate(String templateOid,String executionId,String processUse){
        return engineService.getFieldByProcessTemplate(templateOid,executionId,processUse);
    }
 
    /**
     * 使用分类的主键获取业务数据
     * @param btmType 业务类型
     * @param queryObject 查询对象
     * @return 表格的显示对象值
     */
    @GetMapping("/getTableDataByOids")
    public DataGrid<Map<String,String>> getTableDataByOids(String btmType,BaseQueryObject queryObject){
        return engineService.getTableDataByExecutionId(btmType,queryObject);
    }
 
    /**
     * 使用分类的主键获取表格的定义
     * @param codeClassifyOid 分类主键
     * @param phase 阶段的名称
     * @return UI相关的信息(仅包含表单)
     */
    @GetMapping("/getTableDefineByClassifyOid")
    public MdmUIInfoVO getTableDefineByClassifyOid(String codeClassifyOid,String phase){
        return engineService.getTableDefineByClassifyOid_v2(codeClassifyOid,phase);
    }
 
    /**
     * 使用分类的的编号路径,获取表单的定义
     * @param idPath 编号的路径
     * @return UI相关的信息(仅包含表单)
     */
//    @VciUnCheckRight
    @GetMapping("/getFormDefineByClassifyIdPath")
    public MdmUIInfoVO getFormDefineByClassifyIdPath(String idPath){
        return engineService.getFormDefineByClassifyIdPath(idPath);
    }
 
    /**
     * 使用分类的主键获取表单的定义
     * @param codeClassifyOid 分类主键
     * @return UI相关的信息(仅包含表单)
     */
    @GetMapping("/getFormDefineByClassifyOid")
    public MdmUIInfoVO getFormDefineByClassifyOid(String codeClassifyOid){
        return engineService.getFormDefineByClassifyOid(codeClassifyOid);
    }
 
    /**
     * 根据模板的主键获取表格的定义
     * @param templateOid 模板的主键
     * @return ui相关的信息(仅包含表格)
     */
    @GetMapping("/getTableDefineByTemplateOid")
    public MdmUIInfoVO getTableDefineByTemplateOid(String templateOid){
        return engineService.getTableDefineByTemplateOid(templateOid);
    }
 
    /**
     * 使用分类的编号路径,获取表格的相关定义
     * @param codeClassifyIdPath 分类的编号路径,必须是从顶层节点开始,xxx/yy/zz这样的格式
     * @param functionId 功能的编号
     * @return UI相关的信息(仅包含表格)
     */
    @GetMapping("/getUIInfoByClassifyIdPath")
    public MdmUIInfoVO getUIInfoByClassifyIdPath(String codeClassifyIdPath,String functionId){
        return engineService.getUIInfoByClassifyIdPath(codeClassifyIdPath,functionId);
    }
 
    /**
     * 使用分类获取表格的定义
     * @param codeClassifyOid 分类主键
     * @param functionId 功能的编号
     * @return UI相关的信息(仅包含表格)
     */
    @GetMapping("/getUIInfoByClassifyOid")
    public MdmUIInfoVO getUIInfoByClassifyOid(String codeClassifyOid,String functionId){
        return engineService.getUIInfoByClassifyOid(codeClassifyOid,functionId);
    }
 
    /**
     * 使用分类获取表格的定义
     * @param codeClassifyOid 分类主键
     * @param functionId 功能的编号
     * @return UI相关的信息(仅包含表格)
     */
    @GetMapping("/getFlowdUIInfoByClassifyOid")
    public MdmUIInfoVO getUIInfoByClassifyOid(String codeClassifyOid,String functionId,String templateId,String taskId,String modelKey){
        return engineService.getFlowUIInfoByClassifyOid(codeClassifyOid,functionId,templateId,taskId,modelKey);
    }
 
    @GetMapping("/thisistest")
    @ResponseBody
    public Integer thisistest(String codeClassifyOid, String functionId) throws Exception {
//        return engineService.selectByTypeAndOid("wupin", "b1511bb3-a773-43e2-ac85-a7fde7314a0f,3e08970024835e69f6c2b2ecd90c48c3,582ff205-0dfb-43e0-8223-e772ff1851ab,db0400fe-cc90-4d9d-8da7-1edf06b1481b");
 
        List<BaseModel> models = new ArrayList<>();
        BaseModel baseModel = new BaseModel();
        Map<String,String > map = new HashMap<>();
        map.put("JZL","6789");
        map.put("JZRXX","67891");
        map.put("JZXZB","67892");
        map.put("JSZGL","67893");
        map.put("JSSXT","67894");
        baseModel.setBtmname("djii");
        baseModel.setCreator("fjivis");
        baseModel.setId("vcia");
        baseModel.setOid("0d86b1ba-9e9e-4d3d-9ae4-f862c3684e74");
        baseModel.setCreateTime(new Date());
        baseModel.setTs(new Date());
        baseModel.setData(map);
        models.add(baseModel);
 
        BaseModel baseModel1 = new BaseModel();
        Map<String,String > map1 = new HashMap<>();
        map1.put("JZL","6789z");
        map1.put("JZRXX","67891z");
        map1.put("JZXZB","67892z");
        map1.put("JSZGL","67893z");
        map1.put("JSSXT","67894z");
        baseModel1.setBtmname("djiiz");
        baseModel1.setCreator("fjivisz");
        baseModel1.setId("vciaz");
        baseModel1.setTs(new Date());
        baseModel1.setOid("4a00be07-f5a8-4a9b-88fb-d52a0d9cf546");
        baseModel1.setCreateTime(new Date());
        baseModel1.setData(map1);
        models.add(baseModel1);
 
        BaseModel baseModel2 = new BaseModel();
        Map<String,String > map2 = new HashMap<>();
        map2.put("JZL","67892");
        map2.put("JZRXX","678912");
        map2.put("JZXZB","678922");
        map2.put("JSZGL","678932");
        map2.put("JSSXT","678942");
        baseModel2.setBtmname("djii2");
        baseModel2.setCreator("fjivis2");
        baseModel2.setTs(new Date());
        baseModel2.setId("vcia2");
        baseModel2.setOid("fa430ff9-f141-4dcf-8809-6f87905c1dea");
        baseModel2.setCreateTime(new Date());
        baseModel2.setData(map2);
        models.add(baseModel2);
 
        return 0;
 
 
 
//        return engineService.updateBatchByBaseModel("wupin", models);
//        return engineService.getUIInfoByClassifyOid(codeClassifyOid,functionId);
    }
 
    /**
     * 默认的参照列表
     * @param referConfigVO 参照的配置信息
     * @return 执行的结果
     */
    @RequestMapping(value = "/defaultReferDataGrid",method = {RequestMethod.POST, RequestMethod.GET})
    public IPage<BaseModelVO> defaultReferDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject){
        return engineService.referDataGrid(referConfigVO,baseQueryObject);
    }
 
    /**
     * 默认的树形参照列表
     * @param referConfigVO 参照的配置信息
     * @return 执行的结果
     */
    @GetMapping("/defaultReferTree")
    public List<Tree> defaultReferTree(UIFormReferVO referConfigVO, TreeQueryObject queryObject){
        return engineService.referTree(referConfigVO,queryObject);
    }
 
    /**
     * 流程中变更状态的简易接口
     * @param flowDTO 流程中携带的body
     * @return
     */
    @PostMapping("/processChangeStatus")
    public R processChangeStatus(@RequestBody FlowStatusDTO flowDTO){
        return engineService.processChangeStatus(flowDTO);
    }
 
    /**
     * 标准申请和修订用
     * @param codeBZApplyDTO 编码申请相关的信息,需要有属性和码段相关的信息
     * @return 执行结果
     */
    @PostMapping("/addSaveBZ")
    @VciBusinessLog(operateName = "申请单个编码")
    public R addSaveBZ (@RequestBody CodeBZApplyDTO codeBZApplyDTO) throws Exception {
        return R.success(engineService.addSaveBZ(codeBZApplyDTO));
    }
 
    /**
     * 下载批量申请的导入模板
     * @param codeClassifyOid 分类的主键
     * @param response 响应对象
     * @throws IOException 抛出异常
     */
    @GetMapping("/exportGroupCodeExcel")
    @VciBusinessLog(operateName = "导出集团码")
    public void exportGroupCodeExcel(String codeClassifyOid, HttpServletResponse response) throws IOException{
 
        try {
            String excelName = mdmIOService.exportGroupCodeExcel(codeClassifyOid);
        } catch (Throwable e) {
            //如果出错,把错误信息写到text
            String msg = LangBaseUtil.getErrorMsg(e);
            if(StringUtils.isBlank(msg)){
                msg = "未知错误";
            }
            ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null);
        }
    }
}