|
@@ -14,10 +14,7 @@ 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.*;
|
|
|
-import com.pavis.ai.app.fda.model.IndustryInfo;
|
|
|
-import com.pavis.ai.app.fda.model.IndustryPlate;
|
|
|
-import com.pavis.ai.app.fda.model.IndustryPlateSum;
|
|
|
-import com.pavis.ai.app.fda.model.SearchCount;
|
|
|
+import com.pavis.ai.app.fda.model.*;
|
|
|
import com.pavis.ai.app.fda.service.NewsService;
|
|
|
import com.pavis.ai.app.fda.service.SearchService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -45,7 +42,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
private IndustryPlateMapper industryPlateMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- private IndustryStockMapper industryStockMapper;
|
|
|
+ private IndustryPlateResMapper industryPlateResMapper;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@@ -61,7 +58,8 @@ 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);
|
|
|
+ return toSearch(searchInfo);
|
|
|
// QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper();
|
|
|
// industryInfoQueryWrapper.lambda()
|
|
|
// .eq(IndustryInfo::getPlateId, searchInfo.getSearchParam())
|
|
@@ -113,14 +111,18 @@ public class SearchServiceImpl implements SearchService {
|
|
|
// return incInfos;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public IndustryDetailsInfo hisFind(List<String> ids) {
|
|
|
- return toDetailsByPlateId(ids, false);
|
|
|
+ // return toDetailsByPlateId(ids, false);
|
|
|
+ return toFindDetailsByPlateId(ids, false);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public IndustryDetailsInfo predictFind(List<String> ids) {
|
|
|
- return toDetailsByPlateId(ids, true);
|
|
|
+ // return toDetailsByPlateId(ids, true);
|
|
|
+ return toFindDetailsByPlateId(ids, true);
|
|
|
|
|
|
// List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
//
|
|
@@ -167,6 +169,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
// return industryInfo;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public IndustryDetailsInfo hisHushenSum() {
|
|
|
return toHisHushenSum();
|
|
@@ -174,146 +177,41 @@ public class SearchServiceImpl implements SearchService {
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> incLastWeek() {
|
|
|
- return toIncInfos(true, false, false, false, null);
|
|
|
- // return TestCommon.getIncList();
|
|
|
+ // return toIncInfos(true, false, false, false, null);
|
|
|
+ return lastWeekActual(true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> incNextWeekPred() {
|
|
|
- return toIncInfos(true, false, true, false, null);
|
|
|
+ // return toIncInfos(true, false, true, false, null);
|
|
|
+ return weekPred(true, false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> incLastWeekPred() {
|
|
|
- return toIncInfos(true, true, false, false, null);
|
|
|
+ // return toIncInfos(true, true, false, false, null);
|
|
|
+ return weekPred(true, true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> decLastWeek() {
|
|
|
- return toIncInfos(false, false, false, false, null);
|
|
|
+ // return toIncInfos(false, false, false, false, null);
|
|
|
+ return lastWeekActual(false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> decNextWeekPred() {
|
|
|
- return toIncInfos(false, false, true, false, null);
|
|
|
+ // return toIncInfos(false, false, true, false, null);
|
|
|
+ return weekPred(false, false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<IncInfo> decLastWeekPred() {
|
|
|
- return toIncInfos(false, true, false, false, null);
|
|
|
+ // return toIncInfos(false, true, false, false, null);
|
|
|
+ return weekPred(false, true);
|
|
|
}
|
|
|
|
|
|
- public List<IndustryPlateSum> toPlateSums(String monday,String sunday){
|
|
|
- QueryWrapper<IndustryPlateSum> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
- if (DateUtils.checkDate(monday,sunday).equals(true)) {
|
|
|
- industryPlateQueryWrapper.lambda()
|
|
|
- .orderByDesc(IndustryPlateSum::getPlateDate)
|
|
|
- .between(IndustryPlateSum::getPlateDate,sunday,monday)
|
|
|
- .last("limit 0,5");
|
|
|
- }else {
|
|
|
- industryPlateQueryWrapper.lambda()
|
|
|
- .orderByDesc(IndustryPlateSum::getPlateDate)
|
|
|
- .between(IndustryPlateSum::getPlateDate,monday,sunday)
|
|
|
- .last("limit 0,5");
|
|
|
- }
|
|
|
|
|
|
- List<IndustryPlateSum> industryPlateSums = industryPlateSumMapper.selectList(industryPlateQueryWrapper);
|
|
|
- return industryPlateSums;
|
|
|
- }
|
|
|
- public IndustryDetail initDetail(IndustryPlateSum nextPlatesNum){
|
|
|
- IndustryDetail industryDetail = IndustryDetail.builder()
|
|
|
- .industryId(nextPlatesNum.getId())
|
|
|
- .industryDate(nextPlatesNum.getPlateDate())
|
|
|
- .close(nextPlatesNum.getPlateClose())
|
|
|
- .pred(nextPlatesNum.getPlateClosePred())
|
|
|
- .build();
|
|
|
- return industryDetail;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 沪深接口。
|
|
|
- * @return
|
|
|
- */
|
|
|
- public IndustryDetailsInfo toHisHushenSum(){
|
|
|
- QueryWrapper<IndustryPlateSum> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
- industryPlateQueryWrapper.lambda()
|
|
|
- .orderByDesc(IndustryPlateSum::getPlateDate)
|
|
|
- .last("limit 0,5");
|
|
|
- List<IndustryPlateSum> industryPlateSums = industryPlateSumMapper.selectList(industryPlateQueryWrapper);
|
|
|
- String date = industryPlateSums.size() > 0 ? industryPlateSums.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
- Map<String,Object> weekMap = DateUtils.getEverydayByActual(date);
|
|
|
- String monday = weekMap.get("MONDAY").toString();
|
|
|
- String sunday = weekMap.get("SUNDAY").toString();
|
|
|
- List<IndustryPlateSum> plateSums = toPlateSums(monday, sunday);
|
|
|
- log.info("沪深 实际:{}",JSON.toJSONString(plateSums));
|
|
|
-
|
|
|
- Map<String, Object> nextWeekMap = DateUtils.getEverydayOfNexWeek(date);
|
|
|
- String nextMonday = nextWeekMap.get("monday").toString();
|
|
|
- String nextSunday = nextWeekMap.get("sunday").toString();
|
|
|
- List<IndustryPlateSum> nextPlatesNums = toPlateSums(nextMonday, nextSunday);
|
|
|
- log.info("沪深 预测:{}",JSON.toJSONString(nextPlatesNums));
|
|
|
-
|
|
|
- List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
- List<IndustryDetail> nextIndustryDetails = new ArrayList<>();
|
|
|
- for (IndustryPlateSum nextPlatesNum : nextPlatesNums) {
|
|
|
- // 预测在上方,实际在下方。
|
|
|
- nextIndustryDetails.add(initDetail(nextPlatesNum));
|
|
|
- }
|
|
|
- for (IndustryPlateSum industryPlateSum : plateSums) {
|
|
|
- // 预测在上方,实际在下方。
|
|
|
- industryDetails.add(initDetail(industryPlateSum));
|
|
|
- }
|
|
|
-
|
|
|
- IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
|
|
|
- .actuals(industryDetails)
|
|
|
- .news(new ArrayList<>())
|
|
|
- // todo 此处是涨还是跌???????????????
|
|
|
- .tag(true)
|
|
|
- .build();
|
|
|
- return industryInfo;
|
|
|
-
|
|
|
- // String date = industryPlateSums.size() > 0 ? industryPlateSums.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
- // log.info("实际数据日期:{}", date);
|
|
|
- // // 2、近五天数据日期计算。
|
|
|
- // Map<String, Object> weekMap = DateUtils.getEverydayByActual(date);
|
|
|
- // String monday = weekMap.get("MONDAY").toString();
|
|
|
- // String sunday = weekMap.get("SUNDAY").toString();
|
|
|
- // List<IndustryPlate> industryPlates = toIndustryPlates("", monday, sunday);
|
|
|
- // // 3、下周预测放上面,实际数据放下面。
|
|
|
- // // List<Float> closes = new ArrayList<>();
|
|
|
- // // List<Float> closePreds = new ArrayList<>();
|
|
|
- // // for (IndustryPlate industryPlate : industryPlates) {
|
|
|
- // // closes.add(industryPlate.getPlateClose());
|
|
|
- // // closePreds.add(industryPlate.getPlateClosePred());
|
|
|
- // // }
|
|
|
- // List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
- // IndustryDetail industryDetail;
|
|
|
- // for (IndustryPlate industryPlate : industryPlates) {
|
|
|
- // QueryWrapper<IndustryPlate> queryWrapper = new QueryWrapper<>();
|
|
|
- // industryPlateQueryWrapper.lambda()
|
|
|
- // .eq(IndustryPlate::getPlateId,industryPlate.getPlateId())
|
|
|
- // .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
- // .last("limit 0,10");
|
|
|
- // List<IndustryPlate> sumIndustryPlates = industryPlateMapper.selectList(queryWrapper);
|
|
|
- // Double close = 0.0;
|
|
|
- // Double closePred = 0.0;
|
|
|
- // if (sumIndustryPlates.size() > 0){
|
|
|
- // close = sumIndustryPlates.stream().filter(s -> null != s.getPlateClose())
|
|
|
- // .mapToDouble(IndustryPlate::getPlateClose).sum();
|
|
|
- // closePred = sumIndustryPlates.stream().filter(s -> null != s.getPlateClosePred())
|
|
|
- // .mapToDouble(IndustryPlate::getPlateClosePred).sum();
|
|
|
- // }
|
|
|
- // industryDetail = IndustryDetail.builder()
|
|
|
- // .industryId("")
|
|
|
- // .industryDate(industryPlate.getPlateDate())
|
|
|
- // .close(Float.valueOf(close.toString()))
|
|
|
- // .pred(Float.valueOf(closePred.toString()))
|
|
|
- // .build();
|
|
|
- //
|
|
|
- // industryDetails.add(industryDetail);
|
|
|
- // }
|
|
|
-
|
|
|
- // return industryDetails;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 根据行业id获取详情或者未来七天预测接口
|
|
@@ -404,6 +302,16 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return industryDetail;
|
|
|
}
|
|
|
|
|
|
+ public IndustryDetail toInitIndustryDetail(IndustryPlateRes industryPlate) {
|
|
|
+ IndustryDetail industryDetail = IndustryDetail.builder()
|
|
|
+ .industryId(industryPlate.getPlateId())
|
|
|
+ .industryDate(industryPlate.getPlateDate())
|
|
|
+ .close(industryPlate.getPlateClose())
|
|
|
+ .pred(industryPlate.getPlateClosePred())
|
|
|
+ .build();
|
|
|
+ return industryDetail;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据plateid、周一至周日的期间获取每一天的close pred值。
|
|
|
*
|
|
@@ -442,13 +350,44 @@ public class SearchServiceImpl implements SearchService {
|
|
|
List<IndustryPlate> industryPlates = industryPlateMapper.selectList(queryWrapper);
|
|
|
return industryPlates;
|
|
|
}
|
|
|
+ public List<IndustryPlateRes> toIndustryPlateRes(String id, String monday, String sunday) {
|
|
|
+ log.info("详情查询:{}", id + ",monday:" + monday + ",sunday:" + sunday);
|
|
|
+
|
|
|
+ QueryWrapper<IndustryPlateRes> queryWrapper = new QueryWrapper<>();
|
|
|
+ if (id.equals("")){
|
|
|
+ if (DateUtils.checkDate(monday,sunday).equals(true)){
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate)
|
|
|
+ .between(IndustryPlateRes::getPlateDate, sunday,monday );
|
|
|
+ }else {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate)
|
|
|
+ .between(IndustryPlateRes::getPlateDate, monday, sunday);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (DateUtils.checkDate(monday,sunday).equals(true)){
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlateRes::getPlateId, id)
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate)
|
|
|
+ .between(IndustryPlateRes::getPlateDate, sunday,monday );
|
|
|
+ }else {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlateRes::getPlateId, id)
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate)
|
|
|
+ .between(IndustryPlateRes::getPlateDate, monday, sunday);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<IndustryPlateRes> industryPlates = industryPlateResMapper.selectList(queryWrapper);
|
|
|
+ return industryPlates;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
+ // List<IndustryPlate> datePlates = getNewest();
|
|
|
+ List<IndustryPlateRes> 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();
|
|
@@ -540,40 +479,41 @@ public class SearchServiceImpl implements SearchService {
|
|
|
public List<IncInfo> toIncInfos(Boolean tag, Boolean lastTag, Boolean nextTag, Boolean ifIncDec, SearchInfo searchInfo) {
|
|
|
// 跌幅 上周实际榜:
|
|
|
// 1、拿到数据库中倒叙排序的最新的日期。根据当前日期判断是否是周六,是 本周的和上周的数据。否则上周和上上周的数据。
|
|
|
- List<IndustryPlate> datePlates = getNewest();
|
|
|
+ // List<IndustryPlate> datePlates = getNewest();
|
|
|
+ List<IndustryPlateRes> 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<>();
|
|
|
+ List<IndustryPlateRes> plates = new ArrayList<>();
|
|
|
if (ifIncDec.equals(true)) {
|
|
|
- plates = searchIndustryPlate(searchInfo,friday,lastFriday);
|
|
|
+ plates = searchIndustryPlateRes(searchInfo,friday,lastFriday);
|
|
|
}else {
|
|
|
- plates = findIndustryPlate(true, null,friday , lastFriday);
|
|
|
+ plates = findIndustryPlateRes(true, null,friday , lastFriday);
|
|
|
}
|
|
|
|
|
|
// 3、tag涨跌true/false过滤
|
|
|
IncInfo incInfo;
|
|
|
List<IncInfo> incInfos = new ArrayList<>();
|
|
|
- QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
- industryPlateQueryWrapper.eq("plate_id", null);
|
|
|
+ // 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());
|
|
|
+ plates = findIndustryPlateRes(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("nextFriday").toString());
|
|
|
+ plates = findIndustryPlateRes(false, null, map.get("friday").toString(), map.get("nextFriday").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) {
|
|
|
+ for (IndustryPlateRes plate : plates) {
|
|
|
Float value = calLastWeekActual(date,plate.getPlateId());
|
|
|
if (lastTag) {
|
|
|
value = calLastWeekPred(date,plate.getPlateId());
|
|
@@ -613,6 +553,8 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return sortLists;
|
|
|
}
|
|
|
if (tag.equals(true)) {
|
|
|
+ // 涨幅:倒叙取前十。
|
|
|
+ // 跌幅:正序取前十。
|
|
|
// 涨幅:
|
|
|
sortLists.removeIf(s -> s.getIndustryTag().equals(false));
|
|
|
log.info("涨幅:{}", JSON.toJSONString(sortLists));
|
|
@@ -662,6 +604,33 @@ public class SearchServiceImpl implements SearchService {
|
|
|
log.info("search plates:{}",JSON.toJSONString(plates));
|
|
|
return plates;
|
|
|
}
|
|
|
+ public List<IndustryPlateRes> searchIndustryPlateRes(SearchInfo searchInfo,String friday,String lastFriday){
|
|
|
+ List<IndustryPlateRes> plates = new ArrayList<>();
|
|
|
+ // 涨跌均存在。根据行业id查询进来的。
|
|
|
+ QueryWrapper<IndustryPlateRes> queryWrapper = new QueryWrapper();
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)){
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlateRes::getPlateId, searchInfo.getSearchParam())
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate, lastFriday, friday)
|
|
|
+ .last("limit 0,10")
|
|
|
+ .or()
|
|
|
+ .like(IndustryPlateRes::getPlateName, searchInfo.getSearchParam());
|
|
|
+ }else {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlateRes::getPlateId, searchInfo.getSearchParam())
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate, friday, lastFriday)
|
|
|
+ .last("limit 0,10")
|
|
|
+ .or()
|
|
|
+ .like(IndustryPlateRes::getPlateName, searchInfo.getSearchParam());
|
|
|
+ }
|
|
|
+ plates = industryPlateResMapper.selectList(queryWrapper);
|
|
|
+ log.info("search plates:{}",JSON.toJSONString(plates));
|
|
|
+ return plates;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 查询,上周实际,上周预测,下周预测。
|
|
@@ -692,6 +661,26 @@ public class SearchServiceImpl implements SearchService {
|
|
|
List<IndustryPlate> plates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
return plates;
|
|
|
}
|
|
|
+ public List<IndustryPlateRes> findIndustryPlateRes(Boolean just, String plateId, String friday, String lastFriday) {
|
|
|
+ QueryWrapper<IndustryPlateRes> queryWrapper = new QueryWrapper<>();
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)){
|
|
|
+ queryWrapper.between("plate_date", lastFriday, friday);
|
|
|
+ }else {
|
|
|
+ queryWrapper.between("plate_date", friday, lastFriday);
|
|
|
+ }
|
|
|
+ queryWrapper.groupBy("plate_id");
|
|
|
+ queryWrapper.isNotNull("plate_id");
|
|
|
+ queryWrapper.last("limit 0,10");
|
|
|
+ if (just.equals(false)) {
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)){
|
|
|
+ queryWrapper.between("plate_date", lastFriday, friday);
|
|
|
+ }else {
|
|
|
+ queryWrapper.between("plate_date", friday, lastFriday);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<IndustryPlateRes> plates = industryPlateResMapper.selectList(queryWrapper);
|
|
|
+ return plates;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 上周实际榜。
|
|
@@ -783,10 +772,499 @@ public class SearchServiceImpl implements SearchService {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<IndustryPlate> getNewest() {
|
|
|
- QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+ // public List<IndustryPlate> getNewest() {
|
|
|
+ // QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+ // industryPlateQueryWrapper.lambda()
|
|
|
+ // .orderByDesc(IndustryPlate::getPlateDate);
|
|
|
+ // return industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
+ // }
|
|
|
+ public List<IndustryPlateRes> getNewest() {
|
|
|
+ QueryWrapper<IndustryPlateRes> industryPlateResQueryWrapper = new QueryWrapper<>();
|
|
|
+ industryPlateResQueryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate);
|
|
|
+ return industryPlateResMapper.selectList(industryPlateResQueryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 涨/跌上周实际榜。
|
|
|
+ * @param incOrDec
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IncInfo> lastWeekActual(Boolean incOrDec){
|
|
|
+ // 1、根据日期倒序拿到数据库中的最新日期
|
|
|
+ Map<String,Object> actualMap = toDate();
|
|
|
+ // 1、根据当前日期判断是否是周六,是 本周的和上周的数据。否则上周和上上周的数据。
|
|
|
+ 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);
|
|
|
+ // 3、返回数据创建。
|
|
|
+ List<IncInfo> incInfos = toBackIncInfos(true,false,plateResList);
|
|
|
+ List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() > 0.0F)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return finalIncInfos;
|
|
|
+ }else {
|
|
|
+ plateResList = toActualIncOrDec(incOrDec,friday,lastFriday);
|
|
|
+ // 3、返回数据创建。
|
|
|
+ List<IncInfo> incInfos = toBackIncInfos(false,false,plateResList);
|
|
|
+ List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() < 0.0F)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return finalIncInfos;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取日期。
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String,Object> toDate(){
|
|
|
+ // 1、根据日期倒序拿到数据库中的最新日期
|
|
|
+ List<IndustryPlateRes> datePlates = getNewest();
|
|
|
+ String date = datePlates.size() > 0 ? datePlates.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
+ // 1.1 根据当前日期判断是否是周六,是 本周的和上周的数据。否则上周和上上周的数据。
|
|
|
+ Map<String,Object> actualMap = DateUtils.getFridayOrLastFriday(date);
|
|
|
+ return actualMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 涨跌实际榜查询函数。
|
|
|
+ * @param incOrDec
|
|
|
+ * @param friday
|
|
|
+ * @param lastFriday
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IndustryPlateRes> toActualIncOrDec(Boolean incOrDec,String friday,String lastFriday){
|
|
|
+ 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)
|
|
|
+ .last("limit 0,10");
|
|
|
+ }else {
|
|
|
+ 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)
|
|
|
+ .last("limit 0,10");
|
|
|
+ }else {
|
|
|
+ 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));
|
|
|
+ return plates;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 周预测:上周或者下周预测
|
|
|
+ * @param lastOrNext
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IncInfo> weekPred(Boolean incOrDec,Boolean lastOrNext){
|
|
|
+ // 1、根据日期倒序拿到数据库中的最新日期
|
|
|
+ List<IndustryPlateRes> datePlates = getNewest();
|
|
|
+ String date = datePlates.size() > 0 ? datePlates.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
+ // 2、检索出符合要求的数据。
|
|
|
+ List<IndustryPlateRes> plates = new ArrayList<>();
|
|
|
+ if(lastOrNext.equals(true)){
|
|
|
+ // 上周预测。
|
|
|
+ Map<String, Object> map = DateUtils.getFridayOrLastFriday(date);
|
|
|
+ plates = toPredLastOrNext(incOrDec,map.get("friday").toString(),map.get("lastFriday").toString());
|
|
|
+ if (incOrDec.equals(true)){
|
|
|
+ // 3、创建返回值。
|
|
|
+ List<IncInfo> incInfos = toBackIncInfos(true,true,plates);
|
|
|
+ List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() > 0.0F)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return finalIncInfos;
|
|
|
+ }else {
|
|
|
+ List<IncInfo> incInfos = toBackIncInfos(false,true,plates);
|
|
|
+ List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() < 0.0F)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return finalIncInfos;
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ Map<String, Object> map = DateUtils.getEverydayOfNexWeek(date);
|
|
|
+ plates = toPredLastOrNext(incOrDec,map.get("friday").toString(),map.get("nextFriday").toString());
|
|
|
+ // 3、创建返回值。
|
|
|
+ if (incOrDec.equals(true)){
|
|
|
+ // 3、创建返回值。
|
|
|
+ List<IncInfo> incInfos = toBackIncInfos(incOrDec,true,plates);
|
|
|
+ List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() > 0.0F)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return finalIncInfos;
|
|
|
+ }else {
|
|
|
+ List<IncInfo> incInfos = toBackIncInfos(incOrDec,true,plates);
|
|
|
+ List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() < 0.0F)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return finalIncInfos;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 返回信息创建接口。
|
|
|
+ // * @param incOrDec 涨幅跌幅
|
|
|
+ * @param actualOrPred 实际or预测
|
|
|
+ * @param plates 列表。
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IncInfo> toBackIncInfos(Boolean incOrDec,Boolean actualOrPred,List<IndustryPlateRes> plates){
|
|
|
+ // 3、返回数据创建。
|
|
|
+ IncInfo incInfo;
|
|
|
+ List<IncInfo> incInfos = new ArrayList<>();
|
|
|
+ for (IndustryPlateRes industryPlateRes : plates) {
|
|
|
+ Float actualVal = null != industryPlateRes.getPlateCloseUp() ?
|
|
|
+ industryPlateRes.getPlateCloseUp() : 0.0F;
|
|
|
+ Float predVal = null != industryPlateRes.getPlateClosePredUp() ?
|
|
|
+ industryPlateRes.getPlateClosePredUp() : 0.0F;
|
|
|
+ Float value = actualOrPred.equals(true) ? actualVal : predVal;
|
|
|
+ Boolean industryTag = value > 0.0F ? true : false;
|
|
|
+ incInfo = IncInfo.builder()
|
|
|
+ .industryId(industryPlateRes.getPlateId())
|
|
|
+ // .industryName(plate.getPlateName())
|
|
|
+ // todo 后期需要修改。
|
|
|
+ .industryName(industryPlateRes.getPlateName())
|
|
|
+ .industryValue(value)
|
|
|
+ .industryTag(incOrDec.equals(true) ? true : false)
|
|
|
+ .build();
|
|
|
+ incInfos.add(incInfo);
|
|
|
+ }
|
|
|
+ return incInfos;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 涨跌预测榜:上周or下周。函数。
|
|
|
+ * @param incOrDec
|
|
|
+ * @param friday
|
|
|
+ * @param lastFriday
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IndustryPlateRes> toPredLastOrNext(Boolean incOrDec,String friday,String lastFriday){
|
|
|
+ QueryWrapper<IndustryPlateRes> queryWrapper = new QueryWrapper<>();
|
|
|
+ if (incOrDec.equals(true)){
|
|
|
+ // 涨幅
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateClosePredUp)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
+ .last("limit 0,10");
|
|
|
+ }else {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateClosePredUp)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
+ .last("limit 0,10");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByAsc(IndustryPlateRes::getPlateClosePredUp)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
+ .last("limit 0,10");
|
|
|
+ }else {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByAsc(IndustryPlateRes::getPlateClosePredUp)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
+ .last("limit 0,10");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<IndustryPlateRes> plates = industryPlateResMapper.selectList(queryWrapper);
|
|
|
+ log.info("toPredLastOrNext plates:{}",JSON.toJSONString(plates));
|
|
|
+ return plates;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 沪深数据获取接口。
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IndustryDetailsInfo toHisHushenSum(){
|
|
|
+ QueryWrapper<IndustryPlateSum> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
industryPlateQueryWrapper.lambda()
|
|
|
- .orderByDesc(IndustryPlate::getPlateDate);
|
|
|
- return industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
+ .orderByDesc(IndustryPlateSum::getPlateDate)
|
|
|
+ .last("limit 0,5");
|
|
|
+ List<IndustryPlateSum> industryPlateSums = industryPlateSumMapper.selectList(industryPlateQueryWrapper);
|
|
|
+ String date = industryPlateSums.size() > 0 ? industryPlateSums.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
+ Map<String,Object> weekMap = DateUtils.getEverydayByActual(date);
|
|
|
+ String monday = weekMap.get("MONDAY").toString();
|
|
|
+ String sunday = weekMap.get("SUNDAY").toString();
|
|
|
+ List<IndustryPlateSum> plateSums = toPlateSums(monday, sunday);
|
|
|
+ log.info("沪深 实际:{}",JSON.toJSONString(plateSums));
|
|
|
+
|
|
|
+ Map<String, Object> nextWeekMap = DateUtils.getEverydayOfNexWeek(date);
|
|
|
+ String nextMonday = nextWeekMap.get("monday").toString();
|
|
|
+ String nextSunday = nextWeekMap.get("sunday").toString();
|
|
|
+ List<IndustryPlateSum> nextPlatesNums = toPlateSums(nextMonday, nextSunday);
|
|
|
+ log.info("沪深 预测:{}",JSON.toJSONString(nextPlatesNums));
|
|
|
+
|
|
|
+ List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
+ List<IndustryDetail> nextIndustryDetails = new ArrayList<>();
|
|
|
+ for (IndustryPlateSum nextPlatesNum : nextPlatesNums) {
|
|
|
+ // 预测在上方,实际在下方。
|
|
|
+ nextIndustryDetails.add(initDetail(nextPlatesNum));
|
|
|
+ }
|
|
|
+ for (IndustryPlateSum industryPlateSum : plateSums) {
|
|
|
+ // 预测在上方,实际在下方。
|
|
|
+ industryDetails.add(initDetail(industryPlateSum));
|
|
|
+ }
|
|
|
+
|
|
|
+ IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
|
|
|
+ .actuals(industryDetails)
|
|
|
+ .news(new ArrayList<>())
|
|
|
+ // todo 此处是涨还是跌???????????????
|
|
|
+ .tag(true)
|
|
|
+ .build();
|
|
|
+ return industryInfo;
|
|
|
+
|
|
|
+ // String date = industryPlateSums.size() > 0 ? industryPlateSums.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
+ // log.info("实际数据日期:{}", date);
|
|
|
+ // // 2、近五天数据日期计算。
|
|
|
+ // Map<String, Object> weekMap = DateUtils.getEverydayByActual(date);
|
|
|
+ // String monday = weekMap.get("MONDAY").toString();
|
|
|
+ // String sunday = weekMap.get("SUNDAY").toString();
|
|
|
+ // List<IndustryPlate> industryPlates = toIndustryPlates("", monday, sunday);
|
|
|
+ // // 3、下周预测放上面,实际数据放下面。
|
|
|
+ // // List<Float> closes = new ArrayList<>();
|
|
|
+ // // List<Float> closePreds = new ArrayList<>();
|
|
|
+ // // for (IndustryPlate industryPlate : industryPlates) {
|
|
|
+ // // closes.add(industryPlate.getPlateClose());
|
|
|
+ // // closePreds.add(industryPlate.getPlateClosePred());
|
|
|
+ // // }
|
|
|
+ // List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
+ // IndustryDetail industryDetail;
|
|
|
+ // for (IndustryPlate industryPlate : industryPlates) {
|
|
|
+ // QueryWrapper<IndustryPlate> queryWrapper = new QueryWrapper<>();
|
|
|
+ // industryPlateQueryWrapper.lambda()
|
|
|
+ // .eq(IndustryPlate::getPlateId,industryPlate.getPlateId())
|
|
|
+ // .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
+ // .last("limit 0,10");
|
|
|
+ // List<IndustryPlate> sumIndustryPlates = industryPlateMapper.selectList(queryWrapper);
|
|
|
+ // Double close = 0.0;
|
|
|
+ // Double closePred = 0.0;
|
|
|
+ // if (sumIndustryPlates.size() > 0){
|
|
|
+ // close = sumIndustryPlates.stream().filter(s -> null != s.getPlateClose())
|
|
|
+ // .mapToDouble(IndustryPlate::getPlateClose).sum();
|
|
|
+ // closePred = sumIndustryPlates.stream().filter(s -> null != s.getPlateClosePred())
|
|
|
+ // .mapToDouble(IndustryPlate::getPlateClosePred).sum();
|
|
|
+ // }
|
|
|
+ // industryDetail = IndustryDetail.builder()
|
|
|
+ // .industryId("")
|
|
|
+ // .industryDate(industryPlate.getPlateDate())
|
|
|
+ // .close(Float.valueOf(close.toString()))
|
|
|
+ // .pred(Float.valueOf(closePred.toString()))
|
|
|
+ // .build();
|
|
|
+ //
|
|
|
+ // industryDetails.add(industryDetail);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // return industryDetails;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 沪深接口查询函数。
|
|
|
+ * @param monday
|
|
|
+ * @param sunday
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IndustryPlateSum> toPlateSums(String monday,String sunday){
|
|
|
+ QueryWrapper<IndustryPlateSum> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+ if (DateUtils.checkDate(monday,sunday).equals(true)) {
|
|
|
+ industryPlateQueryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlateSum::getPlateDate)
|
|
|
+ .between(IndustryPlateSum::getPlateDate,sunday,monday)
|
|
|
+ .last("limit 0,5");
|
|
|
+ }else {
|
|
|
+ industryPlateQueryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlateSum::getPlateDate)
|
|
|
+ .between(IndustryPlateSum::getPlateDate,monday,sunday)
|
|
|
+ .last("limit 0,5");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<IndustryPlateSum> industryPlateSums = industryPlateSumMapper.selectList(industryPlateQueryWrapper);
|
|
|
+ return industryPlateSums;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化沪深接口函数。
|
|
|
+ * @param nextPlatesNum
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IndustryDetail initDetail(IndustryPlateSum nextPlatesNum){
|
|
|
+ IndustryDetail industryDetail = IndustryDetail.builder()
|
|
|
+ .industryId(nextPlatesNum.getId())
|
|
|
+ .industryDate(nextPlatesNum.getPlateDate())
|
|
|
+ .close(nextPlatesNum.getPlateClose())
|
|
|
+ .pred(nextPlatesNum.getPlateClosePred())
|
|
|
+ .build();
|
|
|
+ return industryDetail;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据行业id或者行业名称查询接口。
|
|
|
+ * @param searchInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IncInfo> toSearch(SearchInfo searchInfo){
|
|
|
+ // 1、根据日期倒序拿到数据库中的最新日期
|
|
|
+ Map<String,Object> actualMap = toDate();
|
|
|
+ // 1、根据当前日期判断是否是周六,是 本周的和上周的数据。否则上周和上上周的数据。
|
|
|
+ String friday = actualMap.get("friday").toString();
|
|
|
+ String lastFriday = actualMap.get("lastFriday").toString();
|
|
|
+ // 2、查询涨跌幅。取前十。
|
|
|
+ List<IndustryPlateRes> plates = toSearchQuery(searchInfo,friday,lastFriday);
|
|
|
+ // 3、创建返回s数据。
|
|
|
+ return toSearchBackIncInfos(plates);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建返回函数。
|
|
|
+ * @param plates
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IncInfo> toSearchBackIncInfos(List<IndustryPlateRes> plates) {
|
|
|
+ IncInfo incInfo;
|
|
|
+ List<IncInfo> incInfos = new ArrayList<>();
|
|
|
+ for (IndustryPlateRes industryPlateRes : plates) {
|
|
|
+ Float value = null != industryPlateRes.getPlateCloseUp() ? industryPlateRes.getPlateCloseUp()
|
|
|
+ : 0.0F;
|
|
|
+ incInfo = IncInfo.builder()
|
|
|
+ .industryId(industryPlateRes.getPlateId())
|
|
|
+ // .industryName(plate.getPlateName())
|
|
|
+ // todo 后期需要修改。
|
|
|
+ .industryName(industryPlateRes.getPlateName())
|
|
|
+ .industryValue(value)
|
|
|
+ .industryTag(value > 0.0F ? true : false)
|
|
|
+ .build();
|
|
|
+ incInfos.add(incInfo);
|
|
|
+ }
|
|
|
+ return incInfos;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据行业id或者行业名称查询函数
|
|
|
+ * @param searchInfo
|
|
|
+ * @param friday
|
|
|
+ * @param lastFriday
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IndustryPlateRes> toSearchQuery(SearchInfo searchInfo,String friday,String lastFriday){
|
|
|
+ QueryWrapper<IndustryPlateRes> queryWrapper = new QueryWrapper<>();
|
|
|
+ // 涨幅
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlateRes::getPlateId,searchInfo.getSearchParam())
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
+ .last("limit 0,10")
|
|
|
+ .or()
|
|
|
+ .like(IndustryPlateRes::getPlateName,searchInfo.getSearchParam());
|
|
|
+ }else {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlateRes::getPlateId,searchInfo.getSearchParam())
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
+ .last("limit 0,10")
|
|
|
+ .or()
|
|
|
+ .like(IndustryPlateRes::getPlateName,searchInfo.getSearchParam());
|
|
|
+ }
|
|
|
+ List<IndustryPlateRes> plates = industryPlateResMapper.selectList(queryWrapper);
|
|
|
+ log.info("toSearchQuery plates:{}",JSON.toJSONString(plates));
|
|
|
+ return plates;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 根据行业id进入详情。
|
|
|
+ * @param ids
|
|
|
+ * @param detailsFlag
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IndustryDetailsInfo toFindDetailsByPlateId(List<String> ids,Boolean detailsFlag){
|
|
|
+ // todo 根据id进入详情,计算值。包含下周预测。
|
|
|
+ List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
+ for (String id : ids) {
|
|
|
+ // 上周的每一天,下周的每一天。
|
|
|
+ // toIncInfos();
|
|
|
+ // 1、根据plateid、platename查询出该行业的所有信息。按照日期倒序排序,获取该时间,然后得出该时间的一周内每天的数据。
|
|
|
+ // 实际数据也即本周数据。
|
|
|
+ QueryWrapper<IndustryPlateRes> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlateRes::getPlateId, id)
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate);
|
|
|
+ List<IndustryPlateRes> datePlates = industryPlateResMapper.selectList(queryWrapper);
|
|
|
+ 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<IndustryPlateRes> industryPlates = toIndustryPlateRes(id, monday, sunday);
|
|
|
+ // 3、下周预测放上面,实际数据放下面。
|
|
|
+ List<IndustryPlateRes> nextIndustryPlates = new ArrayList<>();
|
|
|
+ if (detailsFlag.equals(true)) {
|
|
|
+ Map<String, Object> nextWeekMap = DateUtils.getEverydayOfNexWeek(date);
|
|
|
+ String nextMonday = nextWeekMap.get("monday").toString();
|
|
|
+ String nextSunday = nextWeekMap.get("sunday").toString();
|
|
|
+ nextIndustryPlates = toIndustryPlateRes(id, nextMonday, nextSunday);
|
|
|
+ log.info("预测:{}", JSON.toJSONString(nextIndustryPlates));
|
|
|
+ for (IndustryPlateRes nextIndustryPlate : nextIndustryPlates) {
|
|
|
+ industryDetails.add(toInitIndustryDetail(nextIndustryPlate));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (nextIndustryPlates.size() > 0 && detailsFlag.equals(true)){
|
|
|
+ // 创建detail列表
|
|
|
+ log.info("实际:{}", JSON.toJSONString(industryPlates));
|
|
|
+ for (IndustryPlateRes industryPlate : industryPlates) {
|
|
|
+ industryDetails.add(toInitIndustryDetail(industryPlate));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (detailsFlag.equals(false)){
|
|
|
+ // 创建detail列表
|
|
|
+ log.info("实际:{}", JSON.toJSONString(industryPlates));
|
|
|
+ for (IndustryPlateRes industryPlate : industryPlates) {
|
|
|
+ industryDetails.add(toInitIndustryDetail(industryPlate));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 4、附带新闻数据。
|
|
|
+ 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();
|
|
|
+ return industryInfo;
|
|
|
+ }
|
|
|
+
|
|
|
}
|