Browse Source

公告关联阅读人
寝室干部任命

phoenix 1 year ago
parent
commit
249dec8e95

+ 18 - 0
src/main/java/com/xjrsoft/module/oa/service/impl/NewsServiceImpl.java

@@ -27,6 +27,7 @@ import com.xjrsoft.module.oa.service.INewsService;
 import com.xjrsoft.module.oa.vo.NewsPageVo;
 import com.xjrsoft.module.oa.vo.NewsRelationVo;
 import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
+import com.xjrsoft.module.organization.entity.Department;
 import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.entity.UserDeptRelation;
 import com.xjrsoft.module.organization.mapper.UserDeptRelationMapper;
@@ -34,10 +35,13 @@ import com.xjrsoft.module.organization.mapper.UserMapper;
 import com.xjrsoft.module.organization.service.IWeChatService;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.mapper.BaseStudentSchoolRollMapper;
+import com.xjrsoft.module.teacher.entity.XjrUser;
+import com.xjrsoft.module.teacher.mapper.XjrUserMapper;
 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.stream.Collectors;
 
@@ -70,6 +74,8 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
 
     private final UserMapper userMapper;
 
+    private final XjrUserMapper xjrUserMapper;
+
     private final CommonPropertiesConfig commonPropertiesConfig;
 
     @Override
