lihang
2023-05-04 3579af2945dd38d841a23cd340acd474bb63773a
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
/*
 *      Copyright (c) 2018-2028, Chill Zhuang 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 dreamlu.net 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: Chill 庄骞 (smallchill@163.com)
 */
package com.vci.ubcs.code.service.impl;
 
import com.vci.ubcs.code.entity.CodeKeyattrrepeatEntity;
import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus;
import com.vci.ubcs.code.vo.CodeKeyattrrepeatVO;
import com.vci.ubcs.code.mapper.CodeKeyattrrepeatMapper;
import com.vci.ubcs.code.service.ICodeKeyattrrepeatService;
import com.vci.ubcs.code.vo.pagemodel.CodeKeyAttrRepeatRuleVO;
import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.util.CollectionUtils;
 
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
 
/**
 * 关键属性查重规则 服务实现类
 *
 * @author yuxc
 * @since 2023-04-03
 */
@Service
public class CodeKeyattrrepeatServiceImpl implements ICodeKeyattrrepeatService {
 
    @Autowired
    CodeKeyattrrepeatMapper codeKeyattrrepeatMapper;
 
    @Override
    public IPage<CodeKeyattrrepeatVO> selectPlCodeKeyattrrepeatPage(IPage<CodeKeyattrrepeatVO> page, CodeKeyattrrepeatVO plCodeKeyattrrepeat) {
        return page.setRecords(codeKeyattrrepeatMapper.selectPlCodeKeyattrrepeatPage(page, plCodeKeyattrrepeat));
    }
 
    /**
     * 主键批量获取关键数据查重规则
     *
     * @param oidCollections 主键集合,但是受性能影响,建议一次查询不超过10000个
     * @return 关键数据查重规则显示对象
     */
    @Override
    public List<CodeKeyAttrRepeatRuleVO> listCodeKeyAttrRepeatRuleByOids(Collection<String> oidCollections) {
        VciBaseUtil.alertNotNull(oidCollections,"数据对象主键集合");
        List<CodeKeyattrrepeatEntity> codeKeyAttrRepeatRuleDOList = listCodeKeyAttrRepeatRuleDOByOidCollections(oidCollections);
        return codeKeyAttrRepeatRuleDO2VOs(codeKeyAttrRepeatRuleDOList);
    }
 
    /**
     * 批量数据对象转换为显示对象
     * @param codeKeyattrrepeatEntityS 数据对象列表
     * @return 显示对象
     */
    @Override
    public List<CodeKeyAttrRepeatRuleVO> codeKeyAttrRepeatRuleDO2VOs(Collection<CodeKeyattrrepeatEntity>  codeKeyattrrepeatEntityS){
        List<CodeKeyAttrRepeatRuleVO> voList = new ArrayList<CodeKeyAttrRepeatRuleVO>();
        if(!CollectionUtils.isEmpty(codeKeyattrrepeatEntityS)){
            for(CodeKeyattrrepeatEntity s: codeKeyattrrepeatEntityS){
                CodeKeyAttrRepeatRuleVO vo =  codeKeyAttrRepeatRuleDO2VO(s);
                if(vo != null){
                    voList.add(vo);
                }
            }
        }
        return voList;
    }
 
    /**
     * 使用主键集合查询数据对象
     * @param oidCollections 主键的集合
     * @return 数据对象列表
     */
    private List<CodeKeyattrrepeatEntity> listCodeKeyAttrRepeatRuleDOByOidCollections(Collection<String> oidCollections){
        List<CodeKeyattrrepeatEntity> codeKeyAttrRepeatRuleDOList = new ArrayList<CodeKeyattrrepeatEntity>();
        if(!CollectionUtils.isEmpty(oidCollections)){
            Collection<Collection<String>> oidCollectionsList = VciBaseUtil.switchCollectionForOracleIn(oidCollections);
            for(Collection<String> oids: oidCollectionsList){
                List<CodeKeyattrrepeatEntity> tempDOList =  codeKeyattrrepeatMapper.selectBatchIds(oids);
                if(!CollectionUtils.isEmpty(tempDOList)){
                    codeKeyAttrRepeatRuleDOList.addAll(tempDOList);
                }
            }
        }
        return  codeKeyAttrRepeatRuleDOList;
    }
 
 
    /**
     * 数据对象转换为显示对象
     * @param  codeKeyattrrepeatEntity 数据对象
     * @return 显示对象
     */
    @Override
    public  CodeKeyAttrRepeatRuleVO codeKeyAttrRepeatRuleDO2VO(CodeKeyattrrepeatEntity codeKeyattrrepeatEntity) {
        CodeKeyAttrRepeatRuleVO vo = new CodeKeyAttrRepeatRuleVO();
        if(codeKeyattrrepeatEntity != null) {
            BeanUtilForVCI.copyPropertiesIgnoreCase(codeKeyattrrepeatEntity, vo);
            //如果有lcstatus的类的话
            vo.setLcStatusText(FrameworkDataLCStatus.getTextByValue(vo.getLcStatus()));
        }
        return vo;
    }
}