|
|
|
@ -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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|