Commit aef2ca5c authored by zhkwei's avatar zhkwei

CIT固定资产-资产清单补充及优化以及部分导入工具类

parent 15fef97a
package pwc.taxtech.atms.service.impl;
import org.apache.poi.ss.usermodel.Cell;
import java.util.Calendar;
/**
* @author ZhiKai Z Wei
*/
public class CitCommonUtil {
/**
* 计算当前期间
* @return
*/
public static StringBuilder getPeriod(){
//计算当前期间
Calendar now = Calendar.getInstance();
StringBuilder sb = new StringBuilder();
sb.append(now.get(Calendar.YEAR));
if(now.get(Calendar.MONTH) + 1 < 10){
sb.append(0);
}
sb.append(now.get(Calendar.MONTH) + 1);
return sb;
}
/**
* 导入Excel时根据单元格类型获取单元格的值
* @param cell
* @return
*/
public static Object getValue(Cell cell) {
Object obj = null;
switch (cell.getCellTypeEnum()) {
case BOOLEAN:
obj = cell.getBooleanCellValue();
break;
case ERROR:
obj = cell.getErrorCellValue();
break;
case NUMERIC:
obj = cell.getNumericCellValue();
break;
case STRING:
obj = cell.getStringCellValue();
break;
default:
break;
}
return obj;
}
}
package pwc.taxtech.atms.service.impl;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.nutz.lang.Files;
......@@ -198,4 +203,22 @@ public class FileService {
}
}
public Workbook getWorkbook(InputStream inputStream, String fileName, String fileDir) throws IOException, InvalidFormatException {
String filePath = FileUtils.getTempDirectory().getAbsolutePath() + File.separator + fileDir + File.separator
+ CommonUtils.getUUID() + "_" + fileName;
//保存导入的文件
OperationResultDto<Object> saveResult = saveFile(inputStream, filePath);
//判断是否成功导入
if (saveResult.getResult() != null && !saveResult.getResult()) {
return null;
}
//获取保存文件的输入流
InputStream newInputStream = Files.findFileAsStream(filePath);
//通过输入流获取当前workbook
Workbook workbook = WorkbookFactory.create(newInputStream);
return workbook;
}
}
......@@ -143,6 +143,7 @@ public class MenuServiceImpl {
menuIds.add("a9b1cd87-89ef-4dae-b798-b19e9bbe0821");
menuIds.add("a9b1cd87-89ef-4dae-b798-b19e9bbe0822");
menuIds.add("a9b1cd87-89ef-4dae-b798-b19e9bbe0823");
menuIds.add("a9b1cd87-89ef-4dae-b798-b19e9bbe0824");
menuIds.add("b8c74ee9-e5d7-467b-8565-e77efe6a499f");
// List<MenuDto> menus = getMenus(moduleId).stream().filter(x -> permissionNames.contains(x.getName())).collect(Collectors.toList());
return menuIds;
......
<div id="app-data-import" class="app-data-import ">
<nav class="navbar navbar-custom" role="navigation"
style="margin-bottom: 0; background-image:url(../../../app-resources/images/leftbarbg.png); height:100%;width: 260px">
style="margin-bottom: 0; background-image:url(../../../app-resources/images/leftbarbg.png); height:auto;width: 260px">
<div class="sidebar navbarfix" role="navigation">
<div class="sidebar-nav navbar-collapse" id="sidebar-area" style="height:100%;width: 260px">
<div class="app-data-import-side-bar" style="height: 100%">
......
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