parent
fc166eb894
commit
b6319c9cd8
2 changed files with 51 additions and 0 deletions
@ -0,0 +1,49 @@ |
||||
package org.springblade.lims.ocr; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.lims.goods.vo.ApplyVO; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileWriter; |
||||
import java.util.Random; |
||||
|
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/ocrDistinguish") |
||||
public class OcrDistinguish { |
||||
|
||||
@PostMapping("/download") |
||||
public String download(@RequestBody ApplyVO applyVO) { |
||||
// 随机数文件名
|
||||
long aLong = new Random().nextLong(); |
||||
// 文件路径
|
||||
String filePath = "/app/xumu/4.electronicSignature/" + aLong + ".txt"; |
||||
|
||||
FileWriter fw = null; |
||||
try { |
||||
File file = new File(filePath); |
||||
if (!file.exists()) { |
||||
file.createNewFile(); |
||||
} |
||||
fw = new FileWriter(filePath); |
||||
fw.write(applyVO.getNum()); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} finally { |
||||
try { |
||||
fw.close(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
return aLong + ".txt"; |
||||
} |
||||
|
||||
@GetMapping("/delete") |
||||
public boolean delete(String num) { |
||||
File file = new File("/app/xumu/4.electronicSignature/" + num); |
||||
return file.delete(); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue