| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.volume.VolumeServicePrx; |
| | | import com.vci.file.constant.VciFileDefaultValueConstant; |
| | | import com.vci.file.constant.VciFileLangCodeConstant; |
| | |
| | | */ |
| | | @Override |
| | | public BaseResult uploadFile(MultipartFile multipartFile, VciFileObjectDTO fileObjectDTO) throws VciBaseException { |
| | | VciBaseUtil.alertNotNull(fileObjectDTO.getFileDocClassify(), "文档类型编号"); |
| | | |
| | | String sourceFileName = multipartFile.getOriginalFilename(); |
| | | String fileExtension = getFileExtension(sourceFileName); |
| | | String fileNameNoExtension = getFileNameNoExtension(sourceFileName); |
| | |
| | | } |
| | | InputStream in = null; |
| | | if("filePathField".equalsIgnoreCase(vciFileObjectDO.getFileDocClassify())){ |
| | | vciFileObjectDO.setFilePath(vciFileVolumeDO.getId().toLowerCase() + ":/" + vciFileObjectDO.getFilePath() + "." + vciFileObjectDO.getFileExtension()); |
| | | vciFileObjectDO.setFilePath(vciFileVolumeDO.getId() + ":/" + vciFileObjectDO.getFilePath() + "." + vciFileObjectDO.getFileExtension()); |
| | | }else { |
| | | vciFileObjectDO.setFilePath(vciFileVolumeDO.getId().toLowerCase() + ":/" + vciFileObjectDO.getFilePath()); |
| | | vciFileObjectDO.setFilePath(vciFileVolumeDO.getId() + ":/" + vciFileObjectDO.getFilePath()); |
| | | } |
| | | try{ |
| | | long currentTime = volumnCorbaService.getCurrrentTimeMillions(); |
| | | in = multipartFile.getInputStream(); |
| | | long fileSize = multipartFile.getSize(); |
| | | int blockSize = (int)webProperties.getBlockLength()*1024; |
| | | int blockSize = webProperties.getBlockLength()*1024; |
| | | byte[] buffer = new byte[blockSize]; |
| | | long temp =0L; |
| | | for(temp = 0L; temp < fileSize - (long)blockSize; temp += (long)blockSize) { |
| | |
| | | sourceFileObject.setFileSize(vciFileObjectDO.getFileSize()); |
| | | vciFileObjectMapper.updateByPrimaryKey(sourceFileObject); |
| | | //没办法删除之前的文件, |
| | | |
| | | String volumeName = vciFileVolumeDO.getName(); |
| | | VolumeServicePrx volumnCorbaService = platformClientUtil.getVolumeService(volumeName); |
| | | if(volumnCorbaService == null){ |
| | | throw new VciBaseException("没有获取到卷服务"); |
| | | } |
| | | try { |
| | | volumnCorbaService.deleteFile(sourceFileObject.getFilePath()); |
| | | } catch (PLException e) { |
| | | e.printStackTrace(); |
| | | System.out.println("删除仓库中的文件失败:"+e.getMessage()); |
| | | } |
| | | }else { |
| | | vciFileObjectMapper.insert(vciFileObjectDO); |
| | | } |