新年度工作日节假日数据处理
train项目中的initHolidays
在开发工具中运行下面的代码,调用接口生成年度节假日工作日数据并导入到sys_holidays表中
代码如下:
public static void main(String[] args) {
Integer year=2024;
Integer day=365;
if (DateUtil.isLeapYear(year)){
day=366;
}
Date date=DateUtil.parseDate(year+"-01-01");
File file =new File("D://节假日工作日.txt");
FileAppender appender = new FileAppender(file, 16, true);
for (int i = 0; i <= day; i++) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Date newDate = DateUtil.offset(date, DateField.DAY_OF_YEAR, i);
String dateString = DateUtil.format(newDate,"yyyyMMdd");
String dateString2 = DateUtil.format(newDate,"yyyy-MM-dd");
String url="http://tool.bitefu.net/jiari/?d="+dateString+"&info=1";
String result = HttpUtil.get(url);
JSONObject jsonObject= JSONObject.parseObject(result);
String ifclub = null;
String weekcn = jsonObject.getString("weekcn");
if (weekcn.equals("三")) {
ifclub = "1";
}else{
ifclub = "0";
}
String sql ="INSERT INTO `sys_holidays` VALUES " +
"('"+ IdUtil.simpleUUID() +"', '1', '"+DateUtil.formatDateTime(new Date())+"', '1', '"+DateUtil.formatDateTime(new Date())+"', '', '0'," +
" '"+ jsonObject.getString("status") +"', '" + jsonObject.getString("type") +"', '"+ dateString2 +"', '"+ jsonObject.getString("day") +"', '"+ jsonObject.getString("unixtime") +"', " +
"'"+ jsonObject.getString("yearname") +"', '"+ jsonObject.getString("nonglicn") +"', '"+ jsonObject.getString("nongli") +"', " +
"'"+ jsonObject.getString("shengxiao") +"', '"+ jsonObject.getString("jieqi") +"', '"+ jsonObject.getString("weekcn") +"', '"+ jsonObject.getString("week1") +"', '"+ jsonObject.getString("week2") +"', '"+ jsonObject.getString("week3") +"', '"+ jsonObject.getString("daynum") +"', '"+ jsonObject.getString("weeknum") +"', '"+ jsonObject.getString("avoid") +"', '"+ jsonObject.getString("suit") +"', '"+ ifclub +"');\n";
appender.append(sql);
appender.flush();
appender.toString();
}
System.out.println(new Date());
}


