| | |
| | | package com.ruoyi.compensationperformance.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.compensationperformance.pojo.CompensationPerformance; |
| | | import com.ruoyi.compensationperformance.service.CompensationPerformanceService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.purchase.dto.PaymentRegistrationDto; |
| | | import com.ruoyi.staff.mapper.StaffOnJobMapper; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | return delete ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败"); |
| | | } |
| | | |
| | | @Log(title = "导出薪资管理列表", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response ) { |
| | | List<CompensationPerformance> list = compensationPerformanceService.list(); |
| | | ExcelUtil<CompensationPerformance> util = new ExcelUtil<CompensationPerformance>(CompensationPerformance.class); |
| | | util.exportExcel(response, list, "导出薪资管理列表"); |
| | | } |
| | | |
| | | @Log(title = "下载薪资管理列表模板", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/exportTemplate") |
| | | public void exportTemplate(HttpServletResponse response) { |
| | | List<CompensationPerformance> list = new ArrayList<>(); |
| | | ExcelUtil<CompensationPerformance> util = new ExcelUtil<>(CompensationPerformance.class); |
| | | util.exportExcel(response, list, "下载薪资管理列表模板"); |
| | | } |
| | | |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Log(title = "导入薪资管理列表", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(MultipartFile file) throws Exception { |
| | | ExcelUtil<CompensationPerformance> util = new ExcelUtil<>(CompensationPerformance.class); |
| | | List<CompensationPerformance> list = util.importExcel(file.getInputStream()); |
| | | list.forEach(item->{ |
| | | SysUser staffOnJob = sysUserMapper.selectUserByNickName(item.getName()); |
| | | if(staffOnJob!=null){ |
| | | item.setStaffId(staffOnJob.getUserId()); |
| | | } |
| | | }); |
| | | boolean b = compensationPerformanceService.saveBatch(list); |
| | | return AjaxResult.success(b); |
| | | } |
| | | |
| | | |
| | | } |