Przeglądaj źródła

分配床位,功能调整

dzx 1 rok temu
rodzic
commit
7fbdde2649

+ 37 - 0
src/main/java/com/xjrsoft/module/room/mapper/RoomBedMapper.java

@@ -12,6 +12,7 @@ import com.xjrsoft.module.room.entity.RoomBed;
 import com.xjrsoft.module.room.vo.AdjustBedClassPageVo;
 import com.xjrsoft.module.room.vo.AdjustBedClassStudentPageVo;
 import com.xjrsoft.module.room.vo.AdjustBedStudentPageVo;
+import com.xjrsoft.module.room.vo.ClassStudentCountVo;
 import com.xjrsoft.module.room.vo.DistributeClassPageVo;
 import com.xjrsoft.module.room.vo.DistributeResultListVo;
 import com.xjrsoft.module.room.vo.DistributeRoomBedPageVo;
@@ -81,4 +82,40 @@ public interface RoomBedMapper extends MPJBaseMapper<RoomBed> {
      */
     Page<NoBedStudentPageVo> getNoBedStudent(Page<AdjustBedPageDto> page, AdjustBedPageDto dto);
 
+    /* 查询分配床位班级列表的各个人数 - 开始 */
+
+    /**
+     * 查询班上需要住宿的人数
+     */
+    List<ClassStudentCountVo> getAllStayCount();
+
+    /**
+     * 查询班上需要住宿的男生人数
+     */
+    List<ClassStudentCountVo> getAllStayMaleCount();
+
+    /**
+     * 查询班上需要住宿的女生人数
+     */
+    List<ClassStudentCountVo> getAllStayFemaleCount();
+
+    /**
+     * 已安排的总人数
+     */
+    List<ClassStudentCountVo> getAllArrangedCount();
+
+    /**
+     * 已安排的男生人数
+     */
+    List<ClassStudentCountVo> getAllArrangedMaleCount();
+
+    /**
+     * 已安排的女生人数
+     */
+    List<ClassStudentCountVo> getAllArrangedFemaleCount();
+
+
+
+    /* 查询分配床位班级列表的各个人数 - 结束 */
+
 }

+ 75 - 1
src/main/java/com/xjrsoft/module/room/service/impl/RoomBedServiceImpl.java

@@ -31,6 +31,7 @@ import com.xjrsoft.module.room.service.IRoomBedService;
 import com.xjrsoft.module.room.vo.AdjustBedClassPageVo;
 import com.xjrsoft.module.room.vo.AdjustBedClassStudentPageVo;
 import com.xjrsoft.module.room.vo.AdjustBedStudentPageVo;
+import com.xjrsoft.module.room.vo.ClassStudentCountVo;
 import com.xjrsoft.module.room.vo.DistributeClassPageVo;
 import com.xjrsoft.module.room.vo.DistributeResultClassVo;
 import com.xjrsoft.module.room.vo.DistributeResultListVo;
