2022-03-11 11:08:50 +08:00
|
|
|
package com.engine.salary.web;
|
|
|
|
|
|
|
|
|
|
import com.engine.common.util.ParamUtil;
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
2022-03-15 09:55:58 +08:00
|
|
|
import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldSettingListDTO;
|
|
|
|
|
import com.engine.salary.entity.datacollection.param.*;
|
|
|
|
|
import com.engine.salary.entity.datacollection.po.AttendQuoteFieldPO;
|
2022-03-16 14:29:02 +08:00
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-03-15 14:18:04 +08:00
|
|
|
import com.engine.salary.service.AttendQuoteDataService;
|
2022-03-15 09:55:58 +08:00
|
|
|
import com.engine.salary.service.AttendQuoteFieldService;
|
|
|
|
|
import com.engine.salary.service.AttendQuoteFieldSettingService;
|
2022-03-11 11:08:50 +08:00
|
|
|
import com.engine.salary.service.AttendQuoteService;
|
2022-03-15 14:18:04 +08:00
|
|
|
import com.engine.salary.service.impl.AttendQuoteDataServiceImpl;
|
2022-03-15 09:55:58 +08:00
|
|
|
import com.engine.salary.service.impl.AttendQuoteFieldServiceImpl;
|
|
|
|
|
import com.engine.salary.service.impl.AttendQuoteFieldSettingServiceImpl;
|
2022-03-11 11:08:50 +08:00
|
|
|
import com.engine.salary.service.impl.AttendQuoteServiceImpl;
|
|
|
|
|
import com.engine.salary.util.ResponseResult;
|
2022-03-16 14:29:02 +08:00
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2022-03-11 11:08:50 +08:00
|
|
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
2022-03-15 09:55:58 +08:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-03-16 14:29:02 +08:00
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2022-03-11 11:08:50 +08:00
|
|
|
import weaver.hrm.HrmUserVarify;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.ws.rs.GET;
|
2022-03-15 09:55:58 +08:00
|
|
|
import javax.ws.rs.POST;
|
2022-03-11 11:08:50 +08:00
|
|
|
import javax.ws.rs.Path;
|
|
|
|
|
import javax.ws.rs.Produces;
|
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
2022-03-16 14:29:02 +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.YearMonth;
|
2022-03-15 09:55:58 +08:00
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
2022-03-11 11:08:50 +08:00
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
public class AttendQuoteController {
|
|
|
|
|
|
|
|
|
|
private AttendQuoteService getService(User user) {
|
|
|
|
|
return (AttendQuoteService) ServiceUtil.getService(AttendQuoteServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 14:18:04 +08:00
|
|
|
private AttendQuoteDataService getDataService(User user) {
|
|
|
|
|
return (AttendQuoteDataService) ServiceUtil.getService(AttendQuoteDataServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 09:55:58 +08:00
|
|
|
private AttendQuoteFieldService getFieldService(User user) {
|
|
|
|
|
return (AttendQuoteFieldService) ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private AttendQuoteFieldSettingService getFieldSettingService(User user) {
|
|
|
|
|
return (AttendQuoteFieldSettingService) ServiceUtil.getService(AttendQuoteFieldSettingServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-11 11:08:50 +08:00
|
|
|
/**
|
|
|
|
|
* 考勤数据列表
|
|
|
|
|
*/
|
2022-03-15 09:55:58 +08:00
|
|
|
@POST
|
2022-03-11 11:08:50 +08:00
|
|
|
@Path("/list")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteQueryParam queryParam) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
Map<String, Object> map = ParamUtil.request2Map(request);
|
|
|
|
|
map.put("queryParam", queryParam);
|
|
|
|
|
return ResponseResult.run(getService(user)::list, map);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-11 15:47:08 +08:00
|
|
|
|
2022-03-16 14:29:02 +08:00
|
|
|
/**
|
|
|
|
|
* 获取引用考勤表单
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
// @GET
|
|
|
|
|
// @Path("/getSyncForm")
|
|
|
|
|
// @Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
// public String getSyncForm(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
|
// User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
// return new ResponseResult<Long, Map<String, Object>>().run(getService(user)::getSyncForm, (long)user.getUID());
|
2022-03-11 15:47:08 +08:00
|
|
|
// }
|
2022-03-16 14:29:02 +08:00
|
|
|
|
|
|
|
|
|
2022-03-11 15:47:08 +08:00
|
|
|
// /**
|
|
|
|
|
// * 获取薪资周期和考勤周期
|
|
|
|
|
// * @param salaryYearMonth 薪资所属月
|
|
|
|
|
// * @param salarySobId 薪资账套id
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// @PostMapping("/getSalaryCycleAndAttendCycle")
|
|
|
|
|
// @ApiOperation("获取薪资周期和考勤周期")
|
|
|
|
|
// @WeaPermission
|
|
|
|
|
// public WeaResult<Map<String, Object>> getSalaryCycleAndAttendCycle(@RequestParam(value = "salaryYearMonth") YearMonth salaryYearMonth, @RequestParam(value = "salarySobId") Long salarySobId) {
|
|
|
|
|
// return WeaResult.success(service.getSalaryCycleAndAttendCycle(salaryYearMonth, salarySobId, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
|
|
|
|
|
// }
|
|
|
|
|
//
|
2022-03-16 14:29:02 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 同步引用考勤数据
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/syncAttendQuoteData")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String syncAttendQuoteData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteDataSyncParam syncParam) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<AttendQuoteDataSyncParam, String>().run(getDataService(user)::syncAttendQuoteData, syncParam);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-11 15:47:08 +08:00
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * 获取薪资账套下拉列表
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// @GetMapping("/selectSalarySobList")
|
|
|
|
|
// @ApiOperation("获取薪资账套下拉列表")
|
|
|
|
|
// @WeaPermission
|
|
|
|
|
// public WeaResult<List<Map<String, Object>>> selectSalarySobList() {
|
|
|
|
|
// return WeaResult.success(service.selectSalarySobList(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
|
|
|
|
|
// }
|
|
|
|
|
//
|
2022-03-16 14:29:02 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 下载导入模板
|
|
|
|
|
*/
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/downloadTemplate")
|
|
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
public Response downloadTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
String salaryYearMonth = request.getParameter("salaryYearMonth");
|
|
|
|
|
String salarySobId = request.getParameter("salarySobId");
|
|
|
|
|
AttendQuoteDataExportTemplateParam param = AttendQuoteDataExportTemplateParam.builder()
|
|
|
|
|
.salarySobId(Long.valueOf(salarySobId))
|
|
|
|
|
.salaryYearMonth(YearMonth.parse(salaryYearMonth))
|
|
|
|
|
.build();
|
|
|
|
|
if (param.getSalaryYearMonth() == null || param.getSalarySobId() == null) {
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100250, "薪资所属月和薪资账套id不能为空"));
|
|
|
|
|
}
|
|
|
|
|
XSSFWorkbook workbook = getDataService(user).downloadTemplate(param);
|
|
|
|
|
String fileName = null;
|
|
|
|
|
try {
|
|
|
|
|
fileName = URLEncoder.encode("考勤引用导入模板.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();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 14:18:04 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查看考勤数据
|
|
|
|
|
*
|
|
|
|
|
* @param queryParam
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/view")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String view(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteDataQueryParam queryParam) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<AttendQuoteDataQueryParam, Map<String, Object>>().run(getDataService(user)::view, queryParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除考勤数据
|
|
|
|
|
*
|
|
|
|
|
* @param ids
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@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>().run(getService(user)::delete, ids);
|
|
|
|
|
}
|
2022-03-16 14:29:02 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出考勤数据
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/export")
|
|
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
String attendQuoteId = request.getParameter("attendQuoteId");
|
|
|
|
|
AttendQuoteDataQueryParam param = AttendQuoteDataQueryParam.builder().attendQuoteId(Long.valueOf(attendQuoteId)).build();
|
|
|
|
|
XSSFWorkbook workbook = getDataService(user).export(param);
|
|
|
|
|
String fileName = null;
|
|
|
|
|
try {
|
|
|
|
|
fileName = URLEncoder.encode("考勤导出.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();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 09:55:58 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 考勤字段管理列表
|
|
|
|
|
*
|
|
|
|
|
* @param queryParam
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/fieldList")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String fieldList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldQueryParam queryParam) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
Map<String, Object> map = ParamUtil.request2Map(request);
|
|
|
|
|
map.put("queryParam", queryParam);
|
|
|
|
|
return new ResponseResult<AttendQuoteFieldQueryParam, Map<String, Object>>().run(getFieldService(user)::list, queryParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 同步考勤模块字段
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/syncAttendFields")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String syncAttendFields(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<Long, String>().run(getFieldService(user)::syncAttendFields, (long) user.getUID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取考勤字段表单
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getFieldForm")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String getFieldForm(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
String idStr = request.getParameter("id");
|
|
|
|
|
Long id = null;
|
|
|
|
|
if (StringUtils.isNotBlank(idStr)) {
|
|
|
|
|
id = Long.parseLong(request.getParameter("id"));
|
|
|
|
|
}
|
|
|
|
|
return new ResponseResult<Long, AttendQuoteFieldPO>().run(getFieldService(user)::getFrom, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新建考勤字段
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/saveField")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String saveField(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSaveParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<AttendQuoteFieldSaveParam, String>().run(getFieldService(user)::save, param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改考勤字段
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/updateField")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String updateField(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSaveParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<AttendQuoteFieldSaveParam, String>().run(getFieldService(user)::update, param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除考勤字段
|
|
|
|
|
*
|
|
|
|
|
* @param ids
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/deleteField")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String deleteField(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection<Long> ids) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<Collection<Long>, String>().run(getFieldService(user)::delete, ids);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 启用/停用自定义字段
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/updateEnableStatus")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String updateEnableStatus(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSaveParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<AttendQuoteFieldSaveParam, String>().run(getFieldService(user)::updateEnableStatus, param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 数据采集-考勤引用字段设置列表
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/fieldSetting/list")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String fieldSettingList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSettingQueryParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<AttendQuoteFieldSettingQueryParam, List<AttendQuoteFieldSettingListDTO>>().run(getFieldSettingService(user)::list, param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 数据采集-考勤引用字段设置保存
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/fieldSetting/save")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String fieldSettingSave(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSettingSaveParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<AttendQuoteFieldSettingSaveParam, String>().run(getFieldSettingService(user)::save, param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 数据采集-考勤引用字段设置-恢复默认设置
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/fieldSetting/recoverAsDefault")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String fieldSettingRecoverAsDefault(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSettingRecoverParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<AttendQuoteFieldSettingRecoverParam, List<AttendQuoteFieldSettingListDTO>>().run(getFieldSettingService(user)::recoverAsDefault, param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 数据采集-考勤引用字段设置-设为默认设置
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/fieldSetting/saveAsDefault")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String fieldSettingSaveAsDefault(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AttendQuoteFieldSettingSaveParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<AttendQuoteFieldSettingSaveParam, String>().run(getFieldSettingService(user)::saveAsDefault, param);
|
|
|
|
|
}
|
2022-03-11 15:47:08 +08:00
|
|
|
|
2022-03-11 11:08:50 +08:00
|
|
|
}
|