@@ -101,6 +107,18 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                 newsRelation.setReadMark(0);
                 if (relationDto.getRelationType() == 1) {
                     // 获取部门下的人员添加
+                    Long deptId = relationDto.getRelationId();
+                    MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
+                    queryUser
+                            .leftJoin(UserDeptRelation.class,UserDeptRelation::getUserId,XjrUser::getId)
+                            .leftJoin(Department.class,Department::getId,UserDeptRelation::getDeptId)
+                            .eq(Department::getId,deptId);
+                    List<XjrUser> userList = xjrUserMapper.selectJoinList(XjrUser.class,queryUser);
+                    List<Long> userIdList = new ArrayList<>();
+                    for (Long userId: userIdList) {
+                        newsRelation.setUserId(userId);
+                        newsRelationMapper.insert(newsRelation);
+                    }
                 } else {
                     newsRelation.setUserId(relationDto.getRelationId());
                     newsRelationMapper.insert(newsRelation);

+ 5 - 11
src/main/java/com/xjrsoft/module/room/controller/RoomStudentAppointController.java

@@ -2,18 +2,16 @@ package com.xjrsoft.module.room.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
-import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.room.dto.AddRoomStudentAppointDto;
 import com.xjrsoft.module.room.dto.RoomStudentAppointPageDto;
 import com.xjrsoft.module.room.dto.UpdateRoomStudentAppointDto;
 import com.xjrsoft.module.room.entity.RoomStudentAppoint;
 import com.xjrsoft.module.room.service.IRoomStudentAppointService;
-import com.xjrsoft.module.room.vo.RoomStudentAppointPageVo;
+import com.xjrsoft.module.room.vo.HeadTeaRoomCadreAppointPageVo;
 import com.xjrsoft.module.room.vo.RoomStudentAppointVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -41,14 +39,10 @@ public class RoomStudentAppointController {
     @GetMapping(value = "/page")
     @ApiOperation(value="寝室干部任命列表(分页)")
     @SaCheckPermission("roomstudentappoint:detail")
-    public RT<PageOutput<RoomStudentAppointPageVo>> page(@Valid RoomStudentAppointPageDto dto){
-
-        LambdaQueryWrapper<RoomStudentAppoint> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper
-                    .orderByDesc(RoomStudentAppoint::getId)
-                .select(RoomStudentAppoint.class,x -> VoToColumnUtil.fieldsToColumns(RoomStudentAppointPageVo.class).contains(x.getProperty()));
-        IPage<RoomStudentAppoint> page = roomStudentAppointService.page(ConventPage.getPage(dto), queryWrapper);
-        PageOutput<RoomStudentAppointPageVo> pageOutput = ConventPage.getPageOutput(page, RoomStudentAppointPageVo.class);
+    public RT<PageOutput<HeadTeaRoomCadreAppointPageVo>> page(@Valid RoomStudentAppointPageDto dto){
+
+        IPage<HeadTeaRoomCadreAppointPageVo> page = roomStudentAppointService.getPage(dto);
+        PageOutput<HeadTeaRoomCadreAppointPageVo> pageOutput = ConventPage.getPageOutput(page, HeadTeaRoomCadreAppointPageVo.class);
         return RT.ok(pageOutput);
     }
 

+ 6 - 3
src/main/java/com/xjrsoft/module/room/dto/RoomStudentAppointPageDto.java

@@ -1,6 +1,5 @@
 package com.xjrsoft.module.room.dto;
 
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.xjrsoft.common.page.PageInput;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -25,7 +24,11 @@ public class RoomStudentAppointPageDto extends PageInput {
      * 寝室主键编号
      */
     @ApiModelProperty("寝室主键编号")
-    @TableId
-    private Long roonId;
+    private Long roomId;
 
+    /**
+     * 当前班主任Id
+     */
+    @ApiModelProperty(value = "寝室主键编号",hidden = true)
+    private Long teacherId;
 }

+ 4 - 2
src/main/java/com/xjrsoft/module/room/mapper/RoomStudentAppointMapper.java

@@ -1,8 +1,10 @@
 package com.xjrsoft.module.room.mapper;
 
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.room.dto.RoomStudentAppointPageDto;
 import com.xjrsoft.module.room.entity.RoomStudentAppoint;
+import com.xjrsoft.module.room.vo.HeadTeaRoomCadreAppointPageVo;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -13,5 +15,5 @@ import org.apache.ibatis.annotations.Mapper;
 */
 @Mapper
 public interface RoomStudentAppointMapper extends MPJBaseMapper<RoomStudentAppoint> {
-
+    IPage<HeadTeaRoomCadreAppointPageVo>  getPage(IPage<RoomStudentAppointPageDto> page, RoomStudentAppointPageDto dto);
 }

+ 10 - 8
src/main/java/com/xjrsoft/module/room/service/IRoomStudentAppointService.java

@@ -1,17 +1,19 @@
 package com.xjrsoft.module.room.service;
 
-import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.room.dto.RoomStudentAppointPageDto;
 import com.xjrsoft.module.room.entity.RoomStudentAppoint;
-import lombok.Data;
-import java.util.List;
+import com.xjrsoft.module.room.vo.HeadTeaRoomCadreAppointPageVo;
 
 /**
-* @title: 寝室长任命
-* @Author dzx
-* @Date: 2023-12-30
-* @Version 1.0
-*/
+ * @title: 寝室长任命
+ * @Author dzx
+ * @Date: 2023-12-30
+ * @Version 1.0
+ */
 
 public interface IRoomStudentAppointService extends MPJBaseService<RoomStudentAppoint> {
+
+    IPage<HeadTeaRoomCadreAppointPageVo> getPage(RoomStudentAppointPageDto dto);
 }

+ 64 - 10
src/main/java/com/xjrsoft/module/room/service/impl/RoomStudentAppointServiceImpl.java

@@ -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;
+    }
 }

+ 42 - 0
src/main/java/com/xjrsoft/module/room/vo/AppointPageRoomBedVo.java

@@ -0,0 +1,42 @@
+package com.xjrsoft.module.room.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+* @title: 寝室床位表单出参
+* @Author dzx
+* @Date: 2023-12-27
+* @Version 1.0
+*/
+@Data
+public class AppointPageRoomBedVo {
+
+    /**
+    * 寝室编号(room)
+    */
+    @ApiModelProperty("寝室编号(room)")
+    private Long roomId;
+    /**
+     * 寝室床位编号(room_bed)
+     */
+    @ApiModelProperty("寝室床位编号(room_bed)")
+    private Long roomBedId;
+    /**
+    * 学生用户编号
+    */
+    @ApiModelProperty("学生用户编号")
+    private Long studentUserId;
+    /**
+     * 学生用户编号
+     */
+    @ApiModelProperty("学生用户编号")
+    private String studentUserIdCN;
+    /**
+     * 职务
+     */
+    @ApiModelProperty("职务")
+    private List<String> postList;
+}

+ 8 - 9
src/main/java/com/xjrsoft/module/room/vo/HeadTeaRoomCadreAppointPageVo.java

@@ -2,24 +2,23 @@ package com.xjrsoft.module.room.vo;
 
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.annotation.write.style.ContentStyle;
-import com.xjrsoft.module.room.entity.RoomBed;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.util.List;
 
 /**
-* @title: 寝室长任命分页列表出参
-* @Author dzx
-* @Date: 2023-12-30
-* @Version 1.0
-*/
+ * @title: 寝室长任命分页列表出参
+ * @Author dzx
+ * @Date: 2023-12-30
+ * @Version 1.0
+ */
 @Data
 public class HeadTeaRoomCadreAppointPageVo {
 
     /**
-    * 寝室编号(room)
-    */
+     * 寝室编号(room)
+     */
     @ApiModelProperty("寝室编号(room)")
     private String roomId;
     /**
@@ -47,6 +46,6 @@ public class HeadTeaRoomCadreAppointPageVo {
      * 寝室床位信息
      */
     @ApiModelProperty("寝室床位信息")
-    private List<RoomBed> roomBedList;
+    private List<AppointPageRoomBedVo> roomBedList;
 
 }

+ 5 - 6
src/main/java/com/xjrsoft/module/room/vo/RoomStudentAppointVo.java

@@ -3,12 +3,6 @@ package com.xjrsoft.module.room.vo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
-import java.time.LocalTime;
-import java.time.LocalDateTime;
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Date;
-
 /**
 * @title: 寝室长任命表单出参
 * @Author dzx
@@ -48,6 +42,11 @@ public class RoomStudentAppointVo {
     */
     @ApiModelProperty("职务编号【只取职位级别为寝室的,cadreLevel_room】(base_student_post)")
     private Long postId;
+    /**
+     * 职务编号【只取职位级别为寝室的,cadreLevel_room】(base_student_post)
+     */
+    @ApiModelProperty("职务编号【只取职位级别为寝室的,cadreLevel_room】(base_student_post)")
+    private String postIdCN;
     /**
     * 备注
     */

+ 3 - 3
src/main/resources/mapper/oa/NewsMapper.xml

@@ -40,6 +40,9 @@
         where t.delete_mark = 0 and
         (t.send_end_date > now() or t.send_end_date is null)
           and t.status = 2
+        <if test="dto.type != null and dto.type == 2 and dto.loginId != null and dto.loginId > 0">
+            and (t1.user_id = #{dto.loginId} or t.send_range = 1)
+        </if>
         <if test="dto.type != null and dto.type > 0">
             and t.type_id = #{dto.type}
         </if>
@@ -52,9 +55,6 @@
         <if test="dto.keyword != null and dto.keyword != ''">
             and t.keyword LIKE CONCAT('%',#{dto.keyword},'%')
         </if>
-        <if test="dto.type != null and dto.type == 2 and dto.loginId != null and dto.loginId > 0">
-            and (t1.user_id = #{dto.loginId} or t.send_range = 1)
-        </if>
         order by
         t.send_start_date desc
     </select>

+ 26 - 0
src/main/resources/mapper/room/RoomStudentAppointMapper.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xjrsoft.module.room.mapper.RoomStudentAppointMapper">
+    <select id="getPage" parameterType="com.xjrsoft.module.room.dto.RoomStudentAppointPageDto" resultType="com.xjrsoft.module.room.vo.HeadTeaRoomCadreAppointPageVo">
+        select
+        t2.room_id as roomId,
+        t3.room_name as roomName,
+        t4.name as genderCn,
+        t3.is_max as isMax
+        from base_class t
+        left join base_student_school_roll t1 on t1.class_id = t.id
+        inner join room_bed t2 on t2.student_user_id = t1.user_id
+        left join room t3 on t3.id = t2.room_id
+        left join xjr_dictionary_detail t4 on t4.code = t3.gender
+        where t1.delete_mark = 0 and t2.delete_mark = 0 and t.teacher_id = #{dto.teacherId}
+        <if test="dto.gender != null and dto.gender != ''">
+            and t3.gender = #{dto.gender}
+        </if>
+        <if test="dto.roomId != null and dto.roomId > 0">
+            and t3.id = #{dto.roomId}
+        </if>
+        group by t2.room_id,t4.name
+    </select>
+</mapper>