数据库配置

yun-zuoyi
yunhao.wang 7 years ago
parent d53cd353dd
commit b84402a40a

@ -106,22 +106,22 @@ spring.data.mongodb.port=27017
##主数据源,读写
#impp.write.datasource.type=com.zaxxer.hikari.HikariDataSource
impp.write.datasource.driver-class-name=com.mysql.jdbc.Driver
impp.write.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/dev_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.write.datasource.username=i3_dev_core
impp.write.datasource.password=i3_core_pass
impp.write.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/impp_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.write.datasource.username=impp_i3_core_user
impp.write.datasource.password=impp_i3_core_pwd
##辅数据源,只读
#impp.read.datasource.type=com.zaxxer.hikari.HikariDataSource
impp.read.datasource.driver-class-name=com.mysql.jdbc.Driver
impp.read.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/dev_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.read.datasource.username=i3_dev_core
impp.read.datasource.password=i3_core_pass
impp.read.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/impp_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.read.datasource.username=impp_i3_core_user
impp.read.datasource.password=impp_i3_core_pwd
##############定时任务持久化##############
impp.schedule.datasource.driver-class-name=com.mysql.jdbc.Driver
impp.schedule.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/dev_i3_schedule?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.schedule.datasource.username=i3_dev_schedule
impp.schedule.datasource.password=i3_schedule_pass
impp.schedule.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/impp_i3_schedule?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.schedule.datasource.username=impp_i3_schedule_user
impp.schedule.datasource.password=impp_i3_schedule_pwd
impp.schedule.datasource.max-connections=20
#定时任务在服务启动后多少秒执行
impp.schedule.start.after-second=20

@ -1,5 +1,5 @@
#项目端口
server.port=8100
server.port=1100
#本机ip
impp.server.ip=192.168.1.56
#console控制台服务zipkin追踪全路径
@ -84,7 +84,7 @@ spring.zipkin.base-url=${impp.console.ip}
spring.sleuth.sampler.probability=1.0
################ 日志据源 ################
spring.data.mongodb.database=mongoDBSource
spring.data.mongodb.database=prodMongoDBSource
spring.data.mongodb.uri=192.168.1.55:27017
spring.data.mongodb.username=sa
spring.data.mongodb.password=i3plus
@ -106,22 +106,22 @@ spring.data.mongodb.port=27017
##主数据源,读写
#impp.write.datasource.type=com.zaxxer.hikari.HikariDataSource
impp.write.datasource.driver-class-name=com.mysql.jdbc.Driver
impp.write.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/dev_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.write.datasource.username=i3_dev_core
impp.write.datasource.password=i3_core_pass
impp.write.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3309/impp_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.write.datasource.username=impp_i3_core_user
impp.write.datasource.password=impp_i3_core_pwd
##辅数据源,只读
#impp.read.datasource.type=com.zaxxer.hikari.HikariDataSource
impp.read.datasource.driver-class-name=com.mysql.jdbc.Driver
impp.read.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/dev_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.read.datasource.username=i3_dev_core
impp.read.datasource.password=i3_core_pass
impp.read.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3309/impp_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.read.datasource.username=impp_i3_core_user
impp.read.datasource.password=impp_i3_core_pwd
##############定时任务持久化##############
impp.schedule.datasource.driver-class-name=com.mysql.jdbc.Driver
impp.schedule.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/dev_i3_schedule?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.schedule.datasource.username=i3_dev_schedule
impp.schedule.datasource.password=i3_schedule_pass
impp.schedule.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3309/impp_i3_schedule?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.schedule.datasource.username=impp_i3_schedule_user
impp.schedule.datasource.password=impp_i3_schedule_pwd
impp.schedule.datasource.max-connections=20
#定时任务在服务启动后多少秒执行
impp.schedule.start.after-second=20

