| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- <?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.keao.edu.user.dao.ExamOrganizationRelationDao">
-
- <resultMap type="com.keao.edu.user.entity.ExamOrganizationRelation" id="ExamOrganizationRelation">
- <result column="id_" property="id" />
- <result column="examination_basic_id_" property="examinationBasicId" />
- <result column="organ_id_" property="organId" />
- <result column="settlement_type_" property="settlementType" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler" />
- <result column="share_profit_amount_" property="shareProfitAmount" />
- <result column="self_registration_student_num_" property="selfRegistrationStudentNum" />
- <result column="self_payment_amount_" property="selfPaymentAmount" />
- <result column="total_registration_student_num_" property="totalRegistrationStudentNum"/>
- <result column="total_payment_amount_" property="totalPaymentAmount"/>
- <result column="total_trans_amount_" property="totalTransAmount" />
- <result column="url_" property="url" />
- <result column="send_url_flag_" property="sendUrlFlag" />
- <result column="is_allow_arrange_exam_" property="isAllowArrangeExam" />
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- <result column="tenant_id_" property="tenantId" />
- </resultMap>
- <resultMap id="ExamOrganizationRelationExtraDto" type="com.keao.edu.user.dto.ExamOrganizationRelationExtraDto" extends="ExamOrganizationRelation">
- <result column="organ_name_" property="organizationName"/>
- </resultMap>
- <resultMap id="ExamOrganStatisticsDto" type="com.keao.edu.user.dto.ExamOrganStatisticsDto" extends="ExamOrganizationRelation">
- </resultMap>
-
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="ExamOrganizationRelation" >
- SELECT * FROM exam_organization_relation WHERE id_ = #{id}
- </select>
-
- <!-- 全查询 -->
- <select id="findAll" resultMap="ExamOrganizationRelation">
- SELECT * FROM exam_organization_relation WHERE tenant_id_#{tenantId} ORDER BY id_
- </select>
-
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.keao.edu.user.entity.ExamOrganizationRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- INSERT INTO exam_organization_relation (examination_basic_id_,organ_id_,settlement_type_,share_profit_amount_,
- self_registration_student_num_,self_payment_amount_,total_registration_student_num_,total_payment_amount_,
- url_,send_url_flag_,is_allow_arrange_exam_,total_trans_amount_,
- create_time_,update_time_,tenant_id_)
- VALUES(#{examinationBasicId},#{organId},#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{shareProfitAmount},
- #{selfRegistrationStudentNum},#{selfPaymentAmount},#{totalRegistrationStudentNum},#{totalPaymentAmount},
- #{url},#{sendUrlFlag},#{isAllowArrangeExam},#{totalTransAmount},
- NOW(),NOW(),#{tenantId})
- </insert>
- <insert id="batchInsert" parameterType="com.keao.edu.user.entity.ExamOrganizationRelation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- INSERT INTO exam_organization_relation (examination_basic_id_,organ_id_,settlement_type_,share_profit_amount_,
- self_registration_student_num_,self_payment_amount_,total_registration_student_num_,total_payment_amount_,
- url_,send_url_flag_,is_allow_arrange_exam_,total_trans_amount_,
- create_time_,update_time_,tenant_id_)
- VALUES
- <foreach collection="examOrganizationRelations" item="examOrganizationRelation" separator=",">
- (#{examOrganizationRelation.examinationBasicId},#{examOrganizationRelation.organId},
- #{examOrganizationRelation.settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
- #{examOrganizationRelation.shareProfitAmount},
- #{examOrganizationRelation.selfRegistrationStudentNum},
- #{examOrganizationRelation.selfPaymentAmount},
- #{examOrganizationRelation.totalRegistrationStudentNum},
- #{examOrganizationRelation.totalPaymentAmount},#{examOrganizationRelation.url},
- #{examOrganizationRelation.sendUrlFlag},
- #{examOrganizationRelation.isAllowArrangeExam},
- #{examOrganizationRelation.totalTransAmount},
- NOW(),NOW(),#{examOrganizationRelation.tenantId})
- </foreach>
- </insert>
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.keao.edu.user.entity.ExamOrganizationRelation">
- UPDATE exam_organization_relation
- <set>
- <if test="examinationBasicId != null">
- examination_basic_id_ = #{examinationBasicId},
- </if>
- <if test="sendUrlFlag != null">
- send_url_flag_ = #{sendUrlFlag},
- </if>
- <if test="isAllowArrangeExam != null">
- is_allow_arrange_exam_ = #{isAllowArrangeExam},
- </if>
- <if test="url != null">
- url_ = #{url},
- </if>
- <if test="tenantId != null and tenantId != 0">
- tenant_id_ = #{tenantId},
- </if>
- <if test="shareProfitAmount != null">
- share_profit_amount_ = #{shareProfitAmount},
- </if>
- <if test="selfRegistrationStudentNum != null">
- self_registration_student_num_ = #{selfRegistrationStudentNum},
- </if>
- <if test="selfPaymentAmount != null">
- self_payment_amount_ = #{selfPaymentAmount},
- </if>
- <if test="totalRegistrationStudentNum != null">
- total_registration_student_num_ = #{totalRegistrationStudentNum},
- </if>
- <if test="totalPaymentAmount != null">
- total_payment_amount_ = #{totalPaymentAmount},
- </if>
- <if test="totalTransAmount != null">
- total_trans_amount_ = #{totalTransAmount},
- </if>
- <if test="organId != null">
- organ_id_ = #{organId},
- </if>
- <if test="settlementType != null">
- settlement_type_ = #{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
- </if>
- update_time_ = NOW()
- </set> WHERE id_ = #{id}
- </update>
- <update id="batchUpdate" parameterType="com.keao.edu.user.entity.ExamOrganizationRelation">
- <foreach collection="examOrganizationRelations" item="eo" separator=";">
- UPDATE exam_organization_relation
- <set>
- <if test="eo.examinationBasicId != null">
- examination_basic_id_ = #{eo.examinationBasicId},
- </if>
- <if test="eo.sendUrlFlag != null">
- send_url_flag_ = #{eo.sendUrlFlag},
- </if>
- <if test="eo.isAllowArrangeExam != null">
- is_allow_arrange_exam_ = #{eo.isAllowArrangeExam},
- </if>
- <if test="eo.url != null">
- url_ = #{eo.url},
- </if>
- <if test="eo.tenantId != null">
- tenant_id_ = #{eo.tenantId},
- </if>
- <if test="eo.shareProfitAmount != null">
- share_profit_amount_ = #{eo.shareProfitAmount},
- </if>
- <if test="eo.selfRegistrationStudentNum != null">
- self_registration_student_num_ = #{eo.selfRegistrationStudentNum},
- </if>
- <if test="eo.selfPaymentAmount != null">
- self_payment_amount_ = #{eo.selfPaymentAmount},
- </if>
- <if test="eo.totalRegistrationStudentNum != null">
- total_registration_student_num_ = #{eo.totalRegistrationStudentNum},
- </if>
- <if test="eo.totalPaymentAmount != null">
- total_payment_amount_ = #{eo.totalPaymentAmount},
- </if>
- <if test="eo.totalTransAmount != null">
- total_trans_amount_ = #{eo.totalTransAmount},
- </if>
- <if test="eo.organId != null">
- organ_id_ = #{eo.organId},
- </if>
- <if test="eo.settlementType != null">
- settlement_type_ = #{eo.settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
- </if>
- update_time_ = NOW()
- </set> WHERE id_ = #{eo.id}
- </foreach>
- </update>
- <update id="batchUpdateSendUrlFlag">
- UPDATE exam_organization_relation SET send_url_flag_=#{sendUrlFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
- WHERE examination_basic_id_=#{examId}
- <if test="organIds!=null">
- AND organ_id_ IN
- <foreach collection="organIds" item="organId" separator="," open="(" close=")">
- #{organId}
- </foreach>
- </if>
- </update>
- <!-- 根据主键删除一条记录 -->
- <delete id="delete" >
- DELETE FROM exam_organization_relation WHERE id_ = #{id}
- </delete>
- <delete id="deleteExamOrgans">
- DELETE FROM exam_organization_relation
- WHERE examination_basic_id_=#{examId} AND organ_id_ IN
- <foreach collection="organIds" item="organId" separator="," open="(" close=")">
- #{organId}
- </foreach>
- </delete>
- <sql id="queryCondition">
- <where>
- ear.examination_basic_id_=#{examId}
- <if test="organIds!=null">
- AND ear.organ_id_ IN
- <foreach collection="organIds" item="organId" separator="," open="(" close=")">
- #{organId}
- </foreach>
- </if>
- <if test="settlementType!=null">
- AND ear.settlement_type_=#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="isAllowArrangeExam!=null">
- AND ear.is_allow_arrange_exam_ = #{isAllowArrangeExam}
- </if>
- <if test="search!=null">
- AND (ear.organ_id_=#{search} OR a.name_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- </where>
- </sql>
-
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="ExamOrganizationRelationExtraDto" parameterType="map">
- SELECT
- ear.*,
- a.name_ organ_name_
- FROM exam_organization_relation ear
- LEFT JOIN organization a ON ear.organ_id_=a.id_
- <include refid="queryCondition"/>
- ORDER BY id_ <include refid="global.limit"/>
- </select>
-
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM exam_organization_relation ear
- LEFT JOIN organization a ON ear.organ_id_=a.id_
- <include refid="queryCondition"/>
- </select>
- <select id="queryExamOrgans" resultMap="ExamOrganizationRelationExtraDto" parameterType="map">
- SELECT
- ear.*,
- a.name_ organ_name_
- FROM exam_organization_relation ear
- LEFT JOIN organization a ON ear.organ_id_=a.id_
- <include refid="queryCondition"/>
- ORDER BY id_ <include refid="global.limit"/>
- </select>
- <select id="countExamOrgans" resultType="int">
- SELECT COUNT(*) FROM exam_organization_relation ear
- LEFT JOIN organization a ON ear.organ_id_=a.id_
- <include refid="queryCondition"/>
- </select>
- <select id="getWithExam" resultMap="ExamOrganizationRelation">
- SELECT * FROM exam_organization_relation WHERE examination_basic_id_=#{examId}
- </select>
- <select id="getOrganIdsWithExam" resultType="int">
- SELECT organ_id_ FROM exam_organization_relation WHERE examination_basic_id_=#{examId} FOR UPDATE
- </select>
- <select id="getWithExams" resultMap="ExamOrganizationRelation">
- SELECT * FROM exam_organization_relation WHERE examination_basic_id_ IN
- <foreach collection="examIds" item="examId" separator="," open="(" close=")">
- #{examId}
- </foreach>
- </select>
- <select id="getWithExamsAndOrgans" resultMap="ExamOrganizationRelation">
- SELECT * FROM exam_organization_relation WHERE examination_basic_id_ IN
- <foreach collection="examIds" item="examId" separator="," open="(" close=")">
- #{examId}
- </foreach>
- <if test="organIds!=null">
- AND organ_id_ IN
- <foreach collection="organIds" item="organId" separator="," open="(" close=")">
- #{organId}
- </foreach>
- </if>
- </select>
- <select id="countExamOrganStudentAndPayment" resultMap="ExamOrganizationRelation">
- SELECT
- o.id_ organ_id_,
- SUM(eor.total_registration_student_num_) total_registration_student_num_,
- SUM(eor.total_payment_amount_) total_payment_amount_
- FROM
- organization o
- LEFT JOIN (
- SELECT
- eor1.id_,
- eor1.organ_id_,
- eor1.total_payment_amount_,
- eor1.total_registration_student_num_,
- o1.parent_organ_id_tag_
- FROM
- exam_organization_relation eor1
- LEFT JOIN organization o1 ON o1.id_ = eor1.organ_id_
- WHERE eor1.examination_basic_id_=#{examId}
- ) eor ON eor.parent_organ_id_tag_ LIKE CONCAT( o.parent_organ_id_tag_, '%' )
- <if test="organIds!=null">
- WHERE
- o.id_ IN
- <foreach collection="organIds" item="organId" separator="," open="(" close=")">
- #{organId}
- </foreach>
- </if>
- GROUP BY o.id_
- </select>
- <select id="findByOrganId" resultType="java.lang.Integer">
- SELECT COUNT(DISTINCT id_) FROM exam_organization_relation WHERE organ_id_ = #{organId}
- </select>
- <sql id="queryUnRelatedOrgansCondition">
- <where>
- <if test="tenantId != null and tenantId != 0">
- AND o.tenant_id_ = #{tenantId}
- </if>
- <if test="organIds!=null">
- AND o.id_ IN
- <foreach collection="organIds" item="organId" separator="," open="(" close=")">
- #{organId}
- </foreach>
- </if>
- AND NOT EXISTS ( SELECT organ_id_ FROM exam_organization_relation WHERE examination_basic_id_ = #{examId} AND organ_id_ = o.id_ )
- </where>
- </sql>
- <select id="queryUnRelatedOrgans" resultMap="com.keao.edu.user.dao.OrganizationDao.Organization">
- SELECT
- <include refid="com.keao.edu.user.dao.OrganizationDao.organizationColumn"/>
- FROM
- organization o
- <include refid="queryUnRelatedOrgansCondition"/>
- ORDER BY o.id_
- <include refid="global.limit"/>
- </select>
- <select id="countUnRelatedOrgans" resultType="int">
- SELECT
- COUNT(o.id_)
- FROM
- organization o
- <include refid="queryUnRelatedOrgansCondition"/>
- </select>
- <!-- 获取项目合作机构关联信息 -->
- <select id="getExamOrganizationRelation" resultMap="ExamOrganStatisticsDto">
- SELECT * FROM exam_organization_relation WHERE examination_basic_id_=#{examId} AND organ_id_=#{OrganId} FOR UPDATE
- </select>
- <select id="getExamOrganizationRelations" resultMap="ExamOrganizationRelation">
- SELECT * FROM exam_organization_relation WHERE examination_basic_id_=#{examId} AND organ_id_ IN
- <foreach collection="organIds" item="organId" separator="," open="(" close=")">
- #{organId}
- </foreach>
- </select>
- </mapper>
|