|
@@ -1,5 +1,6 @@
|
|
|
package com.bizmatics.mhfire.service.impl;
|
|
|
|
|
|
+import com.bizmatics.common.core.exception.BusinessException;
|
|
|
import com.bizmatics.common.core.util.DateUtils;
|
|
|
import com.bizmatics.mhfire.persistence.mapper.SiAeAllMapper;
|
|
|
import com.bizmatics.mhfire.service.SiAeAllService;
|
|
@@ -7,10 +8,8 @@ import com.bizmatics.mhfire.service.vo.SiAeAllVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.nio.file.OpenOption;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author yq
|
|
@@ -24,6 +23,8 @@ public class SiAeAllServiceImpl implements SiAeAllService {
|
|
|
@Override
|
|
|
public List<SiAeAllVO> getAeAllCollect(Date startTime, Date endTime) {
|
|
|
List<SiAeAllVO> allVoS = new ArrayList<>();
|
|
|
+ Optional.ofNullable(startTime).orElseThrow(() -> new BusinessException("开始时间不能为空"));
|
|
|
+ Optional.ofNullable(endTime).orElseThrow(() -> new BusinessException("结束时间不能为空"));
|
|
|
Map<String, Double> aeAllCollect = siAeAllMapper.selectAeAllCollect(startTime,endTime);
|
|
|
//获取同比
|
|
|
startTime.setYear(Integer.parseInt(DateUtils.getYear(startTime)) - 1 -1900);
|
|
@@ -37,15 +38,19 @@ public class SiAeAllServiceImpl implements SiAeAllService {
|
|
|
Date linkEndTime = DateUtils.addDays(startTime, -1);
|
|
|
Date linkStartTime = DateUtils.addDays(linkEndTime, -distanceOfTwoDate);
|
|
|
Map<String, Double> linkAllCollect = siAeAllMapper.selectAeAllCollect(linkStartTime,linkEndTime);
|
|
|
- for (String type:aeAllCollect.keySet()) {
|
|
|
- SiAeAllVO siAeAllVO = new SiAeAllVO();
|
|
|
- siAeAllVO.setCheckType(type);
|
|
|
- Double radio = aeAllCollect.get(type);
|
|
|
- siAeAllVO.setNumber(radio.intValue());
|
|
|
- siAeAllVO.setSameRatio(upAllCollect.get(type)/radio);
|
|
|
- siAeAllVO.setLinkRelativeRatio(linkAllCollect.get(type)/radio);
|
|
|
- allVoS.add(siAeAllVO);
|
|
|
- }
|
|
|
+ Optional.ofNullable(aeAllCollect).ifPresent(aeAll -> {
|
|
|
+ for (String type:aeAll.keySet()) {
|
|
|
+ SiAeAllVO siAeAllVO = new SiAeAllVO();
|
|
|
+ siAeAllVO.setCheckType(type);
|
|
|
+ Double radio = aeAll.get(type);
|
|
|
+ siAeAllVO.setNumber(radio.intValue());
|
|
|
+ siAeAllVO.setSameRatio(
|
|
|
+ Optional.ofNullable(upAllCollect).map(up -> up.get(type)).orElse(0.0)/radio);
|
|
|
+ siAeAllVO.setSameRatio(
|
|
|
+ Optional.ofNullable(linkAllCollect).map(link -> link.get(type)).orElse(0.0)/radio);
|
|
|
+ allVoS.add(siAeAllVO);
|
|
|
+ }
|
|
|
+ });
|
|
|
return allVoS;
|
|
|
}
|
|
|
}
|