|
|
|
@ -0,0 +1,96 @@
|
|
|
|
|
package com.dsideal.base.Test;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.dsideal.base.BaseApplication;
|
|
|
|
|
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
|
|
|
|
import com.dsideal.base.Plugin.YamlProp;
|
|
|
|
|
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class ChangeCityMap {
|
|
|
|
|
public static DataEaseModel dm = new DataEaseModel();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取所有地区代码和名称
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static List<Record> getAllAreaCodeName() {
|
|
|
|
|
String sql = "select area_code,area_name from t_city_code";
|
|
|
|
|
return Db.find(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 指定地区的所有子地区
|
|
|
|
|
*
|
|
|
|
|
* @param areaName
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static List<Record> getChildren(String areaName) {
|
|
|
|
|
String sql = "select * from t_dm_area where area_name=?";
|
|
|
|
|
String id = Db.findFirst(sql, areaName).getStr("id");
|
|
|
|
|
sql = "select * from t_dm_area where parent_id=?";
|
|
|
|
|
return Db.find(sql, id);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取一个DataEase的json对象,它用来对区域名进行全名与简称的转换
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static JSONObject getDataEaseJsonObject() {
|
|
|
|
|
List<Record> listArea = getAllAreaCodeName();
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
for (Record record : listArea) {
|
|
|
|
|
String area_code = record.getStr("area_code");
|
|
|
|
|
String area_name = record.getStr("area_name");
|
|
|
|
|
//根据名称获取它下面的所有城市全称和简称
|
|
|
|
|
List<Record> children = getChildren(area_name);
|
|
|
|
|
JSONObject j2 = new JSONObject();
|
|
|
|
|
for (Record child : children) {
|
|
|
|
|
String aName = child.getStr("area_name");
|
|
|
|
|
String bName = child.getStr("full_name");
|
|
|
|
|
j2.put(bName, aName);
|
|
|
|
|
}
|
|
|
|
|
jo.put(area_code, j2);
|
|
|
|
|
}
|
|
|
|
|
return jo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 156530000 : 云南下所有城市的全名:简名
|
|
|
|
|
// 156530100 : 昆明市下所有城市的全名:简名
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
//加载配置文件
|
|
|
|
|
String configFile = "application.yaml";
|
|
|
|
|
BaseApplication.PropKit = new YamlProp(configFile);
|
|
|
|
|
|
|
|
|
|
LocalMysqlConnectUtil.Init();
|
|
|
|
|
//大屏名称
|
|
|
|
|
String sceneName = "云南省教育决策支持系统【市州】";
|
|
|
|
|
String sql = "select * from data_visualization_info where name=?";
|
|
|
|
|
//大屏ID
|
|
|
|
|
String sceneId = Db.use(DataEaseModel.DB_NAME).findFirst(sql, sceneName).getStr("id");
|
|
|
|
|
|
|
|
|
|
System.out.println("sceneId=" + sceneId);
|
|
|
|
|
|
|
|
|
|
//此大屏下有两个地图
|
|
|
|
|
sql = "select id,senior from core_chart_view where scene_id=? and type like '%map%'";
|
|
|
|
|
List<Record> list = Db.use(DataEaseModel.DB_NAME).find(sql, sceneId);
|
|
|
|
|
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
String id = record.getStr("id");
|
|
|
|
|
String senior = record.getStr("senior");
|
|
|
|
|
JSONObject jo = JSONObject.parseObject(senior);
|
|
|
|
|
JSONObject fullYunNanMap = getDataEaseJsonObject();
|
|
|
|
|
jo.put("areaMapping", fullYunNanMap);
|
|
|
|
|
//更新数据库
|
|
|
|
|
sql = "update core_chart_view set senior=? where id=?";
|
|
|
|
|
Db.use(DataEaseModel.DB_NAME).update(sql, jo.toJSONString(), id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|