commit
e36a8623c2
Binary file not shown.
@ -0,0 +1,13 @@
|
|||||||
|
package com.api.organization.web;
|
||||||
|
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description:
|
||||||
|
* @Date 2022/6/28
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@Path("/bs/hrmorganization/common")
|
||||||
|
public class ExportCommonController extends com.engine.organization.web.ExportCommonController {
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.engine.organization.mapper.resource;
|
||||||
|
|
||||||
|
import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam;
|
||||||
|
import com.engine.organization.entity.hrmresource.po.HrmResourcePO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description:
|
||||||
|
* @Date 2022/6/28
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public interface ResourceMapper {
|
||||||
|
|
||||||
|
List<HrmResourcePO> listAll(@Param("param")HrmResourceSearchParam param);
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.engine.organization.mapper.resource.ResourceMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.engine.organization.entity.hrmresource.po.HrmResourcePO">
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 表字段 -->
|
||||||
|
<sql id="baseColumns">
|
||||||
|
id,last_name,department_id,company_id,mobile,telephone,manager_id
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="listAll" resultType="com.engine.organization.entity.hrmresource.po.HrmResourcePO">
|
||||||
|
SELECT
|
||||||
|
<include refid="baseColumns"/>
|
||||||
|
FROM jcl_org_hrmresource
|
||||||
|
where 1 = 1
|
||||||
|
<include refid="likeSql"/>
|
||||||
|
<if test="param.departmentId != null and param.departmentId != ''">
|
||||||
|
and department_id = #{param.departmentId}
|
||||||
|
</if>
|
||||||
|
<if test="param.companyId != null and param.companyId != ''">
|
||||||
|
and company_id = #{param.companyId}
|
||||||
|
</if>
|
||||||
|
<if test="param.mobile != null and param.mobile != ''">
|
||||||
|
and mobile = #{param.mobile}
|
||||||
|
</if>
|
||||||
|
<if test="param.telephone != null and param.telephone != ''">
|
||||||
|
and telephone = #{param.telephone}
|
||||||
|
</if>
|
||||||
|
<if test="param.managerId != null and param.managerId != ''">
|
||||||
|
and manager_id = #{param.managerId}
|
||||||
|
</if>
|
||||||
|
<if test="param.mobileCall != null and param.mobileCall != ''">
|
||||||
|
and mobile_call = #{param.mobileCall}
|
||||||
|
</if>
|
||||||
|
<if test="param.jobTitle != null and param.jobTitle != ''">
|
||||||
|
and job_title = #{param.jobTitle}
|
||||||
|
</if>
|
||||||
|
order by id asc;
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<sql id="likeSql">
|
||||||
|
<if test="param.lastName != null and param.lastName != ''">
|
||||||
|
AND last_name like CONCAT('%',#{param.lastName},'%')
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
<sql id="likeSql" databaseId="oracle">
|
||||||
|
<if test="param.lastName != null and param.lastName != ''">
|
||||||
|
AND last_name like '%'||#{param.lastName}||'%'
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
<sql id="likeSql" databaseId="sqlserver">
|
||||||
|
<if test="param.lastName != null and param.lastName != ''">
|
||||||
|
AND last_name like '%'+#{param.lastName}+'%'
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
@ -1,4 +1,4 @@
|
|||||||
package com.engine.organization.mapper.SISLog;
|
package com.engine.organization.mapper.sislog;
|
||||||
|
|
||||||
import com.engine.organization.entity.LoggerContext;
|
import com.engine.organization.entity.LoggerContext;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.engine.organization.mapper.SISLog.SISLogMapper">
|
<mapper namespace="com.engine.organization.mapper.sislog.SISLogMapper">
|
||||||
<resultMap id="BaseResultMap" type="com.engine.organization.entity.LoggerContext">
|
<resultMap id="BaseResultMap" type="com.engine.organization.entity.LoggerContext">
|
||||||
<!--<result column="id" property="id"/>-->
|
<!--<result column="id" property="id"/>-->
|
||||||
<!--<result column="operate_desc" property="operateDesc"/>-->
|
<!--<result column="operate_desc" property="operateDesc"/>-->
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.engine.organization.service;
|
||||||
|
|
||||||
|
import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description:
|
||||||
|
* @Date 2022/6/28
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public interface ExportCommonService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员导出
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
XSSFWorkbook resourceExport(HrmResourceSearchParam param);
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.engine.organization.service.impl;
|
||||||
|
|
||||||
|
import com.engine.core.impl.Service;
|
||||||
|
import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam;
|
||||||
|
import com.engine.organization.entity.hrmresource.po.HrmResourcePO;
|
||||||
|
import com.engine.organization.mapper.resource.ResourceMapper;
|
||||||
|
import com.engine.organization.service.ExportCommonService;
|
||||||
|
import com.engine.organization.util.HrmI18nUtil;
|
||||||
|
import com.engine.organization.util.db.MapperProxyFactory;
|
||||||
|
import com.engine.salary.util.excel.ExcelUtil;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description:
|
||||||
|
* @Date 2022/6/28
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public class ExportCommonServiceImpl extends Service implements ExportCommonService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XSSFWorkbook resourceExport(HrmResourceSearchParam param) {
|
||||||
|
|
||||||
|
param.setPageSize(null);
|
||||||
|
param.setCurrent(null);
|
||||||
|
List<HrmResourcePO> hrmResourcePOS = MapperProxyFactory.getProxy(ResourceMapper.class).listAll(param);
|
||||||
|
if (hrmResourcePOS == null) {
|
||||||
|
hrmResourcePOS = 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( 93273, "公积金人数"),
|
||||||
|
HrmI18nUtil.getI18nLabel( 93274, "分部"),
|
||||||
|
HrmI18nUtil.getI18nLabel( 93275, "移动电话"),
|
||||||
|
HrmI18nUtil.getI18nLabel( 93278, "办公室电话"),
|
||||||
|
HrmI18nUtil.getI18nLabel( 93279, "直接上级")};
|
||||||
|
excelSheetData.add(Arrays.asList(new Object[]{header}));
|
||||||
|
|
||||||
|
//工作簿数据
|
||||||
|
List<List<Object>> rows = new LinkedList<>();
|
||||||
|
for (HrmResourcePO po : hrmResourcePOS) {
|
||||||
|
List<Object> row = new LinkedList<>();
|
||||||
|
row.add(po.getLastName());
|
||||||
|
row.add(po.getDepartmentId());
|
||||||
|
row.add(po.getCompanyId());
|
||||||
|
row.add(po.getMobile());
|
||||||
|
row.add(po.getTelephone());
|
||||||
|
row.add(po.getManagerId());
|
||||||
|
rows.add(row);
|
||||||
|
}
|
||||||
|
excelSheetData.addAll(rows);
|
||||||
|
return ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
package com.engine.organization.web;
|
||||||
|
|
||||||
|
import com.alipay.oceanbase.jdbc.StringUtils;
|
||||||
|
import com.engine.common.util.ServiceUtil;
|
||||||
|
import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam;
|
||||||
|
import com.engine.organization.wrapper.ExportCommonWrapper;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
import org.ietf.jgss.GSSContext;
|
||||||
|
import weaver.hrm.HrmUserVarify;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.Context;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.StreamingOutput;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description:
|
||||||
|
* @Date 2022/6/28
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public class ExportCommonController {
|
||||||
|
|
||||||
|
private ExportCommonWrapper getExportCommonWrapper(User user) {
|
||||||
|
return ServiceUtil.getService(ExportCommonWrapper.class,user);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/resource/export")
|
||||||
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
public Response resourceExport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||||
|
HrmResourceSearchParam param = buildResourceParam(request);
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
XSSFWorkbook workbook = getExportCommonWrapper(user).resourceExport(param);
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private HrmResourceSearchParam buildResourceParam(HttpServletRequest request) {
|
||||||
|
HrmResourceSearchParam param = new HrmResourceSearchParam();
|
||||||
|
String lastName = request.getParameter("lastName");
|
||||||
|
if (StringUtils.isNotBlank(lastName)){
|
||||||
|
param.setLastName(lastName);
|
||||||
|
}
|
||||||
|
String managerId = request.getParameter("managerId");
|
||||||
|
if (StringUtils.isNotBlank(managerId)){
|
||||||
|
param.setManagerId(Long.valueOf(managerId));
|
||||||
|
}
|
||||||
|
String companyId = request.getParameter("companyId");
|
||||||
|
if (StringUtils.isNotBlank(companyId)){
|
||||||
|
param.setCompanyId(Long.valueOf(companyId));
|
||||||
|
}
|
||||||
|
String departmentId = request.getParameter("departmentId");
|
||||||
|
if (StringUtils.isNotBlank(departmentId)){
|
||||||
|
param.setDepartmentId(Long.valueOf(departmentId));
|
||||||
|
}
|
||||||
|
String mobile = request.getParameter("mobile");
|
||||||
|
if (StringUtils.isNotBlank(mobile)){
|
||||||
|
param.setMobile(mobile);
|
||||||
|
}
|
||||||
|
String telephone = request.getParameter("telephone");
|
||||||
|
if (StringUtils.isNotBlank(telephone)){
|
||||||
|
param.setTelephone(telephone);
|
||||||
|
}
|
||||||
|
String mobileCall = request.getParameter("mobileCall");
|
||||||
|
if (StringUtils.isNotBlank(mobileCall)){
|
||||||
|
param.setMobileCall(mobileCall);
|
||||||
|
}
|
||||||
|
String jobTitle = request.getParameter("jobTitle");
|
||||||
|
if (StringUtils.isNotBlank(jobTitle)){
|
||||||
|
param.setJobTitle(Long.valueOf(jobTitle));
|
||||||
|
}
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.engine.organization.wrapper;
|
||||||
|
|
||||||
|
import com.engine.common.util.ServiceUtil;
|
||||||
|
import com.engine.core.impl.Service;
|
||||||
|
import com.engine.organization.entity.hrmresource.param.HrmResourceSearchParam;
|
||||||
|
import com.engine.organization.service.ExportCommonService;
|
||||||
|
import com.engine.organization.service.impl.ExportCommonServiceImpl;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description:
|
||||||
|
* @Date 2022/6/28
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public class ExportCommonWrapper extends Service {
|
||||||
|
|
||||||
|
public ExportCommonService getExportCommonService(User user) {
|
||||||
|
return ServiceUtil.getService(ExportCommonServiceImpl.class,user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public XSSFWorkbook resourceExport(HrmResourceSearchParam param) {
|
||||||
|
return getExportCommonService(user).resourceExport(param);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue