|
|
|
@ -5,13 +5,14 @@ import com.air.measuredata.dto.MeasureTrendDto;
|
|
|
|
|
import com.air.measuredata.entity.MeasureData; |
|
|
|
|
import com.air.measuredata.mapper.MeasureDataMapper; |
|
|
|
|
import com.air.measuredata.serivce.MeasureDataService; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.air.utils.DateUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 测算数据 |
|
|
|
@ -33,22 +34,35 @@ public class MeasureDataServiceImpl extends ServiceImpl<MeasureDataMapper, Measu
|
|
|
|
|
//测试正确数
|
|
|
|
|
int precisionSum = this.count(Wrappers.<MeasureData>query().lambda().eq(MeasureData::getAccuracy, 1)); |
|
|
|
|
//准确率
|
|
|
|
|
BigDecimal precision = new BigDecimal(precisionSum).divide(totle).setScale(2, BigDecimal.ROUND_HALF_UP); |
|
|
|
|
BigDecimal precision = new BigDecimal(precisionSum).divide(totle,2, BigDecimal.ROUND_HALF_UP); |
|
|
|
|
//误差之和
|
|
|
|
|
BigDecimal absoluteValueSum = baseMapper.getErrorAbsoluteValueSum(); |
|
|
|
|
if (absoluteValueSum != null){ |
|
|
|
|
//预测误差
|
|
|
|
|
BigDecimal error = absoluteValueSum.divide(totle).setScale(2, BigDecimal.ROUND_HALF_UP); |
|
|
|
|
BigDecimal error = absoluteValueSum.divide(totle,2,BigDecimal.ROUND_HALF_UP); |
|
|
|
|
statisticsDto.setError(error.doubleValue()); |
|
|
|
|
} |
|
|
|
|
statisticsDto.setTotle(totle.intValue()); |
|
|
|
|
statisticsDto.setPrecision(precision); |
|
|
|
|
statisticsDto.setError(error); |
|
|
|
|
statisticsDto.setPrecision(precision.doubleValue()); |
|
|
|
|
return statisticsDto; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public MeasureTrendDto trend() { |
|
|
|
|
MeasureTrendDto trendDto = new MeasureTrendDto(); |
|
|
|
|
public List<MeasureTrendDto> trend() { |
|
|
|
|
//统计时间
|
|
|
|
|
LocalDate startTime = LocalDate.now().minusYears(1); |
|
|
|
|
return trendDto; |
|
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
|
String startTime = DateUtil.fromString(now.minusYears(1), "yyyyMM"); |
|
|
|
|
String endTime = DateUtil.fromString(now, "yyyyMM"); |
|
|
|
|
List<MeasureTrendDto> list = baseMapper.getTrend(startTime, endTime); |
|
|
|
|
for (MeasureTrendDto trend : list) { |
|
|
|
|
if (trend.getTotal() == 0) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
//平均差值= 溢价率差值/时间宗数
|
|
|
|
|
double value = new BigDecimal(trend.getPremiumSpread()).divide(new BigDecimal(trend.getTotal()),2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
trend.setAverage(value); |
|
|
|
|
} |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|