ai请求接口

master
chenfei 2 years ago
parent 1d5c88caf7
commit 61f5928d9b

@ -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<String, String> smMap = imageKey(base64_resized_img_sm,"base64_resized_img_sm");
Map<String, String> 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<String, String> 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<String,String> 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<JSONObject> 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)
}

@ -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;
}
}
}

@ -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;
}

@ -5,10 +5,10 @@ import java.util.List;
public class Base64ResizedRmgSm
{
private String front;
private String left;
private String right;
private List<String> other;
// private String left;
// private String right;
//// private List<String> 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<String> getOther()
{
return other;
}
public void setOther(List<String> 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;
// }
}

@ -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;
}
}
Loading…
Cancel
Save