|
|
|
@ -17,10 +17,17 @@ import com.engine.organization.service.PostInfoService;
|
|
|
|
|
import com.engine.organization.util.*;
|
|
|
|
|
import com.engine.organization.util.db.DBType;
|
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
|
import com.engine.organization.util.excel.ExcelUtil;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
import weaver.general.GCONST;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -41,6 +48,39 @@ public class PostInfoServiceImpl extends Service implements PostInfoService {
|
|
|
|
|
private PostMapper getPostMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(PostMapper.class);
|
|
|
|
|
}
|
|
|
|
|
// 判断编制导入模板是否存在,不存在则创建该文件
|
|
|
|
|
static {
|
|
|
|
|
try {
|
|
|
|
|
String outPutPath = GCONST.getRootPath() + File.separator + "hrm" + File.separator + "import" + File.separator + "template" + File.separator + "postinfo.xls";
|
|
|
|
|
File excelPathFile = new File(outPutPath);
|
|
|
|
|
if (!excelPathFile.exists()) {
|
|
|
|
|
String columns = "编号,名称,职务分类,权限,责任,资格,描述说明";
|
|
|
|
|
String[] split = columns.split(",");
|
|
|
|
|
List<Object> columnList = new ArrayList<>(Arrays.asList(split));
|
|
|
|
|
// 创建导入模板
|
|
|
|
|
List<List<Object>> excelSheetData = new ArrayList<>();
|
|
|
|
|
excelSheetData.add(columnList);
|
|
|
|
|
XSSFWorkbook sheets = ExcelUtil.genWorkbookV2(excelSheetData, "postinfo");
|
|
|
|
|
File excelFile = new File(outPutPath);
|
|
|
|
|
if (!excelFile.exists()) {
|
|
|
|
|
String substring = outPutPath.substring(0, outPutPath.lastIndexOf(File.separator));
|
|
|
|
|
File file = new File(substring);
|
|
|
|
|
if (file.mkdirs()) {
|
|
|
|
|
boolean newFile = excelPathFile.createNewFile();
|
|
|
|
|
if (!newFile) {
|
|
|
|
|
throw new IOException(outPutPath + "文件创建失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FileOutputStream out = new FileOutputStream(excelPathFile);
|
|
|
|
|
sheets.write(out);
|
|
|
|
|
out.flush();
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
new BaseBean().writeLog(e);
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> listPage(Map<String, Object> params) {
|
|
|
|
|