@ -1,5 +1,5 @@
#项目端口
server.port=8100
server.port=58100
#本机ip
impp.server.ip=192.168.1.56
#console控制台服务zipkin追踪全路径
@ -84,7 +84,7 @@ spring.zipkin.base-url=${impp.console.ip}
spring.sleuth.sampler.probability=1.0
################ 日志据源 ################
spring.data.mongodb.database=mongoDBSource
spring.data.mongodb.database=testMongoDBSource
spring.data.mongodb.uri=192.168.1.55:27017
spring.data.mongodb.username=sa
spring.data.mongodb.password=i3plus
@ -106,22 +106,22 @@ spring.data.mongodb.port=27017
##主数据源,读写
#impp.write.datasource.type=com.zaxxer.hikari.HikariDataSource
impp.write.datasource.driver-class-name=com.mysql.jdbc.Driver
impp.write.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/dev_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.write.datasource.username=i3_dev_core
impp.write.datasource.password=i3_core_pass
impp.write.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3308/impp_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.write.datasource.username=impp_i3_core_user
impp.write.datasource.password=impp_i3_core_pwd
##辅数据源,只读
#impp.read.datasource.type=com.zaxxer.hikari.HikariDataSource
impp.read.datasource.driver-class-name=com.mysql.jdbc.Driver
impp.read.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/dev_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.read.datasource.username=i3_dev_core
impp.read.datasource.password=i3_core_pass
impp.read.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3308/impp_i3_core?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.read.datasource.username=impp_i3_core_user
impp.read.datasource.password=impp_i3_core_pwd
##############定时任务持久化##############
impp.schedule.datasource.driver-class-name=com.mysql.jdbc.Driver
impp.schedule.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3306/dev_i3_schedule?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.schedule.datasource.username=i3_dev_schedule
impp.schedule.datasource.password=i3_schedule_pass
impp.schedule.datasource.jdbc-url=jdbc:mysql://192.168.1.55:3308/impp_i3_schedule?autoReconnect=true&useSSL=false&characterEncoding=utf-8
impp.schedule.datasource.username=impp_i3_schedule_user
impp.schedule.datasource.password=impp_i3_schedule_pwd
impp.schedule.datasource.max-connections=20
#定时任务在服务启动后多少秒执行
impp.schedule.start.after-second=20

