|
@ -26,9 +26,6 @@ public class DiApiDevice extends DiApiControllerBase { |
|
|
@Resource |
|
|
@Resource |
|
|
private DiDevice device; |
|
|
private DiDevice device; |
|
|
|
|
|
|
|
|
@Value("${logging.file.name}") |
|
|
|
|
|
private String logFileName; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* start device to execute tasks |
|
|
* start device to execute tasks |
|
|
*/ |
|
|
*/ |
|
@ -158,40 +155,6 @@ public class DiApiDevice extends DiApiControllerBase { |
|
|
return this.success(notification); |
|
|
return this.success(notification); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
@PostMapping("/api/device/app-log-fetch") |
|
|
|
|
|
public DiApiResponse appLogFetch( @RequestBody Map<String, Object> params ) { |
|
|
|
|
|
Integer offset = (Integer)params.get("offset"); |
|
|
|
|
|
Integer limit = (Integer)params.get("limit"); |
|
|
|
|
|
|
|
|
|
|
|
// open log file and read limit from offset. |
|
|
|
|
|
RandomAccessFile reader = null; |
|
|
|
|
|
try { |
|
|
|
|
|
reader = new RandomAccessFile(this.logFileName, "r"); |
|
|
|
|
|
reader.seek(offset); |
|
|
|
|
|
byte[] buffer = new byte[limit]; |
|
|
|
|
|
int length = reader.read(buffer); |
|
|
|
|
|
if ( -1 == length ) { |
|
|
|
|
|
return this.success(Map.of("content", "", "length", 0)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String content = new String(buffer); |
|
|
|
|
|
return this.success(Map.of("content", content, "length", length)); |
|
|
|
|
|
} catch (FileNotFoundException e) { |
|
|
|
|
|
return this.error("日志文件打开失败 : " + e.getMessage()); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
return this.error("日志文件读取失败 : " + e.getMessage()); |
|
|
|
|
|
} finally { |
|
|
|
|
|
if ( null != reader ) { |
|
|
|
|
|
try { |
|
|
|
|
|
reader.close(); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void pause() {} |
|
|
public void pause() {} |
|
|
public void resume() {} |
|
|
public void resume() {} |
|
|
} |
|
|
} |