Bläddra i källkod

作品趋势, 容量字符串.0处理

wuweihao 2 år sedan
förälder
incheckning
3d7b07e28a

+ 8 - 1
720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/FileUtils.java

@@ -884,6 +884,11 @@ public class FileUtils {
      * @return
      */
     public int convertUnit(String unit, String volume){
+
+        if (volume.contains(".")){
+            volume = StrUtil.subBefore(volume, ".", true);
+        }
+
         BigDecimal decimal = new BigDecimal(volume);
        if ("MB".equals(unit) || StrUtil.isBlank(unit)){
             log.info("MB: {}", volume);
@@ -891,7 +896,9 @@ public class FileUtils {
             decimal = decimal.divide(new BigDecimal("1024"), 0, BigDecimal.ROUND_HALF_UP);
             log.info("GB: {}", decimal);
         }
-        return Integer.valueOf(decimal.toString());
+        String s = decimal.toString();
+       log.info("结果:{}", s);
+        return Integer.parseInt(s);
     }
 
 

+ 1 - 18
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -491,24 +491,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
     }
 
 
-    /**
-     * 获取素材占用空容量
-     * @param unit 默认MB
-     * @return
-     */
-//    @Override
-//    public Integer getVolume(String unit) {
-//        String volume = entityMapper.sumSize();
-//        log.info("查询使用空间:{} MB", volume);
-//        BigDecimal decimal = new BigDecimal(volume);
-//       if ("MB".equals(unit) || StrUtil.isBlank(unit)){
-//            log.info("MB: {}", volume);
-//        } else if ("GB".equals(unit)){
-//            decimal = decimal.divide(new BigDecimal("1024"), 0, BigDecimal.ROUND_HALF_UP);
-//            log.info("GB: {}", decimal);
-//        }
-//        return Integer.valueOf(decimal.toString());
-//    }
+
 
     @Override
     public Integer getVolume(String unit) {

+ 28 - 5
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/ReportServiceImpl.java

@@ -254,8 +254,21 @@ public class ReportServiceImpl extends IBaseServiceImpl<ReportEntity, Long> impl
     private String workWeekTrentSql(String infoType, String type, String startTime, String endTime) {
         StringBuilder builder = new StringBuilder();
         builder.append(" select groupKey, mix,age, pano,type from (");
-        builder.append(" select DATE_FORMAT(DATE_ADD(day,INTERVAL- (WEEKDAY(day)) day),  '%Y-%m-%d' )  as groupKey, " +
-                "mix, pano, age,type from tb_report where is_delete=0 ");
+
+
+        if ("add".equals(infoType)) {
+            // 新增作品相加
+            builder.append(" select DATE_FORMAT(DATE_ADD(day,INTERVAL- (WEEKDAY(day)) day),  '%Y-%m-%d' )  as groupKey, sum(mix) as mix,sum(age) as age,sum(pano) as pano," +
+                    " type from tb_report where is_delete=0 ");
+        } else {
+            // 作品数取平均值
+            builder.append(" select DATE_FORMAT(DATE_ADD(day,INTERVAL- (WEEKDAY(day)) day),  '%Y-%m-%d' )  as groupKey, " +
+                    "ROUND(AVG(mix)) as mix," +
+                    "ROUND(AVG(age)) as age," +
+                    "ROUND(AVG(pano)) as pano," +
+                    " type from tb_report where is_delete=0 ");
+        }
+
         if (StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime)) {
             builder.append(" and day between '").append(startTime).append("' and '").append(endTime).append("'");
         } else {
@@ -263,7 +276,7 @@ public class ReportServiceImpl extends IBaseServiceImpl<ReportEntity, Long> impl
         }
         builder.append(" and type='").append(type).append("'");
         builder.append(" and info_type='").append(infoType).append("'");
-        builder.append(" ) as a group by groupKey");
+        builder.append(" group by groupKey ) as a ");
         builder.append(" order by groupKey desc");
 
         return builder.toString();
@@ -272,7 +285,17 @@ public class ReportServiceImpl extends IBaseServiceImpl<ReportEntity, Long> impl
     private String workMonthTrentSql(String infoType, String type, String startTime, String endTime) {
         StringBuilder builder = new StringBuilder();
         builder.append(" select groupKey, mix,age, pano,type from (");
-        builder.append(" select DATE_FORMAT(day, '%Y-%m')  as groupKey, mix,age, pano,type from tb_report where is_delete=0");
+
+        if ("add".equals(infoType)) {
+            builder.append(" select DATE_FORMAT(day, '%Y-%m')  as groupKey, sum(mix) as mix,sum(age) as age,sum(pano) as pano ,type from tb_report where is_delete=0");
+        } else {
+            builder.append(" select DATE_FORMAT(day, '%Y-%m')  as groupKey, " +
+                    "ROUND(AVG(mix)) as mix," +
+                    "ROUND(AVG(age)) as age," +
+                    "ROUND(AVG(pano)) as pano," +
+                    " type from tb_report where is_delete=0");
+        }
+
         if (StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime)) {
             builder.append(" and day between '").append(startTime).append("' and '").append(endTime).append("'");
         } else {
@@ -281,7 +304,7 @@ public class ReportServiceImpl extends IBaseServiceImpl<ReportEntity, Long> impl
         }
         builder.append(" and type='").append(type).append("'");
         builder.append(" and info_type='").append(infoType).append("'");
-        builder.append(" ) as a group by groupKey");
+        builder.append(" group by groupKey ) as a ");
         builder.append(" order by groupKey desc");
 
         return builder.toString();