考勤
This commit is contained in:
		| @ -155,9 +155,9 @@ public class BusProjectTeamController extends BaseController { | ||||
|     /** | ||||
|      * 移除班组的管理 | ||||
|      */ | ||||
|     @PutMapping("/deleteUserId/{id}") | ||||
|     public R<Boolean> deleteUserId(@PathVariable("id") Long id){ | ||||
|         return R.ok(busProjectTeamService.deleteUserId(id)); | ||||
|     @PutMapping("/deleteUserId/{id}/{userId}") | ||||
|     public R<Boolean> deleteUserId(@PathVariable("id") Long id,@PathVariable("userId") Long userId){ | ||||
|         return R.ok(busProjectTeamService.deleteUserId(id,userId)); | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -56,5 +56,5 @@ public class BusProjectTeam extends BaseEntity { | ||||
|     /** | ||||
|      * 管理员Id | ||||
|      */ | ||||
|     private Long userId; | ||||
|     private String userId; | ||||
| } | ||||
|  | ||||
| @ -50,5 +50,5 @@ public class BusProjectTeamCreateReq implements Serializable { | ||||
|     /** | ||||
|      * 管理员Id | ||||
|      */ | ||||
|     private Long userId; | ||||
|     private String userId; | ||||
| } | ||||
|  | ||||
| @ -51,5 +51,5 @@ public class BusProjectTeamUpdateReq implements Serializable { | ||||
|     /** | ||||
|      * 管理员Id | ||||
|      */ | ||||
|     private Long userId; | ||||
|     private String userId; | ||||
| } | ||||
|  | ||||
| @ -76,13 +76,12 @@ public class BusProjectTeamVo implements Serializable { | ||||
|     /** | ||||
|      * 管理员Id | ||||
|      */ | ||||
|     private Long userId; | ||||
|     private String userId; | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 管理员Id | ||||
|      */ | ||||
|     @Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "userId") | ||||
|     private String userName; | ||||
|  | ||||
|     /** | ||||
|  | ||||
| @ -121,5 +121,5 @@ public interface IBusProjectTeamService extends IService<BusProjectTeam> { | ||||
|     List<BusProjectTeamAppVo> getByUserId(Long userId,Long projectId); | ||||
|  | ||||
|  | ||||
|     Boolean deleteUserId(Long id); | ||||
|     Boolean deleteUserId(Long id,Long userId); | ||||
| } | ||||
|  | ||||
| @ -33,6 +33,8 @@ import org.dromara.project.service.IBusProjectPunchrangeService; | ||||
| import org.dromara.project.service.IBusProjectService; | ||||
| import org.dromara.project.service.IBusProjectTeamMemberService; | ||||
| import org.dromara.project.service.IBusProjectTeamService; | ||||
| import org.dromara.system.domain.vo.SysUserVo; | ||||
| import org.dromara.system.service.ISysUserService; | ||||
| import org.springframework.beans.BeanUtils; | ||||
| import org.springframework.context.annotation.Lazy; | ||||
| import org.springframework.stereotype.Service; | ||||
| @ -65,6 +67,9 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper, | ||||
|     @Resource | ||||
|     private IBusProjectPunchrangeService projectPunchrangeService; | ||||
|  | ||||
|     @Resource | ||||
|     private ISysUserService userService; | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 查询项目班组 | ||||
| @ -420,11 +425,30 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper, | ||||
|                 m -> ((Number) m.get("team_id")).longValue(), | ||||
|                 m -> ((Number) m.get("count")).longValue() | ||||
|             )); | ||||
|         List<Long> userIdList = projectTeamList.stream() | ||||
|             .map(BusProjectTeam::getUserId) | ||||
|             .filter(StringUtils::isNotBlank) | ||||
|             .flatMap(str -> Arrays.stream(str.split(","))) | ||||
|             .map(s -> Long.valueOf(s.trim())) | ||||
|             .distinct() | ||||
|             .collect(Collectors.toList()); | ||||
|  | ||||
|         List<SysUserVo> sysUserVos = userService.selectUserByIds(userIdList, null); | ||||
|         Map<Long, String> collect = sysUserVos.stream().collect(Collectors.toMap(SysUserVo::getUserId, SysUserVo::getNickName)); | ||||
|  | ||||
|  | ||||
|  | ||||
|         // 对象列表 => 封装对象列表 | ||||
|         List<BusProjectTeamVo> projectTeamVoList = projectTeamList.stream().map(projectTeam -> { | ||||
|             BusProjectTeamVo projectTeamVo = new BusProjectTeamVo(); | ||||
|             BeanUtils.copyProperties(projectTeam, projectTeamVo); | ||||
|             projectTeamVo.setPeopleNumber(teamCountMap.getOrDefault(projectTeam.getId(), 0L)); | ||||
|  | ||||
|             String userId = projectTeamVo.getUserId(); | ||||
|             if (StringUtils.isNotBlank(userId)) { | ||||
|                 String[] split = userId.split(","); | ||||
|                 projectTeamVo.setUserName(Arrays.stream(split).map(s -> collect.getOrDefault(Long.valueOf(s.trim()), "")).collect(Collectors.joining(","))); | ||||
|             } | ||||
|             return projectTeamVo; | ||||
|         }).toList(); | ||||
|         projectTeamVoPage.setRecords(projectTeamVoList); | ||||
| @ -436,7 +460,7 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper, | ||||
|     public List<BusProjectTeamAppVo> getByUserId(Long userId,Long projectId) { | ||||
|         LambdaQueryWrapper<BusProjectTeam> lqw = new LambdaQueryWrapper<>(); | ||||
|  | ||||
|         lqw.eq(BusProjectTeam::getUserId, userId); | ||||
|         lqw.apply("FIND_IN_SET({0}, user_id) > 0", userId); | ||||
|         lqw.eq(BusProjectTeam::getProjectId, projectId); | ||||
|         List<BusProjectTeam> projectTeamList = list(lqw); | ||||
|         if (CollUtil.isNotEmpty(projectTeamList)) { | ||||
| @ -450,10 +474,18 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper, | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Boolean deleteUserId(Long id) { | ||||
|         int update = baseMapper.update(Wrappers.<BusProjectTeam>lambdaUpdate() | ||||
|             .eq(BusProjectTeam::getId, id) | ||||
|             .set(BusProjectTeam::getUserId, null)); | ||||
|         return update>0; | ||||
|     public Boolean deleteUserId(Long id,Long userId) { | ||||
|         BusProjectTeam projectTeam = baseMapper.selectById(id); | ||||
|         String userId1 = projectTeam.getUserId(); | ||||
|         if (StringUtils.isNotBlank(userId1)) { | ||||
|             String[] split = userId1.split(","); | ||||
|             List<String> collect = Arrays.stream(split).filter(s -> !s.equals(userId.toString())).collect(Collectors.toList()); | ||||
|             String join = String.join(",", collect); | ||||
|             int update = baseMapper.update(Wrappers.<BusProjectTeam>lambdaUpdate() | ||||
|                 .eq(BusProjectTeam::getId, id) | ||||
|                 .set(BusProjectTeam::getUserId, join)); | ||||
|             return update > 0; | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 zt
					zt