|
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Component;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author guanhuijuan
|
|
* @author guanhuijuan
|
|
@@ -88,7 +89,7 @@ public class HisServiceImpl implements HisService {
|
|
*/
|
|
*/
|
|
public IndustryDetailsInfo toDetailsByPlateId(List<FindDetail> findDetails,Boolean isDetailed) {
|
|
public IndustryDetailsInfo toDetailsByPlateId(List<FindDetail> findDetails,Boolean isDetailed) {
|
|
// 1、根据行业id、日期倒序查询,
|
|
// 1、根据行业id、日期倒序查询,
|
|
- String datePlate = getNewestDate(findDetails);
|
|
|
|
|
|
+ String datePlate = getNewestDate(findDetails,isDetailed);
|
|
log.info("实际日期:{}",datePlate);
|
|
log.info("实际日期:{}",datePlate);
|
|
// 2、根据行业id、日期在近7天的,实际榜数据。
|
|
// 2、根据行业id、日期在近7天的,实际榜数据。
|
|
// Map<String, Object> weekMap = DateUtils.getEverydayByActual(datePlate);
|
|
// Map<String, Object> weekMap = DateUtils.getEverydayByActual(datePlate);
|
|
@@ -106,7 +107,6 @@ public class HisServiceImpl implements HisService {
|
|
actualPlates = toActualPlates(findDetails.get(0).getPlateId(),
|
|
actualPlates = toActualPlates(findDetails.get(0).getPlateId(),
|
|
month,nearlyMonth);
|
|
month,nearlyMonth);
|
|
}
|
|
}
|
|
- log.info("实际:{}", JSON.toJSONString(actualPlates));
|
|
|
|
|
|
|
|
// 预测数据。
|
|
// 预测数据。
|
|
List<IndustryPlate> nextPlates = new ArrayList<>();
|
|
List<IndustryPlate> nextPlates = new ArrayList<>();
|
|
@@ -116,55 +116,70 @@ public class HisServiceImpl implements HisService {
|
|
String nextMonday = nextWeekMap.get("monday").toString();
|
|
String nextMonday = nextWeekMap.get("monday").toString();
|
|
String nextSunday = nextWeekMap.get("sunday").toString();
|
|
String nextSunday = nextWeekMap.get("sunday").toString();
|
|
if (DateUtils.checkDate(nextMonday, nextSunday).equals(true)) {
|
|
if (DateUtils.checkDate(nextMonday, nextSunday).equals(true)) {
|
|
- nextPlates = toActualPlates(findDetails.get(0).getPlateId(),
|
|
|
|
|
|
+ nextPlates = toActualPlates("",
|
|
nextSunday,nextMonday);
|
|
nextSunday,nextMonday);
|
|
}else {
|
|
}else {
|
|
- nextPlates = toActualPlates(findDetails.get(0).getPlateId(),
|
|
|
|
|
|
+ nextPlates = toActualPlates("",
|
|
nextMonday,nextSunday);
|
|
nextMonday,nextSunday);
|
|
}
|
|
}
|
|
|
|
+ // nextPlates = actualPlates.stream().filter(s -> s.getPlateClose() == null)
|
|
|
|
+ // .collect(Collectors.toList());
|
|
log.info("预测:{}", JSON.toJSONString(nextPlates));
|
|
log.info("预测:{}", JSON.toJSONString(nextPlates));
|
|
}
|
|
}
|
|
// 3、构造实际数据返回。
|
|
// 3、构造实际数据返回。
|
|
List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
List<IndustryDetail> industryDetails = new ArrayList<>();
|
|
- List<Float> floats = new ArrayList<>();
|
|
|
|
List<Integer> axisLists = new ArrayList<>();
|
|
List<Integer> axisLists = new ArrayList<>();
|
|
- if (nextPlates.size() > 0 && isDetailed.equals(true)) {
|
|
|
|
- // 创建detail列表
|
|
|
|
|
|
+ String plateId = findDetails.get(0).getPlateId();
|
|
|
|
+ String userId = findDetails.get(0).getUserId();
|
|
|
|
+ if (isDetailed.equals(false)){
|
|
log.info("实际:{}", JSON.toJSONString(actualPlates));
|
|
log.info("实际:{}", JSON.toJSONString(actualPlates));
|
|
|
|
+ // 实际数据来的。
|
|
for (IndustryPlate industryPlate : actualPlates) {
|
|
for (IndustryPlate industryPlate : actualPlates) {
|
|
- // 如果是周六周日则不展示。
|
|
|
|
String week = DateUtils.getWeekNameByDate(industryPlate.getPlateDate());
|
|
String week = DateUtils.getWeekNameByDate(industryPlate.getPlateDate());
|
|
if (!week.equals("6") && !week.equals("7")){
|
|
if (!week.equals("6") && !week.equals("7")){
|
|
industryDetails.add(toIndustryDetail(industryPlate));
|
|
industryDetails.add(toIndustryDetail(industryPlate));
|
|
- floats.add(industryPlate.getPlateClose());
|
|
|
|
- floats.add(industryPlate.getPlateClosePred());
|
|
|
|
axisLists.add(null == industryPlate.getPlateClose() ? 0 : Math.round(industryPlate.getPlateClose()));
|
|
axisLists.add(null == industryPlate.getPlateClose() ? 0 : Math.round(industryPlate.getPlateClose()));
|
|
- axisLists.add(null == industryPlate.getPlateClosePred() ? 0 : Math.round(industryPlate.getPlateClosePred()));
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (isDetailed.equals(false)) {
|
|
|
|
- // 创建detail列表
|
|
|
|
|
|
+ return toInitDetails(plateId,userId,axisLists,industryDetails);
|
|
|
|
+ }else {
|
|
|
|
+ for (IndustryPlate nextPlate : nextPlates) {
|
|
|
|
+ String week = DateUtils.getWeekNameByDate(nextPlate.getPlateDate());
|
|
|
|
+ if (!week.equals("6") && !week.equals("7")){
|
|
|
|
+ axisLists.add(null == nextPlate.getPlateClose() ? 0 : Math.round(nextPlate.getPlateClose()));
|
|
|
|
+ industryDetails.add(toIndustryDetail(nextPlate));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
log.info("实际:{}", JSON.toJSONString(actualPlates));
|
|
log.info("实际:{}", JSON.toJSONString(actualPlates));
|
|
for (IndustryPlate industryPlate : actualPlates) {
|
|
for (IndustryPlate industryPlate : actualPlates) {
|
|
|
|
+ // 如果是周六周日则不展示。
|
|
String week = DateUtils.getWeekNameByDate(industryPlate.getPlateDate());
|
|
String week = DateUtils.getWeekNameByDate(industryPlate.getPlateDate());
|
|
if (!week.equals("6") && !week.equals("7")){
|
|
if (!week.equals("6") && !week.equals("7")){
|
|
industryDetails.add(toIndustryDetail(industryPlate));
|
|
industryDetails.add(toIndustryDetail(industryPlate));
|
|
- floats.add(industryPlate.getPlateClose());
|
|
|
|
- floats.add(industryPlate.getPlateClosePred());
|
|
|
|
- axisLists.add(null == industryPlate.getPlateClose() ? 0 : Math.round(industryPlate.getPlateClose()));
|
|
|
|
axisLists.add(null == industryPlate.getPlateClosePred() ? 0 : Math.round(industryPlate.getPlateClosePred()));
|
|
axisLists.add(null == industryPlate.getPlateClosePred() ? 0 : Math.round(industryPlate.getPlateClosePred()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return toInitDetails(plateId,userId,axisLists,industryDetails);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 初始化详情数据。
|
|
|
|
+ * @param plateId
|
|
|
|
+ * @param userId
|
|
|
|
+ * @param axisLists
|
|
|
|
+ * @param industryDetails
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public IndustryDetailsInfo toInitDetails (String plateId,String userId,List<Integer> axisLists,List<IndustryDetail> industryDetails){
|
|
// 3.1 新闻列表,根据行业id查询
|
|
// 3.1 新闻列表,根据行业id查询
|
|
SearchInfo searchInfo = SearchInfo.builder()
|
|
SearchInfo searchInfo = SearchInfo.builder()
|
|
- .searchParam(findDetails.get(0).getPlateId())
|
|
|
|
|
|
+ .searchParam(plateId)
|
|
.build();
|
|
.build();
|
|
List<NewsList> newsLists = newsService.getNewsByPlateId(searchInfo.getSearchParam());
|
|
List<NewsList> newsLists = newsService.getNewsByPlateId(searchInfo.getSearchParam());
|
|
- List<FollowInfo> followInfos = getFollowed(findDetails.get(0).getUserId(), findDetails.get(0).getPlateId());
|
|
|
|
|
|
+ List<FollowInfo> followInfos = getFollowed(userId, plateId);
|
|
Boolean isFollowed = followInfos.size() > 0 ? true : false;
|
|
Boolean isFollowed = followInfos.size() > 0 ? true : false;
|
|
- List<Float> axisByY = DateUtils.getAxisY(floats);
|
|
|
|
List<Integer> axisByYs = DateUtils.getAxisList(axisLists);
|
|
List<Integer> axisByYs = DateUtils.getAxisList(axisLists);
|
|
IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
|
|
IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
|
|
.actuals(industryDetails)
|
|
.actuals(industryDetails)
|
|
@@ -204,11 +219,14 @@ public class HisServiceImpl implements HisService {
|
|
QueryWrapper<IndustryPlate> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<IndustryPlate> queryWrapper = new QueryWrapper<>();
|
|
if (plateId.equals("")) {
|
|
if (plateId.equals("")) {
|
|
queryWrapper.lambda()
|
|
queryWrapper.lambda()
|
|
|
|
+ .eq(IndustryPlate::getPlateId, plateId)
|
|
|
|
+ .isNull(IndustryPlate::getPlateClose)
|
|
.orderByDesc(IndustryPlate::getPlateDate)
|
|
.orderByDesc(IndustryPlate::getPlateDate)
|
|
.between(IndustryPlate::getPlateDate, monday, sunday);
|
|
.between(IndustryPlate::getPlateDate, monday, sunday);
|
|
}else {
|
|
}else {
|
|
queryWrapper.lambda()
|
|
queryWrapper.lambda()
|
|
.eq(IndustryPlate::getPlateId, plateId)
|
|
.eq(IndustryPlate::getPlateId, plateId)
|
|
|
|
+ // .isNotNull(IndustryPlate::getPlateClose)
|
|
.orderByDesc(IndustryPlate::getPlateDate)
|
|
.orderByDesc(IndustryPlate::getPlateDate)
|
|
.between(IndustryPlate::getPlateDate, monday, sunday);
|
|
.between(IndustryPlate::getPlateDate, monday, sunday);
|
|
}
|
|
}
|
|
@@ -221,12 +239,20 @@ public class HisServiceImpl implements HisService {
|
|
* @param findDetails
|
|
* @param findDetails
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public String getNewestDate(List<FindDetail> findDetails){
|
|
|
|
|
|
+ public String getNewestDate(List<FindDetail> findDetails,Boolean isActualOrPred){
|
|
for (FindDetail findDetail : findDetails) {
|
|
for (FindDetail findDetail : findDetails) {
|
|
QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
- industryPlateQueryWrapper.lambda()
|
|
|
|
- .eq(IndustryPlate::getPlateId, findDetail.getPlateId())
|
|
|
|
- .orderByDesc(IndustryPlate::getPlateDate);
|
|
|
|
|
|
+ if (isActualOrPred.equals(false)){
|
|
|
|
+ // 实际
|
|
|
|
+ industryPlateQueryWrapper.lambda()
|
|
|
|
+ .eq(IndustryPlate::getPlateId, findDetail.getPlateId())
|
|
|
|
+ .isNotNull(IndustryPlate::getPlateClose)
|
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate);
|
|
|
|
+ }else {
|
|
|
|
+ industryPlateQueryWrapper.lambda()
|
|
|
|
+ .eq(IndustryPlate::getPlateId, findDetail.getPlateId())
|
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate);
|
|
|
|
+ }
|
|
List<IndustryPlate> plates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
List<IndustryPlate> plates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
String date = plates.size() > 0 ? plates.get(0).getPlateDate() : TestCommon.getWeek();
|
|
String date = plates.size() > 0 ? plates.get(0).getPlateDate() : TestCommon.getWeek();
|
|
return date;
|
|
return date;
|
|
@@ -321,15 +347,18 @@ public class HisServiceImpl implements HisService {
|
|
List<IndustryPlateSum> industryPlateSums = industryPlateSumMapper.selectList(industryPlateQueryWrapper);
|
|
List<IndustryPlateSum> industryPlateSums = industryPlateSumMapper.selectList(industryPlateQueryWrapper);
|
|
// 1、获取最新的5个行业的日期。
|
|
// 1、获取最新的5个行业的日期。
|
|
String date = industryPlateSums.size() > 0 ? industryPlateSums.get(0).getPlateDate() : TestCommon.getWeek();
|
|
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();
|
|
|
|
|
|
+ // Map<String, Object> weekMap = DateUtils.getEverydayByActual(date);
|
|
|
|
+ // String monday = weekMap.get("MONDAY").toString();
|
|
|
|
+ // String sunday = weekMap.get("SUNDAY").toString();
|
|
|
|
+ Map<String, Object> weekMap = DateUtils.getMonthByNearly(date);
|
|
|
|
+ String month = weekMap.get("month").toString();
|
|
|
|
+ String nearlyMonth = weekMap.get("nearlyMonth").toString();
|
|
// 2。1、沪深实际数据。
|
|
// 2。1、沪深实际数据。
|
|
List<IndustryPlateSum> plateSums = new ArrayList<>();
|
|
List<IndustryPlateSum> plateSums = new ArrayList<>();
|
|
- if (DateUtils.checkDate(monday, sunday).equals(true)) {
|
|
|
|
- plateSums = toActualPlateSums(sunday, monday);
|
|
|
|
|
|
+ if (DateUtils.checkDate(month, nearlyMonth).equals(true)) {
|
|
|
|
+ plateSums = toActualPlateSums(nearlyMonth, month);
|
|
}else {
|
|
}else {
|
|
- plateSums = toActualPlateSums(monday, sunday);
|
|
|
|
|
|
+ plateSums = toActualPlateSums(month, nearlyMonth);
|
|
}
|
|
}
|
|
log.info("沪深 实际:{}", JSON.toJSONString(plateSums));
|
|
log.info("沪深 实际:{}", JSON.toJSONString(plateSums));
|
|
Map<String, Object> nextWeekMap = DateUtils.getEverydayOfNexWeek(date);
|
|
Map<String, Object> nextWeekMap = DateUtils.getEverydayOfNexWeek(date);
|
|
@@ -348,11 +377,17 @@ public class HisServiceImpl implements HisService {
|
|
List<IndustryDetail> nextIndustryDetails = new ArrayList<>();
|
|
List<IndustryDetail> nextIndustryDetails = new ArrayList<>();
|
|
for (IndustryPlateSum nextPlatesNum : nextPlatesNums) {
|
|
for (IndustryPlateSum nextPlatesNum : nextPlatesNums) {
|
|
// 预测在上方,实际在下方。
|
|
// 预测在上方,实际在下方。
|
|
- nextIndustryDetails.add(toInitDetail(nextPlatesNum));
|
|
|
|
|
|
+ String week = DateUtils.getWeekNameByDate(nextPlatesNum.getPlateDate());
|
|
|
|
+ if (!week.equals("6") && !week.equals("7")){
|
|
|
|
+ nextIndustryDetails.add(toInitDetail(nextPlatesNum));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
for (IndustryPlateSum industryPlateSum : plateSums) {
|
|
for (IndustryPlateSum industryPlateSum : plateSums) {
|
|
// 预测在上方,实际在下方。
|
|
// 预测在上方,实际在下方。
|
|
- industryDetails.add(toInitDetail(industryPlateSum));
|
|
|
|
|
|
+ String week = DateUtils.getWeekNameByDate(industryPlateSum.getPlateDate());
|
|
|
|
+ if (!week.equals("6") && !week.equals("7")){
|
|
|
|
+ industryDetails.add(toInitDetail(industryPlateSum));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
|
|
IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
|
|
.actuals(industryDetails)
|
|
.actuals(industryDetails)
|
|
@@ -360,7 +395,6 @@ public class HisServiceImpl implements HisService {
|
|
// todo 此处是涨还是跌???????????????
|
|
// todo 此处是涨还是跌???????????????
|
|
.tag(true)
|
|
.tag(true)
|
|
// todo 0723 是否需要增加。
|
|
// todo 0723 是否需要增加。
|
|
-
|
|
|
|
.build();
|
|
.build();
|
|
return industryInfo;
|
|
return industryInfo;
|
|
}
|
|
}
|
|
@@ -376,8 +410,8 @@ public class HisServiceImpl implements HisService {
|
|
QueryWrapper<IndustryPlateSum> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<IndustryPlateSum> industryPlateQueryWrapper = new QueryWrapper<>();
|
|
industryPlateQueryWrapper.lambda()
|
|
industryPlateQueryWrapper.lambda()
|
|
.orderByDesc(IndustryPlateSum::getPlateDate)
|
|
.orderByDesc(IndustryPlateSum::getPlateDate)
|
|
- .between(IndustryPlateSum::getPlateDate, monday, sunday)
|
|
|
|
- .last("limit 0,5");
|
|
|
|
|
|
+ .between(IndustryPlateSum::getPlateDate, monday, sunday);
|
|
|
|
+ // .last("limit 0,5");
|
|
List<IndustryPlateSum> industryPlateSums = industryPlateSumMapper.selectList(industryPlateQueryWrapper);
|
|
List<IndustryPlateSum> industryPlateSums = industryPlateSumMapper.selectList(industryPlateQueryWrapper);
|
|
return industryPlateSums;
|
|
return industryPlateSums;
|
|
}
|
|
}
|