|
@@ -1,5 +1,11 @@
|
|
|
package com.yunfeiyun.agmp.fms.service.impl;
|
|
package com.yunfeiyun.agmp.fms.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.annotation.Link;
|
|
|
|
|
+import com.xkzhangsan.time.LunarDate;
|
|
|
|
|
+import com.xkzhangsan.time.calendar.CalendarUtil;
|
|
|
|
|
+import com.xkzhangsan.time.calendar.CalendarWrapper;
|
|
|
|
|
+import com.xkzhangsan.time.calendar.DayWrapper;
|
|
|
|
|
+import com.xkzhangsan.time.utils.StringUtil;
|
|
|
import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.LunchCalenderUtil;
|
|
import com.yunfeiyun.agmp.common.utils.LunchCalenderUtil;
|
|
|
import com.yunfeiyun.agmp.fms.domain.FmsSolar;
|
|
import com.yunfeiyun.agmp.fms.domain.FmsSolar;
|
|
@@ -11,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -102,65 +109,17 @@ public class FmsSolarServiceImpl implements IFmsSolarService
|
|
|
public int updateFmsSolarAll() {
|
|
public int updateFmsSolarAll() {
|
|
|
try {
|
|
try {
|
|
|
List<FmsSolar> fmsSolarList = fmsSolarMapper.selectFmsSolarList(null);
|
|
List<FmsSolar> fmsSolarList = fmsSolarMapper.selectFmsSolarList(null);
|
|
|
- LunchCalenderUtil lunchCalenderUtil = new LunchCalenderUtil();
|
|
|
|
|
- Calendar rightNow = Calendar.getInstance();
|
|
|
|
|
- int year = rightNow.get(Calendar.YEAR);// 获取当前年份
|
|
|
|
|
- lunchCalenderUtil.setyear(year);
|
|
|
|
|
- int month = 1;// 获取当前月份
|
|
|
|
|
- LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
|
|
|
|
- while (month <= 12) {
|
|
|
|
|
- lunchCalenderUtil.setmonth(month);
|
|
|
|
|
- String[] day = lunchCalenderUtil.getCalendar();// 阳历日期
|
|
|
|
|
- String[] chineseDay = lunchCalenderUtil.getchineseCalendar_festival_solarterms();// 农历日期
|
|
|
|
|
- ArrayList<String> listYl = new ArrayList<>();
|
|
|
|
|
- ArrayList<String> listNl = new ArrayList<>();
|
|
|
|
|
- boolean bool = false;
|
|
|
|
|
- int n = 0;
|
|
|
|
|
- for (String s : day) {
|
|
|
|
|
- listYl.add(s);
|
|
|
|
|
- n++;
|
|
|
|
|
- if (n == 7) {
|
|
|
|
|
- int k = lunchCalenderUtil.getweekDay();
|
|
|
|
|
- for (int j = 0; j < k; j++) {
|
|
|
|
|
- listNl.add("");
|
|
|
|
|
- }
|
|
|
|
|
- listNl.addAll(Arrays.asList(chineseDay).subList(k, 7));
|
|
|
|
|
- }
|
|
|
|
|
- if (n % 7 == 0 && n != 7) {
|
|
|
|
|
- bool = true;
|
|
|
|
|
- }
|
|
|
|
|
- if (bool) {
|
|
|
|
|
- listNl.addAll(Arrays.asList(chineseDay).subList((n - 7), n));
|
|
|
|
|
- bool = false;
|
|
|
|
|
- }
|
|
|
|
|
- if (n == day.length && n % 7 != 0) {
|
|
|
|
|
- listNl.addAll(Arrays.asList(chineseDay).subList((n - n % 7), n));
|
|
|
|
|
|
|
+ CalendarWrapper calendarWrapper = CalendarUtil.generateCalendarWithLunar(2025);
|
|
|
|
|
+ List<DayWrapper> list = calendarWrapper.getDayList();
|
|
|
|
|
+ LinkedHashMap<String,FmsSolar> lunarMap = fmsSolarList.stream().collect(Collectors.toMap(FmsSolar::getSolarName,item->item,(a,b)->a,LinkedHashMap::new));
|
|
|
|
|
+ for(DayWrapper dayWrapper : list){
|
|
|
|
|
+ LunarDate lunarDate = dayWrapper.getLunarDate();
|
|
|
|
|
+ if(StringUtil.isNotEmpty(lunarDate.getSolarTerm())){
|
|
|
|
|
+ FmsSolar fmsSolar = lunarMap.get(lunarDate.getSolarTerm());
|
|
|
|
|
+ if(null != fmsSolar){
|
|
|
|
|
+ fmsSolar.setSolarStartdate(dayWrapper.getDateStr());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- for (int k = 0; k < listYl.size(); k++) {
|
|
|
|
|
- if (Arrays.asList(LunchCalenderUtil.SOLAR_TERM).contains(listNl.get(k))) {
|
|
|
|
|
- map.put(listNl.get(k), year + "-" + month +"-"+ listYl.get(k));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- month++;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //已农历立春开始,所以单独处理第二年年初的小寒大寒
|
|
|
|
|
- lunchCalenderUtil.setyear(year + 1);
|
|
|
|
|
- lunchCalenderUtil.setmonth(1);
|
|
|
|
|
- String[] day = lunchCalenderUtil.getCalendar();// 阳历日期
|
|
|
|
|
- String[] chineseDay = lunchCalenderUtil.getchineseCalendar_festival_solarterms();// 农历日期
|
|
|
|
|
- for (int i = 0; i < chineseDay.length; i++) {
|
|
|
|
|
- if (chineseDay[i].equals("小寒")) {
|
|
|
|
|
- map.put("小寒", (year+1) + "-" + 1 + "-" + day[i]);
|
|
|
|
|
- }
|
|
|
|
|
- if (chineseDay[i].equals("大寒")) {
|
|
|
|
|
- map.put("大寒", (year+1) + "-" + 1 + "-" + day[i]);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- for(FmsSolar fmsSolar : fmsSolarList){
|
|
|
|
|
- fmsSolar.setSolarStartdate(DateUtils.turnDateFormat(map.get(fmsSolar.getSolarName()),"yyyy-M-d","yyyy-MM-dd"));
|
|
|
|
|
}
|
|
}
|
|
|
return fmsSolarMapper.updateFmsSolarByBatch(fmsSolarList);
|
|
return fmsSolarMapper.updateFmsSolarByBatch(fmsSolarList);
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|