Browse Source

表报入参修改,bug修改

v_KaixiangGuo 3 years ago
parent
commit
c9610c993a

+ 2 - 2
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/ReportServiceMapper.java

@@ -32,7 +32,7 @@ public interface ReportServiceMapper  {
      * @param type 判断 1-生成码 2-下载码
      * @return
      */
-    ListPackageCodeVo queryPackageCodeNum(@Param("beginDate")LocalDateTime beginDate,@Param("endDate")LocalDateTime endDate,@Param("type")Integer type);
+    ListPackageCodeVo queryPackageCodeNum(@Param("beginDate")String beginDate,@Param("endDate")String endDate,@Param("type")Integer type);
 
     /**
      * 激活码总量
@@ -40,7 +40,7 @@ public interface ReportServiceMapper  {
      * @param endDate
      * @return
      */
-    ListPackageCodeVo queryActivateCodeNum(@Param("beginDate")LocalDateTime beginDate,@Param("endDate")LocalDateTime endDate);
+    ListPackageCodeVo queryActivateCodeNum(@Param("beginDate")String beginDate,@Param("endDate")String endDate);
 
 
     /**

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/ListFactoryCodeReportVO.java

@@ -21,5 +21,5 @@ public class ListFactoryCodeReportVO implements Serializable {
     private Long qrNumber;
 
     @ApiModelProperty("下载率")
-    private String downloadNumber;
+    private Long downloadNumber;
 }

+ 2 - 4
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/ReportReq.java

@@ -20,10 +20,8 @@ public class ReportReq implements Serializable {
     private Integer value;
 
     @ApiModelProperty("开始时间")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private LocalDateTime beginTime;
+    private String beginTime;
 
     @ApiModelProperty("结束时间")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private LocalDateTime endTime;
+    private String endTime;
 }

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/ListFactoryCodeReportRes.java

@@ -35,6 +35,6 @@ public class ListFactoryCodeReportRes implements Serializable {
         private Long qrNumber;
 
         @ApiModelProperty("下载率")
-        private String downloadNumber;
+        private Long downloadNumber;
     }
 }

+ 32 - 23
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/ReportServiceImpl.java

@@ -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()){
            //获取开始/结束时间
@@ -258,7 +260,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;
@@ -341,20 +343,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;
     }