bt-yjj-system-examination-s.../src/main/resources/mybatis/mapper/distributionfield/distribution-field-mapper.xml
2021-05-12 14:07:02 +08:00

378 lines
13 KiB
XML

<?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="cn.com.tenlion.dao.examination.distributionfield.IDistributionFieldDao">
<resultMap id="distributionFieldDTO" type="cn.com.tenlion.pojo.dtos.distributionfield.DistributionFieldDTO">
<result column="distribution_field_id" property="distributionFieldId"/>
<result column="distribution_id" property="distributionId"/>
<result column="field_id" property="fieldId"/>
<result column="field_name" property="fieldName"/>
<result column="field_number" property="fieldNumber"/>
<result column="field_status" property="fieldStatus"/>
<result column="invigilator_id" property="invigilatorId"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<resultMap id="distributionFieldBO" type="cn.com.tenlion.pojo.bos.distributionfield.DistributionFieldBO">
<result column="distribution_field_id" property="distributionFieldId"/>
<result column="distribution_id" property="distributionId"/>
<result column="field_id" property="fieldId"/>
<result column="field_name" property="fieldName"/>
<result column="field_number" property="fieldNumber"/>
<result column="field_status" property="fieldStatus"/>
<result column="invigilator_id" property="invigilatorId"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<resultMap id="distributionFieldPO" type="cn.com.tenlion.pojo.pos.distributionfield.DistributionFieldPO">
<result column="distribution_field_id" property="distributionFieldId"/>
<result column="distribution_id" property="distributionId"/>
<result column="field_id" property="fieldId"/>
<result column="field_name" property="fieldName"/>
<result column="field_number" property="fieldNumber"/>
<result column="field_status" property="fieldStatus"/>
<result column="invigilator_id" property="invigilatorId"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<!-- 考场分配详情统计 -->
<select id="queryCount" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
e_distribution_field t1
WHERE
t1.is_delete = 0 AND t1.field_id = #{fieldId}
</select>
<!-- 考场分配详情详情 -->
<select id="queryWeekCount" parameterType="map" resultType="map">
SELECT
COUNT(1) AS weekCount,
weekTable.weekTime AS weekWeek
FROM (
SELECT
(DAYOFWEEK(DATE_FORMAT(t2.distribution_allot_time ,'%Y-%m-%d' )) - 1) AS weekTime
FROM
e_distribution_field t1
LEFT JOIN
e_distribution t2
ON
t1.distribution_id = t2.distribution_id
WHERE
t1.field_id = #{fieldId} AND YEARWEEK(DATE_FORMAT(t2.distribution_allot_time ,'%Y-%m-%d' ) , 1) = YEARWEEK( NOW() , 1)
) weekTable
GROUP BY weekTable.weekTime
ORDER BY weekTable.weekTime
</select>
<!-- 新增考场分配详情 -->
<insert id="save" parameterType="map">
INSERT INTO e_distribution_field(
distribution_field_id,
distribution_id,
field_id,
field_name,
field_number,
field_status,
invigilator_id,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{distributionFieldId},
#{distributionId},
#{fieldId},
#{fieldName},
#{fieldNumber},
#{fieldStatus},
#{invigilatorId},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除考场分配详情 -->
<update id="remove" parameterType="map">
UPDATE
e_distribution_field
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
distribution_field_id IN
<foreach collection="distributionFieldIds" index="index" open="(" separator="," close=")">
#{distributionFieldIds[${index}]}
</foreach>
</update>
<!-- 删除考场分配详情(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
e_distribution_field
WHERE
distribution_field_id IN
<foreach collection="distributionFieldIds" index="index" open="(" separator="," close=")">
#{distributionFieldIds[${index}]}
</foreach>
</update>
<!-- 修改考场分配详情 -->
<update id="update" parameterType="map">
UPDATE
e_distribution_field
SET
<!-- <if test="distributionId != null and distributionId != ''">-->
<!-- distribution_id = #{distributionId},-->
<!-- </if>-->
<!-- <if test="fieldId != null and fieldId != ''">-->
<!-- field_id = #{fieldId},-->
<!-- </if>-->
<!-- <if test="fieldName != null and fieldName != ''">-->
<!-- field_name = #{fieldName},-->
<!-- </if>-->
<!-- <if test="fieldNumber != null">-->
<!-- field_number = #{fieldNumber},-->
<!-- </if>-->
<!-- <if test="fieldStatus != null and fieldStatus != ''">-->
<!-- field_status = #{fieldStatus},-->
<!-- </if>-->
<if test="invigilatorId != null and invigilatorId != ''">
invigilator_id = #{invigilatorId},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
distribution_field_id = distribution_field_id
WHERE
distribution_field_id = #{distributionFieldId}
</update>
<!-- 考场分配详情详情 -->
<select id="get" parameterType="map" resultMap="distributionFieldDTO">
SELECT
t1.distribution_id,
t1.field_id,
t1.field_name,
t1.field_number,
t1.invigilator_id,
t1.field_status,
t1.distribution_field_id
FROM
e_distribution_field t1
WHERE
t1.is_delete = 0
<if test="distributionFieldId != null and distributionFieldId != ''">
AND
t1.distribution_field_id = #{distributionFieldId}
</if>
</select>
<!-- 考场分配详情详情 -->
<select id="getBO" parameterType="map" resultMap="distributionFieldBO">
SELECT
t1.distribution_field_id,
t1.distribution_id,
t1.field_id,
t1.field_name,
t1.field_number,
t1.invigilator_id,
t1.field_status,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
e_distribution_field t1
WHERE
t1.is_delete = 0
<if test="distributionFieldId != null and distributionFieldId != ''">
AND
t1.distribution_field_id = #{distributionFieldId}
</if>
</select>
<!-- 考场分配详情详情 -->
<select id="getPO" parameterType="map" resultMap="distributionFieldPO">
SELECT
t1.distribution_field_id,
t1.distribution_id,
t1.field_id,
t1.field_name,
t1.field_number,
t1.invigilator_id,
t1.field_status,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
e_distribution_field t1
WHERE
t1.is_delete = 0
<if test="distributionFieldId != null and distributionFieldId != ''">
AND
t1.distribution_field_id = #{distributionFieldId}
</if>
</select>
<!-- 考场分配详情列表 -->
<select id="list" parameterType="map" resultMap="distributionFieldDTO">
SELECT
t1.distribution_field_id,
t1.distribution_id,
t1.field_id,
t1.field_name,
t1.field_number,
t1.invigilator_id,
t1.field_status,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete,
1
FROM
e_distribution_field t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="distributionId != null and distributionId != ''">
AND t1.distribution_id = #{distributionId}
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="distributionFieldIds != null and distributionFieldIds.size > 0">
AND
t1.distribution_field_id IN
<foreach collection="distributionFieldIds" index="index" open="(" separator="," close=")">
#{distributionFieldIds[${index}]}
</foreach>
</if>
</select>
<!-- 考场分配详情列表 -->
<select id="listBO" parameterType="map" resultMap="distributionFieldBO">
SELECT
t1.distribution_field_id,
t1.distribution_id,
t1.field_id,
t1.field_name,
t1.field_number,
t1.invigilator_id,
t1.field_status,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
e_distribution_field t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="distributionFieldIds != null and distributionFieldIds.size > 0">
AND
t1.distribution_field_id IN
<foreach collection="distributionFieldIds" index="index" open="(" separator="," close=")">
#{distributionFieldIds[${index}]}
</foreach>
</if>
</select>
<!-- 考场分配详情列表 -->
<select id="listPO" parameterType="map" resultMap="distributionFieldPO">
SELECT
t1.distribution_field_id,
t1.distribution_id,
t1.field_id,
t1.field_name,
t1.field_number,
t1.invigilator_id,
t1.field_status,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
e_distribution_field t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="distributionFieldIds != null and distributionFieldIds.size > 0">
AND
t1.distribution_field_id IN
<foreach collection="distributionFieldIds" index="index" open="(" separator="," close=")">
#{distributionFieldIds[${index}]}
</foreach>
</if>
</select>
<!-- 考场分配详情统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
e_distribution_field t1
WHERE
t1.is_delete = 0
</select>
</mapper>