| | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | } |