Commit 855da282 by 黄福龙

上传项目

parent b54f80b7
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>Generator</artifactId>
<groupId>com.winsun.tools</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>DBProject</artifactId>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.22</version>
</dependency>
<!--mysql-connector-java-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--jdbc-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<!-- 不设置scope就是全局 -->
<!-- <scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.2.2.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.winsun.db.controller;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
public class ExcelController {
@Test
public void test1(){
String path = "e:/poi_test22.xls";
readTemplate(path);
}
@Test
public void test2(){
String path = "e:/poi_test22.xlsx";
readTemplate2(path);
}
/**
* 获取单元格的值
*/
public static Object getCellValue(HSSFCell cell) {
Object val = "";
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
DecimalFormat df = new DecimalFormat("0");
val = df.format(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
val = cell.getStringCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
val = cell.getCellFormula();
} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
val = cell.getBooleanCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
val = cell.getErrorCellValue();
}
}
return new String(val.toString()).trim();
}
/**
* 处理公式
* @param cell
* @param formulaEvaluator
* @return
*/
public static String getCellValueFormula(Cell cell, FormulaEvaluator formulaEvaluator) {
if (cell == null || formulaEvaluator == null) {
return null;
}
return String.valueOf(formulaEvaluator.evaluate(cell).getNumberValue());
}
public static Object getCellValue(XSSFCell cell) {
Object val = "";
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
DecimalFormat df = new DecimalFormat("0");
val = df.format(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
val = cell.getStringCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
FormulaEvaluator formulaEvaluator
= new XSSFFormulaEvaluator((XSSFWorkbook) cell.getRow().getSheet().getWorkbook());;
val = getCellValueFormula(cell,formulaEvaluator);
} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
val = cell.getBooleanCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
val = cell.getErrorCellValue();
}
}
return new String(val.toString()).trim();
}
/**
* POI解析Excel文件内容 再读取
*
* @author David
* @param
*/
public void readTemplate(String filePath) {
// 需要解析的Excel文件
File file = new File(filePath);// "G:/项目资料/客户画像/111.xls"
try {
// 创建Excel,读取文件内容
HSSFWorkbook workbook = new HSSFWorkbook(FileUtil.getInputStream(file));
// 获取第一个工作表workbook.getSheet("Sheet0");
// HSSFSheet sheet = workbook.getSheet("Sheet0");
// 读取默认第一个工作表sheet
HSSFSheet sheet = workbook.getSheetAt(0);
int firstRowNum = 0;
// 获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
// System.err.println(lastRowNum);
int total = 0;
for (int i = firstRowNum; i <= lastRowNum; i++) {
HSSFRow row = sheet.getRow(i);
// 获取当前行最后单元格列号
int lastCellNum = row.getLastCellNum();
for (int j = 0; j < lastCellNum; j++) {
HSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
String value = getCellValue(cell).toString();
value.replace("/r/n", "");
System.out.print(value + " ");
}
System.out.println();
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 导出生成excel.xls
* @param workbook
*/
public static void export(HSSFWorkbook workbook) {
File file = new File("e:/poi_test" + Math.round(Math.random() * 100) + ".xls");
try {
file.createNewFile();
// 将Excel内容存盘
workbook.write(FileUtil.getOutputStream(file));
} catch (IOException e) {
e.printStackTrace();
} finally {
System.out.println("完成");
}
}
public void readTemplate2(String filePath) {
// 需要解析的Excel文件
File file = new File(filePath);// "G:/项目资料/客户画像/111.xls"
try {
// 创建Excel,读取文件内容
XSSFWorkbook workbook = new XSSFWorkbook(FileUtil.getInputStream(file));
// 获取第一个工作表workbook.getSheet("Sheet0");
// 读取默认第一个工作表sheet
XSSFSheet sheet = workbook.getSheetAt(0);
int firstRowNum = 0;
// 获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
// System.err.println(lastRowNum);
int total = 0;
for (int i = firstRowNum; i <= lastRowNum; i++) {
XSSFRow row = sheet.getRow(i);
// 获取当前行最后单元格列号
int lastCellNum = row.getLastCellNum();
for (int j = 0; j < lastCellNum; j++) {
XSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
String value = getCellValue(cell).toString();
value = value.replace("/r/n", "");
System.out.print(value + " ");
}
System.out.println();
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 导出生成excel.xlsx
* @param workbook
*/
public static void export(XSSFWorkbook workbook){
String name = "f:/poi1_test"+Math.round(Math.random()*100)+".xlsx";
File file = new File(name);
try {
file.createNewFile();
// 将Excel内容存盘
workbook.write(FileUtil.getOutputStream(file));
} catch (IOException e) {
e.printStackTrace();
} finally {
System.out.println("完成");
System.out.println(name);
}
}
/**
* 导出生成excel.xlsx
* @param workbook
*/
public static void export(XSSFWorkbook workbook, String name){
String fileName;
if (StrUtil.isBlank(name)) {
fileName = "f:/poi1_test" + Math.round(Math.random() * 100) + ".xlsx";
} else {
fileName = "f:/" + name + ".xlsx";
}
File file = new File(fileName);
try {
file.createNewFile();
// 将Excel内容存盘
workbook.write(FileUtil.getOutputStream(file));
} catch (IOException e) {
e.printStackTrace();
} finally {
System.out.println("完成");
System.out.println(fileName);
}
}
/**
* 打印list
* @param list
*/
public static void displayList(List list) {
for (Object obj : list) {
System.out.println(obj+"");
}
}
/**
* 打印Map
* @param map
*/
public static void displayMap(Map<String, Object> map) {
for (Entry<String, Object> obj : map.entrySet()) {
System.out.println(obj.getKey() + ":" + obj.getValue());
}
}
/**
* 打印Set
* @param codeSet
*/
public static void displaySet(Set<String> codeSet) {
for(String str:codeSet){
System.out.println(str);
}
}
}
package com.winsun.db.controller;
import java.util.List;
import java.util.Map;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
public class SqlBaseController extends BaseController{
protected static ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
protected static JdbcTemplate jdbcTemplate = (JdbcTemplate) ctx.getBean("jdbcTemplate");
protected static NamedParameterJdbcTemplate namedParameterJdbcTemplate = ctx
.getBean(NamedParameterJdbcTemplate.class);
/**
* 查询
* @param sql
* @return
*/
public List<Map<String, Object>> queryForList(String sql){
return jdbcTemplate.queryForList(sql);
}
/**
*
* 插入、更新、删除
* @param sql
* @return
*/
public int jdbcUpdate(String sql){
return jdbcTemplate.update(sql);
}
/**
* 执行批量语句
* 写语句的sql可不一样
* @param arry
* @return
*/
public static int batchSQLData(String[] arry) {
int result = 0;
// 添加事务
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(
jdbcTemplate.getDataSource());
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus status = transactionManager.getTransaction(def);
try {
if (null != arry && arry.length > 0) {
int[] res = jdbcTemplate.batchUpdate(arry);
for (int i : res) {
result += i;
}
transactionManager.commit(status);
}
} catch (Exception e) {
e.printStackTrace();
transactionManager.rollback(status);
return -1;
}
return result;
}
/**
* 批量执行,统一条写sql,通过每组的参数进行区分。
* @param sql
* @param params
* @return
*/
public static int batchSQLData(String sql, List<Object[]> params) {
int result = 0;
// 添加事务
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(
jdbcTemplate.getDataSource());
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus status = transactionManager.getTransaction(def);
try {
if (null != params && params.size() > 0) {
int[] res = jdbcTemplate.batchUpdate(sql, params);
for (int i : res) {
result += i;
}
transactionManager.commit(status);
}
} catch (Exception e) {
e.printStackTrace();
transactionManager.rollback(status);
return -1;
}
return result;
}
public static String getDateValue(String tableName,String dateCol){
String sql = "SELECT max("+dateCol+") FROM "+tableName;
return jdbcTemplate.queryForObject(sql, String.class);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<!-- 导入资源文件 -->
<context:property-placeholder location="classpath:db.properties"/>
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
<context:component-scan base-package="com" />
<!-- 配置 C3P0 数据源 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<property name="url" value="${jdbc.jdbcUrl}"></property>
<property name="driverClassName" value="${jdbc.driverClass}"></property>
</bean>
<!-- 配置 Spirng 的 JdbcTemplate -->
<bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 配置 NamedParameterJdbcTemplate, 该对象可以使用具名参数, 其没有无参数的构造器, 所以必须为其构造器指定参数 -->
<bean id="namedParameterJdbcTemplate"
class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
<constructor-arg ref="dataSource"></constructor-arg>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 启用事务注解 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
jdbc.driverClass=com.mysql.jdbc.Driver
#ke hu hua xiang
#jdbc.jdbcUrl = jdbc:mysql://112.74.202.190:3306/customerPortrait?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.username= winsun2017
#jdbc.password= winsun
#dian jiang
#jdbc.jdbcUrl = jdbc:mysql://120.24.88.216:3306/dyjl?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.jdbcUrl = jdbc:mysql://120.24.88.216:3306/dyjl-test?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.username = winsun_dev
#jdbc.password = winsun098!@#
#xiao yuan
#jdbc.jdbcUrl = jdbc:mysql://120.24.88.216:3306/xyjl?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.jdbcUrl = jdbc:mysql://120.24.88.216:3306/xyjl-test?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.username = winsun_dev
#jdbc.password = winsun098!@#
#ben di
#jdbc.jdbcUrl = jdbc:mysql://localhost:3306/merchant?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.jdbcUrl = jdbc:mysql://localhost:3306/workload?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.username = root
#jdbc.password = root
#jdbc.jdbcUrl = jdbc:mysql://localhost:3306/location?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.jdbcUrl = jdbc:mysql://localhost:3306/dept?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.jdbcUrl = jdbc:mysql://localhost:3306/dzqd?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.jdbcUrl = jdbc:mysql://localhost:3306/winsun-admin?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.username = zero
#jdbc.password = zero
#yi zhi fu
#jdbc.jdbcUrl = jdbc:mysql://132.97.54.60:58333/yzf_data?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.username = yzf_user
#jdbc.password = yzfuser1!
#jdbc.jdbcUrl = jdbc:mysql://112.74.202.190:3306/lwkb?useUnicode=true&characterEncoding=utf-8
#jdbc.username = lwkb
#jdbc.password = lwkb123
#yong jin
#jdbc.jdbcUrl = jdbc:mysql://132.97.54.10:13306/yjfx?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
#jdbc.username = tpss_gz
#jdbc.password = abc123!@#
#czc
#jdbc.jdbcUrl = jdbc:mysql://132.97.54.36:58333/czc?useUnicode=true&characterEncoding=utf-8
#jdbc.jdbcUrl = jdbc:mysql://132.97.54.36:58333/czc-test?useUnicode=true&characterEncoding=utf-8
#jdbc.username = czc_user
#jdbc.password = czc_user123
#bhy
#jdbc.jdbcUrl = jdbc:mysql://132.97.54.31:58333/baheyi?useUnicode=true&characterEncoding=utf-8
#jdbc.username = root
#jdbc.password = root123
#linux
#jdbc.jdbcUrl = jdbc:mysql://47.106.133.4:3306/location?useUnicode=true&characterEncoding=utf-8
#jdbc.username = locationuser
#jdbc.password = location_123!@#
#jdbc.jdbcUrl = jdbc:mysql://47.106.133.4:3306/edu_cms?useUnicode=true&characterEncoding=utf-8
#jdbc.username = eduuser
#jdbc.password = eduuser123!@#
#ciop
#jdbc.jdbcUrl = jdbc:mysql://47.106.133.4:3306/winsun_admin?useUnicode=true&characterEncoding=utf-8
#jdbc.username = ciopuser
#jdbc.password = Ciop123!@#
#stqd
#jdbc.jdbcUrl = jdbc:mysql://132.97.54.11:58333/address?&useSSL=false&characterEncoding=utf-8
#jdbc.username = address
#jdbc.password = address@181126
#stqd
#jdbc.jdbcUrl = jdbc:mysql://132.97.55.95:18066/mysqlsc?&useSSL=false&characterEncoding=utf-8
#jdbc.username = mycat_user
#jdbc.password = zhyyptmycat$2019
#jdbc.username = root
#jdbc.password = zhyypt888$2019
#stqd-67
jdbc.jdbcUrl = jdbc:mysql://132.97.54.67:3306/stqd_admin?&useSSL=false&characterEncoding=utf-8
jdbc.username = stqd_user
jdbc.password = stqd666$2019
#stqd-60
#jdbc.jdbcUrl = jdbc:mysql://132.97.54.60:58333/stqd_admin?&useSSL=false&characterEncoding=utf-8
#jdbc.username = stqd
#jdbc.password = stqd888$2019
#dskb
#jdbc.jdbcUrl=jdbc:mysql://132.97.153.45:3306/dskb?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
#jdbc.username=root
#jdbc.password=my45$%^
#ka hao
#jdbc.jdbcUrl=jdbc:mysql://132.97.54.14:13306/card
#jdbc.username=card_user
#jdbc.password=card12345678
#zqks
#jdbc.jdbcUrl=jdbc:mysql://132.97.54.60:58333/zqks_admin?&useSSL=false&characterEncoding=utf-8
#jdbc.username=zqks_user
#jdbc.password=zqksuser12!
#jdbc.driverClass=oracle.jdbc.driver.OracleDriver
#louyu
#jdbc.jdbcUrl = jdbc:oracle:thin:@132.97.172.223:1521:ZWFX
#jdbc.username = sk_user
#jdbc.password = SK_user_456
#she qu
#jdbc.jdbcUrl = jdbc:oracle:thin:@132.97.172.223:1521:ZWFX
#jdbc.username = scbuser
#jdbc.password = scb_USER_789
#ceo
#jdbc.jdbcUrl = jdbc:oracle:thin:@132.97.172.223:1521:ZWFX
#jdbc.username = ceouser
#jdbc.password = ceo_USER_789
#ke fu
#jdbc.jdbcUrl = jdbc:oracle:thin:@112.74.202.190:1521:orcl
#jdbc.username = build_user
#jdbc.password = build123
#yi zhi fu
#jdbc.jdbcUrl = jdbc:oracle:thin:@132.97.20.41:1521:orcl
#jdbc.username=merchant_user
#jdbc.password=merchant_user123
#jdbc.username=merchant_temp
#jdbc.password=merchant_temp123
#zzdt
#jdbc.jdbcUrl = jdbc:oracle:thin:@132.97.20.41:1521:orcl
#jdbc.username=yh_user
#jdbc.password=yh_123
#jihe
#jdbc.jdbcUrl = jdbc:oracle:thin:@132.97.172.223:1521:zwfx
#jdbc.username = yz_ywjh
#jdbc.password = ls123
#jdbc.driverClass=com.sybase.jdbc2.jdbc.SybDriver
#IQcom.sybase.jdbc.SybDrive
#jdbc.jdbcUrl = jdbc:sybase:Tds:132.97.93.192:5000/iq_n2
#jdbc.username= sqyx
#jdbc.password= ywzc2016
jdbc.initPoolSize=5
jdbc.maxPoolSize=10
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>Generator</artifactId>
<groupId>com.winsun.tools</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>genTable</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<!-- 不设置scope就是全局 -->
<!-- <scope>test</scope>-->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.winsun.tools.data;
import com.winsun.tools.entity.TreeNode;
/**
* @author zero
* @version 1.0
* @date 2020/5/24 16:43
*/
public class TreeNodeData {
public static TreeNode getData1(){
TreeNode treeNode = new TreeNode(-1, "", null);
TreeNode treeNode0 = new TreeNode(0, "单位","subst_name", treeNode);
TreeNode treeNode1 = new TreeNode(1, "到期总数", treeNode);
TreeNode treeNode2 = new TreeNode(2, "派单数", treeNode);
TreeNode treeNode3 = new TreeNode(3, "跟进情况", treeNode);
TreeNode treeNode4 = new TreeNode(4, "跟进结果", treeNode);
TreeNode treeNode5 = new TreeNode(5, "合计","total", treeNode1);
TreeNode treeNode6 = new TreeNode(6, "互联网专线","toal_hlwzx", treeNode1);
TreeNode treeNode7 = new TreeNode(7, "组网专线","total_zwzx", treeNode1);
TreeNode treeNode8 = new TreeNode(8, "合计","total_pd", treeNode2);
TreeNode treeNode9 = new TreeNode(9, "互联网专线","v1", treeNode2);
TreeNode treeNode10 = new TreeNode(10, "组网专线","v2", treeNode2);
TreeNode treeNode11 = new TreeNode(11, "接单数","v3", treeNode3);
TreeNode treeNode12 = new TreeNode(12, "执行率","v4", treeNode3);
TreeNode treeNode13 = new TreeNode(13, "洽谈中","v5", treeNode3);
TreeNode treeNode14 = new TreeNode(14, "资审合同审批中","v6", treeNode3);
TreeNode treeNode15 = new TreeNode(15, "受理实施中","v7", treeNode3);
TreeNode treeNode16 = new TreeNode(16, "洽谈成功","v8", treeNode3);
TreeNode treeNode17 = new TreeNode(17, "失败","v9", treeNode3);
TreeNode treeNode18 = new TreeNode(18, "续约数","v10", treeNode4);
TreeNode treeNode19 = new TreeNode(19, "续约率","v11", treeNode4);
TreeNode treeNode20 = new TreeNode(20, "提速数","v12", treeNode4);
TreeNode treeNode21 = new TreeNode(21, "占比","v13", treeNode4);
TreeNode treeNode22 = new TreeNode(22, "提值数","v14", treeNode4);
TreeNode treeNode23 = new TreeNode(23, "占比","v15", treeNode4);
TreeNode treeNode24 = new TreeNode(24, "提值月租","v16", treeNode4);
TreeNode treeNode25 = new TreeNode(25, "拆机数","v17", treeNode4);
TreeNode treeNode26 = new TreeNode(26, "占比","v18", treeNode4);
treeNode.calLeavesAmount(treeNode);
treeNode.calNodeLevel(treeNode);
return treeNode;
}
public static TreeNode getVpnXySubst(){
TreeNode treeNode = new TreeNode(-1, "", null);
TreeNode treeNode0 = new TreeNode(0, "县分","subst", treeNode);
TreeNode treeNode1 = new TreeNode(1, "业务/活动名称","fname", treeNode);
TreeNode treeNode2 = new TreeNode(2, "渠道","task_type", treeNode);
TreeNode treeNode3 = new TreeNode(3, "到期客户数","count_customer_due", treeNode);
TreeNode treeNode4 = new TreeNode(4, "目标号码数","count_target_phone", treeNode);
TreeNode treeNode5 = new TreeNode(5, "累计续约数","count_cumulative_renewals", treeNode);
TreeNode treeNode6 = new TreeNode(6, "续约率","renewal_rate", treeNode);
TreeNode treeNode7 = new TreeNode(7, "其中续约类型终补","count_renewal_type_final", treeNode);
TreeNode treeNode8 = new TreeNode(8, "其中续约类型话补","count_renewal_huabu", treeNode);
TreeNode treeNode9 = new TreeNode(9, "其中续约类型套餐打折","count_renewal_discount", treeNode);
TreeNode treeNode10 = new TreeNode(10, "其中续约类型战狼团购","count_renewal_coyote", treeNode);
TreeNode treeNode11 = new TreeNode(11, "其中续约融升套餐","count_renewal_rs", treeNode);
TreeNode treeNode12 = new TreeNode(12, "其中续约无条件或违约金","count_renewal_wtj_wyj", treeNode);
TreeNode treeNode13 = new TreeNode(13, "续约升级5G数","count_renewal_5g", treeNode);
treeNode.calLeavesAmount(treeNode);
treeNode.calNodeLevel(treeNode);
return treeNode;
}
public static TreeNode getVpnXyBranch(){
TreeNode treeNode = new TreeNode(-1, "", null);
TreeNode treeNode0 = new TreeNode(0, "县分","subst", treeNode);
TreeNode treeNode1 = new TreeNode(1, "营服","branch", treeNode);
TreeNode treeNode2 = new TreeNode(2, "业务/活动名称","fname", treeNode);
TreeNode treeNode3 = new TreeNode(3, "渠道","task_type", treeNode);
TreeNode treeNode4 = new TreeNode(4, "到期客户数","count_customer_due", treeNode);
TreeNode treeNode5 = new TreeNode(5, "目标号码数","count_target_phone", treeNode);
TreeNode treeNode6 = new TreeNode(6, "累计续约数","count_cumulative_renewals", treeNode);
TreeNode treeNode7 = new TreeNode(7, "续约率","renewal_rate", treeNode);
TreeNode treeNode8 = new TreeNode(8, "其中续约类型终补","count_renewal_type_final", treeNode);
TreeNode treeNode9 = new TreeNode(9, "其中续约类型话补","count_renewal_huabu", treeNode);
TreeNode treeNode10 = new TreeNode(10, "其中续约类型套餐打折","count_renewal_discount", treeNode);
TreeNode treeNode11 = new TreeNode(11, "其中续约类型战狼团购","count_renewal_coyote", treeNode);
TreeNode treeNode12 = new TreeNode(12, "其中续约融升套餐","count_renewal_rs", treeNode);
TreeNode treeNode13 = new TreeNode(13, "其中续约无条件或违约金","count_renewal_wtj_wyj", treeNode);
TreeNode treeNode14 = new TreeNode(14, "续约升级5G数","count_renewal_5g", treeNode);
treeNode.calLeavesAmount(treeNode);
treeNode.calNodeLevel(treeNode);
return treeNode;
}
public static TreeNode getVpnXyAcc(){
TreeNode treeNode = new TreeNode(-1, "", null);
TreeNode treeNode0 = new TreeNode(0, "县分","subst", treeNode);
TreeNode treeNode1 = new TreeNode(1, "营服","branch", treeNode);
TreeNode treeNode2 = new TreeNode(2, "客户经理","acc_name", treeNode);
TreeNode treeNode3 = new TreeNode(3, "客户经理acc","acc_code", treeNode);
TreeNode treeNode4 = new TreeNode(4, "业务/活动名称","fname", treeNode);
TreeNode treeNode5 = new TreeNode(5, "渠道","task_type", treeNode);
TreeNode treeNode6 = new TreeNode(6, "到期客户数","count_customer_due", treeNode);
TreeNode treeNode7 = new TreeNode(7, "目标号码数","count_target_phone", treeNode);
TreeNode treeNode8 = new TreeNode(8, "累计续约数","count_cumulative_renewals", treeNode);
TreeNode treeNode9 = new TreeNode(9, "续约率","renewal_rate", treeNode);
TreeNode treeNode10 = new TreeNode(10, "其中续约类型终补","count_renewal_type_final", treeNode);
TreeNode treeNode11 = new TreeNode(11, "其中续约类型话补","count_renewal_huabu", treeNode);
TreeNode treeNode12 = new TreeNode(12, "其中续约类型套餐打折","count_renewal_discount", treeNode);
TreeNode treeNode13 = new TreeNode(13, "其中续约类型战狼团购","count_renewal_coyote", treeNode);
TreeNode treeNode14 = new TreeNode(14, "其中续约融升套餐","count_renewal_rs", treeNode);
TreeNode treeNode15 = new TreeNode(15, "其中续约无条件或违约金","count_renewal_wtj_wyj", treeNode);
TreeNode treeNode16 = new TreeNode(16, "续约升级5G数","count_renewal_5g", treeNode);
treeNode.calLeavesAmount(treeNode);
treeNode.calNodeLevel(treeNode);
return treeNode;
}
public static TreeNode getHk4s5ACC(){
TreeNode treeNode = new TreeNode(-1, "", null);
TreeNode treeNode0 = new TreeNode(0, "县分","subst", treeNode);
TreeNode treeNode1 = new TreeNode(1, "营服","branch", treeNode);
TreeNode treeNode2 = new TreeNode(2, "客户经理", treeNode);
TreeNode treeNode3 = new TreeNode(3, "客户经理帐号", treeNode);
TreeNode treeNode4 = new TreeNode(4, "业务/活动名称","fname", treeNode);
TreeNode treeNode5 = new TreeNode(5, "渠道","task_type", treeNode);
TreeNode treeNode6 = new TreeNode(6, "目标数","total_target", treeNode);
TreeNode treeNode7 = new TreeNode(7, "累计5G升级数","total_5g", treeNode);
TreeNode treeNode8 = new TreeNode(8, "升级率","rate_upgrade", treeNode);
TreeNode treeNode9 = new TreeNode(9, "依案办理数","total_yabl", treeNode);
TreeNode treeNode10 = new TreeNode(10, "依案办理率","rate_yabl", treeNode);
TreeNode treeNode11 = new TreeNode(11, "其中5G加包数","count_5g_packets", treeNode);
TreeNode treeNode12 = new TreeNode(12, "其中5G套餐数","count_5g_packages", treeNode);
TreeNode treeNode13 = new TreeNode(13, "5G套餐价值区间129元以下","count_5g_packages_below_129", treeNode);
TreeNode treeNode14 = new TreeNode(14, "G套餐价值区间129-299","count_5g_packages_129_299", treeNode);
TreeNode treeNode15 = new TreeNode(15, "5G套餐价值区间299元以上","count_5g_packages_above_299", treeNode);
treeNode.calLeavesAmount(treeNode);
treeNode.calNodeLevel(treeNode);
return treeNode;
}
}
package com.winsun.tools.entity;
/**
* 树结构反向编译类
*
* @author 吕伟康
* @date 2018年4月14日上午1:05:40
*/
public class TreeNodeReComplie {
private String content;
private int id;
private String clazzName;
private String name;
private String key;
private TreeNodeReComplie parent;
public TreeNodeReComplie() {
}
public TreeNodeReComplie(String clazzName) {
this.clazzName = clazzName;
}
public TreeNodeReComplie(int id, String content) {
this.setId(id);
this.setContent(content);
}
public String getContent() {
if (this.content == null) {
return null;
}
return content;
}
public void setContent(String content) {
this.content = content;
String[] arr = content.split("#");
this.setName(arr[0]);
if (arr.length > 1) {
this.setKey(arr[1]);
}
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
this.setClazzName("treeNode" + id);
}
public String getClazzName() {
return clazzName;
}
public void setClazzName(String clazzName) {
this.clazzName = clazzName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public TreeNodeReComplie getParent() {
return parent;
}
public void setParent(TreeNodeReComplie parent) {
this.parent = parent;
}
public String getJavaCode() {
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("TreeNode treeNode").append(id).append(" = new TreeNode(").append(id);
sBuilder.append(", \"").append(name).append("\"");
if (key != null && !key.equals("")) {
// sBuilder.append(",\"").append(key.toUpperCase()).append("\"");
sBuilder.append(",\"").append(key).append("\"");
}
if (this.parent != null) {
sBuilder.append(", ").append(parent.getClazzName()).append(");");
} else {
sBuilder.append(", ").append("null").append(");");
}
return sBuilder.toString();
}
public TreeNodeSql getTreeNodeSql() {
TreeNodeSql treeNodeSql = new TreeNodeSql();
treeNodeSql.setIndex(id);
treeNodeSql.setName(name);
if (key != null && !key.equals("")) {
treeNodeSql.setKey(key);
}
if (this.parent != null) {
String parentNodeName = parent.getClazzName();
String parentNodeId = parentNodeName.replace("treeNode","");
int index = parentNodeId.length() == 0 ? -1 : Integer.parseInt(parentNodeId);
treeNodeSql.setParentIndex(index);
} else {
treeNodeSql.setParentIndex(-1);
}
return treeNodeSql;
}
@Override
public String toString() {
return "TreeNodeReComplie [content=" + content + ", id=" + id + ", name=" + name + ", key=" + key + "]";
}
}
package com.winsun.tools.entity;
import cn.hutool.core.util.StrUtil;
import com.winsun.tools.utils.SQLHelper;
/**
* @author zero
* @version 1.0
* @date 2020/5/27 10:32
*/
public class TreeNodeSql {
private int index;
private String name;
private String key;
private int parentIndex;
public TreeNodeSql() {
// TODO Auto-generated constructor stub
}
public TreeNodeSql(int index, String name, int parentIndex) {
super();
this.index = index;
this.name = name;
this.parentIndex = parentIndex;
}
public TreeNodeSql(int orderId, String name, String key, int parentIndex) {
super();
this.index = orderId;
this.name = name;
this.key = key;
this.parentIndex = parentIndex;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public int getParentIndex() {
return parentIndex;
}
public void setParentIndex(int parentIndex) {
this.parentIndex = parentIndex;
}
@Override
public String toString() {
return "TreeNodeSql [index=" + index + ", name=" + name + ", key=" + key + ", parentIndex="
+ parentIndex + "]";
}
public String toSql(String table, String tableName){
SQLHelper sqlHelper = new SQLHelper(table,"");
sqlHelper.addInsertClause("index", index + "")
.addInsertClause("name", "'" + name + "'")
.addInsertClause(StrUtil.isNotBlank(key), "key", "'" + key + "'")
.addInsertClause("parent_index", parentIndex + "")
.addInsertClause("table_name", "'" + tableName + "'");
return sqlHelper.getInsertSQL() + ";";
}
// CREATE TABLE `sys_table_config` (
// `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
// `index` int(11) NOT NULL COMMENT '内部自增下标',
// `name` varchar(100) NOT NULL COMMENT '名称',
// `key` varchar(100) DEFAULT NULL COMMENT '字段值',
// `parent_index` int(11) NOT NULL COMMENT '父级下标',
// `table_name` varchar(100) DEFAULT NULL COMMENT '所属表格',
// PRIMARY KEY (`id`)
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8
}
package com.winsun.tools.utils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.text.DecimalFormat;
/**
* @author zero
* @version 1.0
* @date 2020/5/24 0:36
*/
public class ExcelCellUtils {
//处理公式
public static String getCellValueFormula(Cell cell, FormulaEvaluator formulaEvaluator) {
if (cell == null || formulaEvaluator == null) {
return null;
}
return String.valueOf(formulaEvaluator.evaluate(cell).getNumberValue());
}
public static Object getCellValue(XSSFCell cell) {
Object val = "";
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
DecimalFormat df = new DecimalFormat();
val = df.format(cell.getNumericCellValue());
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
val = cell.getStringCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
FormulaEvaluator formulaEvaluator
= new XSSFFormulaEvaluator((XSSFWorkbook) cell.getRow().getSheet().getWorkbook());;
val = getCellValueFormula(cell,formulaEvaluator);
} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
val = cell.getBooleanCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
val = cell.getErrorCellValue();
}
}
return new String(val.toString()).trim();
}
}
package com.winsun.tools.utils;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import com.winsun.tools.entity.TreeNode;
import com.winsun.tools.entity.TreeNodeSql;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* 报表头HTML代码生成
*
* @author 吕伟康
* @date 2018年4月13日下午2:26:45
*/
public class THeadJsonUtils {
public static void main(String[] args) {
// TreeNode treeNode = TreeNodeData.getData1();
// writeLayuiJsonResult(treeNode);
// readData();
writeAppJsonResult(initData());
}
/**
* 输出layui的json结构
* @param treeNode
*/
public static void writeLayuiJsonResult(TreeNode treeNode) {
int max = treeNode.getMaxLevel();// 获取最大的层次 n-1
int[] arr = new int[max + 1];// n层
for (int i = 0; i < arr.length; i++) {// 创建行
arr[i] = 0;
}
List<String> htmlList = new ArrayList<>();
Map<String, List<String>> map = new LinkedHashMap<>();
map = getColumnList(treeNode, max);
htmlList.add("[");
//输出每个级别的表头
for (Entry<String, List<String>> s : map.entrySet()) {
htmlList.add("[");
htmlList.addAll(s.getValue());
htmlList.add("],");
}
htmlList.add("]");
int size = htmlList.size();
String lastStr = htmlList.get(size - 1);
htmlList.set(size - 1, lastStr.substring(0, lastStr.length() - 1));
displayList(htmlList);
System.out.println("--------将html表头输出到html.txt-----------");
//writeToTxt(htmlList);
}
/**
* 解析表头行于列
*
* @param treeNodes
* @param max
* @return
*/
public static Map<String, List<String>> getColumnList(TreeNode treeNodes, int max) {
List<String> keyList = new ArrayList<String>();
Map<String, List<String>> map = new LinkedHashMap<>();
List<TreeNode> nodeList = treeNodes.getJuniors();
int count = 0;
for (int i = 0, s = nodeList.size(); i < s; i++) {
TreeNode treeNode = nodeList.get(i);
String key = treeNode.getKey();
int leafSize = treeNode.getLeafSize();
int level = treeNode.getLevel();
String name = treeNode.getNodeName();
List thList = map.get("" + level);
if (thList == null) {
thList = new ArrayList<>();
map.put("" + level, thList);
}
boolean isLeaf = treeNode.isLeaf();
//开始拼接
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("\t { ");
//表头
sBuilder.append("'title' : '" + name + "' ");
if (StrUtil.isNotBlank(key)) {//赋值
sBuilder.append(", 'field' : '" + key + "'");
}
//其它属性
//列合并
if (leafSize != 1) {
sBuilder.append(", 'colspan' : " + leafSize + " ");
}
//行合并
if (level != max && leafSize == 1 && isLeaf) {
sBuilder.append(", 'rowspan' : " + (max - level + 1) + " ");
}
sBuilder.append(", 'align' : 'center'");
sBuilder.append("},");
thList.add(sBuilder.toString());
}
for (Entry<String, List<String>> s : map.entrySet()) {
List<String> list = s.getValue();
int size = list.size();
String lastStr = list.get(size - 1);
list.set(size - 1, lastStr.substring(0, lastStr.length() - 1));
}
return map;
}
/**
* 打印list
*
* @param list
*/
public static void displayList(List list) {
for (Object obj : list) {
System.out.println(obj);
}
}
public static void writeToTxt(List<String> list) {
writeToTxt(list, null);
}
public static void writeToTxt(List<String> list, String fileName) {
FileOutputStream outSTr = null;
BufferedOutputStream Buff = null;
String path = "f://txt_" + Math.round(Math.random() * 1000) + ".txt";
if (StrUtil.isNotBlank(fileName)) {
path = fileName; //全路径
}
String tab = "";
String enter = "\r\n";
String content = "";
StringBuffer write;
try {
outSTr = new FileOutputStream(new File(path));
Buff = new BufferedOutputStream(outSTr);
for (int i = 0; i < list.size(); i++) {
Object obj = list.get(i);
content = obj.toString();
write = new StringBuffer();
write.append(content).append(tab).append(enter);
Buff.write(write.toString().getBytes("UTF-8"));
}
Buff.flush();
Buff.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
Buff.close();
outSTr.close();
System.out.println("finished...");
System.out.println(path);
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 初始化数据,集成到项目中可使用读数据库的方式
* @return
*/
public static List<TreeNodeSql> initData(){
String filePath = "F:\\项目资料\\实时战报\\社区运营平台\\02 社区智慧运营平台\\02需求开发\\三期\\社区派单报表\\表头.xlsx";
//createCode(filePath, 5);
List<TreeNodeSql> list = TreeNodeDataCreator.getTreeNodeByExcel(filePath, 6);
return list;
}
/**
* 根据数据源读取,进行json输出
*/
public static void readData(List<TreeNodeSql> list){
List<TreeNode> treeNodeList = new ArrayList<>(list.size());
TreeNode treeNode = new TreeNode(-1, "", null);//初始化头
treeNodeList.add(treeNode);
for(TreeNodeSql sql : list ){
TreeNode treeNode0 = new TreeNode(sql.getIndex(),sql.getName(),treeNodeList.get(sql.getParentIndex()+1));
if(StrUtil.isNotBlank(sql.getKey())){
treeNode0.setKey(sql.getKey());
}
treeNodeList.add(treeNode0);
}
treeNode.calLeavesAmount(treeNode);
treeNode.calNodeLevel(treeNode);
writeLayuiJsonResult(treeNode);
}
public static void writeAppJsonResult(List<TreeNodeSql> list){
Map<String, Map<String, Object>> targetMap = new LinkedHashMap<>();
List<Map> topList = new ArrayList<>();
for(TreeNodeSql nodeSql : list){
int index = nodeSql.getIndex();
Map<String, Object> map = new LinkedHashMap<>();
map.put("title", nodeSql.getName());
map.put("align", "center");
if (StrUtil.isNotBlank(nodeSql.getKey())){
map.put("field", nodeSql.getKey());
}
int pIndex = nodeSql.getParentIndex();
if(pIndex != -1){
Map<String, Object> paranetMap = targetMap.get(pIndex +"");
List<Map<String, Object>> children = (List<Map<String, Object>>) paranetMap.get("children");
if(children == null){
children = new ArrayList<>();
paranetMap.put("children", children);
}
children.add(map);
}else{
topList.add(map);
}
targetMap.put(index + "", map);
}
JSONArray array = new JSONArray(topList);
System.out.println(array.toString());
System.out.println("--------将html表头输出到html.txt-----------");
List<String> l = new ArrayList<String>();
l.add(array.toString());
writeToTxt(l);
}
}
package com.winsun.tools.utils;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import cn.hutool.core.util.StrUtil;
import com.winsun.tools.data.TreeNodeData;
import com.winsun.tools.entity.TreeNode;
import org.junit.Test;
/**
* 报表头HTML代码生成
* @author 吕伟康
* @date 2018年4月13日下午2:26:45
*/
public class THeadUtils {
@Test
public void test2(){
TreeNode treeNode = TreeNodeData.getData1();
int max = treeNode.getMaxLevel();// 获取最大的层次 n-1
int[] arr = new int[max + 1];// n层
for (int i = 0; i < arr.length; i++) {// 创建行
arr[i] = 0;
}
List<String> htmlList = new ArrayList<>();
Map<String,List<String>> map = new LinkedHashMap<>();
map = getKeyList(treeNode, max);
for(Entry<String, List<String>> s : map.entrySet()){
System.out.println("<tr class=\"tabTh\">");
displayList(s.getValue());
System.out.println("</tr>");
htmlList.add("<tr class=\"tabTh\">");
htmlList.addAll(s.getValue());
htmlList.add("</tr>");
}
System.out.println("--------将html表头输出到html.txt-----------");
writeToTxt(htmlList);
}
public Map<String,List<String>> getKeyList(TreeNode treeNodes,int max){
List<String> keyList = new ArrayList<String>();
Map<String,List<String>> map = new LinkedHashMap<>();
List<TreeNode> nodeList = treeNodes.getJuniors();
int count = 0;
for(int i = 0,s = nodeList.size() ;i<s;i++){
TreeNode treeNode = nodeList.get(i);
String key = treeNode.getKey();
int leafSize = treeNode.getLeafSize();
int level = treeNode.getLevel();
String name = treeNode.getNodeName();
List thList = map.get(""+level);
if(thList==null){
thList = new ArrayList<>();
map.put(""+level, thList);
}
boolean isLeaf = treeNode.isLeaf();
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("\t<td class=\"tabTh\" ");
//其它属性
//列合并
if(leafSize!=1) {
sBuilder.append("colspan='"+leafSize+"' ");
}
//行合并
if(level!=max && leafSize == 1 && isLeaf){
sBuilder.append("rowspan='"+(max-level+1)+"' ");
}
if(StrUtil.isNotBlank(key)){
sBuilder.append("value = '"+key+"' ");
sBuilder.append("key = '" + count++ + "'");
}
sBuilder.append("\n\t\tstyle=\"word-wrap: break-word; white-space: nowrap; text-align: center; vertical-align: middle;\" ");
sBuilder.append(">")
.append(name)
.append("</td>");
thList.add(sBuilder.toString());
}
return map;
}
/**
* 打印list
* @param list
*/
public static void displayList(List list) {
for (Object obj : list) {
System.out.println(obj);
}
}
public void writeToTxt(List<String> list) {
writeToTxt(list, null);
}
public void writeToTxt(List<String> list, String fileName) {
FileOutputStream outSTr = null;
BufferedOutputStream Buff = null;
String path = "f://txt_"+Math.round(Math.random()*1000)+".txt";
if(StrUtil.isNotBlank(fileName)) {
path = fileName; //全路径
}
String tab = "";
String enter = "\r\n";
String content = "";
StringBuffer write ;
try {
outSTr = new FileOutputStream(new File(path));
Buff = new BufferedOutputStream(outSTr);
for (int i = 0; i < list.size(); i++) {
Object obj = list.get(i);
content = obj.toString();
write = new StringBuffer();
write.append(content).append(tab).append(enter);
Buff.write(write.toString().getBytes("UTF-8"));
}
Buff.flush();
Buff.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
Buff.close();
outSTr.close();
System.out.println("finished...");
System.out.println(path);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
package com.winsun.tools.utils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import cn.hutool.core.io.FileUtil;
import com.winsun.tools.entity.TreeNode;
import com.winsun.tools.entity.TreeNodeReComplie;
import com.winsun.tools.entity.TreeNodeSql;
import org.apache.poi.xssf.usermodel.*;
public class TreeNodeDataCreator {
/**
* 控制台输出结果
*
* @param filePath 文件路径
*/
public static void createCode(String filePath) {
createCode(filePath, 0);
}
/**
* 控制台输出结果
*
* @param filePath 文件路径
* @param sheetIndex sheet下标
*/
public static void createCode(String filePath, int sheetIndex) {
File file = new File(filePath);// "G:/项目资料/客户画像/111.xls"
try {
// 创建Excel,读取文件内容
XSSFWorkbook workbook = new XSSFWorkbook(FileUtil.getInputStream(filePath));
// 读取默认第一个工作表sheet
XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
int firstRowNum = 0;
List<String> javaList = new ArrayList<String>();
// 获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
int total = 0;
List<TreeNodeReComplie> dataList = new LinkedList<>();
Map<String, TreeNodeReComplie> map = new LinkedHashMap<>();
System.out.println("TreeNode treeNode = new TreeNode(-1, \"\", null);");
for (int i = firstRowNum; i <= lastRowNum; i++) {
XSSFRow row = sheet.getRow(i);
// 获取当前行最后单元格列号
int lastCellNum = row.getLastCellNum();
for (int j = 0; j < lastCellNum; j++) {
XSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
String value = ExcelCellUtils.getCellValue(cell).toString();
if (value.equals("")) {
continue;
}
TreeNodeReComplie treeNodeReComplie = new TreeNodeReComplie(total, value);
if (i != firstRowNum) {
XSSFRow row0 = sheet.getRow(i - 1);
XSSFCell cell0 = row0.getCell(j);
if (cell0 == null) {
treeNodeReComplie.setParent(dataList.get(total - 1).getParent());
} else {
String value0 = ExcelCellUtils.getCellValue(cell0).toString();
if (value0.equals("")) {
treeNodeReComplie.setParent(dataList.get(total - 1).getParent());
} else {
treeNodeReComplie.setParent(map.get(value0 + (i - 1) + "" + j));
}
}
} else {
treeNodeReComplie.setParent(new TreeNodeReComplie("treeNode"));
}
map.put(value + i + "" + j, treeNodeReComplie);
dataList.add(treeNodeReComplie);
total++;
System.out.println(treeNodeReComplie.getJavaCode());
}
}
System.out.println("treeNode.calLeavesAmount(treeNode);");
System.out.println("treeNode.calNodeLevel(treeNode);");
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
// String filePath = "F:\\项目资料\\实时战报\\社区运营平台\\02 社区智慧运营平台\\02需求开发\\三期\\社区派单报表\\表头.xlsx";
String filePath = "E:\\Documents\\WeChat Files\\WeChat Files\\zero13168599099\\FileStorage\\File\\2020-05\\表头(3)(1)(1).xlsx";
// createCode(filePath, 0);
List<TreeNodeSql> list = getTreeNodeByExcel(filePath, 0);
for(TreeNodeSql sql : list ){
System.out.println(sql.toSql("tableConfig", "name"));
}
}
/**
* 动态获取treeNode类
*
* @param filePath
* @return
*/
public static List<TreeNodeSql> getTreeNodeByExcel(String filePath) {
return getTreeNodeByExcel(filePath, 0);
}
/**
* 动态获取treeNode类
*
* @param filePath
* @param sheetIndex
* @return
*/
public static List<TreeNodeSql> getTreeNodeByExcel(String filePath, int sheetIndex) {
File file = new File(filePath);// "G:/项目资料/客户画像/111.xls"
try {
// 创建Excel,读取文件内容
XSSFWorkbook workbook = new XSSFWorkbook(FileUtil.getInputStream(filePath));
// 读取默认第一个工作表sheet
XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
int firstRowNum = 0;
List<String> javaList = new ArrayList<String>();
// 获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
int total = 0;
List<TreeNodeReComplie> dataList = new LinkedList<>();
Map<String, TreeNodeReComplie> map = new LinkedHashMap<>();
TreeNode treeNode = new TreeNode(-1, "", null);
List<TreeNodeSql> nodeSqlList = new LinkedList<>();
for (int i = firstRowNum; i <= lastRowNum; i++) {
XSSFRow row = sheet.getRow(i);
// 获取当前行最后单元格列号
int lastCellNum = row.getLastCellNum();
for (int j = 0; j < lastCellNum; j++) {
XSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
String value = ExcelCellUtils.getCellValue(cell).toString();
if (value.equals("")) {
continue;
}
TreeNodeReComplie treeNodeReComplie = new TreeNodeReComplie(total, value);
if (i != firstRowNum) {
XSSFRow row0 = sheet.getRow(i - 1);
XSSFCell cell0 = row0.getCell(j);
if (cell0 == null) {
treeNodeReComplie.setParent(dataList.get(total - 1).getParent());
} else {
String value0 = ExcelCellUtils.getCellValue(cell0).toString();
if (value0.equals("")) {
treeNodeReComplie.setParent(dataList.get(total - 1).getParent());
} else {
treeNodeReComplie.setParent(map.get(value0 + (i - 1) + "" + j));
}
}
} else {
treeNodeReComplie.setParent(new TreeNodeReComplie("treeNode"));
}
map.put(value + i + "" + j, treeNodeReComplie);
dataList.add(treeNodeReComplie);
nodeSqlList.add(treeNodeReComplie.getTreeNodeSql());
total++;
System.out.println(treeNodeReComplie.getTreeNodeSql());
}
}
return nodeSqlList;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
[
[
{title: '序号',rowspan: 2, align: 'center', type: 'numbers'},
{
field: 'subst',width: 100,rowspan: 2, title: '县分', align: 'center'
},
{field: 'batch_num',width: 120,rowspan: 2, title: '批次号',align: 'center'},
{field: 'fname', rowspan: 2,width: 120,title: '业务/活动名称',align: 'center'},
{field: 'task_type',rowspan: 2,width: 70, title: '渠道',align: 'center'},
{
field: 'send',width: 80, rowspan: 2,title: '派单数', align: 'center', templet: function (d) {
return '<div><a href="javascript:void(1);" onclick="openQd(\''+ d.batch_num + '\',\''+ d.task_type + '\',\'' + d.fname + '\',1,\'' + d.subst + '\')">' + d.send + '</a></div>';
}
},
{
field: 'deal',width: 80,rowspan: 2, title: '接单数', align: 'center', templet: function (d) {
return '<div><a href="javascript:void(1);" onclick="openQd(\''+ d.batch_num + '\',\''+ d.task_type + '\',\'' + d.fname + '\',1,\'' + d.subst + '\',\'' + this.field + '\')">' + d.deal + '</a></div>';
}
},
{field: 'confirm',width: 120,rowspan: 2, title: '确认为本人负责客户',align: 'center', templet: function (d) {
return '<div><a href="javascript:void(1);" onclick="openQd(\''+ d.batch_num + '\',\''+ d.task_type + '\',\'' + d.fname + '\',1,\'' + d.subst + '\',\'' + this.field+ '\')">' + d.confirm + '</a></div>';
}},
{field: 'lose',width: 120, rowspan: 2,title: '存在流失风险',align: 'center', templet: function (d) {
return '<div><a href="javascript:void(1);" onclick="openQd(\''+ d.batch_num + '\',\''+ d.task_type + '\',\'' + d.fname + '\',1,\'' + d.subst + '\',\'' + this.field + '\')">' + d.lose + '</a></div>';
}},
{field: 'complete',width: 120,rowspan: 2, title: '已完成方案制定',align: 'center', templet: function (d) {
return '<div><a href="javascript:void(1);" onclick="openQd(\''+ d.batch_num + '\',\''+ d.task_type + '\',\'' + d.fname + '\',1,\'' + d.subst + '\',\'' + this.field + '\')">' + d.complete + '</a></div>';
}},
{field: 'visited',width: 120,rowspan: 2, title: '已上门拜访',align: 'center', templet: function (d) {
return '<div><a href="javascript:void(1);" onclick="openQd(\''+ d.batch_num + '\',\''+ d.task_type + '\',\'' + d.fname + '\',1,\'' + d.subst + '\',\'' + this.field + '\')">' + d.visited + '</a></div>';
}},
{field: 'keep_success',width: 120,rowspan: 2, title: '维系成功',align: 'center', templet: function (d) {
return '<div><a href="javascript:void(1);" onclick="openQd(\''+ d.batch_num + '\',\''+ d.task_type + '\',\'' + d.fname + '\',1,\'' + d.subst + '\',\'' + this.field + '\')">' + d.keep_success + '</a></div>';
}},
{field: 'keep_failure',width: 120,rowspan: 2, title: '维系失败',align: 'center', templet: function (d) {
return '<div><a href="javascript:void(1);" onclick="openQd(\''+ d.batch_num + '\',\''+ d.task_type + '\',\'' + d.fname + '\',1,\'' + d.subst + '\',\'' + this.field + '\')">' + d.keep_failure + '</a></div>';
}},
{field: '', colspan: 11, title: '年内到期跟进结果(双线合计)', align: 'center'},
],[
{field: 'dq_sum',width: 100, title: '年内到期数量', align: 'center'},
{field: 'dq_yz',width: 120, title: '年内到期月租',align: 'center'},
{field: 'xy_sum',width: 100, title: '续约数',align: 'center'},
{field: 'xy_sr',width: 100, title: '续约收入', align: 'center'},
{field: 'ts',width: 100, title: '提速数',align: 'center'},
{field: 'ts_zb',width: 100, title: '提速占比',align: 'center'},
{field: 'tz',width: 100, title: '提值数', align: 'center'},
{field: 'tz_zb',width: 100, title: '提值占比',align: 'center'},
{field: 'tz_yz',width: 100, title: '提值月租',align: 'center'},
{field: 'cj_sum',width: 100, title: '拆机数', align: 'center'},
{field: 'cj_zb',width: 100, title: '拆机占比',align: 'center'},
]
]
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title></title>
<link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" />
</head>
<body>
<div id="table1" class="table-box">
</div>
<div id="table2" class="table-box">
</div>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
//这个是单行表头的
var col1 = [
[{
field: 'id',
title: 'ID',
align: 'center'
}, {
field: 'username',
title: '用户名',
align: 'center'
}, {
field: 'sex',
title: '性别',
align: 'center'
}, {
field: 'city',
title: '城市',
align: 'center'
}, {
field: 'sign',
title: '签名',
align: 'center'
}, {
field: 'experience',
title: '积分',
align: 'center'
}, {
field: 'score',
title: '评分',
align: 'center'
}, {
field: 'classify',
title: '职业',
align: 'center'
}, {
field: 'wealth',
title: '财富',
align: 'center'
}]
];
//复杂表头
var col2 = [
[
{ title : '单位' , field : 'subst_name', rowspan : 2 , align: 'center'},
{ title : '到期总数' , colspan : 3 , align: 'center'},
{ title : '派单数' , colspan : 3 , align: 'center'},
{ title : '跟进情况' , colspan : 7 , align: 'center'},
{ title : '跟进结果' , colspan : 9 , align: 'center'}
],
[
{ title : '合计' , field : 'total', align: 'center'},
{ title : '互联网专线' , field : 'toal_hlwzx', align: 'center'},
{ title : '组网专线' , field : 'total_zwzx', align: 'center'},
{ title : '合计' , field : 'total_pd', align: 'center'},
{ title : '互联网专线' , field : 'v1', align: 'center'},
{ title : '组网专线' , field : 'v2', align: 'center'},
{ title : '接单数' , field : 'v3', align: 'center'},
{ title : '执行率' , field : 'v4', align: 'center'},
{ title : '洽谈中' , field : 'v5', align: 'center'},
{ title : '资审合同审批中' , field : 'v6', align: 'center'},
{ title : '受理实施中' , field : 'v7', align: 'center'},
{ title : '洽谈成功' , field : 'v8', align: 'center'},
{ title : '失败' , field : 'v9', align: 'center'},
{ title : '续约数' , field : 'v10', align: 'center'},
{ title : '续约率' , field : 'v11', align: 'center'},
{ title : '提速数' , field : 'v12', align: 'center'},
{ title : '占比' , field : 'v13', align: 'center'},
{ title : '提值数' , field : 'v14', align: 'center'},
{ title : '占比' , field : 'v15', align: 'center'},
{ title : '提值月租' , field : 'v16', align: 'center'},
{ title : '拆机数' , field : 'v17', align: 'center'},
{ title : '占比' , field : 'v18', align: 'center'}
]
];
var table; //表格对象
layui.use(['table'], function() {
table = layui.table;
loadTable('#table1', col1);
loadTable('#table2', col2);
})
function loadTable(id, col) {
table.render({
elem: id,
//url: '/layui-table/api/table1.json',
data:[{"id":10000,"username":"user-0","sex":"女","city":"城市-0","sign":"签名-0","experience":255,"logins":24,"wealth":82830700,"classify":"作家","score":57},{"id":10001,"username":"user-1","sex":"男","city":"城市-1","sign":"签名-1","experience":884,"logins":58,"wealth":64928690,"classify":"词人","score":27},{"id":10002,"username":"user-2","sex":"女","city":"城市-2","sign":"签名-2","experience":650,"logins":77,"wealth":6298078,"classify":"酱油","score":31},{"id":10003,"username":"user-3","sex":"女","city":"城市-3","sign":"签名-3","experience":362,"logins":157,"wealth":37117017,"classify":"诗人","score":68},{"id":10004,"username":"user-4","sex":"男","city":"城市-4","sign":"签名-4","experience":807,"logins":51,"wealth":76263262,"classify":"作家","score":6},{"id":10005,"username":"user-5","sex":"女","city":"城市-5","sign":"签名-5","experience":173,"logins":68,"wealth":60344147,"classify":"作家","score":87},{"id":10006,"username":"user-6","sex":"女","city":"城市-6","sign":"签名-6","experience":982,"logins":37,"wealth":57768166,"classify":"作家","score":34},{"id":10007,"username":"user-7","sex":"男","city":"城市-7","sign":"签名-7","experience":727,"logins":150,"wealth":82030578,"classify":"作家","score":28},{"id":10008,"username":"user-8","sex":"男","city":"城市-8","sign":"签名-8","experience":951,"logins":133,"wealth":16503371,"classify":"词人","score":14},{"id":10009,"username":"user-9","sex":"女","city":"城市-9","sign":"签名-9","experience":484,"logins":25,"wealth":86801934,"classify":"词人","score":75}]
,cols: col
});
}
</script>
</body>
</html>
package com.winsun.test;
import cn.hutool.core.util.StrUtil;
import com.winsun.tools.entity.TreeNode;
import com.winsun.tools.entity.TreeNodeSql;
import com.winsun.tools.utils.THeadJsonUtils;
import com.winsun.tools.utils.TreeNodeDataCreator;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
/**
* @author zero
* @version 1.0
* @date 2020/5/27 12:04
*/
public class TestJsonUtils {
@Test
public void test1(){
String filePath = "E:\\Documents\\WeChat Files\\WeChat Files\\zero13168599099\\FileStorage\\File\\2020-05\\表头(3)(1)(1)(1).xlsx";
List<TreeNodeSql> list = TreeNodeDataCreator.getTreeNodeByExcel(filePath, 4);
//layui json
THeadJsonUtils.readData(list);
//app json
// THeadJsonUtils.writeAppJsonResult(list);
// for(TreeNodeSql sql : list){
// System.out.println(sql.toSql("sys_table_config", "能云必云情况"));
// }
}
}
package com.winsun.test;
import cn.hutool.core.io.FileUtil;
import com.winsun.tools.entity.TreeNodeReComplie;
import com.winsun.tools.utils.ExcelCellUtils;
import com.winsun.tools.utils.TreeNodeDataCreator;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.*;
/**
* @author zero
* @version 1.0
* @date 2020/5/24 0:34
*/
public class TestTreeNodeDataCreator {
@Test
public void testCreateCode() {
String filePath = "F:\\123.xlsx";
TreeNodeDataCreator.createCode(filePath);
}
@Test
public void testSplit() {
String str = "12#45";
String[] arr = str.split("#");
System.out.println(arr[0]);
System.out.println(arr[1]);
}
@Test
public void test1() {
String filePath = "F:\\123.xlsx";
// 需要解析的Excel文件
File file = new File(filePath);// "G:/项目资料/客户画像/111.xls"
try {
// 创建Excel,读取文件内容
XSSFWorkbook workbook = new XSSFWorkbook(FileUtil.getInputStream(filePath));
// 读取默认第一个工作表sheet
XSSFSheet sheet = workbook.getSheetAt(0);
int firstRowNum = 0;
List<String> list = new ArrayList<String>();
// 获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
// System.err.println(lastRowNum);
int total = 0;
for (int i = firstRowNum; i <= lastRowNum; i++) {
XSSFRow row = sheet.getRow(i);
// 获取当前行最后单元格列号
int lastCellNum = row.getLastCellNum();
for (int j = 0; j < lastCellNum; j++) {
XSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
String value = ExcelCellUtils.getCellValue(cell).toString();
if (value.equals("")) {
continue;
}
System.out.print(value + "1");
}
System.out.println();
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void test2() {
String filePath = "F:\\123.xlsx";
// 需要解析的Excel文件
File file = new File(filePath);// "G:/项目资料/客户画像/111.xls"
try {
// 创建Excel,读取文件内容
XSSFWorkbook workbook = new XSSFWorkbook(FileUtil.getInputStream(filePath));
// 读取默认第一个工作表sheet
XSSFSheet sheet = workbook.getSheetAt(0);
int firstRowNum = 0;
List<String> list = new ArrayList<String>();
// 获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
int total = 0;
for (int i = firstRowNum; i <= lastRowNum; i++) {
XSSFRow row = sheet.getRow(i);
// 获取当前行最后单元格列号
int lastCellNum = row.getLastCellNum();
for (int j = 0; j < lastCellNum; j++) {
XSSFCell cell = row.getCell(j);
String value = ExcelCellUtils.getCellValue(cell).toString();
System.out.print(value + "1 ");
}
System.out.println();
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void test3() {
String filePath = "F:\\123.xlsx";
// 需要解析的Excel文件
File file = new File(filePath);// "G:/项目资料/客户画像/111.xls"
try {
// 创建Excel,读取文件内容
XSSFWorkbook workbook = new XSSFWorkbook(FileUtil.getInputStream(filePath));
// 读取默认第一个工作表sheet
XSSFSheet sheet = workbook.getSheetAt(0);
int firstRowNum = 0;
List<String> javaList = new ArrayList<String>();
// 获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
// System.err.println(lastRowNum);
int total = 0;
List<TreeNodeReComplie> dataList = new LinkedList<>();
Map<String, TreeNodeReComplie> map = new LinkedHashMap<>();
System.out.println("TreeNode treeNode = new TreeNode(-1, \"\", null);");
for (int i = firstRowNum; i <= lastRowNum; i++) {
XSSFRow row = sheet.getRow(i);
// 获取当前行最后单元格列号
int lastCellNum = row.getLastCellNum();
for (int j = 0; j < lastCellNum; j++) {
XSSFCell cell = row.getCell(j);
if (cell == null) {
continue;
}
String value = ExcelCellUtils.getCellValue(cell).toString();
if (value.equals("")) {
continue;
}
TreeNodeReComplie treeNodeReComplie = new TreeNodeReComplie(total, value);
if (i != firstRowNum) {
XSSFRow row0 = sheet.getRow(i - 1);
XSSFCell cell0 = row0.getCell(j);
if (cell0 == null) {
treeNodeReComplie.setParent(dataList.get(total - 1).getParent());
} else {
String value0 = ExcelCellUtils.getCellValue(cell0).toString();
if (value0.equals("")) {
treeNodeReComplie.setParent(dataList.get(total - 1).getParent());
} else {
treeNodeReComplie.setParent(map.get(value0 + (i - 1) + "" + j));
}
}
} else {
treeNodeReComplie.setParent(new TreeNodeReComplie("treeNode"));
}
map.put(value + i + "" + j, treeNodeReComplie);
dataList.add(treeNodeReComplie);
total++;
System.out.println(treeNodeReComplie.getJavaCode());
}
}
System.out.println("treeNode.calLeavesAmount(treeNode);");
System.out.println("treeNode.calNodeLevel(treeNode);");
} catch (IOException e) {
e.printStackTrace();
}
}
/*
@Test
public void test(){
TreeNode treeNode = TreeNodeData.test();
// TreeNode treeNode = TreeNodeData.getMpsSalesTreeNodeData();
XSSFWorkbook workbook = ExcelTreeNodeHelper.getWorkbook(treeNode);
ExcelTreeNodeHelper.export(workbook);
}
*/
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.winsun.tools</groupId>
<artifactId>Generator</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>genTable</module>
<module>DBProject</module>
</modules>
<!--统一管理jar包版本-->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.version>4.12</junit.version>
<lombok.version>1.18.8</lombok.version>
<log4j.version>1.2.17</log4j.version>
<mysql.version>5.1.47</mysql.version>
<druid.version>1.1.16</druid.version>
<mybatis.spring.boot.version>1.3.0</mybatis.spring.boot.version>
</properties>
<dependencyManagement>
<dependencies>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<!--junit-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<!--log4j-->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<!-- poi-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<!--spring boot 2.2.2-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--mysql-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
<scope>runtime</scope>
</dependency>
<!-- druid-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<!--mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.spring.boot.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment