| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.applet.dto.*; |
| | | import com.ruoyi.system.applet.query.AppealListQuery; |
| | | import com.ruoyi.system.applet.query.KnowledgeListUserQuery; |
| | | import com.ruoyi.system.applet.query.LeaveListUserQuery; |
| | | import com.ruoyi.system.applet.query.TaskUserListQuery; |
| | | import com.ruoyi.system.applet.query.*; |
| | | import com.ruoyi.system.applet.vo.*; |
| | | import com.ruoyi.system.dto.KnowledgeDTO; |
| | | import com.ruoyi.system.dto.TTaskAuditBatchDTO; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private TFeedbackService feedbackService; |
| | | @Resource |
| | | private TProblemEscalationService problemEscalationService; |
| | | @Resource |
| | | private TNoticeService noticeService; |
| | | |
| | | @ApiOperation(value = "消息通知列表") |
| | | @PostMapping(value = "/noticeList") |
| | | public R<PageInfo<NoticeListVO>> noticeList(@RequestBody NoticeListQuery query) { |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | query.setUserId(userId + ""); |
| | | PageInfo<NoticeListVO> noticeListVOPageInfo = noticeService.noticeList(query); |
| | | List<NoticeListVO> records = noticeListVOPageInfo.getRecords(); |
| | | List<NoticeListVO> noticeListVOS = new ArrayList<>(records); |
| | | for (NoticeListVO noticeListVO : noticeListVOS) { |
| | | noticeListVO.setStatus(2); |
| | | noticeService.updateById(noticeListVO); |
| | | } |
| | | return R.ok(noticeListVOPageInfo); |
| | | } |
| | | |
| | | /** |
| | | * 生成数据 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "测试接口不要调") |
| | | |
| | | @GetMapping(value = "/testData") |
| | | public R<AppealDetailVO> testData(@RequestParam String id) { |
| | | // List<TAppeal> tAppeals = new ArrayList<>(); |
| | | // for (int i = 0; i < 25; i++) { |
| | | // TAppeal tAppeal = new TAppeal(); |
| | | // tAppeal.setTaskId("1938536771253641217"); |
| | | // tAppeal.setAppealPerson("152"); |
| | | // tAppeal.setStatus(1); |
| | | // tAppeal.setAppealContent("申诉"); |
| | | // tAppeal.setPictures("https://bjxj.oss-cn-guangzhou.aliyuncs.com/bjxj/88d2d5614fe6492bba5666a7ab01e76b.png"); |
| | | // tAppeals.add(tAppeal); |
| | | // } |
| | | // appealService.saveBatch(tAppeals); |
| | | // List<TAppeal> tAppeals1 = new ArrayList<>(); |
| | | // for (int i = 0; i < 25; i++) { |
| | | // TAppeal tAppeal = new TAppeal(); |
| | | // tAppeal.setTaskId("1938536771253641217"); |
| | | // tAppeal.setAppealPerson("152"); |
| | | // tAppeal.setStatus(2); |
| | | // tAppeal.setAppealContent("申诉"); |
| | | // tAppeal.setPictures("https://bjxj.oss-cn-guangzhou.aliyuncs.com/bjxj/88d2d5614fe6492bba5666a7ab01e76b.png"); |
| | | // tAppeal.setAuditPerson("162"); |
| | | // tAppeal.setAuditRemark("备注"); |
| | | // tAppeal.setAuditTime(LocalDateTime.now()); |
| | | // tAppeals1.add(tAppeal); |
| | | // } |
| | | // appealService.saveBatch(tAppeals1); |
| | | // List<TAppeal> tAppeals2 = new ArrayList<>(); |
| | | // for (int i = 0; i < 25; i++) { |
| | | // TAppeal tAppeal = new TAppeal(); |
| | | // tAppeal.setTaskId("1938536771253641217"); |
| | | // tAppeal.setAppealPerson("152"); |
| | | // tAppeal.setStatus(3); |
| | | // tAppeal.setAppealContent("申诉"); |
| | | // tAppeal.setPictures("https://bjxj.oss-cn-guangzhou.aliyuncs.com/bjxj/88d2d5614fe6492bba5666a7ab01e76b.png"); |
| | | // tAppeal.setAuditPerson("162"); |
| | | // tAppeal.setAuditRemark("备注"); |
| | | // tAppeal.setAuditTime(LocalDateTime.now()); |
| | | // tAppeals2.add(tAppeal); |
| | | // } |
| | | // appealService.saveBatch(tAppeals2); |
| | | // List<TAppeal> tAppeals3 = new ArrayList<>(); |
| | | // for (int i = 0; i < 25; i++) { |
| | | // TAppeal tAppeal = new TAppeal(); |
| | | // tAppeal.setTaskId("1938536771253641217"); |
| | | // tAppeal.setAppealPerson("152"); |
| | | // tAppeal.setStatus(4); |
| | | // tAppeal.setAppealContent("申诉"); |
| | | // tAppeal.setPictures("https://bjxj.oss-cn-guangzhou.aliyuncs.com/bjxj/88d2d5614fe6492bba5666a7ab01e76b.png"); |
| | | // |
| | | // tAppeals3.add(tAppeal); |
| | | // |
| | | // } |
| | | // appealService.saveBatch(tAppeals3); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "个人中心-首页") |
| | | @PostMapping(value = "/userIndex") |
| | | public R<UserIndexVO> userIndex() { |
| | | UserIndexVO userIndexVO = new UserIndexVO(); |
| | | |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | SysUser sysUser = sysUserService.selectUserById(userId); |
| | | userIndexVO.setAvatar(sysUser.getAvatar()); |
| | | userIndexVO.setNickName(sysUser.getNickName()); |
| | | userIndexVO.setPhonenumber(sysUser.getPhonenumber()); |
| | | if (sysUser.getDeptType() == 1) { |
| | | TProjectDept tProjectDept = projectDeptService.getById(sysUser.getDeptId()); |
| | | if (!tProjectDept.getParentId().equals("0")) { |
| | | TProjectDept tProjectDept1 = projectDeptService.getById(tProjectDept.getParentId()); |
| | | userIndexVO.setDeptName(tProjectDept1.getProjectName() + ">" + tProjectDept.getProjectName()); |
| | | } else { |
| | | userIndexVO.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | } else { |
| | | TDept tDept = deptService.getById(sysUser.getDeptId()); |
| | | if (tDept != null) { |
| | | userIndexVO.setDeptName(tDept.getDeptName()); |
| | | } |
| | | } |
| | | // 查询请假状态 |
| | | List<TLeave> list = leaveService.lambdaQuery().eq(TLeave::getLeavePerson, userId) |
| | | .eq(TLeave::getAuditStatus, 2) |
| | | .list(); |
| | | userIndexVO.setIsLeave(0); |
| | | for (TLeave tLeave : list) { |
| | | LocalDate now = LocalDate.now(); |
| | | LocalDate startDate = tLeave.getStartTime().toLocalDate(); |
| | | LocalDate endDate = tLeave.getStartTime().toLocalDate(); |
| | | if (now.isAfter(startDate) && now.isBefore(endDate)) { |
| | | userIndexVO.setIsLeave(1); |
| | | } else if (now.isEqual(startDate) || now.isEqual(endDate)) { |
| | | userIndexVO.setIsLeave(1); |
| | | } |
| | | } |
| | | // 获取本月第一天凌晨00:00:00 和本月最后一天23:59:59 类型为LocalDateTime |
| | | // 获取当前日期 |
| | | LocalDate now = LocalDate.now(); |
| | | // 本月第一天 |
| | | LocalDate firstDayOfMonth = now.withDayOfMonth(1); |
| | | // 本月最后一天 |
| | | LocalDate lastDayOfMonth = now.withDayOfMonth(now.lengthOfMonth()); |
| | | // 转换为 LocalDateTime:第一天的 00:00:00 |
| | | LocalDateTime startOfMonth = LocalDateTime.of(firstDayOfMonth, LocalTime.MIN); |
| | | // 转换为 LocalDateTime:最后一天的 23:59:59 |
| | | LocalDateTime endOfMonth = LocalDateTime.of(lastDayOfMonth, LocalTime.MAX); |
| | | List<TTask> finishTask = taskCleanerService.lambdaQuery().eq(TTask::getPatrolInspector, userId) |
| | | .ge(TTask::getImplementTime, startOfMonth) |
| | | .le(TTask::getImplementTime, endOfMonth).list(); |
| | | List<String> taskIds = finishTask.stream().map(TTask::getId).collect(Collectors.toList()); |
| | | if (taskIds.isEmpty()){ |
| | | taskIds.add("-1"); |
| | | } |
| | | List<TTaskDetail> taskDetails = taskDetailService.lambdaQuery() |
| | | .eq(TTaskDetail::getAuditStatus, 1).in(TTaskDetail::getTaskId, taskIds) |
| | | .isNotNull(TTaskDetail::getClearStatus) |
| | | .groupBy(TTaskDetail::getTaskId) |
| | | .orderByDesc(TTaskDetail::getCreateTime).list(); |
| | | |
| | | int size = (int) finishTask.stream().filter(e -> e.getStatus() == 5 || e.getStatus() == 6).count(); |
| | | userIndexVO.setFinishCount(size); |
| | | List<TTaskDetail> status1 = taskDetails.stream().filter(e -> e.getClearStatus() == 1).collect(Collectors.toList()); |
| | | List<TTaskDetail> status2 = taskDetails.stream().filter(e -> e.getClearStatus() == 2).collect(Collectors.toList()); |
| | | if (!status1.isEmpty()) { |
| | | BigDecimal divide = new BigDecimal(status1.size() + status2.size()) |
| | | .divide(new BigDecimal(status1.size()), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)); |
| | | userIndexVO.setRate(divide); |
| | | } else { |
| | | userIndexVO.setRate(new BigDecimal(0)); |
| | | } |
| | | // todo 月排名 |
| | | userIndexVO.setRanking(0); |
| | | return R.ok(userIndexVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "任务记录分页列表") |
| | | @PostMapping(value = "/taskList") |
| | | public R<PageInfo<TaskUserListVO>> pageList(@RequestBody TaskUserListQuery query) { |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | query.setUserId(userId+""); |
| | | query.setUserId(userId + ""); |
| | | return R.ok(taskCleanerService.pageListUser(query)); |
| | | } |
| | | |
| | |
| | | taskDetailVO.setLocationIcon(byId2.getLocationIcon()); |
| | | taskDetailVO.setLocationName(byId2.getLocationName()); |
| | | TTaskDetail tTaskDetail = list.stream().filter(e -> e.getHandleType() == 1).findFirst().orElse(null); |
| | | if (tTaskDetail!=null && tTaskDetail.getUnqualified()!=null){ |
| | | TTaskDetail tTaskDetailFinish = list.stream().filter(e -> e.getHandleType() == 2).findFirst().orElse(null); |
| | | if (tTaskDetail != null && tTaskDetail.getUnqualified() != null) { |
| | | TDictData byId3 = dictDataService.getById(tTaskDetail.getUnqualified()); |
| | | if (byId3!=null){ |
| | | if (byId3 != null) { |
| | | tTaskDetail.setUnqualifiedName(byId3.getDataContent()); |
| | | } |
| | | } |
| | | if (tTaskDetailFinish != null) { |
| | | tTaskDetailFinish.setFinishTime(tTaskDetailFinish.getCreateTime()); |
| | | } |
| | | taskDetailVO.setTaskDetail(tTaskDetail); |
| | | taskDetailVO.setRecords(list); |
| | | return R.ok(taskDetailVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "详情任务-操作记录-详情") |
| | | @GetMapping(value = "/detailRecord") |
| | | public R<TaskRecordDetailVO> detailRecord(@RequestParam String id) { |
| | |
| | | taskDetailVO.setLocationAddress(byId1.getLocationAddress()); |
| | | taskDetailVO.setLocationIcon(byId2.getLocationIcon()); |
| | | taskDetailVO.setLocationName(byId2.getLocationName()); |
| | | if ( byId4.getUnqualified()!=null){ |
| | | if (byId4.getUnqualified() != null) { |
| | | TDictData byId3 = dictDataService.getById(byId4.getUnqualified()); |
| | | if (byId3!=null){ |
| | | if (byId3 != null) { |
| | | byId4.setUnqualifiedName(byId3.getDataContent()); |
| | | } |
| | | } |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(byId4.getAuditPerson())); |
| | | if (sysUser!=null){ |
| | | if (sysUser != null) { |
| | | byId4.setAuditPersonName(sysUser.getUserName()); |
| | | } |
| | | taskDetailVO.setTaskDetail(byId4); |
| | | return R.ok(taskDetailVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "申诉记录分页列表") |
| | | @PostMapping(value = "/appealList") |
| | | public R<PageInfo<AppealListVO>> pageListUser(@RequestBody AppealListQuery query) { |
| | | query.setUserId(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | return R.ok(appealService.pageListUser(query)); |
| | | } |
| | | |
| | | @ApiOperation(value = "详情申诉记录") |
| | | @GetMapping(value = "/appealDetail") |
| | | public R<AppealDetailVO> appealDetail(@RequestParam String id) { |
| | | AppealDetailVO appealDetailVO = new AppealDetailVO(); |
| | | TAppeal appeal = appealService.getById(id); |
| | | BeanUtils.copyProperties(appeal,appealDetailVO); |
| | | BeanUtils.copyProperties(appeal, appealDetailVO); |
| | | TTask byId = taskCleanerService.getById(appeal.getTaskId()); |
| | | TLocation byId1 = locationService.getById(byId.getLocationId()); |
| | | TLocationType byId2 = locationTypeService.getById(byId1.getLocationType()); |
| | |
| | | appealDetailVO.setLocationIcon(byId2.getLocationIcon()); |
| | | appealDetailVO.setLocationName(byId2.getLocationName()); |
| | | appealDetailVO.setTaskId(byId.getId()); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(appeal.getAuditPerson())); |
| | | if (sysUser!=null){ |
| | | appealDetailVO.setAuditPersonName(sysUser.getUserName()); |
| | | if (StringUtils.hasLength(appeal.getAuditPerson())) { |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(appeal.getAuditPerson())); |
| | | if (sysUser != null) { |
| | | appealDetailVO.setAuditPersonName(sysUser.getUserName()); |
| | | } |
| | | } |
| | | appealDetailVO.setTaskName(byId.getTaskName()); |
| | | appealDetailVO.setTaskCode(byId.getTaskCode()); |
| | | return R.ok(appealDetailVO); |
| | | } |
| | | |
| | | @Log(title = "取消申诉记录", businessType = BusinessType.OTHER) |
| | | @ApiOperation(value = "取消申诉记录") |
| | | @GetMapping(value = "/cancelAppeal") |
| | |
| | | appealService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取距离最近的任务列表") |
| | | @PostMapping(value = "/listAllTask") |
| | | public R<List<TaskListAllVO>> listAllTask(@RequestBody AppealListDTO appealListDTO) { |
| | | appealListDTO.setUserId(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | List<TaskListAllVO> res = appealService.listAllTask(appealListDTO); |
| | | return R.ok(res); |
| | | } |
| | | |
| | | @ApiOperation(value = "不合格原因列表") |
| | | @PostMapping(value = "/unqualifiedList") |
| | | public R<List<TDictData>> unqualifiedList() { |
| | | List<TDictData> list = dictDataService.list( |
| | | new LambdaQueryWrapper<TDictData>() |
| | | .eq(TDictData::getDataType,2) |
| | | .eq(TDictData::getDataType, 2) |
| | | ); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "上传督察任务") |
| | | @PostMapping(value = "/addInspector") |
| | | public R<Boolean> addInspector(@RequestBody InspectorAddDTO dto) { |
| | | dto.setCommit_person(tokenService.getLoginUser().getUserId()+""); |
| | | if (dto.getClearStatus()==1){ |
| | | TTask task = taskCleanerService.getById(dto.getTaskId()); |
| | | TLocation location = locationService.getById(task.getLocationId()); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(task.getPatrolInspector())); |
| | | dto.setCommitPerson(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | if (dto.getClearStatus() == 1) { |
| | | dto.setStatus(4); |
| | | }else{ |
| | | } else { |
| | | dto.setStatus(1); |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(sysUser.getUserId()+""); |
| | | tNotice.setNoticeContent("【"+location.getLocationName()+"】任务督察不合格,请及时整改!"); |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(dto.getTaskId()); |
| | | tNotice.setNoticeType(8); |
| | | noticeService.save(tNotice); |
| | | } |
| | | inspectorService.save(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "上传意见反馈") |
| | | @PostMapping(value = "/addFeedback") |
| | | public R<Boolean> addFeedback(@RequestBody FeedbackDTO dto) { |
| | | dto.setFeedbackPerson(tokenService.getLoginUser().getUserId()+""); |
| | | dto.setFeedbackPerson(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | feedbackService.save(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "上传问题上报") |
| | | @PostMapping(value = "/addProblem") |
| | | public R<Boolean> addProblem(@RequestBody ProblemDTO dto) { |
| | | dto.setEscalationId(tokenService.getLoginUser().getUserId()+""); |
| | | dto.setEscalationId(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | problemEscalationService.save(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "问题类型列表") |
| | | @PostMapping(value = "/problemList") |
| | | public R<List<TDictData>> problemList() { |
| | | List<TDictData> list = dictDataService.list( |
| | | new LambdaQueryWrapper<TDictData>() |
| | | .eq(TDictData::getDataType,3) |
| | | .eq(TDictData::getDataType, 3) |
| | | ); |
| | | return R.ok(list); |
| | | } |
| | |
| | | public R<PageInfo<KnowledgeVO>> pageList(@RequestBody KnowledgeListUserQuery query) { |
| | | |
| | | |
| | | return R.ok( knowledgeService.pageListUser(query)); |
| | | return R.ok(knowledgeService.pageListUser(query)); |
| | | } |
| | | |
| | | @ApiOperation(value = "详情环卫知识") |
| | |
| | | knowledgeService.updateById(byId); |
| | | return R.ok(byId); |
| | | } |
| | | |
| | | @ApiOperation(value = "发起请假-获取审批流程") |
| | | @GetMapping(value = "/leaveAuditList") |
| | | public R<LeaveAuditListVO> leaveAuditList() { |
| | | LeaveAuditListVO res = new LeaveAuditListVO(); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | SysUser user = sysUserService.selectUserById(userId); |
| | | Long userRole = sysUserService.getUserRole(userId); |
| | | SysRole sysRole = roleService.selectRoleById(userRole); |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | |
| | | SysUser auditPerson = sysUserService.selectUserById(999L); |
| | | //项目负责人、部门负责人、公司成员提交由最终审批人审批; |
| | | if (user.getDeptType()==2 ||sysRole.getRoleName().contains("项目负责人")||sysRole.getRoleName().contains("部门负责人")){ |
| | | if (user.getDeptType() == 2 || sysRole.getRoleName().contains("项目负责人") || sysRole.getRoleName().contains("部门负责人")) { |
| | | LeaveAuditVO tLeaveAudit = new LeaveAuditVO(); |
| | | tLeaveAudit.setAvatar(auditPerson.getAvatar()); |
| | | tLeaveAudit.setNickName(auditPerson.getNickName()); |
| | | res.setAuditPerson(tLeaveAudit); |
| | | }else if (!sysRole.getRoleName().equals("部门助理")){ |
| | | res.setAuditPersonId("999"); |
| | | } else if (!sysRole.getRoleName().equals("部门助理")) { |
| | | // 审批人根据当前角色类型来 |
| | | if (sysRole.getRoleName().contains("现场负责人")||sysRole.getRoleName().contains("组长")){ |
| | | if (sysRole.getRoleName().contains("现场负责人") || sysRole.getRoleName().contains("组长")) { |
| | | List<SysUser> collect = sysUsers.stream().filter(e -> e.getDeptType() == 1 && |
| | | e.getDeptId().equals(user.getDeptId())).collect(Collectors.toList()); |
| | | for (SysUser sysUser : collect) { |
| | | Long userRole1 = sysUserService.getUserRole(sysUser.getUserId()); |
| | | SysRole sysRole1 = roleService.selectRoleById(userRole1); |
| | | if (sysRole1!=null&&sysRole1.getRoleName().equals("项目负责人")){ |
| | | if (sysRole1 != null && sysRole1.getRoleName().equals("项目负责人")) { |
| | | LeaveAuditVO tLeaveAudit = new LeaveAuditVO(); |
| | | tLeaveAudit.setAvatar(sysUser.getAvatar()); |
| | | tLeaveAudit.setNickName(sysUser.getNickName()); |
| | | res.setAuditPerson(tLeaveAudit); |
| | | res.setAuditPersonId(sysUser.getUserId() + ""); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | } else { |
| | | List<SysUser> collect = sysUsers.stream().filter(e -> e.getDeptType() == 1 && |
| | | e.getDeptId().equals(user.getDeptId())).collect(Collectors.toList()); |
| | | for (SysUser sysUser : collect) { |
| | | Long userRole1 = sysUserService.getUserRole(sysUser.getUserId()); |
| | | SysRole sysRole1 = roleService.selectRoleById(userRole1); |
| | | if (sysRole1!=null&&sysRole1.getRoleName().equals("部门负责人")){ |
| | | if (sysRole1 != null && sysRole1.getRoleName().contains("部门负责人")) { |
| | | LeaveAuditVO tLeaveAudit = new LeaveAuditVO(); |
| | | tLeaveAudit.setAvatar(sysUser.getAvatar()); |
| | | tLeaveAudit.setNickName(sysUser.getNickName()); |
| | | res.setAuditPerson(tLeaveAudit); |
| | | res.setAuditPersonId(sysUser.getUserId() + ""); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | res.setCopyPerson(leaveAuditVOS); |
| | | return R.ok(res); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String temp = "2025-06-30 00:00:00"; |
| | | // 轉化爲localdateTime |
| | | LocalDateTime parse = LocalDateTime.parse(temp, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | System.out.println(parse); |
| | | } |
| | | |
| | | @ApiOperation(value = "发起请假") |
| | | @PostMapping(value = "/addLeave") |
| | | public R addLeave(@RequestBody LeaveDTO leaveDTO) { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | // String startTime1 = leaveDTO.getStartTime1(); |
| | | // // 轉化爲LocalDateTime類型 |
| | | // leaveDTO.setStartTime(LocalDateTime.parse(startTime1, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | // String endTime1 = leaveDTO.getEndTime1(); |
| | | // // 轉化爲LocalDateTime類型 |
| | | // leaveDTO.setStartTime(LocalDateTime.parse(endTime1, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | SysUser user = sysUserService.selectUserById(userId); |
| | | Long userRole = sysUserService.getUserRole(userId); |
| | | SysRole sysRole = roleService.selectRoleById(userRole); |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | SysUser auditPerson = sysUserService.selectUserById(999L); |
| | | leaveDTO.setAuditStatus(1); |
| | | Date date = new Date(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | // 生成随机数字6位 |
| | | String format = simpleDateFormat.format(date); |
| | | leaveDTO.setCode(format + RandomUtil.randomNumbers(6)); |
| | | leaveDTO.setTemplateId(user.getTemplateId()); |
| | | leaveDTO.setLeavePerson(userId + ""); |
| | | leaveService.save(leaveDTO); |
| | | //项目负责人、部门负责人、公司成员提交由最终审批人审批; |
| | | if (user.getDeptType()==2 ||sysRole.getRoleName().contains("项目负责人")||sysRole.getRoleName().contains("部门负责人")){ |
| | | if (user.getDeptType() == 2 || sysRole.getRoleName().contains("项目负责人") || sysRole.getRoleName().contains("部门负责人")) { |
| | | TLeaveAudit tLeaveAudit1 = new TLeaveAudit(); |
| | | tLeaveAudit1.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit1.setAuditStatus(1); |
| | | tLeaveAudit1.setAuditId(auditPerson.getUserId()+""); |
| | | tLeaveAudit1.setAuditId(auditPerson.getUserId() + ""); |
| | | tLeaveAudit1.setAuditType(1); |
| | | leaveAuditService.save(tLeaveAudit1); |
| | | }else if (!sysRole.getRoleName().equals("部门助理")){ |
| | | } else if (!sysRole.getRoleName().equals("部门助理")) { |
| | | // 审批人根据当前角色类型来 |
| | | if (sysRole.getRoleName().contains("现场负责人")||sysRole.getRoleName().contains("组长")){ |
| | | if (sysRole.getRoleName().contains("现场负责人") || sysRole.getRoleName().contains("组长")) { |
| | | List<SysUser> collect = sysUsers.stream().filter(e -> e.getDeptType() == 1 && |
| | | e.getDeptId().equals(user.getDeptId())).collect(Collectors.toList()); |
| | | for (SysUser sysUser : collect) { |
| | | Long userRole1 = sysUserService.getUserRole(sysUser.getUserId()); |
| | | SysRole sysRole1 = roleService.selectRoleById(userRole1); |
| | | if (sysRole1!=null&&sysRole1.getRoleName().equals("项目负责人")){ |
| | | if (sysRole1 != null && sysRole1.getRoleName().equals("项目负责人")) { |
| | | TLeaveAudit tLeaveAudit1 = new TLeaveAudit(); |
| | | tLeaveAudit1.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit1.setAuditStatus(1); |
| | | tLeaveAudit1.setAuditId(sysUser.getUserId()+""); |
| | | tLeaveAudit1.setAuditId(sysUser.getUserId() + ""); |
| | | tLeaveAudit1.setAuditType(1); |
| | | leaveAuditService.save(tLeaveAudit1); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | } else { |
| | | List<SysUser> collect = sysUsers.stream().filter(e -> e.getDeptType() == 1 && |
| | | e.getDeptId().equals(user.getDeptId())).collect(Collectors.toList()); |
| | | for (SysUser sysUser : collect) { |
| | | Long userRole1 = sysUserService.getUserRole(sysUser.getUserId()); |
| | | SysRole sysRole1 = roleService.selectRoleById(userRole1); |
| | | if (sysRole1!=null&&sysRole1.getRoleName().equals("部门负责人")){ |
| | | if (sysRole1 != null && sysRole1.getRoleName().contains("部门负责人")) { |
| | | TLeaveAudit tLeaveAudit1 = new TLeaveAudit(); |
| | | tLeaveAudit1.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit1.setAuditStatus(1); |
| | | tLeaveAudit1.setAuditId(sysUser.getUserId()+""); |
| | | tLeaveAudit1.setAuditId(sysUser.getUserId() + ""); |
| | | tLeaveAudit1.setAuditType(1); |
| | | leaveAuditService.save(tLeaveAudit1); |
| | | } |
| | |
| | | TLeaveAudit tLeaveAudit2 = new TLeaveAudit(); |
| | | tLeaveAudit2.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit2.setAuditStatus(2); |
| | | tLeaveAudit2.setAuditId(user.getUserId()+","+auditPerson.getUserId()); |
| | | tLeaveAudit2.setAuditId(user.getUserId() + "," + auditPerson.getUserId()); |
| | | tLeaveAudit2.setAuditType(2); |
| | | tLeaveAudit2.setAuditTime(LocalDateTime.now()); |
| | | leaveAuditService.save(tLeaveAudit2); |
| | | // 新增消息 |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(leaveDTO.getAuditId()); |
| | | tNotice.setNoticeContent(user.getNickName() + "提交了请假申请,请尽快审核"); |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(leaveDTO.getId()); |
| | | tNotice.setNoticeType(6); |
| | | noticeService.save(tNotice); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "我的审批-我的申请") |
| | | @PostMapping(value = "/leaveList") |
| | | public R<PageInfo<LeaveUserListVO>> leaveList(@RequestBody LeaveListUserQuery query) { |
| | | query.setUserId(tokenService.getLoginUser().getUserId()+""); |
| | | return R.ok( leaveService.leaveList(query)); |
| | | query.setUserId(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | return R.ok(leaveService.leaveList(query)); |
| | | } |
| | | |
| | | @ApiOperation(value = "我的审批-审批") |
| | | @PostMapping(value = "/auditLeave") |
| | | public R<Boolean> auditLeave(@RequestBody LeaveAuditDTO dto) { |
| | | |
| | | dto.setAuditId(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | dto.setAuditTime(LocalDateTime.now()); |
| | | leaveService.updateById(dto); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(dto.getLeavePerson())); |
| | | TLeaveAudit leaveAudit = leaveAuditService.lambdaQuery().eq(TLeaveAudit::getLeaveId, dto.getId()) |
| | | .eq(TLeaveAudit::getAuditType, 2).one(); |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(leaveAudit.getAuditId().split(",")[0]); |
| | | tNotice.setNoticeContent(sysUser.getNickName()+"的请假申请已审核,请查收"); |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(dto.getId()); |
| | | tNotice.setNoticeType(7); |
| | | noticeService.save(tNotice); |
| | | TNotice tNotice1 = new TNotice(); |
| | | tNotice1.setUserId(leaveAudit.getAuditId().split(",")[1]); |
| | | tNotice1.setNoticeContent(sysUser.getNickName()+"的请假申请已审核,请查收"); |
| | | tNotice1.setStatus(1); |
| | | tNotice1.setDataId(dto.getId()); |
| | | tNotice1.setNoticeType(7); |
| | | noticeService.save(tNotice1); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "我的审批-详情") |
| | | @GetMapping(value = "/leaveDetail") |
| | | public R<LeaveUserDetailVO> leaveDetail(@RequestParam String id) { |
| | | public R<LeaveUserDetailVO> leaveDetail(@RequestParam String id) { |
| | | TLeave leave = leaveService.getById(id); |
| | | LeaveUserDetailVO leaveUserDetailVO = new LeaveUserDetailVO(); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.parseLong(leaveUserDetailVO.getLeavePerson())); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.parseLong(leave.getLeavePerson())); |
| | | Long userRole = sysUserService.getUserRole(sysUser.getUserId()); |
| | | SysRole sysRole = roleService.selectRoleById(userRole); |
| | | if (sysRole.getRoleName().contains("现场负责人")||sysRole.getRoleName().equals("组长")){ |
| | | if (sysUser.getDeptType() == 1){ |
| | | if (sysRole.getRoleName().contains("现场负责人") || sysRole.getRoleName().equals("组长")) { |
| | | if (sysUser.getDeptType() == 1) { |
| | | TProjectDept tProjectDept = projectDeptService.getById(sysUser.getDeptId()); |
| | | if (!tProjectDept.getParentId().equals("0")){ |
| | | if (!tProjectDept.getParentId().equals("0")) { |
| | | TProjectDept tProjectDept1 = projectDeptService.getById(tProjectDept.getParentId()); |
| | | leaveUserDetailVO.setDeptName(tProjectDept1.getProjectName()+">"+tProjectDept.getProjectName()); |
| | | }else{ |
| | | leaveUserDetailVO.setDeptName(tProjectDept1.getProjectName() + ">" + tProjectDept.getProjectName()); |
| | | } else { |
| | | leaveUserDetailVO.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | }else{ |
| | | } else { |
| | | TDept tDept = deptService.getById(sysUser.getDeptId()); |
| | | leaveUserDetailVO.setDeptName(tDept.getDeptName()); |
| | | } |
| | | }else if (sysRole.getRoleName().contains("项目负责人")){ |
| | | } else if (sysRole.getRoleName().contains("项目负责人")) { |
| | | TProjectDept tProjectDept = projectDeptService.getById(sysUser.getDeptId()); |
| | | leaveUserDetailVO.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | if (sysUser.getDeptType() == 2){ |
| | | if (sysUser.getDeptType() == 2) { |
| | | TDept byId = deptService.getById(sysUser.getDeptId()); |
| | | leaveUserDetailVO.setDeptName(byId.getDeptName()); |
| | | } |
| | | TLeave leave = leaveService.getById(id); |
| | | if (sysUser.getDeptType()==1){ |
| | | TProjectDept projectDept = projectDeptService.getById(sysUser.getDeptId()); |
| | | if (projectDept.getParentId().equals("0")){ |
| | | leaveUserDetailVO.setDeptName(projectDept.getProjectName()); |
| | | }else{ |
| | | TProjectDept projectDept1 = projectDeptService.getById(projectDept.getParentId()); |
| | | leaveUserDetailVO.setDeptName(projectDept1.getProjectName()+">"+projectDept.getProjectName()); |
| | | } |
| | | } |
| | | leaveUserDetailVO.setLeavePersonName(sysUser.getNickName()); |
| | | LeaveAuditListVO leaveAuditListVO = new LeaveAuditListVO(); |
| | | List<TLeaveAudit> list = leaveAuditService.list(new LambdaQueryWrapper<TLeaveAudit>() |
| | | .eq(TLeaveAudit::getAuditId, leave.getId())); |
| | | .eq(TLeaveAudit::getLeaveId, leave.getId())); |
| | | for (TLeaveAudit tLeaveAudit : list) { |
| | | if (tLeaveAudit.getAuditType()==1){ |
| | | if (tLeaveAudit.getAuditType() == 1) { |
| | | LeaveAuditVO leaveAuditVO = new LeaveAuditVO(); |
| | | SysUser sysUser1 = sysUserService.selectUserById(Long.valueOf(tLeaveAudit.getAuditId())); |
| | | if (sysUser1!=null){ |
| | | if (sysUser1 != null) { |
| | | leaveAuditVO.setAvatar(sysUser1.getAvatar()); |
| | | leaveAuditVO.setNickName(sysUser1.getNickName()); |
| | | } |
| | | leaveAuditVO.setCreateTime(tLeaveAudit.getAuditTime()); |
| | | leaveAuditVO.setAuditStatus(tLeaveAudit.getAuditStatus()); |
| | | leaveAuditListVO.setAuditPerson(leaveAuditVO); |
| | | }else{ |
| | | } else { |
| | | List<LeaveAuditVO> leaveAuditVOS = new ArrayList<>(); |
| | | // 抄送人 |
| | | LeaveAuditVO leaveAuditVO = new LeaveAuditVO(); |
| | |
| | | leaveUserDetailVO.setAuditTime(leave.getAuditTime()); |
| | | leaveUserDetailVO.setAuditRemark(leave.getAuditRemark()); |
| | | leaveUserDetailVO.setCode(leave.getCode()); |
| | | return R.ok( ); |
| | | return R.ok(leaveUserDetailVO); |
| | | } |
| | | } |
| | | |