摘要:
本文介绍了一个基于Java的周次生成工具,用于根据指定的年份和周次类型(自然周或财务周)生成连续的周次列表数据。
需求描述:
根据周次类型,生成连续的周次列表数据。
周次类型分2种:
- 自然周:周一至周日
- 财务周:周五至下周四
特殊要求:
- 按某年第一个周止日(类型为自然周时,是某年第一个周日),计算得到某年的第一周。
- 按周止日算年份、月份;若周起日是当年,而周止日是下一年,则对应周算入下一年的第一周。
最终效果展示:
效果:(自然周)
效果:(财务周)
实现步骤:
1.定义周次类型枚举
包括自然周和财务周,并指定了每种周次的起始和结束日期对应的星期几。
import java.util.Calendar;/**周次类型*/
public enum WeekKindEnum {// 周一到周日G("G", Calendar.MONDAY,Calendar.SUNDAY,"自然周"),// 周五到下周四F("F",Calendar.FRIDAY,Calendar.THURSDAY,"财务周");WeekKindEnum(String code, int beginNum, int endNum, String desc) {this.code = code;this.beginNum = beginNum;this.endNum = endNum;this.desc = desc;}private String code;private int beginNum;private int endNum;private String desc;public String getCode() {return code;}public int getBeginNum() {return beginNum;}public int getEndNum() {return endNum;}public String getDesc() {return desc;}
}
2.定义周次实体
用于存储周次的相关信息,如年份、周起止日期、周次、周描述、所属年月等。
import java.text.SimpleDateFormat;
import java.util.Date;/*** @ClassName WeekEntity* @Description 周次* @Date 2024/11/8 23:29* @Author yqwang*/
public class WeekEntity {/*年*/private String year;/*周起*/private Date beginDate;/*周止*/private Date endDate;/*周次(某年第几周)*/private int week;/*周描述*/private String weekDesc;/*周次(某月第几周)*/private int weekMonth;/*所属年月yyyy-MM*/private String yearMonth;/*所属年月yyyy-MM-01*/private Date yearMonthDate;/*类型:G(general)自然周F(finance)财务周*/private String kindId;public String getYear() {return year;}public void setYear(String year) {this.year = year;}public Date getBeginDate() {return beginDate;}public void setBeginDate(Date beginDate) {this.beginDate = beginDate;}public Date getEndDate() {return endDate;}public void setEndDate(Date endDate) {this.endDate = endDate;}public int getWeek() {return week;}public void setWeek(int week) {this.week = week;}public String getWeekDesc() {return weekDesc;}public void setWeekDesc(String weekDesc) {this.weekDesc = weekDesc;}public int getWeekMonth() {return weekMonth;}public void setWeekMonth(int weekMonth) {this.weekMonth = weekMonth;}public String getYearMonth() {return yearMonth;}public void setYearMonth(String yearMonth) {this.yearMonth = yearMonth;}public Date getYearMonthDate() {return yearMonthDate;}public void setYearMonthDate(Date yearMonthDate) {this.yearMonthDate = yearMonthDate;}public String getKindId() {return kindId;}public void setKindId(String kindId) {this.kindId = kindId;}@Overridepublic String toString() {return "WeekEntity{" +"year='" + year + '\'' +", beginDate=" + formatDate(beginDate) +", endDate=" + formatDate(endDate) +", week=" + week +", weekDesc='" + weekDesc + '\'' +", weekMonth=" + weekMonth +", yearMonth='" + yearMonth + '\'' +", yearMonthDate=" + formatDate(yearMonthDate) +", kindId='" + kindId + '\'' +'}';}private static String formatDate(Date date) {SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");return sdf.format(date);}
}
3.编写生成工具类
编写了生成工具类WeekOfMonthCalcUtil
,其中包含了generateWeeks
方法,用于根据年份和周次类型生成周次列表。该方法首先获取第一周的起止日期,然后循环得到每年的每周,并设置周次实体的其他属性值。
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;/*** @ClassName WeekOfMonthCalcUtil* @Description 用于生成年份的周次(自然周、财务周)信息* @Date 2024/11/8 16:41* @Author yqwang*/
public class WeekOfMonthCalcUtil {public static void main(String[] args) {// 自然周List<WeekEntity> weeks = generateWeeks(2023, WeekKindEnum.G);weeks.addAll(generateWeeks(2024, WeekKindEnum.G));// 还需要财务周? // weeks.addAll(generateWeeks(2024, WeekKindEnum.F));// 打印结果for (WeekEntity week : weeks) {System.out.println(week);}}/*** @Title:generateWeeks* @param year 需要生成周次的年份* @param weekKindEnum 周次类型* @return 周次列表*/public static List<WeekEntity> generateWeeks(int year, WeekKindEnum weekKindEnum) {List<WeekEntity> weeks = new ArrayList<>(53);// 1.获取第一周的起止日期Calendar weekStart = getFirstWeekStart(year, weekKindEnum);// 今年的第几周int yearWeek = 1;while (weekStart.get(Calendar.YEAR) <= year){// 2.循环得到今年的每周,终止条件:开始年份<=目标年份WeekEntity row = new WeekEntity();row.setYear(String.valueOf(year));row.setBeginDate(weekStart.getTime());// 周止Calendar weekEnd = (Calendar) weekStart.clone();weekEnd.add(Calendar.DAY_OF_YEAR, 6);row.setEndDate(weekEnd.getTime());if(weekEnd.get(Calendar.YEAR) > year){// 周止是下一年,则退出(会算到下一年的第一周)break;}// 设置其他属性值row.setWeek(yearWeek);// 第1周(24.12.30~25.01.05)row.setWeekDesc(String.format("第%s周(%s~%s)",yearWeek,formatDate(row.getBeginDate(),"yy.MM.dd"),formatDate(row.getEndDate(),"yy.MM.dd")));// (正常以[周止]判断所属月;特殊:止是下一年,则以[周起判断所属月])Calendar belongDate = weekEnd;if(weekEnd.get(Calendar.YEAR) > year){belongDate = weekStart;}// 所属年月yyyy-MMrow.setYearMonth(formatDate(belongDate,"yyyy-MM"));// 所属年月yyyy-MM-01row.setYearMonthDate(truncDate(belongDate,"yyyy-MM"));// 所属周的当月第几周(若周止所在月天>=7,则周次-1)int dayOfWeek = weekEnd.get(Calendar.DAY_OF_MONTH);int weekMonth = (int) Math.floor((dayOfWeek-0.1)/7)+1;row.setWeekMonth(weekMonth);// 类型row.setKindId(weekKindEnum.getCode());weeks.add(row);// 3.周+1yearWeek ++;weekStart.add(Calendar.DAY_OF_YEAR, 7);}return weeks;}/**返回yyyy-MM-dd格式*/@SuppressWarnings("unused")private static String formatDate(Calendar calendar) {return formatDate(calendar.getTime());}/**返回yyyy-MM-dd格式*/private static String formatDate(Date date) {return formatDate(date,"yyyy-MM-dd");}/**返回指定格式*/private static String formatDate(Calendar calendar,String pattern){return formatDate(calendar.getTime(),pattern);}/**返回指定格式*/private static String formatDate(Date date,String pattern){if (date == null ) {throw new IllegalArgumentException("Date and format must not be null");}SimpleDateFormat sdf = new SimpleDateFormat(pattern);return sdf.format(date);}/**日期截取*/private static Date truncDate(Calendar calendar,String pattern){return truncDate(calendar.getTime(),pattern);}/**日期截取*/private static Date truncDate(Date date,String pattern){String dateStr = formatDate(date,pattern);DateFormat df = new SimpleDateFormat(pattern);try {return df.parse(dateStr);} catch (ParseException e) {e.printStackTrace();}return null;}/*** 获取某年第一个的周起日* 说明:通过某年第一个周止,往前推6天,即可得到周起日* */private static Calendar getFirstWeekStart(int year, WeekKindEnum weekKindEnum) {// yyyy-01-01Calendar end = Calendar.getInstance();end.set(year, Calendar.JANUARY, 1);// 1.拿到某年第一个周止while(true){// 2.当前是否是周止,不是则加1天,继续判断if(end.get(Calendar.DAY_OF_WEEK)== weekKindEnum.getEndNum()){break;}// +1天end.add(Calendar.DAY_OF_MONTH, 1);}// 3.返回周起日end.add(Calendar.DAY_OF_YEAR, -6);return end;}}
4.main()方法运行效果测试
WeekEntity{year='2023', beginDate=2022-12-26, endDate=2023-01-01, week=1, weekDesc='第1周(22.12.26~23.01.01)', weekMonth=1, yearMonth='2023-01', yearMonthDate=2023-01-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-01-02, endDate=2023-01-08, week=2, weekDesc='第2周(23.01.02~23.01.08)', weekMonth=2, yearMonth='2023-01', yearMonthDate=2023-01-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-01-09, endDate=2023-01-15, week=3, weekDesc='第3周(23.01.09~23.01.15)', weekMonth=3, yearMonth='2023-01', yearMonthDate=2023-01-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-01-16, endDate=2023-01-22, week=4, weekDesc='第4周(23.01.16~23.01.22)', weekMonth=4, yearMonth='2023-01', yearMonthDate=2023-01-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-01-23, endDate=2023-01-29, week=5, weekDesc='第5周(23.01.23~23.01.29)', weekMonth=5, yearMonth='2023-01', yearMonthDate=2023-01-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-01-30, endDate=2023-02-05, week=6, weekDesc='第6周(23.01.30~23.02.05)', weekMonth=1, yearMonth='2023-02', yearMonthDate=2023-02-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-02-06, endDate=2023-02-12, week=7, weekDesc='第7周(23.02.06~23.02.12)', weekMonth=2, yearMonth='2023-02', yearMonthDate=2023-02-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-02-13, endDate=2023-02-19, week=8, weekDesc='第8周(23.02.13~23.02.19)', weekMonth=3, yearMonth='2023-02', yearMonthDate=2023-02-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-02-20, endDate=2023-02-26, week=9, weekDesc='第9周(23.02.20~23.02.26)', weekMonth=4, yearMonth='2023-02', yearMonthDate=2023-02-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-02-27, endDate=2023-03-05, week=10, weekDesc='第10周(23.02.27~23.03.05)', weekMonth=1, yearMonth='2023-03', yearMonthDate=2023-03-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-03-06, endDate=2023-03-12, week=11, weekDesc='第11周(23.03.06~23.03.12)', weekMonth=2, yearMonth='2023-03', yearMonthDate=2023-03-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-03-13, endDate=2023-03-19, week=12, weekDesc='第12周(23.03.13~23.03.19)', weekMonth=3, yearMonth='2023-03', yearMonthDate=2023-03-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-03-20, endDate=2023-03-26, week=13, weekDesc='第13周(23.03.20~23.03.26)', weekMonth=4, yearMonth='2023-03', yearMonthDate=2023-03-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-03-27, endDate=2023-04-02, week=14, weekDesc='第14周(23.03.27~23.04.02)', weekMonth=1, yearMonth='2023-04', yearMonthDate=2023-04-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-04-03, endDate=2023-04-09, week=15, weekDesc='第15周(23.04.03~23.04.09)', weekMonth=2, yearMonth='2023-04', yearMonthDate=2023-04-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-04-10, endDate=2023-04-16, week=16, weekDesc='第16周(23.04.10~23.04.16)', weekMonth=3, yearMonth='2023-04', yearMonthDate=2023-04-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-04-17, endDate=2023-04-23, week=17, weekDesc='第17周(23.04.17~23.04.23)', weekMonth=4, yearMonth='2023-04', yearMonthDate=2023-04-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-04-24, endDate=2023-04-30, week=18, weekDesc='第18周(23.04.24~23.04.30)', weekMonth=5, yearMonth='2023-04', yearMonthDate=2023-04-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-05-01, endDate=2023-05-07, week=19, weekDesc='第19周(23.05.01~23.05.07)', weekMonth=1, yearMonth='2023-05', yearMonthDate=2023-05-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-05-08, endDate=2023-05-14, week=20, weekDesc='第20周(23.05.08~23.05.14)', weekMonth=2, yearMonth='2023-05', yearMonthDate=2023-05-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-05-15, endDate=2023-05-21, week=21, weekDesc='第21周(23.05.15~23.05.21)', weekMonth=3, yearMonth='2023-05', yearMonthDate=2023-05-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-05-22, endDate=2023-05-28, week=22, weekDesc='第22周(23.05.22~23.05.28)', weekMonth=4, yearMonth='2023-05', yearMonthDate=2023-05-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-05-29, endDate=2023-06-04, week=23, weekDesc='第23周(23.05.29~23.06.04)', weekMonth=1, yearMonth='2023-06', yearMonthDate=2023-06-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-06-05, endDate=2023-06-11, week=24, weekDesc='第24周(23.06.05~23.06.11)', weekMonth=2, yearMonth='2023-06', yearMonthDate=2023-06-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-06-12, endDate=2023-06-18, week=25, weekDesc='第25周(23.06.12~23.06.18)', weekMonth=3, yearMonth='2023-06', yearMonthDate=2023-06-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-06-19, endDate=2023-06-25, week=26, weekDesc='第26周(23.06.19~23.06.25)', weekMonth=4, yearMonth='2023-06', yearMonthDate=2023-06-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-06-26, endDate=2023-07-02, week=27, weekDesc='第27周(23.06.26~23.07.02)', weekMonth=1, yearMonth='2023-07', yearMonthDate=2023-07-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-07-03, endDate=2023-07-09, week=28, weekDesc='第28周(23.07.03~23.07.09)', weekMonth=2, yearMonth='2023-07', yearMonthDate=2023-07-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-07-10, endDate=2023-07-16, week=29, weekDesc='第29周(23.07.10~23.07.16)', weekMonth=3, yearMonth='2023-07', yearMonthDate=2023-07-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-07-17, endDate=2023-07-23, week=30, weekDesc='第30周(23.07.17~23.07.23)', weekMonth=4, yearMonth='2023-07', yearMonthDate=2023-07-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-07-24, endDate=2023-07-30, week=31, weekDesc='第31周(23.07.24~23.07.30)', weekMonth=5, yearMonth='2023-07', yearMonthDate=2023-07-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-07-31, endDate=2023-08-06, week=32, weekDesc='第32周(23.07.31~23.08.06)', weekMonth=1, yearMonth='2023-08', yearMonthDate=2023-08-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-08-07, endDate=2023-08-13, week=33, weekDesc='第33周(23.08.07~23.08.13)', weekMonth=2, yearMonth='2023-08', yearMonthDate=2023-08-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-08-14, endDate=2023-08-20, week=34, weekDesc='第34周(23.08.14~23.08.20)', weekMonth=3, yearMonth='2023-08', yearMonthDate=2023-08-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-08-21, endDate=2023-08-27, week=35, weekDesc='第35周(23.08.21~23.08.27)', weekMonth=4, yearMonth='2023-08', yearMonthDate=2023-08-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-08-28, endDate=2023-09-03, week=36, weekDesc='第36周(23.08.28~23.09.03)', weekMonth=1, yearMonth='2023-09', yearMonthDate=2023-09-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-09-04, endDate=2023-09-10, week=37, weekDesc='第37周(23.09.04~23.09.10)', weekMonth=2, yearMonth='2023-09', yearMonthDate=2023-09-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-09-11, endDate=2023-09-17, week=38, weekDesc='第38周(23.09.11~23.09.17)', weekMonth=3, yearMonth='2023-09', yearMonthDate=2023-09-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-09-18, endDate=2023-09-24, week=39, weekDesc='第39周(23.09.18~23.09.24)', weekMonth=4, yearMonth='2023-09', yearMonthDate=2023-09-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-09-25, endDate=2023-10-01, week=40, weekDesc='第40周(23.09.25~23.10.01)', weekMonth=1, yearMonth='2023-10', yearMonthDate=2023-10-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-10-02, endDate=2023-10-08, week=41, weekDesc='第41周(23.10.02~23.10.08)', weekMonth=2, yearMonth='2023-10', yearMonthDate=2023-10-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-10-09, endDate=2023-10-15, week=42, weekDesc='第42周(23.10.09~23.10.15)', weekMonth=3, yearMonth='2023-10', yearMonthDate=2023-10-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-10-16, endDate=2023-10-22, week=43, weekDesc='第43周(23.10.16~23.10.22)', weekMonth=4, yearMonth='2023-10', yearMonthDate=2023-10-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-10-23, endDate=2023-10-29, week=44, weekDesc='第44周(23.10.23~23.10.29)', weekMonth=5, yearMonth='2023-10', yearMonthDate=2023-10-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-10-30, endDate=2023-11-05, week=45, weekDesc='第45周(23.10.30~23.11.05)', weekMonth=1, yearMonth='2023-11', yearMonthDate=2023-11-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-11-06, endDate=2023-11-12, week=46, weekDesc='第46周(23.11.06~23.11.12)', weekMonth=2, yearMonth='2023-11', yearMonthDate=2023-11-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-11-13, endDate=2023-11-19, week=47, weekDesc='第47周(23.11.13~23.11.19)', weekMonth=3, yearMonth='2023-11', yearMonthDate=2023-11-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-11-20, endDate=2023-11-26, week=48, weekDesc='第48周(23.11.20~23.11.26)', weekMonth=4, yearMonth='2023-11', yearMonthDate=2023-11-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-11-27, endDate=2023-12-03, week=49, weekDesc='第49周(23.11.27~23.12.03)', weekMonth=1, yearMonth='2023-12', yearMonthDate=2023-12-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-12-04, endDate=2023-12-10, week=50, weekDesc='第50周(23.12.04~23.12.10)', weekMonth=2, yearMonth='2023-12', yearMonthDate=2023-12-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-12-11, endDate=2023-12-17, week=51, weekDesc='第51周(23.12.11~23.12.17)', weekMonth=3, yearMonth='2023-12', yearMonthDate=2023-12-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-12-18, endDate=2023-12-24, week=52, weekDesc='第52周(23.12.18~23.12.24)', weekMonth=4, yearMonth='2023-12', yearMonthDate=2023-12-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-12-25, endDate=2023-12-31, week=53, weekDesc='第53周(23.12.25~23.12.31)', weekMonth=5, yearMonth='2023-12', yearMonthDate=2023-12-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-01-01, endDate=2024-01-07, week=1, weekDesc='第1周(24.01.01~24.01.07)', weekMonth=1, yearMonth='2024-01', yearMonthDate=2024-01-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-01-08, endDate=2024-01-14, week=2, weekDesc='第2周(24.01.08~24.01.14)', weekMonth=2, yearMonth='2024-01', yearMonthDate=2024-01-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-01-15, endDate=2024-01-21, week=3, weekDesc='第3周(24.01.15~24.01.21)', weekMonth=3, yearMonth='2024-01', yearMonthDate=2024-01-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-01-22, endDate=2024-01-28, week=4, weekDesc='第4周(24.01.22~24.01.28)', weekMonth=4, yearMonth='2024-01', yearMonthDate=2024-01-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-01-29, endDate=2024-02-04, week=5, weekDesc='第5周(24.01.29~24.02.04)', weekMonth=1, yearMonth='2024-02', yearMonthDate=2024-02-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-02-05, endDate=2024-02-11, week=6, weekDesc='第6周(24.02.05~24.02.11)', weekMonth=2, yearMonth='2024-02', yearMonthDate=2024-02-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-02-12, endDate=2024-02-18, week=7, weekDesc='第7周(24.02.12~24.02.18)', weekMonth=3, yearMonth='2024-02', yearMonthDate=2024-02-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-02-19, endDate=2024-02-25, week=8, weekDesc='第8周(24.02.19~24.02.25)', weekMonth=4, yearMonth='2024-02', yearMonthDate=2024-02-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-02-26, endDate=2024-03-03, week=9, weekDesc='第9周(24.02.26~24.03.03)', weekMonth=1, yearMonth='2024-03', yearMonthDate=2024-03-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-03-04, endDate=2024-03-10, week=10, weekDesc='第10周(24.03.04~24.03.10)', weekMonth=2, yearMonth='2024-03', yearMonthDate=2024-03-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-03-11, endDate=2024-03-17, week=11, weekDesc='第11周(24.03.11~24.03.17)', weekMonth=3, yearMonth='2024-03', yearMonthDate=2024-03-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-03-18, endDate=2024-03-24, week=12, weekDesc='第12周(24.03.18~24.03.24)', weekMonth=4, yearMonth='2024-03', yearMonthDate=2024-03-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-03-25, endDate=2024-03-31, week=13, weekDesc='第13周(24.03.25~24.03.31)', weekMonth=5, yearMonth='2024-03', yearMonthDate=2024-03-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-04-01, endDate=2024-04-07, week=14, weekDesc='第14周(24.04.01~24.04.07)', weekMonth=1, yearMonth='2024-04', yearMonthDate=2024-04-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-04-08, endDate=2024-04-14, week=15, weekDesc='第15周(24.04.08~24.04.14)', weekMonth=2, yearMonth='2024-04', yearMonthDate=2024-04-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-04-15, endDate=2024-04-21, week=16, weekDesc='第16周(24.04.15~24.04.21)', weekMonth=3, yearMonth='2024-04', yearMonthDate=2024-04-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-04-22, endDate=2024-04-28, week=17, weekDesc='第17周(24.04.22~24.04.28)', weekMonth=4, yearMonth='2024-04', yearMonthDate=2024-04-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-04-29, endDate=2024-05-05, week=18, weekDesc='第18周(24.04.29~24.05.05)', weekMonth=1, yearMonth='2024-05', yearMonthDate=2024-05-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-05-06, endDate=2024-05-12, week=19, weekDesc='第19周(24.05.06~24.05.12)', weekMonth=2, yearMonth='2024-05', yearMonthDate=2024-05-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-05-13, endDate=2024-05-19, week=20, weekDesc='第20周(24.05.13~24.05.19)', weekMonth=3, yearMonth='2024-05', yearMonthDate=2024-05-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-05-20, endDate=2024-05-26, week=21, weekDesc='第21周(24.05.20~24.05.26)', weekMonth=4, yearMonth='2024-05', yearMonthDate=2024-05-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-05-27, endDate=2024-06-02, week=22, weekDesc='第22周(24.05.27~24.06.02)', weekMonth=1, yearMonth='2024-06', yearMonthDate=2024-06-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-06-03, endDate=2024-06-09, week=23, weekDesc='第23周(24.06.03~24.06.09)', weekMonth=2, yearMonth='2024-06', yearMonthDate=2024-06-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-06-10, endDate=2024-06-16, week=24, weekDesc='第24周(24.06.10~24.06.16)', weekMonth=3, yearMonth='2024-06', yearMonthDate=2024-06-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-06-17, endDate=2024-06-23, week=25, weekDesc='第25周(24.06.17~24.06.23)', weekMonth=4, yearMonth='2024-06', yearMonthDate=2024-06-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-06-24, endDate=2024-06-30, week=26, weekDesc='第26周(24.06.24~24.06.30)', weekMonth=5, yearMonth='2024-06', yearMonthDate=2024-06-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-07-01, endDate=2024-07-07, week=27, weekDesc='第27周(24.07.01~24.07.07)', weekMonth=1, yearMonth='2024-07', yearMonthDate=2024-07-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-07-08, endDate=2024-07-14, week=28, weekDesc='第28周(24.07.08~24.07.14)', weekMonth=2, yearMonth='2024-07', yearMonthDate=2024-07-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-07-15, endDate=2024-07-21, week=29, weekDesc='第29周(24.07.15~24.07.21)', weekMonth=3, yearMonth='2024-07', yearMonthDate=2024-07-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-07-22, endDate=2024-07-28, week=30, weekDesc='第30周(24.07.22~24.07.28)', weekMonth=4, yearMonth='2024-07', yearMonthDate=2024-07-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-07-29, endDate=2024-08-04, week=31, weekDesc='第31周(24.07.29~24.08.04)', weekMonth=1, yearMonth='2024-08', yearMonthDate=2024-08-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-08-05, endDate=2024-08-11, week=32, weekDesc='第32周(24.08.05~24.08.11)', weekMonth=2, yearMonth='2024-08', yearMonthDate=2024-08-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-08-12, endDate=2024-08-18, week=33, weekDesc='第33周(24.08.12~24.08.18)', weekMonth=3, yearMonth='2024-08', yearMonthDate=2024-08-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-08-19, endDate=2024-08-25, week=34, weekDesc='第34周(24.08.19~24.08.25)', weekMonth=4, yearMonth='2024-08', yearMonthDate=2024-08-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-08-26, endDate=2024-09-01, week=35, weekDesc='第35周(24.08.26~24.09.01)', weekMonth=1, yearMonth='2024-09', yearMonthDate=2024-09-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-09-02, endDate=2024-09-08, week=36, weekDesc='第36周(24.09.02~24.09.08)', weekMonth=2, yearMonth='2024-09', yearMonthDate=2024-09-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-09-09, endDate=2024-09-15, week=37, weekDesc='第37周(24.09.09~24.09.15)', weekMonth=3, yearMonth='2024-09', yearMonthDate=2024-09-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-09-16, endDate=2024-09-22, week=38, weekDesc='第38周(24.09.16~24.09.22)', weekMonth=4, yearMonth='2024-09', yearMonthDate=2024-09-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-09-23, endDate=2024-09-29, week=39, weekDesc='第39周(24.09.23~24.09.29)', weekMonth=5, yearMonth='2024-09', yearMonthDate=2024-09-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-09-30, endDate=2024-10-06, week=40, weekDesc='第40周(24.09.30~24.10.06)', weekMonth=1, yearMonth='2024-10', yearMonthDate=2024-10-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-10-07, endDate=2024-10-13, week=41, weekDesc='第41周(24.10.07~24.10.13)', weekMonth=2, yearMonth='2024-10', yearMonthDate=2024-10-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-10-14, endDate=2024-10-20, week=42, weekDesc='第42周(24.10.14~24.10.20)', weekMonth=3, yearMonth='2024-10', yearMonthDate=2024-10-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-10-21, endDate=2024-10-27, week=43, weekDesc='第43周(24.10.21~24.10.27)', weekMonth=4, yearMonth='2024-10', yearMonthDate=2024-10-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-10-28, endDate=2024-11-03, week=44, weekDesc='第44周(24.10.28~24.11.03)', weekMonth=1, yearMonth='2024-11', yearMonthDate=2024-11-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-11-04, endDate=2024-11-10, week=45, weekDesc='第45周(24.11.04~24.11.10)', weekMonth=2, yearMonth='2024-11', yearMonthDate=2024-11-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-11-11, endDate=2024-11-17, week=46, weekDesc='第46周(24.11.11~24.11.17)', weekMonth=3, yearMonth='2024-11', yearMonthDate=2024-11-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-11-18, endDate=2024-11-24, week=47, weekDesc='第47周(24.11.18~24.11.24)', weekMonth=4, yearMonth='2024-11', yearMonthDate=2024-11-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-11-25, endDate=2024-12-01, week=48, weekDesc='第48周(24.11.25~24.12.01)', weekMonth=1, yearMonth='2024-12', yearMonthDate=2024-12-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-12-02, endDate=2024-12-08, week=49, weekDesc='第49周(24.12.02~24.12.08)', weekMonth=2, yearMonth='2024-12', yearMonthDate=2024-12-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-12-09, endDate=2024-12-15, week=50, weekDesc='第50周(24.12.09~24.12.15)', weekMonth=3, yearMonth='2024-12', yearMonthDate=2024-12-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-12-16, endDate=2024-12-22, week=51, weekDesc='第51周(24.12.16~24.12.22)', weekMonth=4, yearMonth='2024-12', yearMonthDate=2024-12-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-12-23, endDate=2024-12-29, week=52, weekDesc='第52周(24.12.23~24.12.29)', weekMonth=5, yearMonth='2024-12', yearMonthDate=2024-12-01, kindId='G'}
5.最后:保存List<WeekEntity> weeks到数据库即可。