Merge branch 'develop_migration' into 'develop_master'
feat: There is no way the, See merge request LiuChao/foton-slrs-system-rest!293
This commit is contained in:
@@ -59,9 +59,6 @@ public class AttFileEOController {
|
||||
@Value("${file.path}")
|
||||
private String filePath;//文件存储路径
|
||||
|
||||
@Value("${stand.edit.file.path}")
|
||||
private String standEditFilePath;
|
||||
|
||||
// @Autowired
|
||||
// private RoleEOService roleEOService;
|
||||
//
|
||||
@@ -79,82 +76,6 @@ public class AttFileEOController {
|
||||
return Result.success(attFileEO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "|onlyOffice接收文件")
|
||||
@PostMapping("/recieveFile")
|
||||
public void recieveFile(HttpServletRequest request, HttpServletResponse response, String fileNm,String standNo){
|
||||
logger.info("**********进入onlyoffice接收文档接口************");
|
||||
try {
|
||||
PrintWriter writer = response.getWriter();
|
||||
String body = "";
|
||||
try {
|
||||
Scanner scanner = new Scanner(request.getInputStream());
|
||||
scanner.useDelimiter("\\A");
|
||||
body = scanner.hasNext() ? scanner.next() : "";
|
||||
scanner.close();
|
||||
} catch (Exception ex) {
|
||||
writer.write("get request.getInputStream error:" + ex.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (body.isEmpty()) {
|
||||
writer.write("empty request.getInputStream");
|
||||
return;
|
||||
}
|
||||
|
||||
net.sf.json.JSONObject jsonObj = net.sf.json.JSONObject.fromObject(body);
|
||||
logger.info("**********onlyoffice接收文档接口获得结果body************" + body);
|
||||
int status = (Integer) jsonObj.get("status");
|
||||
|
||||
int saved = 0;
|
||||
if (status == 2 || status == 3)//MustSave, Corrupted
|
||||
{
|
||||
String downloadUri = (String) jsonObj.get("url");
|
||||
|
||||
try {
|
||||
logger.info("**********onlyoffice接收文档接口获得downloadUri************" + downloadUri);
|
||||
if (StringUtils.isNotEmpty(downloadUri)) {
|
||||
File file = new File(standEditFilePath + standNo + "\\" + fileNm);
|
||||
downloadNetFile(downloadUri, file);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
saved = 1;
|
||||
logger.info("**********onlyoffice接收文档接口异常************" + ex.getMessage());
|
||||
logger.error(ex.getMessage(),ex);
|
||||
}
|
||||
} else if (status == 4) {
|
||||
logger.info("**********onlyoffice接收文档接口开始修改文件状态状态4************");
|
||||
|
||||
logger.info("**********onlyoffice接收文档接口修改文件状态成功状态4************");
|
||||
}
|
||||
logger.info("onlyoffice编辑完成--------------");
|
||||
writer.write("{\"error\":" + saved + "}");
|
||||
} catch (IOException e) {
|
||||
logger.info("**********onlyoffice接收文档接口异常************" + e.getMessage());
|
||||
logger.error(e.getMessage(),e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void downloadNetFile(String downloadUrl, File file) {
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
URL url = new URL(downloadUrl);
|
||||
URLConnection connection = url.openConnection();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
int length = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
while ((length = inputStream.read(bytes)) != -1) {
|
||||
fileOutputStream.write(bytes, 0, length);
|
||||
}
|
||||
fileOutputStream.close();
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
logger.error("download error ! url :{}, exception:{}", downloadUrl, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value="|File|上传文件")
|
||||
@PostMapping(value="/upload",consumes="multipart/*",headers="content-type=multipart/form-data" )
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
|
||||
Reference in New Issue
Block a user