main
黄海 7 months ago
parent bda3ead20a
commit 5309374780

@ -152,14 +152,24 @@ public class Step2_CopyFilter {
List<Record> list = Db.use(DB_NAME).find(sql, childId); List<Record> list = Db.use(DB_NAME).find(sql, childId);
String custom_filter_json = cn.hutool.core.io.FileUtil.readUtf8String(PathKit.getRootClassPath() + "/Data/filter.json"); String custom_filter_json = cn.hutool.core.io.FileUtil.readUtf8String(PathKit.getRootClassPath() + "/Data/filter.json");
for (Record record : list) { for (Record record : list) {
long dataset_id = record.getLong("table_id");
sql = "select id from core_dataset_table_field where dataset_table_id =(" +
" select id from core_dataset_table where dataset_group_id=(select id from core_dataset_group where id=?)" +
") and origin_name='行政区划'";
long field_id = Db.use(DB_NAME).queryLong(sql, dataset_id);
long id = record.getLong("id"); long id = record.getLong("id");
String custom_filter = record.getStr("custom_filter"); String custom_filter = record.getStr("custom_filter");//原来的过滤器
JSONObject jo = JSONObject.parseObject(custom_filter); JSONObject jo = JSONObject.parseObject(custom_filter);//还原原来的过滤器为JSONObject
jo.put("logic","and"); jo.put("logic", "and");//过滤器默认连接器修改为and
if (jo.getJSONArray("items") == null) { if (jo.getJSONArray("items") == null) {
jo=JSONObject.parseObject(custom_filter_json); JSONObject newJo = JSONObject.parseObject(custom_filter_json);
newJo.getJSONArray("items").getJSONObject(0).put("fieldId", field_id);
jo = newJo;//修改掉fieldId
} else { } else {
jo.getJSONArray("items").add(JSONObject.parseObject(custom_filter_json).getJSONArray("items").getJSONObject(0)); JSONObject newJo = JSONObject.parseObject(custom_filter_json);
newJo.getJSONArray("items").getJSONObject(0).put("fieldId", field_id);
jo.getJSONArray("items").add(newJo);//添加上newJo
} }
sql = "update core_chart_view set custom_filter=? where id=?"; sql = "update core_chart_view set custom_filter=? where id=?";
Db.use(DB_NAME).update(sql, jo.toString(), id); Db.use(DB_NAME).update(sql, jo.toString(), id);

@ -104,6 +104,7 @@ public class Step3_CopyBigScreen {
String res = HttpUtil.createPost(url).contentType("application/json") String res = HttpUtil.createPost(url).contentType("application/json")
.header("x-de-token", getToken()).body(jo.toString()).execute().body(); .header("x-de-token", getToken()).body(jo.toString()).execute().body();
Thread.sleep(2200); Thread.sleep(2200);
System.out.println(res);
long childId = Long.parseLong(JSONObject.parseObject(res).getString("data")); long childId = Long.parseLong(JSONObject.parseObject(res).getString("data"));
//更新pid,没有这步的话,在界面上看不到拷贝出来的大屏! //更新pid,没有这步的话,在界面上看不到拷贝出来的大屏!

Loading…
Cancel
Save