|
|
|
@ -92,6 +92,48 @@ public class CopyBigScreen {
|
|
|
|
|
return Db.use(DataEaseModel.DB_NAME).findFirst(sql, dataVisualizationNameCity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 调用API拷贝大屏
|
|
|
|
|
*
|
|
|
|
|
* @param screenName 目标大屏名称
|
|
|
|
|
* @param id 源大屏ID
|
|
|
|
|
* @param pid 源大屏所属文件夹id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static long callApiToCopy(String screenName, long id, long pid) {
|
|
|
|
|
//拷贝API
|
|
|
|
|
String url = urlPrefix + "/de2api/dataVisualization/copy";
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
jo.put("nodeType", "leaf");
|
|
|
|
|
jo.put("name", screenName);
|
|
|
|
|
jo.put("type", "dataV");
|
|
|
|
|
jo.put("id", id);
|
|
|
|
|
jo.put("pid", pid);
|
|
|
|
|
String res = HttpUtil.createPost(url).contentType("application/json")
|
|
|
|
|
.header("x-de-token", getToken()).body(jo.toString()).execute().body();
|
|
|
|
|
long childId = Long.parseLong(JSONObject.parseObject(res).getString("data"));
|
|
|
|
|
|
|
|
|
|
//更新pid,没有这步的话,在界面上看不到拷贝出来的大屏!
|
|
|
|
|
String sql = "update data_visualization_info set pid=? where id=?";
|
|
|
|
|
Db.use(DB_NAME).update(sql, pid, childId);
|
|
|
|
|
return childId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 发布共享链接
|
|
|
|
|
*
|
|
|
|
|
* @param motherShareRecord
|
|
|
|
|
* @param childId
|
|
|
|
|
*/
|
|
|
|
|
public static void publishShare(Record motherShareRecord, long childId) {
|
|
|
|
|
//发布共享链接
|
|
|
|
|
Record shareRecord = new Record().setColumns(motherShareRecord);
|
|
|
|
|
shareRecord.set("resource_id", childId);
|
|
|
|
|
shareRecord.set("id", CommonUtil.getSnowId());
|
|
|
|
|
shareRecord.set("uuid", CommonUtil.randomString(8));//大小写字母和数字组合,长度为8
|
|
|
|
|
Db.use(DataEaseModel.DB_NAME).save("xpack_share", "id", shareRecord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拷贝城市大屏
|
|
|
|
|
*
|
|
|
|
@ -114,21 +156,7 @@ public class CopyBigScreen {
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
String cityName = list.get(i);
|
|
|
|
|
String screenName = dataVisualizationNameCity + cityName;//要拷贝出来的屏幕名称
|
|
|
|
|
//拷贝API
|
|
|
|
|
String url = urlPrefix + "/de2api/dataVisualization/copy";
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
jo.put("nodeType", "leaf");
|
|
|
|
|
jo.put("name", screenName);
|
|
|
|
|
jo.put("type", "dataV");
|
|
|
|
|
jo.put("id", motherId);
|
|
|
|
|
jo.put("pid", pid);
|
|
|
|
|
String res = HttpUtil.createPost(url).contentType("application/json")
|
|
|
|
|
.header("x-de-token", getToken()).body(jo.toString()).execute().body();
|
|
|
|
|
long childId = Long.parseLong(JSONObject.parseObject(res).getString("data"));
|
|
|
|
|
|
|
|
|
|
//更新pid,没有这步的话,在界面上看不到拷贝出来的大屏!
|
|
|
|
|
sql = "update data_visualization_info set pid=? where id=?";
|
|
|
|
|
Db.use(DB_NAME).update(sql, pid, childId);
|
|
|
|
|
long childId = callApiToCopy(screenName, motherId, pid);
|
|
|
|
|
|
|
|
|
|
// 修改地图中城市
|
|
|
|
|
List<Record> listMap = dm.getMap(childId);
|
|
|
|
@ -137,7 +165,7 @@ public class CopyBigScreen {
|
|
|
|
|
//core_chart_view表
|
|
|
|
|
for (Record record : listMap) {
|
|
|
|
|
long id = record.getLong("id");
|
|
|
|
|
jo = JSONObject.parseObject(record.getStr("custom_attr"));
|
|
|
|
|
JSONObject jo = JSONObject.parseObject(record.getStr("custom_attr"));
|
|
|
|
|
//修改城市编码
|
|
|
|
|
jo.getJSONObject("map").put("id", area_code);
|
|
|
|
|
jo.getJSONObject("map").put("level", "city");
|
|
|
|
@ -162,11 +190,7 @@ public class CopyBigScreen {
|
|
|
|
|
cityParamsInfoRecord.set("params_info_id", UUID.randomUUID().toString());
|
|
|
|
|
Db.use(DB_NAME).save("visualization_outer_params_info", "params_info_id", cityParamsInfoRecord);
|
|
|
|
|
//发布共享链接
|
|
|
|
|
Record shareRecord = new Record().setColumns(motherShareRecord);
|
|
|
|
|
shareRecord.set("resource_id", childId);
|
|
|
|
|
shareRecord.set("id", CommonUtil.getSnowId());
|
|
|
|
|
shareRecord.set("uuid", CommonUtil.randomString(8));//大小写字母和数字组合,长度为8
|
|
|
|
|
Db.use(DataEaseModel.DB_NAME).save("xpack_share", "id", shareRecord);
|
|
|
|
|
publishShare(motherShareRecord, childId);
|
|
|
|
|
System.out.println((i + 1) + "、" + cityName + "修改完成,共" + (list.size()) + "个。");
|
|
|
|
|
}
|
|
|
|
|
System.out.println("恭喜,所有操作成功完成!");
|
|
|
|
@ -181,37 +205,20 @@ public class CopyBigScreen {
|
|
|
|
|
//清理掉旧的数据
|
|
|
|
|
clearScreen(dataVisualizationProvince);
|
|
|
|
|
//母屏信息
|
|
|
|
|
String sql = "select * from data_visualization_info where name =?";
|
|
|
|
|
Record motherRecord = Db.use(DataEaseModel.DB_NAME).findFirst(sql, dataVisualizationProvince);
|
|
|
|
|
Record motherRecord = getVisualizationByName(dataVisualizationProvince);
|
|
|
|
|
long motherId = motherRecord.getLong("id");//母屏ID
|
|
|
|
|
long pid = motherRecord.getLong("pid"); //隶属文件夹
|
|
|
|
|
|
|
|
|
|
//母屏共享链接
|
|
|
|
|
sql = "select * from xpack_share where resource_id=?";
|
|
|
|
|
String sql = "select * from xpack_share where resource_id=?";
|
|
|
|
|
Record motherShareRecord = Db.use(DataEaseModel.DB_NAME).findFirst(sql, motherId);
|
|
|
|
|
|
|
|
|
|
String screenName = dataVisualizationProvince + "【黄海】";//要拷贝出来的屏幕名称
|
|
|
|
|
//拷贝API
|
|
|
|
|
String url = urlPrefix + "/de2api/dataVisualization/copy";
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
jo.put("nodeType", "leaf");
|
|
|
|
|
jo.put("name", screenName);
|
|
|
|
|
jo.put("type", "dataV");
|
|
|
|
|
jo.put("id", motherId);
|
|
|
|
|
jo.put("pid", pid);
|
|
|
|
|
String res = HttpUtil.createPost(url).contentType("application/json")
|
|
|
|
|
.header("x-de-token", getToken()).body(jo.toString()).execute().body();
|
|
|
|
|
long childId = Long.parseLong(JSONObject.parseObject(res).getString("data"));
|
|
|
|
|
|
|
|
|
|
//更新pid,没有这步的话,在界面上看不到拷贝出来的大屏!
|
|
|
|
|
sql = "update data_visualization_info set pid=? where id=?";
|
|
|
|
|
Db.use(DB_NAME).update(sql, pid, childId);
|
|
|
|
|
long childId = callApiToCopy(screenName, motherId, pid);
|
|
|
|
|
|
|
|
|
|
//发布共享链接
|
|
|
|
|
Record shareRecord = new Record().setColumns(motherShareRecord);
|
|
|
|
|
shareRecord.set("resource_id", childId);
|
|
|
|
|
shareRecord.set("id", CommonUtil.getSnowId());
|
|
|
|
|
shareRecord.set("uuid", CommonUtil.randomString(8));//大小写字母和数字组合,长度为8
|
|
|
|
|
Db.use(DataEaseModel.DB_NAME).save("xpack_share", "id", shareRecord);
|
|
|
|
|
publishShare(motherShareRecord, childId);
|
|
|
|
|
System.out.println("恭喜,省级大屏拷贝完成!");
|
|
|
|
|
return motherId;
|
|
|
|
|
}
|
|
|
|
@ -239,17 +246,12 @@ public class CopyBigScreen {
|
|
|
|
|
LocalMysqlConnectUtil.Init();
|
|
|
|
|
//获取数据可视化名称
|
|
|
|
|
String dataVisualizationNameCity = LocalMysqlConnectUtil.PropKit.get("dataEase.dataVisualizationNameCity");
|
|
|
|
|
|
|
|
|
|
//获取数据可视化名称
|
|
|
|
|
String dataVisualizationProvince = LocalMysqlConnectUtil.PropKit.get("dataEase.dataVisualizationProvince");
|
|
|
|
|
|
|
|
|
|
//拷贝省级大屏
|
|
|
|
|
//copyProvinceScreen(dataVisualizationProvince);
|
|
|
|
|
|
|
|
|
|
copyProvinceScreen(dataVisualizationProvince);
|
|
|
|
|
//拷贝市州级大屏
|
|
|
|
|
//copyCityScreen(dataVisualizationNameCity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
copyCityScreen(dataVisualizationNameCity);
|
|
|
|
|
//更新复制出的省级大屏的链接路由
|
|
|
|
|
Record motherRecord = getVisualizationByName(dataVisualizationNameCity);
|
|
|
|
|
long motherId = motherRecord.getLong("id");//母屏ID
|
|
|
|
|