|  |  |  | 
|---|
|  |  |  | import doumeemes.core.model.ApiResponse; | 
|---|
|  |  |  | import doumeemes.core.model.PageWrap; | 
|---|
|  |  |  | import doumeemes.core.model.PageData; | 
|---|
|  |  |  | import doumeemes.core.utils.DateUtil; | 
|---|
|  |  |  | import doumeemes.dao.business.model.SalaryParam; | 
|---|
|  |  |  | import doumeemes.dao.business.vo.SalaryParamVO; | 
|---|
|  |  |  | import doumeemes.dao.ext.dto.SalaryParamDTO; | 
|---|
|  |  |  | import doumeemes.service.business.SalaryParamService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartFile; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartHttpServletRequest; | 
|---|
|  |  |  | import org.springframework.web.multipart.commons.CommonsMultipartResolver; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.time.format.DateTimeFormatter; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Iterator; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/updateById") | 
|---|
|  |  |  | @RequiresPermissions("business:salaryparam:update") | 
|---|
|  |  |  | public ApiResponse updateById(@RequestBody SalaryParam salaryParam) { | 
|---|
|  |  |  | salaryParamService.updateById(salaryParam); | 
|---|
|  |  |  | salaryParamService.update(salaryParam); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/exportExcel") | 
|---|
|  |  |  | @RequiresPermissions("business:salaryparam:exportExcel") | 
|---|
|  |  |  | public void exportExcel (@RequestBody PageWrap<SalaryParamDTO> pageWrap, HttpServletResponse response) { | 
|---|
|  |  |  | ExcelExporter.build(SalaryParamVO.class).export(salaryParamService.findPage(pageWrap).getRecords(), "设置类-绩效工资配置表", response); | 
|---|
|  |  |  | ExcelExporter.build(SalaryParamVO.class).export(salaryParamService.findPage(pageWrap).getRecords(), "设置类-绩效工资配置表"+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")), response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID查询") | 
|---|
|  |  |  | 
|---|
|  |  |  | public ApiResponse findById(@PathVariable Integer id) { | 
|---|
|  |  |  | return ApiResponse.success(salaryParamService.findById(id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "批量导入计划", notes = "批量导入计划", httpMethod = "POST", position = 6) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "folder", value = "文件夹", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @PostMapping(value = "/importBatch", headers = "content-type=multipart/form-data") | 
|---|
|  |  |  | //    @RequiresPermissions("business:salaryparam:create") | 
|---|
|  |  |  | public ApiResponse importBatch(String folder, HttpServletRequest request, HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | CommonsMultipartResolver multipartResovler = new CommonsMultipartResolver(); | 
|---|
|  |  |  | if (multipartResovler.isMultipart(request)) { | 
|---|
|  |  |  | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; | 
|---|
|  |  |  | Iterator<String> it = multipartRequest.getFileNames(); | 
|---|
|  |  |  | while (it.hasNext()) { | 
|---|
|  |  |  | MultipartFile file = multipartRequest.getFile((String) it.next()); | 
|---|
|  |  |  | salaryParamService.importPlans(file); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ApiResponse.success( null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|