智能算薪导出

This commit is contained in:
钱涛 2023-08-29 13:55:36 +08:00
parent 4644f34bbb
commit 1c9cc632d3
13 changed files with 338 additions and 246 deletions

View File

@ -1,9 +1,9 @@
package com.engine.salary.entity.taxapiflow.dto;
import com.engine.salary.annotation.TableTitle;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -21,42 +21,49 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@ApiModel("智能算税-流量使用记录")
public class TaxDeclarationApiFlowRecordListDTO {
//id")
//id
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
//序号")
//序号
@TableTitle(title = "序号", key = "indexNum", dataIndex = "indexNum")
private Integer indexNum;
//使用时间")
//使用时间
private String createTime;
//个税扣缴义务人")
//个税扣缴义务人
@TableTitle(title = "个税扣缴义务人", key = "taxAgentName", dataIndex = "taxAgentName")
private String taxAgentName;
//人员")
//人员
@TableTitle(title = "人员", key = "employeeName", dataIndex = "employeeName")
private String employeeName;
//人员类型")
//人员类型
private String employeeType;
//人员id")
//人员id
@JsonSerialize(using = ToStringSerializer.class)
private Long employeeId;
//创建人id")
//创建人id
@JsonSerialize(using = ToStringSerializer.class)
private Long creatorId;
//身份证号码")
//身份证号码
@TableTitle(title = "身份证号码", key = "idCardNo", dataIndex = "idCardNo")
private String idCardNo;
//接口业务")
//接口业务
@TableTitle(title = "接口业务", key = "businessTypeName", dataIndex = "businessTypeName")
private String businessTypeName;
//操作人")
//操作人
@TableTitle(title = "操作人", key = "creator", dataIndex = "creator")
private String creator;
//结果")
//结果
@TableTitle(title = "结果", key = "result", dataIndex = "result")
private String result;
}

View File

@ -1,10 +1,10 @@
package com.engine.salary.entity.taxapiflow.dto;
import com.engine.salary.annotation.TableTitle;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -22,7 +22,6 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@ApiModel("智能算税-流量统计-月度详情")
public class TaxDeclarationApiFlowStatisticDetailListDTO {
//id")
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@ -30,12 +29,15 @@ public class TaxDeclarationApiFlowStatisticDetailListDTO {
private Long taxAgentId;
@JsonIgnore
@TableTitle(title = "个税扣缴义务人",key = "taxAgentName",dataIndex = "taxAgentName")
private String taxAgentName;
//税款所属期")
//税款所属期
@TableTitle(title = "",key = "",dataIndex = "")
private String taxMonth;
//月使用流量数")
//月使用流量数
@TableTitle(title = "月使用流量数",key = "used",dataIndex = "used")
private Integer used;
}

View File

@ -1,9 +1,9 @@
package com.engine.salary.entity.taxapiflow.dto;
import com.engine.salary.annotation.TableTitle;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -11,30 +11,34 @@ import lombok.NoArgsConstructor;
/**
* 智能算税-流量统计
* <p>Copyright: Copyright (c) 2023</p>
* <p>Company: 泛微软件</p>
*
* @author chengliming
* @date 2022-11-11 17:01:25
*/
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("智能算税-流量统计")
public class TaxDeclarationApiFlowStatisticListDTO {
//id")
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
//序号")
//序号
@TableTitle(title = "序号",key = "indexNum",dataIndex = "indexNum")
private Integer indexNum;
//个税扣缴义务人")
//个税扣缴义务人
@TableTitle(title = "个税扣缴义务人",key = "taxAgentName",dataIndex = "taxAgentName")
private String taxAgentName;
//个税扣缴义务人ID")
//个税扣缴义务人ID
@JsonSerialize(using = ToStringSerializer.class)
private Long taxAgentId;
//已使用")
//已使用
@TableTitle(title = "已使用",key = "used",dataIndex = "used")
private Integer used;
}

View File

@ -1,15 +1,15 @@
package com.engine.salary.entity.taxapiflow.param;
import com.engine.salary.common.BaseQueryParam;
import com.engine.salary.util.SalaryDateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.time.YearMonth;
import java.util.Date;
/**
* 流量月度详情查询参数
@ -29,22 +29,22 @@ public class TaxDeclarationApiFlowMonthQueryParam extends BaseQueryParam {
private Long taxAgentId;
//税款所属期开始时间")
private YearMonth startTaxMonth;
private Date startTaxMonth;
//税款所属期结束时间")
private YearMonth endTaxMonth;
private Date endTaxMonth;
public Integer getStartTaxMonth() {
if (startTaxMonth == null) {
return 0;
}
return Integer.parseInt(startTaxMonth.toString().replace("-", ""));
return Integer.parseInt(SalaryDateUtil.getFormatYYYYMM(startTaxMonth).replace("-", ""));
}
public Integer getEndTaxMonth() {
if (endTaxMonth == null) {
return Integer.MAX_VALUE;
}
return Integer.parseInt(endTaxMonth.toString().replace("-", ""));
return Integer.parseInt(SalaryDateUtil.getFormatYYYYMM(endTaxMonth).replace("-", ""));
}
}

View File

@ -4,6 +4,7 @@ import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowRecordListDT
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowRecordQueryParam;
import com.engine.salary.service.impl.TaxDeclarationApiBillingServiceImpl;
import com.engine.salary.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.List;
@ -44,8 +45,7 @@ public interface TaxDeclarationApiBillingService {
* 导出流量使用记录
*
* @param queryParam
* @param map
*/
// void exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam, Map<String, Object> map);
XSSFWorkbook exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam);
}

