This commit is contained in:
wangjinlei
2023-11-20 14:14:51 +08:00
parent db58953a9f
commit d9d6ee68da
6 changed files with 97 additions and 35 deletions

View File

@@ -173,8 +173,6 @@ public class MyUserController {
}else{
areacode = Integer.valueOf(areaCode);
}
System.out.println(areacode);
//验证一分钟内是否已经发过
String redisCode = redisTemplate.opsForValue().get("RegistCode" + phone);
if (!StringUtils.isEmpty(redisCode)) {

View File

@@ -184,4 +184,16 @@ public class PointController {
return R.ok().put("tgdz",stringStringMap);
}
@RequestMapping("/WYLQForYear")
public R WYLQForYear(@RequestBody Map<String,Object> map) throws ParseException {
String date = map.get("date").toString();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
simpleDateFormat.applyPattern("yyyy-MM-dd hh:mm:ss");
Date parse = simpleDateFormat.parse(date);
Map<String, Object> stringStringMap = pointService.WYLQForDate(parse);
return R.ok().put("wylq",stringStringMap);
}
}

View File

@@ -18,4 +18,6 @@ public interface PointService extends IService<PointEntity> {
List<PointEntity> searchPoint(String keywords);
Map<String,Object> TGDZForDate(Date date);
Map<String,Object> WYLQForDate(Date date);
}

View File

@@ -20,6 +20,8 @@ import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
import static com.peanut.config.TGDZ.*;
@Service("pointService")
public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> implements PointService {
@@ -80,9 +82,6 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
Map<String, Integer> ct = myCalendar.getCT();
Integer tg_year = ct.get("tg_year");
Integer tg_month = ct.get("tg_month");
String[] tg = TGDZ.tg;
String[] dz = TGDZ.dz;
String[] dzz = TGDZ.dzz;
//年份天干地支
Integer ty_c = tg_year%10;
@@ -129,28 +128,45 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
}
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;
}
return flagMap;
}
Map<String, Object> yearWY = getYearWY(check_dh?year:year-1);
@Override
public Map<String, Object> WYLQForDate(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);
HashMap<String, Object> flagMap = new HashMap<>();
if(month==1&&getSolarTerm(year, 1, 2)>day){
year--;
}
Map<String, Object> yearWY = getYearWY(year,month,day);
flagMap.put("wy",yearWY);
//获取六气相关
Map<String, Object> yearLQ = getYearLQ(check_dh?year:year-1);
Map<String, Object> yearLQ = getYearLQ(year,month,day);
flagMap.put("lq",yearLQ);
//杂项
Integer ty_c = year%10;
Integer ty = ty_c<=3?ty_c+10-3:ty_c-3;
String c_year_t = tg[ty-1];
Integer d = (year+7)%12;
if(d==0){
d=12;
}
String c_year_d = dz[d - 1];
return flagMap;
}
private Map<String,Object> getYearLQ(Integer year){
String[] dz = TGDZ.dz;
private Map<String,Object> getYearLQ(Integer year,Integer month,Integer day){
Integer d = (year+7)%12;
if(d==0){
d=12;
@@ -182,7 +198,6 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
flag.put("time",time);
String[] zhuqi = {"厥阴","少阴","少阳","太阴","阳明","太阳"};
flag.put("zhuqi",zhuqi);
String[] lq = TGDZ.lq;
String sitian;
if(c_year_d==""||c_year_d==""){
sitian = "少阴";
@@ -203,12 +218,31 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
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);
//判断第几个是当前项目
int now_key;
Calendar now = Calendar.getInstance();
now.set(year,month-1,day);
long timeInMillis = now.getTimeInMillis();
if(timeInMillis<chunFen.getTimeInMillis()){
now_key = 0;
} else if (timeInMillis<xiaoMan.getTimeInMillis()) {
now_key = 1;
} else if (timeInMillis<daShu.getTimeInMillis()) {
now_key = 2;
} else if (timeInMillis<qiufen.getTimeInMillis()) {
now_key = 3;
} else if (timeInMillis<xiaoxue.getTimeInMillis()){
now_key = 4;
} else {
now_key = 5;
}
flag.put("now",now_key);
return flag;
}
private String myAddLQ(int i){
String[] lq = TGDZ.lq;
if(i<0){
return lq[i+6];
} else if (i>5) {
@@ -223,8 +257,7 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
* @param year 年2013
* @return
*/
private Map<String,Object> getYearWY(Integer year){
String[] tg = TGDZ.tg;
private Map<String,Object> getYearWY(Integer year,Integer month,Integer day){
Integer ty_c = year%10;
Integer ty = ty_c<=3?ty_c+10-3:ty_c-3;
String c_year_t = tg[ty-1];
@@ -270,7 +303,24 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
}else {
nianYun = "";
}
String[] wx = TGDZ.wx;
//判断第几个是当前项目
int now_key;
Calendar now = Calendar.getInstance();
now.set(year,month-1,day);
long timeInMillis = now.getTimeInMillis();
if(timeInMillis<chunFen.getTimeInMillis()){
now_key = 0;
} else if (timeInMillis<mangZhong.getTimeInMillis()) {
now_key = 1;
} else if (timeInMillis<chuShu.getTimeInMillis()) {
now_key = 2;
} else if (timeInMillis<liDong.getTimeInMillis()) {
now_key = 3;
} else {
now_key = 4;
}
flag.put("now",now_key);
flag.put("nianYun",nianYun);
flag.put("zhuYun",wx);
List<String> list = Arrays.asList(wx);
@@ -287,7 +337,6 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
}
private String mygetWx(int i){
String[] wx = TGDZ.wx;
if(i>=5){
return wx[i-5];
}else{
@@ -310,7 +359,6 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
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();
@@ -335,14 +383,11 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
* @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;
sc =S20;
} else if (year >= 2001 && year <= 2100) {// 21世纪
sc =s21;
sc =S21;
}
double C=num==1?sc[(month) * 2 - 1 - 1]:sc[month * 2 - 1];
int Y = year % 100;