ludc
2024-01-28 9660ff90d9a58fb675c821d9ed31b627a59d4b76
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
package com.vci.ubcs.code.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
 
import com.vci.ubcs.code.dto.CodeClassifyTemplateAttrDTO;
import com.vci.ubcs.code.entity.CodeClassify;
import com.vci.ubcs.code.entity.CodeClassifyTemplateAttr;
import com.vci.ubcs.code.entity.CodeClassifyTemplate;
import com.vci.ubcs.code.enumpack.CodeLevelTypeEnum;
import com.vci.ubcs.code.mapper.CodeClassifyTemplateAttrMapper;
import com.vci.ubcs.code.mapper.CodeClassifyTemplateMapper;
import com.vci.ubcs.code.service.ICodeClassifyTemplateAttrService;
import com.vci.ubcs.code.service.ICodeReferConfigService;
import com.vci.ubcs.code.service.ICodeTempphaseService;
import com.vci.ubcs.code.vo.CodeReferConfigVO;
import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateAttrVO;
import com.vci.ubcs.code.vo.pagemodel.UIFormReferVO;
import com.vci.ubcs.code.wrapper.CodeClassifyTemplateAttrWrapper;
import com.vci.ubcs.omd.feign.IBtmTypeClient;
import com.vci.ubcs.omd.vo.BtmTypeAttributeVO;
import com.vci.ubcs.omd.vo.BtmTypeVO;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.revision.service.RevisionModelUtil;
import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil;
import com.vci.ubcs.starter.util.MdmBtmTypeConstant;
import com.vci.ubcs.starter.util.PatternUtil;
import com.vci.ubcs.starter.util.UBCSCondition;
import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum;
import com.vci.ubcs.starter.web.pagemodel.*;
import com.vci.ubcs.starter.web.pagemodel.PageHelper;
import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import com.vci.ubcs.starter.web.util.VciDateUtil;
import com.vci.ubcs.system.entity.DictBiz;
import com.vci.ubcs.system.feign.IDictBizClient;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
 
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
 
import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.*;
import static com.vci.ubcs.code.constant.FrameWorkLangCodeConstant.DATA_OID_NOT_EXIST;
 
/**
 * 主题库分类的模板属性服务
 * @author ludc
 * @date 2023/5/5
 */
@Service
public class CodeClassifyTemplateAttrServiceImpl extends ServiceImpl<CodeClassifyTemplateAttrMapper, CodeClassifyTemplateAttr> implements ICodeClassifyTemplateAttrService {
 
    /**
     * 数据操作层
     */
    @Resource
    private CodeClassifyTemplateAttrMapper codeClassifyTemplateAttrMapper;
 
    @Resource
    IDictBizClient iDictBizClient;
 
    @Resource
    CodeClassifyTemplateMapper codeClassifyTemplateMapper;
 
    @Resource
    private ICodeReferConfigService codeReferConfigService;
 
    @Resource
    @Lazy
    ICodeTempphaseService codeTempphaseService;
 
    /**
     * 对象的操作
     */
    @Autowired(required = false)
    private RevisionModelUtil revisionModelUtil;
 
    /**
     * 属性服务对象
     */
    @Resource
    private IBtmTypeClient btmTypeClient;
 
    /**
     * 查询所有的主题库分类的模板属性
     * @param mpjLambdaWrapper 查询条件
     * @param pageHelper 分页和排序
     * @return 执行结果
     * @throws VciBaseException 查询条件和分页出错的时候会抛出异常
     */
    @Override
    public IPage<CodeClassifyTemplateAttrVO> gridCodeClassifyTemplateAttr(MPJLambdaWrapper<CodeClassifyTemplateAttr> mpjLambdaWrapper , PageHelper pageHelper) throws VciBaseException {
        //没有传递参数,就不执行查询逻辑
        if(mpjLambdaWrapper == null){
            return new Page<>();
        }
        Query query = new Query();
        if (pageHelper == null) {
            pageHelper = new PageHelper(-1);
            query.setSize(-1);
        }else {
            query.setCurrent(pageHelper.getPage());
            query.setSize(pageHelper.getLimit());
        }
        //pageHelper.addDefaultAsc("ordernum");
        query.setAscs("ORDERNUM");
        //这儿是个连表查询
        IPage<CodeClassifyTemplateAttr> doList = codeClassifyTemplateAttrMapper.selectPage(Condition.getPage(query), mpjLambdaWrapper);
        IPage<CodeClassifyTemplateAttrVO> voList = new Page<>();
        if (!CollectionUtils.isEmpty(doList.getRecords())) {
            voList = CodeClassifyTemplateAttrWrapper.build().pageVO(doList);
        }
        return voList;
    }
 
