This commit is contained in:
wangjinlei
2023-11-10 09:05:25 +08:00
parent ccb3b0c1eb
commit ed9dc63245
5 changed files with 527 additions and 3 deletions

View File

@@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -168,4 +171,17 @@ public class PointController {
return R.ok().put("points",pointEntities);
}
@RequestMapping("/TGDZForYear")
public R TGDZForYear(@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);
String[] strings = pointService.TGDZForYear(parse);
return R.ok().put("tgdz",strings);
}
}

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.PointEntity;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -15,4 +16,6 @@ public interface PointService extends IService<PointEntity> {
List<PointEntity> getPoints(Integer pointCategoryId);
List<PointEntity> searchPoint(String keywords);
String[] TGDZForYear(Date year);
}

View File

@@ -1,11 +1,14 @@
package com.peanut.modules.book.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.MyCalendar;
import com.peanut.config.TGDZ;
import com.peanut.modules.book.dao.PointCategoryDao;
import com.peanut.modules.book.dao.PointDao;
import com.peanut.modules.book.entity.PointCategoryEntity;
@@ -14,9 +17,7 @@ import com.peanut.modules.book.service.PointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service("pointService")
public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> implements PointService {
@@ -64,6 +65,121 @@ public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> impleme
return list;
}
@Override
public String[] TGDZForYear(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);
MyCalendar mc = new MyCalendar();
mc.setyear(year);
mc.setmonth(month);
mc.getfirstday(day);
System.out.println(mc.getChinaYearString());
System.out.println(mc.getChinaMonthString());
System.out.println(mc.getCalendar().toString());
// String[] day = mc.getCalendar();// 阳历日期
// String[] chineseday = mc.getchineseCalendar_festival_solarterms();// 农历日期
// 以下为输出
// System.out.println(mc.getyear() + "年" + mc.getmonth() + "月");
// System.out.println();
// String[] week = {"日", "一", "二", "三", "四", "五", "六"};
// for (String str : week) {
// System.out.printf("%-7s", " " + str);
// }
// System.out.println();
// ArrayList<String> listYl = new ArrayList<>();
// ArrayList<String> listNl = new ArrayList<>();
// boolean bool = false;
// int n = 0;
// for (int i = 0; i < day.length; i++) {
// System.out.printf("%-5s", " " + day[i]);
// listYl.add(day[i]);
// n++;
// if (n == 7) {
// System.out.println();
// int k = mc.getweekDay();
// for (int j = 0; j < k; j++) {
// System.out.printf("%9s", "");
// listNl.add("");
// }
// for (int j = k; j < 7; j++) {
// System.out.printf("%4s", chineseday[j]);
// listNl.add(chineseday[j]);
// }
// System.out.println();
// }
//
//
// if (n % 7 == 0 && n != 7) {
// System.out.println();
// bool = true;
// }
// if (bool == true) {
// for (int j = (n - 7); j < n; j++) {
// System.out.printf("%4s", chineseday[j]);
// listNl.add(chineseday[j]);
// }
// if (n != day.length) {
// System.out.println();
// }
// bool = false;
// }
// if (n == day.length && n % 7 != 0) {
// System.out.println();
// for (int j = (n - n % 7); j < n; j++) {
// System.out.printf("%4s", chineseday[j]);
// listNl.add(chineseday[j]);
// }
// }
// }
// System.out.println();
// System.out.println(listYl);
// System.out.println(listNl);
// ArrayList<Object> list = new ArrayList<>();
// for (int k = 0; k < listYl.size(); k++) {
// JSONObject jsonObject = new JSONObject();
// if (listYl.get(k) == "") {
// jsonObject.put("yl", "");
// jsonObject.put("nl", "");
// } else {
// jsonObject.put("yl", listYl.get(k));
// jsonObject.put("nl", listNl.get(k));
// }
// list.add(jsonObject);
// }
// System.out.println(list);
String[] strings = mc.getchineseCalendar_festival_solarterms();
return strings;
// Integer day = calendar.get(Calendar.DAY_OF_MONTH);
// String[] tg = TGDZ.tg;
// String[] dz = TGDZ.dz;
// 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+"月 ";
}
private void createIds(Integer id, List<Integer> list){
LambdaQueryWrapper<PointCategoryEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PointCategoryEntity::getPid,id);