|
|
|
@ -2,6 +2,8 @@ package cn.chjyj.szwh; |
|
|
|
|
|
|
|
import cn.chjyj.szwh.mapper.FestivalsMapper; |
|
|
|
import cn.chjyj.szwh.utils.DateUtils; |
|
|
|
import cn.chjyj.szwh.utils.SzFileUtils; |
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
@ -112,4 +114,25 @@ public class NewTest { |
|
|
|
ex.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 计算资源文件大小 |
|
|
|
*/ |
|
|
|
@Test |
|
|
|
public void calFileSize(){ |
|
|
|
String originStr ="{\"register\":\"测试服南波二十五\",\"serviceType\":\"全景\",\"isliCode\":\"010003-000000000000011123999999-1\",\n" + |
|
|
|
"\"identifier\":\"010003-000000000000011123999999-1\",\"serviceCode\":\"010003\",\"titleName\":\"0bj-1013-04\",\n" + |
|
|
|
"\"releaseTime\":\"2022-10-13 20:11:22\",\"md5Val\":\"fce769143cf8cc634f37e66eab07b39c\",\"copyrightOwner\":\"\n" + |
|
|
|
"测试服南波二十六\",\"identifiers\":\"\",\"copyrightDurationEnd\":\"\",\n" + |
|
|
|
"\"copyrightOwnerShip\":\"测试服南波二十六\",\"description\":\"全景三维描述\",\"copyrightDurationStart\":\"\",\n" + |
|
|
|
"\"label\":\"标签\",\"metadataFileFormat\":\"obj\",\"systemIdentity\":\"3e2c0a92a88e48ef888083a2ae6692fd\",\n" + |
|
|
|
"\"typed\":\"三维全景\",\"carrier\":\"光盘\",\"otherIdentifiers\":\"测试服南波二十六\",\"metadataFileSize\":\"1581\",\n" + |
|
|
|
"\"contributors\":\"测试服南波二十六\",\"registrant\":\"测试服南波二十六\",\"copyrightRegNo\":\"2022\",\"registerDate\":\"2022-10-13 19:34:32\"}"; |
|
|
|
JSONObject json = JSONObject.parseObject(originStr); |
|
|
|
// 标的信息
|
|
|
|
Long filesize =json.getLongValue("metadataFileSize"); |
|
|
|
// 格式化文件大小
|
|
|
|
String formatFileSize = SzFileUtils.fileSizeFormat(filesize); |
|
|
|
System.out.println("资源文件大小:"+formatFileSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|