Forráskód Böngészése

新增学院住宿统计情况接口

liu 1 hónapja
szülő
commit
d480bd2adc

+ 5 - 0
src/main/java/com/template/api/WelcomeStudentControllerAPI.java

@@ -94,4 +94,9 @@ public interface WelcomeStudentControllerAPI {
     @GetMapping(value = "/levelRegister")
     @ApiOperation(value = "层次报到情况", notes = "层次报到情况", httpMethod = "GET")
     CommonResult levelRegister(Integer collegeId, Integer yearId) throws ParseException;
+
+    @GetMapping(value = "/collegeStudentStay")
+    @ApiOperation(value = "学院住宿统计情况", notes = "学院住宿统计情况", httpMethod = "GET")
+    CommonResult collegeStudentStay(Integer yearId) throws ParseException;
+
 }

+ 25 - 0
src/main/java/com/template/controller/WelcomeStudentController.java

@@ -2402,5 +2402,30 @@ public class WelcomeStudentController implements WelcomeStudentControllerAPI {
         return CommonResult.ok(vos);
 
     }
+
+    @Override
+    public CommonResult collegeStudentStay(Integer yearId) throws ParseException {
+        String nstartTime = null;
+        String nendTime = null;
+        boolean lastYear = TimeExchange.CompareDate(TimeExchange.getDate(), TimeExchange.getYear() + "-07-01", "yyyy-MM-dd");
+        if (yearId == null) {
+            Integer yearInt = Integer.valueOf(TimeExchange.getYear());
+            //当前时间小于本年度的7月1日 说明要查去年的数据
+            if (lastYear) {
+                nstartTime = (yearInt - 1) + "-06-01";
+                nendTime = yearInt + "-06-01";
+            } else {
+                nstartTime = yearInt + "-06-01";
+                nendTime = (yearInt + 1) + "-06-01";
+            }
+        } else {
+            nstartTime = yearId + "-06-01";
+            nendTime = (yearId + 1) + "-06-01";
+        }
+
+        List<BedCheckRateVO> vos=welcomeBedService.collegeStudentStay(nstartTime,nendTime);
+
+        return CommonResult.ok(vos);
+    }
 }
 

+ 1 - 0
src/main/java/com/template/mapper/WelcomeBedMapper.java

@@ -41,4 +41,5 @@ public interface WelcomeBedMapper extends BaseMapper<WelcomeBed> {
 
     IPage<WelcomeBed> queryPageWelcomeBeds(Page<WelcomeBed> page, @Param("schoolId") Integer schoolId, @Param("buildId") Integer buildId, @Param("dormitoryId") Integer dormitoryId, @Param("sex") String sex, @Param("isCheck") Integer isCheck, @Param("collegeId") Integer collegeId, @Param("majorId") Integer majorId, @Param("classstrId") Integer classstrId, @Param("retentionState") Integer retentionState, @Param("nstartTime") String nstartTime, @Param("nendTime") String nendTime);
 
+    List<BedCheckRateVO> collegeStudentStay(@Param("startTime") String startTime, @Param("endTime") String endTime);
 }

+ 32 - 0
src/main/java/com/template/model/vo/BedCheckRateVO.java

@@ -0,0 +1,32 @@
+package com.template.model.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class BedCheckRateVO {
+
+    //    院系名称
+    private String collegeName;
+
+    //    男生床位总数
+    private Integer maleTotal;
+
+    //    男生入住数量
+    private Integer maleCheck;
+
+    //    男生入住比率
+    private BigDecimal maleRate;
+
+    //    女生床位总数
+    private Integer femaleTotal;
+
+    //    女生入住数量
+    private Integer femaleCheck;
+
+    //    女生入住比率
+    private BigDecimal femaleRate;
+
+
+}

+ 2 - 0
src/main/java/com/template/services/WelcomeBedService.java

