|
@@ -2,6 +2,7 @@ package com.pavis.ai.app.fda.service.impl;
|
|
|
|
|
|
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.his.IndustryDetail;
|
|
|
import com.pavis.ai.app.fda.form.his.IndustryDetailsInfo;
|
|
@@ -51,7 +52,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> search(SearchInfo searchInfo) {
|
|
|
- return toIncInfos(true,false,false,true,searchInfo);
|
|
|
+ return toIncInfos(true, false, false, true, searchInfo);
|
|
|
// QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper();
|
|
|
// industryInfoQueryWrapper.lambda()
|
|
|
// .eq(IndustryInfo::getPlateId, searchInfo.getSearchParam())
|
|
@@ -103,15 +104,14 @@ public class SearchServiceImpl implements SearchService {
|
|
|
// return incInfos;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public IndustryDetailsInfo hisFind(List<String> ids) {
|
|
|
- return toDetailsByPlateId(ids,false);
|
|
|
+ return toDetailsByPlateId(ids, false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public IndustryDetailsInfo predictFind(List<String> ids) {
|
|
|
- return toDetailsByPlateId(ids,true);
|
|
|
+ return toDetailsByPlateId(ids, true);
|
|
|
|
|
|
// List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
//
|
|
@@ -160,11 +160,12 @@ public class SearchServiceImpl implements SearchService {
|
|
|
|
|
|
/**
|
|
|
* 根据行业id获取详情或者未来七天预测接口
|
|
|
+ *
|
|
|
* @param ids
|
|
|
* @param detailsFlag
|
|
|
* @return
|
|
|
*/
|
|
|
- public IndustryDetailsInfo toDetailsByPlateId(List<String> ids,Boolean detailsFlag){
|
|
|
+ public IndustryDetailsInfo toDetailsByPlateId(List<String> ids, Boolean detailsFlag) {
|
|
|
// todo 根据id进入详情,计算值。包含下周预测。
|
|
|
List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
for (String id : ids) {
|
|
@@ -174,36 +175,50 @@ public class SearchServiceImpl implements SearchService {
|
|
|
// 实际数据也即本周数据。
|
|
|
QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
industryPlateQueryWrapper.lambda()
|
|
|
- .eq(IndustryPlate::getPlateId,id)
|
|
|
+ .eq(IndustryPlate::getPlateId, id)
|
|
|
.orderByDesc(IndustryPlate::getPlateDate);
|
|
|
- List<IndustryPlate> selIndustryPlates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
- String date = selIndustryPlates.get(0).getPlateDate();
|
|
|
- log.info("实际数据日期:{}",date);
|
|
|
- // 2、下周预测,根据改时间获取下一周的周一至周日的每天的预测值。
|
|
|
- Map<String,Object> weekMap = TestCommon.getEveryday(date,false);
|
|
|
- String monday = weekMap.get("MONDAY").toString();
|
|
|
- String sunday = weekMap.get("SUNDAY").toString();
|
|
|
- List<IndustryPlate> industryPlates = toIndustryPlates(id,monday,sunday);
|
|
|
- log.info("实际:{}",JSON.toJSONString(industryPlates));
|
|
|
- System.err.println(detailsFlag);
|
|
|
- // 3、下周预测放上面,实际数据放下面。
|
|
|
- if (detailsFlag.equals(true)){
|
|
|
- System.err.println("if");
|
|
|
- Map<String,Object> nextWeekMap = TestCommon.getEveryday(date,true);
|
|
|
- String nextMonday = nextWeekMap.get("MONDAY").toString();
|
|
|
- String nextSunday = nextWeekMap.get("SUNDAY").toString();
|
|
|
- List<IndustryPlate> nextIndustryPlates = toIndustryPlates(id,nextMonday,nextSunday);
|
|
|
- log.info("预测:{}",JSON.toJSONString(nextIndustryPlates));
|
|
|
- for (IndustryPlate nextIndustryPlate : nextIndustryPlates) {
|
|
|
- industryDetails.add(toIndustryDetail(nextIndustryPlate));
|
|
|
+ List<IndustryPlate> datePlates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
+ if (datePlates.size() > 0) {
|
|
|
+ // String date = datePlates.get(0).getPlateDate();
|
|
|
+ String date = datePlates.size() > 0 ? datePlates.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
+ // 从这天开始算:周一至周五的数据。
|
|
|
+ log.info("实际数据日期:{}", date);
|
|
|
+ // 2、下周预测,根据改时间获取下一周的周一至周日的每天的预测值。
|
|
|
+ Map<String, Object> weekMap = DateUtils.getEverydayByActual(date);
|
|
|
+ // todo
|
|
|
+ String monday = weekMap.get("MONDAY").toString();
|
|
|
+ String sunday = weekMap.get("SUNDAY").toString();
|
|
|
+ List<IndustryPlate> industryPlates = toIndustryPlates(id, monday, sunday);
|
|
|
+ System.err.println(detailsFlag);
|
|
|
+ // 3、下周预测放上面,实际数据放下面。
|
|
|
+ List<IndustryPlate> nextIndustryPlates = new ArrayList<>();
|
|
|
+ if (detailsFlag.equals(true)) {
|
|
|
+ System.err.println("if");
|
|
|
+ Map<String, Object> nextWeekMap = DateUtils.getEverydayOfNexWeek(date);
|
|
|
+ String nextMonday = nextWeekMap.get("monday").toString();
|
|
|
+ String nextSunday = nextWeekMap.get("sunday").toString();
|
|
|
+ nextIndustryPlates = toIndustryPlates(id, nextMonday, nextSunday);
|
|
|
+ log.info("预测:{}", JSON.toJSONString(nextIndustryPlates));
|
|
|
+ for (IndustryPlate nextIndustryPlate : nextIndustryPlates) {
|
|
|
+ industryDetails.add(toIndustryDetail(nextIndustryPlate));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (nextIndustryPlates.size() > 0 && detailsFlag.equals(true)){
|
|
|
+ // 创建detail列表
|
|
|
+ log.info("实际:{}", JSON.toJSONString(industryPlates));
|
|
|
+ for (IndustryPlate industryPlate : industryPlates) {
|
|
|
+ industryDetails.add(toIndustryDetail(industryPlate));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (detailsFlag.equals(false)){
|
|
|
+ // 创建detail列表
|
|
|
+ log.info("实际:{}", JSON.toJSONString(industryPlates));
|
|
|
+ for (IndustryPlate industryPlate : industryPlates) {
|
|
|
+ industryDetails.add(toIndustryDetail(industryPlate));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- // 创建detail列表
|
|
|
- for (IndustryPlate industryPlate : industryPlates) {
|
|
|
- industryDetails.add(toIndustryDetail(industryPlate));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 4、附带新闻数据。
|
|
|
SearchInfo searchInfo = SearchInfo.builder()
|
|
|
.searchParam(ids.get(0))
|
|
@@ -220,70 +235,83 @@ public class SearchServiceImpl implements SearchService {
|
|
|
|
|
|
/**
|
|
|
* 创建每一天的close、pred值。
|
|
|
+ *
|
|
|
* @param industryPlate
|
|
|
* @return
|
|
|
*/
|
|
|
- public IndustryDetail toIndustryDetail(IndustryPlate industryPlate){
|
|
|
+ public IndustryDetail toIndustryDetail(IndustryPlate industryPlate) {
|
|
|
IndustryDetail industryDetail = IndustryDetail.builder()
|
|
|
- .industryId(industryPlate.getPlateId())
|
|
|
- .industryDate(industryPlate.getPlateDate())
|
|
|
- .close(industryPlate.getPlateClose())
|
|
|
- .pred(industryPlate.getPlateClosePred())
|
|
|
- .build();
|
|
|
+ .industryId(industryPlate.getPlateId())
|
|
|
+ .industryDate(industryPlate.getPlateDate())
|
|
|
+ .close(industryPlate.getPlateClose())
|
|
|
+ .pred(industryPlate.getPlateClosePred())
|
|
|
+ .build();
|
|
|
return industryDetail;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据plateid、周一至周日的期间获取每一天的close pred值。
|
|
|
+ *
|
|
|
* @param id
|
|
|
* @param monday
|
|
|
* @param sunday
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<IndustryPlate> toIndustryPlates(String id,String monday,String sunday){
|
|
|
- log.info("详情查询:{}",id + ",monday:" + monday + ",sunday:" + sunday);
|
|
|
+ public List<IndustryPlate> toIndustryPlates(String id, String monday, String sunday) {
|
|
|
+ log.info("详情查询:{}", id + ",monday:" + monday + ",sunday:" + sunday);
|
|
|
QueryWrapper<IndustryPlate> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda()
|
|
|
- .eq(IndustryPlate::getPlateId,id)
|
|
|
- .between(IndustryPlate::getPlateDate,monday,sunday);
|
|
|
+ if (DateUtils.checkDate(monday,sunday).equals(true)){
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlate::getPlateId, id)
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
+ .between(IndustryPlate::getPlateDate, sunday,monday );
|
|
|
+ }else {
|
|
|
+ System.err.println("else else");
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlate::getPlateId, id)
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
+ .between(IndustryPlate::getPlateDate, monday, sunday);
|
|
|
+ }
|
|
|
+
|
|
|
List<IndustryPlate> industryPlates = industryPlateMapper.selectList(queryWrapper);
|
|
|
return industryPlates;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> incLastWeek() {
|
|
|
- return toIncInfos(true,false,false,false,null);
|
|
|
+ return toIncInfos(true, false, false, false, null);
|
|
|
// return TestCommon.getIncList();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> incNextWeekPred() {
|
|
|
- return toIncInfos(true,false,true,false,null);
|
|
|
+ return toIncInfos(true, false, true, false, null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> incLastWeekPred() {
|
|
|
- return toIncInfos(true,true,false,false,null);
|
|
|
+ return toIncInfos(true, true, false, false, null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> decLastWeek() {
|
|
|
- return toIncInfos(false,false,false,false,null);
|
|
|
+ return toIncInfos(false, false, false, false, null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> decNextWeekPred() {
|
|
|
- return toIncInfos(false,false,true,false,null);
|
|
|
+ return toIncInfos(false, false, true, false, null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> decLastWeekPred() {
|
|
|
- return toIncInfos(false,true,false,false,null);
|
|
|
+ return toIncInfos(false, true, false, false, null);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 涨幅/跌幅的实际/预测榜方法。
|
|
|
+ *
|
|
|
* @param tag
|
|
|
* @param lastTag
|
|
|
* @param nextTag
|
|
@@ -291,108 +319,153 @@ public class SearchServiceImpl implements SearchService {
|
|
|
* @param searchInfo
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<IncInfo> toIncInfos(Boolean tag,Boolean lastTag,Boolean nextTag,Boolean ifIncDec,SearchInfo searchInfo){
|
|
|
- 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);
|
|
|
+ public List<IncInfo> toIncInfos(Boolean tag, Boolean lastTag, Boolean nextTag, Boolean ifIncDec, SearchInfo searchInfo) {
|
|
|
+ // 跌幅 上周实际榜:
|
|
|
+ // 1、拿到数据库中倒叙排序的最新的日期。根据当前日期判断是否是周六,是 本周的和上周的数据。否则上周和上上周的数据。
|
|
|
+ List<IndustryPlate> datePlates = getNewest();
|
|
|
+ String date = datePlates.size() > 0 ? datePlates.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
+ Map<String,Object> actualMap = DateUtils.getFridayOrLastFriday(date);
|
|
|
+ String friday = actualMap.get("friday").toString();
|
|
|
+ String lastFriday = actualMap.get("lastFriday").toString();
|
|
|
+ // 2、去plate查询数据,周五的数据-上周五的数据。根据value倒叙排序,涨幅倒叙 跌幅就是正序。
|
|
|
+ List<IndustryPlate> plates = new ArrayList<>();
|
|
|
+ if (ifIncDec.equals(true)) {
|
|
|
+ plates = searchIndustryPlate(searchInfo,friday,lastFriday);
|
|
|
}else {
|
|
|
- QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- // 涨幅跌幅。上周周五的close-上上上周五的close >0涨 <0跌
|
|
|
- // industryInfoQueryWrapper.eq("tag",tag);
|
|
|
- industryInfoQueryWrapper.isNotNull("id");
|
|
|
- industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
+ plates = findIndustryPlate(true, null,friday , lastFriday);
|
|
|
}
|
|
|
|
|
|
+ // 3、tag涨跌true/false过滤
|
|
|
IncInfo incInfo;
|
|
|
List<IncInfo> incInfos = new ArrayList<>();
|
|
|
- for (IndustryInfo industryInfo : industryInfos) {
|
|
|
- Map<String,Object> actualMap = ifIncDec ? TestCommon.calWeek(TestCommon.getWeek(),true) :
|
|
|
- TestCommon.calWeek(TestCommon.getWeek(),false);
|
|
|
- List<IndustryPlate> plates = findIndustryPlate(true,industryInfo.getPlateId(),actualMap.get("monday").toString(),actualMap.get("sunday").toString());
|
|
|
- QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
- industryPlateQueryWrapper.eq("plate_id",industryInfo.getPlateId());
|
|
|
- if (lastTag){
|
|
|
- Map<String,Object> map = TestCommon.calWeek(TestCommon.getWeek(),false);
|
|
|
- plates = findIndustryPlate(false,industryInfo.getPlateId(),map.get("monday").toString(),map.get("sunday").toString() );
|
|
|
- }
|
|
|
- if (nextTag){
|
|
|
- Map<String,Object> map = TestCommon.calWeek(TestCommon.getNextWeek(),true);
|
|
|
- plates = findIndustryPlate(false,industryInfo.getPlateId(),map.get("monday").toString(),map.get("sunday").toString() );
|
|
|
+ QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+ industryPlateQueryWrapper.eq("plate_id", null);
|
|
|
+ if (lastTag) {
|
|
|
+ // Map<String, Object> map = TestCommon.calWeek(date, false);
|
|
|
+ Map<String, Object> map = DateUtils.getFridayOrLastFriday(date);
|
|
|
+ plates = findIndustryPlate(false, null, map.get("friday").toString(), map.get("lastFriday").toString());
|
|
|
+ }
|
|
|
+ if (nextTag) {
|
|
|
+ // Map<String, Object> map = TestCommon.calWeek(date, true);
|
|
|
+ Map<String, Object> map = DateUtils.getEverydayOfNexWeek(date);
|
|
|
+ plates = findIndustryPlate(false, null, map.get("friday").toString(), map.get("lastFriday").toString());
|
|
|
+ }
|
|
|
+ // List<IndustryPlate> plates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
+ // 此处去重。
|
|
|
+ // List<IndustryPlate> distinctPlatesList = plates.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
|
|
|
+ // new TreeSet<>(Comparator.comparing(t -> t.getPlateId()))), ArrayList::new));
|
|
|
+ log.info("plates:{}",JSON.toJSONString(plates));
|
|
|
+ for (IndustryPlate plate : plates) {
|
|
|
+ Float value = calLastWeekActual(date,plate.getPlateId());
|
|
|
+ if (lastTag) {
|
|
|
+ value = calLastWeekPred(date,plate.getPlateId());
|
|
|
}
|
|
|
- // List<IndustryPlate> plates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
- for (IndustryPlate plate : plates) {
|
|
|
- Float value = calLastWeekActual(plate.getPlateId());
|
|
|
- if (lastTag){
|
|
|
- value = calLastWeekPred(plate.getPlateId());
|
|
|
- }
|
|
|
- if (nextTag){
|
|
|
- value = calNextWeekPred(plate.getPlateId());
|
|
|
- }
|
|
|
- Boolean industryTag = value > 0.0 ? true : false;
|
|
|
- log.info("plateId:{}",plate.getPlateId());
|
|
|
- log.info("value:{}",value);
|
|
|
- log.info("industryTag:{}",industryTag);
|
|
|
- incInfo = IncInfo.builder()
|
|
|
- .industryId(plate.getPlateId())
|
|
|
- .industryName(industryInfo.getPlateName())
|
|
|
- .industryValue(value)
|
|
|
- .industryTag(industryTag)
|
|
|
- .build();
|
|
|
- incInfos.add(incInfo);
|
|
|
+ if (nextTag) {
|
|
|
+ value = calNextWeekPred(date,plate.getPlateId());
|
|
|
}
|
|
|
+ Boolean industryTag = value > 0.0 ? true : false;
|
|
|
+ log.info("plateId:{}", plate.getPlateId());
|
|
|
+ log.info("value:{}", value);
|
|
|
+ log.info("industryTag:{}", industryTag);
|
|
|
+ QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ industryInfoQueryWrapper.lambda()
|
|
|
+ .eq(IndustryInfo::getPlateId, plate.getPlateId());
|
|
|
+ // List<IndustryInfo> infos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
+ incInfo = IncInfo.builder()
|
|
|
+ .industryId(plate.getPlateId())
|
|
|
+ .industryName(plate.getPlateName())
|
|
|
+ .industryValue(value)
|
|
|
+ .industryTag(industryTag)
|
|
|
+ .build();
|
|
|
+ incInfos.add(incInfo);
|
|
|
}
|
|
|
- // 排序 排序值: 上周周五的close-上上上周五的close >0涨 <0跌
|
|
|
- List<IncInfo> sortLists = incInfos.stream()
|
|
|
+ // 排序:涨幅倒序-跌幅正序。 排序值: 上周周五的close-上上上周五的close >0涨 <0跌
|
|
|
+ List<IncInfo> sortLists = tag.equals(true) ? incInfos.stream()
|
|
|
.sorted(Comparator.comparing(IncInfo::getIndustryValue).reversed())
|
|
|
+ .collect(Collectors.toList()) : incInfos.stream()
|
|
|
+ .sorted(Comparator.comparing(IncInfo::getIndustryValue))
|
|
|
.collect(Collectors.toList());
|
|
|
- log.info("sort info:{}",JSON.toJSONString(sortLists));
|
|
|
+ log.info("sort info:{}", JSON.toJSONString(sortLists));
|
|
|
// 去除跌幅榜或者涨幅榜。
|
|
|
- log.info("tag :{}",tag);
|
|
|
- if (ifIncDec.equals(true)){
|
|
|
- log.info("涨跌幅:{}",JSON.toJSONString(sortLists));
|
|
|
+ log.info("tag :{}", tag);
|
|
|
+ if (ifIncDec.equals(true)) {
|
|
|
+ log.info("涨跌幅:{}", JSON.toJSONString(sortLists));
|
|
|
return sortLists;
|
|
|
}
|
|
|
- if (tag.equals(true)){
|
|
|
+ if (tag.equals(true)) {
|
|
|
// 涨幅:
|
|
|
sortLists.removeIf(s -> s.getIndustryTag().equals(false));
|
|
|
- log.info("涨幅:{}",JSON.toJSONString(sortLists));
|
|
|
+ log.info("涨幅:{}", JSON.toJSONString(sortLists));
|
|
|
return sortLists;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// 跌幅。
|
|
|
// List<IncInfo> finalIncInfos = sortLists.stream().filter(s->s.getIndustryTag() && s.getIndustryTag() == true)
|
|
|
// .collect(Collectors.toList());
|
|
|
// return finalIncInfos;
|
|
|
sortLists.removeIf(s -> s.getIndustryTag().equals(true));
|
|
|
- log.info("跌幅:{}",JSON.toJSONString(sortLists));
|
|
|
+ log.info("跌幅:{}", JSON.toJSONString(sortLists));
|
|
|
return sortLists;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据行业id或者行业名称进行搜索.
|
|
|
+ * @param searchInfo
|
|
|
+ * @param friday
|
|
|
+ * @param lastFriday
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IndustryPlate> searchIndustryPlate(SearchInfo searchInfo,String friday,String lastFriday){
|
|
|
+ List<IndustryPlate> plates = new ArrayList<>();
|
|
|
+ // 涨跌均存在。根据行业id查询进来的。
|
|
|
+ QueryWrapper<IndustryPlate> queryWrapper = new QueryWrapper();
|
|
|
+ System.err.println(searchInfo.getSearchParam());
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)){
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlate::getPlateId, searchInfo.getSearchParam())
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
+ .groupBy(IndustryPlate::getPlateId)
|
|
|
+ .between(IndustryPlate::getPlateDate, lastFriday, friday)
|
|
|
+ .or()
|
|
|
+ .like(IndustryPlate::getPlateName, searchInfo.getSearchParam());
|
|
|
+ }else {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlate::getPlateId, searchInfo.getSearchParam())
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
+ .groupBy(IndustryPlate::getPlateId)
|
|
|
+ .between(IndustryPlate::getPlateDate, friday, lastFriday)
|
|
|
+ .or()
|
|
|
+ .like(IndustryPlate::getPlateName, searchInfo.getSearchParam());
|
|
|
+ }
|
|
|
+ plates = industryPlateMapper.selectList(queryWrapper);
|
|
|
+ log.info("search plates:{}",JSON.toJSONString(plates));
|
|
|
+ return plates;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询,上周实际,上周预测,下周预测。
|
|
|
+ *
|
|
|
* @param just
|
|
|
* @param plateId
|
|
|
- * @param monday
|
|
|
- * @param sunday
|
|
|
+ * @param friday
|
|
|
+ * @param lastFriday
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<IndustryPlate> findIndustryPlate(Boolean just,String plateId,String monday,String sunday){
|
|
|
+ public List<IndustryPlate> findIndustryPlate(Boolean just, String plateId, String friday, String lastFriday) {
|
|
|
QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
- industryPlateQueryWrapper.between("plate_date",monday,sunday);
|
|
|
- industryPlateQueryWrapper.eq("plate_id",plateId);
|
|
|
- if (just.equals(false)){
|
|
|
- industryPlateQueryWrapper.between("plate_date",monday,sunday);
|
|
|
+ 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");
|
|
|
+ if (just.equals(false)) {
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)){
|
|
|
+ industryPlateQueryWrapper.between("plate_date", lastFriday, friday);
|
|
|
+ }else {
|
|
|
+ industryPlateQueryWrapper.between("plate_date", friday, lastFriday);
|
|
|
+ }
|
|
|
}
|
|
|
List<IndustryPlate> plates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
return plates;
|
|
@@ -400,83 +473,94 @@ public class SearchServiceImpl implements SearchService {
|
|
|
|
|
|
/**
|
|
|
* 上周实际榜。
|
|
|
+ *
|
|
|
* @param plateId
|
|
|
* @return
|
|
|
*/
|
|
|
- public Float calLastWeekActual(String plateId){
|
|
|
- Map<String,Object> map = TestCommon.calWeek("",true);
|
|
|
+ public Float calLastWeekActual(String date,String plateId) {
|
|
|
+ Map<String, Object> map = DateUtils.getFridayOrLastFriday(date);
|
|
|
// b本周实际拿的是预测的数据,pred。
|
|
|
// 上周实际榜:上周周五的close-上上周周五的close
|
|
|
String friday = map.get("friday").toString();
|
|
|
- List<IndustryPlate> industryPlates = getClose(plateId,friday);
|
|
|
+ List<IndustryPlate> industryPlates = getClose(plateId, friday);
|
|
|
String lastFriday = map.get("lastFriday").toString();
|
|
|
- log.info("calLastWeekActual 上周五:{}",friday);
|
|
|
- log.info("calLastWeekActual 上上周五:{}",lastFriday);
|
|
|
- List<IndustryPlate> industryPlatesLast = getClose(plateId,lastFriday);
|
|
|
- if (industryPlates.size() > 0 && industryPlatesLast.size() > 0){
|
|
|
- Float close = industryPlates.get(0).getPlateClose();
|
|
|
- Float lastClose = industryPlatesLast.get(0).getPlateClose();
|
|
|
- Float value = close - lastClose;
|
|
|
- return value;
|
|
|
- }
|
|
|
- return 0.0F;
|
|
|
+ List<IndustryPlate> industryPlatesLast = getClose(plateId, lastFriday);
|
|
|
+ return getCloseValue(industryPlates,industryPlatesLast);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 上周预测榜。
|
|
|
- * 上周预测:上周五的pred-上上周无的pred
|
|
|
+ * 上周预测:上周五的pred-上上周无的pred
|
|
|
+ *
|
|
|
* @param plateId
|
|
|
* @return
|
|
|
*/
|
|
|
- public Float calLastWeekPred(String plateId){
|
|
|
- Map<String,Object> map = TestCommon.calWeek("",true);
|
|
|
+ public Float calLastWeekPred(String date,String plateId) {
|
|
|
+ Map<String, Object> map = DateUtils.getFridayOrLastFriday(date);
|
|
|
String friday = map.get("friday").toString();
|
|
|
String lastFriday = map.get("lastFriday").toString();
|
|
|
- log.info("calLastWeekPred 上周五:{}",friday);
|
|
|
- log.info("calLastWeekPred 上上周五:{}",lastFriday);
|
|
|
- List<IndustryPlate> industryPlates = getClose(plateId,friday);
|
|
|
- List<IndustryPlate> industryPlatesLast = getClose(plateId,lastFriday);
|
|
|
- Float pred = industryPlates.get(0).getPlateClosePred();
|
|
|
- Float lastPred = industryPlatesLast.get(0).getPlateClosePred();
|
|
|
- Float value = pred - lastPred;
|
|
|
- return value;
|
|
|
+ List<IndustryPlate> industryPlatesLast = getClose(plateId, lastFriday);
|
|
|
+ List<IndustryPlate> industryPlates = getClose(plateId, friday);
|
|
|
+ return getPredValue(industryPlates,industryPlatesLast);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 下周预测榜
|
|
|
- * 下周预测:这周周五的pred-上周周五的pred。
|
|
|
+ * 下周预测:这周周五的pred-上周周五的pred。
|
|
|
+ * 计算方式:下周预测-本周预测啊
|
|
|
* @param plateId
|
|
|
* @return
|
|
|
*/
|
|
|
- public Float calNextWeekPred(String plateId){
|
|
|
- Map<String,Object> map = TestCommon.calWeek("",true);
|
|
|
- String friday = TestCommon.currWeekFriday();
|
|
|
- String lastFriday = map.get("friday").toString();
|
|
|
- log.info("calNextWeekPred 本周五:{}",friday);
|
|
|
- log.info("calNextWeekPred 上周五:{}",lastFriday);
|
|
|
- List<IndustryPlate> industryPlates = getClose(plateId,friday);
|
|
|
- List<IndustryPlate> industryPlatesLast = getClose(plateId,lastFriday);
|
|
|
- Float pred = industryPlates.get(0).getPlateClosePred();
|
|
|
- Float lastPred = industryPlatesLast.get(0).getPlateClosePred();
|
|
|
+ public Float calNextWeekPred(String date,String plateId) {
|
|
|
+ Map<String, Object> map = DateUtils.getEverydayOfNexWeek(date);
|
|
|
+ String nextFriday = map.get("nextFriday").toString();
|
|
|
+ String friday = map.get("friday").toString();
|
|
|
+ List<IndustryPlate> industryPlatesNext = getClose(plateId, nextFriday);
|
|
|
+ List<IndustryPlate> industryPlates = getClose(plateId, friday);
|
|
|
+ return getPredValue(industryPlatesNext,industryPlates);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Float getCloseValue(List<IndustryPlate> industryPlates,List<IndustryPlate> industryPlatesLast){
|
|
|
+ Float close = industryPlates.size() > 0 ? industryPlates.get(0).getPlateClose() : 0.0F;
|
|
|
+ Float lastClose = industryPlatesLast.size() > 0 ? industryPlatesLast.get(0).getPlateClose() : 1.0F;
|
|
|
+ Float value = close - lastClose;
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Float getPredValue(List<IndustryPlate> industryPlates,List<IndustryPlate> industryPlatesLast){
|
|
|
+ Float pred = industryPlates.size() > 0 ? industryPlates.get(0).getPlateClosePred() : 0.0F;
|
|
|
+ Float lastPred = industryPlatesLast.size() > 0 ? industryPlatesLast.get(0).getPlateClosePred() : 1.0F;
|
|
|
Float value = pred - lastPred;
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取N周五的收盘价。
|
|
|
+ *
|
|
|
* @param plateId
|
|
|
* @param friday
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<IndustryPlate> getClose(String plateId,String friday){
|
|
|
- log.info("sel industryplate:{}",plateId +"," + friday);
|
|
|
+ public List<IndustryPlate> getClose(String plateId, String friday) {
|
|
|
+ log.info("getClose() industryplate:{}", plateId + "," + friday);
|
|
|
QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
industryPlateQueryWrapper.lambda()
|
|
|
- .eq(IndustryPlate::getPlateId,plateId)
|
|
|
- .eq(IndustryPlate::getPlateDate,friday);
|
|
|
+ .eq(IndustryPlate::getPlateId, plateId)
|
|
|
+ .eq(IndustryPlate::getPlateDate, friday);
|
|
|
List<IndustryPlate> industryPlates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
- log.info("plates:{}",JSON.toJSONString(industryPlates));
|
|
|
+ log.info("plates:{}", JSON.toJSONString(industryPlates));
|
|
|
return industryPlates;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取数据库中最新的日期。
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IndustryPlate> getNewest() {
|
|
|
+ QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+ industryPlateQueryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate);
|
|
|
+ return industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
+ }
|
|
|
}
|