Response re = client.get(ZYOAurl + "/zhiYuanOAForSync/synchrodownSW?id=" + oaFile.getId() + "&filetoken=" + filetoken + "&fileUrl=" + fileUrl + "&fileType=" + fileType);
@Transactional(rollbackFor = Exception.class)
@SuppressWarnings("rawtypes")
@AutoLog(value = "把文件发给人力")
@GetMapping(value = "/synchrodownSW")
public String synchrodownSW(String id, String filetoken, String fileUrl, String fileType, HttpResponse re) throws Exception {
// 将上传的文件使用OA文件ID进行保存
// String newFilename = oaFile.getId() + "." + fileType;
String newFilename = id + "." + fileType;
// 创建本地服务器保存文件的地址,按照年月创建文件夹
// 获取当前年月
SimpleDateFormat sformat = new SimpleDateFormat("yyyy-MM");// 日期格式
String yearmonth = sformat.format(new Date());
String path = uploadpath + "//renli//" + yearmonth;
File filePath = new File(path);
if (!filePath.exists()) {// 如果目录已存在,则不再重新创建
filePath.mkdirs();
}
StringBuffer parameters = new StringBuffer();
parameters.append("fileId=" + fileUrl);
parameters.append("&token=" + filetoken);
URL preUrl = null;
URLConnection uc = null;
preUrl = new URL(ZYOAurl + "/seeyon/services/downloadService");
String s = parameters.toString();
uc = preUrl.openConnection();
uc.setDoOutput(true);
uc.setUseCaches(false);
uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
HttpURLConnection hc = (HttpURLConnection) uc;
hc.setRequestMethod("POST");
OutputStream os = hc.getOutputStream();
DataOutputStream dos = new DataOutputStream(os);
//dos.writeBytes(s);
String fileString = dos.toString();
System.out.println("fileString:" + fileString);
dos.flush();
dos.close();
return fileString;
}
暂无回答
我要回答