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);
|
}
|
}
|
}
|