|
@@ -4,6 +4,7 @@ import com.bizmatics.common.core.exception.BusinessException;
|
|
import com.bizmatics.common.core.util.DateUtils;
|
|
import com.bizmatics.common.core.util.DateUtils;
|
|
import com.bizmatics.mhfire.persistence.mapper.SiAeAllMapper;
|
|
import com.bizmatics.mhfire.persistence.mapper.SiAeAllMapper;
|
|
import com.bizmatics.mhfire.service.SiAeAllService;
|
|
import com.bizmatics.mhfire.service.SiAeAllService;
|
|
|
|
+import com.bizmatics.mhfire.service.util.Arith;
|
|
import com.bizmatics.mhfire.service.vo.SiAeAllVO;
|
|
import com.bizmatics.mhfire.service.vo.SiAeAllVO;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -28,12 +29,10 @@ public class SiAeAllServiceImpl implements SiAeAllService {
|
|
Optional.ofNullable(endTime).orElseThrow(() -> new BusinessException("结束时间不能为空"));
|
|
Optional.ofNullable(endTime).orElseThrow(() -> new BusinessException("结束时间不能为空"));
|
|
Map<String, Double> aeAllCollect = siAeAllMapper.selectAeAllCollect(startTime,endTime);
|
|
Map<String, Double> aeAllCollect = siAeAllMapper.selectAeAllCollect(startTime,endTime);
|
|
//获取同比
|
|
//获取同比
|
|
- startTime.setYear(Integer.parseInt(DateUtils.getYear(startTime)) - 1 -1900);
|
|
|
|
- endTime.setYear(Integer.parseInt(DateUtils.getYear(endTime)) - 1 -1900);
|
|
|
|
- Map<String, Double> upAllCollect = siAeAllMapper.selectAeAllCollect(startTime,endTime);
|
|
|
|
|
|
+ Date upStartTime = DateUtils.addYears(startTime, -1);
|
|
|
|
+ Date upEndTime = DateUtils.addYears(endTime, -1);
|
|
|
|
+ Map<String, Double> upAllCollect = siAeAllMapper.selectAeAllCollect(upStartTime,upEndTime);
|
|
//获取环比
|
|
//获取环比
|
|
- startTime.setYear(Integer.parseInt(DateUtils.getYear(startTime)) + 1 - 1900);
|
|
|
|
- endTime.setYear(Integer.parseInt(DateUtils.getYear(endTime)) + 1 - 1900);
|
|
|
|
//获取两个时间天数之差
|
|
//获取两个时间天数之差
|
|
int distanceOfTwoDate = DateUtils.getDistanceOfTwoDateNew(startTime, endTime);
|
|
int distanceOfTwoDate = DateUtils.getDistanceOfTwoDateNew(startTime, endTime);
|
|
Date linkEndTime = DateUtils.addDays(startTime, -1);
|
|
Date linkEndTime = DateUtils.addDays(startTime, -1);
|
|
@@ -46,14 +45,10 @@ public class SiAeAllServiceImpl implements SiAeAllService {
|
|
Double radio = aeAll.get(type);
|
|
Double radio = aeAll.get(type);
|
|
siAeAllVO.setNumber(radio);
|
|
siAeAllVO.setNumber(radio);
|
|
if (0 != radio){
|
|
if (0 != radio){
|
|
- double upRadio = Optional.ofNullable(upAllCollect).map(up -> up.get(type)).orElse(0.0)/radio;
|
|
|
|
- BigDecimal b = new BigDecimal(upRadio);
|
|
|
|
- upRadio = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
|
- siAeAllVO.setSameRatio(upRadio);
|
|
|
|
- double linkRadio = Optional.ofNullable(linkAllCollect).map(link -> link.get(type)).orElse(0.0)/radio;
|
|
|
|
- b = new BigDecimal(linkRadio);
|
|
|
|
- linkRadio = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
|
- siAeAllVO.setLinkRelativeRatio(linkRadio);
|
|
|
|
|
|
+ double upRadio = Optional.ofNullable(upAllCollect).map(up -> up.get(type)).orElse(0.0);
|
|
|
|
+ siAeAllVO.setSameRatio(Arith.div(upRadio,radio));
|
|
|
|
+ double linkRadio = Optional.ofNullable(linkAllCollect).map(link -> link.get(type)).orElse(0.0);
|
|
|
|
+ siAeAllVO.setLinkRelativeRatio(Arith.div(linkRadio,radio));
|
|
}else {
|
|
}else {
|
|
siAeAllVO.setSameRatio(0.00);
|
|
siAeAllVO.setSameRatio(0.00);
|
|
siAeAllVO.setLinkRelativeRatio(0.00);
|
|
siAeAllVO.setLinkRelativeRatio(0.00);
|
|
@@ -65,5 +60,4 @@ public class SiAeAllServiceImpl implements SiAeAllService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|