    /**
     * 参照主题库分类的模板属性列表
     * @param conditionMap 查询条件
     * @param pageHelper 分页和排序
     * @return 主题库分类的模板属性显示对象列表,生效的内容
     * @throws VciBaseException 查询条件和分页出错的时候会抛出异常
     */
    @Override
    public IPage<CodeClassifyTemplateAttrVO> refDataGridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) throws VciBaseException{
        if(conditionMap == null){
            conditionMap = new HashMap<String, String>();
        }
        return gridCodeClassifyTemplateAttr(UBCSCondition.getMPJLambdaWrapperByMapString(conditionMap, CodeClassifyTemplateAttr.class),pageHelper);
    }
 
    @Override
    public IPage<CodeClassifyTemplateAttrVO> selectCodeClstempattrPage(IPage<CodeClassifyTemplateAttrVO> page, CodeClassifyTemplateAttrVO CodeClstempattr) {
        return page.setRecords(baseMapper.selectCodeClstempattrPage(page, CodeClstempattr));
    }
 
    /**
     * 使用模板的主键获取模板的属性--批量
     *
     * @param templateOidCollection 模板的主键
     * @return 属性的信息
     */
    @Override
    public List<CodeClassifyTemplateAttrVO> listCodeClassifyTemplateAttrByTemplateOids(Collection<String> templateOidCollection) {
        if(CollectionUtils.isEmpty(templateOidCollection)){
            return new ArrayList<>();
        }
        List<CodeClassifyTemplateAttr> attrDOList = new ArrayList<>();
        VciBaseUtil.switchCollectionForOracleIn(templateOidCollection).stream().forEach(templateOids->{
//            Map<String,String> conditionMap = new HashMap<>();
//            conditionMap.put("classifytemplateoid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(templateOids.toArray(new String[0])) + ")");
//            PageHelper pageHelper = new PageHelper(-1);
//            pageHelper.addDefaultAsc("orderNum");
//            QueryWrapper<CodeClassifyTemplateAttr> wrapper = new QueryWrapper<>();
//            wrapper.in("classifytemplateoid",templateOids);
//            wrapper.orderByAsc("orderNum");
            List<CodeClassifyTemplateAttr> attrDOS = baseMapper.selectByClassifytemplateoidRel(VciBaseUtil.toInSql(templateOids.toArray(new String[0])));
//                baseMapper.selectByClassifytemplateoid(VciBaseUtil.toInSql(templateOids.toArray(new String[0])));
 
            if(!CollectionUtils.isEmpty(attrDOS)){
                attrDOList.addAll(attrDOS);
            }
        });
        return codeClassifyTemplateAttrDO2VOs(attrDOList);
    }
 
    /**
     * 批量数据对象转换为显示对象
     * @param codeClassifyTemplateAttrDOs 数据对象列表
     * @return 显示对象
     * @throws VciBaseException 参数为空或者不存在的时候会抛出异常
     */
    @Override
    public List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrDO2VOs(Collection<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOs) throws VciBaseException{
        List<CodeClassifyTemplateAttrVO> voList = new ArrayList<CodeClassifyTemplateAttrVO>();
        if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOs)){
            for(CodeClassifyTemplateAttr s: codeClassifyTemplateAttrDOs){
                CodeClassifyTemplateAttrVO vo =  codeClassifyTemplateAttrDO2VO(s);
                if(vo != null){
                    voList.add(vo);
                }
            }
        }
        return voList;
    }
 
    /**
     * 数据对象转换为显示对象
     * @param  codeClassifyTemplateAttrDO 数据对象
     * @return 显示对象
     * @throws VciBaseException 拷贝属性出错的时候会抛出异常
     */
    @Override
    public CodeClassifyTemplateAttrVO codeClassifyTemplateAttrDO2VO(CodeClassifyTemplateAttr codeClassifyTemplateAttrDO) throws VciBaseException{
        CodeClassifyTemplateAttrVO vo = new CodeClassifyTemplateAttrVO();
        if(codeClassifyTemplateAttrDO != null){
            BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,vo);
            //如果有lcstatus的类的话
            vo.setAttributeDataTypeText(VciFieldTypeEnum.getTextByValue(vo.getAttributeDataType()));
        }
        return vo;
    }
 
    //    @Override
//    public IPage<CodeClassifyTemplateAttrVO> selectCodeClstempattrPage(IPage<CodeClassifyTemplateAttrVO> page, CodeClassifyTemplateAttrVO CodeClstempattr) {
//        return page.setRecords(baseMapper.selectCodeClstempattrPage(page, CodeClstempattr));
//    }
 
 
//    /**
//     * 使用模板的主键获取模板的属性--批量
//     *
//     * @param templateOidCollection 模板的主键
//     * @return 属性的信息
//     */
//    @Override
//    public List<CodeClassifyTemplateAttrVO> listCodeClassifyTemplateAttrByTemplateOids(Collection<String> templateOidCollection) {
//        if(CollectionUtils.isEmpty(templateOidCollection)){
//            return new ArrayList<>();
//        }
//        List<CodeClassifyTemplateAttr> attrDOList = new ArrayList<>();
//        VciBaseUtil.switchCollectionForOracleIn(templateOidCollection).stream().forEach(templateOids->{
////            Map<String,String> conditionMap = new HashMap<>();
////            conditionMap.put("classifytemplateoid", QueryOptionConstant.IN + "(" + VciBaseUtil.toInSql(templateOids.toArray(new String[0])) + ")");
////            PageHelper pageHelper = new PageHelper(-1);
////            pageHelper.addDefaultAsc("orderNum");
//            List<CodeClassifyTemplateAttr> attrDOS = baseMapper.selectByClassifytemplateoid(VciBaseUtil.toInSql(templateOids.toArray(new String[0])));
//
//            if(!CollectionUtils.isEmpty(attrDOS)){
//                attrDOList.addAll(attrDOS);
//            }
//        });
//        return codeClassifyTemplateAttrDO2VOs(attrDOList);
//    }
 
