| | |
| | | if (!StringUtils.isEmpty(document_template_tail)) { |
| | | fileList.add(fileManagerService.getFile(document_template_tail)); |
| | | } |
| | | File mergeFile = MergeDoc.mergeDoc(fileList, Global.getSystemConfig("upload.file.temp.path", "./attachment/temp") + |
| | | File.separator + "nest_red_document_" + IdUtil.randomUUID() + "_" + ff.getString("file_uuid")); |
| | | File mergeFile = MergeDoc.mergeDoc(fileList, Global.getSystemConfig("upload.file.temp.path", "./attachment/temp") + File.separator + "nest_red_document_" + IdUtil.randomUUID() + "_" + ff.getString("file_uuid")); |
| | | if (mergeFile != null && mergeFile.isFile()) { |
| | | if ("doc".equals(fileType)) { |
| | | //将docx文件转换为doc文件 |
| | |
| | | return; |
| | | } |
| | | //正则匹配redis中的key |
| | | try (Jedis jedis = RedisUtil.getJedis()) { |
| | | Set<String> keys = jedis.keys(this.DOCUMENT_EDIT_KEY + "*-" + userId); |
| | | if (keys != null && keys.size() > 0) { |
| | | //清空redis |
| | | RedisUtil.del(keys.toArray(new String[keys.size()])); |
| | | Set<byte[]> keys = RedisUtil.keys(this.DOCUMENT_EDIT_KEY + "*-" + userId); |
| | | if (keys != null && keys.size() > 0) { |
| | | String[] strKeys = new String[keys.size()]; |
| | | int i = 0; |
| | | for (byte[] key : keys) { |
| | | strKeys[i++] = new String(key); |
| | | } |
| | | //清空redis |
| | | RedisUtil.del(keys.toArray(new String[keys.size()])); |
| | | } |
| | | } |
| | | |
| | |
| | | throw new BaseException(FileCode.GET_FILE_RECORD_FAIL); |
| | | } |
| | | String key = this.DOCUMENT_EDIT_KEY + fileUuid + "-" + userId; |
| | | try (Jedis jedis = RedisUtil.getJedis()) { |
| | | //模糊匹配key |
| | | Set<byte[]> keyBytes = jedis.keys((this.DOCUMENT_EDIT_KEY + fileUuid + "-*").getBytes(StandardCharsets.UTF_8)); |
| | | if (!CollectionUtil.isEmpty(keyBytes)) { |
| | | Set<String> keys = keyBytes.stream().map(item -> new String(item, StandardCharsets.UTF_8)).collect(Collectors.toSet()); |
| | | boolean remove = keys.remove(this.DOCUMENT_EDIT_KEY + fileUuid + "-" + userId); |
| | | if (keys != null && keys.size() > 0) { |
| | | //正在被编辑 |
| | | String existsKey = keys.toArray(new String[]{})[0]; |
| | | //这里会抛出正在编辑的异常 |
| | | throwBeingEditDocument(existsKey.substring(existsKey.lastIndexOf("-") + 1)); |
| | | } else if (remove) { |
| | | RedisUtil.setOutTime(key, getExpirationTime()); |
| | | return; |
| | | } |
| | | //模糊匹配key |
| | | Set<byte[]> keyBytes = RedisUtil.keys((this.DOCUMENT_EDIT_KEY + fileUuid + "-*").getBytes(StandardCharsets.UTF_8)); |
| | | if (!CollectionUtil.isEmpty(keyBytes)) { |
| | | Set<String> keys = keyBytes.stream().map(item -> new String(item, StandardCharsets.UTF_8)).collect(Collectors.toSet()); |
| | | boolean remove = keys.remove(this.DOCUMENT_EDIT_KEY + fileUuid + "-" + userId); |
| | | if (keys != null && keys.size() > 0) { |
| | | //正在被编辑 |
| | | String existsKey = keys.toArray(new String[]{})[0]; |
| | | //这里会抛出正在编辑的异常 |
| | | throwBeingEditDocument(existsKey.substring(existsKey.lastIndexOf("-") + 1)); |
| | | } else if (remove) { |
| | | RedisUtil.setOutTime(key, getExpirationTime()); |
| | | return; |
| | | } |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("userId", userId); |
| | | params.put("fileUuid", fileUuid); |
| | | params.put("uniqueKey", IdUtil.randomUUID()); |
| | | RedisUtil.set(key, params); |
| | | RedisUtil.setOutTime(key, getExpirationTime()); |
| | | } |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("userId", userId); |
| | | params.put("fileUuid", fileUuid); |
| | | params.put("uniqueKey", IdUtil.randomUUID()); |
| | | RedisUtil.set(key, params); |
| | | RedisUtil.setOutTime(key, getExpirationTime()); |
| | | } |
| | | |
| | | /** |