| | |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.salary.vo.HrmTaxRateConfigImportExcelVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.salary.vo.HrmTaxRateConfigImportReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.salary.vo.HrmTaxRateConfigImportRespVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.salary.vo.HrmTaxRateConfigRespVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.salary.vo.HrmTaxRateConfigSaveReqVO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.salary.HrmTaxRateConfigDO; |
| | |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获取个税税率配置") |
| | | @Parameter(name = "id", description = "配置ID", required = true) |
| | | @PreAuthorize("@ss.hasPermission('hrm:tax-rate:query')") |
| | | public CommonResult<HrmTaxRateConfigRespVO> getTaxRateConfig(@RequestParam("id") Long id) { |
| | | HrmTaxRateConfigDO config = taxRateConfigService.getTaxRateConfig(id); |
| | | return success(BeanUtils.toBean(config, HrmTaxRateConfigRespVO.class)); |
| | |
| | | |
| | | @GetMapping("/list") |
| | | @Operation(summary = "获取个税税率配置列表") |
| | | @PreAuthorize("@ss.hasPermission('hrm:tax-rate:query')") |
| | | public CommonResult<List<HrmTaxRateConfigRespVO>> getTaxRateConfigList() { |
| | | List<HrmTaxRateConfigDO> list = taxRateConfigService.getTaxRateConfigList(); |
| | | return success(BeanUtils.toBean(list, HrmTaxRateConfigRespVO.class)); |
| | |
| | | @GetMapping("/get-effective") |
| | | @Operation(summary = "获取生效的个税税率配置列表(按级数排序)") |
| | | @Parameter(name = "effectiveDate", description = "生效日期", required = true) |
| | | @PreAuthorize("@ss.hasPermission('hrm:tax-rate:query')") |
| | | public CommonResult<List<HrmTaxRateConfigRespVO>> getEffectiveTaxRateConfigList( |
| | | @RequestParam("effectiveDate") LocalDate effectiveDate) { |
| | | List<HrmTaxRateConfigDO> list = taxRateConfigService.getEffectiveTaxRateConfigList(effectiveDate); |
| | | return success(BeanUtils.toBean(list, HrmTaxRateConfigRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入个税税率配置模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<HrmTaxRateConfigImportExcelVO> list = Arrays.asList( |
| | | HrmTaxRateConfigImportExcelVO.builder().name("2026年个税税率表").effectiveDate(LocalDate.of(2026, 1, 1)) |
| | | .level(1).minAmount(new BigDecimal("0")).maxAmount(new BigDecimal("36000")) |
| | | .taxRate(new BigDecimal("3")).quickDeduction(new BigDecimal("0")).status(0).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.writeTemplate(response, "个税税率配置导入模板.xls", "个税税率配置列表", |
| | | HrmTaxRateConfigImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入个税税率配置") |
| | | @PreAuthorize("@ss.hasPermission('hrm:tax-rate-config:import')") |
| | | public CommonResult<HrmTaxRateConfigImportRespVO> importExcel(@Valid HrmTaxRateConfigImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<HrmTaxRateConfigImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), HrmTaxRateConfigImportExcelVO.class); |
| | | return success(taxRateConfigService.importTaxRateConfigList(list, importReqVO)); |
| | | } |
| | | |
| | | } |