部门管理全部导出
This commit is contained in:
parent
4b6c4d5c3d
commit
7fcee07495
|
|
@ -31,4 +31,14 @@ public interface ExportCommonService {
|
|||
* @return
|
||||
*/
|
||||
XSSFWorkbook resourceExport(HttpServletRequest request, HttpServletResponse response, String ids);
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 部门管理页面全部导出
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/9/21 3:43 PM
|
||||
* @param: []
|
||||
* @return: org.apache.poi.xssf.usermodel.XSSFWorkbook
|
||||
*/
|
||||
XSSFWorkbook departmentExport();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -243,7 +243,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
|
||||
@Override
|
||||
public Map<String, List<MenuBtn>> getHasRight() {
|
||||
return MenuBtn.getDatasNoBtnColum();
|
||||
MenuBtn.builder().isBatch("1").isTop("1").menuFun("new").menuIcon("icon-coms-New-Flow").menuName("新增").type("BTN_Addnew").build();
|
||||
Map<String, List<MenuBtn>> datasNoBtnColum = MenuBtn.getDatasNoBtnColum();
|
||||
datasNoBtnColum.get("topMenu").add(MenuBtn.builder().isBatch("0").isTop("1").menuFun("export").menuIcon("icon-coms-export").menuName("全部导出").type("BTN_Export").build());
|
||||
datasNoBtnColum.get("rightMenu").add(MenuBtn.builder().isBatch("0").isTop("0").menuFun("export").menuIcon("icon-coms-export").menuName("全部导出").type("BTN_Export").build());
|
||||
return datasNoBtnColum;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -10,12 +10,17 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|||
import com.cloudstore.eccom.result.WeaResultMsg;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.component.OrganizationWeaTable;
|
||||
import com.engine.organization.entity.department.bo.DepartmentBO;
|
||||
import com.engine.organization.entity.department.dto.DepartmentListDTO;
|
||||
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||
import com.engine.organization.entity.hrmresource.po.SearchTemplatePO;
|
||||
import com.engine.organization.entity.hrmresource.vo.HrmResourceVO;
|
||||
import com.engine.organization.mapper.department.DepartmentMapper;
|
||||
import com.engine.organization.mapper.resource.HrmResourceMapper;
|
||||
import com.engine.organization.mapper.resource.ResourceMapper;
|
||||
import com.engine.organization.service.ExportCommonService;
|
||||
import com.engine.organization.util.HrmI18nUtil;
|
||||
import com.engine.organization.util.PageInfoSortUtil;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import com.engine.organization.util.detach.DetachUtil;
|
||||
import com.engine.organization.util.excel.ExcelUtil;
|
||||
|
|
@ -38,6 +43,12 @@ import java.util.stream.Collectors;
|
|||
**/
|
||||
public class ExportCommonServiceImpl extends Service implements ExportCommonService {
|
||||
|
||||
|
||||
private static DepartmentMapper getDepartmentMapper() {
|
||||
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook resourceExport(List<Long> ids) {
|
||||
|
||||
|
|
@ -201,5 +212,45 @@ public class ExportCommonServiceImpl extends Service implements ExportCommonServ
|
|||
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook departmentExport() {
|
||||
String orderSql = PageInfoSortUtil.getSortSql("", " showorder ");
|
||||
List<DepartmentPO> allList = getDepartmentMapper().listAll(orderSql);
|
||||
new DetachUtil(user).filterDepartmentList(allList);
|
||||
List<DepartmentListDTO> compListDTOS = DepartmentBO.buildDeptDTOList(allList);
|
||||
|
||||
// 1.工作簿名称
|
||||
String sheetName = HrmI18nUtil.getI18nLabel(85368, "部门档案数据");
|
||||
// 2.表头(后面动态获取)
|
||||
List<List<Object>> excelSheetData = new ArrayList<>();
|
||||
|
||||
String[] header = {
|
||||
HrmI18nUtil.getI18nLabel( -93270, "部门名称"),
|
||||
HrmI18nUtil.getI18nLabel( -93272, "编号"),
|
||||
HrmI18nUtil.getI18nLabel( -93274, "部门简称"),
|
||||
HrmI18nUtil.getI18nLabel( -93275, "所属分部"),
|
||||
HrmI18nUtil.getI18nLabel( -93278, "上级部门"),
|
||||
HrmI18nUtil.getI18nLabel( -93279, "部门负责人"),
|
||||
HrmI18nUtil.getI18nLabel( -93280, "启用状态")
|
||||
};
|
||||
excelSheetData.add(Arrays.asList(header));
|
||||
|
||||
//数据
|
||||
List<List<Object>> rows = new LinkedList<>();
|
||||
for (DepartmentListDTO vo : compListDTOS) {
|
||||
List<Object> row = new LinkedList<>();
|
||||
row.add(vo.getDepartmentName());
|
||||
row.add(vo.getDepartmentCode());
|
||||
row.add(vo.getDepartmentMark());
|
||||
row.add(vo.getSubCompanyName());
|
||||
row.add(vo.getSupDepName());
|
||||
row.add(vo.getBmfzr());
|
||||
row.add(vo.getCanceled() == 0 ? "启用" : "未启用");
|
||||
rows.add(row);
|
||||
}
|
||||
excelSheetData.addAll(rows);
|
||||
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,26 +57,26 @@ public class ExportCommonController {
|
|||
}
|
||||
|
||||
|
||||
// @GET
|
||||
// @Path("/department/export")
|
||||
// @Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
// public Response departmentExport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
// User user = HrmUserVarify.getUser(request, response);
|
||||
// XSSFWorkbook workbook = getExportCommonWrapper(user).departmentExport(request, response);
|
||||
// String time = LocalDate.now().toString();
|
||||
// String fileName = "人员导出" + time;
|
||||
// try {
|
||||
// fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// StreamingOutput output = outputStream -> {
|
||||
// workbook.write(outputStream);
|
||||
// outputStream.flush();
|
||||
// };
|
||||
// response.setContentType("application/octet-stream");
|
||||
// return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
|
||||
// }
|
||||
@GET
|
||||
@Path("/department/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response departmentExport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getExportCommonWrapper(user).departmentExport();
|
||||
String time = LocalDate.now().toString();
|
||||
String fileName = "部门导出" + time;
|
||||
try {
|
||||
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
StreamingOutput output = outputStream -> {
|
||||
workbook.write(outputStream);
|
||||
outputStream.flush();
|
||||
};
|
||||
response.setContentType("application/octet-stream");
|
||||
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,4 +30,8 @@ public class ExportCommonWrapper extends Service {
|
|||
public XSSFWorkbook resourceExport(HttpServletRequest request, HttpServletResponse response, String ids) {
|
||||
return getExportCommonService(user).resourceExport(request, response, ids);
|
||||
}
|
||||
|
||||
public XSSFWorkbook departmentExport() {
|
||||
return getExportCommonService(user).departmentExport();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue