|
|
|
@ -20,6 +20,7 @@ import com.ruoyi.system.domain.resp.TRecordResp;
|
|
|
|
|
import com.ruoyi.system.service.*;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
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;
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
String result;
|
|
|
|
|
TRecord tRecord = new TRecord();
|
|
|
|
|
tRecord.setId(recordId);
|
|
|
|
|
tRecord.setStatus("1");
|
|
|
|
|
tRecordService.updateTRecord(tRecord);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = HttpUtils.sendPost(URL, mapper.writeValueAsString(aiPostReq));
|
|
|
|
|
result = HttpUtils.sendPost(URL, mapper.writeValueAsString(delNullData(aiPostReq)));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
tRecord.setStatus("0");
|
|
|
|
|
tRecordService.updateTRecord(tRecord);
|
|
|
|
|
throw new ServiceException(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isEmpty(result))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
jsonObject = removeBase64Image(JSONObject.parseObject(result),recordId);
|
|
|
|
|
TRecord tRecord = new TRecord();
|
|
|
|
|
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.setAiResult(JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue));
|
|
|
|
|
tRecord.setAiResult2(JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue));
|
|
|
|
@ -403,42 +409,43 @@ public class AppController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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> smMap = imageKey(base64_resized_img_sm,"sm");
|
|
|
|
|
Map<String, String> sxMap = imageKey(base64_resized_img_sx, "sx");
|
|
|
|
|
smMap.putAll(sxMap);
|
|
|
|
|
smMap.forEach((name,value)->{
|
|
|
|
|
if(!StringUtils.isEmpty(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){
|
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
|
if(!StringUtils.isEmpty(base64_resized_img_sm.getFront())){
|
|
|
|
|
map.put("sm_front",base64_resized_img_sm.getFront());
|
|
|
|
|
if(!StringUtils.isEmpty(param.getFront())){
|
|
|
|
|
map.put(key+"_front",param.getFront());
|
|
|
|
|
}
|
|
|
|
|
if(!StringUtils.isEmpty(base64_resized_img_sx.getFront())){
|
|
|
|
|
map.put("sx_front",base64_resized_img_sx.getFront());
|
|
|
|
|
if(!StringUtils.isEmpty(param.getLeft())){
|
|
|
|
|
map.put(key+"_left",param.getLeft());
|
|
|
|
|
}
|
|
|
|
|
map.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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
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 Map<String,String> imageKey(Base64ResizedRmgSm param,String key){
|
|
|
|
|
//
|
|
|
|
|
//// 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)
|
|
|
|
|
{
|
|
|
|
@ -473,11 +480,20 @@ public class AppController extends BaseController
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
TRecord tRecord = new TRecord();
|
|
|
|
|
tRecord.setId(recordId);
|
|
|
|
|
tRecord.setStatus("0");
|
|
|
|
|
tRecordService.updateTRecord(tRecord);
|
|
|
|
|
throw new ServiceException("JSON解析错误:" + jsonObject.toJSONString());
|
|
|
|
|
}
|
|
|
|
|
return jsonObject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JSONObject delNullData(AiPostReq aiPostReq){
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(aiPostReq));
|
|
|
|
|
return jsonObject;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String GenerateImage(String imgStr)
|
|
|
|
|
{
|
|
|
|
|