| | |
| | | package com.ruoyi.approve.service.impl; |
| | | |
| | | 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.approve.mapper.ApproveProcessMapper; |
| | | import com.ruoyi.approve.pojo.ApproveNode; |
| | |
| | | import com.ruoyi.approve.service.IApproveProcessService; |
| | | import com.ruoyi.approve.utils.DailyRedisCounter; |
| | | import com.ruoyi.approve.vo.ApproveGetAndUpdateVo; |
| | | import com.ruoyi.approve.vo.ApproveNodeVo; |
| | | import com.ruoyi.approve.vo.ApproveProcessVO; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | private final SysDeptMapper sysDeptMapper; |
| | | private final IApproveNodeService approveNodeService; |
| | | private final SysUserMapper sysUserMapper; |
| | | private final ApproveProcessMapper approveProcessMapper; |
| | | |
| | | @Override |
| | | public void addApprove(ApproveProcessVO approveProcessVO) { |
| | |
| | | //流程 ID |
| | | String approveID = today + formattedCount; |
| | | |
| | | //审批人姓名处理 |
| | | String approverIds = approveProcessVO.getApproverIds(); |
| | | String[] idArray = approverIds.split(","); |
| | | String approverNames = getApproverNames(approveProcessVO.getApproverIds()); |
| | | String[] namdArray = approverIds.split(","); |
| | | |
| | | ApproveProcess approveProcess = new ApproveProcess(); |
| | | approveProcess.setApproveId(approveID); |
| | | approveProcess.setApproveUser(userId); |
| | | approveProcess.setApproveDeptName(approveProcessVO.getDeptName()); |
| | | approveProcess.setApproveUserNames(approveProcessVO.getApproverNames()); |
| | | approveProcess.setApproveDeptId(approveProcessVO.getApproveDeptId()); |
| | | // approveProcess.setApproveDeptName(approveProcessVO.getDeptName()); |
| | | approveProcess.setApproveUserIds(approveProcessVO.getApproverIds()); |
| | | approveProcess.setApproveUserNames(approverNames); |
| | | approveProcess.setApproveUserCurrentId(Long.parseLong(idArray[0])); |
| | | approveProcess.setApproveUserCurrentName(namdArray[0]); |
| | | approveProcess.setApproveTime(new Date()); |
| | | approveProcess.setApproveReason(approveProcessVO.getApproveReason()); |
| | | approveProcess.setApproveOverTime(null); |
| | |
| | | approveNodeService.initApproveNodes(approveID); |
| | | } |
| | | |
| | | private String getApproverNames(String approverIds) { |
| | | String[] idArray = approverIds.split(","); |
| | | |
| | | Integer[] ids = Arrays.stream(idArray) |
| | | .map(Integer::parseInt) |
| | | .toArray(Integer[]::new); |
| | | String names = ""; |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | for (Integer id : ids) { |
| | | SysUser sysUser = sysUserMapper.selectUserById(id.longValue()); |
| | | names = stringBuilder + "," + sysUser.getUserName(); |
| | | } |
| | | return names; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<SysDept> selectDeptListByDeptIds(Long[] deptIds) { |
| | | List<SysDept> sysDeptList =new ArrayList<SysDept>(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ApproveProcess> listAll() { |
| | | public IPage<ApproveProcess> listAll(Page page) { |
| | | LambdaQueryWrapper<ApproveProcess> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ApproveProcess::getApproveDelete, 0); |
| | | return list(queryWrapper); |
| | | return approveProcessMapper.selectPage(page, queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void delApprove(Long[] ids) { |
| | | for (Long id : ids) { |
| | | LambdaQueryWrapper<ApproveProcess> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ApproveProcess::getApproveId, id); |
| | | queryWrapper.eq(ApproveProcess::getApproveDelete, 1); |
| | | update(queryWrapper); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateApproveProcessStatus(ApproveNode approveNode) { |
| | | ApproveProcess approveProcess = getById(approveNode.getApproveProcessId()); |
| | | if(approveNode.getIsFirst()){ |
| | | if(approveNode.getApproveNodeStatus() == 1){ |
| | | public void updateApproveProcessStatus(ApproveNodeVo approveNodeVo) { |
| | | ApproveNode node = approveNodeService.getById(approveNodeVo.getId()); |
| | | ApproveProcess approveProcess = getById(node.getApproveProcessId()); |
| | | |
| | | String[] idArray = approveProcess.getApproveUserIds().split(","); |
| | | String[] nameArray = approveProcess.getApproveUserNames().split(","); |
| | | |
| | | Integer noderOrder = approveNodeVo.getApproveNodeOrder(); |
| | | approveProcess.setApproveUserCurrentId(Long.parseLong(idArray[noderOrder])); |
| | | approveProcess.setApproveUserCurrentName(nameArray[noderOrder]); |
| | | |
| | | if(noderOrder.equals(1)){ |
| | | if(approveNodeVo.getApproveNodeStatus() == 1){ |
| | | approveProcess.setApproveStatus(1); |
| | | } |
| | | } |
| | | if(approveNode.getIsLast()){ |
| | | if(approveNode.getApproveNodeStatus() == 1){ |
| | | if(noderOrder.equals(idArray.length)){ |
| | | if(approveNodeVo.getApproveNodeStatus() == 1){ |
| | | approveProcess.setApproveStatus(2); |
| | | } |
| | | } |
| | | updateById(approveProcess); |
| | | |
| | | } |
| | | |