Commit de148a4e8c9b8de4244a594cf73d0cef305e4382

Authored by xp.Huang
2 parents a0f98e83 fdb2dd16

Merge branch '20220908' into 'master'

fix: 小程序统计接口异常问题修复

See merge request huang/thingsboard3.3.2!129
@@ -23,7 +23,7 @@ public enum ErrorMessage { @@ -23,7 +23,7 @@ public enum ErrorMessage {
23 PROVIDE_CORRECT_PHONE_NUMBER(400004,"请提供正确的电话号码"), 23 PROVIDE_CORRECT_PHONE_NUMBER(400004,"请提供正确的电话号码"),
24 PROVIDE_CORRECT_EMAIL(400005,"请提供正确的邮箱"), 24 PROVIDE_CORRECT_EMAIL(400005,"请提供正确的邮箱"),
25 PHONE_NUMBER_OR_EMAIL_REQUIRED(400006,"必须提供电话或者邮箱"), 25 PHONE_NUMBER_OR_EMAIL_REQUIRED(400006,"必须提供电话或者邮箱"),
26 - NAME_ALREADY_EXISTS(400007,"名称已存在"), 26 + NAME_ALREADY_EXISTS(400007,"名称已被使用"),
27 ROLE_IN_USE(400008,"该角色还存在用户使用"), 27 ROLE_IN_USE(400008,"该角色还存在用户使用"),
28 NONE_DEFAULT_RULE_CHAIN(400009,"该租户不存在默认的规则链"), 28 NONE_DEFAULT_RULE_CHAIN(400009,"该租户不存在默认的规则链"),
29 TENANT_MISMATCHING(400010,"租户不匹配"), 29 TENANT_MISMATCHING(400010,"租户不匹配"),
@@ -67,7 +67,7 @@ public enum ErrorMessage { @@ -67,7 +67,7 @@ public enum ErrorMessage {
67 VIDEO_PLATFORM_CONFIG_LACK(400047,"流媒体平台信息缺失"), 67 VIDEO_PLATFORM_CONFIG_LACK(400047,"流媒体平台信息缺失"),
68 VIDEO_PLATFORM_CONFIG_ERROR(400048,"流媒体平台信息配置有误"), 68 VIDEO_PLATFORM_CONFIG_ERROR(400048,"流媒体平台信息配置有误"),
69 VIDEO_PLATFORM_NEED_ENABLE_HLS_HTTPS(400049,"平台需开启https的hls协议"), 69 VIDEO_PLATFORM_NEED_ENABLE_HLS_HTTPS(400049,"平台需开启https的hls协议"),
70 - NAME_EXISTED(400050,"名称【%s】已存在"), 70 + NAME_EXISTED(400050,"名称【%s】已被使用"),
71 INVALID_PARAMETER_OR_NOT_MATCH_TENANT(400051,"参数错误或该条数据不属于当前租户"), 71 INVALID_PARAMETER_OR_NOT_MATCH_TENANT(400051,"参数错误或该条数据不属于当前租户"),
72 CRON_INVALID(400052,"cron表达式无效"), 72 CRON_INVALID(400052,"cron表达式无效"),
73 EXPORT_CONFIG_NON_EXISTENT(400053,"报表配置不存在或已被删除"), 73 EXPORT_CONFIG_NON_EXISTENT(400053,"报表配置不存在或已被删除"),
@@ -36,6 +36,8 @@ import org.thingsboard.server.common.data.id.DeviceProfileId; @@ -36,6 +36,8 @@ import org.thingsboard.server.common.data.id.DeviceProfileId;
36 import org.thingsboard.server.common.data.id.TenantId; 36 import org.thingsboard.server.common.data.id.TenantId;
37 import org.thingsboard.server.common.data.page.PageData; 37 import org.thingsboard.server.common.data.page.PageData;
38 import org.thingsboard.server.common.data.page.PageLink; 38 import org.thingsboard.server.common.data.page.PageLink;
  39 +import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException;
  40 +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
39 import org.thingsboard.server.dao.entity.AbstractEntityService; 41 import org.thingsboard.server.dao.entity.AbstractEntityService;
40 import org.thingsboard.server.dao.exception.DataValidationException; 42 import org.thingsboard.server.dao.exception.DataValidationException;
41 import org.thingsboard.server.dao.service.DataValidator; 43 import org.thingsboard.server.dao.service.DataValidator;
@@ -112,7 +114,7 @@ public class DeviceProfileServiceImpl extends AbstractEntityService implements D @@ -112,7 +114,7 @@ public class DeviceProfileServiceImpl extends AbstractEntityService implements D
112 } catch (Exception t) { 114 } catch (Exception t) {
113 ConstraintViolationException e = extractConstraintViolationException(t).orElse(null); 115 ConstraintViolationException e = extractConstraintViolationException(t).orElse(null);
114 if (e != null && e.getConstraintName() != null && e.getConstraintName().equalsIgnoreCase("device_profile_name_unq_key")) { 116 if (e != null && e.getConstraintName() != null && e.getConstraintName().equalsIgnoreCase("device_profile_name_unq_key")) {
115 - throw new DataValidationException("Device profile with such name already exists!"); 117 + throw new YtDataValidationException(ErrorMessage.NAME_ALREADY_EXISTS.getMessage());
116 } else if (e != null && e.getConstraintName() != null && e.getConstraintName().equalsIgnoreCase("device_provision_key_unq_key")) { 118 } else if (e != null && e.getConstraintName() != null && e.getConstraintName().equalsIgnoreCase("device_provision_key_unq_key")) {
117 throw new DataValidationException("Device profile with such provision device key already exists!"); 119 throw new DataValidationException("Device profile with such provision device key already exists!");
118 } else { 120 } else {
@@ -174,7 +174,7 @@ public class HomePageServiceImpl implements HomePageService { @@ -174,7 +174,7 @@ public class HomePageServiceImpl implements HomePageService {
174 }else{ 174 }else{
175 totalExpired.getAndIncrement(); 175 totalExpired.getAndIncrement();
176 } 176 }
177 - if(endTime.isAfter(customer.getUpdateTime()) && startTime.isBefore(customer.getUpdateTime())){ 177 + if(customer.getUpdateTime() != null && endTime.isAfter(customer.getUpdateTime()) && startTime.isBefore(customer.getUpdateTime())){
178 totalActivity.incrementAndGet(); 178 totalActivity.incrementAndGet();
179 } 179 }
180 180
@@ -380,8 +380,8 @@ @@ -380,8 +380,8 @@
380 <select id="findDeviceKeys" resultType="string"> 380 <select id="findDeviceKeys" resultType="string">
381 SELECT 381 SELECT
382 DISTINCT base.key as keyName 382 DISTINCT base.key as keyName
383 - FROM ts_kv_latest latest  
384 - LEFT JOIN ts_kv_dictionary base ON latest.key = base.key_id 383 + FROM ts_kv_dictionary base
  384 + LEFT JOIN ts_kv_latest latest ON latest.key = base.key_id
385 LEFT JOIN device tb ON tb.ID = latest.entity_id 385 LEFT JOIN device tb ON tb.ID = latest.entity_id
386 LEFT JOIN iotfs_device iot ON tb.ID :: TEXT = iot.tb_device_id 386 LEFT JOIN iotfs_device iot ON tb.ID :: TEXT = iot.tb_device_id
387 <where> 387 <where>