Browse Source

#风电驾驶舱

zhongwei
yang_shj 1 year ago
parent
commit
7b7089ad15
  1. 8
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/EminfoAndEmParamVo.java
  2. 36
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindDeviceVo.java
  3. 33
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindGenerationVo.java
  4. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindScoreVo.java
  5. 71
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindStationVo.java
  6. 33
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindTargetCurveVo.java
  7. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml
  8. 29
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WindHomeController.java
  9. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/WindHomeService.java
  10. 240
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java

8
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/EminfoAndEmParamVo.java

@ -26,6 +26,14 @@ public class EminfoAndEmParamVo extends EmInfoExtendVo {
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private int rideCount; private int rideCount;
@ApiModelProperty(value = "经度")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lgtd;
@ApiModelProperty(value = "纬度")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lttd;
@ApiModelProperty(value = "机组运行状态") @ApiModelProperty(value = "机组运行状态")
private String runStatus; private String runStatus;

36
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindDeviceVo.java

@ -0,0 +1,36 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel(value = "风电设备对象")
public class WindDeviceVo {
@ApiModelProperty(value = "归属机构")
private Long deptId;
@ApiModelProperty(value = "编码")
private String code;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "经度")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lgtd;
@ApiModelProperty(value = "纬度")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lttd;
@ApiModelProperty(value = "排序")
private Integer ord;
}

33
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindGenerationVo.java

