From ef68afe4ed92699b120a524e6db159676da732d7 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Thu, 2 Mar 2023 11:13:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/bean/FirePointQueryResultBean.java | 26 ++++++++++++++++--- .../straw/utils/FirePointQueryManager.java | 24 ++++++++--------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/xkrs/straw/model/bean/FirePointQueryResultBean.java b/src/main/java/com/xkrs/straw/model/bean/FirePointQueryResultBean.java index 908bca5..4cb89de 100644 --- a/src/main/java/com/xkrs/straw/model/bean/FirePointQueryResultBean.java +++ b/src/main/java/com/xkrs/straw/model/bean/FirePointQueryResultBean.java @@ -6,19 +6,29 @@ import java.util.List; public class FirePointQueryResultBean { - private boolean success; + private boolean success = false; - private String errorMessage; + private String errorMessage = null; - private List list; + private List list = null; + + private long count = 0L; public FirePointQueryResultBean() { } - public FirePointQueryResultBean(boolean success, String errorMessage, List list) { + public FirePointQueryResultBean(String errorMessage) { + this.success = false; + this.errorMessage = errorMessage; + this.list = null; + this.count = 0L; + } + + public FirePointQueryResultBean(boolean success, String errorMessage, List list, long count) { this.success = success; this.errorMessage = errorMessage; this.list = list; + this.count = count; } public boolean isSuccess() { @@ -44,4 +54,12 @@ public class FirePointQueryResultBean { public void setList(List list) { this.list = list; } + + public long getCount() { + return count; + } + + public void setCount(long count) { + this.count = count; + } } diff --git a/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java b/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java index a3afb8d..0d3ea5a 100644 --- a/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java +++ b/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java @@ -46,26 +46,26 @@ public class FirePointQueryManager { String userCode = sysUserEntity.getCountyCode(); //如果用户注册的区划编码是空,就返回失败 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); //如果格式化后的用户区划编码是空,就返回失败 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时间范围 String vipTimeRangeJson = sysUserEntity.getVipTimeRangeJson(); //如果用户的VIP时间范围数据是空,就返回失败 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时间范围,得到对象 VipTimeRangeBean vipTimeRangeBean = JsonUtils.deserialize(vipTimeRangeJson, VipTimeRangeBean.class); //用户注册时有初始VIP时间范围,反序列化失败或无数据,说明该用户的数据发生了异常,返回失败 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) { //校验用户VIP开始时间合法性 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结束时间合法性 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 userEndLocalDateTimeA = LocalDateTime.parse(vipTimeRangeItemA.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1); @@ -85,20 +85,20 @@ public class FirePointQueryManager { if (vipTimeRangeItemA != vipTimeRangeItemB) { //校验用户VIP开始时间合法性 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结束时间合法性 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 userEndLocalDateTimeB = LocalDateTime.parse(vipTimeRangeItemB.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1); //校验用户VIP开始结束时间是否存在交叉现象 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)) { - return new FirePointQueryResultBean(false, "User VIP 开始结束时间格式不合法6, 存在交叉现象", null); + return new FirePointQueryResultBean("User VIP 开始结束时间格式不合法6, 存在交叉现象"); } } } @@ -108,7 +108,7 @@ public class FirePointQueryManager { } catch (Exception e) { e.printStackTrace(); - return new FirePointQueryResultBean(false, e.getMessage(), null); + return new FirePointQueryResultBean(e.getMessage()); } // { @@ -274,7 +274,7 @@ public class FirePointQueryManager { } //对合并后的结果进行排序 List sortedResultList = resultList.stream().sorted(Comparator.comparing(AllFirePointVo::getSatelliteTime)).collect(Collectors.toList()); - return new FirePointQueryResultBean(true, "", sortedResultList); + return new FirePointQueryResultBean(true, "", sortedResultList, sortedResultList.size()); } }