6个列表页导出完成
This commit is contained in:
parent
72e9e152d6
commit
d0f12c2faf
|
|
@ -17,7 +17,7 @@ public class AccountExportPO extends InsuranceAccountDetailPO {
|
|||
|
||||
private String departmentName;
|
||||
|
||||
private UserStatusEnum userStatus;
|
||||
private Integer userStatus;
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
|
|
@ -43,11 +43,19 @@ public class AccountExportPO extends InsuranceAccountDetailPO {
|
|||
this.departmentName = departmentName;
|
||||
}
|
||||
|
||||
public UserStatusEnum getUserStatus() {
|
||||
public Integer getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
|
||||
public void setUserStatus(UserStatusEnum userStatus) {
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
// public UserStatusEnum getUserStatus() {
|
||||
// return userStatus;
|
||||
// }
|
||||
//
|
||||
// public void setUserStatus(UserStatusEnum userStatus) {
|
||||
// this.userStatus = userStatus;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,4 +58,6 @@ public enum UserStatusEnum {
|
|||
return m;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,32 +3,32 @@
|
|||
<mapper namespace="com.engine.salary.mapper.InsuranceExportMapper">
|
||||
<select id="exportAccount" resultType="com.engine.salary.entity.siexport.po.AccountExportPO">
|
||||
SELECT
|
||||
a.*,e.username AS userName,e.MOBILE AS telephone,d.`NAME` AS departmentName,e.`STATUS` AS userStatus
|
||||
a.*,e.lastname AS userName,e.MOBILE AS telephone,d.departmentname AS departmentName,e.`STATUS` AS userStatus
|
||||
FROM(
|
||||
SELECT * from hrsa_bill_detail
|
||||
WHERE delete_type = 0 AND bill_month = #{billMonth} AND payment_status = #{paymentStatus}
|
||||
)a
|
||||
LEFT JOIN {$publicdb}.employee e ON e.ID = a.employee_id
|
||||
LEFT JOIN {$publicdb}.department d ON d.id = e.department
|
||||
LEFT JOIN hrmresource e ON e.ID = a.employee_id
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
||||
</select>
|
||||
<select id="exportAccount" resultType="com.weaver.hrm.salary.entity.siexport.po.AccountExportPO" databaseId="oracle">
|
||||
SELECT
|
||||
a.*,e.username AS userName,e.MOBILE AS telephone,d.NAME AS departmentName,e.STATUS AS userStatus
|
||||
FROM(
|
||||
SELECT * from hrsa_bill_detail
|
||||
WHERE delete_type = 0 AND bill_month = #{billMonth} AND payment_status = #{paymentStatus}
|
||||
)a
|
||||
LEFT JOIN {$publicdb}.employee e ON e.ID = a.employee_id
|
||||
LEFT JOIN {$publicdb}.department d ON d.id = e.department
|
||||
a.*,e.lastname AS userName,e.MOBILE AS telephone,d.departmentname AS departmentName,e.STATUS AS userStatus
|
||||
FROM(
|
||||
SELECT * from hrsa_bill_detail
|
||||
WHERE delete_type = 0 AND bill_month = #{billMonth} AND payment_status = #{paymentStatus}
|
||||
)a
|
||||
LEFT JOIN hrmresource e ON e.ID = a.employee_id
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
||||
</select>
|
||||
<select id="exportAccount" resultType="com.weaver.hrm.salary.entity.siexport.po.AccountExportPO" databaseId="sqlserver">
|
||||
SELECT
|
||||
a.*,e.username AS userName,e.MOBILE AS telephone,d.NAME AS departmentName,e.STATUS AS userStatus
|
||||
FROM(
|
||||
SELECT * from hrsa_bill_detail
|
||||
WHERE delete_type = 0 AND bill_month = #{billMonth} AND payment_status = #{paymentStatus}
|
||||
)a
|
||||
LEFT JOIN {$publicdb}.employee e ON e.ID = a.employee_id
|
||||
LEFT JOIN {$publicdb}.department d ON d.id = e.department
|
||||
SELECT
|
||||
a.*,e.lastname AS userName,e.MOBILE AS telephone,d.departmentname AS departmentName,e.STATUS AS userStatus
|
||||
FROM(
|
||||
SELECT * from hrsa_bill_detail
|
||||
WHERE delete_type = 0 AND bill_month = #{billMonth} AND payment_status = #{paymentStatus}
|
||||
)a
|
||||
LEFT JOIN hrmresource e ON e.ID = a.employee_id
|
||||
LEFT JOIN hrmdepartment d ON d.id = e.departmentid
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
|
|||
//工作簿名称
|
||||
String sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案"); //表头
|
||||
//表头
|
||||
excelSheetData.add(Collections.singletonList(columns.stream().map(WeaTableColumn::getText).toArray(String[]::new)));
|
||||
excelSheetData.add(Arrays.asList(columns.stream().map(WeaTableColumn::getText).toArray(String[]::new)));
|
||||
//工作簿数据
|
||||
List<List<Object>> rows = new LinkedList<>();
|
||||
for (Map<String, Object> recordData : records) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ import java.util.*;
|
|||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.engine.salary.enums.UserStatusEnum.getDefaultLabelByValue;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO
|
||||
|
|
@ -75,7 +77,7 @@ public class SIExportServiceImpl extends Service implements SIExportService {
|
|||
SalaryI18nUtil.getI18nLabel( 93276, "公积金缴费合计"),
|
||||
SalaryI18nUtil.getI18nLabel( 93277, "其他福利缴费合计"),
|
||||
SalaryI18nUtil.getI18nLabel( 93278, "合计")};
|
||||
excelSheetData.add(Collections.singletonList(header));
|
||||
excelSheetData.add(Arrays.asList(header));
|
||||
|
||||
//工作簿数据
|
||||
List<List<Object>> rows = new LinkedList<>();
|
||||
|
|
@ -112,7 +114,7 @@ public class SIExportServiceImpl extends Service implements SIExportService {
|
|||
List<List<Object>> excelSheetData = new ArrayList<>();
|
||||
//工作簿名称
|
||||
String sheetName = SalaryI18nUtil.getI18nLabel(85368, "社保福利档案"); //表头
|
||||
excelSheetData.add(Collections.singletonList(columns.stream().map(WeaTableColumn::getText).toArray(String[]::new)));
|
||||
excelSheetData.add(Arrays.asList(columns.stream().map(WeaTableColumn::getText).toArray(String[]::new)));
|
||||
//工作簿数据
|
||||
List<List<Object>> rows = new LinkedList<>();
|
||||
for (Map<String, Object> recordData : records) {
|
||||
|
|
@ -142,7 +144,7 @@ public class SIExportServiceImpl extends Service implements SIExportService {
|
|||
record.put("department", item.getDepartmentName());
|
||||
record.put("supplementaryMonth", item.getSupplementaryMonth());
|
||||
record.put("mobile", item.getTelephone());
|
||||
record.put("employeeStatus", item.getUserStatus() == null ? "" : item.getUserStatus().getDescription());
|
||||
record.put("employeeStatus", item.getUserStatus() == null ? "" : getDefaultLabelByValue(item.getUserStatus()));
|
||||
ResourceFromEnum from = SalaryEnumUtil.enumMatchByValue(item.getResourceFrom(), ResourceFromEnum.values(), ResourceFromEnum.class);
|
||||
record.put("sourceFrom", SalaryI18nUtil.getI18nLabel( from.getLabelId(), from.getDefaultLabel()));
|
||||
record.put("socialPayOrg", paymentMap.get(item.getSocialPayOrg()) == null ? "" : paymentMap.get(item.getSocialPayOrg()).getName());
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class SIImportServiceImpl extends Service implements SIImportService {
|
|||
}
|
||||
List<Map<String, Object>> datas = buildTableData(insuranceArchivesEmployeePOS);
|
||||
//表头
|
||||
excelSheetData.add(Collections.singletonList(headers.toArray(new String[0])));
|
||||
excelSheetData.add(Arrays.asList(headers.toArray(new String[0])));
|
||||
//工作簿数据
|
||||
List<List<Object>> rows = new LinkedList<>();
|
||||
for (int i = 1; i <= datas.size(); i++) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.engine.salary.web;
|
||||
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.salary.biz.SIAccountBiz;
|
||||
import com.engine.salary.entity.siaccount.param.InspectAccountParam;
|
||||
|
|
@ -9,19 +10,18 @@ import com.engine.salary.entity.siexport.param.InsuranceExportParam;
|
|||
import com.engine.salary.enums.siaccount.PaymentStatusEnum;
|
||||
import com.engine.salary.service.SIAccountService;
|
||||
import com.engine.salary.service.impl.SIAccountServiceImpl;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.wrapper.SIExportWrapper;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import com.engine.salary.wrapper.SIImportWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
|
@ -29,7 +29,6 @@ import javax.ws.rs.core.StreamingOutput;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
|
@ -51,11 +50,14 @@ public class SIExportController {
|
|||
return ServiceUtil.getService(SIExportWrapper.class,user);
|
||||
}
|
||||
|
||||
public SIImportWrapper getSIImportWrapper(User user) {
|
||||
return ServiceUtil.getService(SIImportWrapper.class,user);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/archives/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response
|
||||
) {
|
||||
public Response export(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
InsuranceArchivesListParam param = buildParam(request);
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getSIExportWrapper(user).export(param);
|
||||
|
|
@ -76,11 +78,12 @@ public class SIExportController {
|
|||
|
||||
|
||||
|
||||
@POST
|
||||
@GET
|
||||
@Path("/archives/exportInspect")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response exportInspect(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@RequestBody InspectAccountParam param) {
|
||||
@QueryParam("ids")List<Long> ids,@QueryParam("billMonth") String billMonth) {
|
||||
InspectAccountParam param = InspectAccountParam.builder().ids(ids).billMonth(billMonth).build();
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
SIAccountBiz siAccountBiz = new SIAccountBiz();
|
||||
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth());
|
||||
|
|
@ -105,11 +108,12 @@ public class SIExportController {
|
|||
|
||||
|
||||
|
||||
@POST
|
||||
@GET
|
||||
@Path("/common/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response exportAccount(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@RequestBody InsuranceExportParam param) {
|
||||
@QueryParam("billMonth") String billMonth) {
|
||||
InsuranceExportParam param = InsuranceExportParam.builder().billMonth(billMonth).build();
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getSIExportWrapper(user).exportAccount(PaymentStatusEnum.COMMON.getValue(),param);
|
||||
String time = LocalDate.now().toString();
|
||||
|
|
@ -128,11 +132,12 @@ public class SIExportController {
|
|||
}
|
||||
|
||||
|
||||
@POST
|
||||
@GET
|
||||
@Path("/supplementary/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response exportSupplementary(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@RequestBody InsuranceExportParam param) {
|
||||
@QueryParam("billMonth") String billMonth) {
|
||||
InsuranceExportParam param = InsuranceExportParam.builder().billMonth(billMonth).build();
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getSIExportWrapper(user).exportAccount(PaymentStatusEnum.REPAIR.getValue(),param);
|
||||
String time = LocalDate.now().toString();
|
||||
|
|
@ -150,11 +155,12 @@ public class SIExportController {
|
|||
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@GET
|
||||
@Path("/overView/export")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response exportOverView(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@RequestBody InsuranceExportParam param) {
|
||||
@QueryParam("billMonth") String billMonth) {
|
||||
InsuranceExportParam param = InsuranceExportParam.builder().billMonth(billMonth).build();
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getSIExportWrapper(user).exportOverView(param);
|
||||
String time = LocalDate.now().toString();
|
||||
|
|
@ -172,6 +178,40 @@ public class SIExportController {
|
|||
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/exportCurrentData")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response exportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
InsuranceArchivesListParam param = buildParam(request);
|
||||
SIAccountBiz siAccountBiz = new SIAccountBiz();
|
||||
if (param.getInspectAll() != null && param.getInspectAll()) {
|
||||
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth());
|
||||
param.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList()));
|
||||
}
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getSIImportWrapper(user).exportTemplate(param);
|
||||
String time = LocalDate.now().toString();
|
||||
String fileName = "";
|
||||
if (BooleanUtil.isTrue(param.getTemplateFlag())) {
|
||||
fileName = SalaryI18nUtil.getI18nLabel( 100571, "社保福利档案模板");
|
||||
} else {
|
||||
fileName = SalaryI18nUtil.getI18nLabel( 94629, "社保福利档案");
|
||||
}
|
||||
fileName = 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();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private InsuranceArchivesListParam buildParam(HttpServletRequest request) {
|
||||
InsuranceArchivesListParam param = new InsuranceArchivesListParam();
|
||||
String userName = request.getParameter("userName");
|
||||
|
|
|
|||
|
|
@ -1,77 +0,0 @@
|
|||
package com.engine.salary.web;
|
||||
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.salary.biz.SIAccountBiz;
|
||||
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
|
||||
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.wrapper.SIImportWrapper;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
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;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
* @Description: TODO 福利导入控制器
|
||||
* @Date 2022/4/20
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class SIImportController {
|
||||
|
||||
public SIImportWrapper getSIImportWrapper(User user) {
|
||||
return ServiceUtil.getService(SIImportWrapper.class,user);
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("/exportCurrentData")
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response exportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@RequestBody InsuranceArchivesListParam param) {
|
||||
SIAccountBiz siAccountBiz = new SIAccountBiz();
|
||||
if (param.getInspectAll() != null && param.getInspectAll()) {
|
||||
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth());
|
||||
param.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList()));
|
||||
}
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
XSSFWorkbook workbook = getSIImportWrapper(user).exportTemplate(param);
|
||||
String time = LocalDate.now().toString();
|
||||
String fileName = "";
|
||||
if (BooleanUtil.isTrue(param.getTemplateFlag())) {
|
||||
fileName =SalaryI18nUtil.getI18nLabel( 100571, "社保福利档案模板");
|
||||
} else {
|
||||
fileName = SalaryI18nUtil.getI18nLabel( 94629, "社保福利档案");
|
||||
}
|
||||
fileName = 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue