政企WPS
This commit is contained in:
@ -318,7 +318,7 @@ public class WpsController {
|
||||
businessIdList2.add(tempDocFileId);
|
||||
Optional<AttachmentDetail> optional2 = attachmentClient.findByBusinessId(businessIdList2);
|
||||
AttachmentDetail detail = optional2.get();
|
||||
List<AttachmentEntity> entityList = detail.get(fileId[0]);
|
||||
List<AttachmentEntity> entityList = detail.get(tempDocFileId);
|
||||
Optional<byte[]> optional1 = attachmentClient.downloadFileByObjectId(entityList.get(0).getId());
|
||||
if(optional1!=null&&optional1.isPresent()) {
|
||||
fileLength = String.valueOf(optional1.get().length);
|
||||
|
@ -29,6 +29,4 @@ public interface WpsService{
|
||||
String downloadDecrypt(String key);
|
||||
|
||||
Map<String,String> saveKSFile(KingSoftFileSaveVo vo);
|
||||
|
||||
public byte[] uploadTempFile(String fileExtension);
|
||||
}
|
||||
|
@ -130,6 +130,8 @@ public class WpsServiceImpl implements WpsService {
|
||||
private String kswpsurl;
|
||||
@Value("${KingSoftWps.kswpsurl-preview}")
|
||||
private String kswpsurl_preview;
|
||||
@Value("${KingSoftWps.tempDocFileId}")
|
||||
private String tempDocFileId;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@ -716,37 +718,30 @@ public class WpsServiceImpl implements WpsService {
|
||||
}
|
||||
}
|
||||
}
|
||||
//没有文件 上传模板一份
|
||||
if(uploadB){
|
||||
buf = uploadTempFile(fileExtension);
|
||||
log.info(" 没有文件 上传模板一份 "+id+" | "+fileName+" | "+fileExtension);
|
||||
uploadTempFile(id,fileName,fileExtension);
|
||||
log.info(" 没有文件 上传模板一份 成功");
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
@Override
|
||||
public byte[] uploadTempFile(String fileExtension){
|
||||
String text = "1111";
|
||||
byte buf[] = text.getBytes();
|
||||
File tempFile = null;
|
||||
private void uploadTempFile(String fileid,String fileName,String fileExtension){
|
||||
try {
|
||||
tempFile = File.createTempFile("tempDoc", "."+fileExtension);
|
||||
tempFile.deleteOnExit(); // 在程序退出时删除临时文件
|
||||
|
||||
byte[] b = " ".getBytes();
|
||||
OutputStream out = new FileOutputStream(tempFile);
|
||||
out.write(b);
|
||||
out.close();
|
||||
|
||||
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(tempFile));
|
||||
buf = IOUtils.toByteArray(bis);
|
||||
log.info("buf:"+buf.length);
|
||||
List<String> businessIdList2 = new ArrayList<>();
|
||||
businessIdList2.add(tempDocFileId);
|
||||
Optional<AttachmentDetail> optional2 = attachmentClient.findByBusinessId(businessIdList2);
|
||||
AttachmentDetail detail = optional2.get();
|
||||
List<AttachmentEntity> entityList = detail.get(tempDocFileId);
|
||||
Optional<byte[]> optional1 = attachmentClient.downloadFileByObjectId(entityList.get(0).getId());
|
||||
if(optional1!=null&&optional1.isPresent()) {
|
||||
byte buf[] = optional1.get();
|
||||
Optional<UploadObject> op=attachmentClient.upload(fileid,fileName+"."+fileExtension,buf);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("读取异常",e);
|
||||
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("模板文件读取异常",true);
|
||||
}finally {
|
||||
if(tempFile!=null) {
|
||||
tempFile.deleteOnExit();
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user