|
@@ -2,6 +2,8 @@ package com.pavis.ai.app.fda.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
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;
|
|
@@ -10,6 +12,7 @@ import com.pavis.ai.app.fda.form.inc.IncInfo;
|
|
|
import com.pavis.ai.app.fda.form.news.NewsList;
|
|
|
import com.pavis.ai.app.fda.form.search.HotSearch;
|
|
|
import com.pavis.ai.app.fda.form.search.SearchInfo;
|
|
|
+import com.pavis.ai.app.fda.form.sel.QueryForm;
|
|
|
import com.pavis.ai.app.fda.mapper.IndustryInfoMapper;
|
|
|
import com.pavis.ai.app.fda.mapper.IndustryPlateMapper;
|
|
|
import com.pavis.ai.app.fda.mapper.IndustryStockMapper;
|
|
@@ -50,6 +53,11 @@ public class SearchServiceImpl implements SearchService {
|
|
|
@Autowired
|
|
|
private NewsService newsService;
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<IncInfo> incLastWeekPage() {
|
|
|
+ return toIncInfosPage(true, false, false, false, null);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<IncInfo> search(SearchInfo searchInfo) {
|
|
|
return toIncInfos(true, false, false, true, searchInfo);
|
|
@@ -158,6 +166,37 @@ public class SearchServiceImpl implements SearchService {
|
|
|
// return industryInfo;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<IncInfo> incLastWeek() {
|
|
|
+ return toIncInfos(true, false, false, false, null);
|
|
|
+ // return TestCommon.getIncList();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IncInfo> incNextWeekPred() {
|
|
|
+ return toIncInfos(true, false, true, false, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IncInfo> incLastWeekPred() {
|
|
|
+ return toIncInfos(true, true, false, false, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IncInfo> decLastWeek() {
|
|
|
+ return toIncInfos(false, false, false, false, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IncInfo> decNextWeekPred() {
|
|
|
+ return toIncInfos(false, false, true, false, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IncInfo> decLastWeekPred() {
|
|
|
+ return toIncInfos(false, true, false, false, null);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据行业id获取详情或者未来七天预测接口
|
|
|
*
|
|
@@ -277,38 +316,90 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return industryPlates;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<IncInfo> incLastWeek() {
|
|
|
- return toIncInfos(true, false, false, false, null);
|
|
|
- // return TestCommon.getIncList();
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public List<IncInfo> incNextWeekPred() {
|
|
|
- return toIncInfos(true, false, true, false, null);
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public List<IncInfo> incLastWeekPred() {
|
|
|
- return toIncInfos(true, true, false, false, null);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<IncInfo> decLastWeek() {
|
|
|
- return toIncInfos(false, false, false, false, null);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<IncInfo> decNextWeekPred() {
|
|
|
- return toIncInfos(false, false, true, false, null);
|
|
|
- }
|
|
|
+ public List<IncInfo> toIncInfosPage(Boolean tag, Boolean lastTag, Boolean nextTag, Boolean ifIncDec, SearchInfo searchInfo) {
|
|
|
+ IncInfo incInfo;
|
|
|
+ List<IncInfo> incInfos = new ArrayList<>();
|
|
|
+ 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<>();
|
|
|
+ IPage<IndustryPlate> industryPlateIPage = null;
|
|
|
+ if (ifIncDec.equals(true)) {
|
|
|
+ // industryPlateIPage = searchIndustryPlate(searchInfo,friday,lastFriday);
|
|
|
+ }else {
|
|
|
+ // plates = findIndustryPlate(true, null,friday , lastFriday);
|
|
|
+ QueryForm queryForm = new QueryForm();
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
+ queryForm.setFriday(lastFriday);
|
|
|
+ queryForm.setLastFriday(friday);
|
|
|
+ }else {
|
|
|
+ queryForm.setFriday(friday);
|
|
|
+ queryForm.setLastFriday(lastFriday);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public List<IncInfo> decLastWeekPred() {
|
|
|
- return toIncInfos(false, true, false, false, null);
|
|
|
+ Page<IndustryPlate> page = new Page<>();
|
|
|
+ page.setCurrent(0L);
|
|
|
+ page.setSize(3);
|
|
|
+ industryPlateIPage = industryPlateMapper.findIndustryPlate(page, queryForm);
|
|
|
+ }
|
|
|
+ for (IndustryPlate plate : industryPlateIPage.getRecords()) {
|
|
|
+ Float value = calLastWeekActual(date,plate.getPlateId());
|
|
|
+ if (lastTag) {
|
|
|
+ value = calLastWeekPred(date,plate.getPlateId());
|
|
|
+ }
|
|
|
+ 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 = 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("tag :{}", tag);
|
|
|
+ if (ifIncDec.equals(true)) {
|
|
|
+ log.info("涨跌幅:{}", JSON.toJSONString(sortLists));
|
|
|
+ return sortLists;
|
|
|
+ }
|
|
|
+ if (tag.equals(true)) {
|
|
|
+ // 涨幅:
|
|
|
+ sortLists.removeIf(s -> s.getIndustryTag().equals(false));
|
|
|
+ log.info("涨幅:{}", JSON.toJSONString(sortLists));
|
|
|
+ return sortLists;
|
|
|
+ } 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));
|
|
|
+ return sortLists;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 涨幅/跌幅的实际/预测榜方法。
|
|
|
*
|