Commit b11c57d4b5c9c3b62e2cbea0672d8b5b0235f966
1 parent
fa4b73cb
修正打包jar后snap路径问题,兼容windows路径
Showing
1 changed file
with
15 additions
and
6 deletions
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -24,7 +24,6 @@ import gov.nist.javax.sip.stack.SIPDialog; | @@ -24,7 +24,6 @@ import gov.nist.javax.sip.stack.SIPDialog; | ||
| 24 | import org.slf4j.Logger; | 24 | import org.slf4j.Logger; |
| 25 | import org.slf4j.LoggerFactory; | 25 | import org.slf4j.LoggerFactory; |
| 26 | import org.springframework.beans.factory.annotation.Autowired; | 26 | import org.springframework.beans.factory.annotation.Autowired; |
| 27 | -import org.springframework.beans.factory.annotation.Value; | ||
| 28 | import org.springframework.http.HttpStatus; | 27 | import org.springframework.http.HttpStatus; |
| 29 | import org.springframework.http.ResponseEntity; | 28 | import org.springframework.http.ResponseEntity; |
| 30 | import org.springframework.stereotype.Service; | 29 | import org.springframework.stereotype.Service; |
| @@ -32,13 +31,11 @@ import org.springframework.util.ResourceUtils; | @@ -32,13 +31,11 @@ import org.springframework.util.ResourceUtils; | ||
| 32 | import org.springframework.web.context.request.async.DeferredResult; | 31 | import org.springframework.web.context.request.async.DeferredResult; |
| 33 | 32 | ||
| 34 | import javax.sip.ClientTransaction; | 33 | import javax.sip.ClientTransaction; |
| 35 | -import javax.sip.Dialog; | ||
| 36 | -import javax.sip.header.CallIdHeader; | ||
| 37 | import javax.sip.message.Response; | 34 | import javax.sip.message.Response; |
| 38 | -import java.io.File; | ||
| 39 | import java.io.FileNotFoundException; | 35 | import java.io.FileNotFoundException; |
| 40 | import java.util.UUID; | 36 | import java.util.UUID; |
| 41 | 37 | ||
| 38 | +@SuppressWarnings(value = {"rawtypes", "unchecked"}) | ||
| 42 | @Service | 39 | @Service |
| 43 | public class PlayServiceImpl implements IPlayService { | 40 | public class PlayServiceImpl implements IPlayService { |
| 44 | 41 | ||
| @@ -97,7 +94,20 @@ public class PlayServiceImpl implements IPlayService { | @@ -97,7 +94,20 @@ public class PlayServiceImpl implements IPlayService { | ||
| 97 | result.onCompletion(()->{ | 94 | result.onCompletion(()->{ |
| 98 | // 点播结束时调用截图接口 | 95 | // 点播结束时调用截图接口 |
| 99 | try { | 96 | try { |
| 100 | - String path = ResourceUtils.getURL("classpath:").getPath()+"static/static/snap/"; | 97 | + String classPath = ResourceUtils.getURL("classpath:").getPath(); |
| 98 | + // System.out.println(classPath); | ||
| 99 | + String path = classPath + "static/static/snap/"; | ||
| 100 | + if(classPath.contains("jar")) { | ||
| 101 | + classPath = classPath.substring(0, classPath.lastIndexOf(".")); | ||
| 102 | + classPath = classPath.substring(0, classPath.lastIndexOf("/")); | ||
| 103 | + path = classPath + "/snap/"; | ||
| 104 | + } | ||
| 105 | + if (path.startsWith("file:")) { | ||
| 106 | + path = path.substring(path.indexOf(":") + 1, path.length()); | ||
| 107 | + } | ||
| 108 | + if(System.getProperty("os.name").contains("indows")) { | ||
| 109 | + path = path.substring(1, path.length()); | ||
| 110 | + } | ||
| 101 | String fileName = deviceId + "_" + channelId + ".jpg"; | 111 | String fileName = deviceId + "_" + channelId + ".jpg"; |
| 102 | ResponseEntity responseEntity = (ResponseEntity)result.getResult(); | 112 | ResponseEntity responseEntity = (ResponseEntity)result.getResult(); |
| 103 | if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) { | 113 | if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) { |
| @@ -109,7 +119,6 @@ public class PlayServiceImpl implements IPlayService { | @@ -109,7 +119,6 @@ public class PlayServiceImpl implements IPlayService { | ||
| 109 | zlmresTfulUtils.getSnap(flvUrl, 5, 1, path, fileName); | 119 | zlmresTfulUtils.getSnap(flvUrl, 5, 1, path, fileName); |
| 110 | } | 120 | } |
| 111 | } | 121 | } |
| 112 | - | ||
| 113 | System.out.println(path); | 122 | System.out.println(path); |
| 114 | } catch (FileNotFoundException e) { | 123 | } catch (FileNotFoundException e) { |
| 115 | e.printStackTrace(); | 124 | e.printStackTrace(); |