package com.zc.business.domain; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.domain.BaseEntity; import com.zc.business.enums.TrafficDataPeriodTypeEnum; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.util.Date; @Data public class DcStatisticsData implements Serializable { private static final long serialVersionUID = 1L; /** * 主键 */ private String id; /** * 统计时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") private Date statisticalDate; /** * 上报时间 */ @TableField(exist = false) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") private Date reportTime; /** * 车流量 */ private Integer trafficVolume; /** * 统计粒度 * 1-年 * 2-月 * 3-季 * 4-日 */ private Byte periodType; /** * 创建时间 */ private Date createTime; /** * 修改时间 */ private Date updateTime; /** * 1型客车车流量 */ private Integer type1PassengerFlow; /** * 2型客车车流量 */ private Integer type2PassengerFlow; /** * 3型客车车流量 */ private Integer type3PassengerFlow; /** * 4型客车车流量 */ private Integer type4PassengerFlow; /** * 1型货车车流量 */ private Integer type1TruckFlow; /** * 2型货车车流量 */ private Integer type2TruckFlow; /** * 3型货车车流量 */ private Integer type3TruckFlow; /** * 4型货车车流量 */ private Integer type4TruckFlow; /** * 5型货车车流量 */ private Integer type5TruckFlow; /** * 6型货车车流量 */ private Integer type6TruckFlow; /** * 1型专项作业车车流量 */ private Integer type1SpecialVehicleFlow; /** * 2型专项作业车车流量 */ private Integer type2SpecialVehicleFlow; /** * 3型专项作业车车流量 */ private Integer type3SpecialVehicleFlow; /** * 4型专项作业车车流量 */ private Integer type4SpecialVehicleFlow; /** * 5型专项作业车车流量 */ private Integer type5SpecialVehicleFlow; /** * 6型专项作业车车流量 */ private Integer type6SpecialVehicleFlow; /** * 开始时间 */ @TableField(exist = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date startTime; /** * 结束时间 */ @TableField(exist = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date endTime; public void setPeriodType(Byte periodType) { this.periodType = periodType; } /** * 设置交通数据的统计周期类型。 * @param periodType 统计周期类型的枚举值。 */ public void setPeriodType(TrafficDataPeriodTypeEnum periodType) { this.periodType = periodType.getCode(); // 将枚举类型转换为代码值存储 } /** * 根据给定的统计周期类型和日期,设置统计日期为相应周期的起始日期。 * @param statisticalDate 原始统计日期。 * @param typeEnum 统计周期类型。 */ public void setStatisticalDate(Date statisticalDate, TrafficDataPeriodTypeEnum typeEnum) { switch (typeEnum) { case DAY: // 设置为当天的起始时间 this.statisticalDate = DateUtil.beginOfDay(statisticalDate); break; case MONTH: // 设置为当月的起始日期 this.statisticalDate = DateUtil.beginOfMonth(statisticalDate); break; case QUARTER: // 设置为当季度的起始日期 this.statisticalDate = DateUtil.beginOfQuarter(statisticalDate); break; case YEAR: // 设置为当年的起始日期 this.statisticalDate = DateUtil.beginOfYear(statisticalDate); break; default: // 如果不是预定义的周期类型,则不做任何处理 this.statisticalDate = statisticalDate; } } public void generateUniqueId() { } }