|
@@ -166,6 +166,11 @@ public class SearchServiceImpl implements SearchService {
|
|
|
// return industryInfo;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<IndustryDetail> hisHushenSum() {
|
|
|
+ return toHisHushenSum();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<IncInfo> incLastWeek() {
|
|
|
return toIncInfos(true, false, false, false, null);
|
|
@@ -197,6 +202,61 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return toIncInfos(false, true, false, false, null);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 沪深接口。
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IndustryDetail> toHisHushenSum(){
|
|
|
+ QueryWrapper<IndustryPlate> 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);
|
|
|
+ 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获取详情或者未来七天预测接口
|
|
|
*
|
|
@@ -228,11 +288,9 @@ public class SearchServiceImpl implements SearchService {
|
|
|
String monday = weekMap.get("MONDAY").toString();
|
|
|
String sunday = weekMap.get("SUNDAY").toString();
|
|
|
List<IndustryPlate> industryPlates = toIndustryPlates(id, monday, sunday);
|
|
|
- System.err.println(detailsFlag);
|
|
|
// 3、下周预测放上面,实际数据放下面。
|
|
|
List<IndustryPlate> nextIndustryPlates = new ArrayList<>();
|
|
|
if (detailsFlag.equals(true)) {
|
|
|
- System.err.println("if");
|
|
|
Map<String, Object> nextWeekMap = DateUtils.getEverydayOfNexWeek(date);
|
|
|
String nextMonday = nextWeekMap.get("monday").toString();
|
|
|
String nextSunday = nextWeekMap.get("sunday").toString();
|
|
@@ -298,20 +356,31 @@ public class SearchServiceImpl implements SearchService {
|
|
|
*/
|
|
|
public List<IndustryPlate> toIndustryPlates(String id, String monday, String sunday) {
|
|
|
log.info("详情查询:{}", id + ",monday:" + monday + ",sunday:" + sunday);
|
|
|
+
|
|
|
QueryWrapper<IndustryPlate> queryWrapper = new QueryWrapper<>();
|
|
|
- if (DateUtils.checkDate(monday,sunday).equals(true)){
|
|
|
- queryWrapper.lambda()
|
|
|
- .eq(IndustryPlate::getPlateId, id)
|
|
|
- .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
- .between(IndustryPlate::getPlateDate, sunday,monday );
|
|
|
+ if (id.equals("")){
|
|
|
+ if (DateUtils.checkDate(monday,sunday).equals(true)){
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
+ .between(IndustryPlate::getPlateDate, sunday,monday );
|
|
|
+ }else {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
+ .between(IndustryPlate::getPlateDate, monday, sunday);
|
|
|
+ }
|
|
|
}else {
|
|
|
- System.err.println("else else");
|
|
|
- queryWrapper.lambda()
|
|
|
- .eq(IndustryPlate::getPlateId, id)
|
|
|
- .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
- .between(IndustryPlate::getPlateDate, monday, sunday);
|
|
|
+ if (DateUtils.checkDate(monday,sunday).equals(true)){
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlate::getPlateId, id)
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
+ .between(IndustryPlate::getPlateDate, sunday,monday );
|
|
|
+ }else {
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(IndustryPlate::getPlateId, id)
|
|
|
+ .orderByDesc(IndustryPlate::getPlateDate)
|
|
|
+ .between(IndustryPlate::getPlateDate, monday, sunday);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
List<IndustryPlate> industryPlates = industryPlateMapper.selectList(queryWrapper);
|
|
|
return industryPlates;
|
|
|
}
|
|
@@ -439,7 +508,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
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("lastFriday").toString());
|
|
|
+ plates = findIndustryPlate(false, null, map.get("friday").toString(), map.get("nextFriday").toString());
|
|
|
}
|
|
|
// List<IndustryPlate> plates = industryPlateMapper.selectList(industryPlateQueryWrapper);
|
|
|
// 此处去重。
|
|
@@ -461,10 +530,12 @@ public class SearchServiceImpl implements SearchService {
|
|
|
QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
|
|
|
industryInfoQueryWrapper.lambda()
|
|
|
.eq(IndustryInfo::getPlateId, plate.getPlateId());
|
|
|
- // List<IndustryInfo> infos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
+ List<IndustryInfo> infos = industryInfoMapper.selectList(industryInfoQueryWrapper);
|
|
|
incInfo = IncInfo.builder()
|
|
|
.industryId(plate.getPlateId())
|
|
|
- .industryName(plate.getPlateName())
|
|
|
+ // .industryName(plate.getPlateName())
|
|
|
+ // todo 后期需要修改。
|
|
|
+ .industryName(infos.get(0).getPlateName())
|
|
|
.industryValue(value)
|
|
|
.industryTag(industryTag)
|
|
|
.build();
|
|
@@ -510,13 +581,13 @@ public class SearchServiceImpl implements SearchService {
|
|
|
List<IndustryPlate> plates = new ArrayList<>();
|
|
|
// 涨跌均存在。根据行业id查询进来的。
|
|
|
QueryWrapper<IndustryPlate> queryWrapper = new QueryWrapper();
|
|
|
- System.err.println(searchInfo.getSearchParam());
|
|
|
if (DateUtils.checkDate(friday,lastFriday).equals(true)){
|
|
|
queryWrapper.lambda()
|
|
|
.eq(IndustryPlate::getPlateId, searchInfo.getSearchParam())
|
|
|
.orderByDesc(IndustryPlate::getPlateDate)
|
|
|
.groupBy(IndustryPlate::getPlateId)
|
|
|
.between(IndustryPlate::getPlateDate, lastFriday, friday)
|
|
|
+ .last("limit 0,10")
|
|
|
.or()
|
|
|
.like(IndustryPlate::getPlateName, searchInfo.getSearchParam());
|
|
|
}else {
|
|
@@ -525,6 +596,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
.orderByDesc(IndustryPlate::getPlateDate)
|
|
|
.groupBy(IndustryPlate::getPlateId)
|
|
|
.between(IndustryPlate::getPlateDate, friday, lastFriday)
|
|
|
+ .last("limit 0,10")
|
|
|
.or()
|
|
|
.like(IndustryPlate::getPlateName, searchInfo.getSearchParam());
|
|
|
}
|
|
@@ -551,6 +623,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
}
|
|
|
industryPlateQueryWrapper.groupBy("plate_id");
|
|
|
industryPlateQueryWrapper.isNotNull("plate_id");
|
|
|
+ industryPlateQueryWrapper.last("limit 0,10");
|
|
|
if (just.equals(false)) {
|
|
|
if (DateUtils.checkDate(friday,lastFriday).equals(true)){
|
|
|
industryPlateQueryWrapper.between("plate_date", lastFriday, friday);
|
|
@@ -612,15 +685,19 @@ public class SearchServiceImpl implements SearchService {
|
|
|
}
|
|
|
|
|
|
public Float getCloseValue(List<IndustryPlate> industryPlates,List<IndustryPlate> industryPlatesLast){
|
|
|
- Float close = industryPlates.size() > 0 ? industryPlates.get(0).getPlateClose() : 0.0F;
|
|
|
- Float lastClose = industryPlatesLast.size() > 0 ? industryPlatesLast.get(0).getPlateClose() : 1.0F;
|
|
|
+ Float close = industryPlates.size() > 0 ? null != industryPlates.get(0).getPlateClose() ?
|
|
|
+ industryPlates.get(0).getPlateClose() : 0.0F : 0.0F;
|
|
|
+ Float lastClose = industryPlatesLast.size() > 0 ? null != industryPlatesLast.get(0).getPlateClose() ?
|
|
|
+ industryPlatesLast.get(0).getPlateClose() : 0.0F : 0.0F;
|
|
|
Float value = close - lastClose;
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
public Float getPredValue(List<IndustryPlate> industryPlates,List<IndustryPlate> industryPlatesLast){
|
|
|
- Float pred = industryPlates.size() > 0 ? industryPlates.get(0).getPlateClosePred() : 0.0F;
|
|
|
- Float lastPred = industryPlatesLast.size() > 0 ? industryPlatesLast.get(0).getPlateClosePred() : 1.0F;
|
|
|
+ Float pred = industryPlates.size() > 0 ? null != industryPlates.get(0).getPlateClosePred() ?
|
|
|
+ industryPlates.get(0).getPlateClosePred() : 0.0F : 0.0F;
|
|
|
+ Float lastPred = industryPlatesLast.size() > 0 ? null != industryPlatesLast.get(0).getPlateClosePred() ?
|
|
|
+ industryPlatesLast.get(0).getPlateClosePred() : 0.0F : 0.0F;
|
|
|
Float value = pred - lastPred;
|
|
|
return value;
|
|
|
}
|