天干地支
This commit is contained in:
@@ -5,6 +5,8 @@ public class MyCalendar {
|
|||||||
private int year = 0;
|
private int year = 0;
|
||||||
private int month = 0;
|
private int month = 0;
|
||||||
|
|
||||||
|
private int day =0;
|
||||||
|
|
||||||
public void setyear(int year) {
|
public void setyear(int year) {
|
||||||
this.year = year;
|
this.year = year;
|
||||||
}
|
}
|
||||||
@@ -21,6 +23,14 @@ public class MyCalendar {
|
|||||||
return month;
|
return month;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDay() {
|
||||||
|
return day;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDay(int day) {
|
||||||
|
this.day = day;
|
||||||
|
}
|
||||||
|
|
||||||
private int chineseyear;// 农历年份
|
private int chineseyear;// 农历年份
|
||||||
private int chinesemonth;// 农历月份
|
private int chinesemonth;// 农历月份
|
||||||
private int chineseday;// 农历日
|
private int chineseday;// 农历日
|
||||||
@@ -58,6 +68,18 @@ public class MyCalendar {
|
|||||||
this.setyear(year);
|
this.setyear(year);
|
||||||
this.setmonth(month);
|
this.setmonth(month);
|
||||||
this.getfirstday(day);
|
this.getfirstday(day);
|
||||||
|
|
||||||
|
setTgchineseyear(checkLC()?year:year-1);
|
||||||
|
//设置月份
|
||||||
|
if(month==1){
|
||||||
|
setTgchinesemonth(checkMonthJQ()?12:11);
|
||||||
|
} else if (month==2) {
|
||||||
|
setTgchinesemonth(checkMonthJQ()?1:12);
|
||||||
|
}else {
|
||||||
|
setTgchinesemonth(checkMonthJQ()?month-1:month-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,Integer> getCT(){
|
public Map<String,Integer> getCT(){
|
||||||
@@ -65,9 +87,14 @@ public class MyCalendar {
|
|||||||
Integer c_month = Integer.valueOf(this.getChinesemonth());
|
Integer c_month = Integer.valueOf(this.getChinesemonth());
|
||||||
Integer c_day = (Integer.valueOf(this.getChineseday()))+1;
|
Integer c_day = (Integer.valueOf(this.getChineseday()))+1;
|
||||||
Map<String, Integer> stringIntegerMap = new HashMap<>();
|
Map<String, Integer> stringIntegerMap = new HashMap<>();
|
||||||
stringIntegerMap.put("year",c_year);
|
stringIntegerMap.put("c_year",c_year);
|
||||||
stringIntegerMap.put("month",c_month);
|
stringIntegerMap.put("c_month",c_month);
|
||||||
stringIntegerMap.put("day",c_day);
|
stringIntegerMap.put("c_day",c_day);
|
||||||
|
stringIntegerMap.put("tg_year",getTgchineseyear());
|
||||||
|
stringIntegerMap.put("tg_month",getTgchinesemonth());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return stringIntegerMap;
|
return stringIntegerMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +216,7 @@ public class MyCalendar {
|
|||||||
|
|
||||||
// 计算当年当月day日所对应的农历:chineseyear,chinesemonth,chineseday
|
// 计算当年当月day日所对应的农历:chineseyear,chinesemonth,chineseday
|
||||||
public void getfirstday(int day) {
|
public void getfirstday(int day) {
|
||||||
|
setDay(day);
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(year, month - 1, day);
|
cal.set(year, month - 1, day);
|
||||||
int leapMonth = 0;
|
int leapMonth = 0;
|
||||||
@@ -455,7 +483,42 @@ public class MyCalendar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int num1 = (int) ((Y * D + C1) - L);
|
int num1 = (int) ((Y * D + C1) - L);
|
||||||
if(month<num1){
|
|
||||||
|
if(day<num1){
|
||||||
|
return false;
|
||||||
|
}else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断当月节气是否通过
|
||||||
|
public boolean checkMonthJQ(){
|
||||||
|
double D = 0.2422;
|
||||||
|
// "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨",
|
||||||
|
// "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑",
|
||||||
|
// "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"
|
||||||
|
// 定义数组,存储的是20世纪和21世纪的节气C值
|
||||||
|
double[] SolarTerms_C_20thcentury = { 6.11, 20.84, 4.6295, 19.4599, 6.3826, 21.4155, 5.59, 20.888, 6.318, 21.86,
|
||||||
|
6.5, 22.2, 7.928, 23.65, 8.35, 23.95, 8.44, 23.822, 9.098, 24.218, 8.218, 23.08, 7.9, 22.6 };
|
||||||
|
double[] SolarTerms_C_21stcentury = { 5.4055, 20.12, 3.87, 18.73, 5.63, 20.646, 4.81, 20.1, 5.52, 21.04, 5.678,
|
||||||
|
21.37, 7.108, 22.83, 7.5, 23.13, 7.646, 23.042, 8.318, 23.438, 7.438, 22.36, 7.18, 21.94 };
|
||||||
|
double[] SolarTerms_C = null;
|
||||||
|
if (year >= 1901 && year <= 2000) {// 20世纪
|
||||||
|
SolarTerms_C = SolarTerms_C_20thcentury;
|
||||||
|
} else if (year >= 2001 && year <= 2100) {// 21世纪
|
||||||
|
SolarTerms_C = SolarTerms_C_21stcentury;
|
||||||
|
}
|
||||||
|
double C1 = SolarTerms_C[(month) * 2 - 1 - 1];
|
||||||
|
int Y = year % 100;
|
||||||
|
int L = (Y) / 4;
|
||||||
|
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
|
||||||
|
// 注意:凡闰年3月1日前闰年数要减一,即:L=[(Y-1)/4],因为小寒、大寒、立春、雨水这两个节气都小于3月1日
|
||||||
|
if (C1 == 5.4055 || C1 == 3.87) {
|
||||||
|
L = (Y - 1) / 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int num1 = (int) ((Y * D + C1) - L);
|
||||||
|
if(day<num1){
|
||||||
return false;
|
return false;
|
||||||
}else {
|
}else {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -5,4 +5,8 @@ public class TGDZ {
|
|||||||
public static final String[] tg = {"甲","乙","丙","丁","戊","己","庚","辛","壬","癸"};
|
public static final String[] tg = {"甲","乙","丙","丁","戊","己","庚","辛","壬","癸"};
|
||||||
|
|
||||||
public static final String[] dz = {"寅","卯","辰","巳","午","未","申","酉","戌","亥","子","丑"};
|
public static final String[] dz = {"寅","卯","辰","巳","午","未","申","酉","戌","亥","子","丑"};
|
||||||
|
|
||||||
|
public static final String[] dzz = {"子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"};
|
||||||
|
|
||||||
|
public static final String[] dzr = {"甲子","乙丑","丙寅","丁卯","戊辰","己巳","庚午","辛未","壬申","癸酉","甲戌","乙亥","丙子","丁丑","戊寅","己卯","庚辰","辛巳","壬午","癸未","甲申","乙酉","丙戌","丁亥","戊子","己丑","庚寅","辛卯","壬辰","癸巳","甲午","乙未","丙申","丁酉","戊戌","己亥","庚子","辛丑","壬寅","癸卯","甲辰","乙巳","丙午","丁未","戊申","己酉","庚戌","辛亥","壬子","癸丑","甲寅","乙卯","丙辰","丁巳","戊午","己未","庚申","辛酉","壬戌","癸亥"};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public class PointController {
|
|||||||
Date parse = simpleDateFormat.parse(date);
|
Date parse = simpleDateFormat.parse(date);
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> stringStringMap = pointService.TGDZForYear(parse);
|
Map<String, String> stringStringMap = pointService.TGDZForDate(parse);
|
||||||
return R.ok().put("tgdz",stringStringMap);
|
return R.ok().put("tgdz",stringStringMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,5 +17,5 @@ public interface PointService extends IService<PointEntity> {
|
|||||||
|
|
||||||
List<PointEntity> searchPoint(String keywords);
|
List<PointEntity> searchPoint(String keywords);
|
||||||
|
|
||||||
Map<String,String> TGDZForYear(Date year);
|
Map<String,String> TGDZForDate(Date date);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,56 +66,75 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String,String> TGDZForYear(Date date) {
|
public Map<String,String> TGDZForDate(Date date) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
Integer year = calendar.get(Calendar.YEAR);
|
||||||
|
int kkk = calendar.get(Calendar.MONTH);
|
||||||
|
Integer month = kkk + 1;
|
||||||
|
Integer day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
|
Integer hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||||
|
|
||||||
|
System.out.println(hour);
|
||||||
MyCalendar myCalendar = new MyCalendar();
|
MyCalendar myCalendar = new MyCalendar();
|
||||||
myCalendar.setDate(date);
|
myCalendar.setDate(date);
|
||||||
Map<String, Integer> ct = myCalendar.getCT();
|
Map<String, Integer> ct = myCalendar.getCT();
|
||||||
System.out.println(ct);
|
System.out.println(ct);
|
||||||
System.out.println(Arrays.toString(myCalendar.getchineseCalendar_festival_solarterms()));
|
Integer tg_year = ct.get("tg_year");
|
||||||
Integer year = ct.get("year");
|
Integer tg_month = ct.get("tg_month");
|
||||||
Integer month = ct.get("month");
|
// Integer day = ct.get("c_day");
|
||||||
Integer day = ct.get("day");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String[] tg = TGDZ.tg;
|
String[] tg = TGDZ.tg;
|
||||||
String[] dz = TGDZ.dz;
|
String[] dz = TGDZ.dz;
|
||||||
|
String[] dzz = TGDZ.dzz;
|
||||||
|
|
||||||
//年份天干地支
|
//年份天干地支
|
||||||
String c_year = myCalendar.getChinaYearString();
|
Integer ty_c = tg_year%10;
|
||||||
|
Integer ty = ty_c<=3?ty_c+10-3:ty_c-3;
|
||||||
|
String c_year_t = tg[ty-1];
|
||||||
|
Integer d = (tg_year+7)%12;
|
||||||
|
if(d==0){
|
||||||
|
d=12;
|
||||||
|
}
|
||||||
|
String c_year_d = dz[d - 1];
|
||||||
|
String c_year = c_year_t+c_year_d;
|
||||||
|
|
||||||
//月份天干地支
|
//月份天干地支
|
||||||
Integer ty_c = year%10;
|
Integer tm = ((ty*2 +tg_month)%10)==0?10:((ty*2 +tg_month)%10);
|
||||||
Integer ty = ty_c<=3?ty_c+10-3:ty_c-3;
|
String c_month = tg[tm-1]+dz[tg_month-1];
|
||||||
Integer tm = ((ty*2 +month)%10)==0?10:((ty*2 +month)%10);
|
|
||||||
String c_month = tg[tm-1]+dz[month-1];
|
|
||||||
|
|
||||||
HashMap<String, String> flagMap = new HashMap<>();
|
HashMap<String, String> flagMap = new HashMap<>();
|
||||||
flagMap.put("year",c_year);
|
flagMap.put("year",c_year);
|
||||||
flagMap.put("month",c_month);
|
flagMap.put("month",c_month);
|
||||||
|
|
||||||
|
//获取日干支
|
||||||
|
String dayGZ = getDayGZ(year, month, day);
|
||||||
|
flagMap.put("day",dayGZ);
|
||||||
|
|
||||||
|
//获取时干支,时天干=日天干×2+时地支-2(因为天干有十个,所以计算出来的数字如果大于10,就要减去10)
|
||||||
|
String substring = dayGZ.substring(0, 1);
|
||||||
|
List<String> list = Arrays.asList(tg);
|
||||||
|
int i = list.indexOf(substring);
|
||||||
|
int s_d;
|
||||||
|
if(hour==23){
|
||||||
|
s_d = 1;
|
||||||
|
}else{
|
||||||
|
if(hour%2==0){
|
||||||
|
s_d = (hour+2)/2;
|
||||||
|
}else {
|
||||||
|
s_d = (hour+3)/2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int dd = ((i+1)*2+s_d-2)%10;
|
||||||
|
int dcc;
|
||||||
|
if(dd==0){
|
||||||
|
dcc=9;
|
||||||
|
}else{
|
||||||
|
dcc = dd-1;
|
||||||
|
}
|
||||||
|
flagMap.put("hour",tg[dcc]+dzz[s_d-1]);
|
||||||
return flagMap;
|
return flagMap;
|
||||||
|
|
||||||
// Integer y = year % 10;
|
|
||||||
// if(y<=3){
|
|
||||||
// y += 10;
|
|
||||||
// }
|
|
||||||
// String s = tg[y-3-1];
|
|
||||||
// Integer d = (year+7)%12;
|
|
||||||
// if(d==0){
|
|
||||||
// d=12;
|
|
||||||
// }
|
|
||||||
// String s1 = dz[d - 1];
|
|
||||||
// //月干
|
|
||||||
// String y_s = tg[(((y - 3) * 2 + month)%10) - 1];
|
|
||||||
// String y_d = dz[month-1];
|
|
||||||
//
|
|
||||||
// return s+s1+"年 "+y_s+y_d+"月 ";
|
|
||||||
|
|
||||||
|
|
||||||
// return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createIds(Integer id, List<Integer> list){
|
private void createIds(Integer id, List<Integer> list){
|
||||||
@@ -128,4 +147,25 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
|
|||||||
}
|
}
|
||||||
list.add(id);
|
list.add(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDayGZ(int year,int month,int day){
|
||||||
|
if(year==2024&&month==1&&day==1){
|
||||||
|
return "甲子";
|
||||||
|
}
|
||||||
|
String[] dzr = TGDZ.dzr;
|
||||||
|
Calendar basedate = Calendar.getInstance();
|
||||||
|
basedate.set(2024, 1 - 1, 1);
|
||||||
|
Calendar now = Calendar.getInstance();
|
||||||
|
now.set(year,month-1,day);
|
||||||
|
if(year<2024){
|
||||||
|
int offset = (int) ((basedate.getTimeInMillis() - now.getTimeInMillis()) / (1000 * 60 * 60 * 24));
|
||||||
|
int c = offset%60;
|
||||||
|
int cc = c==0?0:60-c;
|
||||||
|
return dzr[cc];
|
||||||
|
}else{
|
||||||
|
int offset = (int) ((now.getTimeInMillis() - basedate.getTimeInMillis()) / (1000 * 60 * 60 * 24));
|
||||||
|
int c = offset%60;
|
||||||
|
return dzr[c];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,18 +9,18 @@ wxpay.notifyUrl:https://testapi.nuttyreading.com/pay/payNotify
|
|||||||
# ?? url
|
# ?? url
|
||||||
wxpay.refundNotifyUrl:http://pjm6m9.natappfree.cc/pay/refundNotify
|
wxpay.refundNotifyUrl:http://pjm6m9.natappfree.cc/pay/refundNotify
|
||||||
# key pem
|
# key pem
|
||||||
wxpay.keyPemPath:/usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem
|
#wxpay.keyPemPath:/usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem
|
||||||
#wxpay.keyPemPath:C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/apiclient_key.pem
|
#wxpay.keyPemPath:C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/apiclient_key.pem
|
||||||
#wxpay.keyPemPath:D:/hs/nuttyreading-java/src/main/resources/cent/apiclient_key.pem
|
wxpay.keyPemPath:D:/hs/nuttyreading-java/src/main/resources/cent/apiclient_key.pem
|
||||||
# ???
|
# ???
|
||||||
wxpay.serialNo:679AECB2F7AC4183033F713828892BA640E4EEE3
|
wxpay.serialNo:679AECB2F7AC4183033F713828892BA640E4EEE3
|
||||||
# API v3 key
|
# API v3 key
|
||||||
wxpay.apiV3Key:4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF
|
wxpay.apiV3Key:4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF
|
||||||
# ????
|
# ????
|
||||||
wxpay.wechatPayCertificateUrl:/usr/local/hs/peanut_book/target/classes/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
#wxpay.wechatPayCertificateUrl:/usr/local/hs/peanut_book/target/classes/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
||||||
#wxpay.wechatPayCertificateUrl:C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
#wxpay.wechatPayCertificateUrl:C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
||||||
# wxpay.wechatPayCertificateUrl:D:/hs/nuttyreading-java/src/main/resources/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
wxpay.wechatPayCertificateUrl:D:/hs/nuttyreading-java/src/main/resources/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
||||||
# ?? url
|
# ?? url
|
||||||
wxpay.privateKeyUrl:/usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem
|
#wxpay.privateKeyUrl:/usr/local/hs/peanut_book/target/classes/cent/apiclient_key.pem
|
||||||
#wxpay.privateKeyUrl:C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/apiclient_key.pem
|
#wxpay.privateKeyUrl:C:/Users/Cauchy/IdeaProjects/nuttyreading-java/src/main/resources/cent/apiclient_key.pem
|
||||||
#wxpay.privateKeyUrl:D:/hs/nuttyreading-java/src/main/resources/cent/apiclient_key.pem
|
wxpay.privateKeyUrl:D:/hs/nuttyreading-java/src/main/resources/cent/apiclient_key.pem
|
||||||
Reference in New Issue
Block a user