package com.mortals.xhx.module.area.model;

import cn.hutool.core.date.DateUtil;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * 区域前端映射树结构实体类
 *
 * @author zxfei
 * @date 2022-01-12
 */
@Data
public class AreaTreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private String id;

    /**
     * 节点名称
     */
    private String label;
    /**
     * 区域编码
     */
    private String areaCode;
    /**
     * 是否叶子节点
     */
    private Boolean isLeaf;

    /**
     * 节点类型
     */
    private String type;

    /**
     * 图标
     */
    private String icon;

    /**
     * 区域等级(1.省，2.地市州，3.区县，4.街道，5.社区)
     */
    private Integer areaLevel;

    /**
     * 子节点
     */
    private List<AreaTreeSelect> children;

    public AreaTreeSelect(AreaEntity entity) {
        this.id = entity.getIid();
        this.label = entity.getName();
        if ("False".equalsIgnoreCase(entity.getHaveSonArea())) {
            this.isLeaf = true;
            this.children = new ArrayList();
        } else {
            this.isLeaf = false;
        }
        this.areaCode=entity.getAreaCode();
        this.areaLevel=entity.getAreaLevel();
        this.type = "area";
        this.icon = "el-icon-folder";
    }


    public static void main(String[] args) {


        int year = 2023; // 目标年份
        int week = 42;   // 目标周数
        int dayOfWeek = 2; // 目标星期几 (1 表示星期日，2 表示星期一，以此类推)

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.WEEK_OF_YEAR, week);
        calendar.set(Calendar.DAY_OF_WEEK, dayOfWeek);

        int targetYear = calendar.get(Calendar.YEAR);
        int targetMonth = calendar.get(Calendar.MONTH) + 1; // 月份是从 0 开始计数的，所以需要 +1
        int targetDay = calendar.get(Calendar.DAY_OF_MONTH);


        System.out.println("目标日期：" + targetYear + "-" + targetMonth + "-" + targetDay);


        String 年_月_日 = DateUtil.format(new Date(), "年 月 日");
        System.out.println(年_月_日);

    }


}