Prechádzať zdrojové kódy

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

wuweihao 2 rokov pred
rodič
commit
9ea91e791f

+ 11 - 6
720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/FileUtils.java

@@ -880,18 +880,15 @@ public class FileUtils {
     /**
      * 转换文件单位
      * @param unit MB 默认
-     * @param num
      * @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);
+           // 四舍五入 取整
+           decimal = decimal.setScale(0, BigDecimal.ROUND_HALF_UP);
+           log.info("MB: {}", decimal);
         } else if ("GB".equals(unit)){
             decimal = decimal.divide(new BigDecimal("1024"), 0, BigDecimal.ROUND_HALF_UP);
             log.info("GB: {}", decimal);
@@ -901,5 +898,13 @@ public class FileUtils {
         return Integer.parseInt(s);
     }
 
+    @Test
+    public void test(){
+        String volume = "1000";
+        BigDecimal decimal = new BigDecimal(volume);
+        decimal = decimal.setScale(0, BigDecimal.ROUND_HALF_UP);
+        System.out.println(decimal);
+    }
+
 
 }

+ 9 - 0
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/AgeController.java

@@ -10,6 +10,7 @@ import com.gis.service.ReportService;
 import com.gis.service.WorkService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -20,6 +21,7 @@ import javax.validation.Valid;
  * Created by owen on 2022/6/28 0028 16:56
  *
  */
+@Slf4j
 @Api(tags = "v1.3-提供四维看看接口 请求头需要appId")
 @RestController
 @RequestMapping("/api/age")
@@ -85,4 +87,11 @@ public class AgeController {
         po.setPoType("work");
         return reportService.workTrend(po);
     }
+
+//    @ApiOperation(value = "v1.3-解密并发测试")
+//    @GetMapping("/decode")
+//    public Result decode()  {
+//        log.info("测试解密并发");
+//        return Result.success("完成");
+//    }
 }

+ 2 - 0
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/TestController.java

@@ -296,4 +296,6 @@ public class TestController extends BaseController {
 
 
 
+
+
 }