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
/*
 *      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.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vci.ubcs.code.entity.CodeClstempattrEntity;
import com.vci.ubcs.code.mapper.CodeClstempattrMapper;
import com.vci.ubcs.code.service.ICodeClstempattrService;
import com.vci.ubcs.code.vo.CodeClstempattrVO;
 
import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum;
import com.vci.ubcs.starter.web.util.BeanUtilForVCI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
 
/**
 * 编码库定义-模板属性 服务实现类
 *
 * @author yuxc
 * @since 2023-04-19
 */
@Service
public class CodeClstempattrServiceImpl extends ServiceImpl<CodeClstempattrMapper, CodeClstempattrEntity> implements ICodeClstempattrService {
 
    @Resource
    CodeClstempattrMapper codeClstempattrMapper;
 
    @Override
    public IPage<CodeClstempattrVO> selectCodeClstempattrPage(IPage<CodeClstempattrVO> page, CodeClstempattrVO CodeClstempattr) {
        return page.setRecords(baseMapper.selectCodeClstempattrPage(page, CodeClstempattr));
    }
 
 
    /**
     * 使用模板的主键获取模板的属性--批量
     *
     * @param templateOidCollection 模板的主键
     * @return 属性的信息
     */
    @Override
    public List<CodeClstempattrVO> listCodeClassifyTemplateAttrByTemplateOids(Collection<String> templateOidCollection) {
        if(CollectionUtils.isEmpty(templateOidCollection)){
            return new ArrayList<>();
        }
        List<CodeClstempattrEntity> 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<CodeClstempattrEntity> 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<CodeClstempattrVO> codeClassifyTemplateAttrDO2VOs(Collection<CodeClstempattrEntity>  codeClassifyTemplateAttrDOs){
        List<CodeClstempattrVO> voList = new ArrayList<CodeClstempattrVO>();
        if(!CollectionUtils.isEmpty(codeClassifyTemplateAttrDOs)){
            for(CodeClstempattrEntity s: codeClassifyTemplateAttrDOs){
                CodeClstempattrVO vo =  codeClassifyTemplateAttrDO2VO(s);
                if(vo != null){
                    voList.add(vo);
                }
            }
        }
        return voList;
    }
 
    /**
     * 数据对象转换为显示对象
     * @param  codeClassifyTemplateAttrDO 数据对象
     * @return 显示对象
     */
    @Override
    public  CodeClstempattrVO codeClassifyTemplateAttrDO2VO(CodeClstempattrEntity codeClassifyTemplateAttrDO){
        CodeClstempattrVO vo = new CodeClstempattrVO();
        if(codeClassifyTemplateAttrDO != null){
            BeanUtilForVCI.copyPropertiesIgnoreCase(codeClassifyTemplateAttrDO,vo);
            //如果有lcstatus的类的话
            vo.setAttributeDataTypeText(VciFieldTypeEnum.getTextByValue(vo.getAttributedatatype()));
        }
        return vo;
    }
}