View File

@ -8,6 +8,7 @@ import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowMonthQuery
import com.engine.salary.entity.taxapiflow.response.QueryAccountBalanceResponse;
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationApiConfigPO;
import com.engine.salary.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.List;
@ -57,22 +58,19 @@ public interface TaxDeclarationApiFlowStatisticService {
*/
List<TaxDeclarationApiFlowStatisticDetailListDTO> listFlowStatisticDetail(TaxDeclarationApiFlowMonthQueryParam queryParam);
// /**
// * 导出流量统计
// *
// * @param map
// * @param dtoList
// */
// void exportFlowStatistics(Map<String, Object> map, List<TaxDeclarationApiFlowStatisticListDTO> dtoList);
//
// /**
// * 导出流量月度统计
// *
// * @param queryParam
// * @param map
// * @param dtoList
// */
// void exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Map<String, Object> map, List<TaxDeclarationApiFlowStatisticDetailListDTO> dtoList);
/**
* 导出流量统计
*
* @param dtoList
*/
XSSFWorkbook exportFlowStatistics(List<TaxDeclarationApiFlowStatisticListDTO> dtoList);
/**
* 导出流量月度统计
*
* @param dtoList
*/
XSSFWorkbook exportFlowStatisticsDetail( List<TaxDeclarationApiFlowStatisticDetailListDTO> dtoList);
/**
* 查询流量统计数据

View File

@ -272,7 +272,7 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
@Override
public Map<Long, String> mapByEmployeeIds(Collection<Long> employeeIds) {
List<DataCollectionEmployee> simpleUserInfos = getEmployeeByIdsAll((List<Long>) employeeIds);
List<DataCollectionEmployee> simpleUserInfos = getEmployeeByIdsAll(new ArrayList<>(employeeIds));
Map<Long, String> result = new HashMap<>();
simpleUserInfos.forEach(e -> {
result.put(e.getEmployeeId(), e.getIdNo());

View File

@ -14,7 +14,9 @@ import com.engine.salary.enums.taxdeclaration.EnumDeclareApiBusinessType;
import com.engine.salary.mapper.taxdeclaration.TaxDeclarationApiFlowRecordMapper;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.google.common.collect.Lists;
@ -22,6 +24,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;
import java.util.*;
@ -123,48 +126,36 @@ public class TaxDeclarationApiBillingServiceImpl extends Service implements TaxD
return build;
}
// @Override
// public void exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam, Map<String, Object> map) {
// ExportWrapper exportWrapper = new ExportWrapper(map, employeeId, tenantKey);
// // 表头
// List<String> headers = exportWrapper.getHeaders();
// headers.add(SalaryI18nUtil.getI18nLabel( 159083, "时间"));
// headers.add(SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人"));
// headers.add(SalaryI18nUtil.getI18nLabel( 100133, "人员"));
// headers.add(SalaryI18nUtil.getI18nLabel( 106277, "身份证号"));
// headers.add(SalaryI18nUtil.getI18nLabel( 159085, "接口服务"));
// headers.add(SalaryI18nUtil.getI18nLabel( 85435, "操作人"));
// headers.add(SalaryI18nUtil.getI18nLabel( 159086, "结果"));
// exportWrapper.getExcelSheetData().setHeaders(Collections.singletonList(headers.toArray(new String[]{})));
// // 获取数据
// List<TaxDeclarationApiFlowRecordListDTO> dtoList = listFlowRecord(queryParam, employeeId, tenantKey);
// // 组装数据
// for (TaxDeclarationApiFlowRecordListDTO dto : dtoList) {
// List<Object> row = new ArrayList<>();
// row.add(dto.getCreateTime());
// row.add(dto.getTaxAgentName());
// row.add(dto.getEmployeeName());
// row.add(dto.getIdCardNo());
// row.add(dto.getBusinessTypeName());
// row.add(dto.getCreator());
// row.add(dto.getResult());
// exportWrapper.getRows().add(row);
// }
// // 生成表格
// buildExcelData(exportWrapper);
// }
@Override
public XSSFWorkbook exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) {
List<List<Object>> rows = new ArrayList<>();
// 表头
List<Object> headers = new ArrayList<>();
headers.add(SalaryI18nUtil.getI18nLabel(159083, "时间"));
headers.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
headers.add(SalaryI18nUtil.getI18nLabel(100133, "人员"));
headers.add(SalaryI18nUtil.getI18nLabel(106277, "身份证号"));
headers.add(SalaryI18nUtil.getI18nLabel(159085, "接口服务"));
headers.add(SalaryI18nUtil.getI18nLabel(85435, "操作人"));
headers.add(SalaryI18nUtil.getI18nLabel(159086, "结果"));
// 获取数据
List<TaxDeclarationApiFlowRecordListDTO> dtoList = listFlowRecord(queryParam);
// 组装数据
for (TaxDeclarationApiFlowRecordListDTO dto : dtoList) {
List<Object> row = new ArrayList<>();
row.add(dto.getCreateTime());
row.add(dto.getTaxAgentName());
row.add(dto.getEmployeeName());
row.add(dto.getIdCardNo());
row.add(dto.getBusinessTypeName());
row.add(dto.getCreator());
row.add(dto.getResult());
rows.add(row);
}
// 生成表格
return ExcelUtil.genWorkbookV2(rows, "接口使用记录数据");
}
// /**
// * 构建excel数据
// *
// * @param wrapper
// */
// private void buildExcelData(ExportWrapper wrapper) {
// wrapper.getExcelSheetData().setRows(wrapper.getRows());
// wrapper.getSheetList().add(wrapper.getExcelSheetData());
// salaryBatchService.simpleExportExcel(wrapper.buildExportExcelInfo(), wrapper.getSheetList());
// }
//
/**
* 封装一些临时的集合类便于方法复用

View File

@ -19,10 +19,12 @@ import com.engine.salary.service.TaxAgentTaxReturnService;
import com.engine.salary.service.TaxDeclarationApiConfigService;
import com.engine.salary.service.TaxDeclarationApiFlowStatisticService;
import com.engine.salary.util.*;
import com.engine.salary.util.excel.ExcelUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import dm.jdbc.util.IdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;
import java.time.LocalDate;
@ -67,7 +69,7 @@ public class TaxDeclarationApiFlowStatisticServiceImpl extends Service implement
@Override
public PageInfo<TaxDeclarationApiFlowStatisticListDTO> pageFlowStatistics(BaseQueryParam queryParam) {
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), listFlowStatistic());
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), listFlowStatistic(),TaxDeclarationApiFlowStatisticListDTO.class);
}
@Override
@ -147,48 +149,45 @@ public class TaxDeclarationApiFlowStatisticServiceImpl extends Service implement
.build()).collect(Collectors.toList());
}
// @Override
// public void exportFlowStatistics(Map<String, Object> map, List<TaxDeclarationApiFlowStatisticListDTO> dtoList) {
// ExportWrapper exportWrapper = new ExportWrapper(map, employeeId, tenantKey);
// // 表头
// List<String> headers = exportWrapper.getHeaders();
// headers.add(SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人"));
// headers.add(SalaryI18nUtil.getI18nLabel( 159084, "已使用流量"));
// exportWrapper.getExcelSheetData().setHeaders(Collections.singletonList(headers.toArray(new String[]{})));
// // 组装数据
// for (TaxDeclarationApiFlowStatisticListDTO dto : dtoList) {
// List<Object> row = new ArrayList<>();
// row.add(dto.getTaxAgentName());
// row.add(dto.getUsed());
// exportWrapper.getRows().add(row);
// }
// // 生成表格
// buildExcelData(exportWrapper);
// }
@Override
public XSSFWorkbook exportFlowStatistics(List<TaxDeclarationApiFlowStatisticListDTO> dtoList) {
// @Override
// public void exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Map<String, Object> map, List<TaxDeclarationApiFlowStatisticDetailListDTO> dtoList) {
// ExportWrapper exportWrapper = new ExportWrapper(map, employeeId, tenantKey);
// // 表头
// List<String> headers = exportWrapper.getHeaders();
// headers.add(SalaryI18nUtil.getI18nLabel( 86184, "个税扣缴义务人"));
// headers.add(SalaryI18nUtil.getI18nLabel( 86176, "税款所属期"));
// headers.add(SalaryI18nUtil.getI18nLabel( 159087, "月使用流量数"));
// exportWrapper.getExcelSheetData().setHeaders(Collections.singletonList(headers.toArray(new String[]{})));
// // 组装数据
// for (TaxDeclarationApiFlowStatisticDetailListDTO dto : dtoList) {
// List<Object> row = new ArrayList<>();
// row.add(dto.getTaxAgentName());
// row.add(dto.getTaxMonth());
// row.add(dto.getUsed());
// exportWrapper.getRows().add(row);
// }
// // 生成表格
// /**
// wrapper.getExcelSheetData().setRows(wrapper.getRows());
// wrapper.getSheetList().add(wrapper.getExcelSheetData());
// salaryBatchService.simpleExportExcel(wrapper.buildExportExcelInfo(), wrapper.getSheetList());
// }}
List<List<Object>> rows = new ArrayList<>();
// 表头
List<Object> headers = new ArrayList<>();
headers.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
headers.add(SalaryI18nUtil.getI18nLabel(159084, "已使用流量"));
rows.add(headers);
// 组装数据
for (TaxDeclarationApiFlowStatisticListDTO dto : dtoList) {
List<Object> row = new ArrayList<>();
row.add(dto.getTaxAgentName());
row.add(dto.getUsed());
rows.add(row);
}
// 生成表格
return ExcelUtil.genWorkbookV2(rows, "接口流量统计数据");
}
@Override
public XSSFWorkbook exportFlowStatisticsDetail(List<TaxDeclarationApiFlowStatisticDetailListDTO> dtoList) {
List<List<Object>> rows = new ArrayList<>();
// 表头
List<Object> headers = new ArrayList<>();
headers.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
headers.add(SalaryI18nUtil.getI18nLabel(86176, "税款所属期"));
headers.add(SalaryI18nUtil.getI18nLabel(159087, "月使用流量数"));
// 组装数据
for (TaxDeclarationApiFlowStatisticDetailListDTO dto : dtoList) {
List<Object> row = new ArrayList<>();
row.add(dto.getTaxAgentName());
row.add(dto.getTaxMonth());
row.add(dto.getUsed());
rows.add(row);
}
// 生成表格
return ExcelUtil.genWorkbookV2(rows, "接口流量月统计数据");
}
public QueryAccountBalanceResponse getQueryAccountBalanceResponse(TaxDeclarationApiConfigPO apiConfig) {

View File

@ -6,9 +6,14 @@ import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationBillingConfigFormDT
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowRecordQueryParam;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationBillingConfigSaveParam;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.TaxDeclarationApiFlowBillingWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
@ -20,6 +25,11 @@ 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.LocalDateTime;
/**
* 智能算薪-计费
@ -29,6 +39,7 @@ import javax.ws.rs.core.MediaType;
* @author qiantao
* @version 1.0
**/
@Slf4j
public class TaxDeclarationApiFlowController {
private TaxDeclarationApiFlowBillingWrapper getTaxDeclarationApiFlowBillingWrapper(User user) {
@ -103,19 +114,61 @@ public class TaxDeclarationApiFlowController {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<TaxDeclarationApiFlowRecordQueryParam, PageInfo<TaxDeclarationApiFlowRecordListDTO>>(user).run(getTaxDeclarationApiFlowBillingWrapper(user)::getFlowRecord, queryParam);
}
//
// /**
// * 导出接口流量使用记录
// *
// * @param queryParam 查询条件
// * @return WeaResult 返回结果
// */
// @POST
// @Path("/record/export")
// @Produces(MediaType.APPLICATION_JSON)
// public String exportFlowRecord(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationApiFlowRecordQueryParam queryParam) {
// User user = HrmUserVarify.getUser(request, response);
// return new ResponseResult<TaxDeclarationApiFlowRecordQueryParam, PageInfo<TaxDeclarationApiFlowRecordListDTO>>(user).run(getTaxDeclarationApiFlowBillingWrapper(user)::getFlowRecord,queryParam);
// return WeaResult.success(getTaxDeclarationApiFlowBillingWrapper.exportFlowRecord(queryParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
/**
* 导出接口流量使用记录
*
* @return WeaResult 返回结果
*/
@GET
@Path("/record/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportFlowStatisticsDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User user = HrmUserVarify.getUser(request, response);
TaxDeclarationApiFlowRecordQueryParam queryParam = TaxDeclarationApiFlowRecordQueryParam.builder().build();
String taxAgentId = request.getParameter("taxAgentId");
if(StringUtils.isNotBlank(taxAgentId)){
queryParam.setTaxAgentId(Long.valueOf(taxAgentId));
}
String startDate = request.getParameter("startDate");
if(StringUtils.isNotBlank(startDate)){
queryParam.setStartDate(SalaryDateUtil.stringToDate(startDate));
}
String endDate = request.getParameter("endDate");
if(StringUtils.isNotBlank(endDate)){
queryParam.setEndDate(SalaryDateUtil.stringToDate(endDate));
}
String businessType = request.getParameter("businessType");
if(StringUtils.isNotBlank(businessType)){
queryParam.setBusinessType(Integer.valueOf(businessType));
}
String result = request.getParameter("result");
if(StringUtils.isNotBlank(result)){
queryParam.setBusinessType(Integer.valueOf(result));
}
XSSFWorkbook workbook = getTaxDeclarationApiFlowBillingWrapper(user).exportFlowRecord(queryParam);
String fileName = SalaryI18nUtil.getI18nLabel(156419, "接口流量月统计数据") + "-" + SalaryDateUtil.getFormatLocalDate(LocalDateTime.now());
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;
}
}
}

View File

@ -4,21 +4,33 @@ import com.engine.common.util.ServiceUtil;
import com.engine.salary.common.BaseQueryParam;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowStatisticDetailListDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowStatisticListDTO;
import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowTotalDTO;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowMonthQueryParam;
import com.engine.salary.util.ResponseResult;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.TaxDeclarationApiFlowStatisticWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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.GET;
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.LocalDateTime;
/**
* 智能算薪-计费
@ -26,23 +38,25 @@ import javax.ws.rs.core.MediaType;
* @author chengliming
* @date 2022-11-15 16:05:40
*/
@Slf4j
public class TaxDeclarationApiFlowStatisticController {
private TaxDeclarationApiFlowStatisticWrapper getTaxDeclarationApiFlowStatisticWrapper(User user) {
return ServiceUtil.getService(TaxDeclarationApiFlowStatisticWrapper.class, user);
}
// /**
// * 接口流量统计
// *
// * @return WeaResult 返回结果
// */
// @Path
// @POST
// @Produces(MediaType.APPLICATION_JSON)
// public WeaResult<TaxDeclarationApiFlowTotalDTO> getFlowStatistics() {
// return WeaResult.success(taxDeclarationApiFlowStatisticWrapper.getFlowStatistics(TenantContext.getCurrentTenantKey(), UserContext.getCurrentEmployeeId()));
// }
/**
* 接口流量统计
*
* @return WeaResult 返回结果
*/
@POST
@Path("/info")
@Produces(MediaType.APPLICATION_JSON)
public String getFlowStatistics(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, TaxDeclarationApiFlowTotalDTO>(user).run(getTaxDeclarationApiFlowStatisticWrapper(user)::getFlowStatistics);
}
/**
* 接口流量使用明细
@ -58,19 +72,40 @@ public class TaxDeclarationApiFlowStatisticController {
return new ResponseResult<BaseQueryParam, PageInfo<TaxDeclarationApiFlowStatisticListDTO>>(user).run(getTaxDeclarationApiFlowStatisticWrapper(user)::getFlowStatisticsList, queryParam);
}
// /**
// * 导出接口流量使用明细
// *
// * @return WeaResult 返回结果
// */
// @Path("/export")
// @GET
// @Produces(MediaType.APPLICATION_JSON)
// public String exportFlowStatistics(@Context HttpServletRequest request, @Context HttpServletResponse response) {
// User user = HrmUserVarify.getUser(request, response);
// return new ResponseResult<BaseQueryParam, PageInfo<TaxDeclarationApiFlowStatisticListDTO>>(user).run(getTaxDeclarationApiFlowStatisticWrapper(user)::getFlowStatisticsList, queryParam);
// return WeaResult.success(taxDeclarationApiFlowStatisticWrapper.exportFlowStatistics(UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
/**
* 导出接口流量使用明细
*
* @return WeaResult 返回结果
*/
@GET
@Path("/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportFlowStatistics(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User user = HrmUserVarify.getUser(request, response);
XSSFWorkbook workbook = getTaxDeclarationApiFlowStatisticWrapper(user).exportFlowStatistics();
String fileName = SalaryI18nUtil.getI18nLabel(156419, "接口流量统计数据") + "-" + SalaryDateUtil.getFormatLocalDate(LocalDateTime.now());
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;
}
}
/**
* 接口流量月度使用明细
@ -86,16 +121,52 @@ public class TaxDeclarationApiFlowStatisticController {
return new ResponseResult<TaxDeclarationApiFlowMonthQueryParam, PageInfo<TaxDeclarationApiFlowStatisticDetailListDTO>>(user).run(getTaxDeclarationApiFlowStatisticWrapper(user)::getFlowStatisticsDetail, queryParam);
}
// /**
// * 导出接口流量使用明细
// *
// * @param queryParam 查询条件
// * @return WeaResult 返回结果
// */
// @Path("/detail/export")
// @ApiOperation("导出接口流量使用明细")
// @Produces(MediaType.APPLICATION_JSON)
// public WeaResult<?> exportFlowStatisticsDetail(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationApiFlowMonthQueryParam queryParam) {
// return WeaResult.success(taxDeclarationApiFlowStatisticWrapper.exportFlowStatisticsDetail(queryParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()));
// }
/**
* 导出接口流量月度使用明细
*
* @return WeaResult 返回结果
*/
@GET
@Path("/detail/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportFlowStatisticsDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User user = HrmUserVarify.getUser(request, response);
TaxDeclarationApiFlowMonthQueryParam queryParam = TaxDeclarationApiFlowMonthQueryParam.builder().build();
String taxAgentId = request.getParameter("taxAgentId");
if(StringUtils.isNotBlank(taxAgentId)){
queryParam.setTaxAgentId(Long.valueOf(taxAgentId));
}
String startTaxMonth = request.getParameter("startTaxMonth");
if(StringUtils.isNotBlank(startTaxMonth)){
queryParam.setStartTaxMonth(SalaryDateUtil.stringToDate(startTaxMonth));
}
String endTaxMonth = request.getParameter("endTaxMonth");
if(StringUtils.isNotBlank(endTaxMonth)){
queryParam.setEndTaxMonth(SalaryDateUtil.stringToDate(endTaxMonth));
}
XSSFWorkbook workbook = getTaxDeclarationApiFlowStatisticWrapper(user).exportFlowStatisticsDetail(queryParam);
String fileName = SalaryI18nUtil.getI18nLabel(156419, "接口流量月统计数据") + "-" + SalaryDateUtil.getFormatLocalDate(LocalDateTime.now());
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;
}
}
}

