|
@@ -19,6 +19,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.DayOfWeek;
|
|
|
import java.time.Instant;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -101,10 +102,12 @@ public class ReportServiceImpl implements ReportService {
|
|
|
if(!CollectionUtils.isEmpty(listFactoryCodeTotalReportVOS)) {
|
|
|
listFactoryCodeTotalReportVOS.forEach(listReportVO -> {
|
|
|
Double val = 0d;
|
|
|
+ //计算下载率
|
|
|
if (null != factoryCodeDownloadTotalMaps.get(listReportVO.getFactoryName())) {
|
|
|
val = factoryCodeDownloadTotalMaps.get(listReportVO.getFactoryName()).doubleValue() / listReportVO.getQrNumber().doubleValue() * 100;
|
|
|
}
|
|
|
- listReportVO.setDownloadNumber(new DecimalFormat("#0.00").format(val + 0.000001d) + "%");
|
|
|
+ //下载率取整
|
|
|
+ listReportVO.setDownloadNumber(new BigDecimal(Math.floor(val)).longValue());
|
|
|
});
|
|
|
}
|
|
|
// 封装出参
|
|
@@ -123,7 +126,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
null == reportReq.getEndTime() &&
|
|
|
null == reportReq.getBeginTime() &&
|
|
|
!ObjectUtils.isEmpty(reportReq.getValue())){
|
|
|
- HashMap<String, LocalDateTime> timestamp = getTimestamp(reportReq.getValue());
|
|
|
+ HashMap<String, String> timestamp = getTimestamp(reportReq.getValue());
|
|
|
reportReq.setBeginTime( timestamp.get("startTime"));
|
|
|
reportReq.setEndTime( timestamp.get("endTime"));
|
|
|
}
|
|
@@ -134,8 +137,8 @@ public class ReportServiceImpl implements ReportService {
|
|
|
* @param timeType (0-当天,1-本周,2-本月)
|
|
|
* @return key 开始时间:startTime 结束时间:endTime
|
|
|
*/
|
|
|
- private HashMap<String, LocalDateTime> getTimestamp(Integer timeType) {
|
|
|
- HashMap<String, LocalDateTime> hashMap = new HashMap<String, LocalDateTime>();
|
|
|
+ private HashMap<String, String> getTimestamp(Integer timeType) {
|
|
|
+ HashMap<String, String> hashMap = new HashMap<String, String>();
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
|
//当天
|
|
@@ -174,13 +177,12 @@ public class ReportServiceImpl implements ReportService {
|
|
|
* @author ludashi
|
|
|
* @date 2021/6/3 13:37
|
|
|
* @param l 时间毫秒值
|
|
|
- * @return java.time.LocalDateTime
|
|
|
+ * @return String
|
|
|
*/
|
|
|
- private LocalDateTime longTurnData(Long l) {
|
|
|
- Instant instant = Instant.ofEpochMilli(l);
|
|
|
- ZoneId zone = ZoneId.systemDefault();
|
|
|
- LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone);
|
|
|
- return localDateTime;
|
|
|
+ private static String longTurnData(Long l) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = new Date(l);
|
|
|
+ return simpleDateFormat.format(date);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -210,7 +212,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
@Override
|
|
|
public PackageCodeTypeRes queryPackageCodeGeneral(ReportReq reportReq) {
|
|
|
//0-准备时间参数
|
|
|
- Map<String,LocalDateTime> map=new HashMap<String,LocalDateTime>();
|
|
|
+ Map<String,String> map=new HashMap<String,String>();
|
|
|
//判断是否有参数值
|
|
|
if(null!= reportReq.getValue()){
|
|
|
//获取开始/结束时间
|
|
@@ -240,11 +242,10 @@ public class ReportServiceImpl implements ReportService {
|
|
|
ListPackageCodeVo downloadPresentBean = reportServiceMapper.queryPackageCodeNum(map.get("beginDate"), map.get("endDate"), 2);
|
|
|
//查询往期激活码(参数:开始时间,结束时间,1-同期/2-往期)
|
|
|
ListPackageCodeVo activatePresentBean = reportServiceMapper.queryActivateCodeNum(map.get("beginDate"), map.get("endDate"));
|
|
|
-
|
|
|
//计算增长率
|
|
|
res.setCreatePercent(percentBigDecimal(res.getCreateBoxNumber()+res.getCreateCapNumber(), createPresentBean.getQrBoxNumber()+createPresentBean.getQrCapNumber()));
|
|
|
- res.setCreatePercent(percentBigDecimal(res.getLoadBoxNumber()+res.getLoadCapNumber(), downloadPresentBean.getQrBoxNumber()+downloadPresentBean.getQrCapNumber()));
|
|
|
- res.setCreatePercent(percentBigDecimal(res.getActivateBoxNumber()+res.getActivateCapNumber(), activatePresentBean.getQrBoxNumber()+activatePresentBean.getQrCapNumber()));
|
|
|
+ res.setLoadPercent(percentBigDecimal(res.getLoadBoxNumber()+res.getLoadCapNumber(), downloadPresentBean.getQrBoxNumber()+downloadPresentBean.getQrCapNumber()));
|
|
|
+ res.setActivatePercent(percentBigDecimal(res.getActivateBoxNumber()+res.getActivateCapNumber(), activatePresentBean.getQrBoxNumber()+activatePresentBean.getQrCapNumber()));
|
|
|
}
|
|
|
|
|
|
//返回参数
|
|
@@ -258,7 +259,7 @@ public class ReportServiceImpl implements ReportService {
|
|
|
* @param reportReq
|
|
|
* @param map
|
|
|
*/
|
|
|
- private Map FillParam(ReportReq reportReq,Map<String,LocalDateTime> map) {
|
|
|
+ private Map FillParam(ReportReq reportReq,Map<String,String> map) {
|
|
|
setQueryTime(reportReq);
|
|
|
map=getBeforeWeekTime(reportReq.getValue().toString());
|
|
|
return map;
|
|
@@ -269,20 +270,20 @@ public class ReportServiceImpl implements ReportService {
|
|
|
* @param before 往期数
|
|
|
* @return
|
|
|
*/
|
|
|
- public static String percentBigDecimal(long present, long before) {
|
|
|
+ public static double percentBigDecimal(long present, long before) {
|
|
|
BigDecimal preNum = BigDecimal.valueOf(present);
|
|
|
BigDecimal sufNum = BigDecimal.valueOf(before);
|
|
|
double result = countDecimal(preNum, sufNum);
|
|
|
if (result > 0) {
|
|
|
- return "+" + result + "%";
|
|
|
+ return result;
|
|
|
}
|
|
|
if (result < 0) {
|
|
|
- return "-" + Math.abs(result) + "%";
|
|
|
+ return -Math.abs(result);
|
|
|
}
|
|
|
if (result == 0) {
|
|
|
- return "0%";
|
|
|
+ return 0;
|
|
|
}
|
|
|
- return null;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
public static double countDecimal(BigDecimal preNum, BigDecimal sufNum) {
|
|
@@ -341,20 +342,27 @@ public class ReportServiceImpl implements ReportService {
|
|
|
* 获取往期时间(1-周,2-月)
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String,LocalDateTime> getBeforeWeekTime(String value){
|
|
|
- Map<String,LocalDateTime> map=new HashMap<String,LocalDateTime>();
|
|
|
+ public static Map<String,String> getBeforeWeekTime(String value){
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd ");
|
|
|
+ Map<String,String> map=new HashMap<String,String>();
|
|
|
+ Calendar calStart = Calendar.getInstance();
|
|
|
+ Calendar calEnd = Calendar.getInstance();
|
|
|
if("1".equals(value)){
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
- LocalDateTime todayOfLastWeek = now.minusDays(7);
|
|
|
- map.put("beginDate",todayOfLastWeek.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusDays(1));
|
|
|
- map.put("endDate",todayOfLastWeek.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).minusDays(1));
|
|
|
+ calStart.add(Calendar.DAY_OF_MONTH,-7);//上一周
|
|
|
+ calEnd.add(Calendar.DAY_OF_MONTH,-7);
|
|
|
+ calStart.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
|
|
|
+ calEnd.setFirstDayOfWeek(Calendar.MONDAY);
|
|
|
+ calEnd.set(Calendar.DAY_OF_WEEK, calEnd.getFirstDayOfWeek() + 6);
|
|
|
}else{
|
|
|
- DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- LocalDateTime date2 = LocalDateTime.parse(fmt.format(LocalDateTime.now()), fmt);
|
|
|
- LocalDateTime localDateTime = date2.minusMonths(1);
|
|
|
- map.put("beginDate",localDateTime.with(TemporalAdjusters.firstDayOfMonth()));
|
|
|
- map.put("endDate",localDateTime.with(TemporalAdjusters.lastDayOfMonth()));
|
|
|
+ calStart.add(Calendar.MONTH, -1);//上一月
|
|
|
+ calEnd.add(Calendar.MONTH, -1);
|
|
|
+ calStart.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ calEnd.set(Calendar.DAY_OF_MONTH, calEnd.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
}
|
|
|
+ String beginTime = simpleDateFormat.format(calStart.getTime()) + "00:00:00";
|
|
|
+ String endTime = simpleDateFormat.format(calEnd.getTime()) + "23:59:59";
|
|
|
+ map.put("beginDate",beginTime);
|
|
|
+ map.put("endDate",endTime);
|
|
|
return map;
|
|
|
}
|
|
|
|