FundMainMapper.xml 9.36 KB
<?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.chinagas.modules.zjwjsb.mapper.FundMainMapper">
    <resultMap id="fundMainResult" type="FundMain">
        <id property="mainId" column="main_id"/>
        <result property="headId"  column="head_id"/>
        <result property="title"  column="title"/>
        <result property="status"  column="status"/>
        <result property="statusName" column="status_name"/>
        <result property="bizId" column="biz_id"/>
        <result property="paySum"  column="pay_sum"/>
        <result property="deptId" column="dept_id"/>
        <result property="deptName" column="dept_name"/>
        <result property="applyDate" column="apply_date"/>
        <result property="applyBy" column="apply_by"/>
        <result property="approvalDate" column="approval_date"/>
        <result property="remark" column="remark"/>
        <collection property="fundDetailList" column="main_id"   javaType="java.util.List"   ofType="FundDetail" select="selectFundDetail" />
        <collection  property="attachmentList" column="main_id"   javaType="java.util.List"   ofType="Attachment" select="selectAttachmentByMainId" />
    </resultMap>

    <resultMap id="fundDetailResult" type="FundDetail">
        <id property="id" column="id"/>
        <id property="mainId" column="main_id"/>
        <id property="bizId" column="biz_id"/>
        <id property="payNo" column="pay_no"/>
        <id property="title" column="title"/>
        <id property="approval" column="approval"/>
        <id property="hasPay" column="has_pay"/>
        <id property="waitForPay" column="wait_for_pay"/>
        <id property="approvalForPay" column="approval_for_pay"/>
        <id property="itemClass" column="item_class"/>
        <id property="itemClassName" column="item_class_name"/>
        <id property="applyDate" column="apply_date"/>
        <id property="status" column="status"/>
        <id property="statusName" column="status_name"/>
        <id property="delFlag" column="del_flag"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
    </resultMap>

    <sql id="selectFundMainVo" >
        select
            p.main_id,
            p.head_id,
            p.title,
            p.status,
            p.status_name,
            p.biz_id,
            p.pay_sum,
            p.dept_id,
            p.dept_name,
            p.apply_date,
            p.apply_by,
            p.approval_date,
            p.remark
        from ta_fund_main p
    </sql>

    <select id="selectFundDetail" resultMap="fundDetailResult">
        select d.id,d.main_id,d.biz_id,d.pay_no,d.title,d.approval,d.has_pay,d.wait_for_pay,d.approval_for_pay,d.item_class,d.item_class_name,
               d.apply_date,d.status,d.status_name,d.del_flag,d.create_time,d.create_by,d.update_time,d.update_by
        from ta_fund_main m join ta_fund_detail d on m.main_id = d.main_id where m.main_id = #{mainId} and d.del_flag = '0'
    </select>

    <select id="selectAttachmentByMainId" resultType="Attachment">
        select attachment_id,attachment_name,url,process_id,path,final_path,attachment_type from zjwjsb_attachment where process_id = #{mainId}
    </select>

    <select id="selectFundMainList" parameterType="FundMain" resultMap="fundMainResult">
        <include refid="selectFundMainVo"/>
        where 1 = 1
        <if test="mainId != null and mainId != ''">
            and p.main_id like concat('%',#{mainId},'%')
        </if>
        <if test="headId != null and headId != ''">
            and p.head_id like concat('%',#{headId},'%')
        </if>
        <if test="title != null and title != ''">
            and p.title like concat('%',#{title},'%')
        </if>
        <if test="status != null and status != ''">
            and p.status = #{status}
        </if>
        <if test="statusName != null and statusName != ''">
            and p.status_name = #{statusName}
        </if>
        <if test="bizId != null and bizId != ''">
            and p.biz_id = #{bizId}
        </if>
        <if test="paySum != null and paySum != ''">
            and p.pay_sum = #{paySum}
        </if>
        <if test="deptId != null and deptId != ''">
            and p.dept_id = #{deptId}
        </if>
        <if test="deptName != null and deptName != ''">
            and p.dept_name = #{deptName}
        </if>
        <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
            AND date_format(p.apply_date,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
        </if>
        <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
            AND date_format(p.apply_date,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
        </if>
        <if test="applyBy != null and applyBy != ''">
            and p.apply_by = #{applyBy}
        </if>
        <if test="params.approvalBeginTime != null and params.approvalBeginTime != ''"><!-- 开始时间检索 -->
            AND date_format(p.approval_date,'%y%m%d') &gt;= date_format(#{params.approvalBeginTime},'%y%m%d')
        </if>
        <if test="params.approvalEndTime != null and params.approvalEndTime != ''"><!-- 结束时间检索 -->
            AND date_format(p.approval_date,'%y%m%d') &lt;= date_format(#{params.approvalEndTime},'%y%m%d')
        </if>
        <if test="remark != null and remark != ''">
            and p.remark like concat('%',#{remark},'%')
        </if>
        ${params.dataScope}
        order by p.apply_date desc
    </select>

    <insert id="insertFundMain" parameterType="FundMain">
        insert into ta_fund_main(
        <trim suffix="" suffixOverrides=",">
            <if test="mainId != null and mainId != ''">main_id,</if>
            <if test="headId != null and headId != ''">head_id,</if>
            <if test="title != null and title != ''">title,</if>
            <if test="status != null">status,</if>
            <if test="statusName != null and statusName != ''">status_name,</if>
            <if test="bizId != null and bizId != ''">biz_id,</if>
            <if test="paySum != null">pay_sum,</if>
            <if test="deptId != null and deptId != ''">dept_id,</if>
            <if test="deptName != null and deptName != ''">dept_name,</if>
            <if test="applyDate != null">apply_date,</if>
            <if test="applyBy != null and applyBy != ''">apply_by,</if>
            <if test="approvalDate != null">approval_date,</if>
            <if test="remark != null and remark != ''">remark,</if>
        </trim>
        )  values(
        <trim suffix="" suffixOverrides=",">
            <if test="mainId != null and mainId != ''">#{mainId},</if>
            <if test="headId != null and headId != ''">#{headId},</if>
            <if test="title != null and title != ''">#{title},</if>
            <if test="status != null">#{status},</if>
            <if test="statusName != null and statusName != ''">#{statusName},</if>
            <if test="bizId != null and bizId != ''">#{bizId},</if>
            <if test="paySum != null">#{paySum},</if>
            <if test="deptId != null and deptId != ''">#{deptId},</if>
            <if test="deptName != null and deptName != ''">#{deptName},</if>
            <if test="applyDate != null">#{applyDate, jdbcType=TIMESTAMP},</if>
            <if test="applyBy != null and applyBy != ''">#{applyBy},</if>
            <if test="approvalDate != null">#{approvalDate, jdbcType=TIMESTAMP},</if>
            <if test="remark != null and remark != ''">#{remark},</if>
        </trim>
        )
    </insert>

    <update id="updateFundMain" parameterType="FundMain">
        update ta_fund_main
        <trim prefix="SET" suffixOverrides=",">
            <if test="headId != null and headId != ''">head_id = #{headId},</if>
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="status != null">status = #{status},</if>
            <if test="statusName != null and statusName != ''">status_name = #{statusName},</if>
            <if test="bizId != null and bizId != ''">biz_id = #{bizId},</if>
            <if test="paySum != null">pay_sum = #{paySum},</if>
            <if test="deptId != null and deptId != ''">dept_id = #{deptId},</if>
            <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
            <if test="applyDate != null">apply_date = #{applyDate, jdbcType=TIMESTAMP},</if>
            <if test="applyBy != null and applyBy != ''">apply_by = #{applyBy},</if>
            <if test="approvalDate != null">approval_date = #{approvalDate, jdbcType=TIMESTAMP},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</if>
        </trim>
        where main_id = #{mainId}
    </update>

    <select id="selectFundMainByMainId" parameterType="String" resultMap="fundMainResult">
        <include refid="selectFundMainVo"/> where main_id = #{mainId}
    </select>

    <select id="selectFundMainByHeadId" parameterType="String" resultMap="fundMainResult">
        <include refid="selectFundMainVo"/> where head_id = #{headId}
    </select>

    <select id="ifFundMainExist" resultType="int" parameterType="String">
        select count(1) from ta_fund_main where main_id = #{mainId}
    </select>

</mapper>