Solving the last bug from downCode.
This commit is contained in:
parent
e26004fd17
commit
f55f0595d8
@ -110,7 +110,8 @@ public class XhpcDownCodeServiceImpl implements IXhpcDownCodeService {
|
||||
String left = "https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/";
|
||||
List<String> imgUrls = xhpcDownCodeMapper.selectUrlsByPile(pileId);
|
||||
List<String> list1 = DownMaterialUtil.getDownLoadUrls(left,imgUrls);
|
||||
DownMaterialUtil.saveImageToDisk(list1,file2,imgUrls);
|
||||
System.out.println(list1);
|
||||
DownMaterialUtil.saveImageToDisk(list1, file2, imgUrls);
|
||||
File file = new File(environment.getProperty("img.url"));
|
||||
//储存路径
|
||||
long l = System.currentTimeMillis();
|
||||
@ -214,6 +215,7 @@ public class XhpcDownCodeServiceImpl implements IXhpcDownCodeService {
|
||||
//test
|
||||
// public void downMaterialBy11(Long pileId) throws Exception {
|
||||
//
|
||||
//
|
||||
// List<Map<String,Object>> list = xhpcDownCodeMapper.selectExcelDataByPileId(pileId);
|
||||
// System.out.println(list);
|
||||
// File file1 = new File("Material");
|
||||
@ -268,8 +270,8 @@ public class XhpcDownCodeServiceImpl implements IXhpcDownCodeService {
|
||||
// fos.close();
|
||||
// String left = "https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/";
|
||||
// List<String> imgUrls = xhpcDownCodeMapper.selectUrlsByPile(pileId);
|
||||
// System.out.println(imgUrls);
|
||||
// List<String> list1 = DownMaterialUtil.getDownLoadUrls(left,imgUrls);
|
||||
// System.out.println(list1);
|
||||
// DownMaterialUtil.saveImageToDisk1(list1,file2,imgUrls);
|
||||
// File file = new File(file1.getAbsolutePath());
|
||||
// DownMaterialUtil.fileToZip(file);
|
||||
@ -350,8 +352,6 @@ public class XhpcDownCodeServiceImpl implements IXhpcDownCodeService {
|
||||
// String url=environment.getProperty("img.url")+l;
|
||||
//
|
||||
// DownMaterialUtil.fileToZip(file,url);
|
||||
//
|
||||
// return "Material"+l+".zip";
|
||||
// }
|
||||
|
||||
static boolean delFile(File file) {
|
||||
|
||||
@ -48,6 +48,7 @@ public class DownMaterialUtil {
|
||||
|
||||
for(int i = 0; i < urls.size(); i ++) {
|
||||
InputStream inputStream = getInputStream(urls.get(i));
|
||||
if (null == inputStream) continue;
|
||||
byte[] data = new byte[1024];
|
||||
int len = 0;
|
||||
FileOutputStream fileOutputStream = null;
|
||||
@ -64,7 +65,7 @@ public class DownMaterialUtil {
|
||||
System.out.println(real);
|
||||
System.out.println(file.getName() + "/" + real);
|
||||
fileOutputStream = new FileOutputStream(file.getAbsoluteFile() + "/" + real);
|
||||
|
||||
System.out.println(file.getAbsoluteFile());
|
||||
while ((len = inputStream.read(data)) != -1) {
|
||||
fileOutputStream.write(data, 0, len);
|
||||
}
|
||||
@ -72,12 +73,10 @@ public class DownMaterialUtil {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (fileOutputStream != null) {
|
||||
try {
|
||||
@ -91,48 +90,51 @@ public class DownMaterialUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveImageToDisk1(List<String> urls, File file, List<String> imgNames) {
|
||||
|
||||
for (int i = 0; i < urls.size(); i++) {
|
||||
InputStream inputStream = getInputStream(urls.get(i));
|
||||
byte[] data = new byte[1024];
|
||||
int len = 0;
|
||||
FileOutputStream fileOutputStream = null;
|
||||
try {
|
||||
String str = imgNames.get(i);
|
||||
int poke = 0;
|
||||
for (int j = str.length() - 1; j >= 0; j--) {
|
||||
if (str.charAt(j) == 47) {
|
||||
poke = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String real = str.substring(poke + 1);
|
||||
System.out.println(real);
|
||||
System.out.println(file.getName() + "\\" + real);
|
||||
fileOutputStream = new FileOutputStream(file.getAbsoluteFile() + "\\" + real);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (fileOutputStream != null) {
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println("success");
|
||||
}
|
||||
}
|
||||
}
|
||||
// public static void saveImageToDisk1(List<String> urls, File file, List<String> imgNames) {
|
||||
//
|
||||
// for (int i = 0; i < urls.size(); i++) {
|
||||
// InputStream inputStream = getInputStream(urls.get(i));
|
||||
// if(null == inputStream) continue;
|
||||
// System.out.println(inputStream);
|
||||
// byte[] data = new byte[1024];
|
||||
// int len = 0;
|
||||
// FileOutputStream fileOutputStream = null;
|
||||
// try {
|
||||
// String str = imgNames.get(i);
|
||||
// int poke = 0;
|
||||
// for (int j = str.length() - 1; j >= 0; j--) {
|
||||
// if (str.charAt(j) == 47) {
|
||||
// poke = j;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// String real = str.substring(poke + 1);
|
||||
// System.out.println(real);
|
||||
// System.out.println(file.getName() + "\\" + real);
|
||||
// fileOutputStream = new FileOutputStream(file.getAbsoluteFile() + "\\" + real);
|
||||
// while ((len = inputStream.read(data)) != -1) {
|
||||
// fileOutputStream.write(data, 0, len);
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
//
|
||||
// try {
|
||||
// inputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// if (fileOutputStream != null) {
|
||||
// try {
|
||||
// fileOutputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// System.out.println("success");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public static void fileToZip(File sourceFile) throws Exception {
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ spring:
|
||||
|
||||
|
||||
#二维码Logo图片获取位置:
|
||||
imgPath: "/www/wwwroot/www.scxhua.cn/xhpc-charging-stion/logo.png"
|
||||
imgPath: "/www/wwwroot/xhpc.scxhua.com/xhpc-charging-stion/logo.png"
|
||||
#生成的二维码存放位置:
|
||||
destPath: "/www/wwwroot/www.scxhua.cn/xhpc-charging-stion/XiaoHuaFullImgs"
|
||||
#生成的最终完整图片的存放位置:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user