fix: 增加动量趋势接口

dev
laixingyu 3 years ago
parent 6f588dff93
commit 63fde2b21b

@ -45,6 +45,14 @@ public class StockController {
return ok(dongCaiSecondaryIndustryService.trendPlate(dongCaiSecondaryIndustryRequest)); return ok(dongCaiSecondaryIndustryService.trendPlate(dongCaiSecondaryIndustryRequest));
} }
@PostMapping(value = "/trends")
@ApiOperation("动量趋势板块")
public Result<PageList<DongCaiSecondaryIndustryResponse>> trends(@RequestBody DongCaiSecondaryIndustryRequest dongCaiSecondaryIndustryRequest) {
return ok(dongCaiSecondaryIndustryService.trends(dongCaiSecondaryIndustryRequest));
}
@PostMapping(value = "/riseLossesStatistics") @PostMapping(value = "/riseLossesStatistics")
@ApiOperation("首页-涨跌统计") @ApiOperation("首页-涨跌统计")

@ -16,7 +16,7 @@ public interface DongCaiSecondaryIndustryMapper extends BaseMapper<DongCaiSecond
/** /**
* *
* @param pageInfo * @param pageInfo
* @param firstDate * @param firstDate
* @param secondDate * @param secondDate
@ -29,5 +29,18 @@ public interface DongCaiSecondaryIndustryMapper extends BaseMapper<DongCaiSecond
@Param("sortSort") String sortSort, @Param("sortSort") String sortSort,
@Param("sortChangeSort")String sortChangeSort); @Param("sortChangeSort")String sortChangeSort);
/**
* ()
* @param pageInfo
* @param firstDate
* @param secondDate
* @param sortSort
* @param sortChangeSort
*/
Page<DongCaiSecondaryIndustry> trends(@Param("page") Page<PageModel> pageInfo,
@Param("firstDate")Date firstDate,
@Param("secondDate")Date secondDate,
@Param("sortSort") String sortSort,
@Param("sortChangeSort")String sortChangeSort,
@Param("type")String type);
} }

@ -44,4 +44,44 @@
</select> </select>
<!--
趋势板块查询trends
* @param pageInfo 分页
* @param firstDate 第一个日期
* @param secondDate 第二个日期
* @param sortSort 排序的排序
* @param sortChangeSort 排序变化的排序
* @param type 趋势类型 1日 10日 15日 20日 30日
Page<DongCaiSecondaryIndustry> trends(@Param("page") Page<PageModel> pageInfo,
@Param("firstDate")Date firstDate,
@Param("secondDate")Date secondDate,
@Param("sortSort") String sortSort,
@Param("sortChangeSort")String sortChangeSort,
@Param("type")String type);
-->
<select id="trends" resultType="com.ssdmn.biz.gupiao.pojo.domain.DongCaiSecondaryIndustry">
select t.trade_day as businessDate, t.blemind2 as securityName,d.security_code as securityCode,d.number_ingredients as numberIngredients, d.opening_price as openingPrice,
d.closing_price as closingPrice,d.volume as volume,d.turnover as turnover,d.total_capitalization as totalCapitalization,d.free_capitalization as freeCapitalization,
d.change_percentage as changePercentage,d.highest_price as highestPrice,d.lowest_price as lowestPrice, d.rise_number as riseNumber,d.losses_number as lossesNumber,
d.flat_number as flatNumber, d.rise_stop_number as riseStopNumber,d.losses_stop_number as lossesStopNumber,d.stop_number as stopNumber,d.recently_high as recentlyHigh,
d.recently_low as recentlyLow,d.pe_ttm as peTtm,d.pe_center_ttm as peCenterTtm,t.sort as sort,t.sort_change as sortChange, t.trend_value as trendValue,t.trend_value_change as trendValueChange
from trends t
left join dong_cai_secondary_industry d on (t.blemind2 = d.security_name)
where t.trade_day = #{firstDate} and d.business_date = #{firstDate} and t.type = #{type}
<choose>
<when test="sortSort != null and sortSort.trim() != '' and sortChangeSort != null and sortChangeSort.trim() != ''">
order by sort ${sortSort},sortChange ${sortChangeSort}
</when>
<otherwise>
<if test="sortSort != null and sortSort.trim() != '' ">
order by sort ${sortSort}
</if>
<if test="sortChangeSort != null and sortChangeSort.trim() != ''">
order by sortChange ${sortChangeSort}
</if>
</otherwise>
</choose>
</select>
</mapper> </mapper>

@ -129,4 +129,12 @@ public class DongCaiSecondaryIndustry {
@TableField(exist=false) @TableField(exist=false)
private Integer sortChange; private Integer sortChange;
@ApiModelProperty("动量值")
@TableField(exist=false)
private Integer trendValue;
@ApiModelProperty("动量值变化")
@TableField(exist=false)
private Integer trendValueChange;
} }

