|
|
|
@ -1,96 +1,96 @@
|
|
|
|
|
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.*;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.repository.*;
|
|
|
|
|
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 TestExcelOrderNoRule extends TestBase {
|
|
|
|
|
|
|
|
|
|
public static final Logger LOGGER = LoggerFactory.getLogger(TestExcelOrderNoRule.class);
|
|
|
|
|
|
|
|
|
|
// 文件路径
|
|
|
|
|
public static final String PATH_NAME = "init/oder-no-rule.xlsx";
|
|
|
|
|
// 权限Sheet 名称
|
|
|
|
|
public static final String SHEET_ORDER_NO_RULE = "order-no-rule";
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysOrderNoRuleRepository sysOrderNoRuleRDao;
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testInit() throws Exception {
|
|
|
|
|
XSSFWorkbook workbook = getWorkbook(PATH_NAME);
|
|
|
|
|
if(workbook != null){
|
|
|
|
|
XSSFSheet sheetOrderNoRule = workbook.getSheet(SHEET_ORDER_NO_RULE);
|
|
|
|
|
|
|
|
|
|
List<SysOrderNoRule> ysOrderNoRuleList = getSysOrderNoRule(sheetOrderNoRule);
|
|
|
|
|
|
|
|
|
|
LOGGER.info("System Init SysOrderNoRule Size:{}",ysOrderNoRuleList.size());
|
|
|
|
|
|
|
|
|
|
sysOrderNoRuleRDao.saveAll(ysOrderNoRuleList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<SysOrderNoRule> getSysOrderNoRule(XSSFSheet sheet){
|
|
|
|
|
List<SysOrderNoRule> result = new ArrayList<>();
|
|
|
|
|
if(sheet != null){
|
|
|
|
|
if(sheet.getLastRowNum() >= 1){
|
|
|
|
|
SysOrderNoRule 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 SysOrderNoRule();
|
|
|
|
|
obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
|
|
|
|
|
obj.setName(row.getCell(1).getStringCellValue());
|
|
|
|
|
obj.setOrderNoRuleCode(row.getCell(2).getStringCellValue());
|
|
|
|
|
obj.setOrderNoRule(row.getCell(3).getStringCellValue());
|
|
|
|
|
obj.setSerialNoSeed(Long.parseLong(row.getCell(4).getStringCellValue()));
|
|
|
|
|
obj.setSerialNoIncrement(Long.parseLong(row.getCell(5).getStringCellValue()));
|
|
|
|
|
obj.setSerialNoLength(Long.parseLong(row.getCell(6).getStringCellValue()));
|
|
|
|
|
obj.setIsCycle(Integer.parseInt(row.getCell(7).getStringCellValue()));
|
|
|
|
|
obj.setOrderNoRuleDescription(row.getCell(8).getStringCellValue());
|
|
|
|
|
obj.setOrderNoRuleStatus(1);
|
|
|
|
|
obj.setSerialNo(-1L);
|
|
|
|
|
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;//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
|
|
|
|
//
|
|
|
|
|
//import cn.estsh.i3plus.pojo.platform.bean.*;
|
|
|
|
|
//import cn.estsh.i3plus.pojo.platform.repository.*;
|
|
|
|
|
//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 TestExcelOrderNoRule extends cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestBase {
|
|
|
|
|
//
|
|
|
|
|
// public static final Logger LOGGER = LoggerFactory.getLogger(TestExcelOrderNoRule.class);
|
|
|
|
|
//
|
|
|
|
|
// // 文件路径
|
|
|
|
|
// public static final String PATH_NAME = "init/oder-no-rule.xlsx";
|
|
|
|
|
// // 权限Sheet 名称
|
|
|
|
|
// public static final String SHEET_ORDER_NO_RULE = "order-no-rule";
|
|
|
|
|
//
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private SysOrderNoRuleRepository sysOrderNoRuleRDao;
|
|
|
|
|
//
|
|
|
|
|
// @Test
|
|
|
|
|
// public void testInit() throws Exception {
|
|
|
|
|
// XSSFWorkbook workbook = getWorkbook(PATH_NAME);
|
|
|
|
|
// if(workbook != null){
|
|
|
|
|
// XSSFSheet sheetOrderNoRule = workbook.getSheet(SHEET_ORDER_NO_RULE);
|
|
|
|
|
//
|
|
|
|
|
// List<SysOrderNoRule> ysOrderNoRuleList = getSysOrderNoRule(sheetOrderNoRule);
|
|
|
|
|
//
|
|
|
|
|
// LOGGER.info("System Init SysOrderNoRule Size:{}",ysOrderNoRuleList.size());
|
|
|
|
|
//
|
|
|
|
|
// sysOrderNoRuleRDao.saveAll(ysOrderNoRuleList);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// public List<SysOrderNoRule> getSysOrderNoRule(XSSFSheet sheet){
|
|
|
|
|
// List<SysOrderNoRule> result = new ArrayList<>();
|
|
|
|
|
// if(sheet != null){
|
|
|
|
|
// if(sheet.getLastRowNum() >= 1){
|
|
|
|
|
// SysOrderNoRule 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 SysOrderNoRule();
|
|
|
|
|
// obj.setId(Long.parseLong(row.getCell(0).getStringCellValue()));
|
|
|
|
|
// obj.setName(row.getCell(1).getStringCellValue());
|
|
|
|
|
// obj.setOrderNoRuleCode(row.getCell(2).getStringCellValue());
|
|
|
|
|
// obj.setOrderNoRule(row.getCell(3).getStringCellValue());
|
|
|
|
|
// obj.setSerialNoSeed(Long.parseLong(row.getCell(4).getStringCellValue()));
|
|
|
|
|
// obj.setSerialNoIncrement(Long.parseLong(row.getCell(5).getStringCellValue()));
|
|
|
|
|
// obj.setSerialNoLength(Long.parseLong(row.getCell(6).getStringCellValue()));
|
|
|
|
|
// obj.setIsCycle(Integer.parseInt(row.getCell(7).getStringCellValue()));
|
|
|
|
|
// obj.setOrderNoRuleDescription(row.getCell(8).getStringCellValue());
|
|
|
|
|
// obj.setOrderNoRuleStatus(1);
|
|
|
|
|
// obj.setSerialNo(-1L);
|
|
|
|
|
// 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 = cn.estsh.i3plus.core.apiservice.serviceimpl.busi.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;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//}
|
|
|
|
|