2022-03-07 22:22:09 +08:00
|
|
|
package com.engine.salary.web;
|
|
|
|
|
|
|
|
|
|
import com.engine.common.util.ParamUtil;
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
2022-05-09 11:18:54 +08:00
|
|
|
import com.engine.salary.entity.datacollection.param.AttendQuoteDataImportParam;
|
|
|
|
|
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
|
2022-05-06 16:58:01 +08:00
|
|
|
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
|
2022-04-22 15:17:31 +08:00
|
|
|
import com.engine.salary.entity.sischeme.dto.InsuranceSchemeListDTO;
|
|
|
|
|
import com.engine.salary.entity.sischeme.param.InsuranceSchemeParam;
|
2022-03-09 09:42:10 +08:00
|
|
|
import com.engine.salary.entity.sischeme.param.InsuranceSchemeReqParam;
|
2022-05-09 11:18:54 +08:00
|
|
|
import com.engine.salary.entity.sischeme.param.SISchemaImportParam;
|
2022-03-11 14:28:39 +08:00
|
|
|
import com.engine.salary.enums.sicategory.WelfareTypeEnum;
|
2022-05-09 11:18:54 +08:00
|
|
|
import com.engine.salary.mapper.siaccount.InsuranceAccountDetailMapper;
|
|
|
|
|
import com.engine.salary.service.SIAccountService;
|
2022-03-07 22:22:09 +08:00
|
|
|
import com.engine.salary.service.SISchemeService;
|
2022-05-09 11:18:54 +08:00
|
|
|
import com.engine.salary.service.impl.SIAccountServiceImpl;
|
2022-03-07 22:22:09 +08:00
|
|
|
import com.engine.salary.service.impl.SISchemeServiceImpl;
|
|
|
|
|
import com.engine.salary.util.ResponseResult;
|
2022-04-22 15:17:31 +08:00
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
import com.engine.salary.wrapper.SISchemeWrapper;
|
2022-05-06 16:58:01 +08:00
|
|
|
import com.wbi.util.Util;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
2022-03-09 09:42:10 +08:00
|
|
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
2022-05-06 16:58:01 +08:00
|
|
|
import org.apache.axis2.wsdl.codegen.writer.CBuildScriptWriter;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2022-03-07 22:22:09 +08:00
|
|
|
import weaver.hrm.HrmUserVarify;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
2022-03-09 09:42:10 +08:00
|
|
|
import javax.ws.rs.*;
|
2022-03-07 22:22:09 +08:00
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
2022-05-06 16:58:01 +08:00
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
import javax.ws.rs.core.StreamingOutput;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
2022-03-07 22:22:09 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author weaver_cl
|
2022-03-09 09:42:10 +08:00
|
|
|
* @Description: TODO 社保方案控制器
|
2022-03-07 22:22:09 +08:00
|
|
|
* @Date 2022/3/7
|
|
|
|
|
* @Version V1.0
|
|
|
|
|
**/
|
|
|
|
|
public class SISchemeController {
|
|
|
|
|
|
|
|
|
|
private SISchemeService getService(User user) {
|
|
|
|
|
return ServiceUtil.getService(SISchemeServiceImpl.class,user);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 15:17:31 +08:00
|
|
|
private SISchemeWrapper getSISchemeWrapper(User user) {
|
|
|
|
|
|
|
|
|
|
return ServiceUtil.getService(SISchemeWrapper.class,user);
|
|
|
|
|
}
|
2022-03-07 22:22:09 +08:00
|
|
|
|
2022-05-09 11:18:54 +08:00
|
|
|
private SIAccountService getSIAccountService(User user) {
|
|
|
|
|
return ServiceUtil.getService(SIAccountServiceImpl.class, user);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-07 22:22:09 +08:00
|
|
|
/**
|
|
|
|
|
* 查询福利方案表单
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getForm")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
2022-03-15 09:34:53 +08:00
|
|
|
public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
|
|
|
|
@DefaultValue("SOCIAL_SECURITY") @QueryParam(value = "welfareTypeEnum") WelfareTypeEnum welfareTypeEnum) {
|
2022-03-07 22:22:09 +08:00
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
2022-03-15 09:34:53 +08:00
|
|
|
Map<String, Object> map = ParamUtil.request2Map(request);
|
|
|
|
|
//InsuranceSchemeDTO insuranceSchemeDTO = InsuranceSchemeDTO.builder().welfareType(welfareTypeEnum).build();
|
|
|
|
|
map.put("welfareTypeEnum",welfareTypeEnum);
|
2022-05-05 10:35:58 +08:00
|
|
|
return new ResponseResult< Map<String, Object>, Map<String, Object>>(user).run(getService(user)::getForm,map);
|
2022-03-07 22:22:09 +08:00
|
|
|
}
|
2022-03-09 09:42:10 +08:00
|
|
|
|
|
|
|
|
|
2022-03-10 18:23:31 +08:00
|
|
|
/**
|
|
|
|
|
* 查询福利方案列表
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-04-22 15:17:31 +08:00
|
|
|
// @GET
|
|
|
|
|
// @Path("/getTable")
|
|
|
|
|
// @Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
// public String getTable(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
|
|
|
|
// @QueryParam("searchCondition") String searchCondition, @QueryParam("welfareTypeEnum") WelfareTypeEnum welfareTypeEnum ) {
|
|
|
|
|
// User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
// InsuranceSchemeDTO insuranceSchemeDTO = InsuranceSchemeDTO.builder().welfareType(welfareTypeEnum).build();
|
|
|
|
|
// Integer welfareType = insuranceSchemeDTO.getWelfareType().getValue();
|
|
|
|
|
// Map<String, Object> map = ParamUtil.request2Map(request);
|
|
|
|
|
// map.put("searchCondition",searchCondition);
|
|
|
|
|
// map.put("welfareType",welfareType);
|
|
|
|
|
// return ResponseResult.run(getService(user)::listPage, map);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@POST
|
2022-03-10 18:23:31 +08:00
|
|
|
@Path("/getTable")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
2022-04-22 15:17:31 +08:00
|
|
|
public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceSchemeParam insuranceSchemeParam) {
|
2022-03-10 18:23:31 +08:00
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
2022-04-25 18:06:09 +08:00
|
|
|
return new ResponseResult<InsuranceSchemeParam, PageInfo<InsuranceSchemeListDTO>>(user).run(getSISchemeWrapper(user)::listPage, insuranceSchemeParam);
|
2022-03-10 18:23:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-03-09 09:42:10 +08:00
|
|
|
/**
|
|
|
|
|
* 新增
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/insert")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
2022-03-09 16:12:47 +08:00
|
|
|
public String insertScheme(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceSchemeReqParam insuranceSchemeReqParam) {
|
2022-03-09 09:42:10 +08:00
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
Map<String, Object> map = ParamUtil.request2Map(request);
|
|
|
|
|
map.put("insuranceSchemeReqParam",insuranceSchemeReqParam);
|
2022-05-05 10:35:58 +08:00
|
|
|
return new ResponseResult< Map<String, Object>, Map<String, Object>>(user).run(getService(user)::insertScheme,map);
|
2022-03-09 09:42:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编辑
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @param insuranceSchemeReqParam
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/update")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String update(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody InsuranceSchemeReqParam insuranceSchemeReqParam) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
Map<String, Object> map = ParamUtil.request2Map(request);
|
|
|
|
|
map.put("insuranceSchemeReqParam",insuranceSchemeReqParam);
|
2022-05-05 10:35:58 +08:00
|
|
|
return new ResponseResult< Map<String, Object>, Map<String, Object>>(user).run(getService(user)::update,map);
|
2022-03-09 09:42:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除(接口中暂无)
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @param ids
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/delete")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String deleteTaxRate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Collection<Long> ids) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
Map<String, Object> map = ParamUtil.request2Map(request);
|
|
|
|
|
map.put("ids",ids);
|
2022-05-05 10:35:58 +08:00
|
|
|
return new ResponseResult< Map<String, Object>, Map<String, Object>>(user).run(getService(user)::delete,map);
|
2022-03-09 09:42:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 复制福利方案表单
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/copyScheme")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String copyScheme(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
|
|
|
|
@QueryParam("id") Long id, @QueryParam("schemeName") String schemeName) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
Map<String, Object> map = ParamUtil.request2Map(request);
|
|
|
|
|
map.put("id",id);
|
|
|
|
|
map.put("schemeName",schemeName);
|
2022-05-05 10:35:58 +08:00
|
|
|
return new ResponseResult< Map<String, Object>, Map<String, Object>>(user).run(getService(user)::copyScheme,map);
|
2022-03-09 09:42:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-05-06 16:58:01 +08:00
|
|
|
/**
|
|
|
|
|
* 导出档案
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GET
|
2022-05-09 11:18:54 +08:00
|
|
|
@Path("/export")
|
2022-05-06 16:58:01 +08:00
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
|
|
|
|
InsuranceArchivesListParam param = new InsuranceArchivesListParam();
|
|
|
|
|
String ids = request.getParameter("ids");
|
|
|
|
|
if(StringUtils.isNotBlank(ids)){
|
|
|
|
|
param.setIds( Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList()));
|
|
|
|
|
}
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
XSSFWorkbook workbook = getService(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();
|
|
|
|
|
};
|
|
|
|
|
return Response.ok(output)
|
|
|
|
|
.header("Content-disposition", "attachment;filename=" + fileName)
|
|
|
|
|
.header("Cache-Control", "no-cache").build();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-09 09:42:10 +08:00
|
|
|
|
2022-05-09 11:18:54 +08:00
|
|
|
@POST
|
|
|
|
|
@Path("/preview")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String preview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SISchemaImportParam queryParam) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<SISchemaImportParam, Map<String, Object>>(user).run(getService(user)::preview, queryParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/importBatch")
|
|
|
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
|
|
|
public String batchImportEbatch(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SISchemaImportParam queryParam) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
return new ResponseResult<SISchemaImportParam, Map<String, Object>>(user).run(getService(user)::batchImportEbatch, queryParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出档案和档案模板
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/template/export")
|
|
|
|
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
|
|
public Response exportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody InsuranceArchivesListParam param) {
|
|
|
|
|
User user = HrmUserVarify.getUser(request, response);
|
|
|
|
|
if (param.getInspectAll() != null && param.getInspectAll()) {
|
|
|
|
|
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = getSIAccountService(user).allInspects(param.getIds(), param.getBillMonth());
|
|
|
|
|
param.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList()));
|
|
|
|
|
}
|
|
|
|
|
XSSFWorkbook workbook = getService(user).exportTemplate(param);
|
|
|
|
|
String fileName = null;
|
|
|
|
|
try {
|
|
|
|
|
fileName = URLEncoder.encode("福利档案模板.xlsx", "UTF-8");
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamingOutput output = outputStream -> {
|
|
|
|
|
workbook.write(outputStream);
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
};
|
|
|
|
|
return Response.ok(output)
|
|
|
|
|
.header("Content-disposition", "attachment;filename=" + fileName)
|
|
|
|
|
.header("Cache-Control", "no-cache").build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-03-09 09:42:10 +08:00
|
|
|
|
2022-03-07 22:22:09 +08:00
|
|
|
}
|