package com.lxzn.activiti.service; import com.eetrust.label.LabelOperator; import com.lxzn.framework.exception.ExceptionCast; import com.lxzn.framework.model.response.CommonCode; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; /** * @Description: * @Author: zhangherong * @Date: Created in 2021/5/26 16:17 * @Version: 1.0 * @Modified By: */ @Component @Slf4j public class SecureDocService { @Value("${securedoc.serverIp}") private String serverIp; @Value("${securedoc.serverPort}") private int serverPort; @Value("${securedoc.identifier}") private String identifier; @Value("${securedoc.binFileLabel}") private String binFileLabel; @Value("${securedoc.editFileLabel}") private String editFileLabel; public void binByFileLable(String fileName){ LabelOperator labelOperator = new LabelOperator(serverIp,serverPort); //默认不开启 //fase 远程调用MB服务 //true 调用本地MB服务 labelOperator.setLocalService(false); //设置本地工程编码格式(UTF_8、GBK),默认为UTF_8 //labelOperator.setCharacter(CharacterEnums.UTF_8); short fileFrom = 0; int bindFileLabel = labelOperator.bindFileLabel(identifier, fileName , binFileLabel ,fileFrom); if(bindFileLabel == 0){ log.info("文件预定密成功,{}", fileName); }else{ ExceptionCast.cast(CommonCode.SECURE_DOC_BIN_LABEL_ERROR); } } public void editLabelByPath(String path){ LabelOperator labelOperator = new LabelOperator(serverIp,serverPort); //设置本地工程编码格式(UTF_8、GBK),默认为UTF_8 //labelOperator.setCharacter(CharacterEnums.UTF_8); //默认不开启 //fase 远程调用MB服务 //true 调用本地MB服务 labelOperator.setLocalService(false); log.info("editFileLabel={},identifier={},path={}", editFileLabel, identifier, path); int modifyFileLabel = labelOperator.modifyFileLabel(identifier,path,editFileLabel); if(modifyFileLabel == 0){ log.info("文件正式定密成功,{}", path); }else{ ExceptionCast.cast(CommonCode.SECURE_DOC_EDIT_LABEL_ERROR); } } }