@@ -91,4 +91,6 @@ public interface WelcomeBedService extends IService<WelcomeBed> {
     void updateBuild(String schoolId, Integer buildId, String build, String school);
 
     WelcomeBed getBedByAdmissNum(String admissNum);
+
+    List<BedCheckRateVO> collegeStudentStay(String startTime, String endTime);
 }

+ 5 - 0
src/main/java/com/template/services/impl/WelcomeBedServiceImpl.java

@@ -479,4 +479,9 @@ public class WelcomeBedServiceImpl extends ServiceImpl<WelcomeBedMapper, Welcome
         return welcomeBed;
     }
 
+    @Override
+    public List<BedCheckRateVO> collegeStudentStay(String startTime, String endTime) {
+        return welcomeBedMapper.collegeStudentStay(startTime,endTime);
+    }
+
 }

+ 26 - 0
src/main/resources/mapper/template/WelcomeBedMapper.xml

@@ -243,4 +243,30 @@
         AND wb.create_time between #{nstartTime} and #{nendTime}
         order by LPAD(wb.build, 20, '0'),wb.dormitory,wb.number asc
     </select>
+
+    <select id="collegeStudentStay" resultType="com.template.model.vo.BedCheckRateVO">
+        SELECT
+            wo.`name` as collegeName,
+            SUM(CASE WHEN wb.sex = '男' THEN 1 ELSE 0 END) AS male_total,
+            SUM(CASE WHEN wb.sex = '男' AND wb.is_check = 1 THEN 1 ELSE 0 END) AS male_check,
+            ROUND(
+                            SUM(CASE WHEN wb.sex = '男' AND wb.is_check = 1 THEN 1 ELSE 0 END) * 100.0
+                        / NULLIF(SUM(CASE WHEN wb.sex = '男' THEN 1 ELSE 0 END), 0), 2
+                ) AS male_rate,
+            SUM(CASE WHEN wb.sex = '女' THEN 1 ELSE 0 END) AS female_total,
+            SUM(CASE WHEN wb.sex = '女' AND wb.is_check = 1 THEN 1 ELSE 0 END) AS female_check,
+            ROUND(
+                            SUM(CASE WHEN wb.sex = '女' AND wb.is_check = 1 THEN 1 ELSE 0 END) * 100.0
+                        / NULLIF(SUM(CASE WHEN wb.sex = '女' THEN 1 ELSE 0 END), 0), 2
+                ) AS female_rate
+        FROM
+            welcome_bed wb
+                LEFT JOIN welcome_org wo ON wb.college_id = wo.id AND wo.deleted = 0
+        WHERE
+            wb.deleted = 0
+          AND wb.create_time BETWEEN #{startTime} AND #{endTime}
+        GROUP BY
+            wb.college_id, wo.`name`
+
+    </select>
 </mapper>

+ 2 - 2
src/main/resources/mapper/template/WelcomeStudentMapper.xml

@@ -115,7 +115,7 @@
             SUM(1) AS totalCount,
             SUM(CASE WHEN ws.is_registered = 1 THEN 1 ELSE 0 END) AS count,
             ROUND(
-                        SUM(CASE WHEN ws.is_registered = 1 THEN 1 ELSE 0 END) / SUM(1),
+                        SUM(CASE WHEN ws.is_registered = 1 THEN 1 ELSE 0 END) * 100.0 / NULLIF(SUM(1), 0),
                         2
                 ) AS rate,
             wo.`name`
@@ -211,7 +211,7 @@
             SUM(1) AS totalCount,
             SUM(CASE WHEN ws.is_registered = 1 THEN 1 ELSE 0 END) AS count,
             ROUND(
-                        SUM(CASE WHEN ws.is_registered = 1 THEN 1 ELSE 0 END) / SUM(1),
+                        SUM(CASE WHEN ws.is_registered = 1 THEN 1 ELSE 0 END) * 100.0 / NULLIF(SUM(1), 0),
                         2
                 ) AS rate,
             wo.`name`