|
|
@@ -519,17 +519,24 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
|
|
|
@Override
|
|
|
public void saveDialog(DialogReqDTO dialogReqDTO) {
|
|
|
- //String dialogId = dialogReqDTO.getId();
|
|
|
- //String id = dialogMapper.selectDialogById(dialogId);
|
|
|
-// if(id == null) {
|
|
|
-// String i = dialogMapper.insertDialog(dialogReqDTO);
|
|
|
-// }
|
|
|
- String uuid = IdUtils.fastSimpleUUID();
|
|
|
- dialogReqDTO.setId(uuid);
|
|
|
- dialogMapper.insertDialog(dialogReqDTO);
|
|
|
+ String dialogId = null;
|
|
|
+ String id = null;
|
|
|
+ if(com.takai.common.utils.StringUtils.isNotEmpty(dialogReqDTO.getId())){
|
|
|
+ id = dialogMapper.selectDialogById(dialogReqDTO.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(id == null){
|
|
|
+ String uuid = IdUtils.fastSimpleUUID();
|
|
|
+ dialogReqDTO.setId(uuid);
|
|
|
+ dialogMapper.insertDialog(dialogReqDTO);
|
|
|
+ dialogId = uuid;
|
|
|
+ }else{
|
|
|
+ dialogId = dialogReqDTO.getId();
|
|
|
+ }
|
|
|
+
|
|
|
for(DialogDetailReqDTO dto : dialogReqDTO.getMessages()) {
|
|
|
- dto.setDialogId(uuid);
|
|
|
- String detailId = dialogMapper.selectDialogDetailById(uuid);
|
|
|
+ dto.setDialogId(dialogId);
|
|
|
+ String detailId = dialogMapper.selectDialogDetailById(dto.getId());
|
|
|
if(detailId == null) {
|
|
|
String detailUuid = IdUtils.fastSimpleUUID();
|
|
|
dto.setId(detailUuid);
|
|
|
@@ -568,8 +575,8 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public DialogRespDTO getDialogDetail(String dialogId) {
|
|
|
- DialogRespDTO detail = dialogMapper.selectDialogDetail(dialogId);
|
|
|
+ public List<DialogRespDTO> getDialogDetail(String dialogId) {
|
|
|
+ List<DialogRespDTO> detail = dialogMapper.selectDialogDetail(dialogId);
|
|
|
return detail;
|
|
|
}
|
|
|
|
|
|
@@ -655,20 +662,40 @@ public class BigModelServiceImpl implements IBigModelService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String getSliceInfo(String requestId) {
|
|
|
- String body = null;
|
|
|
+ public List<Map<String, Object>> getSliceInfo(String requestId) {
|
|
|
+ List<Map<String, Object>> list = new ArrayList();
|
|
|
String url = bigModelConfig.getBaseurl() + bigModelConfig.getSliceInfo().replace("{request_id}",requestId);
|
|
|
Request request = buildGetRequest(url);
|
|
|
OkHttpClient client = buildOkHttpClient();
|
|
|
try {
|
|
|
Response response = client.newCall(request).execute();
|
|
|
if(response.isSuccessful()) {
|
|
|
- body = response.body().string();
|
|
|
+ String body = response.body().string();
|
|
|
+ boolean status = isJsonObject(body);
|
|
|
+ if(!status){
|
|
|
+ return list;
|
|
|
+ }else{
|
|
|
+ JSONObject jsonObj = JSON.parseObject(body);
|
|
|
+ JSONObject jb = jsonObj.getJSONObject("data");
|
|
|
+ JSONArray array = jb.getJSONArray("document_slices");
|
|
|
+ if(array != null){
|
|
|
+ for(int i=0; i<array.size(); i++){
|
|
|
+ Map<String, Object> map = new HashMap();
|
|
|
+ JSONObject detailObj = array.getJSONObject(i);
|
|
|
+ JSONObject docObj = detailObj.getJSONObject("document");
|
|
|
+ String name = String.valueOf(docObj.get("name"));
|
|
|
+ String urlStr = String.valueOf(docObj.get("url"));
|
|
|
+ map.put("name", name);
|
|
|
+ map.put("url", urlStr);
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
- return body;
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
@Override
|