优化
This commit is contained in:
parent
debab6db6e
commit
ef68afe4ed
@ -6,19 +6,29 @@ import java.util.List;
|
|||||||
|
|
||||||
public class FirePointQueryResultBean {
|
public class FirePointQueryResultBean {
|
||||||
|
|
||||||
private boolean success;
|
private boolean success = false;
|
||||||
|
|
||||||
private String errorMessage;
|
private String errorMessage = null;
|
||||||
|
|
||||||
private List<AllFirePointVo> list;
|
private List<AllFirePointVo> list = null;
|
||||||
|
|
||||||
|
private long count = 0L;
|
||||||
|
|
||||||
public FirePointQueryResultBean() {
|
public FirePointQueryResultBean() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FirePointQueryResultBean(boolean success, String errorMessage, List<AllFirePointVo> list) {
|
public FirePointQueryResultBean(String errorMessage) {
|
||||||
|
this.success = false;
|
||||||
|
this.errorMessage = errorMessage;
|
||||||
|
this.list = null;
|
||||||
|
this.count = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FirePointQueryResultBean(boolean success, String errorMessage, List<AllFirePointVo> list, long count) {
|
||||||
this.success = success;
|
this.success = success;
|
||||||
this.errorMessage = errorMessage;
|
this.errorMessage = errorMessage;
|
||||||
this.list = list;
|
this.list = list;
|
||||||
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuccess() {
|
public boolean isSuccess() {
|
||||||
@ -44,4 +54,12 @@ public class FirePointQueryResultBean {
|
|||||||
public void setList(List<AllFirePointVo> list) {
|
public void setList(List<AllFirePointVo> list) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCount(long count) {
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,26 +46,26 @@ public class FirePointQueryManager {
|
|||||||
String userCode = sysUserEntity.getCountyCode();
|
String userCode = sysUserEntity.getCountyCode();
|
||||||
//如果用户注册的区划编码是空,就返回失败
|
//如果用户注册的区划编码是空,就返回失败
|
||||||
if (TextUtils.isEmpty(userCode)) {
|
if (TextUtils.isEmpty(userCode)) {
|
||||||
return new FirePointQueryResultBean(false, "User CountyCode Error 1, userCode = " + userCode, null);
|
return new FirePointQueryResultBean("User CountyCode Error 1, userCode = " + userCode);
|
||||||
}
|
}
|
||||||
//对用户区划编码进行格式化,获得没有冗余数据的区划编码
|
//对用户区划编码进行格式化,获得没有冗余数据的区划编码
|
||||||
String noRedundantUserCode = FirePointCodeUtils.getFormatCutCode(userCode);
|
String noRedundantUserCode = FirePointCodeUtils.getFormatCutCode(userCode);
|
||||||
//如果格式化后的用户区划编码是空,就返回失败
|
//如果格式化后的用户区划编码是空,就返回失败
|
||||||
if (TextUtils.isEmpty(noRedundantUserCode)) {
|
if (TextUtils.isEmpty(noRedundantUserCode)) {
|
||||||
return new FirePointQueryResultBean(false, "User CountyCode Error 2, userCode = " + userCode + ", noRedundantUserCode = " + noRedundantUserCode, null);
|
return new FirePointQueryResultBean("User CountyCode Error 2, userCode = " + userCode + ", noRedundantUserCode = " + noRedundantUserCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取用户的VIP时间范围
|
//获取用户的VIP时间范围
|
||||||
String vipTimeRangeJson = sysUserEntity.getVipTimeRangeJson();
|
String vipTimeRangeJson = sysUserEntity.getVipTimeRangeJson();
|
||||||
//如果用户的VIP时间范围数据是空,就返回失败
|
//如果用户的VIP时间范围数据是空,就返回失败
|
||||||
if (TextUtils.isEmpty(vipTimeRangeJson)) {
|
if (TextUtils.isEmpty(vipTimeRangeJson)) {
|
||||||
return new FirePointQueryResultBean(false, "User VipTimeRangeJson Error 1, vipTimeRangeJson = " + vipTimeRangeJson, null);
|
return new FirePointQueryResultBean("User VipTimeRangeJson Error 1, vipTimeRangeJson = " + vipTimeRangeJson);
|
||||||
}
|
}
|
||||||
//反序列化用户的VIP时间范围,得到对象
|
//反序列化用户的VIP时间范围,得到对象
|
||||||
VipTimeRangeBean vipTimeRangeBean = JsonUtils.deserialize(vipTimeRangeJson, VipTimeRangeBean.class);
|
VipTimeRangeBean vipTimeRangeBean = JsonUtils.deserialize(vipTimeRangeJson, VipTimeRangeBean.class);
|
||||||
//用户注册时有初始VIP时间范围,反序列化失败或无数据,说明该用户的数据发生了异常,返回失败
|
//用户注册时有初始VIP时间范围,反序列化失败或无数据,说明该用户的数据发生了异常,返回失败
|
||||||
if (vipTimeRangeBean == null || vipTimeRangeBean.getList() == null || vipTimeRangeBean.getList().size() == 0) {
|
if (vipTimeRangeBean == null || vipTimeRangeBean.getList() == null || vipTimeRangeBean.getList().size() == 0) {
|
||||||
return new FirePointQueryResultBean(false, "User VipTimeRangeJson Error 2, 已保存的VIP时间范围反序列化失败, vipTimeRangeJson = " + vipTimeRangeJson, null);
|
return new FirePointQueryResultBean("User VipTimeRangeJson Error 2, 已保存的VIP时间范围反序列化失败, vipTimeRangeJson = " + vipTimeRangeJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
//得到由<开始时间 + 结束时间>组成的集合
|
//得到由<开始时间 + 结束时间>组成的集合
|
||||||
@ -73,11 +73,11 @@ public class FirePointQueryManager {
|
|||||||
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItemA : vipTimeRangeItemList) {
|
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItemA : vipTimeRangeItemList) {
|
||||||
//校验用户VIP开始时间合法性
|
//校验用户VIP开始时间合法性
|
||||||
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemA.getStartTime())) {
|
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemA.getStartTime())) {
|
||||||
return new FirePointQueryResultBean(false, "User VIP 开始时间格式不合法1, StartTime = " + vipTimeRangeItemA.getStartTime(), null);
|
return new FirePointQueryResultBean("User VIP 开始时间格式不合法1, StartTime = " + vipTimeRangeItemA.getStartTime());
|
||||||
}
|
}
|
||||||
//校验用户VIP结束时间合法性
|
//校验用户VIP结束时间合法性
|
||||||
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemA.getEndTime())) {
|
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemA.getEndTime())) {
|
||||||
return new FirePointQueryResultBean(false, "User VIP 结束时间格式不合法2, EndTime = " + vipTimeRangeItemA.getEndTime(), null);
|
return new FirePointQueryResultBean("User VIP 结束时间格式不合法2, EndTime = " + vipTimeRangeItemA.getEndTime());
|
||||||
}
|
}
|
||||||
LocalDateTime userStartLocalDateTimeA = LocalDateTime.parse(vipTimeRangeItemA.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
LocalDateTime userStartLocalDateTimeA = LocalDateTime.parse(vipTimeRangeItemA.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
||||||
LocalDateTime userEndLocalDateTimeA = LocalDateTime.parse(vipTimeRangeItemA.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
LocalDateTime userEndLocalDateTimeA = LocalDateTime.parse(vipTimeRangeItemA.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
||||||
@ -85,20 +85,20 @@ public class FirePointQueryManager {
|
|||||||
if (vipTimeRangeItemA != vipTimeRangeItemB) {
|
if (vipTimeRangeItemA != vipTimeRangeItemB) {
|
||||||
//校验用户VIP开始时间合法性
|
//校验用户VIP开始时间合法性
|
||||||
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemB.getStartTime())) {
|
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemB.getStartTime())) {
|
||||||
return new FirePointQueryResultBean(false, "User VIP 开始时间格式不合法3, StartTime = " + vipTimeRangeItemB.getStartTime(), null);
|
return new FirePointQueryResultBean("User VIP 开始时间格式不合法3, StartTime = " + vipTimeRangeItemB.getStartTime());
|
||||||
}
|
}
|
||||||
//校验用户VIP结束时间合法性
|
//校验用户VIP结束时间合法性
|
||||||
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemB.getEndTime())) {
|
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemB.getEndTime())) {
|
||||||
return new FirePointQueryResultBean(false, "User VIP 结束时间格式不合法4, EndTime = " + vipTimeRangeItemB.getEndTime(), null);
|
return new FirePointQueryResultBean("User VIP 结束时间格式不合法4, EndTime = " + vipTimeRangeItemB.getEndTime());
|
||||||
}
|
}
|
||||||
LocalDateTime userStartLocalDateTimeB = LocalDateTime.parse(vipTimeRangeItemB.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
LocalDateTime userStartLocalDateTimeB = LocalDateTime.parse(vipTimeRangeItemB.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
||||||
LocalDateTime userEndLocalDateTimeB = LocalDateTime.parse(vipTimeRangeItemB.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
LocalDateTime userEndLocalDateTimeB = LocalDateTime.parse(vipTimeRangeItemB.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
||||||
//校验用户VIP开始结束时间是否存在交叉现象
|
//校验用户VIP开始结束时间是否存在交叉现象
|
||||||
if (userStartLocalDateTimeB.isBefore(userStartLocalDateTimeA) && userEndLocalDateTimeB.isAfter(userStartLocalDateTimeA)) {
|
if (userStartLocalDateTimeB.isBefore(userStartLocalDateTimeA) && userEndLocalDateTimeB.isAfter(userStartLocalDateTimeA)) {
|
||||||
return new FirePointQueryResultBean(false, "User VIP 开始结束时间格式不合法5, 存在交叉现象", null);
|
return new FirePointQueryResultBean("User VIP 开始结束时间格式不合法5, 存在交叉现象");
|
||||||
}
|
}
|
||||||
if (userStartLocalDateTimeB.isBefore(userEndLocalDateTimeA) && userEndLocalDateTimeB.isAfter(userEndLocalDateTimeA)) {
|
if (userStartLocalDateTimeB.isBefore(userEndLocalDateTimeA) && userEndLocalDateTimeB.isAfter(userEndLocalDateTimeA)) {
|
||||||
return new FirePointQueryResultBean(false, "User VIP 开始结束时间格式不合法6, 存在交叉现象", null);
|
return new FirePointQueryResultBean("User VIP 开始结束时间格式不合法6, 存在交叉现象");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ public class FirePointQueryManager {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return new FirePointQueryResultBean(false, e.getMessage(), null);
|
return new FirePointQueryResultBean(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// {
|
// {
|
||||||
@ -274,7 +274,7 @@ public class FirePointQueryManager {
|
|||||||
}
|
}
|
||||||
//对合并后的结果进行排序
|
//对合并后的结果进行排序
|
||||||
List<AllFirePointVo> sortedResultList = resultList.stream().sorted(Comparator.comparing(AllFirePointVo::getSatelliteTime)).collect(Collectors.toList());
|
List<AllFirePointVo> sortedResultList = resultList.stream().sorted(Comparator.comparing(AllFirePointVo::getSatelliteTime)).collect(Collectors.toList());
|
||||||
return new FirePointQueryResultBean(true, "", sortedResultList);
|
return new FirePointQueryResultBean(true, "", sortedResultList, sortedResultList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user