|
|
@ -2,13 +2,16 @@ package com.dsideal.base.DataEase.Util;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
|
|
|
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
|
|
|
|
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
|
|
|
|
import com.dsideal.base.Util.FileUtil;
|
|
|
|
import com.dsideal.base.Util.FileUtil;
|
|
|
|
import com.jfinal.kit.PathKit;
|
|
|
|
import com.jfinal.kit.PathKit;
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.dsideal.base.DataEase.Model.DataEaseModel.DB_NAME;
|
|
|
|
import static com.dsideal.base.DataEase.Model.DataEaseModel.DB_NAME;
|
|
|
|
|
|
|
|
|
|
|
@ -26,69 +29,127 @@ public class CallApiToCopy {
|
|
|
|
//读取Data目录下DataEaseLogin.json文件
|
|
|
|
//读取Data目录下DataEaseLogin.json文件
|
|
|
|
JSONObject jo = FileUtil.readJsonFile(PathKit.getRootClassPath() + "/Data/DataEaseLogin.json");
|
|
|
|
JSONObject jo = FileUtil.readJsonFile(PathKit.getRootClassPath() + "/Data/DataEaseLogin.json");
|
|
|
|
String url = urlPrefix + "/de2api/login/localLogin";
|
|
|
|
String url = urlPrefix + "/de2api/login/localLogin";
|
|
|
|
//.header("Authorization", "Bearer " + token)
|
|
|
|
|
|
|
|
String res = HttpUtil.createPost(url).contentType("application/json")
|
|
|
|
String res = HttpUtil.createPost(url).contentType("application/json")
|
|
|
|
.body(jo.toString()).execute().body();
|
|
|
|
.body(jo.toString()).execute().body();
|
|
|
|
return JSONObject.parseObject(res).getJSONObject("data").getString("token");
|
|
|
|
return JSONObject.parseObject(res).getJSONObject("data").getString("token");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DataEaseModel dm = new DataEaseModel();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void clear(String dataVisualizationName) {
|
|
|
|
|
|
|
|
//一、先删除后插入保持健康:保留:【云南省教育决策支持系统【市州】】,删除掉云南省教育决策支持系统【市州】+昆明市,云南省教育决策支持系统【市州】+楚雄州等数据
|
|
|
|
|
|
|
|
String sql = "select * from data_visualization_info where name like '%" + dataVisualizationName + "%' and name <>'" + dataVisualizationName + "'";
|
|
|
|
|
|
|
|
List<Record> toDelList = Db.use(DB_NAME).find(sql);
|
|
|
|
|
|
|
|
for (Record record : toDelList) {
|
|
|
|
|
|
|
|
long id = record.getLong("id");
|
|
|
|
|
|
|
|
//(1) 删除关联的表core_chart_view
|
|
|
|
|
|
|
|
sql = "delete from core_chart_view where scene_id=?";
|
|
|
|
|
|
|
|
Db.use(DB_NAME).update(sql, id);
|
|
|
|
|
|
|
|
//(2) 删除共享链接表
|
|
|
|
|
|
|
|
sql = "delete from xpack_share WHERE resource_id=?";
|
|
|
|
|
|
|
|
Db.use(DB_NAME).update(sql, id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//(3) 删除可视化资源表
|
|
|
|
|
|
|
|
sql = "delete from core_opt_recent where resource_id=?";
|
|
|
|
|
|
|
|
Db.use(DB_NAME).update(sql, id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// (4) 跳转记录表
|
|
|
|
|
|
|
|
sql = "delete from visualization_link_jump where source_dv_id=?";
|
|
|
|
|
|
|
|
Db.use(DB_NAME).update(sql, id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// (5) 跳转配置表
|
|
|
|
|
|
|
|
sql = "select * from visualization_link_jump_info where target_dv_id=?";
|
|
|
|
|
|
|
|
List<Record> jumpList = Db.use(DB_NAME).find(sql, id);
|
|
|
|
|
|
|
|
for (Record r : jumpList) {
|
|
|
|
|
|
|
|
long jumpId = r.getLong("id");
|
|
|
|
|
|
|
|
sql = "delete from visualization_link_jump_target_view_info where link_jump_info_id =?";
|
|
|
|
|
|
|
|
Db.use(DB_NAME).update(sql, jumpId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sql = "delete from visualization_link_jump_info where id=?";
|
|
|
|
|
|
|
|
Db.use(DB_NAME).update(sql, jumpId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// (6) 外部参数关联关系表
|
|
|
|
|
|
|
|
sql = "select params_id from visualization_outer_params where visualization_id=?";
|
|
|
|
|
|
|
|
String paramsId = Db.use(DB_NAME).queryStr(sql, id);
|
|
|
|
|
|
|
|
sql = "delete from visualization_outer_params_info where params_id=?";
|
|
|
|
|
|
|
|
Db.use(DB_NAME).update(sql, paramsId);
|
|
|
|
|
|
|
|
sql = "delete from visualization_outer_params where visualization_id=?";
|
|
|
|
|
|
|
|
Db.use(DB_NAME).update(sql, id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//(7) 删除主表数据
|
|
|
|
|
|
|
|
Db.use(DB_NAME).deleteById("data_visualization_info", id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("成功删除大屏数据" + toDelList.size() + "条~");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
LocalMysqlConnectUtil.Init();
|
|
|
|
LocalMysqlConnectUtil.Init();
|
|
|
|
|
|
|
|
//获取数据可视化名称
|
|
|
|
|
|
|
|
String dataVisualizationName = LocalMysqlConnectUtil.PropKit.get("dataEase.dataVisualizationName");
|
|
|
|
|
|
|
|
//旧的不去,新的不来
|
|
|
|
|
|
|
|
clear(dataVisualizationName);
|
|
|
|
//母屏的id
|
|
|
|
//母屏的id
|
|
|
|
String motherId = "1036286881547030528";
|
|
|
|
String motherId = "1036286881547030528";
|
|
|
|
//母屏所在的文件夹ID
|
|
|
|
//母屏所在的文件夹ID
|
|
|
|
String pid = "1036643788262608896";
|
|
|
|
String pid = "1036643788262608896";
|
|
|
|
//要拷贝出来的屏幕名称
|
|
|
|
|
|
|
|
String screenName = "云南省教育决策支持系统【市州】-copy";
|
|
|
|
|
|
|
|
String sql = "select canvas_style_data,component_data from data_visualization_info where id=?";
|
|
|
|
|
|
|
|
Record record = Db.use(DB_NAME).findFirst(sql, motherId);
|
|
|
|
|
|
|
|
String canvas_style_data = record.getStr("canvas_style_data");
|
|
|
|
|
|
|
|
String component_data = record.getStr("component_data");
|
|
|
|
|
|
|
|
//拷贝
|
|
|
|
|
|
|
|
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")
|
|
|
|
for (String cityName : dm.getCityNameList()) {
|
|
|
|
.header("x-de-token", getToken())
|
|
|
|
//要拷贝出来的屏幕名称
|
|
|
|
.body(jo.toString()).execute().body();
|
|
|
|
String screenName = dataVisualizationName + cityName;
|
|
|
|
String screenId = JSONObject.parseObject(res).getString("data");
|
|
|
|
//拷贝
|
|
|
|
System.out.println("生成大屏ID=" + screenId);
|
|
|
|
String url = urlPrefix + "/de2api/dataVisualization/copy";
|
|
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
JSONObject canvasViewInfo = FileUtil.readJsonFile(PathKit.getRootClassPath() + "/Data/CanvasViewInfo.json");
|
|
|
|
jo.put("nodeType", "leaf");
|
|
|
|
//将临时副本保存下来
|
|
|
|
jo.put("name", screenName);
|
|
|
|
url = urlPrefix + "/de2api/dataVisualization/saveCanvas";
|
|
|
|
jo.put("type", "dataV");
|
|
|
|
jo = new JSONObject();
|
|
|
|
jo.put("id", motherId);
|
|
|
|
jo.put("appData", null);
|
|
|
|
jo.put("pid", pid);
|
|
|
|
jo.put("canvasStyleData", canvas_style_data);
|
|
|
|
|
|
|
|
jo.put("canvasViewInfo", canvasViewInfo);
|
|
|
|
String res = HttpUtil.createPost(url).contentType("application/json")
|
|
|
|
jo.put("componentData", component_data);
|
|
|
|
.header("x-de-token", getToken())
|
|
|
|
jo.put("id", screenId);
|
|
|
|
.body(jo.toString()).execute().body();
|
|
|
|
jo.put("name", screenName);
|
|
|
|
long bigScreenId = Long.parseLong(JSONObject.parseObject(res).getString("data"));
|
|
|
|
jo.put("pid", pid);
|
|
|
|
System.out.println("生成大屏ID=" + bigScreenId);
|
|
|
|
jo.put("status", 1);
|
|
|
|
|
|
|
|
jo.put("type", "dataV");
|
|
|
|
//更新pid
|
|
|
|
jo.put("selfWatermarkStatus", true);
|
|
|
|
String sql = "update data_visualization_info set pid=? where id=?";
|
|
|
|
jo.put("creatorName", null);
|
|
|
|
Db.use(DB_NAME).update(sql, pid, bigScreenId);
|
|
|
|
jo.put("updateName", null);
|
|
|
|
|
|
|
|
jo.put("createTime", 1734047402783L);
|
|
|
|
// (3) 修改地图中城市
|
|
|
|
jo.put("updateTime", 1734047402783L);
|
|
|
|
List<Record> list = dm.getMap(bigScreenId);
|
|
|
|
jo.put("watermarkInfo", null);
|
|
|
|
//core_chart_view表
|
|
|
|
jo.put("weight", null);
|
|
|
|
for (Record record : list) {
|
|
|
|
jo.put("mobileLayout", false);
|
|
|
|
long id = record.getLong("id");
|
|
|
|
jo.put("dataState", "ready");
|
|
|
|
jo = JSONObject.parseObject(record.getStr("custom_attr"));
|
|
|
|
jo.put("optType", "copy");
|
|
|
|
//获取城市编码
|
|
|
|
|
|
|
|
String area_code = dm.getCityCode(cityName);
|
|
|
|
//将jo保存下来与原文档进行对比
|
|
|
|
//修改城市编码
|
|
|
|
//cn.hutool.core.io.FileUtil.writeUtf8String(jo.toString(), "c:/1.json");
|
|
|
|
jo.getJSONObject("map").put("id", area_code);
|
|
|
|
|
|
|
|
jo.getJSONObject("map").put("level", "city");
|
|
|
|
res = HttpUtil.createPost(url).contentType("application/json")
|
|
|
|
//写到数据库
|
|
|
|
.header("x-de-token", getToken())
|
|
|
|
String jsonString = jo.toString();
|
|
|
|
.body(jo.toString()).execute().body();
|
|
|
|
Db.use(DB_NAME).update("update core_chart_view set custom_attr=? where id=?", jsonString, id);
|
|
|
|
System.out.println(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//4、修改外部参数
|
|
|
|
|
|
|
|
sql = "select * from visualization_outer_params where visualization_id =?";
|
|
|
|
|
|
|
|
Record motherOuterParamsRecord = Db.use(DB_NAME).findFirst(sql, motherId);
|
|
|
|
|
|
|
|
String motherParamsId = motherOuterParamsRecord.getStr("params_id");
|
|
|
|
|
|
|
|
Record cityOuterParamsRecord = new Record().setColumns(motherOuterParamsRecord);
|
|
|
|
|
|
|
|
cityOuterParamsRecord.set("params_id", UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
cityOuterParamsRecord.set("visualization_id", bigScreenId);
|
|
|
|
|
|
|
|
Db.use(DB_NAME).save("visualization_outer_params", "params_id", cityOuterParamsRecord);
|
|
|
|
|
|
|
|
//复制外部参数关联关系表
|
|
|
|
|
|
|
|
sql = "select * from visualization_outer_params_info where params_id=?";
|
|
|
|
|
|
|
|
Record paramsInfoRecord = Db.use(DB_NAME).findFirst(sql, motherParamsId);
|
|
|
|
|
|
|
|
Record cityParamsInfoRecord = new Record().setColumns(paramsInfoRecord);
|
|
|
|
|
|
|
|
cityParamsInfoRecord.set("params_id", cityOuterParamsRecord.getStr("params_id"));
|
|
|
|
|
|
|
|
cityParamsInfoRecord.set("params_info_id", UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
Db.use(DB_NAME).save("visualization_outer_params_info", "params_info_id", cityParamsInfoRecord);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(cityName + "修改完成");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("ok");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|