海外平台-数据全英文化
This commit is contained in:
@ -0,0 +1,15 @@
|
||||
package com.ho.common.tools.annotation;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* 切换为英文环境后,不支持配置操作
|
||||
* @author kerwin
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface NotSportEnOperation {
|
||||
}
|
||||
@ -733,10 +733,16 @@ public interface CommonConstant {
|
||||
|
||||
String MSG = "设备接入通道";
|
||||
|
||||
String MSG_EN = "Equipment access channel ";
|
||||
|
||||
String SUCCESS = "恢复";
|
||||
|
||||
String SUCCESS_EN = "recover";
|
||||
|
||||
String FAIL = "断开";
|
||||
|
||||
String FAIL_EN = "disconnect";
|
||||
|
||||
String SN_FAIL = "设备接入点离线";
|
||||
|
||||
String STATION_FAIL = "离线";
|
||||
@ -761,6 +767,7 @@ public interface CommonConstant {
|
||||
String CHECK_MODIFY_VALUE = "命令下发修改值不在范围内";
|
||||
|
||||
String DEVICE_NO_SN = "设备没有配置SN";
|
||||
String DEVICE_NO_SN_EN = "The device is not configured with SN";
|
||||
String NOT_SN = "没有配置站内接入点";
|
||||
String INTERVAL = "间隔";
|
||||
String STATION = "电站";
|
||||
@ -994,4 +1001,10 @@ public interface CommonConstant {
|
||||
String CF_FROZEN = "cfFrozen";
|
||||
//将数据库统配符合“_”变成普通字符
|
||||
String JOIN_STATION_ID = "\\_";
|
||||
|
||||
String REPORT_NAME="月度报表";
|
||||
String REPORT_NAME_EN="monthly report";
|
||||
|
||||
String BILL_NAME="月度账单";
|
||||
String BILL_NAME_EN="monthly bill";
|
||||
}
|
||||
|
||||
@ -26,9 +26,12 @@ public interface DefineConstant {
|
||||
String SHARP = "尖";
|
||||
|
||||
String SUMMARY = "汇总";
|
||||
String SUMMARY_EN = "summary";
|
||||
|
||||
String SUMMARY_DATA_STATION = "电站汇总数据";
|
||||
|
||||
String SUMMARY_DATA_STATION_EN = "Summary data of power station";
|
||||
|
||||
interface PeakShaving {
|
||||
String ADD_TEMPLATE_SUCCESS = "新增计划曲线模板成功";
|
||||
String TEMPLATE_CHECK_SIZE = "至少有一个时段和一个计划用电,请确认后重试!";
|
||||
@ -79,7 +82,11 @@ public interface DefineConstant {
|
||||
String ANTI_BACKFLOW_METER = "防逆流表";
|
||||
String TOTAL_ACTIVE_POWER = "总有功功率";
|
||||
String BUILDING = "(在建)";
|
||||
|
||||
String BUILDING_EN = "(under construction)";
|
||||
String PROPOSED = "(拟建)";
|
||||
|
||||
String PROPOSED_EN = "(proposed)";
|
||||
}
|
||||
|
||||
interface PlanningPolicy{
|
||||
@ -100,6 +107,8 @@ public interface DefineConstant {
|
||||
|
||||
interface PointDemo{
|
||||
String TIME = "时间";
|
||||
|
||||
String TIME_EN = "time";
|
||||
}
|
||||
|
||||
interface DeviceTypeCol{
|
||||
|
||||
@ -223,6 +223,8 @@ public interface RedisKeyConstant {
|
||||
String LOGIN_TYPE_PHONE = "phone";
|
||||
// 语言切换
|
||||
String LANG="lang";
|
||||
|
||||
String EN_US="en_US";
|
||||
}
|
||||
|
||||
//设备相关
|
||||
|
||||
@ -468,6 +468,7 @@ public enum BaseResponseCode implements ResponseCodeInterface {
|
||||
/************************抽取新的********************************/
|
||||
EXCEL_DATA_NOT_EXIST(500, "不存在昨日负荷数据"),
|
||||
EXISTS_DUPLICATE_ALARM(500,"该作用范围内的字段已经配置过,重复字符为:"),
|
||||
EN_US_NOT_SUPPORT_OPERATION(500,"请切换为中文,再操作配置!"),
|
||||
;
|
||||
|
||||
/**
|
||||
|
||||
@ -21,23 +21,30 @@ public class TranslateUtils {
|
||||
|
||||
|
||||
// 静态翻译方法:输入待翻译文本,返回目标语言文本
|
||||
public static String translate(String text) throws IOException {
|
||||
public static String translate(String text) {
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
// 动态构建请求体(支持任意文本)
|
||||
String jsonBody = String.format("{\"from\":\"zh\",\"to\":\"en\",\"q\":\"%s\"}", text);
|
||||
RequestBody body = RequestBody.create(mediaType, jsonBody);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url("https://aip.baidubce.com/rpc/2.0/mt/texttrans/v1?access_token=" + getAccessToken())
|
||||
.post(body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.build();
|
||||
Request request = null;
|
||||
try {
|
||||
request = new Request.Builder()
|
||||
.url("https://aip.baidubce.com/rpc/2.0/mt/texttrans/v1?access_token=" + getAccessToken())
|
||||
.post(body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.build();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try (Response response = HTTP_CLIENT.newCall(request).execute()) {
|
||||
String responseBody = response.body().string();
|
||||
// 解析JSON获取dst值
|
||||
return parseDstFromResponse(responseBody);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +54,11 @@ public class TranslateUtils {
|
||||
JSONObject result = root.getJSONObject("result");
|
||||
JSONArray transResult = result.getJSONArray("trans_result");
|
||||
// 获取第一条翻译结果的dst字段
|
||||
return transResult.getJSONObject(0).getString("dst");
|
||||
String disStr = transResult.getJSONObject(0).getString("dst");
|
||||
if(disStr.contains("Zhongzi Technology")){
|
||||
disStr = disStr.replace("Zhongzi Technology","Sinotech");
|
||||
}
|
||||
return disStr;
|
||||
}
|
||||
|
||||
// 示例调用
|
||||
|
||||
Reference in New Issue
Block a user