|
@@ -12,6 +12,9 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.apache.shiro.crypto.hash.Hash;
|
|
|
import org.jeecg.common.util.ResultMapUtils;
|
|
|
import org.jeecg.common.util.StatusCode;
|
|
|
+import org.jeecg.common.util.jsonschema.JsonschemaUtil;
|
|
|
+import org.jeecg.modules.ctop.entity.BytedanceAreaInfo;
|
|
|
+import org.jeecg.modules.ctop.mapper.BytedanceAreaInfoMapper;
|
|
|
import org.jeecg.modules.ctop.mapper.PlatformCampaignStatisticInfoMapper;
|
|
|
import org.jeecg.modules.ctop.service.ICreateInternalService;
|
|
|
import org.jeecg.modules.ctop.service.IReportService;
|
|
@@ -28,6 +31,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.*;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -405,4 +409,40 @@ public class SampleTest {
|
|
|
createInternalService.createInternal(json);
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BytedanceAreaInfoMapper areaInfoMapper;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void setJSONFile() {
|
|
|
+ String path = "C:\\Users\\宋英豪\\Downloads\\data_20190222\\city.json";
|
|
|
+ String jsonString = JsonschemaUtil.readJsonFile(path);
|
|
|
+ JSONObject data = JSONObject.parseObject(jsonString);
|
|
|
+ data.forEach((k, v) -> {
|
|
|
+ JSONObject getData = data.getJSONObject(k);
|
|
|
+ BytedanceAreaInfo areaInfo = new BytedanceAreaInfo();
|
|
|
+ Integer level = getData.getInteger("level");
|
|
|
+ Long id = getData.getLong("id");
|
|
|
+ String name = getData.getString("name");
|
|
|
+ System.out.println(name);
|
|
|
+ String parent = getData.getString("parent");
|
|
|
+ areaInfo.setId(id);
|
|
|
+ areaInfo.setLevel(level);
|
|
|
+ String code = id + "";
|
|
|
+ if (level == 1) {
|
|
|
+ areaInfo.setParentCode(parent);
|
|
|
+ areaInfo.setCode(code);
|
|
|
+ } else if (level == 2) {
|
|
|
+ areaInfo.setParentCode(code.substring(0, 2));
|
|
|
+ areaInfo.setCode(code.substring(0, 4));
|
|
|
+ } else {
|
|
|
+ areaInfo.setParentCode(code.substring(0, 4));
|
|
|
+ areaInfo.setCode(code);
|
|
|
+ }
|
|
|
+ areaInfo.setName(name);
|
|
|
+ areaInfo.setCreateTime(new Date());
|
|
|
+ areaInfo.setUpdateTime(new Date());
|
|
|
+ areaInfoMapper.insert(areaInfo);
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|