@ -141,6 +141,7 @@ public class TestExcelPermission extends TestBase {
obj.setUserInfoId(Long.parseLong(row.getCell(5).getStringCellValue()));
obj.setUserName(row.getCell(6).getStringCellValue());
obj.setIsValid(1);
obj.setUserStatus(1);
obj.setUserType(1);
obj.setUserLoginNum(0);

@ -1,207 +1,207 @@
//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
//
//import cn.estsh.i3plus.pojo.platform.bean.*;
//import cn.estsh.i3plus.pojo.platform.repository.SysConfigRepository;
//import cn.estsh.i3plus.pojo.platform.repository.SysDictionaryRepository;
//import cn.estsh.i3plus.pojo.platform.repository.SysLocaleLanguageRepository;
//import cn.estsh.i3plus.pojo.platform.repository.SysLocaleResourceRepository;
//import org.apache.poi.ss.usermodel.Row;
//import org.apache.poi.xssf.usermodel.XSSFSheet;
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
//import org.junit.Test;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//
//import java.io.InputStream;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @Description :
// * @Reference :
// * @Author : yunhao
// * @CreateDate : 2018-11-22 11:01
// * @Modify:
// **/
//public class TestExcelSysConfig extends TestBase {
//
// public static final Logger LOGGER = LoggerFactory.getLogger(TestExcelPermission.class);
//
// // 文件路径
// public static final String PATH_NAME = "init/sys-config.xlsx";
// // 权限Sheet 名称
// public static final String SHEET_SYS_CONFIG = "sys-config";
// public static final String SHEET_DICTIONARY = "dictionary";
// public static final String SHEET_LANGUAGE = "language";
// public static final String SHEET_RESOURCE = "resource";
//
// @Autowired
// private SysConfigRepository sysConfigRDao;
// @Autowired
// private SysDictionaryRepository sysDictionaryRDao;
// @Autowired
// private SysLocaleLanguageRepository sysLocaleLanguageRDao;
// @Autowired
// private SysLocaleResourceRepository sysLocaleResourceRDao;
//
// @Test
// public void testInit() throws Exception {
// XSSFWorkbook workbook = getWorkbook(PATH_NAME);
// if(workbook != null){
// XSSFSheet sheetSysConfig = workbook.getSheet(SHEET_SYS_CONFIG);
// XSSFSheet sheetDictionary = workbook.getSheet(SHEET_DICTIONARY);
// XSSFSheet sheetLanguage = workbook.getSheet(SHEET_LANGUAGE);
// XSSFSheet sheetResource = workbook.getSheet(SHEET_RESOURCE);
//
// List<SysConfig> sysConfigList = getSysConfig(sheetSysConfig);
// List<SysDictionary> sysDictionaryList = getSysDictionary(sheetDictionary);
// List<SysLocaleLanguage> sysLocaleLanguageList = getSysLocaleLanguage(sheetLanguage);
// List<SysLocaleResource> sysLocaleResourceList= getSysLocaleResource(sheetResource);
//
// LOGGER.info("System Init SysConfig Size:{}",sysConfigList.size());
// LOGGER.info("System Init SysDictionary Size:{}",sysDictionaryList.size());
// LOGGER.info("System Init SysLocaleLanguage Size:{}",sysLocaleLanguageList.size());
// LOGGER.info("System Init SysLocaleResource Size:{}",sysLocaleResourceList.size());
//
// sysConfigRDao.saveAll(sysConfigList);
// sysDictionaryRDao.saveAll(sysDictionaryList);
// sysLocaleLanguageRDao.saveAll(sysLocaleLanguageList);
// sysLocaleResourceRDao.saveAll(sysLocaleResourceList);
// }
// }
//
// public List<SysConfig> getSysConfig(XSSFSheet sheet){
// List<SysConfig> result = new ArrayList<>();
// if(sheet != null){
// if(sheet.getLastRowNum() >= 1){
// SysConfig obj = null;
// for (int i = 1; i <= sheet.getLastRowNum(); i++) {
// try {
// Row row = sheet.getRow(i);//获取索引为i的行以0开始
// if(row.getCell(0).toString().trim().length() > 0){
// obj = new SysConfig();
// obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
// obj.setName(row.getCell(1).getStringCellValue());
// obj.setConfigType(Integer.valueOf(row.getCell(2).getStringCellValue()));
// obj.setConfigCode(row.getCell(3).getStringCellValue());
// obj.setConfigValue(row.getCell(4).getStringCellValue());
// obj.setConfigDescription(row.getCell(5).getStringCellValue());
// obj.setIsValid(1);
//
// result.add(obj);
// }
// }catch (Exception e){
// LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
// }
// }
// }
// }
// return result;
// }
//
// public List<SysDictionary> getSysDictionary(XSSFSheet sheet){
// List<SysDictionary> result = new ArrayList<>();
// if(sheet != null){
// if(sheet.getLastRowNum() >= 1){
// SysDictionary obj = null;
// for (int i = 1; i <= sheet.getLastRowNum(); i++) {
// try {
// Row row = sheet.getRow(i);//获取索引为i的行以0开始
// if(row.getCell(0).toString().trim().length() > 0){
// obj = new SysDictionary();
// obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
// obj.setName(row.getCell(1).getStringCellValue());
// obj.setDictionaryCode(row.getCell(2).getStringCellValue());
// obj.setParentId(Long.valueOf(row.getCell(3).getStringCellValue()));
// obj.setParentNameRdd(row.getCell(4).getStringCellValue());
// obj.setParentCodeRdd(row.getCell(5).getStringCellValue());
// obj.setDictionaryValue(row.getCell(6).getStringCellValue());
// obj.setDictionarySort(Integer.valueOf(row.getCell(7).getStringCellValue()));
// obj.setDictionaryDescription(row.getCell(8).getStringCellValue());
// obj.setIsValid(1);
//
// result.add(obj);
// }
// }catch (Exception e){
// LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
// }
// }
// }
// }
// return result;
// }
//
// public List<SysLocaleLanguage> getSysLocaleLanguage(XSSFSheet sheet){
// List<SysLocaleLanguage> result = new ArrayList<>();
// if(sheet != null){
// if(sheet.getLastRowNum() >= 1){
// SysLocaleLanguage obj = null;
// for (int i = 1; i <= sheet.getLastRowNum(); i++) {
// try {
// Row row = sheet.getRow(i);//获取索引为i的行以0开始
// if(row.getCell(0).toString().trim().length() > 0){
// obj = new SysLocaleLanguage();
// obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
// obj.setLanguageName(row.getCell(1).getStringCellValue());
// obj.setLanguageCode(row.getCell(2).getStringCellValue());
// obj.setLanguageSort(Integer.valueOf(row.getCell(3).getStringCellValue()));
// obj.setIsDefault(Integer.valueOf(row.getCell(4).getStringCellValue()));
// obj.setLanguageStatus(Integer.valueOf(row.getCell(5).getStringCellValue()));
// obj.setIsValid(1);
//
// result.add(obj);
// }
// }catch (Exception e){
// LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
// }
// }
// }
// }
// return result;
// }
//
// public List<SysLocaleResource> getSysLocaleResource(XSSFSheet sheet){
// List<SysLocaleResource> result = new ArrayList<>();
// if(sheet != null){
// if(sheet.getLastRowNum() >= 1){
// SysLocaleResource obj = null;
// for (int i = 1; i <= sheet.getLastRowNum(); i++) {
// try {
// Row row = sheet.getRow(i);//获取索引为i的行以0开始
// if(row.getCell(0).toString().trim().length() > 0){
// obj = new SysLocaleResource();
// obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
// obj.setResourceType(Integer.valueOf(row.getCell(1).getStringCellValue()));
// obj.setLanguageCode(row.getCell(2).getStringCellValue());
// obj.setLanguageNameRdd(row.getCell(3).getStringCellValue());
// obj.setResourceKey(row.getCell(4).getStringCellValue());
// obj.setResourceValue(row.getCell(5).getStringCellValue());
// obj.setIsSystem(Integer.valueOf(row.getCell(6).getStringCellValue()));
// obj.setIsValid(1);
//
// result.add(obj);
// }
// }catch (Exception e){
// LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
// }
// }
// }
// }
// return result;
// }
//
//
// public XSSFWorkbook getWorkbook(String pathName){
// try {
// InputStream in = TestExcelPermission.class.getClassLoader().getResourceAsStream(pathName);
// XSSFWorkbook workbook = new XSSFWorkbook(in);
// return workbook;
// }catch (Exception e){
// LOGGER.error(" System Init Sys Data Excel Error file path {} error message :{}",pathName,e.getMessage());
// e.getMessage();
// return null;
// }
// }
//
//}
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.pojo.platform.bean.*;
import cn.estsh.i3plus.pojo.platform.repository.SysConfigRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysDictionaryRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysLocaleLanguageRepository;
import cn.estsh.i3plus.pojo.platform.repository.SysLocaleResourceRepository;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2018-11-22 11:01
* @Modify:
**/
public class TestExcelSysConfig extends TestBase {
public static final Logger LOGGER = LoggerFactory.getLogger(TestExcelPermission.class);
// 文件路径
public static final String PATH_NAME = "init/sys-config.xlsx";
// 权限Sheet 名称
public static final String SHEET_SYS_CONFIG = "sys-config";
public static final String SHEET_DICTIONARY = "dictionary";
public static final String SHEET_LANGUAGE = "language";
public static final String SHEET_RESOURCE = "resource";
@Autowired
private SysConfigRepository sysConfigRDao;
@Autowired
private SysDictionaryRepository sysDictionaryRDao;
@Autowired
private SysLocaleLanguageRepository sysLocaleLanguageRDao;
@Autowired
private SysLocaleResourceRepository sysLocaleResourceRDao;
@Test
public void testInit() throws Exception {
XSSFWorkbook workbook = getWorkbook(PATH_NAME);
if(workbook != null){
XSSFSheet sheetSysConfig = workbook.getSheet(SHEET_SYS_CONFIG);
XSSFSheet sheetDictionary = workbook.getSheet(SHEET_DICTIONARY);
XSSFSheet sheetLanguage = workbook.getSheet(SHEET_LANGUAGE);
XSSFSheet sheetResource = workbook.getSheet(SHEET_RESOURCE);
List<SysConfig> sysConfigList = getSysConfig(sheetSysConfig);
List<SysDictionary> sysDictionaryList = getSysDictionary(sheetDictionary);
List<SysLocaleLanguage> sysLocaleLanguageList = getSysLocaleLanguage(sheetLanguage);
List<SysLocaleResource> sysLocaleResourceList= getSysLocaleResource(sheetResource);
LOGGER.info("System Init SysConfig Size:{}",sysConfigList.size());
LOGGER.info("System Init SysDictionary Size:{}",sysDictionaryList.size());
LOGGER.info("System Init SysLocaleLanguage Size:{}",sysLocaleLanguageList.size());
LOGGER.info("System Init SysLocaleResource Size:{}",sysLocaleResourceList.size());
sysConfigRDao.saveAll(sysConfigList);
sysDictionaryRDao.saveAll(sysDictionaryList);
sysLocaleLanguageRDao.saveAll(sysLocaleLanguageList);
sysLocaleResourceRDao.saveAll(sysLocaleResourceList);
}
}
public List<SysConfig> getSysConfig(XSSFSheet sheet){
List<SysConfig> result = new ArrayList<>();
if(sheet != null){
if(sheet.getLastRowNum() >= 1){
SysConfig obj = null;
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
try {
Row row = sheet.getRow(i);//获取索引为i的行以0开始
if(row.getCell(0).toString().trim().length() > 0){
obj = new SysConfig();
obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
obj.setName(row.getCell(1).getStringCellValue());
obj.setConfigType(Integer.valueOf(row.getCell(2).getStringCellValue()));
obj.setConfigCode(row.getCell(3).getStringCellValue());
obj.setConfigValue(row.getCell(4).getStringCellValue());
obj.setConfigDescription(row.getCell(5).getStringCellValue());
obj.setIsValid(1);
result.add(obj);
}
}catch (Exception e){
LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
}
}
}
}
return result;
}
public List<SysDictionary> getSysDictionary(XSSFSheet sheet){
List<SysDictionary> result = new ArrayList<>();
if(sheet != null){
if(sheet.getLastRowNum() >= 1){
SysDictionary obj = null;
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
try {
Row row = sheet.getRow(i);//获取索引为i的行以0开始
if(row.getCell(0).toString().trim().length() > 0){
obj = new SysDictionary();
obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
obj.setName(row.getCell(1).getStringCellValue());
obj.setDictionaryCode(row.getCell(2).getStringCellValue());
obj.setParentId(Long.valueOf(row.getCell(3).getStringCellValue()));
obj.setParentNameRdd(row.getCell(4).getStringCellValue());
obj.setParentCodeRdd(row.getCell(5).getStringCellValue());
obj.setDictionaryValue(row.getCell(6).getStringCellValue());
obj.setDictionarySort(Integer.valueOf(row.getCell(7).getStringCellValue()));
obj.setDictionaryDescription(row.getCell(8).getStringCellValue());
obj.setIsValid(1);
result.add(obj);
}
}catch (Exception e){
LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
}
}
}
}
return result;
}
public List<SysLocaleLanguage> getSysLocaleLanguage(XSSFSheet sheet){
List<SysLocaleLanguage> result = new ArrayList<>();
if(sheet != null){
if(sheet.getLastRowNum() >= 1){
SysLocaleLanguage obj = null;
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
try {
Row row = sheet.getRow(i);//获取索引为i的行以0开始
if(row.getCell(0).toString().trim().length() > 0){
obj = new SysLocaleLanguage();
obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
obj.setLanguageName(row.getCell(1).getStringCellValue());
obj.setLanguageCode(row.getCell(2).getStringCellValue());
obj.setLanguageSort(Integer.valueOf(row.getCell(3).getStringCellValue()));
obj.setIsDefault(Integer.valueOf(row.getCell(4).getStringCellValue()));
obj.setLanguageStatus(Integer.valueOf(row.getCell(5).getStringCellValue()));
obj.setIsValid(1);
result.add(obj);
}
}catch (Exception e){
LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
}
}
}
}
return result;
}
public List<SysLocaleResource> getSysLocaleResource(XSSFSheet sheet){
List<SysLocaleResource> result = new ArrayList<>();
if(sheet != null){
if(sheet.getLastRowNum() >= 1){
SysLocaleResource obj = null;
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
try {
Row row = sheet.getRow(i);//获取索引为i的行以0开始
if(row.getCell(0).toString().trim().length() > 0){
obj = new SysLocaleResource();
obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
obj.setResourceType(Integer.valueOf(row.getCell(1).getStringCellValue()));
obj.setLanguageCode(row.getCell(2).getStringCellValue());
obj.setLanguageNameRdd(row.getCell(3).getStringCellValue());
obj.setResourceKey(row.getCell(4).getStringCellValue());
obj.setResourceValue(row.getCell(5).getStringCellValue());
obj.setIsSystem(Integer.valueOf(row.getCell(6).getStringCellValue()));
obj.setIsValid(1);
result.add(obj);
}
}catch (Exception e){
LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i);
}
}
}
}
return result;
}
public XSSFWorkbook getWorkbook(String pathName){
try {
InputStream in = TestExcelPermission.class.getClassLoader().getResourceAsStream(pathName);
XSSFWorkbook workbook = new XSSFWorkbook(in);
return workbook;
}catch (Exception e){
LOGGER.error(" System Init Sys Data Excel Error file path {} error message :{}",pathName,e.getMessage());
e.getMessage();
return null;
}
}
}

Loading…
Cancel
Save