| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <?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.template.mapper.WelcomeBedMapper">
- <update id="updateData">
- UPDATE `welcome_bed`
- SET is_check = 0,
- student_card = NULL,
- card_num = NULL,
- `name` = NULL
- WHERE
- id = #{bedId}
- </update>
- <update id="updateBuild">
- UPDATE `welcome_bed`
- SET
- build= #{build},
- school_id= #{schoolId},
- school= #{school}
- WHERE
- deleted=0
- AND build_id= #{buildId}
- </update>
- <select id="queryBedList" resultType="com.template.model.vo.BedInfosVo">
- select id,student_card,is_check,number,build,build_id,dormitory_id,dormitory from welcome_bed
- where dormitory_id in (
- SELECT dormitory_id FROM `welcome_bed`
- where student_card = #{studentCard} and deleted = 0)
- and deleted = 0
- order by number
- </select>
- <select id="getBedList" resultType="com.template.model.vo.BedDetailsVo">
- SELECT
- number,
- is_check as isCheck
- FROM
- welcome_bed
- WHERE
- deleted = 0
- AND school_id = #{schoolId}
- AND build_id = #{buildId}
- AND dormitory_id = #{dormitoryId}
- AND (student_card != #{studentCard} or student_card is NULL)
- </select>
- <select id="getBedDetailsVo" resultType="com.template.model.vo.BedDetailsVo">
- SELECT
- ws.picture,
- wb.card_num ascardNum,
- ws.`name`,
- ws.sex,
- ws.nationality,
- wo.`name` as college,
- wo2.`name` as major,
- wo3.`name` as classstr,
- ws.batch_value as batchValue,
- w.build,
- ws.exam_num as examNum,
- wd.dormitory,
- wb.student_card as studentCard,
- ws.address,
- ws.phone,
- wb.number,
- wb.is_check as isCheck
- FROM
- welcome_bed wb
- LEFT JOIN welcome_org wo ON wb.college_id = wo.id
- AND wo.deleted = 0
- LEFT JOIN welcome_org wo2 ON wb.major_id = wo2.id
- AND wo2.deleted = 0
- LEFT JOIN welcome_org wo3 ON wb.classstr_id = wo3.id
- AND wo3.deleted = 0
- LEFT JOIN welcome_build w ON wb.build_id = w.id
- AND w.deleted = 0
- LEFT JOIN welcome_dormitory wd ON wb.dormitory_id = wd.id
- AND wd.deleted = 0
- LEFT JOIN welcome_student ws ON wb.student_card = ws.card_id
- AND ws.deleted = 0
- WHERE
- wb.deleted = 0
- AND wb.school_id = #{schoolId}
- AND wb.build_id = #{buildId}
- AND wb.dormitory_id = #{dormitoryId}
- AND wb.student_card = #{studentCard}
- </select>
- <select id="isCheck" resultType="com.template.model.vo.WelcomeBedCheckVo">
- SELECT
- wb.is_check as isCheck,
- wb.school_id as schoolId,
- wb.build_id as buildId,
- wb.dormitory_id as dormitoryId,
- ws.school,
- w.build,
- wd.dormitory
- FROM
- `welcome_bed` wb
- LEFT JOIN welcome_school ws ON ws.id = wb.school_id
- AND ws.deleted = 0
- LEFT JOIN welcome_build w ON w.id = wb.build_id
- AND w.deleted = 0
- LEFT JOIN welcome_dormitory wd ON wd.id = wb.dormitory_id
- AND wd.deleted = 0
- WHERE
- wb.deleted =0
- AND wb.student_card= #{studentCard}
- </select>
- <resultMap type="com.template.model.vo.BedSqlTotalVo" id="queryBedSqlMap">
- <result property="totalData" column="totalData"/>
- <result property="totalBed" column="totalBed"/>
- <result property="college" column="college"/>
- <result property="sex" column="sex"/>
- <result property="build" column="build"/>
- <result property="dormitory" column="dormitory"/>
- </resultMap>
- <select id="queryBedSqlList" resultType="com.template.model.vo.BedSqlTotalVo" resultMap="queryBedSqlMap">
- -- select (select sum(1) as total from welcome_student where deleted = 0 and college = wb.college and iden_type = 1 and sex = wb.sex) as totalData,
- select 0 as totalData,
- SUM(1) as totalBed,college,sex,build,dormitory
- from welcome_bed wb
- where wb.deleted = 0 and wb.college is not null and wb.college != ''
- <if test="collegeId != null and collegeId != ''">
- and wb.college_id = #{collegeId}
- </if>
- <if test="sex != null and sex != ''">
- and wb.sex = #{sex}
- </if>
- group by wb.college,wb.sex,wb.build,wb.dormitory
- </select>
- <resultMap type="com.template.model.vo.SleepSqlTotalVo" id="queryTotalSqlMap">
- <result property="totalBed" column="totalBed"/>
- <result property="sleeper" column="sleeper"/>
- <result property="totalData" column="totalData"/>
- <result property="college" column="college"/>
- <result property="sex" column="sex"/>
- </resultMap>
- <select id="queryTotalSqlList" resultType="com.template.model.vo.SleepSqlTotalVo" resultMap="queryTotalSqlMap">
- select SUM(1) as totalBed,
- (select SUM(1) as total from welcome_bed where deleted = 0 and `name` is not null and name != '' and college = wb.college and sex = wb.sex) as sleeper,
- -- (select sum(1) as total from welcome_student where deleted = 0 and college = wb.college and iden_type = 1 and sex = wb.sex) as totalData,wb.college,wb.sex from welcome_bed wb
- 0 as totalData,wb.college,wb.sex from welcome_bed wb
- where wb.deleted = 0 and wb.college is not null
- <if test="collegeId != null and collegeId != ''">
- and wb.college_id = #{collegeId}
- </if>
- <if test="sex != null and sex != ''">
- and wb.sex = #{sex}
- </if>
- group by wb.college,wb.sex
- </select>
- <select id="queryPageWelcomeBedsC" resultType="com.template.model.pojo.WelcomeBed">
- SELECT
- wb.*
- FROM
- `welcome_bed` wb
- WHERE
- wb.deleted =0
- <if test="schoolId != null and schoolId != ''">
- and wb.school_id = #{schoolId}
- </if>
- <if test="buildId != null and buildId != ''">
- and wb.build_id = #{buildId}
- </if>
- <if test="dormitoryId != null and dormitoryId != ''">
- and wb.dormitory_id = #{dormitoryId}
- </if>
- <if test="sex != null and sex != ''">
- and wb.sex = #{sex}
- </if>
- <if test="isCheck != null">
- and wb.is_check = #{isCheck}
- </if>
- <if test="majorId != null and majorId != ''">
- and wb.major_id = #{majorId}
- </if>
- <if test="classstrId != null and classstrId != ''">
- and wb.classstr_id = #{classstrId}
- </if>
- <if test="retentionState != null and retentionState != ''">
- and wb.retention_state = #{retentionState}
- </if>
- AND FIND_IN_SET(wb.college_id,#{collegeIds})
- order by LPAD(wb.build, 20, '0'),wb.dormitory,wb.number asc
- </select>
- <select id="queryPageWelcomeBeds" resultType="com.template.model.pojo.WelcomeBed">
- SELECT
- wb.*
- FROM
- `welcome_bed` wb
- WHERE
- wb.deleted =0
- <if test="schoolId != null and schoolId != ''">
- and wb.school_id = #{schoolId}
- </if>
- <if test="buildId != null and buildId != ''">
- and wb.build_id = #{buildId}
- </if>
- <if test="dormitoryId != null and dormitoryId != ''">
- and wb.dormitory_id = #{dormitoryId}
- </if>
- <if test="sex != null and sex != ''">
- and wb.sex = #{sex}
- </if>
- <if test="isCheck != null ">
- and wb.is_check = #{isCheck}
- </if>
- <if test="collegeId != null and collegeId != ''">
- and wb.college_id = #{collegeId}
- </if>
- <if test="majorId != null and majorId != ''">
- and wb.major_id = #{majorId}
- </if>
- <if test="classstrId != null and classstrId != ''">
- and wb.classstr_id = #{classstrId}
- </if>
- <if test="retentionState != null and retentionState != ''">
- and wb.retention_state = #{retentionState}
- </if>
- order by LPAD(wb.build, 20, '0'),wb.dormitory,wb.number asc
- </select>
- </mapper>
|