|
@@ -14,6 +14,8 @@ import org.springframework.web.client.RestTemplate;
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.sql.Timestamp;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* @Project : huimv.shiwan
|
|
@@ -33,8 +35,8 @@ public class ImageController {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/upload", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
|
|
public void uploadImage(@RequestBody JSONObject paramJo) throws IOException {
|
|
|
-// log.info(" name>>" + paramJo.getString("name"));
|
|
|
-// log.info(" image>>" + paramJo.getString("image"));
|
|
|
+ log.info("# 输入参数name>>" + paramJo.getString("name"));
|
|
|
+ log.info("# 输入参数image>>" + paramJo.getString("image"));
|
|
|
String name = paramJo.getString("name");
|
|
|
if (name == null) {
|
|
|
log.error("出错:参数name为null");
|
|
@@ -43,7 +45,6 @@ public class ImageController {
|
|
|
if (image == null) {
|
|
|
log.error("出错:参数image为null");
|
|
|
}
|
|
|
-// }
|
|
|
// if(imageService.saveImage(imageBase64,name)){
|
|
|
// 保存图片
|
|
|
JSONObject saveResultJo = imageService.saveImage(image, name);
|
|
@@ -53,9 +54,7 @@ public class ImageController {
|
|
|
String relativePath = saveResultJo.getString("relativePath");
|
|
|
String fileName = saveResultJo.getString("fileName");
|
|
|
// AI识别程序的结果
|
|
|
-// String aiResult = imageService.getAiResult2(imgPath);
|
|
|
JSONObject aiResultJo = imageService.getAiResult(imgPath,fileName);
|
|
|
-// System.out.println("aiResultJo>>" + aiResultJo);
|
|
|
String aiResult = aiResultJo.getString("result");
|
|
|
if(!aiResult.trim().equalsIgnoreCase("success")){
|
|
|
log.error("AI识别结果出错: "+aiResultJo);
|
|
@@ -64,8 +63,9 @@ public class ImageController {
|
|
|
}
|
|
|
int aiTimeUsed = aiResultJo.getInteger("timeUsed");
|
|
|
JSONArray aiPiggyJa = aiResultJo.getJSONArray("piggy");
|
|
|
+ Timestamp createTime = new Timestamp(new Date().getTime());
|
|
|
// 图片入库
|
|
|
- if(imageService.addImage(name, imgPath, relativePath, fileName,aiResult,aiTimeUsed,aiPiggyJa.toString())){
|
|
|
+ if(imageService.addImage(name, imgPath, relativePath, fileName,aiResult,aiTimeUsed,aiPiggyJa.toString(),createTime)){
|
|
|
log.info("图片入库成功.");
|
|
|
}else{
|
|
|
log.info("图片入库出错.");
|