From 1c9cc632d3e8d3e8e8a90c5d4889bf4a8909f341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Tue, 29 Aug 2023 13:55:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E8=83=BD=E7=AE=97=E8=96=AA=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaxDeclarationApiFlowRecordListDTO.java | 33 ++-- ...larationApiFlowStatisticDetailListDTO.java | 10 +- ...TaxDeclarationApiFlowStatisticListDTO.java | 22 +-- .../TaxDeclarationApiFlowMonthQueryParam.java | 12 +- .../TaxDeclarationApiBillingService.java | 4 +- ...TaxDeclarationApiFlowStatisticService.java | 30 ++-- .../impl/SalaryEmployeeServiceImpl.java | 2 +- .../TaxDeclarationApiBillingServiceImpl.java | 77 +++++----- ...eclarationApiFlowStatisticServiceImpl.java | 83 +++++----- .../web/TaxDeclarationApiFlowController.java | 83 ++++++++-- ...DeclarationApiFlowStatisticController.java | 143 +++++++++++++----- .../TaxDeclarationApiFlowBillingWrapper.java | 28 ++-- ...TaxDeclarationApiFlowStatisticWrapper.java | 57 ++----- 13 files changed, 338 insertions(+), 246 deletions(-) diff --git a/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowRecordListDTO.java b/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowRecordListDTO.java index 5b6ef90cb..33b2a72f4 100644 --- a/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowRecordListDTO.java +++ b/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowRecordListDTO.java @@ -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; } diff --git a/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowStatisticDetailListDTO.java b/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowStatisticDetailListDTO.java index 9d658b6d9..cf4d4ee9f 100644 --- a/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowStatisticDetailListDTO.java +++ b/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowStatisticDetailListDTO.java @@ -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; } diff --git a/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowStatisticListDTO.java b/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowStatisticListDTO.java index ecfa10f57..ac37af2c3 100644 --- a/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowStatisticListDTO.java +++ b/src/com/engine/salary/entity/taxapiflow/dto/TaxDeclarationApiFlowStatisticListDTO.java @@ -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; /** * 智能算税-流量统计 + *

Copyright: Copyright (c) 2023

+ *

Company: 泛微软件

* - * @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; } diff --git a/src/com/engine/salary/entity/taxapiflow/param/TaxDeclarationApiFlowMonthQueryParam.java b/src/com/engine/salary/entity/taxapiflow/param/TaxDeclarationApiFlowMonthQueryParam.java index 2ae0cbb43..69fa8b8fa 100644 --- a/src/com/engine/salary/entity/taxapiflow/param/TaxDeclarationApiFlowMonthQueryParam.java +++ b/src/com/engine/salary/entity/taxapiflow/param/TaxDeclarationApiFlowMonthQueryParam.java @@ -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("-", "")); } } diff --git a/src/com/engine/salary/service/TaxDeclarationApiBillingService.java b/src/com/engine/salary/service/TaxDeclarationApiBillingService.java index 409b99903..574076008 100644 --- a/src/com/engine/salary/service/TaxDeclarationApiBillingService.java +++ b/src/com/engine/salary/service/TaxDeclarationApiBillingService.java @@ -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 map); + XSSFWorkbook exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam); } diff --git a/src/com/engine/salary/service/TaxDeclarationApiFlowStatisticService.java b/src/com/engine/salary/service/TaxDeclarationApiFlowStatisticService.java index 960bcd23c..a8e0cb4dc 100644 --- a/src/com/engine/salary/service/TaxDeclarationApiFlowStatisticService.java +++ b/src/com/engine/salary/service/TaxDeclarationApiFlowStatisticService.java @@ -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 listFlowStatisticDetail(TaxDeclarationApiFlowMonthQueryParam queryParam); -// /** -// * 导出流量统计 -// * -// * @param map -// * @param dtoList -// */ -// void exportFlowStatistics(Map map, List dtoList); -// -// /** -// * 导出流量月度统计 -// * -// * @param queryParam -// * @param map -// * @param dtoList -// */ -// void exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Map map, List dtoList); + /** + * 导出流量统计 + * + * @param dtoList + */ + XSSFWorkbook exportFlowStatistics(List dtoList); + + /** + * 导出流量月度统计 + * + * @param dtoList + */ + XSSFWorkbook exportFlowStatisticsDetail( List dtoList); /** * 查询流量统计数据 diff --git a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java index 5fda44b47..3d37e414f 100644 --- a/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryEmployeeServiceImpl.java @@ -272,7 +272,7 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee @Override public Map mapByEmployeeIds(Collection employeeIds) { - List simpleUserInfos = getEmployeeByIdsAll((List) employeeIds); + List simpleUserInfos = getEmployeeByIdsAll(new ArrayList<>(employeeIds)); Map result = new HashMap<>(); simpleUserInfos.forEach(e -> { result.put(e.getEmployeeId(), e.getIdNo()); diff --git a/src/com/engine/salary/service/impl/TaxDeclarationApiBillingServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationApiBillingServiceImpl.java index e09f4cb69..f8177facf 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationApiBillingServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationApiBillingServiceImpl.java @@ -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.*; @@ -99,7 +102,7 @@ public class TaxDeclarationApiBillingServiceImpl extends Service implements TaxD private TempPropertiesWrapper getUserInfoAndTaxAgentMap(List list) { Map employeeTaxAgentMap = SalaryEntityUtil.convert2Map(list, TaxDeclarationApiFlowRecordPO::getEmployeeId, TaxDeclarationApiFlowRecordPO::getTaxAgentId); // 获取人员信息 - List employeeComInfos =getSalaryEmployeeService(user).getEmployeeByIdsAll(new ArrayList<>(employeeTaxAgentMap.keySet())); + List employeeComInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(new ArrayList<>(employeeTaxAgentMap.keySet())); Map empNameMap = SalaryEntityUtil.convert2Map(employeeComInfos, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); Map empIdNoMap = getSalaryEmployeeService(user).mapByEmployeeIds(employeeTaxAgentMap.keySet()); List extEmployeePOS = getExtEmpService(user).listAll(); @@ -123,48 +126,36 @@ public class TaxDeclarationApiBillingServiceImpl extends Service implements TaxD return build; } -// @Override -// public void exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam, Map map) { -// ExportWrapper exportWrapper = new ExportWrapper(map, employeeId, tenantKey); -// // 表头 -// List 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 dtoList = listFlowRecord(queryParam, employeeId, tenantKey); -// // 组装数据 -// for (TaxDeclarationApiFlowRecordListDTO dto : dtoList) { -// List 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> rows = new ArrayList<>(); + // 表头 + List 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 dtoList = listFlowRecord(queryParam); + // 组装数据 + for (TaxDeclarationApiFlowRecordListDTO dto : dtoList) { + List 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()); -// } -// /** * 封装一些临时的集合类,便于方法复用 @@ -196,7 +187,7 @@ public class TaxDeclarationApiBillingServiceImpl extends Service implements TaxD // 接口类型 private EnumDeclareApiBusinessType businessType; - public ApiFlowUpdateWrapper(Date taxYearMonth, TaxDeclarationApiConfigPO apiConfig, EnumDeclareApiBusinessType businessType,Long currentEmployeeId) { + public ApiFlowUpdateWrapper(Date taxYearMonth, TaxDeclarationApiConfigPO apiConfig, EnumDeclareApiBusinessType businessType, Long currentEmployeeId) { this.taxYearMonth = taxYearMonth; this.apiFlowDetailPOList = new ArrayList<>(); this.apiConfig = apiConfig; diff --git a/src/com/engine/salary/service/impl/TaxDeclarationApiFlowStatisticServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationApiFlowStatisticServiceImpl.java index 26bb2777f..2a2e51fed 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationApiFlowStatisticServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationApiFlowStatisticServiceImpl.java @@ -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 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 map, List dtoList) { -// ExportWrapper exportWrapper = new ExportWrapper(map, employeeId, tenantKey); -// // 表头 -// List 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 row = new ArrayList<>(); -// row.add(dto.getTaxAgentName()); -// row.add(dto.getUsed()); -// exportWrapper.getRows().add(row); -// } -// // 生成表格 -// buildExcelData(exportWrapper); -// } + @Override + public XSSFWorkbook exportFlowStatistics(List dtoList) { -// @Override -// public void exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Map map, List dtoList) { -// ExportWrapper exportWrapper = new ExportWrapper(map, employeeId, tenantKey); -// // 表头 -// List 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 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> rows = new ArrayList<>(); + // 表头 + List headers = new ArrayList<>(); + headers.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人")); + headers.add(SalaryI18nUtil.getI18nLabel(159084, "已使用流量")); + rows.add(headers); + // 组装数据 + for (TaxDeclarationApiFlowStatisticListDTO dto : dtoList) { + List row = new ArrayList<>(); + row.add(dto.getTaxAgentName()); + row.add(dto.getUsed()); + rows.add(row); + } + // 生成表格 + return ExcelUtil.genWorkbookV2(rows, "接口流量统计数据"); + } + + @Override + public XSSFWorkbook exportFlowStatisticsDetail(List dtoList) { + List> rows = new ArrayList<>(); + // 表头 + List headers = new ArrayList<>(); + headers.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人")); + headers.add(SalaryI18nUtil.getI18nLabel(86176, "税款所属期")); + headers.add(SalaryI18nUtil.getI18nLabel(159087, "月使用流量数")); + // 组装数据 + for (TaxDeclarationApiFlowStatisticDetailListDTO dto : dtoList) { + List 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) { diff --git a/src/com/engine/salary/web/TaxDeclarationApiFlowController.java b/src/com/engine/salary/web/TaxDeclarationApiFlowController.java index 0fdcad304..b4f543da0 100644 --- a/src/com/engine/salary/web/TaxDeclarationApiFlowController.java +++ b/src/com/engine/salary/web/TaxDeclarationApiFlowController.java @@ -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>(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>(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; + } + } + } diff --git a/src/com/engine/salary/web/TaxDeclarationApiFlowStatisticController.java b/src/com/engine/salary/web/TaxDeclarationApiFlowStatisticController.java index d9591b2e9..184920487 100644 --- a/src/com/engine/salary/web/TaxDeclarationApiFlowStatisticController.java +++ b/src/com/engine/salary/web/TaxDeclarationApiFlowStatisticController.java @@ -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 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(user).run(getTaxDeclarationApiFlowStatisticWrapper(user)::getFlowStatistics); + } /** * 接口流量使用明细 @@ -58,19 +72,40 @@ public class TaxDeclarationApiFlowStatisticController { return new ResponseResult>(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>(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>(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; + } + } } diff --git a/src/com/engine/salary/wrapper/TaxDeclarationApiFlowBillingWrapper.java b/src/com/engine/salary/wrapper/TaxDeclarationApiFlowBillingWrapper.java index e5c8d3ceb..81685df79 100644 --- a/src/com/engine/salary/wrapper/TaxDeclarationApiFlowBillingWrapper.java +++ b/src/com/engine/salary/wrapper/TaxDeclarationApiFlowBillingWrapper.java @@ -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; + /** * 个税申报计费 *

