|
|
|
|
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 {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取指定大屏中的地图配置信息
|
|
|
|
|
*
|
|
|
|
|
* @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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改大屏的城市地图为指定的城市
|
|
|
|
|
*
|
|
|
|
|
* @param dataVisualizationName 大屏名称
|
|
|
|
|
* @param cityName 城市名称
|
|
|
|
|
*/
|
|
|
|
|
public static void updateCity(String dataVisualizationName, String cityName) {
|
|
|
|
|
//取出大屏的ID值
|
|
|
|
|
String sql = "select * from dataease.data_visualization_info where name =?";
|
|
|
|
|
Record dataVisualizationInfo = Db.findFirst(sql, dataVisualizationName);
|
|
|
|
|
long bigScreenId = dataVisualizationInfo.getLong("id");
|
|
|
|
|
// 配置的内容
|
|
|
|
|
List<Record> list = getMap(bigScreenId);
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
long id = record.getLong("id");
|
|
|
|
|
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 dataease.core_chart_view set custom_attr=? where id=?", jsonString, id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 测试地址:
|
|
|
|
|
* 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"), 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 = "黄海测试的市州地图";
|
|
|
|
|
String cityName = "昭通市";
|
|
|
|
|
updateCity(dataVisualizationName, cityName);
|
|
|
|
|
/*
|
|
|
|
|
要修改的市州名称,需要用全称
|
|
|
|
|
156530100 昆明市
|
|
|
|
|
156530300 曲靖市
|
|
|
|
|
156530400 玉溪市
|
|
|
|
|
156530500 保山市
|
|
|
|
|
156530600 昭通市
|
|
|
|
|
156530700 丽江市
|
|
|
|
|
156530800 普洱市
|
|
|
|
|
156530900 临沧市
|
|
|
|
|
156532300 楚雄彝族自治州
|
|
|
|
|
156532500 红河哈尼族彝族自治州
|
|
|
|
|
156532600 文山壮族苗族自治州
|
|
|
|
|
156532800 西双版纳傣族自治州
|
|
|
|
|
156532900 大理白族自治州
|
|
|
|
|
156533100 德宏傣族景颇族自治州
|
|
|
|
|
156533300 怒江傈僳族自治州
|
|
|
|
|
156533400 迪庆藏族自治州
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|