main
黄海 7 months ago
parent f314b449d9
commit 84264a9b75

@ -6,11 +6,15 @@ import com.dsideal.base.DataEase.Model.DataEaseModel;
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
import com.dsideal.base.Util.CommonUtil;
import com.dsideal.base.Util.FileUtil;
import com.jfinal.kit.Kv;
import com.jfinal.kit.PathKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.SqlPara;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.dsideal.base.DataEase.Model.DataEaseModel.DB_NAME;
import static com.dsideal.base.DataEase.Util.Step3_CopyBigScreen.*;
@ -22,8 +26,6 @@ public class Step2_CopyFilter {
public static DataEaseModel dm = new DataEaseModel();
/**
*
*
@ -62,6 +64,23 @@ public class Step2_CopyFilter {
}
}
/**
* ID
*
* @param scene_id
* @return
*/
public static Map<Long, Long> queryChartViewFilterFieldId(long scene_id) {
Map<Long, Long> map = new HashMap<>();
Kv kv = Kv.by("scene_id", scene_id);
SqlPara sqlPara = Db.getSqlPara("DataEase.queryChartViewFilterFieldId", kv);
List<Record> list = Db.use(DB_NAME).find(sqlPara);
for (Record record : list) {
map.put(record.getLong("id"), record.getLong("table_field_id"));
}
return map;
}
/**
*
*
@ -82,6 +101,9 @@ public class Step2_CopyFilter {
String screenName = LocalMysqlConnectUtil.PropKit.get("dataEase.dataVisualizationNameCity");//要拷贝出来的屏幕名称
long childId = callApiToCopy(screenName, motherId, pid);
//只有一个复制的大屏当然只有一个字段map,如果是16个的话就需要放到循环里面进行获取map
Map<Long, Long> mapField = queryChartViewFilterFieldId(childId);
// 修改地图中城市
List<Record> listMap = dm.getMap(childId);
//获取城市编码
@ -103,13 +125,17 @@ public class Step2_CopyFilter {
String custom_filter_json = cn.hutool.core.io.FileUtil.readUtf8String(PathKit.getRootClassPath() + "/Data/filter.json");
for (Record record : list) {
long id = record.getLong("id");
long fieldId = mapField.get(id);
String custom_filter = record.getStr("custom_filter");
JSONObject jo = JSONObject.parseObject(custom_filter);
jo.put("logic", "and");
if (jo.getJSONArray("items") == null) {
jo = JSONObject.parseObject(custom_filter_json);
jo.getJSONArray("items").getJSONObject(0).put("fieldId", fieldId);
} else {
jo.getJSONArray("items").add(JSONObject.parseObject(custom_filter_json).getJSONArray("items").getJSONObject(0));
JSONObject newJo = JSONObject.parseObject(custom_filter_json).getJSONArray("items").getJSONObject(0);
newJo.put("fieldId", fieldId);
jo.getJSONArray("items").add(newJo);
}
sql = "update core_chart_view set custom_filter=? where id=?";
Db.use(DB_NAME).update(sql, jo.toString(), id);
@ -123,7 +149,6 @@ public class Step2_CopyFilter {
}
public static void main(String[] args) throws InterruptedException {
//连接本地数据库系统
LocalMysqlConnectUtil.Init();

@ -33,4 +33,14 @@
where t1.province_id='FD61813E-70A1-42AB-9A8E-141ED4D47B98' and t1.level_id=5
order by t1.city_id
#end
#sql("queryChartViewFilterFieldId")
select * from (
select t1.id,t1.title,t1.table_id,t1.custom_filter,
(select t2.id from core_dataset_table_field as t2
where t2.dataset_table_id =(select t3.id from core_dataset_table as t3 where t3.dataset_group_id=t1.table_id) and t2.origin_name='行政区划') as table_field_id
from core_chart_view as t1 where t1.scene_id=#para(scene_id) and t1.table_id>0
and t1.type not like '%map%'
) as tt where table_field_id is not null ;
#end
#end
Loading…
Cancel
Save