|
|
|
|
package com.dsideal.base.Tools;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
|
|
|
|
import com.dsideal.base.Plugin.YamlProp;
|
|
|
|
|
import com.jfinal.kit.Prop;
|
|
|
|
|
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
|
|
|
|
|
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class ChangeDataEaseCity {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"),
|
|
|
|
|
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();
|
|
|
|
|
//取出大屏的ID值
|
|
|
|
|
String sql = "select * from data_visualization_info where name ='黄海测试的市州地图'";
|
|
|
|
|
Record dataVisualizationInfo = Db.findFirst(sql);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//回写到数据库
|
|
|
|
|
String jsonString = jo.toJSONString();
|
|
|
|
|
Db.update("update 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
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|