|
@@ -1,25 +1,79 @@
|
|
|
package com.xjrsoft.module.room.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.page.ConventPage;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.room.dto.RoomStudentAppointPageDto;
|
|
|
+import com.xjrsoft.module.room.entity.RoomBed;
|
|
|
import com.xjrsoft.module.room.entity.RoomStudentAppoint;
|
|
|
+import com.xjrsoft.module.room.mapper.RoomBedMapper;
|
|
|
import com.xjrsoft.module.room.mapper.RoomStudentAppointMapper;
|
|
|
import com.xjrsoft.module.room.service.IRoomStudentAppointService;
|
|
|
+import com.xjrsoft.module.room.vo.AppointPageRoomBedVo;
|
|
|
+import com.xjrsoft.module.room.vo.HeadTeaRoomCadreAppointPageVo;
|
|
|
+import com.xjrsoft.module.room.vo.RoomStudentAppointVo;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentPost;
|
|
|
+import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
|
/**
|
|
|
-* @title: 寝室长任命
|
|
|
-* @Author dzx
|
|
|
-* @Date: 2023-12-30
|
|
|
-* @Version 1.0
|
|
|
-*/
|
|
|
+ * @title: 寝室长任命
|
|
|
+ * @Author dzx
|
|
|
+ * @Date: 2023-12-30
|
|
|
+ * @Version 1.0
|
|
|
+ */
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class RoomStudentAppointServiceImpl extends MPJBaseServiceImpl<RoomStudentAppointMapper, RoomStudentAppoint> implements IRoomStudentAppointService {
|
|
|
+
|
|
|
+ private final RoomStudentAppointMapper roomStudentAppointMapper;
|
|
|
+
|
|
|
+ private final RoomBedMapper roomBedMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<HeadTeaRoomCadreAppointPageVo> getPage(RoomStudentAppointPageDto dto) {
|
|
|
+ IPage<HeadTeaRoomCadreAppointPageVo> headTeaRoomCadreAppointPageVoIPage = roomStudentAppointMapper.getPage(ConventPage.getPage(dto), dto);
|
|
|
+ //找到每个寝室的每个床位的人
|
|
|
+ for (HeadTeaRoomCadreAppointPageVo headTeaRoomCadreAppointPageVo : headTeaRoomCadreAppointPageVoIPage.getRecords()) {
|
|
|
+ MPJLambdaWrapper<RoomBed> queryRoomBed = new MPJLambdaWrapper<>();
|
|
|
+ queryRoomBed
|
|
|
+ .selectAs(RoomBed::getId,AppointPageRoomBedVo::getRoomBedId)
|
|
|
+ .selectAs(XjrUser::getName, AppointPageRoomBedVo::getStudentUserIdCN)
|
|
|
+ .select(RoomBed.class, x -> VoToColumnUtil.fieldsToColumns(AppointPageRoomBedVo.class).contains(x.getProperty()))
|
|
|
+ .leftJoin(XjrUser.class,XjrUser::getId,RoomBed::getStudentUserId)
|
|
|
+ .eq(RoomBed::getRoomId,headTeaRoomCadreAppointPageVo.getRoomId())
|
|
|
+ .eq(RoomBed::getIsCheckIn,1);
|
|
|
+ List<AppointPageRoomBedVo> appointPageRoomBedVoList = roomBedMapper.selectJoinList(AppointPageRoomBedVo.class,queryRoomBed);
|
|
|
+ if (ObjectUtil.isNotNull(appointPageRoomBedVoList) && appointPageRoomBedVoList.size() > 0){
|
|
|
+ //找到每个人的职位
|
|
|
+ for (AppointPageRoomBedVo appointPageRoomBedVo : appointPageRoomBedVoList) {
|
|
|
+ MPJLambdaWrapper<RoomStudentAppoint> queryPost = new MPJLambdaWrapper<>();
|
|
|
+ queryPost
|
|
|
+ .selectAs(BaseStudentPost::getPost, RoomStudentAppointVo::getPostIdCN)
|
|
|
+ .select(RoomStudentAppoint.class, x -> VoToColumnUtil.fieldsToColumns(RoomStudentAppointVo.class).contains(x.getProperty()))
|
|
|
+ .leftJoin(BaseStudentPost.class,BaseStudentPost::getId,RoomStudentAppoint::getPostId)
|
|
|
+ .eq(RoomStudentAppoint::getRoomId,appointPageRoomBedVo.getRoomId())
|
|
|
+ .eq(RoomStudentAppoint::getRoomBedId,appointPageRoomBedVo.getRoomBedId())
|
|
|
+ .eq(RoomStudentAppoint::getStudentUserId,appointPageRoomBedVo.getStudentUserId());
|
|
|
+ List<RoomStudentAppointVo> roomStudentAppointList = this.selectJoinList(RoomStudentAppointVo.class,queryPost);
|
|
|
+ if (ObjectUtil.isNotNull(roomStudentAppointList) && roomStudentAppointList.size() > 0){
|
|
|
+ List<String> postList = new ArrayList<>();
|
|
|
+ for (RoomStudentAppointVo roomStudentAppointVo : roomStudentAppointList) {
|
|
|
+ postList.add(roomStudentAppointVo.getPostIdCN());
|
|
|
+ }
|
|
|
+ appointPageRoomBedVo.setPostList(postList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ headTeaRoomCadreAppointPageVo.setRoomBedList(appointPageRoomBedVoList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return headTeaRoomCadreAppointPageVoIPage;
|
|
|
+ }
|
|
|
}
|