|
@@ -6,15 +6,18 @@ 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.follow.Follower;
|
|
|
import com.pavis.ai.app.fda.form.his.IndustryDetail;
|
|
|
import com.pavis.ai.app.fda.form.his.IndustryDetailsInfo;
|
|
|
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.FindDetail;
|
|
|
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.*;
|
|
|
+import com.pavis.ai.app.fda.model.FollowInfo;
|
|
|
import com.pavis.ai.app.fda.service.NewsService;
|
|
|
import com.pavis.ai.app.fda.service.SearchService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -51,6 +54,9 @@ public class SearchServiceImpl implements SearchService {
|
|
|
@Autowired
|
|
|
private IndustryPlateSumMapper industryPlateSumMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FollowInfoMapper followInfoMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public List<IncInfo> incLastWeekPage() {
|
|
|
return toIncInfosPage(true, false, false, false, null);
|
|
@@ -113,15 +119,15 @@ public class SearchServiceImpl implements SearchService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public IndustryDetailsInfo hisFind(List<String> ids) {
|
|
|
- return toDetailsByPlateId(ids, false);
|
|
|
+ public IndustryDetailsInfo hisFind(List<FindDetail> findDetails) {
|
|
|
+ return toDetailsByPlateId(findDetails, false);
|
|
|
// return toFindDetailsByPlateId(ids, false);
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public IndustryDetailsInfo predictFind(List<String> ids) {
|
|
|
- return toDetailsByPlateId(ids, true);
|
|
|
+ public IndustryDetailsInfo predictFind(List<FindDetail> findDetails) {
|
|
|
+ return toDetailsByPlateId(findDetails, true);
|
|
|
// return toFindDetailsByPlateId(ids, true);
|
|
|
|
|
|
// List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
@@ -212,25 +218,92 @@ public class SearchServiceImpl implements SearchService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public int toFollow(Follower follower) {
|
|
|
+ // 1、查询该用户已关注的行业。
|
|
|
+ List<FollowInfo> followInfos = getFollowed(follower.getUserId(),follower.getPlateId());
|
|
|
+ // 2、判断是否需要入库。
|
|
|
+ if (followInfos.size() > 0){
|
|
|
+ // 已关注过请勿重复关注。
|
|
|
+ return -1;
|
|
|
+ }else {
|
|
|
+ // 未关注过该行业,新增关注记录。
|
|
|
+ FollowInfo followInfo = new FollowInfo();
|
|
|
+ BeanUtils.copyProperties(follower, followInfo);
|
|
|
+ followInfo.setOperator("ghj");
|
|
|
+ followInfo.setOperatorId("");
|
|
|
+ followInfo.setOperateIp("192.168.1.73");
|
|
|
+ followInfo.setOperateTime(DateUtils.getCurrentTime());
|
|
|
+ return followInfoMapper.insert(followInfo);
|
|
|
+ }
|
|
|
+ // return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int toCancelFollow(Follower follower) {
|
|
|
+ List<FollowInfo> followInfos = getFollowed(follower.getUserId(),follower.getPlateId());
|
|
|
+ if (followInfos.size() < 0){
|
|
|
+ return -1;
|
|
|
+ }else {
|
|
|
+ int deletedId = 0;
|
|
|
+ for (FollowInfo followInfo : followInfos) {
|
|
|
+ QueryWrapper<FollowInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(FollowInfo::getUserId,follower.getUserId())
|
|
|
+ .eq(FollowInfo::getPlateId,follower.getPlateId());
|
|
|
+ deletedId = followInfoMapper.delete(queryWrapper);
|
|
|
+ }
|
|
|
+ return deletedId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IncInfo> followDetails(String userId) {
|
|
|
+ QueryWrapper<FollowInfo> followInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ followInfoQueryWrapper.lambda()
|
|
|
+ .eq(FollowInfo::getUserId,userId);
|
|
|
+ List<FollowInfo> followInfos = followInfoMapper.selectList(followInfoQueryWrapper);
|
|
|
+ IncInfo incInfo;
|
|
|
+ List<IncInfo> incInfos = new ArrayList<>();
|
|
|
+ for (FollowInfo followInfo : followInfos) {
|
|
|
+ QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
+ industryPlateQueryWrapper.lambda()
|
|
|
+ .eq(IndustryPlate::getPlateId, followInfo.getPlateId())
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate);
|
|
|
+ List<IndustryPlate> datePlates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
+ String date = datePlates.size() > 0 ? datePlates.get(0).getPlateDate() : TestCommon.getWeek();
|
|
|
+ Float value = calLastWeekActual(date,followInfo.getPlateId());
|
|
|
+ incInfo = IncInfo.builder()
|
|
|
+ .industryId(followInfo.getPlateId())
|
|
|
+ .industryValue(value)
|
|
|
+ .industryTag(value > 0.0F ? true : false)
|
|
|
+ .industryName(followInfo.getPlateName())
|
|
|
+ .build();
|
|
|
+ incInfos.add(incInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return incInfos;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 根据行业id获取详情或者未来七天预测接口
|
|
|
*
|
|
|
- * @param ids
|
|
|
+ * @param findDetails
|
|
|
* @param detailsFlag
|
|
|
* @return
|
|
|
*/
|
|
|
- public IndustryDetailsInfo toDetailsByPlateId(List<String> ids, Boolean detailsFlag) {
|
|
|
+ public IndustryDetailsInfo toDetailsByPlateId(List<FindDetail> findDetails, Boolean detailsFlag) {
|
|
|
// todo 根据id进入详情,计算值。包含下周预测。
|
|
|
List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
|
- for (String id : ids) {
|
|
|
+ for (FindDetail findDetail : findDetails) {
|
|
|
// 上周的每一天,下周的每一天。
|
|
|
// toIncInfos();
|
|
|
// 1、根据plateid、platename查询出该行业的所有信息。按照日期倒序排序,获取该时间,然后得出该时间的一周内每天的数据。
|
|
|
// 实际数据也即本周数据。
|
|
|
QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
|
industryPlateQueryWrapper.lambda()
|
|
|
- .eq(IndustryPlate::getPlateId, id)
|
|
|
+ .eq(IndustryPlate::getPlateId, findDetail.getPlateId())
|
|
|
.orderByDesc(IndustryPlate::getPlateDate);
|
|
|
List<IndustryPlate> datePlates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
if (datePlates.size() > 0) {
|
|
@@ -243,14 +316,14 @@ public class SearchServiceImpl implements SearchService {
|
|
|
// todo
|
|
|
String monday = weekMap.get("MONDAY").toString();
|
|
|
String sunday = weekMap.get("SUNDAY").toString();
|
|
|
- List<IndustryPlate> industryPlates = toIndustryPlates(id, monday, sunday);
|
|
|
+ List<IndustryPlate> industryPlates = toIndustryPlates(findDetail.getPlateId(), monday, sunday);
|
|
|
// 3、下周预测放上面,实际数据放下面。
|
|
|
List<IndustryPlate> 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 = toIndustryPlates(id, nextMonday, nextSunday);
|
|
|
+ nextIndustryPlates = toIndustryPlates(findDetail.getPlateId(), nextMonday, nextSunday);
|
|
|
log.info("预测:{}", JSON.toJSONString(nextIndustryPlates));
|
|
|
for (IndustryPlate nextIndustryPlate : nextIndustryPlates) {
|
|
|
industryDetails.add(toIndustryDetail(nextIndustryPlate));
|
|
@@ -274,19 +347,36 @@ public class SearchServiceImpl implements SearchService {
|
|
|
}
|
|
|
// 4、附带新闻数据。
|
|
|
SearchInfo searchInfo = SearchInfo.builder()
|
|
|
- .searchParam(ids.get(0))
|
|
|
+ .searchParam(findDetails.get(0).getPlateId())
|
|
|
.build();
|
|
|
// todo 需要修改接口。
|
|
|
List<NewsList> newsLists = newsService.getNewsByPlateId(searchInfo.getSearchParam());
|
|
|
-
|
|
|
+ List<FollowInfo> followInfos = getFollowed(findDetails.get(0).getUserId(),findDetails.get(0).getPlateId());
|
|
|
+ Boolean isFollowed = followInfos.size() > 0 ? true : false;
|
|
|
IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
|
|
|
.actuals(industryDetails)
|
|
|
.news(newsLists)
|
|
|
.tag(true)
|
|
|
+ .isFollowed(isFollowed)
|
|
|
.build();
|
|
|
return industryInfo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断该用户是否关注过该行业。
|
|
|
+ * @param userId
|
|
|
+ * @param plateId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<FollowInfo> getFollowed(String userId,String plateId){
|
|
|
+ QueryWrapper<FollowInfo> followInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ followInfoQueryWrapper.lambda()
|
|
|
+ .eq(FollowInfo::getUserId,userId)
|
|
|
+ .eq(FollowInfo::getPlateId,plateId);
|
|
|
+ List<FollowInfo> followInfos = followInfoMapper.selectList(followInfoQueryWrapper);
|
|
|
+ return followInfos;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 创建每一天的close、pred值。
|
|
|
*
|
|
@@ -846,12 +936,14 @@ public class SearchServiceImpl implements SearchService {
|
|
|
.orderByDesc(IndustryPlateRes::getPlateCloseUp)
|
|
|
.groupBy(IndustryPlateRes::getPlateId)
|
|
|
.between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
+ .eq(IndustryPlateRes::getPlateCloseUp,null)
|
|
|
.last("limit 0,10");
|
|
|
}else {
|
|
|
queryWrapper.lambda()
|
|
|
.orderByDesc(IndustryPlateRes::getPlateCloseUp)
|
|
|
.groupBy(IndustryPlateRes::getPlateId)
|
|
|
.between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
+ .eq(IndustryPlateRes::getPlateCloseUp,null)
|
|
|
.last("limit 0,10");
|
|
|
}
|
|
|
}else {
|
|
@@ -860,12 +952,14 @@ public class SearchServiceImpl implements SearchService {
|
|
|
.orderByAsc(IndustryPlateRes::getPlateCloseUp)
|
|
|
.groupBy(IndustryPlateRes::getPlateId)
|
|
|
.between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
+ .eq(IndustryPlateRes::getPlateCloseUp,null)
|
|
|
.last("limit 0,10");
|
|
|
}else {
|
|
|
queryWrapper.lambda()
|
|
|
.orderByAsc(IndustryPlateRes::getPlateCloseUp)
|
|
|
.groupBy(IndustryPlateRes::getPlateId)
|
|
|
.between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
+ .eq(IndustryPlateRes::getPlateCloseUp,null)
|
|
|
.last("limit 0,10");
|
|
|
}
|
|
|
}
|
|
@@ -973,29 +1067,29 @@ public class SearchServiceImpl implements SearchService {
|
|
|
// 涨幅
|
|
|
if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
queryWrapper.lambda()
|
|
|
+ .between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
.orderByDesc(IndustryPlateRes::getPlateClosePredUp)
|
|
|
.groupBy(IndustryPlateRes::getPlateId)
|
|
|
- .between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
.last("limit 0,10");
|
|
|
}else {
|
|
|
queryWrapper.lambda()
|
|
|
+ .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
.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()
|
|
|
+ .between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
.orderByAsc(IndustryPlateRes::getPlateClosePredUp)
|
|
|
.groupBy(IndustryPlateRes::getPlateId)
|
|
|
- .between(IndustryPlateRes::getPlateDate,lastFriday,friday)
|
|
|
.last("limit 0,10");
|
|
|
}else {
|
|
|
queryWrapper.lambda()
|
|
|
+ .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
.orderByAsc(IndustryPlateRes::getPlateClosePredUp)
|
|
|
.groupBy(IndustryPlateRes::getPlateId)
|
|
|
- .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
.last("limit 0,10");
|
|
|
}
|
|
|
}
|
|
@@ -1140,7 +1234,13 @@ public class SearchServiceImpl implements SearchService {
|
|
|
String friday = actualMap.get("friday").toString();
|
|
|
String lastFriday = actualMap.get("lastFriday").toString();
|
|
|
// 2、查询涨跌幅。取前十。
|
|
|
- List<IndustryPlateRes> plates = toSearchQuery(searchInfo,friday,lastFriday);
|
|
|
+ List<IndustryPlateRes> plates = new ArrayList<>();
|
|
|
+ if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
+ plates = toSearchQuery(searchInfo,lastFriday,friday);
|
|
|
+ }else {
|
|
|
+ plates = toSearchQuery(searchInfo,friday,lastFriday);
|
|
|
+ }
|
|
|
+
|
|
|
// 3、创建返回s数据。
|
|
|
return toSearchBackIncInfos(plates);
|
|
|
|
|
@@ -1180,26 +1280,37 @@ public class SearchServiceImpl implements SearchService {
|
|
|
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());
|
|
|
- }
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlateRes::getPlateDate)
|
|
|
+ .groupBy(IndustryPlateRes::getPlateId)
|
|
|
+ .between(IndustryPlateRes::getPlateDate,friday,lastFriday)
|
|
|
+ .last("limit 0,10")
|
|
|
+ .or()
|
|
|
+ .like(IndustryPlateRes::getPlateId,searchInfo.getSearchParam())
|
|
|
+ .or()
|
|
|
+ .like(IndustryPlateRes::getPlateName,searchInfo.getSearchParam());
|
|
|
List<IndustryPlateRes> plates = industryPlateResMapper.selectList(queryWrapper);
|
|
|
+ // List<IndustryPlateRes> plates = industryPlateResMapper.selectList(queryWrapper);
|
|
|
+ // List<IndustryPlateRes> plates = new ArrayList<>();
|
|
|
+ // if (DateUtils.checkDate(friday,lastFriday).equals(true)) {
|
|
|
+ // QueryForm queryForm = QueryForm.builder()
|
|
|
+ // .plateId(searchInfo.getSearchParam())
|
|
|
+ // .plateName(searchInfo.getSearchParam())
|
|
|
+ // .friday(lastFriday)
|
|
|
+ // .lastFriday(friday)
|
|
|
+ // .build();
|
|
|
+ // plates = industryPlateResMapper.findPlateByIdOrName(queryForm);
|
|
|
+ // }else {
|
|
|
+ // QueryForm queryForm = QueryForm.builder()
|
|
|
+ // .plateId(searchInfo.getSearchParam())
|
|
|
+ // .plateName(searchInfo.getSearchParam())
|
|
|
+ // .friday(friday)
|
|
|
+ // .lastFriday(lastFriday)
|
|
|
+ // .build();
|
|
|
+ // plates = industryPlateResMapper.findPlateByIdOrName(queryForm);
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
log.info("toSearchQuery plates:{}",JSON.toJSONString(plates));
|
|
|
return plates;
|
|
|
}
|