|
@@ -13,12 +13,10 @@ 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;
|
|
|
-import com.pavis.ai.app.fda.mapper.SearchCountMapper;
|
|
|
+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.service.NewsService;
|
|
|
import com.pavis.ai.app.fda.service.SearchService;
|
|
@@ -53,6 +51,9 @@ public class SearchServiceImpl implements SearchService {
|
|
|
@Autowired
|
|
|
private NewsService newsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IndustryPlateSumMapper industryPlateSumMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public List<IncInfo> incLastWeekPage() {
|
|
|
return toIncInfosPage(true, false, false, false, null);
|
|
@@ -167,7 +168,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<IndustryDetail> hisHushenSum() {
|
|
|
+ public IndustryDetailsInfo hisHushenSum() {
|
|
|
return toHisHushenSum();
|
|
|
}
|
|
|
|
|
@@ -202,59 +203,116 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return toIncInfos(false, true, false, false, null);
|
|
|
}
|
|
|
|
|
|
+ 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 List<IndustryDetail> toHisHushenSum(){
|
|
|
- QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+ public IndustryDetailsInfo toHisHushenSum(){
|
|
|
+ QueryWrapper<IndustryPlateSum> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
industryPlateQueryWrapper.lambda()
|
|
|
- .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
- .last("limit 0,10");
|
|
|
-
|
|
|
- List<IndustryPlate> datePlates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
- String date = datePlates.size() > 0 ? datePlates.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
- log.info("实际数据日期:{}", date);
|
|
|
- // 2、近五天数据日期计算。
|
|
|
- Map<String, Object> weekMap = DateUtils.getEverydayByActual(date);
|
|
|
+ .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<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();
|
|
|
+ List<IndustryPlateSum> plateSums = toPlateSums(monday, sunday);
|
|
|
+ log.info("沪深 实际:{}",JSON.toJSONString(plateSums));
|
|
|
|
|
|
- industryDetails.add(industryDetail);
|
|
|
+ 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;
|
|
|
+ // return industryDetails;
|
|
|
}
|
|
|
|
|
|
/**
|