@ -32,6 +32,14 @@ public interface DongCaiSecondaryIndustryService extends IService<DongCaiSeconda
*/ */
PageList<DongCaiSecondaryIndustryResponse> trendPlate(DongCaiSecondaryIndustryRequest dongCaiSecondaryIndustryRequest); PageList<DongCaiSecondaryIndustryResponse> trendPlate(DongCaiSecondaryIndustryRequest dongCaiSecondaryIndustryRequest);
/**
*
*
* @param dongCaiSecondaryIndustryRequest
* @return
*/
PageList<DongCaiSecondaryIndustryResponse> trends(DongCaiSecondaryIndustryRequest dongCaiSecondaryIndustryRequest);
/** /**
* *
* @param securityCode code * @param securityCode code

@ -191,7 +191,96 @@ public class DongCaiSecondaryIndustryServiceImpl extends ServiceImpl<DongCaiSeco
return PageUtils.pageList((int)resultPage.getCurrent(),(int)resultPage.getSize(),(int)resultPage.getTotal(),collect); return PageUtils.pageList((int)resultPage.getCurrent(),(int)resultPage.getSize(),(int)resultPage.getTotal(),collect);
} }
public PageList<DongCaiSecondaryIndustryResponse> trends(DongCaiSecondaryIndustryRequest dongCaiSecondaryIndustryRequest){
// 分页
Page<DongCaiSecondaryIndustry> page = Querys.page(dongCaiSecondaryIndustryRequest.getPageModel());
// 类型
Integer trendType = 1;
if(ObjectUtil.isNotEmpty(dongCaiSecondaryIndustryRequest.getTrendType()) && dongCaiSecondaryIndustryRequest.getTrendType() > 0){
trendType = dongCaiSecondaryIndustryRequest.getTrendType();
}
if(ObjectUtil.isEmpty(dongCaiSecondaryIndustryRequest.getBusinessDate())){
dongCaiSecondaryIndustryRequest.setBusinessDate(DateUtil.parseDate(DateUtil.now()));
}
// 查询最后的日期
LambdaQueryWrapper<DongCaiSecondaryIndustry> queryWrapper = new LambdaQueryWrapper<DongCaiSecondaryIndustry>()
.select(DongCaiSecondaryIndustry::getBusinessDate)
.le(DongCaiSecondaryIndustry::getBusinessDate,dongCaiSecondaryIndustryRequest.getBusinessDate())
.groupBy(DongCaiSecondaryIndustry::getBusinessDate)
.orderByDesc(DongCaiSecondaryIndustry::getBusinessDate).last("limit " + trendType);
List<DongCaiSecondaryIndustry> dongCaiSecondaryIndustryList = list(queryWrapper);
Date firstDate = null;
Date secondDate = null;
if(dongCaiSecondaryIndustryList.size() > 1){
firstDate = dongCaiSecondaryIndustryList.get(0).getBusinessDate();
}
if(dongCaiSecondaryIndustryList.size() > 2){
secondDate = dongCaiSecondaryIndustryList.get(dongCaiSecondaryIndustryList.size() -1).getBusinessDate();
}
String sortField = dongCaiSecondaryIndustryRequest.getPageModel().getSortField();
String sortWay = dongCaiSecondaryIndustryRequest.getPageModel().getSortWay();
// 排名的排序
String sort = null;
// 排名变化的排序
String sortChange = null;
if(ObjectUtil.isNotEmpty(sortField)){
String[] sortFieldArr = sortField.split(",");
String[] sortWayArr = sortWay.split(",");
for (int i = 0; i < sortFieldArr.length; i++) {
String s = sortFieldArr[i];
if("sort".equals(s)){
try{
sort = sortWayArr[i];
}catch (Exception e){
sort = "desc";
}
}
if("sortChange".equals(s)){
try{
sortChange = sortWayArr[i];
}catch (Exception e){
sortChange = "desc";
}
}
}
}
Page<DongCaiSecondaryIndustry> resultPage = baseMapper.trends(new Page<>(dongCaiSecondaryIndustryRequest.getPageModel().getPageNo(),
dongCaiSecondaryIndustryRequest.getPageModel().getPageSize()),
firstDate,
secondDate,
sort,
sortChange,
trendType.toString());
List<DongCaiSecondaryIndustryResponse> collect = resultPage.getRecords().stream().map(dongCaiSecondaryIndustry ->
BeanUtil.toBean(dongCaiSecondaryIndustry, DongCaiSecondaryIndustryResponse.class)
).collect(Collectors.toList());
return PageUtils.pageList((int)resultPage.getCurrent(),(int)resultPage.getSize(),(int)resultPage.getTotal(),collect);
}
@Override @Override
public OriginalIssueStockSortResponseChange dongCaiSortChange(String securityCode) { public OriginalIssueStockSortResponseChange dongCaiSortChange(String securityCode) {

Loading…
Cancel
Save