| | |
| | | package com.ruoyi.staff.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | |
| | | import com.ruoyi.staff.service.IStaffOnJobService; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 在职员工下拉(新增离职用) |
| | | * @return |
| | | */ |
| | | @GetMapping("/list") |
| | | public AjaxResult staffOnJobList() { |
| | | return AjaxResult.success(staffOnJobService.staffOnJobList()); |
| | | } |
| | | |
| | | /** |
| | | * 在职员工详情 |
| | | * @param staffNo |
| | | * @return |
| | |
| | | @GetMapping("/staffNo") |
| | | public AjaxResult staffOnJobDetail(String staffNo) { |
| | | return AjaxResult.success(staffOnJobService.staffOnJobDetail(staffNo)); |
| | | } |
| | | /** |
| | | * 在职员工导入 |
| | | */ |
| | | @PostMapping("/import") |
| | | @Log(title = "在职员工导入", businessType = BusinessType.IMPORT) |
| | | public AjaxResult importData(@RequestPart("file") MultipartFile file) { |
| | | Boolean b = staffOnJobService.importData(file); |
| | | if (b) { |
| | | return AjaxResult.success("导入成功"); |
| | | } |
| | | return AjaxResult.error("导入失败"); |
| | | } |
| | | |
| | | /** |
| | |
| | | staffOnJobService.staffOnJobExport(response, staffOnJob); |
| | | } |
| | | |
| | | /** |
| | | * 新增在职员工 |
| | | */ |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody StaffOnJob staffOnJob) { |
| | | if (staffOnJob.getStaffState() == null) { |
| | | staffOnJob.setStaffState(1); |
| | | } |
| | | return staffOnJobService.save(staffOnJob) ? AjaxResult.success() : AjaxResult.error("新增失败"); |
| | | } |
| | | |
| | | /** |
| | | * 修改在职员工 |
| | | */ |
| | | @PutMapping("/{id}") |
| | | public AjaxResult update(@PathVariable Long id, @RequestBody StaffOnJob staffOnJob) { |
| | | staffOnJob.setId(id); |
| | | return staffOnJobService.updateById(staffOnJob) ? AjaxResult.success() : AjaxResult.error("修改失败"); |
| | | } |
| | | |
| | | /** |
| | | * 删除在职员工 |
| | | */ |
| | | @DeleteMapping("/del") |
| | | public AjaxResult del(@RequestBody List<Long> ids) { |
| | | return staffOnJobService.removeByIds(ids) ? AjaxResult.success() : AjaxResult.error("删除失败"); |
| | | } |
| | | |
| | | /** |
| | | * 在职员工统计(在职人数 / 薪资合计) |
| | | */ |
| | | @GetMapping("/statistics") |
| | | public AjaxResult statistics() { |
| | | List<StaffOnJob> list = staffOnJobService.list(); |
| | | long onJobCount = list.stream() |
| | | .filter(s -> s.getStaffState() != null && s.getStaffState() == 1).count(); |
| | | java.math.BigDecimal salaryTotal = list.stream() |
| | | .filter(s -> s.getStaffState() != null && s.getStaffState() == 1 && s.getSalary() != null) |
| | | .map(StaffOnJob::getSalary) |
| | | .reduce(java.math.BigDecimal.ZERO, java.math.BigDecimal::add); |
| | | java.util.Map<String, Object> map = new java.util.HashMap<>(); |
| | | map.put("onJobCount", onJobCount); |
| | | map.put("salaryTotal", salaryTotal); |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | |
| | | } |