|
|
|
@ -14,61 +14,89 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class ChangeDataEaseCity {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取指定大屏中的地图配置信息
|
|
|
|
|
* @param bigScreenId 大屏ID
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static List<Record> getMap(long bigScreenId) {
|
|
|
|
|
String sql = "select id,custom_attr from dataease.core_chart_view where scene_id=? and type='map'";
|
|
|
|
|
List<Record> list = Db.find(sql, bigScreenId);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取城市编码
|
|
|
|
|
*
|
|
|
|
|
* @param cityName 城市名称
|
|
|
|
|
* @return 城市编码
|
|
|
|
|
*/
|
|
|
|
|
public static String getCityCode(String cityName) {
|
|
|
|
|
String sql = "select area_code from t_city_code where area_name=?";
|
|
|
|
|
return Db.findFirst(sql, cityName).getStr("area_code");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 测试地址:
|
|
|
|
|
* http://10.10.14.203:8100/#/de-link/zud8IQ8J
|
|
|
|
|
*
|
|
|
|
|
* @param args
|
|
|
|
|
*/
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
//加载配置文件
|
|
|
|
|
String configFile = "application_dev.yaml";
|
|
|
|
|
Prop PropKit = new YamlProp(configFile);
|
|
|
|
|
|
|
|
|
|
HikariCpPlugin dataEasePlugin = new HikariCpPlugin(PropKit.get("mysql.jdbcUrl").replace("ds_db", DataEaseModel.DB_NAME), PropKit.get("mysql.user"),
|
|
|
|
|
HikariCpPlugin dataEasePlugin = new HikariCpPlugin(PropKit.get("mysql.jdbcUrl"), PropKit.get("mysql.user"),
|
|
|
|
|
PropKit.get("mysql.password").trim(), PropKit.get("mysql.driverClassName"));
|
|
|
|
|
dataEasePlugin.start();
|
|
|
|
|
|
|
|
|
|
// 配置ActiveRecord插件
|
|
|
|
|
ActiveRecordPlugin arpDataEase = new ActiveRecordPlugin(DataEaseModel.DB_NAME, dataEasePlugin);
|
|
|
|
|
arpDataEase.setDialect(new MysqlDialect());
|
|
|
|
|
|
|
|
|
|
//启动数据库
|
|
|
|
|
arpDataEase.start();
|
|
|
|
|
|
|
|
|
|
//要修改的大屏中文名称
|
|
|
|
|
String dataVisualizationName = "黄海测试的市州地图";
|
|
|
|
|
//要修改的市州名称,需要用全称
|
|
|
|
|
/**
|
|
|
|
|
156530100 昆明市
|
|
|
|
|
156530300 曲靖市
|
|
|
|
|
156530400 玉溪市
|
|
|
|
|
156530500 保山市
|
|
|
|
|
156530600 昭通市
|
|
|
|
|
156530700 丽江市
|
|
|
|
|
156530800 普洱市
|
|
|
|
|
156530900 临沧市
|
|
|
|
|
156532300 楚雄彝族自治州
|
|
|
|
|
156532500 红河哈尼族彝族自治州
|
|
|
|
|
156532600 文山壮族苗族自治州
|
|
|
|
|
156532800 西双版纳傣族自治州
|
|
|
|
|
156532900 大理白族自治州
|
|
|
|
|
156533100 德宏傣族景颇族自治州
|
|
|
|
|
156533300 怒江傈僳族自治州
|
|
|
|
|
156533400 迪庆藏族自治州
|
|
|
|
|
*/
|
|
|
|
|
String cityName = "红河哈尼族彝族自治州";
|
|
|
|
|
|
|
|
|
|
//取出大屏的ID值
|
|
|
|
|
String sql = "select * from data_visualization_info where name ='黄海测试的市州地图'";
|
|
|
|
|
Record dataVisualizationInfo = Db.findFirst(sql);
|
|
|
|
|
String sql = "select * from dataease.data_visualization_info where name =?";
|
|
|
|
|
Record dataVisualizationInfo = Db.findFirst(sql, dataVisualizationName);
|
|
|
|
|
long bigScreenId = dataVisualizationInfo.getLong("id");
|
|
|
|
|
System.out.println(bigScreenId);
|
|
|
|
|
// 配置的内容
|
|
|
|
|
sql = "select id,custom_attr from core_chart_view where scene_id=? and type='map'";
|
|
|
|
|
List<Record> list = Db.find(sql, bigScreenId);
|
|
|
|
|
|
|
|
|
|
List<Record> list = getMap(bigScreenId);
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
long id = record.getLong("id");
|
|
|
|
|
com.alibaba.fastjson2.JSONObject jo = com.alibaba.fastjson2.JSONObject.parseObject(record.getStr("custom_attr"));
|
|
|
|
|
System.out.println(jo.getJSONObject("map").getString("level"));
|
|
|
|
|
System.out.println(jo.getJSONObject("map").getString("id"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (jo.getJSONObject("map").getString("id").equals("156530100")) {
|
|
|
|
|
//修改为楚雄
|
|
|
|
|
jo.getJSONObject("map").put("id", "156532300");
|
|
|
|
|
jo.getJSONObject("map").put("level", "city");
|
|
|
|
|
} else {
|
|
|
|
|
//修改为昆明
|
|
|
|
|
jo.getJSONObject("map").put("id", "156530100");
|
|
|
|
|
jo.getJSONObject("map").put("level", "city");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//回写到数据库
|
|
|
|
|
JSONObject jo = JSONObject.parseObject(record.getStr("custom_attr"));
|
|
|
|
|
//获取城市编码
|
|
|
|
|
String area_code = getCityCode(cityName);
|
|
|
|
|
//修改城市编码
|
|
|
|
|
jo.getJSONObject("map").put("id", area_code);
|
|
|
|
|
jo.getJSONObject("map").put("level", "city");
|
|
|
|
|
//写到数据库
|
|
|
|
|
String jsonString = jo.toJSONString();
|
|
|
|
|
Db.update("update core_chart_view set custom_attr=? where id=?", jsonString, id);
|
|
|
|
|
Db.update("update dataease.core_chart_view set custom_attr=? where id=?", jsonString, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* json格式化工具
|
|
|
|
|
* https://www.uutils.com/format/json.htm
|
|
|
|
|
*
|
|
|
|
|
* 互联网:2023年,省市县行政区划名称及编码对照表、最新省市区表1
|
|
|
|
|
* https://blog.csdn.net/isworking/article/details/128630487
|
|
|
|
|
云南省
|
|
|
|
|
province 156530000
|
|
|
|
|
220000000000
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|