View File

@ -12,10 +12,15 @@ import com.engine.salary.service.TaxDeclarationApiBillingService;
import com.engine.salary.service.TaxDeclarationApiConfigService;
import com.engine.salary.service.impl.TaxDeclarationApiBillingServiceImpl;
import com.engine.salary.service.impl.TaxDeclarationApiConfigServiceImpl;
import com.engine.salary.util.SalaryAssert;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;
import java.util.List;
/**
* 个税申报计费
* <p>Copyright: Copyright (c) 2023</p>
@ -57,24 +62,11 @@ public class TaxDeclarationApiFlowBillingWrapper extends Service {
return page;
}
// public Map<String, Object> exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam, Long employeeId, String tenantKey) {
// List<TaxDeclarationApiFlowRecordListDTO> dtoList = taxDeclarationApiBillingService.listFlowRecord(queryParam, employeeId, tenantKey);
// SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel( 95795, "数据不存在"));
// // 构建异步导出参数
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportFlowRecord");
// map.put("sheetName", SalaryI18nUtil.getI18nLabel( 183779, "接口使用记录数据"));
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// taxDeclarationApiBillingService.exportFlowRecord(queryParam, map, employeeId, tenantKey);
// } finally {
// }
// }
// };
// ThreadPoolUtil.execute(localRunnable);
// return map;
// }
public XSSFWorkbook exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam) {
List<TaxDeclarationApiFlowRecordListDTO> dtoList = getTaxDeclarationApiBillingService(user).listFlowRecord(queryParam);
SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel( 95795, "数据不存在"));
return getTaxDeclarationApiBillingService(user).exportFlowRecord(queryParam);
}
public void enableConfig(TaxDeclarationBillingConfigSaveParam saveParam) {
getTaxDeclarationApiConfigService(user).enableConfig(saveParam);

View File

@ -9,10 +9,15 @@ import com.engine.salary.entity.taxapiflow.dto.TaxDeclarationApiFlowTotalDTO;
import com.engine.salary.entity.taxapiflow.param.TaxDeclarationApiFlowMonthQueryParam;
import com.engine.salary.service.TaxDeclarationApiFlowStatisticService;
import com.engine.salary.service.impl.TaxDeclarationApiFlowStatisticServiceImpl;
import com.engine.salary.util.SalaryAssert;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;
import java.util.List;
/**
* 个税申报计费
*
@ -40,46 +45,16 @@ public class TaxDeclarationApiFlowStatisticWrapper extends Service {
return page;
}
// public Map<String, Object> exportFlowStatistics(Long employeeId, String tenantKey) {
// List<TaxDeclarationApiFlowStatisticListDTO> dtoList = getTaxDeclarationApiFlowStatisticService(user).listFlowStatistic(tenantKey, employeeId);
// SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 95795, "数据不存在"));
// // 构建异步导出参数
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportFlowStatistics");
// map.put("sheetName", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 184066, "接口流量统计数据"));
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// getTaxDeclarationApiFlowStatisticService(user).exportFlowStatistics(map, dtoList, employeeId, tenantKey);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.execute(localRunnable);
// return map;
// }
//
// public Map<String, Object> exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Long employeeId, String tenantKey) {
// List<TaxDeclarationApiFlowStatisticDetailListDTO> dtoList = getTaxDeclarationApiFlowStatisticService(user).listFlowStatisticDetail(queryParam, employeeId, tenantKey);
// SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 95795, "数据不存在"));
// // 构建异步导出参数
// Map<String, Object> map = salaryBatchService.buildeExportParam("exportFlowStatisticsDetail");
// map.put("sheetName", SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 184067, "接口流量月统计数据"));
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// getTaxDeclarationApiFlowStatisticService(user).exportFlowStatisticsDetail(queryParam, map, dtoList, employeeId, tenantKey);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.execute(localRunnable);
// return map;
// }
public XSSFWorkbook exportFlowStatistics() {
List<TaxDeclarationApiFlowStatisticListDTO> dtoList = getTaxDeclarationApiFlowStatisticService(user).listFlowStatistic();
SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel(95795, "数据不存在"));
return getTaxDeclarationApiFlowStatisticService(user).exportFlowStatistics(dtoList);
}
public XSSFWorkbook exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam) {
List<TaxDeclarationApiFlowStatisticDetailListDTO> dtoList = getTaxDeclarationApiFlowStatisticService(user).listFlowStatisticDetail(queryParam);
SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel(95795, "数据不存在"));
return getTaxDeclarationApiFlowStatisticService(user).exportFlowStatisticsDetail(dtoList);
}
}