// 文件目录
String fileName=uploadFile.getFileItem().getName();//文件名
String uploadDir = SystemProperties.getProperty("upload.dir");
//获取系统时间
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
String str = simpleDateFormat.format(date);
String filePath = uploadDir+"BaseRules"+"/"+str+"/";
FileUtility.createDirectorys(filePath);
Random random = new Random();
try {
int rannum = (int) (random.nextDouble() * (99999 - 10000 + 1)) + 10000;// 获取5位随机数
FileOutputStream os = new FileOutputStream(filePath +rannum+ fileName);
InputStream in = uploadFile.getInputStream();
byte[] buffer = new byte[1024];
int b = 0;
while ((b = in.read(buffer)) != -1) {
os.write(buffer, 0, b);
}
System.out.println("上传成功!");
os.flush(); //关闭流
in.close();
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// long startTime=System.currentTimeMillis(); //获取开始时间
if (!uploadFile.isEmpty()) {
//读取Excel
InputStream inputStream = uploadFile.getInputStream();
SSXSSFWorkbook workbook = new SSXSSFWorkbook(new XSSFWorkbook(inputStream));
XSSFSheet sheet = (XSSFSheet) workbook.getXSSFWorkbook().getSheetAt(0);
int i = 1;
while (sheet.getRow(i) != null) {
//获取行号数据
Row row = sheet.getRow(i);
//存值
CqcBaseRulesVw cqcBaseRulesVw = new CqcBaseRulesVw();
cqcBaseRulesVw.setCqcNo(row.getCell(0).toString());// 序号
cqcBaseRulesVw.setCqcName(row.getCell(1).toString());// 总则
cqcBaseRulesVw.setItemCode(row.getCell(2).toString());// ITEM_CODE
cqcBaseRulesVw.setCqcDesc(row.getCell(3).toString()); // 说明
if("停用".equals(row.getCell(4).toString())){
cqcBaseRulesVw.setEnabledFlag("N");// 启用状态
}
else{
cqcBaseRulesVw.setEnabledFlag("Y");// 启用状态
}
cqcBaseRulesVw.setLoginUserVw(loginUser);
save(cqcBaseRulesVw);
i++;
}
}
}
String fileName=uploadFile.getFileItem().getName();//文件名
String uploadDir = SystemProperties.getProperty("upload.dir");
//获取系统时间
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
String str = simpleDateFormat.format(date);
String filePath = uploadDir+"BaseRules"+"/"+str+"/";
FileUtility.createDirectorys(filePath);
Random random = new Random();
try {
int rannum = (int) (random.nextDouble() * (99999 - 10000 + 1)) + 10000;// 获取5位随机数
FileOutputStream os = new FileOutputStream(filePath +rannum+ fileName);
InputStream in = uploadFile.getInputStream();
byte[] buffer = new byte[1024];
int b = 0;
while ((b = in.read(buffer)) != -1) {
os.write(buffer, 0, b);
}
System.out.println("上传成功!");
os.flush(); //关闭流
in.close();
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// long startTime=System.currentTimeMillis(); //获取开始时间
if (!uploadFile.isEmpty()) {
//读取Excel
InputStream inputStream = uploadFile.getInputStream();
SSXSSFWorkbook workbook = new SSXSSFWorkbook(new XSSFWorkbook(inputStream));
XSSFSheet sheet = (XSSFSheet) workbook.getXSSFWorkbook().getSheetAt(0);
int i = 1;
while (sheet.getRow(i) != null) {
//获取行号数据
Row row = sheet.getRow(i);
//存值
CqcBaseRulesVw cqcBaseRulesVw = new CqcBaseRulesVw();
cqcBaseRulesVw.setCqcNo(row.getCell(0).toString());// 序号
cqcBaseRulesVw.setCqcName(row.getCell(1).toString());// 总则
cqcBaseRulesVw.setItemCode(row.getCell(2).toString());// ITEM_CODE
cqcBaseRulesVw.setCqcDesc(row.getCell(3).toString()); // 说明
if("停用".equals(row.getCell(4).toString())){
cqcBaseRulesVw.setEnabledFlag("N");// 启用状态
}
else{
cqcBaseRulesVw.setEnabledFlag("Y");// 启用状态
}
cqcBaseRulesVw.setLoginUserVw(loginUser);
save(cqcBaseRulesVw);
i++;
}
}
}