|
@@ -1,479 +1,479 @@
|
|
|
-package com.pavis.ai.app.fda;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.pavis.ai.app.fda.common.utils.DateUtils;
|
|
|
-import com.pavis.ai.app.fda.form.TestCommon;
|
|
|
-import com.pavis.ai.app.fda.form.inc.IncInfo;
|
|
|
-import com.pavis.ai.app.fda.mapper.IndustryInfoMapper;
|
|
|
-import com.pavis.ai.app.fda.mapper.IndustryPlateMapper;
|
|
|
-import com.pavis.ai.app.fda.mapper.IndustryPlateResMapper;
|
|
|
-import com.pavis.ai.app.fda.model.IndustryInfo;
|
|
|
-import com.pavis.ai.app.fda.model.IndustryPlate;
|
|
|
-import com.pavis.ai.app.fda.model.IndustryPlateRes;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.junit.Test;
|
|
|
-import org.junit.runner.RunWith;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-import org.springframework.test.context.junit4.SpringRunner;
|
|
|
-
|
|
|
-import java.time.DayOfWeek;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
-import java.time.temporal.ChronoUnit;
|
|
|
-import java.time.temporal.TemporalAdjusters;
|
|
|
-import java.time.temporal.WeekFields;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author guanhuijuan
|
|
|
- * @create 2020-07-18 12:17
|
|
|
- * @desc
|
|
|
- **/
|
|
|
-@RunWith(SpringRunner.class)
|
|
|
-@SpringBootTest
|
|
|
-@Slf4j
|
|
|
-public class LocalDateTest {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IndustryPlateMapper industryPlateMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IndustryInfoMapper industryInfoMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IndustryPlateResMapper industryPlateResMapper;
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testMonth(){
|
|
|
- String date = "2020-06-31";
|
|
|
- System.out.println(DateUtils.getMonthByNearly("2020-06-30"));
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testMon(){
|
|
|
- String date = "2020-06-30";
|
|
|
- Map<String,Object> map = DateUtils.getMonthByNearly(date);
|
|
|
- String month = map.get("month").toString();
|
|
|
- String nearlyMonth = map.get("nearlyMonth").toString();
|
|
|
- System.err.println(month+"<>"+nearlyMonth);
|
|
|
- Boolean tag = DateUtils.checkDate(month, nearlyMonth);
|
|
|
- if (tag.equals(true)){
|
|
|
- System.err.println(nearlyMonth+"<>"+month);
|
|
|
- }else {
|
|
|
- System.err.println(month+"<>"+nearlyMonth);
|
|
|
- }
|
|
|
- System.err.println(tag);
|
|
|
- String testDate = "2020-05-31";
|
|
|
- String week = DateUtils.getWeekNameByDate(testDate);
|
|
|
- if (!week.equals("6") &&
|
|
|
- !week.equals("7")){
|
|
|
- System.err.println("add");
|
|
|
- }else {
|
|
|
- System.err.println("del");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testY(){
|
|
|
- List<Float> floats = new ArrayList<>();
|
|
|
- floats.add(70.34F);
|
|
|
- floats.add(28.954F);
|
|
|
- floats.add(55.90F);
|
|
|
- floats.add(55.90F);
|
|
|
- floats.add(89.123F);
|
|
|
- // System.err.println(DateUtils.getAxisY(floats));
|
|
|
- List<Integer> integers = new ArrayList<>();
|
|
|
- integers.add(70);
|
|
|
- integers.add(28);
|
|
|
- integers.add(55);
|
|
|
- integers.add(55);
|
|
|
- integers.add(89);
|
|
|
- Integer lastNum = 20;
|
|
|
- Integer firstNum = 100;
|
|
|
- Integer num = (firstNum - lastNum) / 6;
|
|
|
- System.err.println(num);
|
|
|
- List<Integer> nums = new ArrayList<>();
|
|
|
- nums.add(lastNum);
|
|
|
- for (int i = 0; i < 7; i++) {
|
|
|
- nums.add(lastNum += num);
|
|
|
- }
|
|
|
- System.err.println(JSON.toJSONString(nums));
|
|
|
- }
|
|
|
-
|
|
|
- // 1、实际榜:
|
|
|
- // 2、预测帮:查找close为空的。
|
|
|
- // 3、date上周 上上周测试。
|
|
|
- // 4、数据截取。
|
|
|
- @Test
|
|
|
- public void testDate(){
|
|
|
- String date = "2020-07-24";
|
|
|
- Map<String,Object> actualMap = DateUtils.getFridayOrLastFriday(date);
|
|
|
- Map<String,Object> nextMap = DateUtils.getEverydayOfNexWeek(date);
|
|
|
- System.err.println("周五那天的:"+date);
|
|
|
- System.err.println(JSON.toJSONString(actualMap));
|
|
|
- System.err.println();
|
|
|
- System.err.println();
|
|
|
- System.out.println(JSON.toJSONString(nextMap));
|
|
|
-
|
|
|
- String date1 = "2020-07-20";
|
|
|
- Map<String,Object> actualMap1 = DateUtils.getFridayOrLastFriday(date1);
|
|
|
- Map<String,Object> nextMap1 = DateUtils.getEverydayOfNexWeek(date1);
|
|
|
- System.err.println("周一的:"+date1);
|
|
|
- System.err.println(JSON.toJSONString(actualMap1));
|
|
|
- System.err.println();
|
|
|
- System.err.println();
|
|
|
- System.out.println(JSON.toJSONString(nextMap1));
|
|
|
-
|
|
|
- String date11 = "2020-07-22";
|
|
|
- Map<String,Object> actualMap11 = DateUtils.getFridayOrLastFriday(date11);
|
|
|
- Map<String,Object> nextMap11 = DateUtils.getEverydayOfNexWeek(date11);
|
|
|
- System.err.println("周三的:"+date11);
|
|
|
- System.err.println(JSON.toJSONString(actualMap11));
|
|
|
- System.err.println();
|
|
|
- System.err.println();
|
|
|
- System.out.println(JSON.toJSONString(nextMap11));
|
|
|
-
|
|
|
- String date111 = "2020-07-25";
|
|
|
- Map<String,Object> actualMap111 = DateUtils.getFridayOrLastFriday(date111);
|
|
|
- Map<String,Object> nextMap111 = DateUtils.getEverydayOfNexWeek(date111);
|
|
|
- System.err.println("周六的:"+date111);
|
|
|
- System.err.println(JSON.toJSONString(actualMap111));
|
|
|
- System.err.println();
|
|
|
- System.err.println();
|
|
|
- System.out.println(JSON.toJSONString(nextMap111));
|
|
|
-
|
|
|
- String date1111 = "2020-07-26";
|
|
|
- Map<String,Object> actualMap1111 = DateUtils.getFridayOrLastFriday(date1111);
|
|
|
- Map<String,Object> nextMap1111 = DateUtils.getEverydayOfNexWeek(date1111);
|
|
|
- System.err.println("周日的:"+date1111);
|
|
|
- System.err.println(JSON.toJSONString(actualMap1111));
|
|
|
- System.err.println();
|
|
|
- System.err.println();
|
|
|
- System.out.println(JSON.toJSONString(nextMap1111));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testUpdateIPlateName(){
|
|
|
- // QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- // industryInfoQueryWrapper.lambda()
|
|
|
- // .isNotNull(IndustryInfo::getId)
|
|
|
- // .groupBy(IndustryInfo::getPlateId);
|
|
|
- // List<IndustryInfo> industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
-
|
|
|
- QueryWrapper<IndustryPlateRes> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
- industryPlateQueryWrapper.lambda()
|
|
|
- .isNotNull(IndustryPlateRes::getId);
|
|
|
- List<IndustryPlateRes> industryPlates = industryPlateResMapper.selectList(industryPlateQueryWrapper);
|
|
|
-
|
|
|
- for (IndustryPlateRes industryPlate : industryPlates) {
|
|
|
- QueryWrapper<IndustryInfo> infoQueryWrapper = new QueryWrapper<>();
|
|
|
- infoQueryWrapper.lambda()
|
|
|
- .eq(IndustryInfo::getPlateId,industryPlate.getPlateId());
|
|
|
- List<IndustryInfo> industryInfoList = industryInfoMapper.selectList(infoQueryWrapper);
|
|
|
- industryPlate.setPlateName(industryInfoList.get(0).getPlateName());
|
|
|
- industryPlateResMapper.updateById(industryPlate);
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void tes(){
|
|
|
- DateUtils.getEverydayOfNexWeek("2020-07-03");
|
|
|
- // DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- // LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
- // localDate.with(TemporalAdjusters.next(DayOfWeek.of(2)));
|
|
|
- DateUtils.getEverydayOfNexWeek("2020-06-29");
|
|
|
- DateUtils.getEverydayOfNexWeek("2020-07-05");
|
|
|
- DateUtils.getEverydayOfNexWeek("2020-06-22");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void next(){
|
|
|
-
|
|
|
- DateUtils.getEverydayOfNexWeek("2020-07-03");
|
|
|
- // DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- // LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
- // localDate.with(TemporalAdjusters.next(DayOfWeek.of(2)));
|
|
|
- DateUtils.getEverydayOfNexWeek("2020-06-29");
|
|
|
- DateUtils.getEverydayOfNexWeek("2020-07-05");
|
|
|
- DateUtils.getEverydayOfNexWeek("2020-06-22");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testNext(){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- String date = "2020-07-04";
|
|
|
- String week = DateUtils.getWeekNameByDate(date);
|
|
|
- if (week.equals("6") || week.equals("7")){
|
|
|
- // 本周:
|
|
|
- DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
- LocalDate sunday = localDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
- LocalDate monday = localDate.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
- long distance = ChronoUnit.DAYS.between(monday, sunday);
|
|
|
- if (distance < 1) {
|
|
|
- // return map;
|
|
|
- }
|
|
|
- Stream.iterate(monday, d -> d.plusDays(1)).limit(distance + 1).forEach(f -> map.put(f.getDayOfWeek().toString(),f.toString()));
|
|
|
- System.err.println("if:"+JSON.toJSONString(map));
|
|
|
- }else {
|
|
|
- // 上周:
|
|
|
- Map<String,Object> lastMap = DateUtils.getFridayOrLastFriday(date);
|
|
|
- DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- LocalDate localDate = LocalDate.parse(lastMap.get("friday").toString(), pattern);
|
|
|
- LocalDate sunday = localDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
- LocalDate monday = localDate.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
- long distance = ChronoUnit.DAYS.between(monday, sunday);
|
|
|
- if (distance < 1) {
|
|
|
- // return map;
|
|
|
- }
|
|
|
- Stream.iterate(monday, d -> d.plusDays(1)).limit(distance + 1).forEach(f -> map.put(f.getDayOfWeek().toString(),f.toString()));
|
|
|
-
|
|
|
- System.err.println("else:"+JSON.toJSONString(map));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test(){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- String date = "2020-07-04";
|
|
|
- TestCommon.getEveryday("2020-07-03",false);
|
|
|
- TestCommon.getEveryday("2020-07-03",true);
|
|
|
- String week = DateUtils.getWeekNameByDate(date);
|
|
|
- if (week.equals("6") || week.equals("7")){
|
|
|
- // 本周:
|
|
|
- DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
- LocalDate sunday = localDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
- LocalDate monday = localDate.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
- long distance = ChronoUnit.DAYS.between(monday, sunday);
|
|
|
- if (distance < 1) {
|
|
|
- // return map;
|
|
|
- }
|
|
|
- Stream.iterate(monday, d -> d.plusDays(1)).limit(distance + 1).forEach(f -> map.put(f.getDayOfWeek().toString(),f.toString()));
|
|
|
- System.err.println("if:"+JSON.toJSONString(map));
|
|
|
- }else {
|
|
|
- // 上周:
|
|
|
- Map<String,Object> lastMap = DateUtils.getFridayOrLastFriday(date);
|
|
|
- DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- LocalDate localDate = LocalDate.parse(lastMap.get("friday").toString(), pattern);
|
|
|
- LocalDate sunday = localDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
- LocalDate monday = localDate.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
- long distance = ChronoUnit.DAYS.between(monday, sunday);
|
|
|
- if (distance < 1) {
|
|
|
- // return map;
|
|
|
- }
|
|
|
- Stream.iterate(monday, d -> d.plusDays(1)).limit(distance + 1).forEach(f -> map.put(f.getDayOfWeek().toString(),f.toString()));
|
|
|
-
|
|
|
- System.err.println("else:"+JSON.toJSONString(map));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test2(){
|
|
|
- System.err.println(getFridayOrLastFriday("",true));
|
|
|
- System.err.println(getFridayOrLastFriday("2020-07-06",true));
|
|
|
- System.err.println(getFridayOrLastFriday("2020-07-17",true));
|
|
|
- System.err.println(getFridayOrLastFriday("2020-07-14",true));
|
|
|
- System.err.println();
|
|
|
- System.err.println();
|
|
|
- System.err.println();
|
|
|
- System.err.println(getFridayOrLastFriday("",false));
|
|
|
- System.err.println(getFridayOrLastFriday("2020-07-06",false));
|
|
|
- System.err.println(getFridayOrLastFriday("2020-07-17",false));
|
|
|
- System.err.println(getFridayOrLastFriday("2020-07-14",false));
|
|
|
-
|
|
|
- String friday = "2020-07-03";
|
|
|
- String lastFriday = "2020-06-26";
|
|
|
- QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
- if (DateUtils.checkDate(friday,lastFriday).equals(true)){
|
|
|
- industryPlateQueryWrapper.between("plate_date", lastFriday, friday);
|
|
|
- }else {
|
|
|
- industryPlateQueryWrapper.between("plate_date", friday, lastFriday);
|
|
|
- }
|
|
|
- industryPlateQueryWrapper.groupBy("plate_id");
|
|
|
- industryPlateQueryWrapper.isNotNull("plate_id");
|
|
|
- List<IndustryPlate> plates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
- System.err.println(plates.size());
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public static Map<String,Object> getFridayOrLastFriday(String date,Boolean lastOrNext){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- String week = DateUtils.getWeekNameByDate(date);
|
|
|
- if (week.equals("6") || week.equals("7")){
|
|
|
- // 本周周五和上周五
|
|
|
- String currFriday = DateUtils.getFridayOfThisWeek(date);
|
|
|
- map.put("friday",currFriday);
|
|
|
- // 上上周五
|
|
|
- DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- LocalDate localDate = LocalDate.parse(currFriday, pattern);
|
|
|
- LocalDate todayOfLastWeek = lastOrNext.equals(true) ? localDate.minusDays(7) : localDate.plusDays(7);
|
|
|
- LocalDate fridayLocal = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.SATURDAY)).minusDays(1);
|
|
|
- map.put("lastFriday",fridayLocal.toString());
|
|
|
- log.info("friday map:{}", JSON.toJSONString(map));
|
|
|
- return map;
|
|
|
- }else {
|
|
|
- // 上周五和上上周五
|
|
|
- // 指定日期的周。
|
|
|
- DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
- LocalDate todayOfLastWeek = lastOrNext.equals(true) ? localDate.minusDays(7) : localDate.plusDays(7);
|
|
|
- LocalDate fridayLocal = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.SATURDAY)).minusDays(1);
|
|
|
- LocalDate lastFridayLocal = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SATURDAY)).minusDays(1);
|
|
|
- map.put("friday",fridayLocal.toString());
|
|
|
- map.put("lastFriday",lastFridayLocal.toString());
|
|
|
- log.info("friday map:{}", JSON.toJSONString(map));
|
|
|
- return map;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test1(){
|
|
|
- // 获取今天的实际日期。
|
|
|
- // getActualCurrDate();
|
|
|
- // 获取本周周五的日期。
|
|
|
- // getFridayOfThisWeek();
|
|
|
-
|
|
|
- // getDayOfNextWeek();
|
|
|
-
|
|
|
- // getEveryday("2020-07-18",true);
|
|
|
- // TestCommon.calWeek("2020-07-06",false);
|
|
|
- //
|
|
|
- // String date = "2020-07-06";
|
|
|
- // DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- // LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
- // System.err.println(DateUtils.getFridayOfThisWeek(date));
|
|
|
- // System.err.println(DateUtils.getFridayOfThisWeek(""));
|
|
|
-
|
|
|
- // System.err.println(DateUtils.getFridayOrLastFriday(""));
|
|
|
- // System.err.println(DateUtils.getFridayOrLastFriday("2020-07-06"));
|
|
|
- // System.err.println(DateUtils.getFridayOrLastFriday("2020-07-17"));
|
|
|
- // System.err.println(DateUtils.getFridayOrLastFriday("2020-07-14"));
|
|
|
-
|
|
|
- System.err.println(DateUtils.checkDate("2020-06-26","2020-07-03"));
|
|
|
- System.err.println(DateUtils.checkDate("2020-07-03","2020-06-26"));
|
|
|
- List<IncInfo> incInfos = new ArrayList<>();
|
|
|
- incInfos.add(IncInfo.builder().industryValue(1F).build());
|
|
|
- incInfos.add(IncInfo.builder().industryValue(7F).build());
|
|
|
- incInfos.add(IncInfo.builder().industryValue(66F).build());
|
|
|
- incInfos.add(IncInfo.builder().industryValue(15F).build());
|
|
|
- //年龄升序
|
|
|
- List<IncInfo> sortLists = incInfos.stream()
|
|
|
- .sorted(Comparator.comparing(IncInfo::getIndustryValue))
|
|
|
- .collect(Collectors.toList());
|
|
|
- System.err.println("升序:"+ JSON.toJSONString(sortLists));
|
|
|
- //年龄降序
|
|
|
- // List<IncInfo> sortLists = incInfos.stream()
|
|
|
- // .sorted(Comparator.comparing(IncInfo::getIndustryValue).reversed())
|
|
|
- // .collect(Collectors.toList());
|
|
|
- List<IncInfo> sortListss = incInfos.stream()
|
|
|
- .sorted(Comparator.comparing(IncInfo::getIndustryValue).reversed())
|
|
|
- .collect(Collectors.toList());
|
|
|
- System.err.println("降序序:"+ JSON.toJSONString(sortListss));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取一周内或者下周的每一天的日期。
|
|
|
- * @param date
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static Map<String,Object> getEveryday(String date, Boolean nextFlag){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
- // 求这个日期上一周的周一、周日
|
|
|
- LocalDate todayOfLastWeek = localDate.minusDays(7);
|
|
|
- if (nextFlag.equals(true)){
|
|
|
- todayOfLastWeek = todayOfLastWeek.plusDays(7);
|
|
|
- }
|
|
|
- LocalDate sunday = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
- LocalDate monday = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
- long distance = ChronoUnit.DAYS.between(monday, sunday);
|
|
|
- if (distance < 1) {
|
|
|
- return map;
|
|
|
- }
|
|
|
- Stream.iterate(monday, d -> d.plusDays(1)).limit(distance + 1).forEach(f -> map.put(f.getDayOfWeek().toString(),f.toString()));
|
|
|
- log.info("getEveryday获取一周内每天的日期:{}", JSON.toJSONString(map));
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取下一周的任意一天,默认周一。
|
|
|
- * @return String
|
|
|
- */
|
|
|
- public static String getDayOfNextWeek(){
|
|
|
- // DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- // LocalDate localDate = LocalDate.parse("2020-07-18", pattern);
|
|
|
- LocalDate localDate = currDate().with(DayOfWeek.FRIDAY);
|
|
|
- LocalDate todayOfLastWeek = localDate.plusDays(7);
|
|
|
- LocalDate monday = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
- String next = monday.toString();
|
|
|
- log.info("getNextWeek获取下一周的日期:{}",monday);
|
|
|
- return next;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public static LocalDate currDate(){
|
|
|
- return LocalDate.now();
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取本周的周五日期。
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static String getFridayOfThisWeek(){
|
|
|
- LocalDate toweekFriday = currDate().with(DayOfWeek.FRIDAY);
|
|
|
- String currFriday = toweekFriday.toString();
|
|
|
- log.info("getFridayOfThisWeek获取本周的周五日期:{}",currFriday);
|
|
|
- return currFriday;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取今天的实际日期。
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static String getActualCurrDate(){
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
- String currWeek = now.toLocalDate().toString();
|
|
|
- log.info("getActualCurrDate获取今天实际日期:{}",currWeek);
|
|
|
- return currWeek;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // List<IndustryInfo> industryInfos = new ArrayList<>();
|
|
|
- // // 根据行业id搜索。
|
|
|
- // if (ifIncDec.equals(true)) {
|
|
|
- // QueryWrapper<IndustryInfo> queryWrapper = new QueryWrapper();
|
|
|
- // queryWrapper.lambda()
|
|
|
- // .eq(IndustryInfo::getPlateId, searchInfo.getSearchParam())
|
|
|
- // .orderByDesc(IndustryInfo::getOperateTime)
|
|
|
- // .or()
|
|
|
- // .like(IndustryInfo::getPlateName, searchInfo.getSearchParam())
|
|
|
- // .or()
|
|
|
- // .eq(IndustryInfo::getStockId, searchInfo.getSearchParam())
|
|
|
- // .or()
|
|
|
- // .like(IndustryInfo::getStockName, searchInfo.getSearchParam());
|
|
|
- // industryInfos = industryInfoMapper.selectList(queryWrapper);
|
|
|
- // // 转换为industryPlate
|
|
|
- // // List<IndustryPlate> industryPlates = new ArrayList<>();
|
|
|
- // // IndustryPlate industryPlate;
|
|
|
- // // for (IndustryInfo industryInfo : industryInfos) {
|
|
|
- // // industryPlate = IndustryPlate.builder()
|
|
|
- // // .plateId(in)
|
|
|
- // // .build();
|
|
|
- // // }
|
|
|
- // } else {
|
|
|
- // QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- // // 涨幅跌幅。上周周五的close-上上上周五的close >0涨 <0跌
|
|
|
- // // industryInfoQueryWrapper.eq("tag",tag);
|
|
|
- // industryInfoQueryWrapper.isNotNull("id");
|
|
|
- // industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
- // }
|
|
|
-}
|
|
|
+// package com.pavis.ai.app.fda;
|
|
|
+//
|
|
|
+// import com.alibaba.fastjson.JSON;
|
|
|
+// import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+// import com.pavis.ai.app.fda.common.utils.DateUtils;
|
|
|
+// import com.pavis.ai.app.fda.form.TestCommon;
|
|
|
+// import com.pavis.ai.app.fda.form.inc.IncInfo;
|
|
|
+// import com.pavis.ai.app.fda.mapper.IndustryInfoMapper;
|
|
|
+// import com.pavis.ai.app.fda.mapper.IndustryPlateMapper;
|
|
|
+// import com.pavis.ai.app.fda.mapper.IndustryPlateResMapper;
|
|
|
+// import com.pavis.ai.app.fda.model.IndustryInfo;
|
|
|
+// import com.pavis.ai.app.fda.model.IndustryPlate;
|
|
|
+// import com.pavis.ai.app.fda.model.IndustryPlateRes;
|
|
|
+// import lombok.extern.slf4j.Slf4j;
|
|
|
+// import org.junit.Test;
|
|
|
+// import org.junit.runner.RunWith;
|
|
|
+// import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+// import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+// import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+//
|
|
|
+// import java.time.DayOfWeek;
|
|
|
+// import java.time.LocalDate;
|
|
|
+// import java.time.LocalDateTime;
|
|
|
+// import java.time.format.DateTimeFormatter;
|
|
|
+// import java.time.temporal.ChronoUnit;
|
|
|
+// import java.time.temporal.TemporalAdjusters;
|
|
|
+// import java.time.temporal.WeekFields;
|
|
|
+// import java.util.*;
|
|
|
+// import java.util.stream.Collectors;
|
|
|
+// import java.util.stream.Stream;
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * @author guanhuijuan
|
|
|
+// * @create 2020-07-18 12:17
|
|
|
+// * @desc
|
|
|
+// **/
|
|
|
+// @RunWith(SpringRunner.class)
|
|
|
+// @SpringBootTest
|
|
|
+// @Slf4j
|
|
|
+// public class LocalDateTest {
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private IndustryPlateMapper industryPlateMapper;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private IndustryInfoMapper industryInfoMapper;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private IndustryPlateResMapper industryPlateResMapper;
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testMonth(){
|
|
|
+// String date = "2020-06-31";
|
|
|
+// System.out.println(DateUtils.getMonthByNearly("2020-06-30"));
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testMon(){
|
|
|
+// String date = "2020-06-30";
|
|
|
+// Map<String,Object> map = DateUtils.getMonthByNearly(date);
|
|
|
+// String month = map.get("month").toString();
|
|
|
+// String nearlyMonth = map.get("nearlyMonth").toString();
|
|
|
+// System.err.println(month+"<>"+nearlyMonth);
|
|
|
+// Boolean tag = DateUtils.checkDate(month, nearlyMonth);
|
|
|
+// if (tag.equals(true)){
|
|
|
+// System.err.println(nearlyMonth+"<>"+month);
|
|
|
+// }else {
|
|
|
+// System.err.println(month+"<>"+nearlyMonth);
|
|
|
+// }
|
|
|
+// System.err.println(tag);
|
|
|
+// String testDate = "2020-05-31";
|
|
|
+// String week = DateUtils.getWeekNameByDate(testDate);
|
|
|
+// if (!week.equals("6") &&
|
|
|
+// !week.equals("7")){
|
|
|
+// System.err.println("add");
|
|
|
+// }else {
|
|
|
+// System.err.println("del");
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testY(){
|
|
|
+// List<Float> floats = new ArrayList<>();
|
|
|
+// floats.add(70.34F);
|
|
|
+// floats.add(28.954F);
|
|
|
+// floats.add(55.90F);
|
|
|
+// floats.add(55.90F);
|
|
|
+// floats.add(89.123F);
|
|
|
+// // System.err.println(DateUtils.getAxisY(floats));
|
|
|
+// List<Integer> integers = new ArrayList<>();
|
|
|
+// integers.add(70);
|
|
|
+// integers.add(28);
|
|
|
+// integers.add(55);
|
|
|
+// integers.add(55);
|
|
|
+// integers.add(89);
|
|
|
+// Integer lastNum = 20;
|
|
|
+// Integer firstNum = 100;
|
|
|
+// Integer num = (firstNum - lastNum) / 6;
|
|
|
+// System.err.println(num);
|
|
|
+// List<Integer> nums = new ArrayList<>();
|
|
|
+// nums.add(lastNum);
|
|
|
+// for (int i = 0; i < 7; i++) {
|
|
|
+// nums.add(lastNum += num);
|
|
|
+// }
|
|
|
+// System.err.println(JSON.toJSONString(nums));
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 1、实际榜:
|
|
|
+// // 2、预测帮:查找close为空的。
|
|
|
+// // 3、date上周 上上周测试。
|
|
|
+// // 4、数据截取。
|
|
|
+// @Test
|
|
|
+// public void testDate(){
|
|
|
+// String date = "2020-07-24";
|
|
|
+// Map<String,Object> actualMap = DateUtils.getFridayOrLastFriday(date);
|
|
|
+// Map<String,Object> nextMap = DateUtils.getEverydayOfNexWeek(date);
|
|
|
+// System.err.println("周五那天的:"+date);
|
|
|
+// System.err.println(JSON.toJSONString(actualMap));
|
|
|
+// System.err.println();
|
|
|
+// System.err.println();
|
|
|
+// System.out.println(JSON.toJSONString(nextMap));
|
|
|
+//
|
|
|
+// String date1 = "2020-07-20";
|
|
|
+// Map<String,Object> actualMap1 = DateUtils.getFridayOrLastFriday(date1);
|
|
|
+// Map<String,Object> nextMap1 = DateUtils.getEverydayOfNexWeek(date1);
|
|
|
+// System.err.println("周一的:"+date1);
|
|
|
+// System.err.println(JSON.toJSONString(actualMap1));
|
|
|
+// System.err.println();
|
|
|
+// System.err.println();
|
|
|
+// System.out.println(JSON.toJSONString(nextMap1));
|
|
|
+//
|
|
|
+// String date11 = "2020-07-22";
|
|
|
+// Map<String,Object> actualMap11 = DateUtils.getFridayOrLastFriday(date11);
|
|
|
+// Map<String,Object> nextMap11 = DateUtils.getEverydayOfNexWeek(date11);
|
|
|
+// System.err.println("周三的:"+date11);
|
|
|
+// System.err.println(JSON.toJSONString(actualMap11));
|
|
|
+// System.err.println();
|
|
|
+// System.err.println();
|
|
|
+// System.out.println(JSON.toJSONString(nextMap11));
|
|
|
+//
|
|
|
+// String date111 = "2020-07-25";
|
|
|
+// Map<String,Object> actualMap111 = DateUtils.getFridayOrLastFriday(date111);
|
|
|
+// Map<String,Object> nextMap111 = DateUtils.getEverydayOfNexWeek(date111);
|
|
|
+// System.err.println("周六的:"+date111);
|
|
|
+// System.err.println(JSON.toJSONString(actualMap111));
|
|
|
+// System.err.println();
|
|
|
+// System.err.println();
|
|
|
+// System.out.println(JSON.toJSONString(nextMap111));
|
|
|
+//
|
|
|
+// String date1111 = "2020-07-26";
|
|
|
+// Map<String,Object> actualMap1111 = DateUtils.getFridayOrLastFriday(date1111);
|
|
|
+// Map<String,Object> nextMap1111 = DateUtils.getEverydayOfNexWeek(date1111);
|
|
|
+// System.err.println("周日的:"+date1111);
|
|
|
+// System.err.println(JSON.toJSONString(actualMap1111));
|
|
|
+// System.err.println();
|
|
|
+// System.err.println();
|
|
|
+// System.out.println(JSON.toJSONString(nextMap1111));
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testUpdateIPlateName(){
|
|
|
+// // QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+// // industryInfoQueryWrapper.lambda()
|
|
|
+// // .isNotNull(IndustryInfo::getId)
|
|
|
+// // .groupBy(IndustryInfo::getPlateId);
|
|
|
+// // List<IndustryInfo> industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
+//
|
|
|
+// QueryWrapper<IndustryPlateRes> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+// industryPlateQueryWrapper.lambda()
|
|
|
+// .isNotNull(IndustryPlateRes::getId);
|
|
|
+// List<IndustryPlateRes> industryPlates = industryPlateResMapper.selectList(industryPlateQueryWrapper);
|
|
|
+//
|
|
|
+// for (IndustryPlateRes industryPlate : industryPlates) {
|
|
|
+// QueryWrapper<IndustryInfo> infoQueryWrapper = new QueryWrapper<>();
|
|
|
+// infoQueryWrapper.lambda()
|
|
|
+// .eq(IndustryInfo::getPlateId,industryPlate.getPlateId());
|
|
|
+// List<IndustryInfo> industryInfoList = industryInfoMapper.selectList(infoQueryWrapper);
|
|
|
+// industryPlate.setPlateName(industryInfoList.get(0).getPlateName());
|
|
|
+// industryPlateResMapper.updateById(industryPlate);
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void tes(){
|
|
|
+// DateUtils.getEverydayOfNexWeek("2020-07-03");
|
|
|
+// // DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// // LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
+// // localDate.with(TemporalAdjusters.next(DayOfWeek.of(2)));
|
|
|
+// DateUtils.getEverydayOfNexWeek("2020-06-29");
|
|
|
+// DateUtils.getEverydayOfNexWeek("2020-07-05");
|
|
|
+// DateUtils.getEverydayOfNexWeek("2020-06-22");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void next(){
|
|
|
+//
|
|
|
+// DateUtils.getEverydayOfNexWeek("2020-07-03");
|
|
|
+// // DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// // LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
+// // localDate.with(TemporalAdjusters.next(DayOfWeek.of(2)));
|
|
|
+// DateUtils.getEverydayOfNexWeek("2020-06-29");
|
|
|
+// DateUtils.getEverydayOfNexWeek("2020-07-05");
|
|
|
+// DateUtils.getEverydayOfNexWeek("2020-06-22");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testNext(){
|
|
|
+// Map<String,Object> map = new HashMap<>();
|
|
|
+// String date = "2020-07-04";
|
|
|
+// String week = DateUtils.getWeekNameByDate(date);
|
|
|
+// if (week.equals("6") || week.equals("7")){
|
|
|
+// // 本周:
|
|
|
+// DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
+// LocalDate sunday = localDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
+// LocalDate monday = localDate.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
+// long distance = ChronoUnit.DAYS.between(monday, sunday);
|
|
|
+// if (distance < 1) {
|
|
|
+// // return map;
|
|
|
+// }
|
|
|
+// Stream.iterate(monday, d -> d.plusDays(1)).limit(distance + 1).forEach(f -> map.put(f.getDayOfWeek().toString(),f.toString()));
|
|
|
+// System.err.println("if:"+JSON.toJSONString(map));
|
|
|
+// }else {
|
|
|
+// // 上周:
|
|
|
+// Map<String,Object> lastMap = DateUtils.getFridayOrLastFriday(date);
|
|
|
+// DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// LocalDate localDate = LocalDate.parse(lastMap.get("friday").toString(), pattern);
|
|
|
+// LocalDate sunday = localDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
+// LocalDate monday = localDate.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
+// long distance = ChronoUnit.DAYS.between(monday, sunday);
|
|
|
+// if (distance < 1) {
|
|
|
+// // return map;
|
|
|
+// }
|
|
|
+// Stream.iterate(monday, d -> d.plusDays(1)).limit(distance + 1).forEach(f -> map.put(f.getDayOfWeek().toString(),f.toString()));
|
|
|
+//
|
|
|
+// System.err.println("else:"+JSON.toJSONString(map));
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void test(){
|
|
|
+// Map<String,Object> map = new HashMap<>();
|
|
|
+// String date = "2020-07-04";
|
|
|
+// TestCommon.getEveryday("2020-07-03",false);
|
|
|
+// TestCommon.getEveryday("2020-07-03",true);
|
|
|
+// String week = DateUtils.getWeekNameByDate(date);
|
|
|
+// if (week.equals("6") || week.equals("7")){
|
|
|
+// // 本周:
|
|
|
+// DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
+// LocalDate sunday = localDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
+// LocalDate monday = localDate.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
+// long distance = ChronoUnit.DAYS.between(monday, sunday);
|
|
|
+// if (distance < 1) {
|
|
|
+// // return map;
|
|
|
+// }
|
|
|
+// Stream.iterate(monday, d -> d.plusDays(1)).limit(distance + 1).forEach(f -> map.put(f.getDayOfWeek().toString(),f.toString()));
|
|
|
+// System.err.println("if:"+JSON.toJSONString(map));
|
|
|
+// }else {
|
|
|
+// // 上周:
|
|
|
+// Map<String,Object> lastMap = DateUtils.getFridayOrLastFriday(date);
|
|
|
+// DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// LocalDate localDate = LocalDate.parse(lastMap.get("friday").toString(), pattern);
|
|
|
+// LocalDate sunday = localDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
+// LocalDate monday = localDate.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
+// long distance = ChronoUnit.DAYS.between(monday, sunday);
|
|
|
+// if (distance < 1) {
|
|
|
+// // return map;
|
|
|
+// }
|
|
|
+// Stream.iterate(monday, d -> d.plusDays(1)).limit(distance + 1).forEach(f -> map.put(f.getDayOfWeek().toString(),f.toString()));
|
|
|
+//
|
|
|
+// System.err.println("else:"+JSON.toJSONString(map));
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void test2(){
|
|
|
+// System.err.println(getFridayOrLastFriday("",true));
|
|
|
+// System.err.println(getFridayOrLastFriday("2020-07-06",true));
|
|
|
+// System.err.println(getFridayOrLastFriday("2020-07-17",true));
|
|
|
+// System.err.println(getFridayOrLastFriday("2020-07-14",true));
|
|
|
+// System.err.println();
|
|
|
+// System.err.println();
|
|
|
+// System.err.println();
|
|
|
+// System.err.println(getFridayOrLastFriday("",false));
|
|
|
+// System.err.println(getFridayOrLastFriday("2020-07-06",false));
|
|
|
+// System.err.println(getFridayOrLastFriday("2020-07-17",false));
|
|
|
+// System.err.println(getFridayOrLastFriday("2020-07-14",false));
|
|
|
+//
|
|
|
+// String friday = "2020-07-03";
|
|
|
+// String lastFriday = "2020-06-26";
|
|
|
+// QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+// if (DateUtils.checkDate(friday,lastFriday).equals(true)){
|
|
|
+// industryPlateQueryWrapper.between("plate_date", lastFriday, friday);
|
|
|
+// }else {
|
|
|
+// industryPlateQueryWrapper.between("plate_date", friday, lastFriday);
|
|
|
+// }
|
|
|
+// industryPlateQueryWrapper.groupBy("plate_id");
|
|
|
+// industryPlateQueryWrapper.isNotNull("plate_id");
|
|
|
+// List<IndustryPlate> plates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
+// System.err.println(plates.size());
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// public static Map<String,Object> getFridayOrLastFriday(String date,Boolean lastOrNext){
|
|
|
+// Map<String,Object> map = new HashMap<>();
|
|
|
+// String week = DateUtils.getWeekNameByDate(date);
|
|
|
+// if (week.equals("6") || week.equals("7")){
|
|
|
+// // 本周周五和上周五
|
|
|
+// String currFriday = DateUtils.getFridayOfThisWeek(date);
|
|
|
+// map.put("friday",currFriday);
|
|
|
+// // 上上周五
|
|
|
+// DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// LocalDate localDate = LocalDate.parse(currFriday, pattern);
|
|
|
+// LocalDate todayOfLastWeek = lastOrNext.equals(true) ? localDate.minusDays(7) : localDate.plusDays(7);
|
|
|
+// LocalDate fridayLocal = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.SATURDAY)).minusDays(1);
|
|
|
+// map.put("lastFriday",fridayLocal.toString());
|
|
|
+// log.info("friday map:{}", JSON.toJSONString(map));
|
|
|
+// return map;
|
|
|
+// }else {
|
|
|
+// // 上周五和上上周五
|
|
|
+// // 指定日期的周。
|
|
|
+// DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
+// LocalDate todayOfLastWeek = lastOrNext.equals(true) ? localDate.minusDays(7) : localDate.plusDays(7);
|
|
|
+// LocalDate fridayLocal = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.SATURDAY)).minusDays(1);
|
|
|
+// LocalDate lastFridayLocal = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SATURDAY)).minusDays(1);
|
|
|
+// map.put("friday",fridayLocal.toString());
|
|
|
+// map.put("lastFriday",lastFridayLocal.toString());
|
|
|
+// log.info("friday map:{}", JSON.toJSONString(map));
|
|
|
+// return map;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void test1(){
|
|
|
+// // 获取今天的实际日期。
|
|
|
+// // getActualCurrDate();
|
|
|
+// // 获取本周周五的日期。
|
|
|
+// // getFridayOfThisWeek();
|
|
|
+//
|
|
|
+// // getDayOfNextWeek();
|
|
|
+//
|
|
|
+// // getEveryday("2020-07-18",true);
|
|
|
+// // TestCommon.calWeek("2020-07-06",false);
|
|
|
+// //
|
|
|
+// // String date = "2020-07-06";
|
|
|
+// // DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// // LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
+// // System.err.println(DateUtils.getFridayOfThisWeek(date));
|
|
|
+// // System.err.println(DateUtils.getFridayOfThisWeek(""));
|
|
|
+//
|
|
|
+// // System.err.println(DateUtils.getFridayOrLastFriday(""));
|
|
|
+// // System.err.println(DateUtils.getFridayOrLastFriday("2020-07-06"));
|
|
|
+// // System.err.println(DateUtils.getFridayOrLastFriday("2020-07-17"));
|
|
|
+// // System.err.println(DateUtils.getFridayOrLastFriday("2020-07-14"));
|
|
|
+//
|
|
|
+// System.err.println(DateUtils.checkDate("2020-06-26","2020-07-03"));
|
|
|
+// System.err.println(DateUtils.checkDate("2020-07-03","2020-06-26"));
|
|
|
+// List<IncInfo> incInfos = new ArrayList<>();
|
|
|
+// incInfos.add(IncInfo.builder().industryValue(1F).build());
|
|
|
+// incInfos.add(IncInfo.builder().industryValue(7F).build());
|
|
|
+// incInfos.add(IncInfo.builder().industryValue(66F).build());
|
|
|
+// incInfos.add(IncInfo.builder().industryValue(15F).build());
|
|
|
+// //年龄升序
|
|
|
+// List<IncInfo> sortLists = incInfos.stream()
|
|
|
+// .sorted(Comparator.comparing(IncInfo::getIndustryValue))
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// System.err.println("升序:"+ JSON.toJSONString(sortLists));
|
|
|
+// //年龄降序
|
|
|
+// // List<IncInfo> sortLists = incInfos.stream()
|
|
|
+// // .sorted(Comparator.comparing(IncInfo::getIndustryValue).reversed())
|
|
|
+// // .collect(Collectors.toList());
|
|
|
+// List<IncInfo> sortListss = incInfos.stream()
|
|
|
+// .sorted(Comparator.comparing(IncInfo::getIndustryValue).reversed())
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// System.err.println("降序序:"+ JSON.toJSONString(sortListss));
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 获取一周内或者下周的每一天的日期。
|
|
|
+// * @param date
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// public static Map<String,Object> getEveryday(String date, Boolean nextFlag){
|
|
|
+// Map<String,Object> map = new HashMap<>();
|
|
|
+// DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// LocalDate localDate = LocalDate.parse(date, pattern);
|
|
|
+// // 求这个日期上一周的周一、周日
|
|
|
+// LocalDate todayOfLastWeek = localDate.minusDays(7);
|
|
|
+// if (nextFlag.equals(true)){
|
|
|
+// todayOfLastWeek = todayOfLastWeek.plusDays(7);
|
|
|
+// }
|
|
|
+// LocalDate sunday = todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1);
|
|
|
+// LocalDate monday = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
+// long distance = ChronoUnit.DAYS.between(monday, sunday);
|
|
|
+// if (distance < 1) {
|
|
|
+// return map;
|
|
|
+// }
|
|
|
+// Stream.iterate(monday, d -> d.plusDays(1)).limit(distance + 1).forEach(f -> map.put(f.getDayOfWeek().toString(),f.toString()));
|
|
|
+// log.info("getEveryday获取一周内每天的日期:{}", JSON.toJSONString(map));
|
|
|
+// return map;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 获取下一周的任意一天,默认周一。
|
|
|
+// * @return String
|
|
|
+// */
|
|
|
+// public static String getDayOfNextWeek(){
|
|
|
+// // DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// // LocalDate localDate = LocalDate.parse("2020-07-18", pattern);
|
|
|
+// LocalDate localDate = currDate().with(DayOfWeek.FRIDAY);
|
|
|
+// LocalDate todayOfLastWeek = localDate.plusDays(7);
|
|
|
+// LocalDate monday = todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1);
|
|
|
+// String next = monday.toString();
|
|
|
+// log.info("getNextWeek获取下一周的日期:{}",monday);
|
|
|
+// return next;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// public static LocalDate currDate(){
|
|
|
+// return LocalDate.now();
|
|
|
+// }
|
|
|
+// /**
|
|
|
+// * 获取本周的周五日期。
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// public static String getFridayOfThisWeek(){
|
|
|
+// LocalDate toweekFriday = currDate().with(DayOfWeek.FRIDAY);
|
|
|
+// String currFriday = toweekFriday.toString();
|
|
|
+// log.info("getFridayOfThisWeek获取本周的周五日期:{}",currFriday);
|
|
|
+// return currFriday;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 获取今天的实际日期。
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// public static String getActualCurrDate(){
|
|
|
+// LocalDateTime now = LocalDateTime.now();
|
|
|
+// String currWeek = now.toLocalDate().toString();
|
|
|
+// log.info("getActualCurrDate获取今天实际日期:{}",currWeek);
|
|
|
+// return currWeek;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// // List<IndustryInfo> industryInfos = new ArrayList<>();
|
|
|
+// // // 根据行业id搜索。
|
|
|
+// // if (ifIncDec.equals(true)) {
|
|
|
+// // QueryWrapper<IndustryInfo> queryWrapper = new QueryWrapper();
|
|
|
+// // queryWrapper.lambda()
|
|
|
+// // .eq(IndustryInfo::getPlateId, searchInfo.getSearchParam())
|
|
|
+// // .orderByDesc(IndustryInfo::getOperateTime)
|
|
|
+// // .or()
|
|
|
+// // .like(IndustryInfo::getPlateName, searchInfo.getSearchParam())
|
|
|
+// // .or()
|
|
|
+// // .eq(IndustryInfo::getStockId, searchInfo.getSearchParam())
|
|
|
+// // .or()
|
|
|
+// // .like(IndustryInfo::getStockName, searchInfo.getSearchParam());
|
|
|
+// // industryInfos = industryInfoMapper.selectList(queryWrapper);
|
|
|
+// // // 转换为industryPlate
|
|
|
+// // // List<IndustryPlate> industryPlates = new ArrayList<>();
|
|
|
+// // // IndustryPlate industryPlate;
|
|
|
+// // // for (IndustryInfo industryInfo : industryInfos) {
|
|
|
+// // // industryPlate = IndustryPlate.builder()
|
|
|
+// // // .plateId(in)
|
|
|
+// // // .build();
|
|
|
+// // // }
|
|
|
+// // } else {
|
|
|
+// // QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+// // // 涨幅跌幅。上周周五的close-上上上周五的close >0涨 <0跌
|
|
|
+// // // industryInfoQueryWrapper.eq("tag",tag);
|
|
|
+// // industryInfoQueryWrapper.isNotNull("id");
|
|
|
+// // industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
+// // }
|
|
|
+// }
|