Commit c76413233e4284686570f35ea2c9db42a7ce4c10

Authored by chenjunyu_1481036421
1 parent d796edbc

fix:i18n bug修改

... ... @@ -52,6 +52,7 @@ public class TkApplicationController extends BaseController {
52 52 queryMap.put(PAGE, page);
53 53 queryMap.put(ORDER_FILED, orderBy);
54 54 queryMap.put("name", name);
  55 + queryMap.put("tenantId", getCurrentUser().getCurrentTenantId());
55 56 if(StringUtils.isNotEmpty(organizationId)){
56 57 List<String> organizationIds = tkOrganizationService.organizationAllIds(getCurrentUser().getCurrentTenantId(),organizationId);
57 58 queryMap.put("organizationIds", organizationIds);
... ...
... ... @@ -195,8 +195,19 @@ openapi.app.isnull= The application does not exist
195 195 openapi.api.isnull= API does not exist
196 196 publicly.successful = Publicly successful
197 197 private.success = Private Success
198   -
199   -
  198 +method.does.not.exist = The calling method %s does not exist
  199 +one.second.ago = seconds ago
  200 +one.minute.ago = minutes ago
  201 +one.huor.ago = huor ago
  202 +one.day.ago = day ago
  203 +one.month.ago = month ago
  204 +one.year.ago= year ago
  205 +one.just.ago= just
  206 +one.yesterday.ago= yesterday
  207 +rule.chain.to.tenant = Rule chain should be assigned to tenant
  208 +non.existent.tenant = Rule chain is referencing to non-existent tenant!
  209 +root.rule.chain.is.present = Another root rule chain is present in scope of current tenant!
  210 +edge.root.rule.chain.is.present = Another edge template root rule chain is present in scope of current tenant!
200 211
201 212
202 213
... ...
... ... @@ -194,4 +194,18 @@ choice.device.profile.rule.chain.is.used.for.scene = 选中的产å“ã€%s】正å
194 194 openapi.app.isnull = 应用不存在
195 195 openapi.api.isnull = api不存在
196 196 publicly.successful = 公开成功
197   -private.success = 私有成功
\ No newline at end of file
  197 +private.success = 私有成功
  198 +method.does.not.exist = 调用方法【%s】不存在
  199 +one.second.ago = 秒前
  200 +one.minute.ago = 分钟前
  201 +one.huor.ago = 小时前
  202 +one.day.ago = 天前
  203 +one.month.ago = 月前
  204 +one.year.ago= 年前
  205 +one.just.ago= 刚刚
  206 +one.yesterday.ago= 昨天
  207 +rule.chain.to.tenant =规则链应分配给租户
  208 +non.existent.tenant =规则链正在引用不存在的租户
  209 +root.rule.chain.is.present =当前租户范围内存在另一个根规则链
  210 +edge.root.rule.chain.is.present =当前租户范围内存在另一个边缘模板根规则链
  211 +
... ...
... ... @@ -196,6 +196,14 @@ public enum ErrorMessage {
196 196 CHOICE_DEVICE_PROFILE_RULE_CHAIN_IS_USED_FOR_SCENE(400161,"选中的产品【%s】正在被场景联动【%s】使用,不能更换规则链!!","choice.device.profile.rule.chain.is.used.for.scene"),
197 197 OPENAPI_APP_ISNULL(400162,"应用不存在","openapi.app.isnull"),
198 198 OPENAPI_API_ISNULL(400163,"api不存在","openapi.api.isnull"),
  199 + METHOD_DOES_NOT_EXIST(400164,"调用方法【%s】不存在","method.does.not.exist"),
  200 +
  201 + RULE_CHAIN_TO_TENANT(400165,"规则链应分配给租户","rule.chain.to.tenant"),
  202 + NON_EXISTENT_TENANT(400166,"规则链正在引用不存在的租户!","non.existent.tenant"),
  203 + ROOT_RULE_CHAIN_IS_PRESENT (400167,"当前租户范围内存在另一个根规则链!","root.rule.chain.is.present"),
  204 + EDGE_ROOT_RULE_CHAIN_IS_PRESENT(400168,"当前租户范围内存在另一个边缘模板根规则链!","edge.root.rule.chain.is.present"),
  205 +
  206 +
199 207
200 208 HAVE_NO_PERMISSION(500002, "没有修改权限", "have.no.permission"),
201 209 NOT_ALLOWED_ISOLATED_IN_MONOLITH(500003, "【monolith】模式下,不能选择【isolated】类型的租户配置", "not.allowed.isolated.in.monolith"),
... ...
... ... @@ -30,6 +30,8 @@ import org.thingsboard.server.common.data.rule.RuleChainMetaData;
30 30 import org.thingsboard.server.common.data.rule.RuleChainType;
31 31 import org.thingsboard.server.common.data.rule.RuleNode;
32 32 import org.thingsboard.server.common.data.util.ReflectionUtils;
  33 +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
  34 +import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils;
33 35 import org.thingsboard.server.dao.exception.DataValidationException;
34 36 import org.thingsboard.server.dao.rule.RuleChainService;
35 37 import org.thingsboard.server.dao.service.ConstraintValidator;
... ... @@ -67,21 +69,21 @@ public class RuleChainDataValidator extends DataValidator<RuleChain> {
67 69 ruleChain.setType(RuleChainType.CORE);
68 70 }
69 71 if (ruleChain.getTenantId() == null || ruleChain.getTenantId().isNullUid()) {
70   - throw new DataValidationException("Rule chain should be assigned to tenant!");
  72 + throw new DataValidationException(MessageUtils.message(ErrorMessage.RULE_CHAIN_TO_TENANT.getI18nCode()));
71 73 }
72 74 if (!tenantService.tenantExists(ruleChain.getTenantId())) {
73   - throw new DataValidationException("Rule chain is referencing to non-existent tenant!");
  75 + throw new DataValidationException(MessageUtils.message(ErrorMessage.NON_EXISTENT_TENANT.getI18nCode()));
74 76 }
75 77 if (ruleChain.isRoot() && RuleChainType.CORE.equals(ruleChain.getType())) {
76 78 RuleChain rootRuleChain = ruleChainService.getRootTenantRuleChain(ruleChain.getTenantId());
77 79 if (rootRuleChain != null && !rootRuleChain.getId().equals(ruleChain.getId())) {
78   - throw new DataValidationException("Another root rule chain is present in scope of current tenant!");
  80 + throw new DataValidationException(MessageUtils.message(ErrorMessage.ROOT_RULE_CHAIN_IS_PRESENT.getI18nCode()));
79 81 }
80 82 }
81 83 if (ruleChain.isRoot() && RuleChainType.EDGE.equals(ruleChain.getType())) {
82 84 RuleChain edgeTemplateRootRuleChain = ruleChainService.getEdgeTemplateRootRuleChain(ruleChain.getTenantId());
83 85 if (edgeTemplateRootRuleChain != null && !edgeTemplateRootRuleChain.getId().equals(ruleChain.getId())) {
84   - throw new DataValidationException("Another edge template root rule chain is present in scope of current tenant!");
  86 + throw new DataValidationException(MessageUtils.message(ErrorMessage.EDGE_ROOT_RULE_CHAIN_IS_PRESENT.getI18nCode()));
85 87 }
86 88 }
87 89 }
... ...
... ... @@ -64,7 +64,7 @@ public abstract class AbstractQuartzJob implements Job {
64 64 long runMs =
65 65 sysJobLog.getEndTime().toInstant(ZoneOffset.of("+8")).toEpochMilli()
66 66 - startTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
67   - sysJobLog.setJobMessage(" 总共耗时:" + runMs + "毫秒");
  67 + sysJobLog.setJobMessage(String.valueOf(runMs));
68 68 if (e != null) {
69 69 sysJobLog.setStatus(StatusEnum.FAIL.getIndex());
70 70 String errorMsg = StringUtils.substring(e.getMessage(), 0, 2000);
... ...
... ... @@ -5,8 +5,10 @@ import org.apache.commons.lang3.StringUtils;
5 5 import org.quartz.*;
6 6 import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants;
7 7 import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException;
  8 +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
8 9 import org.thingsboard.server.common.data.yunteng.enums.StatusEnum;
9 10 import org.thingsboard.server.common.data.yunteng.utils.SpringBeanUtils;
  11 +import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils;
10 12 import org.thingsboard.server.dao.yunteng.entities.SysJobEntity;
11 13
12 14 import java.util.Objects;
... ... @@ -117,7 +119,7 @@ public class ScheduleUtils {
117 119 try{
118 120 obj = SpringBeanUtils.getBean(StringUtils.split(invokeTarget, ".")[0]);
119 121 }catch (Exception e){
120   - throw new TkDataValidationException("调用方法【"+invokeTarget+"】不存在");
  122 + throw new TkDataValidationException(String.format(MessageUtils.message(ErrorMessage.METHOD_DOES_NOT_EXIST.getI18nCode()),invokeTarget));
121 123 }
122 124 return containsAnyIgnoreCase(
123 125 obj.getClass().getPackage().getName(),
... ...
1 1 package org.thingsboard.server.dao.util.yunteng.task;
2 2
  3 +import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils;
  4 +
3 5 import java.time.LocalDateTime;
4 6 import java.time.ZoneOffset;
5 7
... ... @@ -9,12 +11,14 @@ public class RelativeDateHandler {
9 11 private static final long ONE_DAY = 86400000L;
10 12 private static final long ONE_WEEK = 604800000L;
11 13
12   - private static final String ONE_SECOND_AGO = "秒前";
13   - private static final String ONE_MINUTE_AGO = "分钟前";
14   - private static final String ONE_HOUR_AGO = "小时前";
15   - private static final String ONE_DAY_AGO = "天前";
16   - private static final String ONE_MONTH_AGO = "月前";
17   - private static final String ONE_YEAR_AGO = "年前";
  14 + private static final String ONE_SECOND_AGO = MessageUtils.message("one.second.ago");
  15 + private static final String ONE_MINUTE_AGO = MessageUtils.message("one.minute.ago");
  16 + private static final String ONE_HOUR_AGO =MessageUtils.message("one.huor.ago");
  17 + private static final String ONE_DAY_AGO = MessageUtils.message("one.day.ago");
  18 + private static final String ONE_MONTH_AGO = MessageUtils.message("one.month.ago");
  19 + private static final String ONE_YEAR_AGO =MessageUtils.message("one.year.ago");
  20 + private static final String ONE_JUST_AGO =MessageUtils.message("one.just.ago");
  21 + private static final String ONE_YESTERDAY_AGO =MessageUtils.message("one.yesterday.ago");
18 22
19 23 public static String format(LocalDateTime date) {
20 24 Long currentTime = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
... ... @@ -22,7 +26,7 @@ public class RelativeDateHandler {
22 26 long delta = currentTime - executeTime;
23 27 if (delta < ONE_MINUTE) {
24 28 long seconds = toSeconds(delta);
25   - return seconds <= 0 ? "刚刚" : seconds + ONE_SECOND_AGO;
  29 + return seconds <= 0 ? ONE_JUST_AGO : seconds + ONE_SECOND_AGO;
26 30 }
27 31 if (delta < 45L * ONE_MINUTE) {
28 32 long minutes = toMinutes(delta);
... ... @@ -33,7 +37,7 @@ public class RelativeDateHandler {
33 37 return (hours <= 0 ? 1 : hours) + ONE_HOUR_AGO;
34 38 }
35 39 if (delta < 48L * ONE_HOUR) {
36   - return "昨天";
  40 + return ONE_YESTERDAY_AGO;
37 41 }
38 42 if (delta < 30L * ONE_DAY) {
39 43 long days = toDays(delta);
... ...
... ... @@ -54,7 +54,7 @@ public class TkDeviceProfileCategoryServiceImpl extends AbstractBaseService<TkDe
54 54 Integer status,
55 55 String dictItemId,
56 56 String name) {
57   - List<TkDeviceProfileCategoryDTO> pageEntity = baseMapper.getPage(tenantId,page-1,pageSize,isSysAdmin,status,dictItemId,name);
  57 + List<TkDeviceProfileCategoryDTO> pageEntity = baseMapper.getPage(tenantId,page,pageSize,isSysAdmin,status,dictItemId,name);
58 58 Long pageCount = baseMapper.getPageSize(tenantId,isSysAdmin,status,dictItemId,name);
59 59 return new TkPageData<>(pageEntity, pageCount);
60 60 }
... ...
... ... @@ -34,7 +34,8 @@
34 34 </if>
35 35 ORDER BY create_time desc
36 36 <if test="page != null">
37   - LIMIT #{pageSize} OFFSET #{page}
  37 + LIMIT #{pageSize}
  38 + OFFSET (#{page} - 1) * #{pageSize};
38 39 </if>
39 40 </select>
40 41
... ...
... ... @@ -29,7 +29,8 @@
29 29 GROUP BY application_name
30 30 ORDER BY recordNum desc
31 31 <if test="page != null">
32   - LIMIT #{pageSize} OFFSET #{page}
  32 + LIMIT #{pageSize}
  33 + OFFSET (#{page} - 1) * #{pageSize};
33 34 </if>
34 35 </select>
35 36
... ...
... ... @@ -51,13 +51,14 @@
51 51
52 52 <select id="getProfilePage" resultMap="detail">
53 53 SELECT
54   - <include refid="basicColumns"/>,base.name as categoryName ,
  54 + <include refid="basicColumns"/>,cate.name as categoryName ,
55 55 CASE
56 56 WHEN re.to_id is not null THEN 1
57 57 ELSE 0
58 58 END AS is_edge
59 59 FROM device_profile base
60 60 LEFT JOIN relation re on re.to_id = base.id and from_type = 'EDGE' and re.relation_type = 'ManagedByEdge'
  61 + LEFT JOIN tk_device_profile_category cate on cate.id = base.category_id
61 62 <where>
62 63 <if test="tenantId !=null">
63 64 AND base.tenant_id = #{tenantId}
... ...