附件上传,按照日期存放

master
bmpandlcm 12 months ago
parent 68d8235def
commit 6c42ab9656

@ -57,7 +57,6 @@ public class FileController {
filePath.mkdir(); filePath.mkdir();
} }
JSONArray from = JSONObject.parseArray(jsonArray); JSONArray from = JSONObject.parseArray(jsonArray);
LogUtil.WriteLog_Info("附件上传接口====jsonArray====" + jsonArray, "FileController");
if (from.size() > 0) { if (from.size() > 0) {
for (int k = 0; k < from.size(); k++) { for (int k = 0; k < from.size(); k++) {
JSONObject map = (JSONObject) from.get(k); JSONObject map = (JSONObject) from.get(k);

@ -92,7 +92,7 @@ public class HttpClientUtil {
}else{ }else{
resultString = "http请求失败"; resultString = "http请求失败";
} }
LogUtil.WriteLog_Info("远程接口请求返回code=========" + response.getStatusLine().getStatusCode(), "FileController");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
LogUtil.WriteLog_Info("远程接口请求报错HttpClientUtil=========" + e.getMessage(), "FileController"); LogUtil.WriteLog_Info("远程接口请求报错HttpClientUtil=========" + e.getMessage(), "FileController");

@ -158,9 +158,13 @@ public class ImageUtils {
mapParam.put("imageBase64", retStr); mapParam.put("imageBase64", retStr);
jsonA.add(mapParam); jsonA.add(mapParam);
map.put("jsonArray", jsonA.toJSONString()); map.put("jsonArray", jsonA.toJSONString());
String s = HttpClientUtil.doPost(fileUploadUrl, map); String[] split = fileUploadUrl.split(",");
LogUtil.WriteLog_Info("ImageUtils====附件上传结果显示END=====" + s, "FileController"); if (split.length > 0) {
for (String strPath : split) {
String s = HttpClientUtil.doPost(strPath, map);
LogUtil.WriteLog_Info("ImageUtils====附件上传结果显示END==" + strPath + "===" + s, "FileController");
}
}
return retStr; return retStr;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -187,13 +191,14 @@ public class ImageUtils {
return (length % 2 == 0) ? length / 2 : length / 2 + 1; return (length % 2 == 0) ? length / 2 : length / 2 + 1;
} }
public static int delFile(String fileName, boolean isXunhuan) { public static int delFile(String fileNameParam, boolean isXunhuan) {
Properties props = System.getProperties(); Properties props = System.getProperties();
String os = props.getProperty("os.name").toLowerCase(); String os = props.getProperty("os.name").toLowerCase();
String fileAddressLocal = ""; String fileAddressLocal = "";
String pathAfter = ""; String pathAfter = "";
if (fileName.contains("/")) { String fileName = "";
String[] split = fileName.split("/"); if (fileNameParam.contains("/")) {
String[] split = fileNameParam.split("/");
if (split.length > 1) { if (split.length > 1) {
pathAfter = split[0]; pathAfter = split[0];
fileName = split[1]; fileName = split[1];
@ -210,9 +215,7 @@ public class ImageUtils {
} else { } else {
// fileAddressLocal = PropertiesUtil.getValue("fileAddressLinux"); // fileAddressLocal = PropertiesUtil.getValue("fileAddressLinux");
} }
LogUtil.WriteLog_Info("ImageUtils本地文件地址=====fileAddressLocal====" + fileAddressLocal, "FileController"); LogUtil.WriteLog_Info("ImageUtils本地文件地址=====fileAddressLocal====" + fileAddressLocal, "FileController");
File file = new File(fileAddressLocal, fileName); // 指定上传位置 File file = new File(fileAddressLocal, fileName); // 指定上传位置
if (file.exists()) { if (file.exists()) {
file.delete(); file.delete();
@ -221,10 +224,15 @@ public class ImageUtils {
String fileDelAddress = PropertiesUtil.getValue("fileDelUrl"); String fileDelAddress = PropertiesUtil.getValue("fileDelUrl");
LogUtil.WriteLog_Info("ImageUtil远程删除文件地址=====fileAddressLocal====" + fileDelAddress, "FileController"); LogUtil.WriteLog_Info("ImageUtil远程删除文件地址=====fileAddressLocal====" + fileDelAddress, "FileController");
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put("fileName", fileName); map.put("fileName", fileNameParam);
map.put("canDel", "N"); map.put("canDel", "N");
String s = HttpClientUtil.doPost(fileDelAddress, map); String[] split = fileDelAddress.split(",");
LogUtil.WriteLog_Info("ImageUtil远程删除文件地址=====执行结果====" + s, "FileController"); if (split.length > 0) {
for (String strPath : split) {
String s = HttpClientUtil.doPost(strPath, map);
LogUtil.WriteLog_Info("ImageUtil远程删除文件地址==" + strPath + "===执行结果====" + s, "FileController");
}
}
} }
return 1; return 1;
} }

Loading…
Cancel
Save