@@ -123,7 +124,80 @@ public class RoomBedServiceImpl extends MPJBaseServiceImpl<RoomBedMapper, RoomBe
 
     @Override
     public Page<DistributeClassPageVo> getDistributeClassInfo(Page<DistributeClassPageDto> page, DistributeClassPageDto dto) {
-        return roomBedMapper.getDistributeClassInfo(page, dto);
+        Page<DistributeClassPageVo> classInfo = roomBedMapper.getDistributeClassInfo(page, dto);
+        List<DistributeClassPageVo> records = classInfo.getRecords();
+        //查询所有班级需要安排住宿的人数,并组装成map备用
+        List<ClassStudentCountVo> allStayCount = roomBedMapper.getAllStayCount();
+        Map<String, Integer> allStayCountMap = new HashMap<>();
+        for (ClassStudentCountVo classStudentCountVo : allStayCount) {
+            allStayCountMap.put(classStudentCountVo.getClassId(), classStudentCountVo.getStudentCount());
+        }
+
+        //查询所有班级需要安排住宿的男生人数,并组装成map备用
+        List<ClassStudentCountVo> allStayMaleCount = roomBedMapper.getAllStayMaleCount();
+        Map<String, Integer> allStayMaleCountMap = new HashMap<>();
+        for (ClassStudentCountVo classStudentCountVo : allStayMaleCount) {
+            allStayMaleCountMap.put(classStudentCountVo.getClassId(), classStudentCountVo.getStudentCount());
+        }
+
+        //查询所有班级需要安排住宿的女生人数,并组装成map备用
+        List<ClassStudentCountVo> allStayFemaleCount = roomBedMapper.getAllStayFemaleCount();
+        Map<String, Integer> allStayFemaleCountMap = new HashMap<>();
+        for (ClassStudentCountVo classStudentCountVo : allStayFemaleCount) {
+            allStayFemaleCountMap.put(classStudentCountVo.getClassId(), classStudentCountVo.getStudentCount());
+        }
+
+        //查询所有班级已经安排住宿的总人数,并组装成map备用
+        List<ClassStudentCountVo> allArrangedCount = roomBedMapper.getAllArrangedCount();
+        Map<String, Integer> allArrangedCountMap = new HashMap<>();
+        for (ClassStudentCountVo classStudentCountVo : allArrangedCount) {
+            allArrangedCountMap.put(classStudentCountVo.getClassId(), classStudentCountVo.getStudentCount());
+        }
+
+        //查询所有班级已经安排住宿的男生人数,并组装成map备用
+        List<ClassStudentCountVo> allArrangedMaleCount = roomBedMapper.getAllArrangedMaleCount();
+        Map<String, Integer> allArrangedMaleCountMap = new HashMap<>();
+        for (ClassStudentCountVo classStudentCountVo : allArrangedMaleCount) {
+            allArrangedMaleCountMap.put(classStudentCountVo.getClassId(), classStudentCountVo.getStudentCount());
+        }
+
+        //查询所有班级已经安排住宿的女生人数,并组装成map备用
+        List<ClassStudentCountVo> allArrangedFemaleCount = roomBedMapper.getAllArrangedFemaleCount();
+        Map<String, Integer> allArrangedFemaleCountMap = new HashMap<>();
+        for (ClassStudentCountVo classStudentCountVo : allArrangedFemaleCount) {
+            allArrangedFemaleCountMap.put(classStudentCountVo.getClassId(), classStudentCountVo.getStudentCount());
+        }
+
+        for (DistributeClassPageVo record : records) {
+            Integer needCout = 0;
+            Integer distributeCount = 0;
+            Integer maleCount = 0, femaleCount = 0;
+            if(allStayMaleCountMap.get(record.getId()) != null){
+                maleCount = allStayMaleCountMap.get(record.getId());
+            }
+            record.setMaleCount(maleCount);
+
+            if(allStayFemaleCountMap.get(record.getId()) != null){
+                femaleCount = allStayMaleCountMap.get(record.getId());
+            }
+            record.setFemaleCount(femaleCount);
+
+            if("SB10001".equals(dto.getGender()) && allStayMaleCountMap.get(record.getId()) != null){
+                needCout = allStayMaleCountMap.get(record.getId());
+                distributeCount = needCout - (allArrangedMaleCountMap.get(record.getId()) == null ? 0 : allArrangedMaleCountMap.get(record.getId()));
+            }else if("SB10002".equals(dto.getGender())){
+                needCout = femaleCount;
+                distributeCount = needCout - (allArrangedFemaleCountMap.get(record.getId()) == null ? 0 : allArrangedFemaleCountMap.get(record.getId()));
+            }else{
+                needCout = allStayCountMap.get(record.getId());
+                distributeCount = needCout - (allArrangedCountMap.get(record.getId()) == null ? 0 : allArrangedCountMap.get(record.getId()));
+            }
+
+            record.setNeedCount(needCout);
+            record.setDistributeCount(distributeCount);
+        }
+
+        return classInfo;
     }
 
     @Override

+ 19 - 0
src/main/java/com/xjrsoft/module/room/vo/ClassStudentCountVo.java

@@ -0,0 +1,19 @@
+package com.xjrsoft.module.room.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author dzx
+ * @date 2024/1/15
+ */
+@Data
+public class ClassStudentCountVo {
+
+    @ApiModelProperty("班级id")
+    private String classId;
+
+
+    @ApiModelProperty("学生人数")
+    private Integer studentCount;
+}

+ 4 - 4
src/main/java/com/xjrsoft/module/room/vo/DistributeClassPageVo.java

@@ -54,12 +54,12 @@ public class DistributeClassPageVo {
     private Integer distributeCount;
 
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("需要住宿的男生人数")
-    @ApiModelProperty("需要住宿的男生人数")
+    @ExcelProperty("需要安排住宿的男生人数")
+    @ApiModelProperty("需要安排住宿的男生人数")
     private Integer maleCount;
 
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("需要住宿的女生人数")
-    @ApiModelProperty("需要住宿的女生人数")
+    @ExcelProperty("需要安排住宿的女生人数")
+    @ApiModelProperty("需要安排住宿的女生人数")
     private Integer femaleCount;
 }

