|
|
@ -20,6 +20,7 @@ import com.ruoyi.system.domain.resp.TRecordResp;
|
|
|
|
import com.ruoyi.system.service.*;
|
|
|
|
import com.ruoyi.system.service.*;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
@ -355,24 +356,29 @@ public class AppController extends BaseController
|
|
|
|
String URL = RequestParamsUtil.HTTP + ip + RequestParamsUtil.SEPARATOR + port + url;
|
|
|
|
String URL = RequestParamsUtil.HTTP + ip + RequestParamsUtil.SEPARATOR + port + url;
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
String result;
|
|
|
|
String result;
|
|
|
|
TRecord tRecord = new TRecord();
|
|
|
|
|
|
|
|
tRecord.setId(recordId);
|
|
|
|
|
|
|
|
tRecord.setStatus("1");
|
|
|
|
|
|
|
|
tRecordService.updateTRecord(tRecord);
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = HttpUtils.sendPost(URL, mapper.writeValueAsString(aiPostReq));
|
|
|
|
result = HttpUtils.sendPost(URL, mapper.writeValueAsString(delNullData(aiPostReq)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tRecord.setStatus("0");
|
|
|
|
|
|
|
|
tRecordService.updateTRecord(tRecord);
|
|
|
|
|
|
|
|
throw new ServiceException(e.getMessage());
|
|
|
|
throw new ServiceException(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(result))
|
|
|
|
if (!StringUtils.isEmpty(result))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
TRecord tRecord = new TRecord();
|
|
|
|
jsonObject = removeBase64Image(JSONObject.parseObject(result),recordId);
|
|
|
|
tRecord.setId(recordId);
|
|
|
|
|
|
|
|
tRecord.setStatus("1");
|
|
|
|
|
|
|
|
tRecordService.updateTRecord(tRecord);
|
|
|
|
|
|
|
|
JSONObject data = JSONObject.parseObject(result);
|
|
|
|
|
|
|
|
if(data.getInteger("code") != 200){
|
|
|
|
|
|
|
|
TRecord tRecord1 = new TRecord();
|
|
|
|
|
|
|
|
tRecord1.setId(recordId);
|
|
|
|
|
|
|
|
tRecord1.setStatus("0");
|
|
|
|
|
|
|
|
tRecordService.updateTRecord(tRecord1);
|
|
|
|
|
|
|
|
throw new ServiceException(data.getString("msg"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
jsonObject = removeBase64Image(data,recordId);
|
|
|
|
tRecord.setUpdateTime(new Date());
|
|
|
|
tRecord.setUpdateTime(new Date());
|
|
|
|
tRecord.setAiResult(JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue));
|
|
|
|
tRecord.setAiResult(JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue));
|
|
|
|
tRecord.setAiResult2(JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue));
|
|
|
|
tRecord.setAiResult2(JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue));
|
|
|
@ -403,15 +409,12 @@ public class AppController extends BaseController
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Base64ResizedRmgSm base64_resized_img_sm = aiPostReq.getBase64_resized_img_sm();
|
|
|
|
Base64ResizedRmgSm base64_resized_img_sm = aiPostReq.getBase64_resized_img_sm();
|
|
|
|
Base64ResizedRmgSx base64_resized_img_sx = aiPostReq.getBase64_resized_img_sx();
|
|
|
|
Base64ResizedRmgSm base64_resized_img_sx = aiPostReq.getBase64_resized_img_sx();
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
Map<String, String> smMap = imageKey(base64_resized_img_sm,"sm");
|
|
|
|
if(!StringUtils.isEmpty(base64_resized_img_sm.getFront())){
|
|
|
|
Map<String, String> sxMap = imageKey(base64_resized_img_sx, "sx");
|
|
|
|
map.put("sm_front",base64_resized_img_sm.getFront());
|
|
|
|
smMap.putAll(sxMap);
|
|
|
|
}
|
|
|
|
smMap.forEach((name,value)->{
|
|
|
|
if(!StringUtils.isEmpty(base64_resized_img_sx.getFront())){
|
|
|
|
if(!StringUtils.isEmpty(value)){
|
|
|
|
map.put("sx_front",base64_resized_img_sx.getFront());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
map.forEach((name,value)->{
|
|
|
|
|
|
|
|
TImage tImage = new TImage();
|
|
|
|
TImage tImage = new TImage();
|
|
|
|
tImage.setThirdId(recordId);
|
|
|
|
tImage.setThirdId(recordId);
|
|
|
|
tImage.setCreateTime(new Date());
|
|
|
|
tImage.setCreateTime(new Date());
|
|
|
@ -419,26 +422,30 @@ public class AppController extends BaseController
|
|
|
|
String path=GenerateImage(value);
|
|
|
|
String path=GenerateImage(value);
|
|
|
|
tImage.setPath(path);
|
|
|
|
tImage.setPath(path);
|
|
|
|
imageService.insertTImage(tImage);
|
|
|
|
imageService.insertTImage(tImage);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// public Map<String,String> imageKey(Base64ResizedRmgSm param,String key){
|
|
|
|
public Map<String,String> imageKey(Base64ResizedRmgSm param,String key){
|
|
|
|
//
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
//// if(!StringUtils.isEmpty(param.getLeft())){
|
|
|
|
if(!StringUtils.isEmpty(param.getFront())){
|
|
|
|
//// map.put(key+"-left",param.getLeft());
|
|
|
|
map.put(key+"_front",param.getFront());
|
|
|
|
//// }
|
|
|
|
}
|
|
|
|
//// if(!StringUtils.isEmpty(param.getFront())){
|
|
|
|
if(!StringUtils.isEmpty(param.getLeft())){
|
|
|
|
//// map.put(key+"-right",param.getRight());
|
|
|
|
map.put(key+"_left",param.getLeft());
|
|
|
|
//// }
|
|
|
|
}
|
|
|
|
//// if(!CollectionUtils.isEmpty(param.getOther())){
|
|
|
|
if(!StringUtils.isEmpty(param.getFront())){
|
|
|
|
//// for (int i = 0; i < param.getOther().size(); i++)
|
|
|
|
map.put(key+"_right",param.getRight());
|
|
|
|
//// {
|
|
|
|
}
|
|
|
|
//// map.put(key+"-other"+i,param.getOther().get(i));
|
|
|
|
if(!CollectionUtils.isEmpty(param.getOther())){
|
|
|
|
//// }
|
|
|
|
for (int i = 0; i < param.getOther().size(); i++)
|
|
|
|
//// }
|
|
|
|
{
|
|
|
|
// return map;
|
|
|
|
map.put(key+"_other_"+i,param.getOther().get(i));
|
|
|
|
//
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
return map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject removeBase64Image(JSONObject jsonObject,Long recordId)
|
|
|
|
public JSONObject removeBase64Image(JSONObject jsonObject,Long recordId)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -473,11 +480,20 @@ public class AppController extends BaseController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
TRecord tRecord = new TRecord();
|
|
|
|
|
|
|
|
tRecord.setId(recordId);
|
|
|
|
|
|
|
|
tRecord.setStatus("0");
|
|
|
|
|
|
|
|
tRecordService.updateTRecord(tRecord);
|
|
|
|
throw new ServiceException("JSON解析错误:" + jsonObject.toJSONString());
|
|
|
|
throw new ServiceException("JSON解析错误:" + jsonObject.toJSONString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return jsonObject;
|
|
|
|
return jsonObject;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject delNullData(AiPostReq aiPostReq){
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(aiPostReq));
|
|
|
|
|
|
|
|
return jsonObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String GenerateImage(String imgStr)
|
|
|
|
public static String GenerateImage(String imgStr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|