CaseDownService.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. package com.fdkankan.fusion.down;
  2. import cn.hutool.core.io.FileUtil;
  3. import com.alibaba.fastjson.JSON;
  4. import com.alibaba.fastjson.JSONArray;
  5. import com.alibaba.fastjson.JSONObject;
  6. import com.deepoove.poi.XWPFTemplate;
  7. import com.fdkankan.fusion.common.FilePath;
  8. import com.fdkankan.fusion.common.ResultData;
  9. import com.fdkankan.fusion.common.util.ShellUtil;
  10. import com.fdkankan.fusion.common.util.UploadToOssUtil;
  11. import com.fdkankan.fusion.entity.*;
  12. import com.fdkankan.fusion.httpClient.LaserService;
  13. import com.fdkankan.fusion.httpClient.response.FdkkResponse;
  14. import com.fdkankan.fusion.request.CaseParam;
  15. import com.fdkankan.fusion.response.DownVo;
  16. import com.fdkankan.fusion.response.DownloadProcessVo;
  17. import com.fdkankan.fusion.response.FusionNumVo;
  18. import com.fdkankan.fusion.response.SceneVo;
  19. import com.fdkankan.fusion.service.*;
  20. import com.fdkankan.fusion.service.impl.DownService;
  21. import com.fdkankan.redis.util.RedisUtil;
  22. import lombok.extern.slf4j.Slf4j;
  23. import org.apache.commons.lang3.StringUtils;
  24. import org.springframework.beans.factory.annotation.Autowired;
  25. import org.springframework.beans.factory.annotation.Value;
  26. import org.springframework.scheduling.annotation.Async;
  27. import org.springframework.stereotype.Service;
  28. import java.io.File;
  29. import java.io.FileOutputStream;
  30. import java.nio.charset.StandardCharsets;
  31. import java.util.HashSet;
  32. import java.util.List;
  33. @Service
  34. @Slf4j
  35. public class CaseDownService {
  36. @Value("${server.servlet.context-path}")
  37. String basePath;
  38. public static String jsonDataName = "data.json";
  39. public static String caseInfo = "/case/getInfo?caseId=";
  40. public static String caseSettingsInfo = "/caseSettings/info?caseId=";
  41. public static String hostIcon = "/edit/hotIcon/list?caseId=";
  42. public static String caseView = "/caseView/allList?caseId=";
  43. public static String caseFiles = "/caseFiles/allList?caseId=";
  44. public static String caseFilesType = "/caseFilesType/allList?caseId=";
  45. public static String caseScene = "/case/sceneList?caseId=";
  46. public static String caseFusion = "/caseFusion/list?caseId=";
  47. public static String caseVideoFolder = "/caseVideoFolder/allList?caseId=";
  48. public static String caseVideo = "/caseVideo/allList?folderId=";
  49. public static String caseTag = "/caseTag/allList?caseId=";
  50. public static String caseTagPoint = "/caseTagPoint/allList?tagId=";
  51. public static String caseInquest = "/caseInquest/info?caseId=";
  52. public static String caseExtractDetail = "/caseExtractDetail/info?caseId=";
  53. public static String fusionGuide = "/fusionGuide/allList?caseId=";
  54. public static String fusionGuidePath = "/fusionGuidePath/allList?guideId=";
  55. public static String fusionMeter = "/fusionMeter/allList?fusionId=";
  56. public static String model = "/model/getInfo?modelId=";
  57. public static String caseImg = "/caseImg/getFfmpegImage?caseId=";
  58. public static String inquestInfoUrl = "/caseInquestInfo/info?caseId=";
  59. public static String casePathInfoUrl = "/casePath/info?caseId=";
  60. public static String caseAnimationUrl = "/caseAnimation/list?caseId=";
  61. public static String laserData = "/laser/dataset/%s/getDataSet";
  62. public static String laserDataQuery = "/laser/filter/%s/query?datasetId=%s";
  63. @Autowired
  64. ICaseService caseService;
  65. @Autowired
  66. ICaseSettingsService caseSettingsService;
  67. @Autowired
  68. IFusionNumService fusionNumService;
  69. @Autowired
  70. ICaseViewService caseViewService;
  71. @Autowired
  72. ICaseVideoFolderService caseVideoFolderService;
  73. @Autowired
  74. ICaseVideoService caseVideoService;
  75. @Autowired
  76. ICaseFilesService caseFilesService;
  77. @Autowired
  78. ICaseFilesTypeService caseFilesTypeService;
  79. @Autowired
  80. IHotIconService hotIconService;
  81. @Autowired
  82. ICaseTagService caseTagService;
  83. @Autowired
  84. ICaseTagPointService caseTagPointService;
  85. @Autowired
  86. IFusionGuideService fusionGuideService;
  87. @Autowired
  88. IFusionGuidePathService fusionGuidePathService;
  89. @Autowired
  90. ICaseInquestService caseInquestService;
  91. @Autowired
  92. ICaseExtractDetailService caseExtractDetailService;
  93. @Autowired
  94. IFusionMeterService fusionMeterService;
  95. @Autowired
  96. IModelService modelService;
  97. @Autowired
  98. LaserService laserService;
  99. @Autowired
  100. ICaseOfflineService caseOfflineService;
  101. @Autowired
  102. ICaseImgService caseImgService;
  103. @Autowired
  104. ICaseInquestInfoService caseInquestInfoService;
  105. @Autowired
  106. ICasePathService casePathService;
  107. @Autowired
  108. ICaseAnimationService animationService;
  109. @Autowired
  110. RedisUtil redisUtil;
  111. @Value("${spring.profiles.active}")
  112. private String environment;
  113. public static String downProcessKey = "fusion:down:offline:process:caseId:%s";
  114. public DownVo checkDown(Integer caseId) {
  115. DownVo downVo = new DownVo();
  116. String redisKey = String.format(downProcessKey, caseId);
  117. if( redisUtil.hasKey(redisKey)){
  118. String res = redisUtil.get(redisKey);
  119. DownloadProcessVo downloadProcessVo = JSONObject.parseObject(res, DownloadProcessVo.class);
  120. if(downloadProcessVo.getStatus() == 1000 && downloadProcessVo.getPercent() == 100 && StringUtils.isNotBlank(downloadProcessVo.getUrl())){
  121. downVo.setDownloadStatus(3);
  122. downVo.setDownloadUrl(downloadProcessVo.getUrl());
  123. }
  124. }
  125. return downVo;
  126. }
  127. public void cleckDownUrl(Integer caseId) {
  128. String redisKey = String.format(downProcessKey, caseId);
  129. if( redisUtil.hasKey(redisKey)){
  130. String res = redisUtil.get(redisKey);
  131. DownloadProcessVo downloadProcessVo = JSONObject.parseObject(res, DownloadProcessVo.class);
  132. if(downloadProcessVo.getStatus() == 1000 && downloadProcessVo.getPercent() == 100 && StringUtils.isNotBlank(downloadProcessVo.getUrl())){
  133. redisUtil.del(redisKey);
  134. }
  135. }
  136. }
  137. @Async
  138. public void downOffline(Integer caseId){
  139. try {
  140. String redisKey = String.format(downProcessKey, caseId);
  141. if( redisUtil.hasKey(redisKey)){
  142. String res = redisUtil.get(redisKey);
  143. DownloadProcessVo downloadProcessVo = JSONObject.parseObject(res, DownloadProcessVo.class);
  144. if(downloadProcessVo.getStatus() != 1003 && (downloadProcessVo.getPercent()== null || downloadProcessVo.getPercent() != 100)){
  145. return;
  146. }
  147. }
  148. setRedisProcess(caseId,0);
  149. //复制前端资源
  150. cpIndexHtml(caseId);
  151. setRedisProcess(caseId,10);
  152. //创建data.json并下载资源
  153. createDataJson(caseId);
  154. setRedisProcess(caseId,50);
  155. //打包zip
  156. String path = "/mnt/fusion/offline";
  157. String name = "offline_"+ caseId;
  158. String zipName = path+File.separator+name+".zip";
  159. ShellUtil.zipOffline(zipName,name);
  160. setRedisProcess(caseId,70);
  161. //上传oss
  162. String ossUrl = zipName.replace("/mnt/", "");
  163. ShellUtil.yunUpload(zipName,ossUrl);
  164. Thread.sleep(2000L);
  165. FileUtil.del(zipName);
  166. ossUrl = queryPath + ossUrl;
  167. caseOfflineService.saveByCase(caseId,ossUrl);
  168. setRedisProcess(caseId,100,ossUrl);
  169. }catch (Exception e){
  170. log.info("down-offline-error:{}",caseId,e);
  171. setRedisProcess(caseId,0,null,1003);
  172. }
  173. }
  174. public void setRedisProcess(Integer caseId,Integer num){
  175. setRedisProcess(caseId,num,null,1000);
  176. }
  177. public void setRedisProcess(Integer caseId,Integer num,String url){
  178. setRedisProcess(caseId,num,url,1000);
  179. }
  180. public void setRedisProcess(Integer caseId,Integer num,String url,Integer status){
  181. String redisKey = String.format(downProcessKey, caseId);
  182. log.info("down-offline-process:{},{},{}",caseId,num,url);
  183. DownloadProcessVo processVo = new DownloadProcessVo();
  184. processVo.setStatus(status);
  185. processVo.setPercent(num);
  186. processVo.setUrl( url);
  187. redisUtil.set(redisKey,JSONObject.toJSONString(processVo));
  188. }
  189. public DownloadProcessVo process(Integer caseId) {
  190. DownloadProcessVo downVo = new DownloadProcessVo();
  191. String redisKey = String.format(downProcessKey, caseId);
  192. if(redisUtil.hasKey(redisKey)){
  193. return JSONObject.parseObject(redisUtil.get(redisKey),DownloadProcessVo.class);
  194. }
  195. return downVo;
  196. }
  197. public void createDataJson(Integer caseId){
  198. log.info("down-offline-createDataJson:{}",caseId);
  199. JSONObject jsonObject = new JSONObject();
  200. CaseParam param = new CaseParam();
  201. param.setCaseId(caseId);
  202. //设置案件信息
  203. jsonObject.put(basePath+inquestInfoUrl+caseId, ResultData.ok(caseInquestInfoService.getByCaseId(caseId)));
  204. jsonObject.put(basePath+caseInfo+caseId, ResultData.ok(caseService.getInfo(caseId)));
  205. List<CaseSettings> caseSettings = caseSettingsService.getByCaseId(caseId);
  206. jsonObject.put(basePath+caseSettingsInfo+caseId, ResultData.ok(caseSettings));
  207. for (CaseSettings caseSetting : caseSettings) {
  208. downResource(caseId,caseSetting.getBack());
  209. downResource(caseId,caseSetting.getCover());
  210. }
  211. List<FusionNumVo> listByCaseId = fusionNumService.getListByCaseId(caseId,null);
  212. jsonObject.put(basePath+caseFusion+caseId, ResultData.ok(listByCaseId));
  213. for (FusionNumVo fusion : listByCaseId) {
  214. jsonObject.put(basePath+fusionMeter+fusion.getFusionId(), ResultData.ok(fusionMeterService.getListByFusionId(fusion.getFusionId(),null)));
  215. }
  216. for (FusionNumVo fusionNumVo : listByCaseId) {
  217. //下载媒体库模型
  218. if(fusionNumVo.getSceneData() != null){
  219. if(fusionNumVo.getSceneData().getType() ==3 && StringUtils.isNotBlank(fusionNumVo.getSceneData().getModelGlbUrl()) ){
  220. downModel(caseId,fusionNumVo.getSceneData().getModelGlbUrl());
  221. }
  222. }
  223. }
  224. List<SceneVo> sceneVos = caseService.sceneList(param);
  225. for (SceneVo sceneData : sceneVos) {
  226. //下载模型
  227. if(StringUtils.isNotBlank(sceneData.getModelGlbUrl())){
  228. downModel(caseId,sceneData.getModelGlbUrl());
  229. }
  230. if(sceneData.getType() != 3){
  231. //下载场景离线包
  232. downSwkk(caseId,sceneData.getNum(),sceneData.getType());
  233. }
  234. if(sceneData.getType() == 2 || sceneData.getType() == 5){
  235. FdkkResponse sceneInfo = laserService.getSceneInfo(sceneData.getNum());
  236. HashSet<String> dataSetIds = new HashSet<>();
  237. if(sceneInfo != null){
  238. JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(sceneInfo.getData()));
  239. JSONArray newJsonArray = new JSONArray();
  240. for (Object object : jsonArray) {
  241. JSONObject sceneInfoObj = (JSONObject) object;
  242. String newPath = String.format(FilePath.OFFLINE_LASER_OSS_PATH, sceneData.getNum(), sceneData.getNum());
  243. String oldPath = sceneInfoObj.getString("webBin");
  244. sceneInfoObj.put("oldWebBin",oldPath);
  245. sceneInfoObj.put("webBin",newPath + oldPath);
  246. newJsonArray.add(sceneInfoObj);
  247. dataSetIds.add( sceneInfoObj.getString("id"));
  248. }
  249. sceneInfo.setData(newJsonArray);
  250. jsonObject.put(String.format(laserData,sceneData.getNum()),sceneInfo);
  251. if(!dataSetIds.isEmpty()){
  252. for (String dataSetId : dataSetIds) {
  253. FdkkResponse sceneInfo2 = laserService.getSceneInfoQuery(sceneData.getNum(),dataSetId);
  254. jsonObject.put(String.format(laserDataQuery,sceneData.getNum(),dataSetId),sceneInfo2);
  255. }
  256. }
  257. }
  258. }
  259. if(sceneData.getModelId() != null){
  260. jsonObject.put(basePath+model+sceneData.getModelId(), ResultData.ok(modelService.getInfo(sceneData.getModelId())));
  261. }
  262. }
  263. jsonObject.put(basePath+caseScene+caseId, ResultData.ok(sceneVos));
  264. List<CaseView> caseViews = caseViewService.allList(caseId, null, null, null, null);
  265. jsonObject.put(basePath+caseView+caseId, ResultData.ok(caseViews));
  266. for (CaseView view : caseViews) {
  267. downResource(caseId,view.getViewImg());
  268. downResource(caseId,view.getViewImgSmall());
  269. }
  270. List<CaseVideoFolder> videoFolders = caseVideoFolderService.getAllList(caseId);
  271. jsonObject.put(basePath+caseVideoFolder+caseId, ResultData.ok(videoFolders));
  272. for (CaseVideoFolder videoFolder : videoFolders) {
  273. downResource(caseId,videoFolder.getVideoFolderCover());
  274. downResource(caseId,videoFolder.getVideoMergeUrl());
  275. List<CaseVideo> allList = caseVideoService.getAllList(videoFolder.getVideoFolderId());
  276. for (CaseVideo video : allList) {
  277. downResource(caseId,video.getVideoCover());
  278. downResource(caseId,video.getVideoPath());
  279. }
  280. jsonObject.put(basePath+caseVideo+videoFolder.getVideoFolderId(), ResultData.ok(allList));
  281. }
  282. List<CaseFiles> caseFilesList = caseFilesService.allList(caseId, null);
  283. for (CaseFiles files : caseFilesList) {
  284. downResource(caseId,files.getFilesUrl());
  285. }
  286. jsonObject.put(basePath+caseFiles+caseId, ResultData.ok(caseFilesList));
  287. jsonObject.put(basePath+caseFilesType+caseId, ResultData.ok(caseFilesTypeService.list()));
  288. List<HotIcon> hotIconList = hotIconService.getListByCaseId(caseId);
  289. for (HotIcon hotIcon : hotIconList) {
  290. downResource(caseId,hotIcon.getIconUrl());
  291. }
  292. jsonObject.put(basePath+hostIcon+caseId, ResultData.ok(hotIconList));
  293. List<CaseTag> caseTagList = caseTagService.allList(caseId, null);
  294. jsonObject.put(basePath+caseTag+caseId, ResultData.ok(caseTagList));
  295. for (CaseTag tag : caseTagList) {
  296. jsonObject.put(basePath+caseTagPoint+tag.getTagId(), ResultData.ok(caseTagPointService.allList(tag.getTagId())));
  297. downResources(caseId,tag.getTagImgUrl());
  298. downResource(caseId,tag.getHotIconUrl());
  299. }
  300. jsonObject.put(basePath+casePathInfoUrl+caseId, ResultData.ok(casePathService.getByCaseId(caseId)));
  301. List<FusionGuide> fusionGuides = fusionGuideService.getAllList(caseId);
  302. jsonObject.put(basePath+fusionGuide+caseId, ResultData.ok(fusionGuides));
  303. for (FusionGuide guide : fusionGuides) {
  304. downResource(caseId,guide.getCover());
  305. List<FusionGuidePath> listByGuideId = fusionGuidePathService.getListByGuideId(guide.getFusionGuideId());
  306. for (FusionGuidePath guidePath : listByGuideId) {
  307. downResource(caseId,guidePath.getCover());
  308. }
  309. jsonObject.put(basePath+fusionGuidePath+guide.getFusionGuideId(), ResultData.ok(listByGuideId));
  310. }
  311. CaseInquest caseInquest1 = caseInquestService.getByCaseId(caseId);
  312. if(caseInquest1 != null){
  313. XWPFTemplate inquestTemp = caseInquestService.getWordByTemplate(caseInquest1);
  314. downWordByTemplate(caseId,inquestTemp,"caseInquest.doc");
  315. }
  316. jsonObject.put(basePath+caseInquest+caseId, ResultData.ok(caseInquest1));
  317. CaseExtractDetail caseExtractDetail1 = caseExtractDetailService.getByCaseId(caseId);
  318. if(caseExtractDetail1 != null){
  319. XWPFTemplate detailTemp = caseExtractDetailService.getWordByTemplate(caseExtractDetail1);
  320. downWordByTemplate(caseId,detailTemp,"caseExtractDetail.doc");
  321. }
  322. jsonObject.put(basePath+caseExtractDetail+caseId, ResultData.ok(caseExtractDetail1));
  323. List<CaseImg> caseImgList = caseImgService.getByCaseId(caseId, 1);
  324. for (CaseImg img : caseImgList) {
  325. downResource(img.getCaseId(),img.getImgUrl());
  326. }
  327. jsonObject.put(basePath+caseImg+caseId, ResultData.ok(caseImgList));
  328. jsonObject.put(basePath+caseAnimationUrl+caseId, ResultData.ok(animationService.getListByCaseId(caseId)));
  329. FileUtil.writeString(JSON.toJSONString(jsonObject), FilePath.OFFLINE_PACKAGE_PATH+caseId+"/www/package/"+jsonDataName,"UTF-8");
  330. }
  331. //http://127.0.0.1:8080/offline.html?caseId=362&app=1&share=1#/show/summary
  332. static String batName = "start-browser.bat";
  333. public void cpIndexHtml(Integer caseId){
  334. log.info("down-offline-cpIndexHtml:{}",caseId);
  335. String caseOfflinePath = FilePath.OFFLINE_PACKAGE_PATH+caseId;
  336. FileUtil.copyContent(new File(FilePath.OFFLINE_TEMPLATE_PATH),new File(caseOfflinePath),true);
  337. String s = FileUtil.readString(caseOfflinePath + File.separator + batName, StandardCharsets.UTF_8);
  338. String s1 = s.replaceAll("@caseId", String.valueOf(caseId));
  339. FileUtil.writeString(s1, caseOfflinePath + File.separator + batName,"UTF-8");
  340. }
  341. @Autowired
  342. DownService downService;
  343. @Autowired
  344. UploadToOssUtil uploadToOssUtil;
  345. public void downSwkk(Integer caseId,String num,Integer type){
  346. String swkkPath = FilePath.OFFLINE_PACKAGE_PATH+caseId + "/www/swkk/"+num;
  347. String swkkZipPath = swkkPath +".zip";
  348. String swssPath = FilePath.OFFLINE_PACKAGE_PATH+caseId + "/www/swss/"+num;
  349. String swssZipPath = swssPath +".zip";
  350. Integer isObj = 0;
  351. if(type == 4 || type == 6){
  352. isObj =1;
  353. }
  354. try {
  355. DownVo downVo = downService.checkDownLoad(num, isObj,"offline");
  356. log.info("down:{}",downVo);
  357. if(downVo.getDownloadStatus() == 3 && StringUtils.isNotBlank(downVo.getDownloadUrl())){
  358. downZip(type,downVo.getDownloadUrl(),swkkZipPath,swkkPath,swssZipPath,swssPath);
  359. }else {
  360. DownVo down = downService.down(num, isObj,"offline");
  361. if(down.getDownloadStatus() == 1){
  362. DownloadProcessVo downloadProcessVo = downService.downloadProcess(num, isObj);
  363. while (downloadProcessVo.getStatus() != 1002 ){
  364. downloadProcessVo = downService.downloadProcess(num, isObj);
  365. Thread.sleep(2000L);
  366. }
  367. downZip(type,downloadProcessVo.getUrl(),swkkZipPath,swkkPath,swssZipPath,swssPath);
  368. }
  369. }
  370. }catch (Exception e){
  371. log.info("下载场景离线包失败:{}",num,e);
  372. }
  373. }
  374. @Value("${upload.query-path}")
  375. private String queryPath;
  376. public void downZip(Integer type ,String uri,String kkzipPath,String kknumPath,String sszipPath,String ssNumPath){
  377. try {
  378. if(type != 2 && type != 5){ //深时点云
  379. if(uri.contains("?")){
  380. uri = uri.split("[?]")[0];
  381. }
  382. ShellUtil.yunDownload(uri.replace(queryPath, ""), kkzipPath);
  383. ShellUtil.unZip(kkzipPath,kknumPath);
  384. FileUtil.del(kkzipPath);
  385. }else {
  386. // InputStream in = minIoUploadService.getObject(uri);
  387. // FileOutputStream out = new FileOutputStream(sszipPath);
  388. // byte[] buffer = new byte[1024];
  389. // int bytesRead;
  390. // while ((bytesRead = in.read(buffer)) != -1) {
  391. // out.write(buffer, 0, bytesRead);
  392. // }
  393. // out.flush();
  394. // out.close();
  395. // in.close();
  396. ShellUtil.yunDownloadSs(uri.replace(queryPath, ""), sszipPath);
  397. ShellUtil.unZip(sszipPath,ssNumPath);
  398. FileUtil.del(sszipPath);
  399. }
  400. }catch (Exception e){
  401. log.info("下载场景离线包失败:{}",uri,e);
  402. }
  403. }
  404. public void downModel(Integer caseId, String modelGlbUrl) {
  405. String path = String.format(FilePath.OFFLINE_OSS_PATH,caseId);
  406. JSONArray jsonArray = JSONArray.parseArray(modelGlbUrl);
  407. for (Object object : jsonArray) {
  408. String res = (String) object;
  409. log.info("下载模型:{}",res);
  410. res = res.replace(queryPath, "");
  411. if(res.contains(".json") || res.contains(".shp")){
  412. res = new File(res).getParentFile().getPath();
  413. }
  414. ShellUtil.yunDownload(res, path +queryPath + res);
  415. }
  416. }
  417. public void downResources(Integer caseId,String urls) {
  418. JSONArray jsonArray = JSONArray.parseArray(urls);
  419. for (Object object : jsonArray) {
  420. String res = (String) object;
  421. downResource(caseId,res);
  422. }
  423. }
  424. public void downResources(Integer caseId,JSONArray urls) {
  425. for (Object object : urls) {
  426. String res = (String) object;
  427. downResource(caseId,res);
  428. }
  429. }
  430. public void downResource(Integer caseId,String url) {
  431. if(StringUtils.isBlank(url) ){
  432. return;
  433. }
  434. url = url.replace(queryPath, "");
  435. if( !uploadToOssUtil.existKey(url)){
  436. log.info("downResource文件不存在:{},{}",caseId,url);
  437. return;
  438. }
  439. String path = String.format(FilePath.OFFLINE_OSS_PATH,caseId);
  440. ShellUtil.yunDownload(url,path+queryPath+url);
  441. }
  442. public void downWordByTemplate(Integer caseId,XWPFTemplate template,String name){
  443. // 指定输出文件的路径
  444. String outputPath = String.format(FilePath.OFFLINE_RESOURCE_PACKAGE_PATH,caseId) + name;
  445. try {
  446. FileOutputStream out = new FileOutputStream(outputPath);
  447. template.write(out);
  448. out.close();
  449. log.info("文档已成功写入到: " + outputPath);
  450. } catch (Exception e) {
  451. log.info("写出文档失败:{},{}",caseId,name,e);
  452. }
  453. }
  454. }