田源
2024-12-03 e973fb747f0d1a382fb9e4cdb20383a0a546ef67
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
package com.vci.web.util.file.clientutil;
 
import com.vci.dto.VciFileDocClassifyDTO;
import com.vci.dto.VciFileDocClassifyDTOList;
import com.vci.pagemodel.VciFileDocClassifyVO;
import com.vci.provider.VciFileDocClassifyProvider;
import com.vci.starter.web.exception.VciBaseException;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.util.LangBaseUtil;
import com.vci.starter.web.util.VciBaseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * @author ludc
 * @date 2024/7/16 14:37
 */
public class VciFileDocClassifyClientUtil {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private VciFileDocClassifyProvider fileDocClassifyProvider;
 
    public VciFileDocClassifyClientUtil() {
    }
 
    public void classifyIdNotExistAdd(Map<String, String> classifyIdMap) throws VciBaseException {
        if (!CollectionUtils.isEmpty(classifyIdMap)) {
            try {
                BaseResult baseResult = this.fileDocClassifyProvider.checkClassifyIdsExist((String)classifyIdMap.keySet().stream().collect(Collectors.joining(",")));
                if (baseResult == null) {
                    throw new VciBaseException("在查询文件类型是否存在时,服务端没有返回结果值");
                }
 
                if (!baseResult.isSuccess() && !CollectionUtils.isEmpty(baseResult.getData())) {
                    List<VciFileDocClassifyDTO> fileDocClassifyDTOS = new ArrayList();
                    baseResult.getData().stream().forEach((id) -> {
                        VciFileDocClassifyDTO classifyDTO = new VciFileDocClassifyDTO();
                        classifyDTO.setId(id.toString());
                        classifyDTO.setName((String)classifyIdMap.get(id));
                        classifyDTO.setDescription("系统内置的文件类型,请勿更改和删除");
                        fileDocClassifyDTOS.add(classifyDTO);
                    });
                    VciFileDocClassifyDTOList classifyDTOList = new VciFileDocClassifyDTOList();
                    classifyDTOList.setDocClassifyDTOList(fileDocClassifyDTOS);
 
                    try {
                        baseResult = this.fileDocClassifyProvider.batchAddClassify(classifyDTOList);
                        if (baseResult == null) {
                            throw new VciBaseException("添加文件类型时,服务端没有返回结果值");
                        }
 
                        if (!baseResult.isSuccess()) {
                            throw new VciBaseException("创建系统内置的文件类型没有成功,服务端没有返回任何信息");
                        }
                    } catch (VciBaseException var7) {
                        throw var7;
                    } catch (Throwable var8) {
                        String msg = LangBaseUtil.getErrorMsg(var8);
                        if (this.logger.isErrorEnabled()) {
                            this.logger.error(msg, var8);
                        }
 
                        throw new VciBaseException(msg, new String[0], var8);
                    }
                }
            } catch (VciBaseException var9) {
                throw var9;
            } catch (Throwable var10) {
                String msg = LangBaseUtil.getErrorMsg(var10);
                if (this.logger.isErrorEnabled()) {
                    this.logger.error(msg, var10);
                }
 
                throw new VciBaseException(msg, new String[0], var10);
            }
        }
 
    }
 
    public String selectDocClassifyNameById(String id) throws VciBaseException {
        VciFileDocClassifyVO docClassifyVO = this.selectDocClassifyVOById(id);
        return docClassifyVO != null ? docClassifyVO.getName() : "";
    }
 
    public VciFileDocClassifyVO selectDocClassifyVOById(String id) throws VciBaseException {
        VciBaseUtil.alertNotNull(new Object[]{id, "文档类型编号"});
 
        try {
            BaseResult baseResult = this.fileDocClassifyProvider.getFileDocClassifyById(id);
            if (baseResult == null) {
                throw new VciBaseException("在查询文件类型是否存在时,服务端没有返回结果值");
            } else if (!baseResult.isSuccess()) {
                throw new VciBaseException(baseResult.getMsg(), baseResult.getMsgObjs());
            } else {
                return (VciFileDocClassifyVO)baseResult.getObj();
            }
        } catch (VciBaseException var4) {
            throw var4;
        } catch (Throwable var5) {
            String msg = LangBaseUtil.getErrorMsg(var5);
            if (this.logger.isErrorEnabled()) {
                this.logger.error(msg, var5);
            }
 
            throw new VciBaseException(msg, new String[0], var5);
        }
    }
}