|
@@ -94,7 +94,7 @@ public class CommonUtil {
|
|
|
public static void setMonthDate(PlatformCalendarRequest platformCalendarRequest) {
|
|
|
String dateStr = platformCalendarRequest.getRequestDateStr();
|
|
|
//如果请求时间为空,就设置带天的请求时间
|
|
|
- if(StringUtils.isBlank(dateStr)) {
|
|
|
+ if (StringUtils.isBlank(dateStr)) {
|
|
|
dateStr = platformCalendarRequest.getRequestDateDayStr();
|
|
|
}
|
|
|
Map<String, String> dateTypeToDateValue = CommonUtil.getMonthDate(dateStr,
|
|
@@ -102,9 +102,6 @@ public class CommonUtil {
|
|
|
//设置月初时间
|
|
|
platformCalendarRequest.setMonthBeginStr(dateTypeToDateValue.get(
|
|
|
CommonConstants.PlatformCalendarConstants.MONTH_BEGIN_DATE));
|
|
|
- //设置当期时间
|
|
|
- platformCalendarRequest.setNowStr(LocalDate.now().format(DateTimeFormatter.ofPattern(
|
|
|
- CommonConstants.PlatformCalendarConstants.TRANS_DATE_FORMAT)));
|
|
|
//设置月末时间
|
|
|
platformCalendarRequest.setMonthEndStr(dateTypeToDateValue.get(
|
|
|
CommonConstants.PlatformCalendarConstants.MONTH_END_DATE));
|
|
@@ -121,7 +118,8 @@ public class CommonUtil {
|
|
|
LocalDate transDate = LocalDate.parse(timeDateStr, DateTimeFormatter.ofPattern(timeFormat));
|
|
|
Map<Integer, Map<Integer, Long>> dayToLiftStatusToNum = new HashMap<>();
|
|
|
if (transDate != null) {
|
|
|
- for (int monthDay = 1; monthDay <= transDate.getMonthValue(); monthDay++) {
|
|
|
+ int dayNum = getLastDayNumOfMonth(transDate);
|
|
|
+ for (int monthDay = 1; monthDay <= dayNum; monthDay++) {
|
|
|
Map<Integer, Long> liftStatusToNum = new HashMap<>();
|
|
|
for (int liftStatus : CommonConstants.PlatformCalendarConstants.LIFT_STATUS_ARRAY) {
|
|
|
liftStatusToNum.put(liftStatus, 0L);
|
|
@@ -205,4 +203,30 @@ public class CommonUtil {
|
|
|
return dayToDataMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @description 获取某月的天数
|
|
|
+ */
|
|
|
+ public static int getLastDayNumOfMonth(LocalDate date) {
|
|
|
+ if (date != null) {
|
|
|
+ return date.with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth();
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @description 获取给点日期字符串指定格式的月的天数
|
|
|
+ * @date 2020/2/28 2:57 下午
|
|
|
+ */
|
|
|
+ public static int getLastDayNumOfMonthFromDateStr(String dateStr, String format) {
|
|
|
+ if (StringUtils.isNotBlank(dateStr)) {
|
|
|
+ LocalDate date = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern(format));
|
|
|
+ return getLastDayNumOfMonth(date);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
}
|