Commit c76413233e4284686570f35ea2c9db42a7ce4c10

Authored by chenjunyu_1481036421
1 parent d796edbc

fix:i18n bug修改

@@ -52,6 +52,7 @@ public class TkApplicationController extends BaseController { @@ -52,6 +52,7 @@ public class TkApplicationController extends BaseController {
52 queryMap.put(PAGE, page); 52 queryMap.put(PAGE, page);
53 queryMap.put(ORDER_FILED, orderBy); 53 queryMap.put(ORDER_FILED, orderBy);
54 queryMap.put("name", name); 54 queryMap.put("name", name);
  55 + queryMap.put("tenantId", getCurrentUser().getCurrentTenantId());
55 if(StringUtils.isNotEmpty(organizationId)){ 56 if(StringUtils.isNotEmpty(organizationId)){
56 List<String> organizationIds = tkOrganizationService.organizationAllIds(getCurrentUser().getCurrentTenantId(),organizationId); 57 List<String> organizationIds = tkOrganizationService.organizationAllIds(getCurrentUser().getCurrentTenantId(),organizationId);
57 queryMap.put("organizationIds", organizationIds); 58 queryMap.put("organizationIds", organizationIds);
@@ -195,8 +195,19 @@ openapi.app.isnull= The application does not exist @@ -195,8 +195,19 @@ openapi.app.isnull= The application does not exist
195 openapi.api.isnull= API does not exist 195 openapi.api.isnull= API does not exist
196 publicly.successful = Publicly successful 196 publicly.successful = Publicly successful
197 private.success = Private Success 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,4 +194,18 @@ choice.device.profile.rule.chain.is.used.for.scene = 选中的产å“ã€%s】正å
194 openapi.app.isnull = 应用不存在 194 openapi.app.isnull = 应用不存在
195 openapi.api.isnull = api不存在 195 openapi.api.isnull = api不存在
196 publicly.successful = 公开成功 196 publicly.successful = 公开成功
197 -private.success = 私有成功  
  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,6 +196,14 @@ public enum ErrorMessage {
196 CHOICE_DEVICE_PROFILE_RULE_CHAIN_IS_USED_FOR_SCENE(400161,"选中的产品【%s】正在被场景联动【%s】使用,不能更换规则链!!","choice.device.profile.rule.chain.is.used.for.scene"), 196 CHOICE_DEVICE_PROFILE_RULE_CHAIN_IS_USED_FOR_SCENE(400161,"选中的产品【%s】正在被场景联动【%s】使用,不能更换规则链!!","choice.device.profile.rule.chain.is.used.for.scene"),
197 OPENAPI_APP_ISNULL(400162,"应用不存在","openapi.app.isnull"), 197 OPENAPI_APP_ISNULL(400162,"应用不存在","openapi.app.isnull"),
198 OPENAPI_API_ISNULL(400163,"api不存在","openapi.api.isnull"), 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 HAVE_NO_PERMISSION(500002, "没有修改权限", "have.no.permission"), 208 HAVE_NO_PERMISSION(500002, "没有修改权限", "have.no.permission"),
201 NOT_ALLOWED_ISOLATED_IN_MONOLITH(500003, "【monolith】模式下,不能选择【isolated】类型的租户配置", "not.allowed.isolated.in.monolith"), 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,6 +30,8 @@ import org.thingsboard.server.common.data.rule.RuleChainMetaData;
30 import org.thingsboard.server.common.data.rule.RuleChainType; 30 import org.thingsboard.server.common.data.rule.RuleChainType;
31 import org.thingsboard.server.common.data.rule.RuleNode; 31 import org.thingsboard.server.common.data.rule.RuleNode;
32 import org.thingsboard.server.common.data.util.ReflectionUtils; 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 import org.thingsboard.server.dao.exception.DataValidationException; 35 import org.thingsboard.server.dao.exception.DataValidationException;
34 import org.thingsboard.server.dao.rule.RuleChainService; 36 import org.thingsboard.server.dao.rule.RuleChainService;
35 import org.thingsboard.server.dao.service.ConstraintValidator; 37 import org.thingsboard.server.dao.service.ConstraintValidator;
@@ -67,21 +69,21 @@ public class RuleChainDataValidator extends DataValidator<RuleChain> { @@ -67,21 +69,21 @@ public class RuleChainDataValidator extends DataValidator<RuleChain> {
67 ruleChain.setType(RuleChainType.CORE); 69 ruleChain.setType(RuleChainType.CORE);
68 } 70 }
69 if (ruleChain.getTenantId() == null || ruleChain.getTenantId().isNullUid()) { 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 if (!tenantService.tenantExists(ruleChain.getTenantId())) { 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 if (ruleChain.isRoot() && RuleChainType.CORE.equals(ruleChain.getType())) { 77 if (ruleChain.isRoot() && RuleChainType.CORE.equals(ruleChain.getType())) {
76 RuleChain rootRuleChain = ruleChainService.getRootTenantRuleChain(ruleChain.getTenantId()); 78 RuleChain rootRuleChain = ruleChainService.getRootTenantRuleChain(ruleChain.getTenantId());
77 if (rootRuleChain != null && !rootRuleChain.getId().equals(ruleChain.getId())) { 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 if (ruleChain.isRoot() && RuleChainType.EDGE.equals(ruleChain.getType())) { 83 if (ruleChain.isRoot() && RuleChainType.EDGE.equals(ruleChain.getType())) {
82 RuleChain edgeTemplateRootRuleChain = ruleChainService.getEdgeTemplateRootRuleChain(ruleChain.getTenantId()); 84 RuleChain edgeTemplateRootRuleChain = ruleChainService.getEdgeTemplateRootRuleChain(ruleChain.getTenantId());
83 if (edgeTemplateRootRuleChain != null && !edgeTemplateRootRuleChain.getId().equals(ruleChain.getId())) { 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,7 +64,7 @@ public abstract class AbstractQuartzJob implements Job {
64 long runMs = 64 long runMs =
65 sysJobLog.getEndTime().toInstant(ZoneOffset.of("+8")).toEpochMilli() 65 sysJobLog.getEndTime().toInstant(ZoneOffset.of("+8")).toEpochMilli()
66 - startTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(); 66 - startTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
67 - sysJobLog.setJobMessage(" 总共耗时:" + runMs + "毫秒"); 67 + sysJobLog.setJobMessage(String.valueOf(runMs));
68 if (e != null) { 68 if (e != null) {
69 sysJobLog.setStatus(StatusEnum.FAIL.getIndex()); 69 sysJobLog.setStatus(StatusEnum.FAIL.getIndex());
70 String errorMsg = StringUtils.substring(e.getMessage(), 0, 2000); 70 String errorMsg = StringUtils.substring(e.getMessage(), 0, 2000);
@@ -5,8 +5,10 @@ import org.apache.commons.lang3.StringUtils; @@ -5,8 +5,10 @@ import org.apache.commons.lang3.StringUtils;
5 import org.quartz.*; 5 import org.quartz.*;
6 import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; 6 import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants;
7 import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; 7 import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException;
  8 +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
8 import org.thingsboard.server.common.data.yunteng.enums.StatusEnum; 9 import org.thingsboard.server.common.data.yunteng.enums.StatusEnum;
9 import org.thingsboard.server.common.data.yunteng.utils.SpringBeanUtils; 10 import org.thingsboard.server.common.data.yunteng.utils.SpringBeanUtils;
  11 +import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils;
10 import org.thingsboard.server.dao.yunteng.entities.SysJobEntity; 12 import org.thingsboard.server.dao.yunteng.entities.SysJobEntity;
11 13
12 import java.util.Objects; 14 import java.util.Objects;
@@ -117,7 +119,7 @@ public class ScheduleUtils { @@ -117,7 +119,7 @@ public class ScheduleUtils {
117 try{ 119 try{
118 obj = SpringBeanUtils.getBean(StringUtils.split(invokeTarget, ".")[0]); 120 obj = SpringBeanUtils.getBean(StringUtils.split(invokeTarget, ".")[0]);
119 }catch (Exception e){ 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 return containsAnyIgnoreCase( 124 return containsAnyIgnoreCase(
123 obj.getClass().getPackage().getName(), 125 obj.getClass().getPackage().getName(),
1 package org.thingsboard.server.dao.util.yunteng.task; 1 package org.thingsboard.server.dao.util.yunteng.task;
2 2
  3 +import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils;
  4 +
3 import java.time.LocalDateTime; 5 import java.time.LocalDateTime;
4 import java.time.ZoneOffset; 6 import java.time.ZoneOffset;
5 7
@@ -9,12 +11,14 @@ public class RelativeDateHandler { @@ -9,12 +11,14 @@ public class RelativeDateHandler {
9 private static final long ONE_DAY = 86400000L; 11 private static final long ONE_DAY = 86400000L;
10 private static final long ONE_WEEK = 604800000L; 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 public static String format(LocalDateTime date) { 23 public static String format(LocalDateTime date) {
20 Long currentTime = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli(); 24 Long currentTime = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
@@ -22,7 +26,7 @@ public class RelativeDateHandler { @@ -22,7 +26,7 @@ public class RelativeDateHandler {
22 long delta = currentTime - executeTime; 26 long delta = currentTime - executeTime;
23 if (delta < ONE_MINUTE) { 27 if (delta < ONE_MINUTE) {
24 long seconds = toSeconds(delta); 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 if (delta < 45L * ONE_MINUTE) { 31 if (delta < 45L * ONE_MINUTE) {
28 long minutes = toMinutes(delta); 32 long minutes = toMinutes(delta);
@@ -33,7 +37,7 @@ public class RelativeDateHandler { @@ -33,7 +37,7 @@ public class RelativeDateHandler {
33 return (hours <= 0 ? 1 : hours) + ONE_HOUR_AGO; 37 return (hours <= 0 ? 1 : hours) + ONE_HOUR_AGO;
34 } 38 }
35 if (delta < 48L * ONE_HOUR) { 39 if (delta < 48L * ONE_HOUR) {
36 - return "昨天"; 40 + return ONE_YESTERDAY_AGO;
37 } 41 }
38 if (delta < 30L * ONE_DAY) { 42 if (delta < 30L * ONE_DAY) {
39 long days = toDays(delta); 43 long days = toDays(delta);
@@ -54,7 +54,7 @@ public class TkDeviceProfileCategoryServiceImpl extends AbstractBaseService<TkDe @@ -54,7 +54,7 @@ public class TkDeviceProfileCategoryServiceImpl extends AbstractBaseService<TkDe
54 Integer status, 54 Integer status,
55 String dictItemId, 55 String dictItemId,
56 String name) { 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 Long pageCount = baseMapper.getPageSize(tenantId,isSysAdmin,status,dictItemId,name); 58 Long pageCount = baseMapper.getPageSize(tenantId,isSysAdmin,status,dictItemId,name);
59 return new TkPageData<>(pageEntity, pageCount); 59 return new TkPageData<>(pageEntity, pageCount);
60 } 60 }
@@ -34,7 +34,8 @@ @@ -34,7 +34,8 @@
34 </if> 34 </if>
35 ORDER BY create_time desc 35 ORDER BY create_time desc
36 <if test="page != null"> 36 <if test="page != null">
37 - LIMIT #{pageSize} OFFSET #{page} 37 + LIMIT #{pageSize}
  38 + OFFSET (#{page} - 1) * #{pageSize};
38 </if> 39 </if>
39 </select> 40 </select>
40 41
@@ -29,7 +29,8 @@ @@ -29,7 +29,8 @@
29 GROUP BY application_name 29 GROUP BY application_name
30 ORDER BY recordNum desc 30 ORDER BY recordNum desc
31 <if test="page != null"> 31 <if test="page != null">
32 - LIMIT #{pageSize} OFFSET #{page} 32 + LIMIT #{pageSize}
  33 + OFFSET (#{page} - 1) * #{pageSize};
33 </if> 34 </if>
34 </select> 35 </select>
35 36
@@ -51,13 +51,14 @@ @@ -51,13 +51,14 @@
51 51
52 <select id="getProfilePage" resultMap="detail"> 52 <select id="getProfilePage" resultMap="detail">
53 SELECT 53 SELECT
54 - <include refid="basicColumns"/>,base.name as categoryName , 54 + <include refid="basicColumns"/>,cate.name as categoryName ,
55 CASE 55 CASE
56 WHEN re.to_id is not null THEN 1 56 WHEN re.to_id is not null THEN 1
57 ELSE 0 57 ELSE 0
58 END AS is_edge 58 END AS is_edge
59 FROM device_profile base 59 FROM device_profile base
60 LEFT JOIN relation re on re.to_id = base.id and from_type = 'EDGE' and re.relation_type = 'ManagedByEdge' 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 <where> 62 <where>
62 <if test="tenantId !=null"> 63 <if test="tenantId !=null">
63 AND base.tenant_id = #{tenantId} 64 AND base.tenant_id = #{tenantId}