|
@@ -22,6 +22,7 @@ import com.fdkankan.download.httpclient.HttpClient;
|
|
import com.fdkankan.download.service.IDownloadService;
|
|
import com.fdkankan.download.service.IDownloadService;
|
|
import com.fdkankan.download.service.ILaserService;
|
|
import com.fdkankan.download.service.ILaserService;
|
|
import com.fdkankan.download.service.IScenePlusService;
|
|
import com.fdkankan.download.service.IScenePlusService;
|
|
|
|
+import com.fdkankan.download.util.DownloadUtil;
|
|
import com.fdkankan.download.util.ImgUtil;
|
|
import com.fdkankan.download.util.ImgUtil;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import jodd.util.SystemUtil;
|
|
import jodd.util.SystemUtil;
|
|
@@ -187,11 +188,9 @@ public class LaserService implements ILaserService {
|
|
FileWriter fileWriter=new FileWriter(copyPath+"start-browser.bat");
|
|
FileWriter fileWriter=new FileWriter(copyPath+"start-browser.bat");
|
|
fileWriter.write(bat.replaceAll("@sceneCode@",num),false);
|
|
fileWriter.write(bat.replaceAll("@sceneCode@",num),false);
|
|
}
|
|
}
|
|
- String target=num + "_laser.zip";
|
|
|
|
- File file=offlineZip(num, path, target);
|
|
|
|
String zipPath = String.format(this.zipLocalFormat, DateExtUtil.format(new Date(), DateExtUtil.dateStyle6),num + "_laser");
|
|
String zipPath = String.format(this.zipLocalFormat, DateExtUtil.format(new Date(), DateExtUtil.dateStyle6),num + "_laser");
|
|
- FileUtil.move(file,new File(zipPath),true);
|
|
|
|
- log.info("生成完成");
|
|
|
|
|
|
+ File file=offlineZip(path,zipPath);
|
|
|
|
+ log.info("生成完成路径{}",file.getAbsoluteFile());
|
|
return zipPath;
|
|
return zipPath;
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
@@ -202,25 +201,35 @@ public class LaserService implements ILaserService {
|
|
}
|
|
}
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
|
|
+ public final static String ZIP_PATH = "cd @path && cp -f @bashOffline . && zip -u -r bashOffline.zip start-browser.bat www/ && mv -f bashOffline.zip @target";
|
|
|
|
+
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
- public File offlineZip(String sceneCode, String path, String target) {
|
|
|
|
|
|
+ public File offlineZip( String path,String moveZipPath) {
|
|
String bashOfflinePath = laserschool + "bashOffline.zip";
|
|
String bashOfflinePath = laserschool + "bashOffline.zip";
|
|
- File file = new File(path + File.separator + "bashOffline.zip");
|
|
|
|
- FileUtil.copy(new File(bashOfflinePath), file, true);
|
|
|
|
- ZipParameters zipParameters = new ZipParameters();
|
|
|
|
- zipParameters.setOverrideExistingFilesInZip(false);
|
|
|
|
- ZipFile zipFile = new ZipFile(file);
|
|
|
|
- zipFile.setCharset(Charset.forName("GBK"));
|
|
|
|
- zipFile.removeFile("www/offline.html");
|
|
|
|
- zipFile.addFolder(new File(path + File.separator + "www"), zipParameters);
|
|
|
|
- zipFile.addFile(new File(path + File.separator + "start-browser.bat"));
|
|
|
|
- return FileUtil.rename(zipFile.getFile(),target, true);
|
|
|
|
|
|
+ File file = new File(moveZipPath);
|
|
|
|
+ if(!file.getParentFile().exists()){
|
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+ String zipCmd = ZIP_PATH;
|
|
|
|
+ zipCmd = zipCmd.replace("@bashOffline", bashOfflinePath);
|
|
|
|
+ zipCmd = zipCmd.replace("@target", moveZipPath);
|
|
|
|
+ zipCmd = zipCmd.replace("@path", path);
|
|
|
|
+ CmdUtils.callLineSh(zipCmd);
|
|
|
|
+ if(!FileUtil.exist(moveZipPath)){
|
|
|
|
+ throw new RuntimeException("打包失败");
|
|
|
|
+ }
|
|
|
|
+ return FileUtil.file(moveZipPath);
|
|
|
|
+
|
|
}
|
|
}
|
|
public void downloadFile(String url, String path){
|
|
public void downloadFile(String url, String path){
|
|
File file = new File(path);
|
|
File file = new File(path);
|
|
if(!file.getParentFile().exists()){
|
|
if(!file.getParentFile().exists()){
|
|
file.getParentFile().mkdirs();
|
|
file.getParentFile().mkdirs();
|
|
}
|
|
}
|
|
- HttpUtil.downloadFile(url, FileUtil.file(path));
|
|
|
|
|
|
+ try {
|
|
|
|
+ DownloadUtil.downFile(url,path);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.info("下载文件报错,url{},path:{}",url, path);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|