|
@@ -870,9 +870,27 @@ public class SearchServiceImpl implements SearchService {
|
|
|
// .orderByDesc(IndustryPlate::getPlateDate);
|
|
|
// return industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 实际榜排序。
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public List<IndustryPlateRes> getNewest() {
|
|
|
QueryWrapper<IndustryPlateRes> industryPlateResQueryWrapper = new QueryWrapper<>();
|
|
|
industryPlateResQueryWrapper.lambda()
|
|
|
+ .isNotNull(IndustryPlateRes::getPlateClose)
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate);
|
|
|
+ return industryPlateResMapper.selectList(industryPlateResQueryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 预测榜排序。
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IndustryPlateRes> getNewestByPred() {
|
|
|
+ QueryWrapper<IndustryPlateRes> industryPlateResQueryWrapper = new QueryWrapper<>();
|
|
|
+ industryPlateResQueryWrapper.lambda()
|
|
|
+ .isNull(IndustryPlateRes::getPlateClose)
|
|
|
.orderByDesc(IndustryPlateRes::getPlateDate);
|
|
|
return industryPlateResMapper.selectList(industryPlateResQueryWrapper);
|
|
|
}
|
|
@@ -884,22 +902,35 @@ public class SearchServiceImpl implements SearchService {
|
|
|
*/
|
|
|
public List<IncInfo> lastWeekActual(Boolean incOrDec){
|
|
|
// 1、根据日期倒序拿到数据库中的最新日期
|
|
|
- Map<String,Object> actualMap = toDate();
|
|
|
+ Map<String,Object> actualMap = toDate(true);
|
|
|
// 1、根据当前日期判断是否是周六,是 本周的和上周的数据。否则上周和上上周的数据。
|
|
|
+ // String lastFriday = actualMap.get("friday").toString();
|
|
|
+ // String friday = DateUtils.getEverydayByActual(lastFriday).get("MONDAY").toString();
|
|
|
+ // todo 此处需要修改。
|
|
|
String friday = actualMap.get("friday").toString();
|
|
|
String lastFriday = actualMap.get("lastFriday").toString();
|
|
|
// 2、查询涨跌幅的实际榜。涨幅 倒叙排序取前十。跌幅 正序排序取前十。根据closeup值。
|
|
|
List<IndustryPlateRes> plateResList = new ArrayList<>();
|
|
|
if (incOrDec.equals(true)){
|
|
|
// 涨幅。
|
|
|
- plateResList = toActualIncOrDec(incOrDec,friday,lastFriday);
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
+ plateResList = toActualIncOrDec(incOrDec,lastFriday,friday);
|
|
|
+ }else {
|
|
|
+ plateResList = toActualIncOrDec(incOrDec,friday,lastFriday);
|
|
|
+ }
|
|
|
+
|
|
|
// 3、返回数据创建。
|
|
|
List<IncInfo> incInfos = toBackActualIncInfos(plateResList);
|
|
|
List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() > 0.0F)
|
|
|
.collect(Collectors.toList());
|
|
|
return finalIncInfos;
|
|
|
}else {
|
|
|
- plateResList = toActualIncOrDec(incOrDec,friday,lastFriday);
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
+ plateResList = toActualIncOrDec(incOrDec,lastFriday,friday);
|
|
|
+ }else {
|
|
|
+ plateResList = toActualIncOrDec(incOrDec,friday,lastFriday);
|
|
|
+ }
|
|
|
+
|
|
|
// 3、返回数据创建。
|
|
|
List<IncInfo> incInfos = toBackActualIncInfos(plateResList);
|
|
|
List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() < 0.0F)
|
|
@@ -912,10 +943,18 @@ public class SearchServiceImpl implements SearchService {
|
|
|
* 取日期。
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String,Object> toDate(){
|
|
|
+ public Map<String,Object> toDate(Boolean actualOrPred){
|
|
|
// 1、根据日期倒序拿到数据库中的最新日期
|
|
|
- List<IndustryPlateRes> datePlates = getNewest();
|
|
|
+ List<IndustryPlateRes> datePlates = new ArrayList<>();
|
|
|
+ if (actualOrPred.equals(true)){
|
|
|
+ // 实际
|
|
|
+ datePlates = getNewest();
|
|
|
+ }else {
|
|
|
+ // 预测
|
|
|
+ datePlates = getNewestByPred();
|
|
|
+ }
|
|
|
String date = datePlates.size() > 0 ? datePlates.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
+ log.info("sql 最新日期:{}",date);
|
|
|
// 1.1 根据当前日期判断是否是周六,是 本周的和上周的数据。否则上周和上上周的数据。
|
|
|
Map<String,Object> actualMap = DateUtils.getFridayOrLastFriday(date);
|
|
|
return actualMap;
|
|
@@ -932,37 +971,17 @@ public class SearchServiceImpl implements SearchService {
|
|
|
QueryWrapper<IndustryPlateRes> queryWrapper = new QueryWrapper<>();
|
|
|
if (incOrDec.equals(true)){
|
|
|
// 涨幅
|
|
|
- if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
- queryWrapper.lambda()
|
|
|
- .orderByDesc(IndustryPlateRes::getPlateCloseUp)
|
|
|
- .groupBy(IndustryPlateRes::getPlateId)
|
|
|
- .between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
- .eq(IndustryPlateRes::getPlateCloseUp,null)
|
|
|
- .last("limit 0,10");
|
|
|
- }else {
|
|
|
- queryWrapper.lambda()
|
|
|
- .orderByDesc(IndustryPlateRes::getPlateCloseUp)
|
|
|
- .groupBy(IndustryPlateRes::getPlateId)
|
|
|
- .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
- .eq(IndustryPlateRes::getPlateCloseUp,null)
|
|
|
- .last("limit 0,10");
|
|
|
- }
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateCloseUp)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
+ .last("limit 0,10");
|
|
|
}else {
|
|
|
- if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
- queryWrapper.lambda()
|
|
|
- .orderByAsc(IndustryPlateRes::getPlateCloseUp)
|
|
|
- .groupBy(IndustryPlateRes::getPlateId)
|
|
|
- .between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
- .eq(IndustryPlateRes::getPlateCloseUp,null)
|
|
|
- .last("limit 0,10");
|
|
|
- }else {
|
|
|
- queryWrapper.lambda()
|
|
|
- .orderByAsc(IndustryPlateRes::getPlateCloseUp)
|
|
|
- .groupBy(IndustryPlateRes::getPlateId)
|
|
|
- .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
- .eq(IndustryPlateRes::getPlateCloseUp,null)
|
|
|
- .last("limit 0,10");
|
|
|
- }
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByAsc(IndustryPlateRes::getPlateCloseUp)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
+ .last("limit 0,10");
|
|
|
}
|
|
|
List<IndustryPlateRes> plates = industryPlateResMapper.selectList(queryWrapper);
|
|
|
log.info("toActualIncOrDec plates:{}",JSON.toJSONString(plates));
|
|
@@ -976,18 +995,41 @@ public class SearchServiceImpl implements SearchService {
|
|
|
*/
|
|
|
public List<IncInfo> weekPred(Boolean incOrDec,Boolean lastOrNext){
|
|
|
// 1、根据日期倒序拿到数据库中的最新日期
|
|
|
- List<IndustryPlateRes> datePlates = getNewest();
|
|
|
+ List<IndustryPlateRes> datePlates = getNewestByPred();
|
|
|
String date = datePlates.size() > 0 ? datePlates.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
// 2、检索出符合要求的数据。
|
|
|
List<IndustryPlateRes> plates = new ArrayList<>();
|
|
|
if(lastOrNext.equals(true)){
|
|
|
+ log.info("上周预测...");
|
|
|
// 上周预测。
|
|
|
Map<String, Object> map = DateUtils.getFridayOrLastFriday(date);
|
|
|
- plates = toPredLastOrNext(incOrDec,map.get("friday").toString(),map.get("lastFriday").toString());
|
|
|
+ String friday = map.get("friday").toString();
|
|
|
+ String lastFriday = map.get("lastFriday").toString();
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
+ plates = toPredLastOrNext(incOrDec,lastFriday,friday);
|
|
|
+ }else {
|
|
|
+ plates = toPredLastOrNext(incOrDec,friday,lastFriday);
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 需要修改。
|
|
|
+ // String lastFriday = map.get("lastFriday").toString();
|
|
|
+ // String friday = DateUtils.getEverydayByActual(lastFriday).get("MONDAY").toString();
|
|
|
+ // plates = toPredLastOrNext(incOrDec,friday,lastFriday);
|
|
|
|
|
|
}else {
|
|
|
+ log.info("下周预测...");
|
|
|
Map<String, Object> map = DateUtils.getEverydayOfNexWeek(date);
|
|
|
- plates = toPredLastOrNext(incOrDec,map.get("friday").toString(),map.get("nextFriday").toString());
|
|
|
+ String friday = map.get("friday").toString();
|
|
|
+ String nextFriday = map.get("nextFriday").toString();
|
|
|
+ if (DateUtils.checkDate(friday,nextFriday).equals(true)) {
|
|
|
+ plates = toPredLastOrNext(incOrDec,nextFriday,friday);
|
|
|
+ }else {
|
|
|
+ plates = toPredLastOrNext(incOrDec,friday,nextFriday);
|
|
|
+ }
|
|
|
+ // todo 需要修改。
|
|
|
+ // String lastFriday = map.get("nextFriday").toString();
|
|
|
+ // String friday = DateUtils.getEverydayByActual(lastFriday).get("MONDAY").toString();
|
|
|
+ // plates = toPredLastOrNext(incOrDec,friday,lastFriday);
|
|
|
}
|
|
|
// 3、创建返回值。
|
|
|
if (incOrDec.equals(true)){
|
|
@@ -1230,7 +1272,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
*/
|
|
|
public List<IncInfo> toSearch(SearchInfo searchInfo){
|
|
|
// 1、根据日期倒序拿到数据库中的最新日期
|
|
|
- Map<String,Object> actualMap = toDate();
|
|
|
+ Map<String,Object> actualMap = toDate(true);
|
|
|
// 1、根据当前日期判断是否是周六,是 本周的和上周的数据。否则上周和上上周的数据。
|
|
|
String friday = actualMap.get("friday").toString();
|
|
|
String lastFriday = actualMap.get("lastFriday").toString();
|
|
@@ -1241,6 +1283,8 @@ public class SearchServiceImpl implements SearchService {
|
|
|
}else {
|
|
|
plates = toSearchQuery(searchInfo,friday,lastFriday);
|
|
|
}
|
|
|
+ // 热点搜索数据更新。
|
|
|
+ newsService.searchCount(searchInfo.getSearchParam(),searchInfo.getSearchParam());
|
|
|
|
|
|
// 3、创建返回s数据。
|
|
|
return toSearchBackIncInfos(plates);
|
|
@@ -1285,6 +1329,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
.orderByDesc(IndustryPlateRes::getPlateDate)
|
|
|
.groupBy(IndustryPlateRes::getPlateId)
|
|
|
.between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
+ // .eq(IndustryPlateRes::getPlateDate,friday)
|
|
|
.last("limit 0,10")
|
|
|
.or()
|
|
|
.like(IndustryPlateRes::getPlateId,searchInfo.getSearchParam())
|