晶优二开,编制信息导出
This commit is contained in:
parent
33c02ec78e
commit
0f84ffa2e0
|
|
@ -0,0 +1,99 @@
|
|||
package com.engine.organization.entity.staff.po;
|
||||
|
||||
import com.engine.organization.annotation.OrganizationTableColumn;
|
||||
import com.engine.organization.transmethod.*;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/03/13
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class StaffExportPO {
|
||||
|
||||
/**
|
||||
* 方案id
|
||||
*/
|
||||
@OrganizationTableColumn(text = "方案", width = "10%", column = "plan_id", transmethod = "com.engine.organization.transmethod.StaffPlanTransMethod.getSpanById")
|
||||
private String planId;
|
||||
/**
|
||||
* 分部
|
||||
*/
|
||||
@OrganizationTableColumn(text = "分部", width = "10%", column = "comp_id", transmethod = "com.engine.organization.transmethod.CompTransMethod.getSpanById")
|
||||
private String compId;
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
@OrganizationTableColumn(text = "部门", width = "10%", column = "dept_id", transmethod = "com.engine.organization.transmethod.DepartmentTransMethod.getSpanById")
|
||||
private String deptId;
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
@OrganizationTableColumn(text = "岗位", width = "10%", column = "job_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getSpanById")
|
||||
private String jobId;
|
||||
/**
|
||||
* 编制数
|
||||
*/
|
||||
@OrganizationTableColumn(text = "编制数", width = "10%", column = "staff_num")
|
||||
private Integer staffNum;
|
||||
/**
|
||||
* 在编
|
||||
*/
|
||||
@OrganizationTableColumn(text = "在编", width = "10%", column = "permanent_num")
|
||||
private Integer permanentNum;
|
||||
/**
|
||||
* 冻结数
|
||||
*/
|
||||
@OrganizationTableColumn(text = "冻结数", width = "10%", column = "freeze_num")
|
||||
private Integer freezeNum;
|
||||
/**
|
||||
* 缺编状态
|
||||
*/
|
||||
@OrganizationTableColumn(text = "缺编状态", width = "10%", column = "lack_status", transmethod = "com.engine.organization.transmethod.StaffTransMethod.getLackSpan")
|
||||
private String lackStatus;
|
||||
/**
|
||||
* 编制描述
|
||||
*/
|
||||
@OrganizationTableColumn(text = "编制描述", width = "10%", column = "staff_desc")
|
||||
private String staffDesc;
|
||||
|
||||
|
||||
public String getPlanId() {
|
||||
return StringUtils.isBlank(planId) ? "" : StaffPlanTransMethod.getSpanById(planId);
|
||||
}
|
||||
|
||||
public String getCompId() {
|
||||
return StringUtils.isBlank(compId) ? "" : CompTransMethod.getSpanById(compId);
|
||||
}
|
||||
|
||||
public String getDeptId() {
|
||||
return StringUtils.isBlank(deptId) ? "" : DepartmentTransMethod.getSpanById(deptId);
|
||||
}
|
||||
|
||||
public String getJobId() {
|
||||
return StringUtils.isBlank(jobId) ? "" : JobTransMethod.getSpanById(jobId);
|
||||
}
|
||||
|
||||
public Integer getStaffNum() {
|
||||
return staffNum;
|
||||
}
|
||||
|
||||
public Integer getPermanentNum() {
|
||||
return permanentNum;
|
||||
}
|
||||
|
||||
public Integer getFreezeNum() {
|
||||
return freezeNum;
|
||||
}
|
||||
|
||||
public String getLackStatus() {
|
||||
return StringUtils.isBlank(lackStatus) ? "" : StaffTransMethod.getLackSpan(lackStatus);
|
||||
}
|
||||
|
||||
public String getStaffDesc() {
|
||||
|
||||
return StringUtils.isBlank(staffDesc) ? "" : staffDesc;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.organization.mapper.staff;
|
||||
|
||||
|
||||
import com.engine.organization.entity.staff.po.StaffExportPO;
|
||||
import com.engine.organization.entity.staff.po.StaffPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
@ -68,7 +69,15 @@ public interface StaffMapper {
|
|||
|
||||
/**
|
||||
* 查询同维度的所有编制方案
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
StaffPO getStaffsByParamId(@Param("ftype") Integer ftype,@Param("compId") String compId,@Param("deptId") String deptId,@Param("jobId") String jobId);
|
||||
StaffPO getStaffsByParamId(@Param("ftype") Integer ftype, @Param("compId") String compId, @Param("deptId") String deptId, @Param("jobId") String jobId);
|
||||
|
||||
/**
|
||||
* 查询所有编制信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<StaffExportPO> getStaffExportPOs();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,4 +350,17 @@
|
|||
and a.job_id = #{jobId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getStaffExportPOs" resultType="com.engine.organization.entity.staff.po.StaffExportPO">
|
||||
select plan_id,
|
||||
comp_id,
|
||||
dept_id,
|
||||
job_id,
|
||||
staff_num,
|
||||
permanent_num,
|
||||
freeze_num,
|
||||
lack_status,
|
||||
staff_desc
|
||||
from jcl_org_staff
|
||||
where delete_type = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -15,8 +14,16 @@ public interface ExportCommonService {
|
|||
|
||||
/**
|
||||
* 人员导出
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
XSSFWorkbook resourceExport(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 编制信息导出
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
XSSFWorkbook staffExport();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ package com.engine.organization.service.impl;
|
|||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.hrmresource.vo.HrmResourceVO;
|
||||
import com.engine.organization.entity.staff.po.StaffExportPO;
|
||||
import com.engine.organization.mapper.hrmresource.HrmResourceMapper;
|
||||
import com.engine.organization.mapper.staff.StaffMapper;
|
||||
import com.engine.organization.service.ExportCommonService;
|
||||
import com.engine.organization.util.HrmI18nUtil;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
|
|
@ -25,7 +27,7 @@ public class ExportCommonServiceImpl extends Service implements ExportCommonServ
|
|||
@Override
|
||||
public XSSFWorkbook resourceExport(List<Long> ids) {
|
||||
|
||||
List<HrmResourceVO> hrmResourceVOS= MapperProxyFactory.getProxy(HrmResourceMapper.class).listAll(ids);
|
||||
List<HrmResourceVO> hrmResourceVOS = MapperProxyFactory.getProxy(HrmResourceMapper.class).listAll(ids);
|
||||
|
||||
if (hrmResourceVOS == null) {
|
||||
hrmResourceVOS = new ArrayList<>();
|
||||
|
|
@ -36,12 +38,12 @@ public class ExportCommonServiceImpl extends Service implements ExportCommonServ
|
|||
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(93270, "姓名"),
|
||||
HrmI18nUtil.getI18nLabel(93272, "部门"),
|
||||
HrmI18nUtil.getI18nLabel(93274, "分部"),
|
||||
HrmI18nUtil.getI18nLabel(93275, "移动电话"),
|
||||
HrmI18nUtil.getI18nLabel(93278, "办公室电话"),
|
||||
HrmI18nUtil.getI18nLabel(93279, "直接上级")};
|
||||
excelSheetData.add(Arrays.asList(header));
|
||||
|
||||
//数据
|
||||
|
|
@ -60,5 +62,49 @@ public class ExportCommonServiceImpl extends Service implements ExportCommonServ
|
|||
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook staffExport() {
|
||||
List<StaffExportPO> staffExportPOs = MapperProxyFactory.getProxy(StaffMapper.class).getStaffExportPOs();
|
||||
if (staffExportPOs == null) {
|
||||
staffExportPOs = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 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(93278, "在编"),
|
||||
HrmI18nUtil.getI18nLabel(93278, "冻结数"),
|
||||
HrmI18nUtil.getI18nLabel(93278, "缺编状态"),
|
||||
HrmI18nUtil.getI18nLabel(93279, "编制描述")
|
||||
};
|
||||
excelSheetData.add(Arrays.asList(header));
|
||||
|
||||
//数据
|
||||
List<List<Object>> rows = new LinkedList<>();
|
||||
for (StaffExportPO vo : staffExportPOs) {
|
||||
List<Object> row = new LinkedList<>();
|
||||
row.add(vo.getPlanId());
|
||||
row.add(vo.getCompId());
|
||||
row.add(vo.getDeptId());
|
||||
row.add(vo.getJobId());
|
||||
row.add(vo.getStaffNum());
|
||||
row.add(vo.getPermanentNum());
|
||||
row.add(vo.getFreezeNum());
|
||||
row.add(vo.getLackStatus());
|
||||
row.add(vo.getStaffDesc());
|
||||
rows.add(row);
|
||||
}
|
||||
excelSheetData.addAll(rows);
|
||||
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,28 @@ import java.util.stream.Collectors;
|
|||
public class ExportCommonController {
|
||||
|
||||
private ExportCommonWrapper getExportCommonWrapper(User user) {
|
||||
return ServiceUtil.getService(ExportCommonWrapper.class,user);
|
||||
return ServiceUtil.getService(ExportCommonWrapper.class, user);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/resource/exportStaff")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response staffExport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getExportCommonWrapper(user).staffExport();
|
||||
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
|
||||
|
|
|
|||
|
|
@ -18,10 +18,14 @@ import java.util.List;
|
|||
public class ExportCommonWrapper extends Service {
|
||||
|
||||
public ExportCommonService getExportCommonService(User user) {
|
||||
return ServiceUtil.getService(ExportCommonServiceImpl.class,user);
|
||||
return ServiceUtil.getService(ExportCommonServiceImpl.class, user);
|
||||
}
|
||||
|
||||
public XSSFWorkbook resourceExport(List<Long> ids) {
|
||||
return getExportCommonService(user).resourceExport(ids);
|
||||
}
|
||||
|
||||
public XSSFWorkbook staffExport() {
|
||||
return getExportCommonService(user).staffExport();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue