| | |
| | | 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.AjaxResult; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import com.ruoyi.common.core.domain.R; |
| | | 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.redis.service.RedisService; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | |
| | | import com.ruoyi.system.query.KnowledgeListQuery; |
| | | import com.ruoyi.system.query.TaskListQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.utils.wx.body.resp.Code2SessionRespBody; |
| | | import com.ruoyi.system.utils.wx.body.resq.Code2SessionResqBody; |
| | | import com.ruoyi.system.utils.wx.model.WeixinProperties; |
| | | import com.ruoyi.system.utils.wx.pojo.AppletUserDecodeData; |
| | | import com.ruoyi.system.utils.wx.pojo.AppletUserEncrypteData; |
| | | import com.ruoyi.system.utils.wx.tools.WxAppletTools; |
| | | import com.ruoyi.system.utils.wx.tools.WxUtils; |
| | | import com.ruoyi.system.vo.system.*; |
| | | import com.sun.jna.platform.win32.LMAccess; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | |
| | | * @author xiaochen |
| | | * @since 2025-05-28 |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = "个人中心") |
| | | @RestController |
| | | @RequestMapping("/t-user") |
| | |
| | | private TProblemEscalationService problemEscalationService; |
| | | @Resource |
| | | private TNoticeService noticeService; |
| | | @Autowired |
| | | private RestTemplate wxRestTemplate; |
| | | @Autowired |
| | | private WeixinProperties weixinProperties; |
| | | @Resource |
| | | private RedisService redisService; |
| | | @ApiOperation(value = "通过code获得openid,获取用户信息",tags = {"微信小程序登录"}) |
| | | @GetMapping("/openIdByJsCode") |
| | | public R<String> openIdByJsCode(@RequestParam String code) { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | SysUser sysUser = sysUserService.selectUserById(userId); |
| | | if(Objects.isNull(sysUser)){ |
| | | return R.fail("未查询到当前登录用户信息"); |
| | | } |
| | | if(StringUtils.hasLength(sysUser.getOpenId())){ |
| | | return R.ok(); |
| | | } |
| | | log.info("<<<<<<<<换取openid开始<<<<<<<<:{}", code); |
| | | WxAppletTools appletTools = new WxAppletTools(wxRestTemplate, weixinProperties, redisService); |
| | | Code2SessionRespBody body = appletTools.getOpenIdByJscode2session(new Code2SessionResqBody().build(code)); |
| | | String openid = body.getOpenid(); |
| | | sysUser.setOpenId(openid); |
| | | sysUserService.updateUser(sysUser); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "消息通知列表") |
| | | @PostMapping(value = "/noticeList") |
| | |
| | | List<TTaskDetail> taskDetails = taskDetailService.lambdaQuery() |
| | | .in(TTaskDetail::getTaskId, taskIds) |
| | | .eq(TTaskDetail::getAuditStatus, 1) |
| | | |
| | | .eq(TTaskDetail::getHandleType,1) |
| | | .isNotNull(TTaskDetail::getClearStatus) |
| | | .groupBy(TTaskDetail::getTaskId) |
| | | .orderByDesc(TTaskDetail::getCreateTime).list(); |
| | | // 使用 stream 去重,保留每个 taskId 最新的一条 |
| | | taskDetails = new ArrayList<>(taskDetails.stream() |
| | | .collect(Collectors.groupingBy( |
| | | TTaskDetail::getTaskId, |
| | | Collectors.collectingAndThen( |
| | | Collectors.toList(), |
| | | listAll -> listAll.get(0) |
| | | ) |
| | | )) |
| | | .values()); |
| | | |
| | | int size = (int) finishTask.stream().filter(e -> e.getStatus() == 5 || e.getStatus() == 6).count(); |
| | | List<String> taskIdsStatus = finishTask.stream().map(TTask::getId).collect(Collectors.toList()); |
| | | if (taskIdsStatus.isEmpty()){ |
| | | taskIdsStatus.add("-1"); |
| | | } |
| | | 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()); |
| | | List<TTaskDetail> status1 = taskDetails.stream().filter(e -> e.getClearStatus() == 1&&taskIdsStatus.contains(e.getTaskId())).collect(Collectors.toList()); |
| | | List<TTaskDetail> status2 = taskDetails.stream().filter(e -> e.getClearStatus() == 2&&taskIdsStatus.contains(e.getTaskId())).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)); |
| | | BigDecimal divide = new BigDecimal(status1.size()) |
| | | .divide(new BigDecimal(status1.size()+status2.size()), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)); |
| | | userIndexVO.setRate(divide); |
| | | } else { |
| | | userIndexVO.setRate(new BigDecimal(0)); |
| | |
| | | if (taskIdsRank.isEmpty()){ |
| | | userIndexVO.setRanking(0); |
| | | }else{ |
| | | List<TTaskDetail> taskDetailsRank = taskDetailService.lambdaQuery().in(TTaskDetail::getTaskId) |
| | | .eq(TTaskDetail::getAuditStatus, 1) |
| | | .isNotNull(TTaskDetail::getClearStatus) |
| | | .groupBy(TTaskDetail::getTaskId) |
| | | .orderByDesc(TTaskDetail::getCreateTime).list(); |
| | | |
| | | for (SysUser user : users) { |
| | | int finishCount = (int) taskRank.stream().filter(e->e.getPatrolInspector().equals(user.getUserId()+"")&&e.getStatus() == 5 || e.getStatus() == 6).count(); |
| | | int totalCount = (int) taskRank.stream().filter(e->e.getPatrolInspector().equals(user.getUserId()+"")).count(); |
| | |
| | | taskDetailVO.setLocationAddressEnd(byId1.getLocationAddressEnd()); |
| | | taskDetailVO.setLocationIcon(byId2.getLocationIcon()); |
| | | taskDetailVO.setLocationTypeName(byId2.getLocationName()); |
| | | taskDetailVO.setLocationLon(byId1.getLocationLon()); |
| | | taskDetailVO.setLocationLat(byId1.getLocationLat()); |
| | | taskDetailVO.setLocationLatEnd(byId1.getLocationLatEnd()); |
| | | taskDetailVO.setLocationLonEnd(byId1.getLocationLonEnd()); |
| | | TTaskDetail tTaskDetail = list.stream().filter(e -> e.getHandleType() == 1).findFirst().orElse(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) { |
| | | tTaskDetail.setUnqualifiedName(byId3.getDataContent()); |
| | | } |
| | | } |
| | | if (tTaskDetailFinish != null) { |
| | | tTaskDetailFinish.setFinishTime(tTaskDetailFinish.getCreateTime()); |
| | | if (tTaskDetail != null) { |
| | | tTaskDetail.setFinishTime(tTaskDetail.getCreateTime()); |
| | | } |
| | | taskDetailVO.setTaskDetail(tTaskDetail); |
| | | taskDetailVO.setRecords(list); |
| | | if (byId.getStatus()==4){ |
| | | TTaskDetail reject = taskDetailService.lambdaQuery().eq(TTaskDetail::getTaskId, id) |
| | | .eq(TTaskDetail::getHandleType,3) |
| | | .orderByDesc(BaseModel::getCreateTime).last("limit 1").one(); |
| | | if (reject!=null){ |
| | | taskDetailVO.setRejectRemark(reject.getAuditRemark()); |
| | | } |
| | | } |
| | | return R.ok(taskDetailVO); |
| | | } |
| | | |
| | |
| | | byId4.setUnqualifiedName(byId3.getDataContent()); |
| | | } |
| | | } |
| | | byId4.setFinishTime(byId4.getCreateTime()); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(byId4.getAuditPerson())); |
| | | if (sysUser != null) { |
| | | byId4.setAuditPersonName(sysUser.getUserName()); |
| | |
| | | TLocationType byId2 = locationTypeService.getById(byId1.getLocationType()); |
| | | appealDetailVO.setLocationAddress(byId1.getLocationAddress()); |
| | | appealDetailVO.setLocationIcon(byId2.getLocationIcon()); |
| | | appealDetailVO.setLocationName(byId2.getLocationName()); |
| | | appealDetailVO.setLocationName(byId1.getLocationName()); |
| | | appealDetailVO.setTaskId(byId.getId()); |
| | | appealDetailVO.setLocationTypeName(byId2.getLocationName()); |
| | | if (StringUtils.hasLength(appeal.getAuditPerson())) { |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(appeal.getAuditPerson())); |
| | | if (sysUser != null) { |
| | |
| | | @PostMapping(value = "/listAllTask") |
| | | public R<List<TaskListAllVO>> listAllTask(@RequestBody AppealListDTO appealListDTO) { |
| | | appealListDTO.setUserId(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | SysUser sysUser = sysUserService.selectUserById(tokenService.getLoginUserApplet().getUserId()); |
| | | if (sysUser.getDeptType()==2){ |
| | | // 公司部门查询所有任务 |
| | | appealListDTO.setUserId(null); |
| | | } |
| | | List<TaskListAllVO> res = appealService.listAllTask(appealListDTO); |
| | | return R.ok(res); |
| | | } |
| | |
| | | SysRole sysRole = roleService.selectRoleById(userRole); |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | SysUser auditPerson = sysUserService.selectUserById(999L); |
| | | |
| | | List<TProjectDept> paojectList = projectDeptService.lambdaQuery().eq(TProjectDept::getParentId, "0").list(); |
| | | //项目部负责人、部门负责人、公司成员提交由最终审批人审批; |
| | | if (user.getDeptType() == 2 || sysRole.getRoleName().contains("项目部负责人") || sysRole.getRoleName().contains("部门负责人")) { |
| | | LeaveAuditVO tLeaveAudit = new LeaveAuditVO(); |
| | |
| | | res.setAuditPersonId("999"); |
| | | } else if (!sysRole.getRoleName().equals("部门助理")) { |
| | | // 审批人根据当前角色类型来 |
| | | if (sysRole.getRoleName().contains("片区负责人") || sysRole.getRoleName().contains("组长/队长")||sysRole.getRoleName().contains("项目部助理")) { |
| | | List<SysUser> collect = sysUsers.stream().filter(e -> e.getDeptType() == 1 && |
| | | e.getDeptId().equals(user.getDeptId())).collect(Collectors.toList()); |
| | | if (sysRole.getRoleName().contains("片区负责人") || sysRole.getRoleName().contains("组长")|| sysRole.getRoleName().contains("队长") |
| | | ||sysRole.getRoleName().contains("项目部助理")) { |
| | | TProjectDept userDept = projectDeptService.getById(user.getDeptId()); |
| | | |
| | | List<SysUser> collect = sysUsers.stream().filter(e -> e.getDeptType() == 1).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 (userDept.getId().equals(sysUser.getDeptId())){ |
| | | // LeaveAuditVO tLeaveAudit = new LeaveAuditVO(); |
| | | // tLeaveAudit.setAvatar(sysUser.getAvatar()); |
| | | // tLeaveAudit.setNickName(sysUser.getNickName()); |
| | | // res.setAuditPerson(tLeaveAudit); |
| | | // res.setAuditPersonId(sysUser.getUserId() + ""); |
| | | // break; |
| | | // } |
| | | // } |
| | | 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; |
| | | if (!sysRole.getRoleName().contains("项目部助理")){ |
| | | if (userDept.getParentId().equals(sysUser.getDeptId())){ |
| | | LeaveAuditVO tLeaveAudit = new LeaveAuditVO(); |
| | | tLeaveAudit.setAvatar(sysUser.getAvatar()); |
| | | tLeaveAudit.setNickName(sysUser.getNickName()); |
| | | res.setAuditPerson(tLeaveAudit); |
| | | res.setAuditPersonId(sysUser.getUserId() + ""); |
| | | break; |
| | | } |
| | | }else{ |
| | | if (userDept.getId().equals(sysUser.getDeptId())){ |
| | | LeaveAuditVO tLeaveAudit = new LeaveAuditVO(); |
| | | tLeaveAudit.setAvatar(sysUser.getAvatar()); |
| | | tLeaveAudit.setNickName(sysUser.getNickName()); |
| | | res.setAuditPerson(tLeaveAudit); |
| | | res.setAuditPersonId(sysUser.getUserId() + ""); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | tLeaveAudit1.setAuditId(auditPerson.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.setAuditType(2); |
| | | tLeaveAudit2.setAuditTime(LocalDateTime.now()); |
| | | leaveAuditService.save(tLeaveAudit2); |
| | | } else if (!sysRole.getRoleName().equals("部门助理")) { |
| | | // 审批人根据当前角色类型来 |
| | | if (sysRole.getRoleName().contains("片区负责人") || sysRole.getRoleName().contains("组长/队长")||sysRole.getRoleName().contains("项目部助理")) { |
| | | List<SysUser> collect = sysUsers.stream().filter(e -> e.getDeptType() == 1 && |
| | | e.getDeptId().equals(user.getDeptId())).collect(Collectors.toList()); |
| | | if (sysRole.getRoleName().contains("片区负责人") || sysRole.getRoleName().contains("组长")|| sysRole.getRoleName().contains("队长") |
| | | ||sysRole.getRoleName().contains("项目部助理")) { |
| | | TProjectDept userDept = projectDeptService.getById(user.getDeptId()); |
| | | |
| | | List<SysUser> collect = sysUsers.stream().filter(e -> e.getDeptType() == 1).collect(Collectors.toList()); |
| | | for (SysUser sysUser : collect) { |
| | | Long userRole1 = sysUserService.getUserRole(sysUser.getUserId()); |
| | | SysRole sysRole1 = roleService.selectRoleById(userRole1); |
| | | |
| | | if (sysRole1 != null && sysRole1.getRoleName().equals("项目部负责人")) { |
| | | TLeaveAudit tLeaveAudit1 = new TLeaveAudit(); |
| | | tLeaveAudit1.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit1.setAuditStatus(1); |
| | | tLeaveAudit1.setAuditId(sysUser.getUserId() + ""); |
| | | tLeaveAudit1.setAuditType(1); |
| | | leaveAuditService.save(tLeaveAudit1); |
| | | if (!sysRole.getRoleName().contains("项目部助理")){ |
| | | if (userDept.getParentId().equals(sysUser.getDeptId())){ |
| | | LeaveAuditVO tLeaveAudit = new LeaveAuditVO(); |
| | | tLeaveAudit.setAvatar(sysUser.getAvatar()); |
| | | tLeaveAudit.setNickName(sysUser.getNickName()); |
| | | TLeaveAudit tLeaveAudit1 = new TLeaveAudit(); |
| | | tLeaveAudit1.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit1.setAuditStatus(1); |
| | | 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() + "," + sysUser.getUserId()); |
| | | tLeaveAudit2.setAuditType(2); |
| | | tLeaveAudit2.setAuditTime(LocalDateTime.now()); |
| | | leaveAuditService.save(tLeaveAudit2); |
| | | break; |
| | | } |
| | | }else{ |
| | | if (userDept.getId().equals(sysUser.getDeptId())){ |
| | | LeaveAuditVO tLeaveAudit = new LeaveAuditVO(); |
| | | tLeaveAudit.setAvatar(sysUser.getAvatar()); |
| | | tLeaveAudit.setNickName(sysUser.getNickName()); |
| | | TLeaveAudit tLeaveAudit1 = new TLeaveAudit(); |
| | | tLeaveAudit1.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit1.setAuditStatus(1); |
| | | 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() + "," + sysUser.getUserId()); |
| | | tLeaveAudit2.setAuditType(2); |
| | | tLeaveAudit2.setAuditTime(LocalDateTime.now()); |
| | | leaveAuditService.save(tLeaveAudit2); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | 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.setAuditType(2); |
| | | tLeaveAudit2.setAuditTime(LocalDateTime.now()); |
| | | leaveAuditService.save(tLeaveAudit2); |
| | | } |
| | | } |
| | | } |
| | | TLeaveAudit tLeaveAudit2 = new TLeaveAudit(); |
| | | tLeaveAudit2.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit2.setAuditStatus(2); |
| | | tLeaveAudit2.setAuditId(user.getUserId() + "," + auditPerson.getUserId()); |
| | | tLeaveAudit2.setAuditType(2); |
| | | tLeaveAudit2.setAuditTime(LocalDateTime.now()); |
| | | leaveAuditService.save(tLeaveAudit2); |
| | | |
| | | // 新增消息 |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(leaveDTO.getAuditId()); |
| | |
| | | public R<LeaveUserDetailVO> leaveDetail(@RequestParam String id) { |
| | | TLeave leave = leaveService.getById(id); |
| | | LeaveUserDetailVO leaveUserDetailVO = new LeaveUserDetailVO(); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.parseLong(leave.getLeavePerson())); |
| | | SysUser sysUser = sysUserService.selectUserById(tokenService.getLoginUserApplet().getUserId()); |
| | | Long userRole = sysUserService.getUserRole(sysUser.getUserId()); |
| | | SysRole sysRole = roleService.selectRoleById(userRole); |
| | | if (sysRole.getRoleName().contains("片区负责人") || sysRole.getRoleName().equals("组长/队长")||sysRole.getRoleName().contains("项目部助理")) { |
| | | if (sysRole.getRoleName().contains("片区负责人") || sysRole.getRoleName().equals("组长")|| sysRole.getRoleName().equals("队长")||sysRole.getRoleName().contains("项目部助理")) { |
| | | if (sysUser.getDeptType() == 1) { |
| | | TProjectDept tProjectDept = projectDeptService.getById(sysUser.getDeptId()); |
| | | if (!tProjectDept.getParentId().equals("0")) { |