@ -0,0 +1,33 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "风电站点对象")
public class WindGenerationVo {
@ApiModelProperty(value = "年份")
private Integer year;
@ApiModelProperty(value = "月份")
private String mon;
@ApiModelProperty(value = "计划发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double plan;
@ApiModelProperty(value = "发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generation;
}

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindScoreVo.java

@ -12,7 +12,7 @@ import java.util.List;
* @author ysj * @author ysj
*/ */
@Data @Data
@ApiModel(value = "水电站分计对象") @ApiModel(value = "风电集团/区域指标对象")
public class WindScoreVo { public class WindScoreVo {
@ApiModelProperty(value = "机构Id") @ApiModelProperty(value = "机构Id")

71
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindStationVo.java

@ -0,0 +1,71 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "风电站点对象")
public class WindStationVo {
@ApiModelProperty(value = "机构Id")
private Long departId;
@ApiModelProperty(value = "机构名称")
private String departName;
@ApiModelProperty(value = "城市行政区域编码")
private String areaCode;
@ApiModelProperty(value = "运行天数")
private Long runDay;
@ApiModelProperty(value = "装机容量")
private Double capacity;
@ApiModelProperty(value = "年计划发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double planYear;
@ApiModelProperty(value = "月计划发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double planMon;
@ApiModelProperty(value = "已发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generation;
@ApiModelProperty(value = "日上网电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationDay;
@ApiModelProperty(value = "日平均风速")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double speed;
@ApiModelProperty(value = "日峰值功率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double peak;
@ApiModelProperty(value = "日综合厂用电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double comprehensivePower;
@ApiModelProperty(value = "日可用时长")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double available;
@ApiModelProperty(value = "风电设备")
private List<WindDeviceVo> devices;
@ApiModelProperty(value = "天气")
private List<Daily> weather;
}

33
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindTargetCurveVo.java

@ -0,0 +1,33 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel(value = "风电站点对象")
public class WindTargetCurveVo {
@ApiModelProperty(value = "月份")
private String mon;
@ApiModelProperty(value = "日期")
private Integer day;
@ApiModelProperty(value = "日上网电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationDay;
@ApiModelProperty(value = "日平均风速")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double speed;
@ApiModelProperty(value = "日峰值功率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double peak;
}

2
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml

@ -91,7 +91,7 @@
SELECT * FROM `hzims_em_info` WHERE IS_DELETED = 0 AND HOME_PAGE_DISPLAY = 1 and `NUMBER` = #{emCode} SELECT * FROM `hzims_em_info` WHERE IS_DELETED = 0 AND HOME_PAGE_DISPLAY = 1 and `NUMBER` = #{emCode}
</select> </select>
<select id="selectEminfoAndEmParamVoList" resultType="com.hnac.hzims.equipment.vo.EminfoAndEmParamVo"> <select id="selectEminfoAndEmParamVoList" resultType="com.hnac.hzims.equipment.vo.EminfoAndEmParamVo">
SELECT ID AS id, `NAME` as name,`NUMBER` as emCode,CREATE_DEPT as createDept,RUN_STATUS as runStatus,IFNULL(EM_INDEX,1) as ord FROM `hzims_em_info` WHERE IS_DELETED = 0 AND HOME_PAGE_DISPLAY = 1 SELECT ID AS id, `NAME` as name,`NUMBER` as emCode,CREATE_DEPT as createDept,RUN_STATUS as runStatus,IFNULL(EM_INDEX,1) as ord,LGTD,LTTD FROM `hzims_em_info` WHERE IS_DELETED = 0 AND HOME_PAGE_DISPLAY = 1
</select> </select>
<update id="updateBachEmState"> <update id="updateBachEmState">

29
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WindHomeController.java

@ -2,8 +2,7 @@ package com.hnac.hzims.operational.main.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.main.service.WindHomeService; import com.hnac.hzims.operational.main.service.WindHomeService;
import com.hnac.hzims.operational.main.vo.HydropowerScoreVo; import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.main.vo.WindScoreVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -15,6 +14,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* @author ysj * @author ysj
*/ */
@ -34,4 +35,28 @@ public class WindHomeController extends BladeController {
return R.data(service.KPIs(deptId)); return R.data(service.KPIs(deptId));
} }
@ApiLog
@ApiOperation("风电站点指标数据")
@GetMapping("/station")
@ApiOperationSupport(order = 2)
public R<WindStationVo> station(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.station(deptId));
}
@ApiLog
@ApiOperation("风电站点发电量")
@GetMapping("/generation")
@ApiOperationSupport(order = 3)
public R<List<WindGenerationVo>> generation(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.generation(deptId));
}
@ApiLog
@ApiOperation("风电站点月份曲线数据")
@GetMapping("/target_curve")
@ApiOperationSupport(order = 3)
public R<List<WindTargetCurveVo>> target_curve(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.target_curve(deptId));
}
} }

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/WindHomeService.java

@ -1,6 +1,11 @@
package com.hnac.hzims.operational.main.service; package com.hnac.hzims.operational.main.service;
import com.hnac.hzims.operational.main.vo.WindGenerationVo;
import com.hnac.hzims.operational.main.vo.WindScoreVo; import com.hnac.hzims.operational.main.vo.WindScoreVo;
import com.hnac.hzims.operational.main.vo.WindStationVo;
import com.hnac.hzims.operational.main.vo.WindTargetCurveVo;
import java.util.List;
/** /**
* @author ysj * @author ysj
@ -9,4 +14,10 @@ public interface WindHomeService {
WindScoreVo KPIs(Long deptId); WindScoreVo KPIs(Long deptId);
WindStationVo station(Long deptId);
List<WindGenerationVo> generation(Long deptId);
List<WindTargetCurveVo> target_curve(Long deptId);
} }

240
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java

@ -1,22 +1,36 @@
package com.hnac.hzims.operational.main.service.impl; package com.hnac.hzims.operational.main.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.operational.fill.entity.WindEntity; import com.hnac.hzims.operational.fill.entity.WindEntity;
import com.hnac.hzims.operational.fill.service.WindService; import com.hnac.hzims.operational.fill.service.WindService;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.IWeatherService;
import com.hnac.hzims.operational.main.service.WindHomeService; import com.hnac.hzims.operational.main.service.WindHomeService;
import com.hnac.hzims.operational.main.vo.WindScoreVo; import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.server.domain.Sys;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.Duration;
import java.util.List; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -27,10 +41,21 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class WindHomeServiceImpl implements WindHomeService { public class WindHomeServiceImpl implements WindHomeService {
private final WindService windService;
private final IWeatherService weatherService;
private final IStationService stationService; private final IStationService stationService;
private final WindService windService; private final RedisTemplate redisTemplate;
public final static String device_cache_final = "hzims:equipment:emInfo:deviceCode.emInfoList";
/**
* 集团/区域指标数据
* @param deptId
* @return
*/
@Override @Override
public WindScoreVo KPIs(Long deptId) { public WindScoreVo KPIs(Long deptId) {
// 查询风电站 // 查询风电站
@ -64,6 +89,159 @@ public class WindHomeServiceImpl implements WindHomeService {
return score; return score;
} }
/**
* 站点指标数据
* @param deptId
* @return
*/
@Override
public WindStationVo station(Long deptId) {
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getRefDept,deptId)
);
if(ObjectUtil.isEmpty(station)){
return new WindStationVo();
}
WindStationVo wind = new WindStationVo();
// 机构编码
wind.setDepartId(station.getRefDept());
// 机构名称
wind.setDepartName(station.getName());
// 站点行政区域编码
wind.setAreaCode(station.getAreaCode());
// 站点七天天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = weatherService.getWeekWeather(Collections.singletonList(station.getCode()));
wind.setWeather(this.getDailyList(weekWeather,station.getCode()));
// 安全运行天数
if (ObjectUtil.isNotEmpty(station.getCommissionTime())) {
wind.setRunDay(Duration.between(station.getCommissionTime(), LocalDateTime.now()).toDays());
}
// 设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
if(CollectionUtil.isNotEmpty(devices)){
// 装机容量
wind.setCapacity(devices.stream().filter(device->device.getCreateDept().equals(station.getRefDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum());
// 设备列表
wind.setDevices(devices.stream().filter(device->device.getCreateDept().equals(station.getRefDept())).map(item->{
WindDeviceVo windDevice = new WindDeviceVo();
windDevice.setDeptId(item.getCreateDept());
windDevice.setCode(item.getEmCode());
windDevice.setName(item.getName());
windDevice.setOrd(item.getOrd());
windDevice.setLgtd(item.getLgtd());
windDevice.setLttd(item.getLttd());
return windDevice;
}).collect(Collectors.toList()));
}
// 查询站点填报数据 - 全部
List<WindEntity> all = windService.list(Wrappers.<WindEntity>lambdaQuery()
.eq(WindEntity::getStationCode,station.getCode())
);
if(CollectionUtil.isNotEmpty(all)){
// 年计划发电量
wind.setPlanYear(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPlan).sum());
// 月计划发电量
wind.setPlanMon(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPlan).sum());
// 总发电量
wind.setGeneration(all.stream().mapToDouble(WindEntity::getPower).sum());
// 日上网电量
wind.setGenerationDay(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getSurfPower).sum());
// 日平均风速
wind.setSpeed(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getSpeed).sum());
// 日峰值功率
wind.setPeak(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getPeakPower).sum());
// 日综合厂用电量
wind.setComprehensivePower(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getComprehensivePower).sum());
// 日可用时长
wind.setAvailable(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getAvailable).sum());
}
return wind;
}
/**
* 风电站点发电量柱状数据
* @param deptId
* @return
*/
@Override
public List<WindGenerationVo> generation(Long deptId) {
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getRefDept,deptId)
);
if(ObjectUtil.isEmpty(station)){
return new ArrayList<>();
}
// 查询风电填报数据
List<WindEntity> winds = windService.list(Wrappers.<WindEntity>lambdaQuery()
.eq(WindEntity::getStationCode,station.getCode())
);
if(CollectionUtil.isEmpty(winds)){
return new ArrayList<>();
}
List<String> monList = this.mons(1,12,false);
return monList.stream().map(mon->{
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
WindGenerationVo generation = new WindGenerationVo();
generation.setYear(localDate.getYear());
generation.setMon(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue());
generation.setPlan(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPlan).sum());
generation.setGeneration(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPower).sum());
return generation;
}).collect(Collectors.toList());
}
/**
* 风电站点月份曲线数据
* @param deptId
* @return
*/
@Override
public List<WindTargetCurveVo> target_curve(Long deptId) {
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getRefDept,deptId)
);
if(ObjectUtil.isEmpty(station)){
return new ArrayList<>();
}
// 查询风电填报数据
List<WindEntity> winds = windService.list(Wrappers.<WindEntity>lambdaQuery()
.eq(WindEntity::getStationCode,station.getCode())
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy-MM"))
);
if(CollectionUtil.isEmpty(winds)){
return new ArrayList<>();
}
List<String> days = this.getCurrentDayList();
return days.stream().map(day->{
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), day), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
WindTargetCurveVo curve = new WindTargetCurveVo();
curve.setMon(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue());
curve.setDay(localDate.getDayOfMonth());
curve.setPeak(winds.stream().filter(o->o.getFillDate().contains(day)).mapToDouble(WindEntity::getPeakPower).sum());
curve.setGenerationDay(winds.stream().filter(o->o.getFillDate().contains(day)).mapToDouble(WindEntity::getSurfPower).sum());
curve.setSpeed(winds.stream().filter(o->o.getFillDate().contains(day)).mapToDouble(WindEntity::getSpeed).sum());
return curve;
}).collect(Collectors.toList());
}
/**
* 获取七天天气
* @param weekWeather
* @param code
* @return
*/
private List<Daily> getDailyList(Map<String, HeWeatherWeatherDailyResponse> weekWeather, String code) {
if(MapUtils.isEmpty(weekWeather)){
return null;
}
HeWeatherWeatherDailyResponse week = weekWeather.get(code);
if(ObjectUtil.isEmpty(week)){
return null;
}
return week.getDaily();
}
/** /**
* 风电数据 - * 风电数据 -
* @param years * @param years
@ -108,4 +286,58 @@ public class WindHomeServiceImpl implements WindHomeService {
// 日发电量 // 日发电量
score.setGenerateDay(days.stream().mapToDouble(WindEntity::getPower).sum()); score.setGenerateDay(days.stream().mapToDouble(WindEntity::getPower).sum());
} }
/**
* 获取近年月份集合
* @param year
* @return
*/
public List<String> mons(int year, int endMoth, boolean nextMon) {
List<String> list = new ArrayList<>();
// 开始日期
Calendar endCal = Calendar.getInstance();
endCal.setTime(new Date());
endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + endMoth);
endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1);
// 结束日期
Calendar startCal = Calendar.getInstance();
startCal.setTime(new Date());
startCal.set(Calendar.YEAR, startCal.get(Calendar.YEAR) - year);
startCal.add(Calendar.MONTH, -startCal.get(Calendar.MONTH));
startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1);
// 获取日期之间的月份
while (endCal.after(startCal)) {
list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE));
startCal.add(Calendar.MONTH, 1);
}
if(nextMon){
list.add(DateUtil.format(endCal.getTime(),DateUtil.PATTERN_DATE));
}
return list;
}
/**
* 获取当月日期List
* @return
*/
private List<String> getCurrentDayList() {
List<String> list = new ArrayList<>();
// 开始日期
Calendar startCal = Calendar.getInstance();
startCal.setTime(new Date());
startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1);
// 结束日期
Calendar endCal = Calendar.getInstance();
endCal.setTime(new Date());
endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1);
endCal.add(Calendar.MONTH, 1);
// 获取日期之间日期
while (endCal.after(startCal)) {
list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE));
startCal.add(Calendar.DATE, 1);
}
return list;
}
} }
Loading…
Cancel
Save