|
|
|
@ -39,6 +39,7 @@ import com.engine.organization.util.*;
|
|
|
|
|
import com.engine.organization.util.coderule.CodeRuleUtil;
|
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
|
import com.engine.organization.util.detach.DetachUtil;
|
|
|
|
|
import com.engine.organization.util.excel.ExcelUtil;
|
|
|
|
|
import com.engine.organization.util.page.Column;
|
|
|
|
|
import com.engine.organization.util.page.PageInfo;
|
|
|
|
|
import com.engine.organization.util.page.PageUtil;
|
|
|
|
@ -46,6 +47,7 @@ import com.engine.organization.util.tree.SearchTreeUtil;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import weaver.common.DateUtil;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
@ -696,6 +698,58 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public XSSFWorkbook departmentExport() {
|
|
|
|
|
|
|
|
|
|
String orderSql = PageInfoSortUtil.getSortSql("", " showorder ");
|
|
|
|
|
List<DepartmentPO> allList = getDepartmentMapper().listAll(orderSql);
|
|
|
|
|
Map<Integer, DepartmentPO> poMaps = allList.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item));
|
|
|
|
|
List<DepartmentListDTO> dtoList = allList.stream().map(e ->
|
|
|
|
|
DepartmentListDTO
|
|
|
|
|
.builder()
|
|
|
|
|
.id(e.getId())
|
|
|
|
|
.departmentMark(e.getDepartmentMark())
|
|
|
|
|
.departmentName(e.getDepartmentName())
|
|
|
|
|
.departmentCode(e.getDepartmentCode())
|
|
|
|
|
.subCompanyName(0 == e.getSubCompanyId1() ? "" : MapperProxyFactory.getProxy(CompMapper.class).listById(e.getSubCompanyId1()).getSubCompanyName())
|
|
|
|
|
.supDepName(null == poMaps.get(e.getSupDepId()) ? "" : poMaps.get(e.getSupDepId()).getDepartmentName())
|
|
|
|
|
.bmfzr(DepartmentBO.getEmployeeNameById(e.getId()))
|
|
|
|
|
.canceled(null == e.getCanceled() ? 0 : e.getCanceled())
|
|
|
|
|
.build()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// 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 : dtoList) {
|
|
|
|
|
List<Object> row = new LinkedList<>();
|
|
|
|
|
row.add(vo.getDepartmentCode());
|
|
|
|
|
row.add(vo.getDepartmentName());
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取所有子部门id
|
|
|
|
|
*
|
|
|
|
|