main
黄海 7 months ago
parent 5ac6a85a91
commit 86f54bbd53

@ -151,29 +151,15 @@ public class Step2_CopyFilter {
sql = "select * from core_chart_view where scene_id=? and table_id>0 and type not like '%map%'"; sql = "select * from core_chart_view where scene_id=? and table_id>0 and type not like '%map%'";
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");
int idx = 0;
for (Record record : list) { for (Record record : list) {
System.out.println("正在设置第" + (++idx) + "个数据~");
long dataset_id = record.getLong("table_id");
System.out.println("dataset_id=" + dataset_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='行政区划'";
Record r = Db.use(DB_NAME).findFirst(sql, dataset_id);
if (r == null) continue;
long field_id = r.getLong("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 JSONObject jo = JSONObject.parseObject(custom_filter);
jo.put("logic", "and");//过滤器默认连接器修改为and jo.put("logic","and");
if (jo.getJSONArray("items") == null) { if (jo.getJSONArray("items") == null) {
JSONObject newJo = JSONObject.parseObject(custom_filter_json); jo=JSONObject.parseObject(custom_filter_json);
newJo.getJSONArray("items").getJSONObject(0).put("fieldId", field_id);
jo = newJo;//修改掉fieldId
} else { } else {
JSONObject newJo = JSONObject.parseObject(custom_filter_json); jo.getJSONArray("items").add(JSONObject.parseObject(custom_filter_json).getJSONArray("items").getJSONObject(0));
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);

Loading…
Cancel
Save