2023-03-01 09:05:03 +08:00
|
|
|
package com.engine.salary.web;
|
|
|
|
|
|
2023-03-03 14:40:17 +08:00
|
|
|
import com.engine.common.util.ServiceUtil;
|
2025-03-24 14:57:00 +08:00
|
|
|
import com.engine.salary.entity.extemp.dto.ExtEmpDTO;
|
2023-07-27 09:39:03 +08:00
|
|
|
import com.engine.salary.entity.extemp.param.ExtEmpImportParam;
|
2023-03-03 14:40:17 +08:00
|
|
|
import com.engine.salary.entity.extemp.param.ExtEmpQueryParam;
|
|
|
|
|
import com.engine.salary.entity.extemp.param.ExtEmpSaveParam;
|
|
|
|
|
import com.engine.salary.entity.extemp.po.ExtEmpPO;
|
|
|
|
|
import com.engine.salary.util.ResponseResult;
|
2023-07-27 09:39:03 +08:00
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2023-03-03 16:57:52 +08:00
|
|
|
import com.engine.salary.util.page.PageInfo;
|
2023-03-03 14:40:17 +08:00
|
|
|
import com.engine.salary.wrapper.ExtEmpWrapper;
|
|
|
|
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
2023-07-27 09:39:03 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2023-03-03 14:40:17 +08:00
|
|
|
import weaver.hrm.HrmUserVarify;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
2023-03-13 16:04:19 +08:00
|
|
|
import javax.ws.rs.*;
|
2023-03-03 14:40:17 +08:00
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
2023-07-27 09:39:03 +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-03-03 14:40:17 +08:00
|
|
|
import java.util.Collection;
|
2023-07-27 09:39:03 +08:00
|
|
|
import java.util.Map;
|
2023-03-03 14:40:17 +08:00
|
|
|
|
2023-03-01 09:05:03 +08:00
|
|
|
/**
|
2023-03-03 14:40:17 +08:00
|
|
|
* 外部人员
|
2023-03-01 09:05:03 +08:00
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
*
|
|
|
|
|
* @author qiantao
|
|
|
|
|
* @version 1.0
|
|
|
|
|
**/
|
2023-07-27 09:39:03 +08:00
|
|
|
@Slf4j
|
2023-03-01 09:05:03 +08:00
|
|
|
public class ExtEmpController {
|
|
|
|
|
|
2023-03-03 14:40:17 +08:00
|
|
|
private ExtEmpWrapper getExtEmpWrapper(User user) {
|
|
|
|
|
return ServiceUtil.getService(ExtEmpWrapper.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
2023-03-03 16:57:52 +08:00
|
|
|
@Path("/listPage")
|
2023-03-03 14:40:17 +08:00
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtEmpQueryParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
2025-03-24 14:57:00 +08:00
|
|
|
return new ResponseResult<ExtEmpQueryParam, PageInfo<ExtEmpDTO>>(user).run(getExtEmpWrapper(user)::listPage, param);
|
2023-03-03 14:40:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/save")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtEmpSaveParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<ExtEmpSaveParam, String>(user).run(getExtEmpWrapper(user)::save, param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/update")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String update(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtEmpSaveParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<ExtEmpSaveParam, String>(user).run(getExtEmpWrapper(user)::update, param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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>, String>(user).run(getExtEmpWrapper(user)::delete, ids);
|
|
|
|
|
}
|
2023-03-01 09:05:03 +08:00
|
|
|
|
2023-03-13 16:04:19 +08:00
|
|
|
@GET
|
|
|
|
|
@Path("/detail")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String save(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<Long, ExtEmpPO>(user).run(getExtEmpWrapper(user)::detail, id);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-27 09:39:03 +08:00
|
|
|
// **********************************非系统人员导入 start*********************************/
|
|
|
|
|
//导出导入模板
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/importtemplate/export")
|
|
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
public Response exportImportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
|
try {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
XSSFWorkbook workbook = getExtEmpWrapper(user).exportImportTemplate();
|
|
|
|
|
String time = LocalDate.now().toString();
|
|
|
|
|
String fileName = SalaryI18nUtil.getI18nLabel(0, "非系统人员导入模板") + time;
|
|
|
|
|
try {
|
|
|
|
|
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8").replaceAll("\\+", "%20");
|
|
|
|
|
} 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-03-13 16:04:19 +08:00
|
|
|
|
2023-07-27 09:39:03 +08:00
|
|
|
}
|
2023-03-01 09:05:03 +08:00
|
|
|
|
2023-07-27 09:39:03 +08:00
|
|
|
//导入非系统人员
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/importExtEmp")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String importExtEmp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtEmpImportParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<ExtEmpImportParam, Map<String, Object>>(user).run(getExtEmpWrapper(user)::importExtEmp, param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/preview")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String previewImportExtEmp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ExtEmpImportParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<ExtEmpImportParam, Map<String, Object>>(user).run(getExtEmpWrapper(user)::previewImportExtEmp, param);
|
|
|
|
|
}
|
|
|
|
|
// **********************************非系统人员导入 end*********************************/
|
2023-03-01 09:05:03 +08:00
|
|
|
}
|