Copyright: Copyright (c) 2023

@@ -57,24 +62,11 @@ public class TaxDeclarationApiFlowBillingWrapper extends Service { return page; } -// public Map exportFlowRecord(TaxDeclarationApiFlowRecordQueryParam queryParam, Long employeeId, String tenantKey) { -// List dtoList = taxDeclarationApiBillingService.listFlowRecord(queryParam, employeeId, tenantKey); -// SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel( 95795, "数据不存在")); -// // 构建异步导出参数 -// Map 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 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); diff --git a/src/com/engine/salary/wrapper/TaxDeclarationApiFlowStatisticWrapper.java b/src/com/engine/salary/wrapper/TaxDeclarationApiFlowStatisticWrapper.java index 380686a03..4129ea15e 100644 --- a/src/com/engine/salary/wrapper/TaxDeclarationApiFlowStatisticWrapper.java +++ b/src/com/engine/salary/wrapper/TaxDeclarationApiFlowStatisticWrapper.java @@ -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 exportFlowStatistics(Long employeeId, String tenantKey) { -// List dtoList = getTaxDeclarationApiFlowStatisticService(user).listFlowStatistic(tenantKey, employeeId); -// SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 95795, "数据不存在")); -// // 构建异步导出参数 -// Map 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 exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam, Long employeeId, String tenantKey) { -// List dtoList = getTaxDeclarationApiFlowStatisticService(user).listFlowStatisticDetail(queryParam, employeeId, tenantKey); -// SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 95795, "数据不存在")); -// // 构建异步导出参数 -// Map 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 dtoList = getTaxDeclarationApiFlowStatisticService(user).listFlowStatistic(); + SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel(95795, "数据不存在")); + return getTaxDeclarationApiFlowStatisticService(user).exportFlowStatistics(dtoList); + } + + public XSSFWorkbook exportFlowStatisticsDetail(TaxDeclarationApiFlowMonthQueryParam queryParam) { + List dtoList = getTaxDeclarationApiFlowStatisticService(user).listFlowStatisticDetail(queryParam); + SalaryAssert.notEmpty(dtoList, SalaryI18nUtil.getI18nLabel(95795, "数据不存在")); + return getTaxDeclarationApiFlowStatisticService(user).exportFlowStatisticsDetail(dtoList); + } }