From 61f5928d9b54f101ecbb0c3dd631a91152b2a39f Mon Sep 17 00:00:00 2001 From: chenfei <18955928961@163.com> Date: Tue, 16 Aug 2022 17:38:41 +0800 Subject: [PATCH] =?UTF-8?q?ai=E8=AF=B7=E6=B1=82=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/api/AppController.java | 72 ++++++++--------- .../ruoyi/common/utils/http/HttpUtils.java | 3 +- .../ruoyi/system/domain/req/AiPostReq.java | 6 +- .../system/domain/req/Base64ResizedRmgSm.java | 77 ++++++++----------- .../system/domain/req/Base64ResizedRmgSx.java | 16 ++++ 5 files changed, 90 insertions(+), 84 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/req/Base64ResizedRmgSx.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java index 9baa818..f7bce67 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java @@ -334,11 +334,11 @@ public class AppController extends BaseController { jsonObject = removeBase64Image(JSONObject.parseObject(result),recordId); - TRecord tRecord = new TRecord(); - tRecord.setId(recordId); - tRecord.setAiResult(jsonObject.toJSONString()); - tRecord.setAiResult2(jsonObject.toJSONString()); - tRecordService.updateTRecord(tRecord); +// TRecord tRecord = new TRecord(); +// tRecord.setId(recordId); +// tRecord.setAiResult(jsonObject.toJSONString()); +// tRecord.setAiResult2(jsonObject.toJSONString()); +// tRecordService.updateTRecord(tRecord); } return AjaxResult.success(jsonObject); } @@ -357,19 +357,19 @@ public class AppController extends BaseController private void saveImage(AiPostReq aiPostReq,Long recordId) { Base64ResizedRmgSm base64_resized_img_sm = aiPostReq.getBase64_resized_img_sm(); - Base64ResizedRmgSm base64_resized_img_sx = aiPostReq.getBase64_resized_img_sx(); + Base64ResizedRmgSx base64_resized_img_sx = aiPostReq.getBase64_resized_img_sx(); Map smMap = imageKey(base64_resized_img_sm,"base64_resized_img_sm"); - Map sxMap = imageKey(base64_resized_img_sx, "base64_resized_img_sx"); - smMap.putAll(sxMap); - sxMap.forEach((name,value)->{ - TImage tImage = new TImage(); - tImage.setThirdId(recordId); - tImage.setCreateTime(new Date()); - tImage.setName(name); - String path=GenerateImage(value); - tImage.setPath(path); - imageService.insertTImage(tImage); - }); +// Map sxMap = imageKey(base64_resized_img_sx, "base64_resized_img_sx"); +// smMap.putAll(sxMap); +// sxMap.forEach((name,value)->{ +// TImage tImage = new TImage(); +// tImage.setThirdId(recordId); +// tImage.setCreateTime(new Date()); +// tImage.setName(name); +// String path=GenerateImage(value); +// tImage.setPath(path); +// imageService.insertTImage(tImage); +// }); } public Map imageKey(Base64ResizedRmgSm param,String key){ @@ -377,25 +377,25 @@ public class AppController extends BaseController if(!StringUtils.isEmpty(param.getFront())){ map.put(key+"-front",param.getFront()); } - if(!StringUtils.isEmpty(param.getLeft())){ - map.put(key+"-left",param.getLeft()); - } - if(!StringUtils.isEmpty(param.getFront())){ - map.put(key+"-right",param.getRight()); - } - if(!CollectionUtils.isEmpty(param.getOther())){ - for (int i = 0; i < param.getOther().size(); i++) - { - map.put(key+"-other"+i,param.getOther().get(i)); - } - } +// if(!StringUtils.isEmpty(param.getLeft())){ +// map.put(key+"-left",param.getLeft()); +// } +// if(!StringUtils.isEmpty(param.getFront())){ +// map.put(key+"-right",param.getRight()); +// } +// if(!CollectionUtils.isEmpty(param.getOther())){ +// for (int i = 0; i < param.getOther().size(); i++) +// { +// map.put(key+"-other"+i,param.getOther().get(i)); +// } +// } return map; } public JSONObject removeBase64Image(JSONObject jsonObject,Long recordId) { - String []keys={"image_sz","image_sz_yudian","image_sz_yuban","image_sz_liewen","image_st","image_sx","image_sx_vein"}; + String []keys={"img_sz","img_sz_yudian","img_sz_yuban","img_sz_liewen","img_st","img_sx","img_sx_vein"}; List parents=new ArrayList<>(); try { @@ -413,12 +413,12 @@ public class AppController extends BaseController String imgStr=parents.get(i).getJSONObject(imageKey).getString("v"); String path=GenerateImage(imgStr); parents.get(i).getJSONObject(keys[i]).put("v",null); - TImage tImage = new TImage(); - tImage.setName(imageKey); - tImage.setPath(path); - tImage.setCreateTime(new Date()); - tImage.setThirdId(recordId); - imageService.insertTImage(tImage); +// TImage tImage = new TImage(); +// tImage.setName(imageKey); +// tImage.setPath(path); +// tImage.setCreateTime(new Date()); +// tImage.setThirdId(recordId); +// imageService.insertTImage(tImage); //保存图片到数据库,thirdId(recordId),path,name(imageKey) } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java index 5ab36eb..dc9fa79 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java @@ -140,7 +140,7 @@ public class HttpUtils conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); conn.setRequestProperty("Accept-Charset", "utf-8"); - conn.setRequestProperty("contentType", "utf-8"); + conn.setRequestProperty("content-Type", "application/json;charset=UTF-8"); conn.setDoOutput(true); conn.setDoInput(true); out = new PrintWriter(conn.getOutputStream()); @@ -278,4 +278,5 @@ public class HttpUtils return true; } } + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AiPostReq.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AiPostReq.java index 28b8b1d..576dc82 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AiPostReq.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/AiPostReq.java @@ -8,7 +8,7 @@ import java.util.List; public class AiPostReq { private Base64ResizedRmgSm base64_resized_img_sm; - private Base64ResizedRmgSm base64_resized_img_sx; + private Base64ResizedRmgSx base64_resized_img_sx; public Base64ResizedRmgSm getBase64_resized_img_sm() { @@ -20,12 +20,12 @@ public class AiPostReq this.base64_resized_img_sm = base64_resized_img_sm; } - public Base64ResizedRmgSm getBase64_resized_img_sx() + public Base64ResizedRmgSx getBase64_resized_img_sx() { return base64_resized_img_sx; } - public void setBase64_resized_img_sx(Base64ResizedRmgSm base64_resized_img_sx) + public void setBase64_resized_img_sx(Base64ResizedRmgSx base64_resized_img_sx) { this.base64_resized_img_sx = base64_resized_img_sx; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/Base64ResizedRmgSm.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/Base64ResizedRmgSm.java index b62fef1..4ecd7fe 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/Base64ResizedRmgSm.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/Base64ResizedRmgSm.java @@ -5,10 +5,10 @@ import java.util.List; public class Base64ResizedRmgSm { private String front; - private String left; - private String right; - private List other; - +// private String left; +// private String right; +//// private List other; +// private String other; public String getFront() { return front; @@ -19,44 +19,33 @@ public class Base64ResizedRmgSm this.front = front; } - public String getLeft() - { - return left; - } - - public void setLeft(String left) - { - this.left = left; - } - - public String getRight() - { - return right; - } - - public void setRight(String right) - { - this.right = right; - } - - public List getOther() - { - return other; - } - - public void setOther(List other) - { - this.other = other; - } - - @Override - public String toString() - { - return "{" + - "front='" + front + '\'' + - ", left='" + left + '\'' + - ", right='" + right + '\'' + - ", other=" + other + - '}'; - } +// public String getLeft() +// { +// return left; +// } +// +// public void setLeft(String left) +// { +// this.left = left; +// } +// +// public String getRight() +// { +// return right; +// } +// +// public void setRight(String right) +// { +// this.right = right; +// } +// +// public String getOther() +// { +// return other; +// } +// +// public void setOther(String other) +// { +// this.other = other; +// } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/Base64ResizedRmgSx.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/Base64ResizedRmgSx.java new file mode 100644 index 0000000..ec51f28 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/req/Base64ResizedRmgSx.java @@ -0,0 +1,16 @@ +package com.ruoyi.system.domain.req; + +public class Base64ResizedRmgSx +{ + private String front; + + public String getFront() + { + return front; + } + + public void setFront(String front) + { + this.front = front; + } +}