|
@@ -15,12 +15,10 @@ import com.pavis.ai.app.fda.mapper.IndustryStockMapper;
|
|
|
import com.pavis.ai.app.fda.mapper.SearchCountMapper;
|
|
|
import com.pavis.ai.app.fda.model.IndustryInfo;
|
|
|
import com.pavis.ai.app.fda.model.IndustryPlate;
|
|
|
-import com.pavis.ai.app.fda.model.IndustryStock;
|
|
|
import com.pavis.ai.app.fda.model.SearchCount;
|
|
|
import com.pavis.ai.app.fda.service.NewsService;
|
|
|
import com.pavis.ai.app.fda.service.SearchService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -47,124 +45,106 @@ public class SearchServiceImpl implements SearchService {
|
|
|
@Autowired
|
|
|
private IndustryStockMapper industryStockMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SearchCountMapper searchCountMapper;
|
|
|
|
|
|
- @private NewsService newsService;
|
|
|
+ @Autowired
|
|
|
+ private NewsService newsService;
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> search(SearchInfo searchInfo) {
|
|
|
- QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper();
|
|
|
- industryInfoQueryWrapper.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());
|
|
|
- List<IndustryInfo> industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
- System.err.println(JSON.toJSONString(industryInfos));
|
|
|
- List<IncInfo> incInfos = new ArrayList<>();
|
|
|
-
|
|
|
- for (IndustryInfo industryInfo : industryInfos) {
|
|
|
- // 记录搜索次数
|
|
|
- searchCount(industryInfo.getPlateId(),industryInfo.getPlateName());
|
|
|
- QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
- industryPlateQueryWrapper.lambda()
|
|
|
- .eq(IndustryPlate::getPlateId,industryInfo.getPlateId());
|
|
|
- List<IndustryPlate> industryPlates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
- IncInfo incInfo;
|
|
|
- for (IndustryPlate industryPlate : industryPlates) {
|
|
|
- incInfo = IncInfo.builder()
|
|
|
- .industryId(industryPlate.getPlateId())
|
|
|
- .industryName(industryInfo.getPlateName())
|
|
|
- .industryValue(TestCommon.toInitFloat())
|
|
|
- // todo 后期需要改。
|
|
|
- .industryTag(industryPlate.getPlateDate().equals("2010-01-10") ? true : false)
|
|
|
- .build();
|
|
|
- incInfos.add(incInfo);
|
|
|
- }
|
|
|
- QueryWrapper<IndustryStock> industryStockQueryWrapper = new QueryWrapper<>();
|
|
|
- industryStockQueryWrapper.lambda()
|
|
|
- .eq(IndustryStock::getStockId,industryInfo.getPlateId());
|
|
|
- List<IndustryStock> industryStocks = industryStockMapper.selectList(industryStockQueryWrapper);
|
|
|
- // IncInfo incInfo;
|
|
|
- for (IndustryStock industryStock : industryStocks) {
|
|
|
- incInfo = IncInfo.builder()
|
|
|
- .industryId(industryStock.getStockId())
|
|
|
- .industryName(industryInfo.getStockName())
|
|
|
- .industryValue(TestCommon.toInitFloat())
|
|
|
- .industryTag(true)
|
|
|
- .build();
|
|
|
- incInfos.add(incInfo);
|
|
|
- }
|
|
|
- }
|
|
|
- return incInfos;
|
|
|
+ return toIncInfos(true,false,false,true,searchInfo);
|
|
|
+ // QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper();
|
|
|
+ // industryInfoQueryWrapper.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());
|
|
|
+ // List<IndustryInfo> industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
+ // System.err.println(JSON.toJSONString(industryInfos));
|
|
|
+ // List<IncInfo> incInfos = new ArrayList<>();
|
|
|
+ //
|
|
|
+ // for (IndustryInfo industryInfo : industryInfos) {
|
|
|
+ // // 记录搜索次数
|
|
|
+ // searchCount(industryInfo.getPlateId(),industryInfo.getPlateName());
|
|
|
+ // // 根据行业id进行查询。
|
|
|
+ // QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+ // industryPlateQueryWrapper.lambda()
|
|
|
+ // .eq(IndustryPlate::getPlateId,industryInfo.getPlateId());
|
|
|
+ // List<IndustryPlate> industryPlates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
+ // IncInfo incInfo;
|
|
|
+ // for (IndustryPlate industryPlate : industryPlates) {
|
|
|
+ // incInfo = IncInfo.builder()
|
|
|
+ // .industryId(industryPlate.getPlateId())
|
|
|
+ // .industryName(industryInfo.getPlateName())
|
|
|
+ // .industryValue(TestCommon.toInitFloat())
|
|
|
+ // // todo 后期需要改。
|
|
|
+ // .industryTag(industryPlate.getPlateDate().equals("2010-01-10") ? true : false)
|
|
|
+ // .build();
|
|
|
+ // incInfos.add(incInfo);
|
|
|
+ // }
|
|
|
+ // QueryWrapper<IndustryStock> industryStockQueryWrapper = new QueryWrapper<>();
|
|
|
+ // industryStockQueryWrapper.lambda()
|
|
|
+ // .eq(IndustryStock::getStockId,industryInfo.getPlateId());
|
|
|
+ // List<IndustryStock> industryStocks = industryStockMapper.selectList(industryStockQueryWrapper);
|
|
|
+ // // IncInfo incInfo;
|
|
|
+ // for (IndustryStock industryStock : industryStocks) {
|
|
|
+ // incInfo = IncInfo.builder()
|
|
|
+ // .industryId(industryStock.getStockId())
|
|
|
+ // .industryName(industryInfo.getStockName())
|
|
|
+ // .industryValue(TestCommon.toInitFloat())
|
|
|
+ // .industryTag(true)
|
|
|
+ // .build();
|
|
|
+ // incInfos.add(incInfo);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // return incInfos;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void searchCount(String plateId, String plateName) {
|
|
|
- QueryWrapper<SearchCount> searchCountQueryWrapper = new QueryWrapper<>();
|
|
|
- searchCountQueryWrapper.lambda()
|
|
|
- .eq(SearchCount::getPlateId,plateId);
|
|
|
- List<SearchCount> searchCounts = searchCountMapper.selectList(searchCountQueryWrapper);
|
|
|
- if (searchCounts.size() > 0){
|
|
|
- // 已存在,直接+1;
|
|
|
- for (SearchCount searchCount : searchCounts) {
|
|
|
- String num = String.valueOf(Integer.valueOf(searchCount.getSearchNum()) + 1);
|
|
|
- searchCount.setSearchNum(num);
|
|
|
- searchCountMapper.updateById(searchCount);
|
|
|
- }
|
|
|
- }else {
|
|
|
- // 新数据新增。
|
|
|
- SearchCount searchCount;
|
|
|
- searchCount = new SearchCount();
|
|
|
- searchCount.setPlateId(plateId);
|
|
|
- searchCount.setPlateName(plateName);
|
|
|
- searchCount.setSearchNum("1");
|
|
|
- searchCountMapper.insert(searchCount);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
- public List<HotSearch> searchHot() {
|
|
|
- QueryWrapper<SearchCount> searchCountQueryWrapper = new QueryWrapper<>();
|
|
|
- searchCountQueryWrapper.orderByDesc("search_num");
|
|
|
- searchCountQueryWrapper.isNotNull("id");
|
|
|
- List<SearchCount> searchCounts = searchCountMapper.selectList(searchCountQueryWrapper);
|
|
|
- HotSearch hotSearch;
|
|
|
- List<HotSearch> hotSearches = new ArrayList<>();
|
|
|
- for (SearchCount searchCount : searchCounts) {
|
|
|
- hotSearch = new HotSearch();
|
|
|
- BeanUtils.copyProperties(searchCount, hotSearch);
|
|
|
- hotSearches.add(hotSearch);
|
|
|
- }
|
|
|
- return hotSearches;
|
|
|
-
|
|
|
- // List<HotSearch> hotSearches = new ArrayList<>();
|
|
|
- // // 07-23 日期加七天。
|
|
|
- // hotSearches.add(TestCommon.toInitHotSearch("BK0422","交运物流",TestCommon.toInitFloat(),true));
|
|
|
- // hotSearches.add(TestCommon.toInitHotSearch("BK0738","多元金融",Float.valueOf("0.0"),false));
|
|
|
- // hotSearches.add(TestCommon.toInitHotSearch("BK450","港口水运",Float.valueOf("0.0"),false));
|
|
|
- // hotSearches.add(TestCommon.toInitHotSearch("BK0734","珠宝首饰",TestCommon.toInitFloat(),true));
|
|
|
- // hotSearches.add(TestCommon.toInitHotSearch("BK0471","化纤行业",TestCommon.toInitFloat(),true));
|
|
|
- // hotSearches.add(TestCommon.toInitHotSearch("BK0485","旅游酒店",TestCommon.toInitFloat(),true));
|
|
|
- // hotSearches.add(TestCommon.toInitHotSearch("BK0475","银行",TestCommon.toInitFloat(),false));
|
|
|
- // hotSearches.add(TestCommon.toInitHotSearch("BK0473","券商信托",TestCommon.toInitFloat(),false));
|
|
|
- // hotSearches.add(TestCommon.toInitHotSearch("BK0474","保险",Float.valueOf("0.0"),true));
|
|
|
- // hotSearches.add(TestCommon.toInitHotSearch("BK0478","有色金属",Float.valueOf("0.0"),true));
|
|
|
- // return hotSearches;
|
|
|
+ public IndustryDetailsInfo hisFind(List<String> ids) {
|
|
|
+ return toDetailsByPlateId(ids,false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public IndustryDetailsInfo predictFind(List<String> ids) {
|
|
|
- for (String id : ids) {
|
|
|
- // 上周的每一天,下周的每一天。
|
|
|
- // toIncInfos();
|
|
|
- }
|
|
|
+ return toDetailsByPlateId(ids,true);
|
|
|
+
|
|
|
+ // List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
+ //
|
|
|
+ // industryDetails.add(TestCommon.toInitIndustryDetail("BK0422","2020-07-17",
|
|
|
+ // null,TestCommon.toInitFloat()));
|
|
|
+ // industryDetails.add(TestCommon.toInitIndustryDetail("BK0738","2020-06-22",
|
|
|
+ // null,TestCommon.toInitFloat()));
|
|
|
+ // industryDetails.add(TestCommon.toInitIndustryDetail("BK450","2020-05-22",
|
|
|
+ // null,TestCommon.toInitFloat()));
|
|
|
+ // industryDetails.add(TestCommon.toInitIndustryDetail("BK0734","2020-04-22",
|
|
|
+ // null,TestCommon.toInitFloat()));
|
|
|
+ // industryDetails.add(TestCommon.toInitIndustryDetail("BK0471","2020-03-22",
|
|
|
+ // null,TestCommon.toInitFloat()));
|
|
|
+ // industryDetails.add(TestCommon.toInitIndustryDetail("BK0422","2020-07-10",
|
|
|
+ // TestCommon.toInitFloat(),TestCommon.toInitFloat()));
|
|
|
+ // industryDetails.add(TestCommon.toInitIndustryDetail("BK0738","2020-06-15",
|
|
|
+ // TestCommon.toInitFloat(),TestCommon.toInitFloat()));
|
|
|
+ // industryDetails.add(TestCommon.toInitIndustryDetail("BK450","2020-05-15",
|
|
|
+ // TestCommon.toInitFloat(),TestCommon.toInitFloat()));
|
|
|
+ // industryDetails.add(TestCommon.toInitIndustryDetail("BK0734","2020-04-15",
|
|
|
+ // TestCommon.toInitFloat(),TestCommon.toInitFloat()));
|
|
|
+ // industryDetails.add(TestCommon.toInitIndustryDetail("BK0471","2020-03-15",
|
|
|
+ // TestCommon.toInitFloat(),TestCommon.toInitFloat()));
|
|
|
+ // SearchInfo searchInfo = SearchInfo.builder()
|
|
|
+ // .searchParam(ids.get(0))
|
|
|
+ // .build();
|
|
|
+ // List<NewsList> newsLists = newsService.newsDetails(searchInfo);
|
|
|
+ // IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
|
|
|
+ // .actuals(industryDetails)
|
|
|
+ // .news(newsLists)
|
|
|
+ // .tag(true)
|
|
|
+ // .build();
|
|
|
+
|
|
|
// List<IndustryInfo> hisInfos = new ArrayList<>();
|
|
|
// // 07-23 日期加七天。
|
|
|
// hisInfos.add(TestCommon.toInitIndustryDetail("8370003","2020-07-17",Float.valueOf(""),43.27F));
|
|
@@ -175,32 +155,61 @@ public class SearchServiceImpl implements SearchService {
|
|
|
// hisInfos.add(TestCommon.toInitIndustryDetail("8370008","2020-07-22",Float.valueOf(""),45.27F));
|
|
|
// hisInfos.add(TestCommon.toInitIndustryDetail("8370009","2020-07-23",Float.valueOf(""),46.27F));
|
|
|
// return hisInfos;
|
|
|
+ // return industryInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据行业id获取详情或者未来七天预测接口
|
|
|
+ * @param ids
|
|
|
+ * @param detailsFlag
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IndustryDetailsInfo toDetailsByPlateId(List<String> ids,Boolean detailsFlag){
|
|
|
+ // todo 根据id进入详情,计算值。包含下周预测。
|
|
|
List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
+ for (String id : ids) {
|
|
|
+ // 上周的每一天,下周的每一天。
|
|
|
+ // toIncInfos();
|
|
|
+ // 1、根据plateid、platename查询出该行业的所有信息。按照日期倒序排序,获取该时间,然后得出该时间的一周内每天的数据。
|
|
|
+ // 实际数据也即本周数据。
|
|
|
+ QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+ industryPlateQueryWrapper.lambda()
|
|
|
+ .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));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 创建detail列表
|
|
|
+ for (IndustryPlate industryPlate : industryPlates) {
|
|
|
+ industryDetails.add(toIndustryDetail(industryPlate));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- industryDetails.add(TestCommon.toInitIndustryDetail("BK0422","2020-07-17",
|
|
|
- null,TestCommon.toInitFloat()));
|
|
|
- industryDetails.add(TestCommon.toInitIndustryDetail("BK0738","2020-06-22",
|
|
|
- null,TestCommon.toInitFloat()));
|
|
|
- industryDetails.add(TestCommon.toInitIndustryDetail("BK450","2020-05-22",
|
|
|
- null,TestCommon.toInitFloat()));
|
|
|
- industryDetails.add(TestCommon.toInitIndustryDetail("BK0734","2020-04-22",
|
|
|
- null,TestCommon.toInitFloat()));
|
|
|
- industryDetails.add(TestCommon.toInitIndustryDetail("BK0471","2020-03-22",
|
|
|
- null,TestCommon.toInitFloat()));
|
|
|
- industryDetails.add(TestCommon.toInitIndustryDetail("BK0422","2020-07-10",
|
|
|
- TestCommon.toInitFloat(),TestCommon.toInitFloat()));
|
|
|
- industryDetails.add(TestCommon.toInitIndustryDetail("BK0738","2020-06-15",
|
|
|
- TestCommon.toInitFloat(),TestCommon.toInitFloat()));
|
|
|
- industryDetails.add(TestCommon.toInitIndustryDetail("BK450","2020-05-15",
|
|
|
- TestCommon.toInitFloat(),TestCommon.toInitFloat()));
|
|
|
- industryDetails.add(TestCommon.toInitIndustryDetail("BK0734","2020-04-15",
|
|
|
- TestCommon.toInitFloat(),TestCommon.toInitFloat()));
|
|
|
- industryDetails.add(TestCommon.toInitIndustryDetail("BK0471","2020-03-15",
|
|
|
- TestCommon.toInitFloat(),TestCommon.toInitFloat()));
|
|
|
+ // 4、附带新闻数据。
|
|
|
SearchInfo searchInfo = SearchInfo.builder()
|
|
|
.searchParam(ids.get(0))
|
|
|
.build();
|
|
|
List<NewsList> newsLists = newsService.newsDetails(searchInfo);
|
|
|
+
|
|
|
IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
|
|
|
.actuals(industryDetails)
|
|
|
.news(newsLists)
|
|
@@ -209,49 +218,107 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return industryInfo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建每一天的close、pred值。
|
|
|
+ * @param industryPlate
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IndustryDetail toIndustryDetail(IndustryPlate industryPlate){
|
|
|
+ IndustryDetail industryDetail = IndustryDetail.builder()
|
|
|
+ .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);
|
|
|
+ QueryWrapper<IndustryPlate> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlate::getPlateId,id)
|
|
|
+ .between(IndustryPlate::getPlateDate,monday,sunday);
|
|
|
+ List<IndustryPlate> industryPlates = industryPlateMapper.selectList(queryWrapper);
|
|
|
+ return industryPlates;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<IncInfo> incLastWeek() {
|
|
|
- return toIncInfos(true,false,false);
|
|
|
+ return toIncInfos(true,false,false,false,null);
|
|
|
// return TestCommon.getIncList();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> incNextWeekPred() {
|
|
|
- return toIncInfos(true,false,true);
|
|
|
+ return toIncInfos(true,false,true,false,null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> incLastWeekPred() {
|
|
|
- return toIncInfos(true,true,false);
|
|
|
+ return toIncInfos(true,true,false,false,null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> decLastWeek() {
|
|
|
- return toIncInfos(false,false,false);
|
|
|
+ return toIncInfos(false,false,false,false,null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> decNextWeekPred() {
|
|
|
- return toIncInfos(false,false,true);
|
|
|
+ return toIncInfos(false,false,true,false,null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> decLastWeekPred() {
|
|
|
- return toIncInfos(false,true,false);
|
|
|
+ return toIncInfos(false,true,false,false,null);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<IncInfo> toIncInfos(Boolean tag,Boolean lastTag,Boolean nextTag){
|
|
|
- QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- // 涨幅跌幅。上周周五的close-上上上周五的close >0涨 <0跌
|
|
|
- // industryInfoQueryWrapper.eq("tag",tag);
|
|
|
- industryInfoQueryWrapper.isNotNull("id");
|
|
|
- List<IndustryInfo> industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
+ /**
|
|
|
+ * 涨幅/跌幅的实际/预测榜方法。
|
|
|
+ * @param tag
|
|
|
+ * @param lastTag
|
|
|
+ * @param nextTag
|
|
|
+ * @param ifIncDec
|
|
|
+ * @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);
|
|
|
+ }else {
|
|
|
+ QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ // 涨幅跌幅。上周周五的close-上上上周五的close >0涨 <0跌
|
|
|
+ // industryInfoQueryWrapper.eq("tag",tag);
|
|
|
+ industryInfoQueryWrapper.isNotNull("id");
|
|
|
+ industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
+ }
|
|
|
|
|
|
IncInfo incInfo;
|
|
|
List<IncInfo> incInfos = new ArrayList<>();
|
|
|
for (IndustryInfo industryInfo : industryInfos) {
|
|
|
- Map<String,Object> actualMap = TestCommon.calWeek(TestCommon.getWeek(),false);
|
|
|
+ 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());
|
|
@@ -292,6 +359,10 @@ public class SearchServiceImpl implements SearchService {
|
|
|
log.info("sort info:{}",JSON.toJSONString(sortLists));
|
|
|
// 去除跌幅榜或者涨幅榜。
|
|
|
log.info("tag :{}",tag);
|
|
|
+ if (ifIncDec.equals(true)){
|
|
|
+ log.info("涨跌幅:{}",JSON.toJSONString(sortLists));
|
|
|
+ return sortLists;
|
|
|
+ }
|
|
|
if (tag.equals(true)){
|
|
|
// 涨幅:
|
|
|
sortLists.removeIf(s -> s.getIndustryTag().equals(false));
|
|
@@ -342,10 +413,13 @@ public class SearchServiceImpl implements SearchService {
|
|
|
log.info("calLastWeekActual 上周五:{}",friday);
|
|
|
log.info("calLastWeekActual 上上周五:{}",lastFriday);
|
|
|
List<IndustryPlate> industryPlatesLast = getClose(plateId,lastFriday);
|
|
|
- Float close = industryPlates.get(0).getPlateClose();
|
|
|
- Float lastClose = industryPlatesLast.get(0).getPlateClose();
|
|
|
- Float value = close - lastClose;
|
|
|
- return value;
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -388,6 +462,12 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取N周五的收盘价。
|
|
|
+ * @param plateId
|
|
|
+ * @param friday
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public List<IndustryPlate> getClose(String plateId,String friday){
|
|
|
log.info("sel industryplate:{}",plateId +"," + friday);
|
|
|
QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|