bug
This commit is contained in:
@@ -17,5 +17,5 @@ public interface PointService extends IService<PointEntity> {
|
||||
|
||||
List<PointEntity> searchPoint(String keywords);
|
||||
|
||||
Map<String,String> TGDZForDate(Date date);
|
||||
Map<String,Object> TGDZForDate(Date date);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.peanut.modules.book.service.PointService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Service("pointService")
|
||||
@@ -66,7 +67,7 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,String> TGDZForDate(Date date) {
|
||||
public Map<String,Object> TGDZForDate(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
Integer year = calendar.get(Calendar.YEAR);
|
||||
@@ -74,17 +75,11 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
|
||||
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.setDate(date);
|
||||
Map<String, Integer> ct = myCalendar.getCT();
|
||||
System.out.println(ct);
|
||||
Integer tg_year = ct.get("tg_year");
|
||||
Integer tg_month = ct.get("tg_month");
|
||||
// Integer day = ct.get("c_day");
|
||||
|
||||
|
||||
String[] tg = TGDZ.tg;
|
||||
String[] dz = TGDZ.dz;
|
||||
String[] dzz = TGDZ.dzz;
|
||||
@@ -103,8 +98,7 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
|
||||
//月份天干地支
|
||||
Integer tm = ((ty*2 +tg_month)%10)==0?10:((ty*2 +tg_month)%10);
|
||||
String c_month = tg[tm-1]+dz[tg_month-1];
|
||||
|
||||
HashMap<String, String> flagMap = new HashMap<>();
|
||||
HashMap<String, Object> flagMap = new HashMap<>();
|
||||
flagMap.put("year",c_year);
|
||||
flagMap.put("month",c_month);
|
||||
|
||||
@@ -134,9 +128,173 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
|
||||
dcc = dd-1;
|
||||
}
|
||||
flagMap.put("hour",tg[dcc]+dzz[s_d-1]);
|
||||
|
||||
//获取五运相关
|
||||
boolean check_dh;
|
||||
if(month==1&&getSolarTerm(year, 1, 2)>day){
|
||||
check_dh = false;
|
||||
}else {
|
||||
check_dh = true;
|
||||
}
|
||||
|
||||
Map<String, Object> yearWY = getYearWY(check_dh?year:year-1);
|
||||
flagMap.put("wy",yearWY);
|
||||
|
||||
//获取六气相关
|
||||
Map<String, Object> yearLQ = getYearLQ(check_dh?year:year-1);
|
||||
flagMap.put("lq",yearLQ);
|
||||
|
||||
|
||||
return flagMap;
|
||||
}
|
||||
|
||||
|
||||
private Map<String,Object> getYearLQ(Integer year){
|
||||
String[] dz = TGDZ.dz;
|
||||
Integer d = (year+7)%12;
|
||||
if(d==0){
|
||||
d=12;
|
||||
}
|
||||
String c_year_d = dz[d - 1];
|
||||
|
||||
HashMap<String, Object> flag = new HashMap<>();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String dh = year.toString() + "-01-" + getSolarTerm(year, 1, 2);//大寒日期
|
||||
Integer n_year = year+1;
|
||||
String ndh = n_year.toString() + "-01-" + getSolarTerm(n_year, 1, 2);//大寒日期
|
||||
Calendar chunFen = Calendar.getInstance();
|
||||
chunFen.set(year,2,getSolarTerm(year,3,2));
|
||||
String erqi = simpleDateFormat.format(chunFen.getTime());
|
||||
Calendar xiaoMan = Calendar.getInstance();
|
||||
xiaoMan.set(year,4,getSolarTerm(year,5,2));
|
||||
String sanqi = simpleDateFormat.format(xiaoMan.getTime());
|
||||
Calendar daShu = Calendar.getInstance();
|
||||
daShu.set(year,6,getSolarTerm(year,7,2));
|
||||
String siqi = simpleDateFormat.format(daShu.getTime());
|
||||
Calendar qiufen = Calendar.getInstance();
|
||||
qiufen.set(year,8,getSolarTerm(year,9,2));
|
||||
String wuqi = simpleDateFormat.format(qiufen.getTime());
|
||||
Calendar xiaoxue = Calendar.getInstance();
|
||||
xiaoxue.set(year,10,getSolarTerm(year,11,2));
|
||||
String liuqi = simpleDateFormat.format(xiaoxue.getTime());
|
||||
List<String> time = new ArrayList<>();
|
||||
time.add(dh);time.add(erqi);time.add(sanqi);time.add(siqi);time.add(wuqi);time.add(liuqi);time.add(ndh);
|
||||
flag.put("time",time);
|
||||
String[] zhuqi = {"厥阴","少阴","少阳","太阴","阳明","太阳"};
|
||||
flag.put("zhuqi",zhuqi);
|
||||
String[] lq = TGDZ.lq;
|
||||
String sitian;
|
||||
if(c_year_d=="子"||c_year_d=="午"){
|
||||
sitian = "少阴";
|
||||
} else if (c_year_d=="丑"||c_year_d=="未") {
|
||||
sitian = "太阴";
|
||||
} else if (c_year_d=="寅"||c_year_d=="申") {
|
||||
sitian = "少阳";
|
||||
} else if (c_year_d=="卯"||c_year_d=="酉") {
|
||||
sitian = "阳明";
|
||||
} else if (c_year_d=="辰"||c_year_d=="戌") {
|
||||
sitian = "太阳";
|
||||
}else {
|
||||
sitian = "厥阴";
|
||||
}
|
||||
List<String> lq_list = Arrays.asList(lq);
|
||||
int i = lq_list.indexOf(sitian);
|
||||
List<String> keqi = new ArrayList<>();
|
||||
keqi.add(myAddLQ(i-2));keqi.add(myAddLQ(i-1));keqi.add(myAddLQ(i));keqi.add(myAddLQ(i+1));keqi.add(myAddLQ(i+2));keqi.add(myAddLQ(i+3));
|
||||
flag.put("keqi",keqi);
|
||||
|
||||
return flag;
|
||||
|
||||
}
|
||||
|
||||
private String myAddLQ(int i){
|
||||
String[] lq = TGDZ.lq;
|
||||
if(i<0){
|
||||
return lq[i+6];
|
||||
} else if (i>5) {
|
||||
return lq[i-6];
|
||||
}else {
|
||||
return lq[i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一年的全部五运分布
|
||||
* @param year 年2013
|
||||
* @return
|
||||
*/
|
||||
private Map<String,Object> getYearWY(Integer year){
|
||||
String[] tg = TGDZ.tg;
|
||||
Integer ty_c = year%10;
|
||||
Integer ty = ty_c<=3?ty_c+10-3:ty_c-3;
|
||||
String c_year_t = tg[ty-1];
|
||||
|
||||
HashMap<String, Object> flag = new HashMap<>();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String dh = year.toString() + "-01-" + getSolarTerm(year, 1, 2);//大寒日期
|
||||
Integer next_year = year+1;
|
||||
String dh_n = next_year.toString()+ "-01-" + getSolarTerm(next_year, 1, 2);//次年大寒日期
|
||||
Calendar chunFen = Calendar.getInstance();
|
||||
chunFen.set(year,2,getSolarTerm(year, 3, 2));
|
||||
chunFen.add(Calendar.DAY_OF_MONTH,15);
|
||||
String erYun = simpleDateFormat.format(chunFen.getTime());
|
||||
Calendar mangZhong = Calendar.getInstance();
|
||||
mangZhong.set(year,5,getSolarTerm(year,6,1));
|
||||
mangZhong.add(Calendar.DAY_OF_MONTH,10);
|
||||
String sanYun = simpleDateFormat.format(mangZhong.getTime());
|
||||
Calendar chuShu = Calendar.getInstance();
|
||||
chuShu.set(year,7,getSolarTerm(year,8,2));
|
||||
chuShu.add(Calendar.DAY_OF_MONTH,7);
|
||||
String siYun = simpleDateFormat.format(chuShu.getTime());
|
||||
Calendar liDong = Calendar.getInstance();
|
||||
liDong.set(year,10,getSolarTerm(year,11,1));
|
||||
liDong.add(Calendar.DAY_OF_MONTH,4);
|
||||
String zhongYun = simpleDateFormat.format(liDong.getTime());
|
||||
ArrayList<String> time = new ArrayList<>();
|
||||
time.add(dh);
|
||||
time.add(erYun);
|
||||
time.add(sanYun);
|
||||
time.add(siYun);
|
||||
time.add(zhongYun);
|
||||
time.add(dh_n);
|
||||
flag.put("time",time);
|
||||
String nianYun;
|
||||
if(c_year_t=="甲"||c_year_t=="己"){
|
||||
nianYun = "土";
|
||||
} else if (c_year_t=="乙"||c_year_t=="庚") {
|
||||
nianYun = "金";
|
||||
} else if (c_year_t=="丙"||c_year_t=="辛") {
|
||||
nianYun = "水";
|
||||
} else if (c_year_t=="丁"||c_year_t=="壬") {
|
||||
nianYun = "木";
|
||||
}else {
|
||||
nianYun = "火";
|
||||
}
|
||||
String[] wx = TGDZ.wx;
|
||||
flag.put("nianYun",nianYun);
|
||||
flag.put("zhuYun",wx);
|
||||
List<String> list = Arrays.asList(wx);
|
||||
int i = list.indexOf(nianYun);
|
||||
ArrayList<String> kwx = new ArrayList<>();
|
||||
for (int jk =0;jk<5;jk++){
|
||||
kwx.add(mygetWx(i));
|
||||
i++;
|
||||
}
|
||||
flag.put("keYun",kwx);
|
||||
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
private String mygetWx(int i){
|
||||
String[] wx = TGDZ.wx;
|
||||
if(i>=5){
|
||||
return wx[i-5];
|
||||
}else{
|
||||
return wx[i];
|
||||
}
|
||||
}
|
||||
|
||||
private void createIds(Integer id, List<Integer> list){
|
||||
LambdaQueryWrapper<PointCategoryEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PointCategoryEntity::getPid,id);
|
||||
@@ -168,4 +326,33 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
|
||||
return dzr[c];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 饭后某年某月的第几个节日的日
|
||||
* @param year
|
||||
* @param month
|
||||
* @param num 1/2
|
||||
* @return
|
||||
*/
|
||||
private int getSolarTerm(Integer year,Integer month,Integer num){
|
||||
double D = TGDZ.D;
|
||||
double[] s20 = TGDZ.S20;
|
||||
double[] s21 = TGDZ.S21;
|
||||
double[] sc = null;
|
||||
if (year >= 1901 && year <= 2000) {// 20世纪
|
||||
sc =s20;
|
||||
} else if (year >= 2001 && year <= 2100) {// 21世纪
|
||||
sc =s21;
|
||||
}
|
||||
double C=num==1?sc[(month) * 2 - 1 - 1]:sc[month * 2 - 1];
|
||||
int Y = year % 100;
|
||||
int L = (Y) / 4;
|
||||
if (num==1&&year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
|
||||
// 注意:凡闰年3月1日前闰年数要减一,即:L=[(Y-1)/4],因为小寒、大寒、立春、雨水这两个节气都小于3月1日
|
||||
if (C == 5.4055 || C == 3.87) {
|
||||
L = (Y - 1) / 4;
|
||||
}
|
||||
}
|
||||
return (int) ((Y * D + C) - L);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user