| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.LeaveListQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.system.LeaveAuditDetailVO; |
| | | import com.ruoyi.system.vo.system.LeaveDetailVO; |
| | | import com.ruoyi.system.vo.system.LeaveListVO; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RestController |
| | | @RequestMapping("/t-leave") |
| | | public class TLeaveController { |
| | | @Resource |
| | | private TLeaveService leaveService; |
| | | @Resource |
| | | private TLeaveAuditService leaveAuditService; |
| | | @Resource |
| | | private TProjectDeptService projectDeptService; |
| | | @Resource |
| | | private TDeptService deptService; |
| | | @Resource |
| | | private ISysUserService sysUserService; |
| | | @ApiOperation(value = "请假记录分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<LeaveListVO>> pageList(@RequestBody LeaveListQuery query) { |
| | | return R.ok(leaveService.pageList(query)); |
| | | } |
| | | @ApiOperation(value = "详情") |
| | | @GetMapping(value = "/detail") |
| | | public R<LeaveDetailVO> detail(@RequestParam String id) { |
| | | LeaveDetailVO leaveDetailVO = new LeaveDetailVO(); |
| | | TLeave byId = leaveService.getById(id); |
| | | BeanUtils.copyProperties(byId,leaveDetailVO); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(byId.getLeavePerson())); |
| | | if (sysUser!=null){ |
| | | leaveDetailVO.setNickName(sysUser.getNickName()); |
| | | leaveDetailVO.setPhone(sysUser.getPhonenumber()); |
| | | if (sysUser.getDeptType() == 1){ |
| | | TProjectDept tProjectDept = projectDeptService.getById(sysUser.getDeptId()); |
| | | if(tProjectDept!=null){ |
| | | if (!tProjectDept.getParentId().equals("0")){ |
| | | TProjectDept tProjectDept1 = projectDeptService.getById(tProjectDept.getParentId()); |
| | | if (tProjectDept1!=null){ |
| | | leaveDetailVO.setDeptName(tProjectDept1.getProjectName()+">"+tProjectDept.getProjectName()); |
| | | } |
| | | }else{ |
| | | leaveDetailVO.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | } |
| | | |
| | | }else{ |
| | | TDept tDept = deptService.getById(sysUser.getDeptId()); |
| | | if (tDept!=null){ |
| | | leaveDetailVO.setDeptName(tDept.getDeptName()); |
| | | } |
| | | } |
| | | } |
| | | List<TLeaveAudit> list = leaveAuditService.lambdaQuery().eq(TLeaveAudit::getLeaveId, id) |
| | | .list(); |
| | | List<LeaveAuditDetailVO> leaveAuditDetailVOS = new ArrayList<>(); |
| | | for (TLeaveAudit tLeaveAudit : list) { |
| | | LeaveAuditDetailVO leaveAuditDetailVO = new LeaveAuditDetailVO(); |
| | | BeanUtils.copyProperties(tLeaveAudit,leaveAuditDetailVO); |
| | | if (tLeaveAudit.getAuditType()==2){ |
| | | for (String s : tLeaveAudit.getAuditId().split(",")) { |
| | | SysUser sysUser1 = sysUserService.selectUserById(Long.valueOf(s)); |
| | | if (sysUser1!=null){ |
| | | leaveAuditDetailVO.setAvatar(sysUser1.getAvatar()); |
| | | leaveAuditDetailVO.setNickName(sysUser1.getNickName()); |
| | | leaveAuditDetailVOS.add(leaveAuditDetailVO); |
| | | |
| | | } |
| | | } |
| | | }else{ |
| | | SysUser sysUser1 = sysUserService.selectUserById(Long.valueOf(tLeaveAudit.getAuditId())); |
| | | // 查询审核人 |
| | | leaveAuditDetailVO.setNickName(sysUser1.getNickName()); |
| | | leaveAuditDetailVO.setAvatar(sysUser1.getAvatar()); |
| | | leaveAuditDetailVOS.add(leaveAuditDetailVO); |
| | | } |
| | | } |
| | | leaveDetailVO.setList(leaveAuditDetailVOS); |
| | | return R.ok(leaveDetailVO); |
| | | } |
| | | } |
| | | |