+ 62 - 0
src/main/resources/mapper/room/RoomBedMapper.xml

@@ -122,6 +122,68 @@
         </if>
 
     </select>
+    <!--查询分配床位班级列表的各个人数 - 开始 -->
+
+    <!-- 查询班上需要住宿的人数 -->
+    <select id="getAllStayCount" resultType="com.xjrsoft.module.room.vo.ClassStudentCountVo">
+        SELECT t1.id,COUNT(*) FROM base_class t1
+        LEFT JOIN base_student_school_roll t2 ON t1.id = t2.class_id
+        LEFT JOIN xjr_user t3 ON t2.user_id = t3.id
+        WHERE t1.delete_mark = 0
+        AND t2.delete_mark = 0 AND t3.delete_mark = 0
+        AND t2.stduy_status = 'FB3002' GROUP BY t1.id
+    </select>
+
+    <!-- 需要安排的男生总人数 -->
+    <select id="getAllStayMaleCount" resultType="com.xjrsoft.module.room.vo.ClassStudentCountVo">
+        SELECT t1.id,COUNT(*) FROM base_class t1
+        LEFT JOIN base_student_school_roll t2 ON t1.id = t2.class_id
+        LEFT JOIN xjr_user t3 ON t2.user_id = t3.id
+        WHERE t1.delete_mark = 0
+        AND t2.delete_mark = 0 AND t3.delete_mark = 0
+        AND t3.gender = 1
+        AND t2.stduy_status = 'FB3002' GROUP BY t1.id
+    </select>
+    <!-- 需要安排的女生总人数 -->
+    <select id="getAllStayFemaleCount" resultType="com.xjrsoft.module.room.vo.ClassStudentCountVo">
+        SELECT t1.id,COUNT(*) FROM base_class t1
+        LEFT JOIN base_student_school_roll t2 ON t1.id = t2.class_id
+        LEFT JOIN xjr_user t3 ON t2.user_id = t3.id
+        WHERE t1.delete_mark = 0
+        AND t2.delete_mark = 0 AND t3.delete_mark = 0
+        AND t3.gender = 2
+        AND t2.stduy_status = 'FB3002' GROUP BY t1.id
+    </select>
+    <!-- 已分配的总人数 -->
+    <select id="getAllArrangedCount" resultType="com.xjrsoft.module.room.vo.ClassStudentCountVo">
+        SELECT COUNT(*) FROM room_bed a1
+        LEFT JOIN base_student_school_roll a2 ON a1.student_user_id = a2.user_id
+        LEFT JOIN xjr_user c4 ON a2.user_id = c4.id
+        WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
+        AND a2.class_id = t1.id
+    </select>
+    <!-- 已分配的男生人数 -->
+    <select id="getAllArrangedMaleCount" resultType="com.xjrsoft.module.room.vo.ClassStudentCountVo">
+        SELECT a1.id,COUNT(*) FROM base_class a1
+        LEFT JOIN base_student_school_roll a2 ON a1.id = a2.class_id
+        LEFT JOIN room_bed a3 ON a2.user_id = a3.student_user_id
+        LEFT JOIN xjr_user a4 ON a3.student_user_id = a4.id AND a4.gender = 1
+        WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
+        AND a4.delete_mark = 0
+        GROUP BY a1.idd
+    </select>
+    <!-- 已分配的女生人数 -->
+    <select id="getAllArrangedFemaleCount" resultType="com.xjrsoft.module.room.vo.ClassStudentCountVo">
+        SELECT a1.id,COUNT(*) FROM base_class a1
+        LEFT JOIN base_student_school_roll a2 ON a1.id = a2.class_id
+        LEFT JOIN room_bed a3 ON a2.user_id = a3.student_user_id
+        LEFT JOIN xjr_user a4 ON a3.student_user_id = a4.id AND a4.gender = 2
+        WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
+        AND a4.delete_mark = 0
+        GROUP BY a1.idd
+    </select>
+    <!--查询分配床位班级列表的各个人数 - 结束 -->
+
     <select id="getDistributeRoomBedInfo" parameterType="com.xjrsoft.module.room.dto.DistributeRoomBedPageDto" resultType="com.xjrsoft.module.room.vo.DistributeRoomBedPageVo">
         SELECT t1.id,t1.sort_code,t2.name AS build_name,t1.floor_number,t1.room_name,t4.name AS gender_cn, t3.name AS check_in_status_cn,
         t1.bed_count,(