| | |
| | | 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.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 |
| | |
| | | @Autowired |
| | | private CompensationPerformanceService compensationPerformanceService; |
| | | |
| | | @Autowired |
| | | private StaffOnJobMapper staffOnJobMapper; |
| | | |
| | | @GetMapping("/listPage") |
| | | @Log(title = "薪酬绩效-分页查询", businessType = BusinessType.OTHER) |
| | | @ApiOperation("薪酬绩效-分页查询") |
| | | public AjaxResult listPage(Page page, CompensationPerformance compensationPerformance){ |
| | | IPage<CompensationPerformance> listPage = compensationPerformanceService.listPage(page, compensationPerformance); |
| | | public AjaxResult listPage(Page page, String staffName, String payDateStr) { |
| | | IPage<CompensationPerformance> listPage = compensationPerformanceService.listPage(page, staffName, payDateStr); |
| | | return AjaxResult.success(listPage); |
| | | } |
| | | |
| | |
| | | @Log(title = "薪酬绩效-添加", businessType = BusinessType.INSERT) |
| | | @ApiOperation("薪酬绩效-添加") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult add(@RequestBody CompensationPerformance compensationPerformance){ |
| | | public AjaxResult add(@RequestBody CompensationPerformance compensationPerformance) { |
| | | boolean save = compensationPerformanceService.save(compensationPerformance); |
| | | return save ? AjaxResult.success("添加成功") : AjaxResult.error("添加失败"); |
| | | } |
| | |
| | | @Log(title = "薪酬绩效-修改", businessType = BusinessType.UPDATE) |
| | | @ApiOperation("薪酬绩效-修改") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult update(@RequestBody CompensationPerformance compensationPerformance){ |
| | | public AjaxResult update(@RequestBody CompensationPerformance compensationPerformance) { |
| | | boolean update = compensationPerformanceService.updateById(compensationPerformance); |
| | | return update ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败"); |
| | | } |
| | |
| | | @Log(title = "薪酬绩效-删除", businessType = BusinessType.DELETE) |
| | | @ApiOperation("薪酬绩效-删除") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult delete(@RequestBody List<Long> ids){ |
| | | if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("请传入要删除的ID"); |
| | | public AjaxResult delete(@RequestBody List<Long> ids) { |
| | | if (CollectionUtils.isEmpty(ids)) return AjaxResult.error("请传入要删除的ID"); |
| | | boolean delete = compensationPerformanceService.removeBatchByIds(ids); |
| | | 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); |
| | | public void export(HttpServletResponse response) { |
| | | List<CompensationPerformance> list = compensationPerformanceService.exportList(); |
| | | ExcelUtil<CompensationPerformance> util = new ExcelUtil<>(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, "下载薪资管理列表模板"); |
| | | } |
| | | |
| | | @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 -> { |
| | | StaffOnJob staffOnJob = staffOnJobMapper.selectStaffByNickName(item.getStaffName()); |
| | | if (staffOnJob != null) { |
| | | item.setStaffId(staffOnJob.getId()); |
| | | } |
| | | }); |
| | | boolean b = compensationPerformanceService.saveBatch(list); |
| | | return AjaxResult.success(b); |
| | | } |
| | | |
| | | |
| | | } |