//    /**
//     * 批量数据对象转换为显示对象
//     * @param codeClassifyTemplateAttrDOs 数据对象列表
//     * @return 显示对象
//     */
//    @Override
//    public List<CodeClassifyTemplateAttrVO> codeClassifyTemplateAttrDO2VOs(Collection<CodeClassifyTemplateAttr>  codeClassifyTemplateAttrDOs){
//        List<CodeClassifyTemplateAttrVO> voList = new ArrayList<CodeClassifyTemplateAttrVO>();
//        if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOs)){
//            for(CodeClassifyTemplateAttr s: codeClassifyTemplateAttrDOs){
//                CodeClassifyTemplateAttrVO vo =  codeClassifyTemplateAttrDO2VO(s);
//                if(vo != null){
//                    voList.add(vo);
//                }
//            }
//        }
//        return voList;
//    }
 
//    /**
//     * 数据对象转换为显示对象
//     * @param  codeClassifyTemplateAttrDO 数据对象
//     * @return 显示对象
//     */
//    @Override
//    public  CodeClassifyTemplateAttrVO codeClassifyTemplateAttrDO2VO(CodeClassifyTemplateAttr codeClassifyTemplateAttrDO){
//        CodeClassifyTemplateAttrVO vo = new CodeClassifyTemplateAttrVO();
//        if(codeClassifyTemplateAttrDO != null){
//            BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,vo);
//            //如果有lcstatus的类的话
//            vo.setAttributeDataTypeText(VciFieldTypeEnum.getTextByValue(vo.getAttributeDataType()));
//        }
//        return vo;
//    }
 
    /**
     * 查询所有的主题库分类的模板属性
     * @param conditionMap 查询条件
     * @param pageHelper 分页和排序
     * @return 执行结果
     */
    @Override
    public DataGrid<CodeClassifyTemplateAttrVO> gridCodeClassifyTemplateAttr(Map<String, String> conditionMap, PageHelper pageHelper) {
        DataGrid<CodeClassifyTemplateAttrVO> dataGrid=new DataGrid<>();
        //没有传递参数,就不执行查询逻辑
        if(conditionMap.size()==0){
            dataGrid.setData(new ArrayList<>());
            dataGrid.setTotal(0);
            return dataGrid;
        }
 
        if (pageHelper == null) {
            pageHelper = new PageHelper(-1);
        }
        pageHelper.addDefaultAsc("ordernum");
        Query query = new Query();
        query.setAscs("ordernum");
        query.setSize(pageHelper.getLimit());
        if(pageHelper.getLimit() != -1){
            query.setCurrent(pageHelper.getPage());
        }
        IPage<CodeClassifyTemplateAttr> doList = baseMapper.
            selectPage(Condition.getPage(query), UBCSCondition.getQueryWrapperByMapString(conditionMap,CodeClassifyTemplateAttr.class).orderByAsc("ordernum"));
        if (!CollectionUtils.isEmpty(doList.getRecords())) {
            dataGrid.setData(codeClassifyTemplateAttrDO2VOs(doList.getRecords()));
            dataGrid.setTotal(VciBaseUtil.getInt(String.valueOf(baseMapper.selectCount(UBCSCondition.getQueryWrapperByMapString(conditionMap,CodeClassifyTemplateAttr.class)))));
        }
        return dataGrid;
    }
 
    /**
     * 增加主题库分类的模板属性
     * @param codeClassifyTemplateAttrDTO 主题库分类的模板属性数据传输对象
     * @return 执行结果
     */
    @Override
    public CodeClassifyTemplateAttrVO addSave(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO){
        VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"需要添加的数据对象");
        //将DTO转换为DO
        CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = new CodeClassifyTemplateAttr();
        BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO);
        DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeClassifyTemplateAttrDO,"codeclstempattr");
        baseMapper.insert(codeClassifyTemplateAttrDO);
        return codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO);
    }
 
    /**
     * 批量添加
     * @param codeClassifyTemplateAttrDTOs 数据传输对象
     * @return 保存后的显示对象
     */
    @Override
    @Transactional
    public List<CodeClassifyTemplateAttrVO> batchAddSave(List<CodeClassifyTemplateAttrDTO> codeClassifyTemplateAttrDTOs) {
        if(CollectionUtils.isEmpty(codeClassifyTemplateAttrDTOs)){
            return new ArrayList<>();
        }
 
        //取所有属性的英文名称,第三个验证需要用到
        Map<String,CodeClassifyTemplateAttrDTO> attrDTOMap =codeClassifyTemplateAttrDTOs.stream().collect(Collectors.toMap(s->s.getId().toLowerCase(Locale.ROOT), t->t));
 
        //找属性中文名字重复
        Map<String, Long> nameCountMap = codeClassifyTemplateAttrDTOs.stream().collect(Collectors.groupingBy(s -> s.getName(), Collectors.counting()));
        List<String> repeatNameList = nameCountMap.keySet().stream().filter(s -> nameCountMap.get(s) > 1).collect(Collectors.toList());
        if(!CollectionUtils.isEmpty(repeatNameList)){
            throw new VciBaseException("模板属性中文名称【{0}】重复",new String[]{ repeatNameList.stream().collect(Collectors.joining(","))});
        }
        //找属性英文名字重复
        Map<String, Long> idCountMap = codeClassifyTemplateAttrDTOs.stream().collect(Collectors.groupingBy(s -> s.getId().toLowerCase(Locale.ROOT), Collectors.counting()));
        List<String> repeatIdList = idCountMap.keySet().stream().filter(s -> idCountMap.get(s) > 1).collect(Collectors.toList());
        if(!CollectionUtils.isEmpty(repeatIdList)){
            throw new VciBaseException("模板属性英文名称【{0}】重复",new String[]{ repeatIdList.stream().collect(Collectors.joining(","))});
        }
 
        // 模板oid
        String CLASSIFYTEMPLATEOID = null;
        //
        CodeReferConfigVO codeReferConfigVO = null;
        //转换
        List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOInsert = new ArrayList<CodeClassifyTemplateAttr>();
        List<String> prefix = new ArrayList<>();
        List<String> suffix = new ArrayList<>();
        List<String> dateFormates = new ArrayList<>();
        for (CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO:codeClassifyTemplateAttrDTOs){
            VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"需要添加的数据对象");
            //将DTO转换为DO
            CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = new CodeClassifyTemplateAttr();
            BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO);
            codeClassifyTemplateAttrDO.setCreateTime(codeClassifyTemplateAttrDO.getCreateTime()!=null?codeClassifyTemplateAttrDO.getCreateTime():new Date());
            // codeClassifyTemplateAttrDO.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));
            codeClassifyTemplateAttrDO.setCreator(String.valueOf(AuthUtil.getUser().getAccount()));
            codeClassifyTemplateAttrDO.setLastModifyTime(new Date());
            // codeClassifyTemplateAttrDO.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId()));
            codeClassifyTemplateAttrDO.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
            codeClassifyTemplateAttrDOInsert.add(codeClassifyTemplateAttrDO);
 
            if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getPrefixValue())){
                prefix.add(codeClassifyTemplateAttrDO.getPrefixValue());
            }
            if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getSuffixValue())){
                suffix.add(codeClassifyTemplateAttrDO.getSuffixValue());
            }
            if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getCodeDateFormat())){
                dateFormates.add(codeClassifyTemplateAttrDO.getCodeDateFormat());
            }
            //判断传过来的枚举注入是否是jsonArr格式
            if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getEnumString())&&!checkKVArr(codeClassifyTemplateAttrDO.getEnumString())){
                throw new VciBaseException("{0}{1}属性的枚举注入数据格式错误!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()});
            }
            //分类注入
            if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getClassifyInvokeAttr())
                && !CodeLevelTypeEnum.MIN.getValue().equalsIgnoreCase(codeClassifyTemplateAttrDO.getClassifyInvokeLevel())
                && VciBaseUtil.getInt(codeClassifyTemplateAttrDO.getClassifyInvokeLevel()) < 0){
                throw new VciBaseException("{0}{1}属性的是分类注入,但是注入层级不能小于0!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()});
            }
 
            //判断传过来的参照配置是否是json格式
            if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getReferConfig())&&!checkKVObj(codeClassifyTemplateAttrDO.getReferConfig())){
                throw new VciBaseException("{0}{1}属性的参照配置数据格式错误!",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()});
            }
            if(StringUtils.isNotBlank(codeClassifyTemplateAttrDO.getCodeDateFormat()) && !checkDateFormat(codeClassifyTemplateAttrDO.getCodeDateFormat())){
                throw new VciBaseException("{0}{1}属性的时间格式不符合要求",new String[]{codeClassifyTemplateAttrDO.getId(),codeClassifyTemplateAttrDO.getName()});
            }
            //如果是组合规则,里面使用的属性不能缺失,也都得显示
            String componentrule = codeClassifyTemplateAttrDTO.getComponentRule();
            boolean isContainsDynamicParameter = PatternUtil.isContainsDynamicParameter(componentrule);
            if(isContainsDynamicParameter){
                List<String> userdAttrList =  PatternUtil.getKeyListByContent(componentrule);//包含的所有${xxx}中的xxx
                if(!CollectionUtils.isEmpty(userdAttrList)){
                    String unExistAttr = userdAttrList.stream().filter(s -> !attrDTOMap.containsKey(s.toLowerCase(Locale.ROOT))).collect(Collectors.joining(","));
                    if(StringUtils.isNotBlank(unExistAttr)){
                        throw new VciBaseException("{0}属性是组合规则,但是规则里包含的属性[{1}]在当前模板中不存在!",new String[]{codeClassifyTemplateAttrDO.getName(), unExistAttr});
                    }
                    //要看看表单是否显示
                    String unFormDisplayAttr = userdAttrList.stream().filter(s -> !VciBaseUtil.getBoolean(attrDTOMap.getOrDefault(s.toLowerCase(Locale.ROOT),
                        new CodeClassifyTemplateAttrDTO()).getFormDisplayFlag())).collect(Collectors.joining(","));
                    if(StringUtils.isNotBlank(unFormDisplayAttr)){
                        throw new VciBaseException("{0}属性是组合规则,但是规则里包含的属性[{1}]在当前模板中没有设置 表单显示 ",new String[]{codeClassifyTemplateAttrDO.getName(),unFormDisplayAttr});
                    }
                }
            }
 
            if(CLASSIFYTEMPLATEOID==null){
                CLASSIFYTEMPLATEOID = codeClassifyTemplateAttrDTO.getClassifyTemplateOid();
            }
 
            // 参照配置是否需要持久化
            codeReferConfigVO = JSONObject.parseObject(codeClassifyTemplateAttrDTO.getReferConfig(), CodeReferConfigVO.class);
            if(Func.isNotEmpty(codeReferConfigVO) && codeReferConfigVO.getIsPersistence()=="true"){
                codeReferConfigService.insert(codeReferConfigVO);
            }
        }
 
        //先都删了
        Map<String,Object> condition = new HashMap<>();
        condition.put("CLASSIFYTEMPLATEOID",CLASSIFYTEMPLATEOID);
        List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDODelete = baseMapper.selectByMap(condition);
 
        //oids
        List<String> oids = new ArrayList<String>();
        for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDODelete){
            oids.add(codeClassifyTemplateAttrDO.getOid());
        }
        if(!CollectionUtils.isEmpty(oids)){
            this.removeBatchByIds(oids);
        }
        //再新增
        if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){
            this.saveBatch(codeClassifyTemplateAttrDOInsert);
        }
 
        //调用阶段
        if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOInsert)){
            codeTempphaseService.codeTemplateAttrModifyTrigger(codeClassifyTemplateAttrDOInsert);
 
        }
 
        //处理可输可选的字符
        if(!CollectionUtils.isEmpty(prefix)){
            for (String s : prefix) {
                DictBiz dictBiz = new DictBiz();
                dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR);
                dictBiz.setDictKey("prefix");
                dictBiz.setDictValue(s);
                iDictBizClient.getCheck(dictBiz) ;
            }
        }
        if(!CollectionUtils.isEmpty(suffix)){
            for (String s : suffix) {
                DictBiz dictBiz = new DictBiz();
                dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR);
                dictBiz.setDictKey("suffix");
                dictBiz.setDictValue(s);
                iDictBizClient.getCheck(dictBiz) ;
            }
        }
        if(!CollectionUtils.isEmpty(dateFormates)){
            for (String s : dateFormates) {
                DictBiz dictBiz = new DictBiz();
                dictBiz.setCode(MdmBtmTypeConstant.CODE_CLASSIFY_TEMPLATE_ATTR);
                dictBiz.setDictKey("dateFormates");
                dictBiz.setDictValue(s);
                iDictBizClient.getCheck(dictBiz) ;
            }
        }
        return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOInsert);
    }
 
    public boolean checkKVArr(String kvString){
        boolean isKV = true;
        try {
            JSONObject.parseArray(kvString, KeyValue.class);
        }catch (Exception e){
            isKV=false;
        }
        return isKV;
    }
 
    public boolean checkKVObj(String kvString){
        boolean isKV = true;
        try {
            JSONObject.parseObject(kvString, UIFormReferVO.class);
        }catch (Exception e){
            isKV=false;
        }
        return isKV;
    }
 
    /**
     * 校验时间格式
     * @param dateFormat 时间格式
     * @return true表示校验通过
     */
    public boolean checkDateFormat(String dateFormat){
        try{
            VciDateUtil.date2Str(new Date(),dateFormat);
            return  true;
        }catch (Throwable e){
            return false;
        }
    }
 
    /**
     * 修改主题库分类的模板属性
     * @param codeClassifyTemplateAttrDTO 主题库分类的模板属性数据传输对象
     * @return 执行结果
     * @throws VciBaseException 参数为空,唯一项,必输项不通过时会抛出异常
     */
    @Override
    public R editSave(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{
        VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"数据对象",codeClassifyTemplateAttrDTO.getOid(),"主题库分类的模板属性主键");
 
        //判断传过来的枚举注入是否是jsonArr格式
        if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getEnumString())&&!checkKVArr(codeClassifyTemplateAttrDTO.getEnumString())){
            throw new VciBaseException("枚举注入数据格式错误!");
        }
 
        //判断传过来的参照配置是否是json格式
        if(StringUtils.isNotBlank(codeClassifyTemplateAttrDTO.getReferBtmId())&&!checkKVObj(codeClassifyTemplateAttrDTO.getReferBtmId())){
            throw new VciBaseException("枚举注入数据格式错误!");
        }
 
 
        //检查ts
        CodeClassifyTemplateAttr codeClassifyTemplateAttrDOCopyFromDTO = new CodeClassifyTemplateAttr();
