| | |
| | | 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); |
| | |
| | | if(vciFileObjectDO.getSecretGrade() == null) { |
| | | vciFileObjectDO.setSecretGrade(DataSecretEnum.NONE.getValue()); |
| | | } |
| | | //todo 先写固定 |
| | | vciFileObjectDO.setCreator("admin"); |
| | | vciFileObjectDO.setLastModifier("admin"); |
| | | // revisionModelUtil.wrapperForAdd(vciFileObjectDO); |
| | | revisionModelUtil.wrapperForAdd(vciFileObjectDO); |
| | | //随机路径 |
| | | // String randomPath = VciBaseUtil.getPk(); |
| | | String randomPath = "rrt"; |
| | | String randomPath = VciBaseUtil.getPk(); |
| | | //目标文件 |
| | | // String targetFileName = vciFileObjectDO.getOid(); |
| | | String targetFileName = VciBaseUtil.getPk(); |
| | | String targetFileName = vciFileObjectDO.getOid(); |
| | | |
| | | String filePath = randomPath+File.separator+targetFileName; |
| | | |
| | |
| | | } |
| | | InputStream in = null; |
| | | if("filePathField".equalsIgnoreCase(vciFileObjectDO.getFileDocClassify())){ |
| | | vciFileObjectDO.setFilePath(volumeName + ":/" + vciFileObjectDO.getFilePath() + "." + vciFileObjectDO.getFileExtension()); |
| | | vciFileObjectDO.setFilePath(vciFileVolumeDO.getId() + ":/" + vciFileObjectDO.getFilePath() + "." + vciFileObjectDO.getFileExtension()); |
| | | }else { |
| | | vciFileObjectDO.setFilePath(volumeName + ":/" + 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); |
| | | } |