|
|
@@ -90,14 +90,11 @@ public class TestPublicController extends CertifyApiController {
|
|
|
String str=moveImg(t.getServiceContent(),t.getOrderNo(),2,uploadPath);
|
|
|
neworder.setServiceContent(str);
|
|
|
}
|
|
|
- } catch (IOException e) {
|
|
|
- if (t.getOrderNo().equals("706517544638255104")){
|
|
|
- logger.debug(t.getContractPictureUrl());
|
|
|
- logger.debug("订单编号["+t.getOrderNo()+"]移动异常...\\n"+e.getLocalizedMessage());
|
|
|
- }
|
|
|
-
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.debug("订单编号["+t.getOrderNo()+"]移动异常..."+e.getLocalizedMessage());
|
|
|
continue;
|
|
|
}
|
|
|
+ logger.debug("订单编号["+t.getOrderNo()+"]移动成功\n"+t.getContractPictureUrl()+"\n"+neworder.getContractPictureUrl());
|
|
|
tOrderNewMapper.updateByPrimaryKeySelective(neworder);
|
|
|
}
|
|
|
}
|
|
|
@@ -124,7 +121,7 @@ public class TestPublicController extends CertifyApiController {
|
|
|
String str=moveImg(t.getServiceContent(),t.getOrderNo(),2,uploadPath);
|
|
|
neworder.setServiceContent(str);
|
|
|
}
|
|
|
- } catch (IOException e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
tOrderNewMapper.updateByPrimaryKeySelective(neworder);
|
|
|
@@ -140,7 +137,7 @@ public class TestPublicController extends CertifyApiController {
|
|
|
* @return
|
|
|
*/
|
|
|
|
|
|
- private static String moveImg(String attURL ,String orderNo,Integer i,String uploadPath) throws IOException {
|
|
|
+ private static String moveImg(String attURL ,String orderNo,Integer i,String uploadPath) throws Exception {
|
|
|
StringBuffer str =new StringBuffer();
|
|
|
String[] split = attURL.split(",");
|
|
|
for (String s : split) {
|
|
|
@@ -175,18 +172,24 @@ public class TestPublicController extends CertifyApiController {
|
|
|
* @param useURL 旧地址
|
|
|
* @param newURL 新地址
|
|
|
*/
|
|
|
- private static void moveFile(String useURL, String newURL,String uploadPath,String url) throws IOException {
|
|
|
+ private static int moveFile(String useURL, String newURL,String uploadPath,String url) throws Exception {
|
|
|
String targePath=uploadPath+newURL;
|
|
|
useURL=uploadPath+useURL;
|
|
|
String targeUrl=targePath+url;
|
|
|
//目标文件夹路径(没有会自动创建)
|
|
|
File targetFile = new File(targePath);
|
|
|
File srcFile = new File(useURL);
|
|
|
+ if (!srcFile.exists()){
|
|
|
+ throw new BusinessException("文件不存在");
|
|
|
+ }
|
|
|
File destFile = new File(targeUrl);
|
|
|
+ //创建文件件
|
|
|
createFile(targetFile);
|
|
|
+ //复制文件
|
|
|
copyFile(srcFile,destFile);
|
|
|
+ //删除源文件
|
|
|
srcFile.delete();
|
|
|
-
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
private static void createFile(File file) {
|
|
|
@@ -216,23 +219,4 @@ public class TestPublicController extends CertifyApiController {
|
|
|
bos.close();
|
|
|
bis.close();
|
|
|
}
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- String uploadPath="F:/data/public/upload";
|
|
|
- String targePath="F:/data/public/upload/new_order_file/706517544638255104/contract";
|
|
|
- // 源文件夹路径(存放图片路径)
|
|
|
- String url=uploadPath+"\\order_file\\c44a10a3-eae0-40ae-b847-d0c09046e340\\176852558400.png";
|
|
|
- String name=url.substring(url.lastIndexOf("\\"));
|
|
|
- String targeUrl=targePath+name;
|
|
|
- //目标文件夹路径(没有会自动创建)
|
|
|
- File targetFile = new File(targePath);
|
|
|
- File srcFile = new File(url);
|
|
|
- File destFile = new File(targeUrl);
|
|
|
- createFile(targetFile);
|
|
|
- try {
|
|
|
- copyFile(srcFile,destFile);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
}
|