//        BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDOCopyFromDTO);
//        boolean tsBoolean = boService.checkTs(codeClassifyTemplateAttrDOCopyFromDTO);
 
        //检查ts
//        Map<String,Object> condition = new HashMap<>(2);
//        condition.put("oid",codeClassifyTemplateAttrDTO.getOid());
//        condition.put("ts",codeClassifyTemplateAttrDTO.getTs());
        CodeClassifyTemplateAttr detail = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid());
        if(!detail.getTs().toString().equals(codeClassifyTemplateAttrDTO.getTs().toString())){//不是最新的不让改
            return R.fail("当前数据不是最新,请刷新后再修改!");
        }
 
        //将DTO转换为DO
        CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid());
        revisionModelUtil.copyFromDTOIgnore(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO);
        baseMapper.updateById(codeClassifyTemplateAttrDO);
        return R.data(codeClassifyTemplateAttrDO2VO(codeClassifyTemplateAttrDO));
    }
 
    /**
     * 删除主题库分类的模板属性
     * @param codeClassifyTemplateAttrDTO 主题库分类的模板属性数据传输对象,oid和ts需要传输
     * @return 删除结果反馈::success:成功,fail:失败
     * @throws VciBaseException 参数为空,被引用时抛出异常
     */
    @Override
    public R deleteCodeClassifyTemplateAttr(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{
        VciBaseUtil.alertNotNull(codeClassifyTemplateAttrDTO,"主题库分类的模板属性数据对象",codeClassifyTemplateAttrDTO.getOid(),"主题库分类的模板属性的主键");
        CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid());
        R baseResult = checkIsCanDeleteForDO(codeClassifyTemplateAttrDTO,codeClassifyTemplateAttrDO);
        if(baseResult.isSuccess()) {
        }else{
            return baseResult;
        }
        //执行删除操作
        int deleteNum = baseMapper.deleteById(codeClassifyTemplateAttrDO.getOid());
        return deleteNum>0?R.success(DELETE_SUCCESS):R.fail(DELETE_FAIL);
    }
 
    /**
     * 校验是否可以删除,如果存在下级,并且下级有数据引用则不能删除
     * @param codeClassifyTemplateAttrDTO 数据传输对象
     * @param codeClassifyTemplateAttrDO 数据库中的数据对象
     * @return success为true为可以删除,false表示有数据引用,obj为true表示有下级
     */
    private R checkIsCanDeleteForDO(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO, CodeClassifyTemplateAttr codeClassifyTemplateAttrDO) {
//        boService.checkTs(codeClassifyTemplateAttrDO);
//        Map<String,Object> condition = new HashMap<>(2);
//        condition.put("oid",codeClassifyTemplateAttrDTO.getOid());
//        condition.put("ts",codeClassifyTemplateAttrDTO.getTs());
        CodeClassifyTemplateAttr detail = baseMapper.selectById(codeClassifyTemplateAttrDTO.getOid());
//        .selectOne(Condition.getQueryWrapper(condition,CodeClstempattrEntity.class));
 
        if(!detail.getTs().toString().equals(codeClassifyTemplateAttrDTO.getTs().toString())){//不是最新的不让改
            return R.fail("当前数据不是最新,请刷新后再修改!");
        }
        if(!checkIsLinked(codeClassifyTemplateAttrDO.getOid())) {
            return R.success("可以删除!");
        }else{
            return R.fail(DATA_LINKED_NOT_DELETE);
        }
    }
 
    /**
     * 校验是否被引用
     * @param oid 主键
     * @throws VciBaseException 被引用的时候会抛出异常
     */
    private boolean checkIsLinked(String oid) throws VciBaseException{
        //TODO 添加需要校验引用的地方
        return false;
    }
 
    /**
     * 主键获取主题库分类的模板属性
     * @param oid 主键
     * @return 主题库分类的模板属性显示对象
     * @throws VciBaseException 参数为空,数据不存在时会抛出异常
     */
    @Override
    public  CodeClassifyTemplateAttrVO getObjectByOid(String oid) throws VciBaseException{
        return codeClassifyTemplateAttrDO2VO(selectByOid(oid));
    }
 
    /**
     * 主键查询数据对象
     * @param oid 主键
     * @return  数据对象
     * @throws VciBaseException 参数为空,并且数据不存在的时候会抛出异常
     */
    private CodeClassifyTemplateAttr selectByOid(String oid) throws VciBaseException{
        VciBaseUtil.alertNotNull(oid,"主键");
        CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = baseMapper.selectById(oid.trim());
        if(codeClassifyTemplateAttrDO == null || StringUtils.isBlank(codeClassifyTemplateAttrDO.getOid())){
            throw new VciBaseException(DATA_OID_NOT_EXIST);
        }
        return codeClassifyTemplateAttrDO;
    }
 
    /**
     * 主键批量获取主题库分类的模板属性
     * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个
     * @return 主题库分类的模板属性显示对象
     * @throws VciBaseException 查询出现异常时会抛出
     */
    @Override
    public Collection<CodeClassifyTemplateAttrVO> listCodeClassifyTemplateAttrByOids(Collection<String> oidCollections) {
        VciBaseUtil.alertNotNull(oidCollections,"数据对象主键集合");
        List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = listCodeClassifyTemplateAttrDOByOidCollections(oidCollections);
        return codeClassifyTemplateAttrDO2VOs(codeClassifyTemplateAttrDOList);
    }
 
    /**
     * 使用主键集合查询数据对象
     * @param oidCollections 主键的集合
     * @return 数据对象列表
     */
    private List<CodeClassifyTemplateAttr> listCodeClassifyTemplateAttrDOByOidCollections(Collection<String> oidCollections){
        List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = new ArrayList<CodeClassifyTemplateAttr>();
        if(!CollectionUtils.isEmpty(oidCollections)){
            Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections);
            for(Collection<String> oids: oidCollectionsList){
                List<CodeClassifyTemplateAttr> tempDOList = baseMapper.selectBatchIds(oids);
                if(!CollectionUtils.isEmpty(tempDOList)){
                    codeClassifyTemplateAttrDOList.addAll(tempDOList);
                }
            }
        }
        return  codeClassifyTemplateAttrDOList;
    }
 
    /**
     * 查询这个模板,业务类型下的所有未选择的属性
     * @param baseQueryObject
     * @return
     */
    @Override
    public DataGrid<BtmTypeAttributeVO> codeClassifyTemplateAttrByBtm(BaseQueryObject baseQueryObject){
        if(baseQueryObject.getConditionMap() == null){
            baseQueryObject.setConditionMap(new HashMap<>());
        }
        DataGrid<BtmTypeAttributeVO> dataGrid=new DataGrid<BtmTypeAttributeVO>();
        //模板oid
        String templateAttrOid = baseQueryObject.getConditionMap().get("oid");
        String name = baseQueryObject.getConditionMap().getOrDefault("name","");
        String id = baseQueryObject.getConditionMap().getOrDefault("id","");
 
        //没有oid不执行逻辑
        if(StringUtils.isBlank(templateAttrOid)){
            dataGrid.setData(new ArrayList<>());
            dataGrid.setTotal(0);
            return dataGrid;
        }
 
        //查询模板对象
        CodeClassifyTemplate codeClassifyTemplateDO = codeClassifyTemplateMapper.selectById(templateAttrOid);
        // 没有模板对象不执行逻辑
        if(Objects.isNull(codeClassifyTemplateDO)){
            dataGrid.setData(new ArrayList<>());
            dataGrid.setTotal(0);
            return dataGrid;
        }
        //这个业务类型下的所有属性
        R<BtmTypeVO> btmTypeVOR = btmTypeClient.getAllAttributeByBtmId(codeClassifyTemplateDO.getBtmTypeId());
        if(!btmTypeVOR.isSuccess()){
            throw new ServiceException("业务类型feign调用错误!");
        }
 
        //这个模板下已经有的属性
        // VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class);
        // queryWrapper.addQueryMap("CLASSIFYTEMPLATEOID",templateAttrOid);
        Map<String,Object> condition = new HashMap<>(1);
        condition.put("CLASSIFYTEMPLATEOID",templateAttrOid);
 
        List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = baseMapper.selectByMap(condition);
 
        List<String> btmIds = new ArrayList<String>();
        for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){
            btmIds.add(codeClassifyTemplateAttrDO.getId());
        }
 
        //过滤掉已经存在的属性
        List<BtmTypeAttributeVO> boAttrss = new ArrayList<BtmTypeAttributeVO>();
        for (BtmTypeAttributeVO osBtmTypeAttributeVO:btmTypeVOR.getData().getAttributes()){
            if(!btmIds.contains(osBtmTypeAttributeVO.getId())){
                //看看是不是有模糊查询
                boolean inSearch = true;
                if(StringUtils.isNotBlank(name) && !osBtmTypeAttributeVO.getName().contains(name.replace("*",""))){
                    inSearch = false;
                }
                if(StringUtils.isNotBlank(id) && !osBtmTypeAttributeVO.getId().contains(id.replace("*",""))){
                    inSearch = false;
                }
                if(inSearch) {
                    if(!VciFieldTypeEnum.VTDouble.equals(osBtmTypeAttributeVO.getAttrDataType())){
                        osBtmTypeAttributeVO.setPrecisionLength(null);
                        osBtmTypeAttributeVO.setScaleLength(null);
                    }
                    boAttrss.add(osBtmTypeAttributeVO);
                }
            }
        }
        // 按照id升序排序
        boAttrss = boAttrss.stream().sorted(Comparator.comparing(BtmTypeAttributeVO::getId)).collect(Collectors.toList());
        dataGrid.setData(boAttrss);
        dataGrid.setTotal(boAttrss.size());
        return dataGrid;
    }
 
    /**
     * 查询这个模板,业务类型下已选择的属性
     * @param baseQueryObject
     * @return
     */
    @Override
    public DataGrid<BtmTypeAttributeVO> codeClassifyTemplateAttrByBtmHave(BaseQueryObject baseQueryObject){
        DataGrid<BtmTypeAttributeVO> dataGrid=new DataGrid<BtmTypeAttributeVO>();
        //模板oid
        String templateAttrOid = baseQueryObject.getConditionMap().get("oid");
 
        //没有oid不执行逻辑
        if(StringUtils.isBlank(templateAttrOid)){
            dataGrid.setData(new ArrayList<>());
            dataGrid.setTotal(0);
            return dataGrid;
        }
 
        //查询模板对象
        CodeClassifyTemplate codeClassifyTemplateDO = codeClassifyTemplateMapper.selectById(templateAttrOid);
 
        //这个业务类型下的所有属性
        // TODO 已完善
        List<BtmTypeAttributeVO> boAttrs =  (List<BtmTypeAttributeVO>) btmTypeClient.getAllAttributeByBtmId(codeClassifyTemplateDO.getBtmTypeId());
        //这个模板下已经有的属性
        //把默认的属性也添加到boAttrs
        if(boAttrs == null){
            boAttrs = new ArrayList<>();
        }
        QueryWrapper<CodeClassifyTemplateAttr> wrapper=new QueryWrapper<>();
        wrapper.eq("CLASSIFYTEMPLATEOID",templateAttrOid);
 
        List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList = baseMapper.selectList(wrapper);
        List<String> btmOids = new ArrayList<String>();
        for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDO:codeClassifyTemplateAttrDOList){
            btmOids.add(codeClassifyTemplateAttrDO.getId());
        }
 
        //过滤掉除了自身的别的属性
        List<BtmTypeAttributeVO> boAttrss = new ArrayList<BtmTypeAttributeVO>();
 
        for (BtmTypeAttributeVO osBtmTypeAttributeVO:boAttrs){
            if(btmOids.contains(osBtmTypeAttributeVO.getId())){
                boAttrss.add(osBtmTypeAttributeVO);
            }
        }
        dataGrid.setData(boAttrss);
        dataGrid.setTotal(boAttrss.size());
        return dataGrid;
    }
 
    /**
     * 同步到其他模板
     * @param codeClassifyTemplateAttrDTO oid
     * @return
     */
    @Override
    public R copyto(CodeClassifyTemplateAttrDTO codeClassifyTemplateAttrDTO) throws VciBaseException{
 
        String templateAttrOid = codeClassifyTemplateAttrDTO.getOid();
 
        //查询出来要复制的对象
        CodeClassifyTemplateAttr codeClassifyTemplateAttrDO = selectByOid(templateAttrOid);
        String id = codeClassifyTemplateAttrDO.getId();//英文名称
        String classfyTemplateOid = codeClassifyTemplateAttrDO.getClassifyTemplateOid();
 
        //查询其他id=id的模板属性
//        VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(CodeClassifyTemplateAttrDO.class);
//        queryWrapper.addQueryMap("id",id);
//        Map<String,Object> condition = new HashMap<>(1);
//        condition.put("id",id);
        QueryWrapper<CodeClassifyTemplateAttr> wrapper=new QueryWrapper<>();
        wrapper.eq("id",id);
        //所有id=id的模板属性
        List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOList =baseMapper.selectList(wrapper);
 
        //要删除的模板属性的oids
        List<String> deleteOids = new ArrayList<String>();
        //要修改的模板属性对象
        List<CodeClassifyTemplateAttr> codeClassifyTemplateAttrDOListInsert = new ArrayList<CodeClassifyTemplateAttr>();
        for (CodeClassifyTemplateAttr codeClassifyTemplateAttrDOi:codeClassifyTemplateAttrDOList){
            String oid = codeClassifyTemplateAttrDOi.getOid();
            String templateOldOid = codeClassifyTemplateAttrDOi.getClassifyTemplateOid();
 
            CodeClassifyTemplateAttr codeClassifyTemplateAttrDOInsert = new CodeClassifyTemplateAttr();
            BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,codeClassifyTemplateAttrDOInsert);
            codeClassifyTemplateAttrDOInsert.setOid(oid);
            codeClassifyTemplateAttrDOInsert.setClassifyTemplateOid(templateOldOid);
            codeClassifyTemplateAttrDOListInsert.add(codeClassifyTemplateAttrDOInsert);
 
            deleteOids.add(codeClassifyTemplateAttrDOi.getOid());
        }
 
//        WebUtil.setPersistence(false);//不执行保存
 
        //删除
//        BatchCBO batchCBOTemplateAttrDelete = codeClassifyTemplateAttrDOissifyTemplateAttrMapper.batchDeleteByOids(deleteOids);
        baseMapper.deleteBatchIds(deleteOids);
        //再新增
//        BatchCBO batchCBOTemplateAttrInsert = codeClassifyTemplateAttrMapper.batchInsert(codeClassifyTemplateAttrDOListInsert);
//        batchCBOTemplateAttrDelete.copyFromOther(batchCBOTemplateAttrInsert);
        this.saveBatch(codeClassifyTemplateAttrDOListInsert);
 
//        WebUtil.setPersistence(true);//执行保存
//        boService.persistenceBatch(batchCBOTemplateAttrDelete);//一起执行保存
 
        return R.success("操作成功!");
    }
 
    /**
     * 使用查询封装器来查询
     * @param wrapper 查询封装器
     * @return 数据对象
     */
    @Override
    public List<CodeClassifyTemplateAttr> selectByWrapper(Wrapper wrapper) {
        return codeClassifyTemplateAttrMapper.selectList(wrapper);
    }
 
}