main
黄海 9 months ago
parent 2044f45c78
commit 4d84fada5f

@ -49,11 +49,15 @@ public class DataEaseController extends Controller {
//发布的地址
String publish_url = BaseApplication.PropKit.get("dataEase.publish_url");
//先更新一下数据表
boolean success = dm.updateCity(dataVisualizationName, city_name);
if (!success) {
int res = dm.updateCity(dataVisualizationName, city_name);
if (res == -1) {
renderJson(CommonUtil.returnMessageJson(false, dataVisualizationName + "名称的大屏不唯一,无法完成更新操作!"));
return;
}
if (res == -2) {
renderJson(CommonUtil.returnMessageJson(false, dataVisualizationName + "名称的大屏并不是隶属于云南教科院项目,无法完成更新操作!"));
return;
}
//拼接一下URL的最终地址
JSONObject jo = new JSONObject();
jo.put("city_name", city_name);

@ -1,5 +1,6 @@
package com.dsideal.base.DataEase.Model;
import com.dsideal.base.BaseApplication;
import com.dsideal.base.Util.ExcelCommonUtil;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Db;
@ -16,9 +17,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
@ -99,16 +98,22 @@ public class DataEaseModel {
* @param dataVisualizationName
* @param cityName
*/
public boolean updateCity(String dataVisualizationName, String cityName) {
public int updateCity(String dataVisualizationName, String cityName) {
//取出大屏的ID值
//云南省教育决策支持系统
String sql = "select * from data_visualization_info where name =?";
List<Record> L1 = Db.use(DB_NAME).find(sql, dataVisualizationName);
if (L1.size() > 1) {
return false;
return -1;
}
Record dataVisualizationInfo = L1.getFirst();
long bigScreenId = dataVisualizationInfo.getLong("id");
//这个名称确实是存在,但它是不是我想要的这个云南省项目中的大屏呢
Set<Long> set = getFamilyNodes();
if (!set.contains(bigScreenId)) {
return -2;
}
// 配置的内容
List<Record> list = getMap(bigScreenId);
@ -118,18 +123,18 @@ public class DataEaseModel {
//获取城市编码
String area_code = getCityCode(cityName);
//修改前
System.out.println("修改前=" + jo.getJSONObject("map"));
//System.out.println("修改前=" + jo.getJSONObject("map"));
//修改城市编码
jo.getJSONObject("map").put("id", area_code);
jo.getJSONObject("map").put("level", "city");
System.out.println("修改后=" + jo.getJSONObject("map"));
//System.out.println("修改后=" + jo.getJSONObject("map"));
//写到数据库
String jsonString = jo.toString();
Db.use(DB_NAME).update("update core_chart_view set custom_attr=? where id=?", jsonString, id);
}
return true;
return 0;
}
@ -383,7 +388,7 @@ public class DataEaseModel {
*/
public static List<String> getColumnNamesFromExcel(String filePath) {
List<String> columnNames = new ArrayList<>();
try (FileInputStream fis = new FileInputStream(new File(filePath));
try (FileInputStream fis = new FileInputStream(filePath);
Workbook workbook = new XSSFWorkbook(fis)) {
Sheet sheet = workbook.getSheetAt(0); // 读取第一个工作表
@ -434,4 +439,42 @@ public class DataEaseModel {
String sql = "select area_name from t_dataease_last_area where id=1";
return Db.findFirst(sql).getStr("area_name");
}
/**
*
*
* @return
*/
public Record getVisuallizationRoot() {
String rootName = BaseApplication.PropKit.get("dataEase.dataVisualizationRootName");
String sql = "select * from data_visualization_info where name =?";
return Db.use(DB_NAME).findFirst(sql, rootName);
}
/**
*
*
* @param id id
* @return
*/
public List<Long> getChildren(long id) {
List<Long> list = new ArrayList<>();
list.add(id);
String sql = "select * from data_visualization_info where pid=?";
List<Record> children = Db.use(DB_NAME).find(sql, id);
for (Record r : children) {
list.addAll(getChildren(r.getLong("id")));
}
return list;
}
/**
*
*
* @return
*/
public Set<Long> getFamilyNodes() {
long rootId = getVisuallizationRoot().getLong("id");
return new HashSet<>(getChildren(rootId));
}
}

@ -23,6 +23,7 @@ redis:
# 数据可视化
dataEase:
dataVisualizationRootName: 云南省教科院
dataVisualizationName: 云南省教育决策支持系统【市州】
publish_url: http://10.10.14.203:8100
ShiZhou_url: /#/de-link/X4l1qGNH

Loading…
Cancel
Save