diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/DgEfficiencyController.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/DgEfficiencyController.java index c35a7c14..9250c312 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/DgEfficiencyController.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/DgEfficiencyController.java @@ -148,6 +148,61 @@ public class DgEfficiencyController { } } } + + // 时间筛选(固定时间),先根据固定时间筛选,再根据自选时间筛选 + if (personalEfficiencyListRequest.getCreateFixedTime() != null ) { + switch (personalEfficiencyListRequest.getCreateFixedTime()) { + case 0: + personalEfficiencyListRequest.setStartTime(DateUtils.getDayBegin()); + personalEfficiencyListRequest.setEndTime(DateUtils.getDayEnd());// 今天 + break; + case 1: + personalEfficiencyListRequest.setStartTime(DateUtils.getBeginDayOfYesterday()); + personalEfficiencyListRequest.setEndTime(DateUtils.getEndDayOfYesterDay());// 昨天 + break; + case 2: + personalEfficiencyListRequest.setStartTime(DateUtils.getBeginDayOfWeek()); + personalEfficiencyListRequest.setEndTime(DateUtils.getEndDayOfWeek());// 本周 + break; + case 3: + personalEfficiencyListRequest.setStartTime(DateUtils.getBeginDayOfMonth()); + personalEfficiencyListRequest.setEndTime(DateUtils.getEndDayOfMonth());// 本月 + break; + case 4: + personalEfficiencyListRequest.setStartTime(DateUtils.getBeginDayOfYear()); + personalEfficiencyListRequest.setEndTime(DateUtils.getEndDayOfYear());// 本年 + break; + } + //自选时间筛选 + }else if (personalEfficiencyListRequest.getStartTime() != null && personalEfficiencyListRequest.getEndTime() != null){ + personalEfficiencyListRequest.setStartTime(personalEfficiencyListRequest.getStartTime()); + personalEfficiencyListRequest.setEndTime(personalEfficiencyListRequest.getEndTime()); + }else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = null; + try { + date = sdf.parse("2020-04-16 00:00:00"); + } catch (ParseException e) { + e.printStackTrace(); + } + personalEfficiencyListRequest.setStartTime(date); + personalEfficiencyListRequest.setEndTime(new Date()); + } + //获取毫秒数 + long longStart = personalEfficiencyListRequest.getStartTime().getTime(); + long longEnd = personalEfficiencyListRequest.getEndTime().getTime(); + //迭代器进行筛选(过滤不在指定范围的时间数据) + Iterator iterator = responseList.iterator(); + while (iterator.hasNext()) { + PersonalEfficiencyListResponse next = iterator.next(); + String applicationDate = next.getApplicationDate(); + long longDate = getLongDate(applicationDate); + //当前日期小于开始日期或当前日期大于结束日期,删除该元素 + if (longDate < longStart || longDate > longEnd) { + iterator.remove(); + } + } + String userId = DgApplyAmountInfoController.getUserId(); CopyForMeRequest copyForMeRequest = new CopyForMeRequest(); copyForMeRequest.setUserId(Integer.parseInt(userId)); @@ -186,60 +241,15 @@ public class DgEfficiencyController { // 已发起 if (personalEfficiencyListRequest.getOperatingStatus().equals(StatusCode.CZ_LAUNCH)) { responseList.removeIf(next -> !next.getOperatingStatus().equals(StatusCode.CZ_LAUNCH)); - // responseList = responseList.stream().filter(p -> !p.getOperatingStatus().equals(StatusCode.CZ_LAUNCH)).collect(Collectors.toList()); // 待处理 } else if (personalEfficiencyListRequest.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)) { responseList.removeIf(next -> !next.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)); - // responseList = responseList.stream().filter(p -> !p.getOperatingStatus().equals(StatusCode.CZ_ON_HAND)).collect(Collectors.toList()); // 已处理 } else if (personalEfficiencyListRequest.getOperatingStatus().equals(StatusCode.CZ_PROCESSED)) { responseList.removeIf(next -> !next.getOperatingStatus().equals(StatusCode.CZ_PROCESSED)); - // responseList = responseList.stream().filter(p -> !p.getOperatingStatus().equals(StatusCode.CZ_PROCESSED)).collect(Collectors.toList()); - } - } - // 时间筛选(固定时间) - if (personalEfficiencyListRequest.getCreateFixedTime() != null && personalEfficiencyListRequest.getStartTime() == null && personalEfficiencyListRequest.getEndTime() == null) { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - switch (personalEfficiencyListRequest.getCreateFixedTime()) { - case 0: - personalEfficiencyListRequest.setStartTime(dateFormat.format(DateUtils.getDayBegin())); - personalEfficiencyListRequest.setEndTime(dateFormat.format(DateUtils.getDayEnd()));// 今天 - break; - case 1: - personalEfficiencyListRequest.setStartTime(dateFormat.format(DateUtils.getBeginDayOfYesterday())); - personalEfficiencyListRequest.setEndTime(dateFormat.format(DateUtils.getEndDayOfYesterDay()));// 昨天 - break; - case 2: - personalEfficiencyListRequest.setStartTime(dateFormat.format(DateUtils.getBeginDayOfWeek())); - personalEfficiencyListRequest.setEndTime(dateFormat.format(DateUtils.getEndDayOfWeek()));// 本周 - break; - case 3: - personalEfficiencyListRequest.setStartTime(dateFormat.format(DateUtils.getBeginDayOfMonth())); - personalEfficiencyListRequest.setEndTime(dateFormat.format(DateUtils.getEndDayOfMonth()));// 本月 - break; - case 4: - personalEfficiencyListRequest.setStartTime(dateFormat.format(DateUtils.getBeginDayOfYear())); - personalEfficiencyListRequest.setEndTime(dateFormat.format(DateUtils.getEndDayOfYear()));// 本年 - break; - default: - personalEfficiencyListRequest.setStartTime(null); - personalEfficiencyListRequest.setEndTime(null); - } - //获取毫秒数 - long longStart = getLongDate(personalEfficiencyListRequest.getStartTime()); - long longEnd = getLongDate(personalEfficiencyListRequest.getEndTime()); - //迭代器进行筛选 - Iterator iterator = responseList.iterator(); - while (iterator.hasNext()) { - PersonalEfficiencyListResponse next = iterator.next(); - String applicationDate = next.getApplicationDate(); - long longDate = getLongDate(applicationDate); - //当前日期小于开始日期或当前日期大于结束日期,删除该元素 - if (longDate < longStart || longDate > longEnd) { - iterator.remove(); - } } } + //按时间降序排列 List collect = responseList.stream().sorted((o1, o2) -> { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/PersonalEfficiencyListRequest.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/PersonalEfficiencyListRequest.java index 91571f33..304eeb7a 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/PersonalEfficiencyListRequest.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/request/PersonalEfficiencyListRequest.java @@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; +import java.util.Date; + /** * @Author chen * @DATE 2020/12/31 15:35 @@ -19,11 +21,11 @@ public class PersonalEfficiencyListRequest { @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @ApiModelProperty("起始时间") - private String startTime; + private Date startTime; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @ApiModelProperty("结束时间") - private String endTime; + private Date endTime; @ApiModelProperty("操作状态") private Integer operatingStatus;