2023-04-10 09:47:33 +08:00
|
|
|
package com.engine.salary.report.web;
|
|
|
|
|
|
2023-04-11 09:22:09 +08:00
|
|
|
import com.engine.common.util.ServiceUtil;
|
2023-06-07 15:43:23 +08:00
|
|
|
import com.engine.salary.report.entity.param.*;
|
2023-04-10 12:43:48 +08:00
|
|
|
import com.engine.salary.report.wrapper.SalaryStatisticsReportWrapper;
|
2023-04-11 09:22:09 +08:00
|
|
|
import com.engine.salary.util.ResponseResult;
|
|
|
|
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
2023-04-24 16:34:23 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2023-09-21 09:38:38 +08:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2023-04-24 16:34:23 +08:00
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2023-04-11 09:22:09 +08:00
|
|
|
import weaver.hrm.HrmUserVarify;
|
|
|
|
|
import weaver.hrm.User;
|
2023-04-10 09:47:33 +08:00
|
|
|
|
2023-04-11 09:22:09 +08:00
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.ws.rs.*;
|
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
2023-04-24 16:34:23 +08:00
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
import javax.ws.rs.core.StreamingOutput;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.time.LocalDate;
|
2023-04-10 09:47:33 +08:00
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-04-23 10:14:32 +08:00
|
|
|
* 薪酬统计报表
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
*
|
|
|
|
|
* @author qiantao
|
|
|
|
|
* @version 1.0
|
|
|
|
|
**/
|
2023-04-24 16:34:23 +08:00
|
|
|
@Slf4j
|
2023-04-10 09:47:33 +08:00
|
|
|
public class SalaryStatisticsReportController {
|
|
|
|
|
|
2023-04-11 09:22:09 +08:00
|
|
|
private SalaryStatisticsReportWrapper getSalaryStatisticsReportWrapper(User user) {
|
|
|
|
|
return ServiceUtil.getService(SalaryStatisticsReportWrapper.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 薪酬统计报表列表
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-04-11 09:22:09 +08:00
|
|
|
@POST
|
|
|
|
|
@Path("/list")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsReportQueryParam queryParam) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<SalaryStatisticsReportQueryParam, List<Map<String, Object>>>(user).run(getSalaryStatisticsReportWrapper(user)::list, queryParam);
|
2023-04-10 09:47:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取薪酬统计报表表单
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-04-11 09:22:09 +08:00
|
|
|
@GET
|
|
|
|
|
@Path("/getForm")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
2023-04-23 10:14:32 +08:00
|
|
|
return new ResponseResult<Long, Map<String, Object>>(user).run(getSalaryStatisticsReportWrapper(user)::getFrom, id);
|
2023-04-10 09:47:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存薪酬统计报表
|
|
|
|
|
*
|
2023-04-11 09:22:09 +08:00
|
|
|
* @param param
|
2023-04-10 09:47:33 +08:00
|
|
|
* @return
|
|
|
|
|
*/
|
2023-04-11 09:22:09 +08:00
|
|
|
@POST
|
|
|
|
|
@Path("/save")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsReportSaveParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<SalaryStatisticsReportSaveParam, String>(user).run(getSalaryStatisticsReportWrapper(user)::save, param);
|
2023-04-10 09:47:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除薪酬统计报表
|
|
|
|
|
*
|
|
|
|
|
* @param ids
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-04-11 09:22:09 +08:00
|
|
|
@POST
|
|
|
|
|
@Path("/delete")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection<Long> ids) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<Collection<Long>, Map<String, Object>>(user).run(getSalaryStatisticsReportWrapper(user)::delete, ids);
|
2023-04-10 09:47:33 +08:00
|
|
|
}
|
|
|
|
|
|
2023-11-07 15:55:03 +08:00
|
|
|
/**
|
|
|
|
|
* 复制薪酬统计报表
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/duplicate")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String duplicate(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<Long, String>(user).run(getSalaryStatisticsReportWrapper(user)::duplicate, id);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-23 10:14:32 +08:00
|
|
|
/**
|
|
|
|
|
* 获取薪酬统计报表查询条件
|
|
|
|
|
*
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getSearchCondition")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<Long, Map<String, Object>>(user).run(getSalaryStatisticsReportWrapper(user)::getSearchCondition, id);
|
|
|
|
|
}
|
2023-04-10 09:47:33 +08:00
|
|
|
|
2023-04-23 10:14:32 +08:00
|
|
|
/**
|
|
|
|
|
* 保存薪酬统计报表查询条件
|
|
|
|
|
*
|
|
|
|
|
* @param param
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/saveSearchCondition")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String saveSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsSearchConditionSaveParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<SalaryStatisticsSearchConditionSaveParam, String>(user).run(getSalaryStatisticsReportWrapper(user)::saveSearchCondition, param);
|
|
|
|
|
}
|
2023-04-10 09:47:33 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取薪酬统计报表数据
|
|
|
|
|
*
|
|
|
|
|
* @param param
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-04-11 09:22:09 +08:00
|
|
|
@POST
|
|
|
|
|
@Path("/getData")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
2023-04-18 18:55:38 +08:00
|
|
|
public String getData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsReportDataQueryParam param) {
|
2023-04-11 09:22:09 +08:00
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<SalaryStatisticsReportDataQueryParam, Map<String, Object>>(user).run(getSalaryStatisticsReportWrapper(user)::getData, param);
|
2023-04-10 09:47:33 +08:00
|
|
|
}
|
|
|
|
|
|
2023-04-24 16:34:23 +08:00
|
|
|
/**
|
|
|
|
|
* 导出报表数据
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-04-24 18:08:06 +08:00
|
|
|
@GET
|
|
|
|
|
@Path("/exportData")
|
2023-04-24 16:34:23 +08:00
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
2023-04-24 18:08:06 +08:00
|
|
|
public Response exportData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
|
SalaryStatisticsReportDataQueryParam param = SalaryStatisticsReportDataQueryParam.builder()
|
|
|
|
|
.id(Long.parseLong(request.getParameter("id")))
|
|
|
|
|
.dimensionId(Long.parseLong(request.getParameter("dimensionId")))
|
2023-11-09 16:14:35 +08:00
|
|
|
.salaryStartMonth(request.getParameter("salaryStartMonth"))
|
|
|
|
|
.salaryEndMonth(request.getParameter("salaryEndMonth"))
|
2023-09-21 09:38:38 +08:00
|
|
|
.isShare(StringUtils.equals(request.getParameter("isShare"), "true"))
|
2023-04-24 18:08:06 +08:00
|
|
|
.build();
|
2023-04-24 16:34:23 +08:00
|
|
|
try {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
Map<String, Object> map = getSalaryStatisticsReportWrapper(user).exportData(param);
|
|
|
|
|
XSSFWorkbook workbook = (XSSFWorkbook) map.get("workbook");
|
|
|
|
|
String time = LocalDate.now().toString();
|
|
|
|
|
String fileName = map.get("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();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("核算人员范围导出异常", e);
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-07 15:43:23 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取报表的透视数据信息
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-06-08 10:24:28 +08:00
|
|
|
@POST
|
2023-06-07 15:43:23 +08:00
|
|
|
@Path("/getDataPerspective")
|
|
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
public String getDataPerspective(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryStatisticsDataPerspectiveQueryParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<SalaryStatisticsDataPerspectiveQueryParam, Map<String, Object>>(user).run(getSalaryStatisticsReportWrapper(user)::getDataPerspective, param);
|
|
|
|
|
}
|
2023-04-10 09:47:33 +08:00
|
|
|
}
|