|
|
@ -47,8 +47,8 @@ public class ExecTranslateServiceImpl implements ExecTranslateService { |
|
|
|
} |
|
|
|
|
|
|
|
String token = getToken(input); |
|
|
|
String createUrl = (String) input.get(Constants.CREATEURL); |
|
|
|
String url = createUrl + token; |
|
|
|
String textUrl = (String) input.get(Constants.TEXTURL); |
|
|
|
String url = textUrl + token; |
|
|
|
Map<String, Object> param = new HashMap<String, Object>(16); |
|
|
|
//原语种 |
|
|
|
String from = (String) input.get(Constants.FROM); |
|
|
@ -62,10 +62,12 @@ public class ExecTranslateServiceImpl implements ExecTranslateService { |
|
|
|
List<String> sentences = joinSentences(parts, 5800); |
|
|
|
String translateContent = Constants.EMPTY; |
|
|
|
for (String sentence : sentences) { |
|
|
|
param.put(Constants.Q, sentence); |
|
|
|
String resStr = DownLoadUtil.doPost(url,JSONObject.toJSONString(param)); |
|
|
|
JSONObject res = JSONObject.parseObject(resStr); |
|
|
|
if(res.containsKey(Constants.RESULT)) { |
|
|
|
List<Map<String, Object>> transResult = (List<Map<String, Object>>) res.get(Constants.TRANS_RESULT); |
|
|
|
Map<String, Object> result = (Map<String, Object>) res.get(Constants.RESULT); |
|
|
|
List<Map<String, Object>> transResult = (List<Map<String, Object>>) result.get(Constants.TRANS_RESULT); |
|
|
|
for (Map<String, Object> tran : transResult) { |
|
|
|
String dst = (String) tran.get(Constants.DST); |
|
|
|
translateContent += dst; |
|
|
@ -87,6 +89,7 @@ public class ExecTranslateServiceImpl implements ExecTranslateService { |
|
|
|
Map<String, Object> results = new HashMap<String, Object>(16); |
|
|
|
//遍历入库返回结果,拼接响应内容 |
|
|
|
results.put(Constants.ISLAST, 1); |
|
|
|
results.put(Constants.SRCCONTENT, q); |
|
|
|
results.put(Constants.CONTENT, Constants.TRANS_FIAL); |
|
|
|
results.put(Constants.ID, UUID.randomUUID().toString()); |
|
|
|
result.put(Constants.RESULTS, JSONObject.toJSONString(results)); |
|
|
@ -101,6 +104,7 @@ public class ExecTranslateServiceImpl implements ExecTranslateService { |
|
|
|
Map<String, Object> results = new HashMap<String, Object>(16); |
|
|
|
//遍历入库返回结果,拼接响应内容 |
|
|
|
results.put(Constants.ISLAST, 1); |
|
|
|
results.put(Constants.SRCCONTENT, q); |
|
|
|
results.put(Constants.CONTENT, translateContent); |
|
|
|
results.put(Constants.ID, UUID.randomUUID().toString()); |
|
|
|
result.put(Constants.RESULTS, JSONObject.toJSONString(results)); |
|
|
|