OrganizeMapper.xml 16.9 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.insight.mapper.OrganizeMapper">
    
    <resultMap type="com.chinagas.modules.insight.domian.Organize" id="OrganizeResult">
        <result property="id"    column="id"    />
        <result property="reportNo"    column="report_no"    />
        <result property="reportName"    column="report_name"    />
        <result property="fiscalYear"    column="fiscal_year"    />
        <result property="area"    column="area"    />
        <result property="areaName"    column="area_name"    />
        <result property="budgetSubject"    column="budget_subject"    />
        <result property="entity"    column="entity"    />
        <result property="statusCode"    column="status_code"    />
        <result property="statusName"    column="status_name"    />
        <result property="validityTimeStart"    column="validity_time_start"    />
        <result property="validityTimeEnd"    column="validity_time_end"    />
        <result property="leader"    column="leader"    />
        <result property="deputyLeader"    column="deputy_leader"    />
        <result property="member"    column="member"    />
        <result property="implementationSituation"    column="implementation_situation"    />
        <result property="attachmentsUrl"    column="attachments_url"    />
        <result property="appraisalResult"    column="appraisal_result"    />
        <result property="rejectReason"    column="reject_reason"    />
        <result property="sysCtime"    column="sys_ctime"    />
        <result property="sysUtime"    column="sys_utime"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="seeProfession"    column="see_profession"    />
        <result property="seeMarket"    column="see_market"    />
        <result property="seeCompete"    column="see_compete"    />
        <result property="seeSelf"    column="see_self"    />
        <result property="seeChance"    column="see_chance"    />
        <result property="deleteFlag"    column="delete_flag"    />
    </resultMap>

    <sql id="selectOrganizeVo">
        select id, report_no, report_name, fiscal_year, area, area_name, budget_subject, entity, status_code, status_name, validity_time_start, validity_time_end,
               leader, deputy_leader, member, implementation_situation, attachments_url, reject_reason, appraisal_result, sys_ctime, sys_utime,
               create_by, update_by, see_profession, see_market, see_compete, see_self, see_chance, delete_flag from organize
    </sql>

    <select id="selectOrganizeList" parameterType="com.chinagas.modules.insight.vo.OrganizeVO" resultMap="OrganizeResult">
        <include refid="selectOrganizeVo"/>
        <where>  
            <if test="reportNo != null  and reportNo != ''"> and report_no = #{reportNo}</if>
            <if test="reportName != null  and reportName != ''"> and report_name like concat('%', #{reportName}, '%')</if>
            <if test="fiscalYear != null and fiscalYear != '' "> and fiscal_year REGEXP #{fiscalYear}</if>
            <if test="area != null  and area != ''"> and area REGEXP #{area}</if>
            <if test="areaName != null  and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
            <if test="budgetSubject != null  and budgetSubject != ''"> and budget_subject REGEXP #{budgetSubject}</if>
            <if test="entity != null  and entity != ''"> and entity REGEXP #{entity}</if>
            <if test="statusCode != null "> and status_code = #{statusCode}</if>
            <if test="statusName != null "> and status_name like concat('%', #{statusName}, '%')</if>
            <if test="validityTimeStart != null "> and validity_time_start = #{validityTimeStart}</if>
            <if test="validityTimeEnd != null "> and validity_time_end = #{validityTimeEnd}</if>
            <if test="leader != null  and leader != ''"> and leader = #{leader}</if>
            <if test="deputyLeader != null  and deputyLeader != ''"> and deputy_leader = #{deputyLeader}</if>
            <if test="member != null  and member != ''"> and member = #{member}</if>
            <if test="implementationSituation != null  and implementationSituation != ''"> and implementation_situation = #{implementationSituation}</if>
            <if test="attachmentsUrl != null  and attachmentsUrl != ''"> and attachments_url = #{attachmentsUrl}</if>
            <if test="rejectReason != null  and rejectReason != ''"> and reject_reason = #{rejectReason}</if>
            <if test="appraisalResult != null "> and appraisal_result = #{appraisalResult}</if>
            <if test="sysCtime != null "> and sys_ctime = #{sysCtime}</if>
            <if test="sysUtime != null "> and sys_utime = #{sysUtime}</if>
            <if test="seeProfession != null  and seeProfession != ''"> and see_profession = #{seeProfession}</if>
            <if test="seeMarket != null  and seeMarket != ''"> and see_market = #{seeMarket}</if>
            <if test="seeCompete != null  and seeCompete != ''"> and see_compete = #{seeCompete}</if>
            <if test="seeSelf != null  and seeSelf != ''"> and see_self = #{seeSelf}</if>
            <if test="seeChance != null  and seeChance != ''"> and see_chance = #{seeChance}</if>
            and delete_flag = 0 order by sys_ctime DESC
        </where>
    </select>
    
    <select id="selectOrganizeById" resultMap="OrganizeResult">
        <include refid="selectOrganizeVo"/>
        where report_no = #{reportNo}
    </select>
        
    <insert id="insertOrganize" parameterType="com.chinagas.modules.insight.domian.Organize">
        insert into organize
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="reportNo != null and reportNo != ''">report_no,</if>
            <if test="reportName != null and reportName != ''">report_name,</if>
            <if test="fiscalYear != null">fiscal_year,</if>
            <if test="area != null and area != ''">area,</if>
            <if test="areaName != null and areaName != ''">area_name,</if>
            <if test="budgetSubject != null and budgetSubject != ''">budget_subject,</if>
            <if test="entity != null and entity != ''">entity,</if>
            <if test="statusCode != null">status_code,</if>
            <if test="statusName != null">status_name,</if>
            <if test="validityTimeStart != null">validity_time_start,</if>
            <if test="validityTimeEnd != null">validity_time_end,</if>
            <if test="leader != null and leader != ''">leader,</if>
            <if test="deputyLeader != null and deputyLeader != ''">deputy_leader,</if>
            <if test="member != null and member != ''">member,</if>
            <if test="implementationSituation != null and implementationSituation != ''">implementation_situation,</if>
            <if test="attachmentsUrl != null and attachmentsUrl != ''">attachments_url,</if>
            <if test="rejectReason != null and rejectReason != ''">reject_reason,</if>
            <if test="appraisalResult != null ">appraisal_result,</if>
            <if test="sysCtime != null">sys_ctime,</if>
            <if test="sysUtime != null">sys_utime,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="seeProfession != null and seeProfession != ''">see_profession,</if>
            <if test="seeMarket != null and seeMarket != ''">see_market,</if>
            <if test="seeCompete != null and seeCompete != ''">see_compete,</if>
            <if test="seeSelf != null and seeSelf != ''">see_self,</if>
            <if test="seeChance != null and seeChance != ''">see_chance,</if>
            <if test="deleteFlag != null">delete_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="reportNo != null and reportNo != ''">#{reportNo},</if>
            <if test="reportName != null and reportName != ''">#{reportName},</if>
            <if test="fiscalYear != null">#{fiscalYear},</if>
            <if test="area != null and area != ''">#{area},</if>
            <if test="areaName != null and areaName != ''">#{areaName},</if>
            <if test="budgetSubject != null and budgetSubject != ''">#{budgetSubject},</if>
            <if test="entity != null and entity != ''">#{entity},</if>
            <if test="statusCode != null">#{statusCode},</if>
            <if test="statusName != null">#{statusName},</if>
            <if test="validityTimeStart != null">#{validityTimeStart},</if>
            <if test="validityTimeEnd != null">#{validityTimeEnd},</if>
            <if test="leader != null and leader != ''">#{leader},</if>
            <if test="deputyLeader != null and deputyLeader != ''">#{deputyLeader},</if>
            <if test="member != null and member != ''">#{member},</if>
            <if test="implementationSituation != null and implementationSituation != ''">#{implementationSituation},</if>
            <if test="attachmentsUrl != null and attachmentsUrl != ''">#{attachmentsUrl},</if>
            <if test="rejectReason != null and rejectReason != ''">#{rejectReason},</if>
            <if test="appraisalResult != null ">#{appraisalResult},</if>
            <if test="sysCtime != null">#{sysCtime},</if>
            <if test="sysUtime != null">#{sysUtime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="seeProfession != null and seeProfession != ''">#{seeProfession},</if>
            <if test="seeMarket != null and seeMarket != ''">#{seeMarket},</if>
            <if test="seeCompete != null and seeCompete != ''">#{seeCompete},</if>
            <if test="seeSelf != null and seeSelf != ''">#{seeSelf},</if>
            <if test="seeChance != null and seeChance != ''">#{seeChance},</if>
            <if test="deleteFlag != null">#{deleteFlag},</if>
         </trim>
    </insert>

    <update id="updateOrganize" parameterType="com.chinagas.modules.insight.domian.Organize">
        update organize
        <trim prefix="SET" suffixOverrides=",">
            <if test="reportName != null and reportName != ''">report_name = #{reportName},</if>
            <if test="fiscalYear != null">fiscal_year = #{fiscalYear},</if>
            <if test="area != null and area != ''">area = #{area},</if>
            <if test="areaName != null and areaName != ''">area_name = #{areaName},</if>
            <if test="budgetSubject != null and budgetSubject != ''">budget_subject = #{budgetSubject},</if>
            <if test="entity != null and entity != ''">entity = #{entity},</if>
            <if test="statusCode != null">status_code = #{statusCode},</if>
            <if test="statusName != null">status_name = #{statusName},</if>
            <if test="validityTimeStart != null">validity_time_start = #{validityTimeStart},</if>
            <if test="validityTimeEnd != null">validity_time_end = #{validityTimeEnd},</if>
            <if test="leader != null and leader != ''">leader = #{leader},</if>
            <if test="deputyLeader != null and deputyLeader != ''">deputy_leader = #{deputyLeader},</if>
            <if test="member != null and member != ''">member = #{member},</if>
            <if test="implementationSituation != null and implementationSituation != ''">implementation_situation = #{implementationSituation},</if>
            <if test="attachmentsUrl != null and attachmentsUrl != ''">attachments_url = #{attachmentsUrl},</if>
            <if test="rejectReason != null and rejectReason != ''">reject_reason = #{rejectReason},</if>
            <if test="appraisalResult != null ">appraisal_result = #{appraisalResult},</if>
            <if test="sysCtime != null">sys_ctime = #{sysCtime},</if>
            <if test="sysUtime != null">sys_utime = #{sysUtime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="seeProfession != null and seeProfession != ''">see_profession = #{seeProfession},</if>
            <if test="seeMarket != null and seeMarket != ''">see_market = #{seeMarket},</if>
            <if test="seeCompete != null and seeCompete != ''">see_compete = #{seeCompete},</if>
            <if test="seeSelf != null and seeSelf != ''">see_self = #{seeSelf},</if>
            <if test="seeChance != null and seeChance != ''">see_chance = #{seeChance},</if>
            <if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
        </trim>
        where report_no = #{reportNo}
    </update>

    <update id="deleteOrganizeById" parameterType="com.chinagas.modules.insight.domian.Organize">
        update organize
        <trim prefix="SET" suffixOverrides=",">
            delete_flag = 1
        </trim>
        where report_no = #{reportNo}
    </update>

<!--    <delete id="deleteOrganizeById" parameterType="Long">-->
<!--        delete from organize where id = #{id}-->
<!--    </delete>-->

    <delete id="deleteOrganizeByIds" parameterType="String">
        delete from organize where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="selectByReportNameExist" resultMap="OrganizeResult">
        select * from organize
        where report_name = #{reportName}
        and delete_flag = 0
        limit 1
    </select>

    <update id="updateByReportNo" parameterType="com.chinagas.modules.insight.domian.Organize">
        update organize
        <trim prefix="SET" suffixOverrides=",">
            <if test="reportName != null and reportName != ''">report_name = #{reportName},</if>
            <if test="fiscalYear != null">fiscal_year = #{fiscalYear},</if>
            <if test="area != null and area != ''">area = #{area},</if>
            <if test="areaName != null and areaName != ''">area_name = #{areaName},</if>
            <if test="budgetSubject != null and budgetSubject != ''">budget_subject = #{budgetSubject},</if>
            <if test="entity != null and entity != ''">entity = #{entity},</if>
            <if test="statusCode != null">status_code = #{statusCode},</if>
            <if test="statusName != null">status_name = #{statusName},</if>
            <if test="validityTimeStart != null">validity_time_start = #{validityTimeStart},</if>
            <if test="validityTimeEnd != null">validity_time_end = #{validityTimeEnd},</if>
            <if test="leader != null and leader != ''">leader = #{leader},</if>
            <if test="deputyLeader != null and deputyLeader != ''">deputy_leader = #{deputyLeader},</if>
            <if test="member != null and member != ''">member = #{member},</if>
            <if test="implementationSituation != null and implementationSituation != ''">implementation_situation = #{implementationSituation},</if>
            <if test="attachmentsUrl != null and attachmentsUrl != ''">attachments_url = #{attachmentsUrl},</if>
            <if test="rejectReason != null and rejectReason != ''">reject_reason = #{rejectReason},</if>
            <if test="appraisalResult != null ">appraisal_result = #{appraisalResult},</if>
            <if test="sysCtime != null">sys_ctime = #{sysCtime},</if>
            <if test="sysUtime != null">sys_utime = #{sysUtime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="sProfession != null and sProfession != ''">s_profession = #{sProfession},</if>
            <if test="sMarket != null and sMarket != ''">s_market = #{sMarket},</if>
            <if test="sCompete != null and sCompete != ''">s_compete = #{sCompete},</if>
            <if test="sSelf != null and sSelf != ''">s_self = #{sSelf},</if>
            <if test="sChance != null and sChance != ''">s_chance = #{sChance},</if>
            <if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
        </trim>
        where report_no = #{reportNo}
    </update>

    <select id="selectCountByStatus" resultType="java.lang.Integer">
        select count(*)
        from organize
        where status_code = #{status}
        and fiscal_year = #{fiscalYear}
        <if test="entity != null  and entity != ''"> and entity REGEXP #{entity}</if>
        and delete_flag = 0
    </select>

    <select id="countGrowth"  parameterType="String" resultType="int">
        SELECT count(1) FROM organize WHERE sys_ctime like concat (#{formatTime}, '%') and delete_flag = 0
    </select>

    <select id="selectOrganizeListByMonth"  resultMap="OrganizeResult">
        SELECT * FROM organize WHERE PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( sys_ctime, '%Y%m' ) ) =1
        and delete_flag = 0
    </select>

</mapper>