OrganizationMapper.xml 13 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.lhcredit.project.business.organization.mapper.OrganizationMapper">
    
    <resultMap type="Organization" id="OrganizationResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="creditNo"    column="credit_no"    />
        <result property="orgType"    column="org_type"    />
        <result property="status"    column="status"    />
        <result property="operName"    column="oper_name"    />
        <result property="regAddress"    column="reg_address"    />
        <result property="startDate"    column="start_date"    />
        <result property="scope"    column="scope"    />
        <result property="registCapi"    column="regist_capi"    />
        <result property="scopeType"    column="scope_type"    />
        <result property="department"    column="department"    />
        <result property="creditLevel"    column="credit_level"    />
        <result property="creditScore"    column="credit_score"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delStatus"    column="del_status"    />
    </resultMap>
	
	<sql id="selectOrganizationVo">
        select id, name, credit_no, org_type, status, oper_name, reg_address, start_date, scope, regist_capi, scope_type, department, credit_level, credit_score, create_time, update_time, del_status from organization
    </sql>
	
    <select id="selectOrganizationList" parameterType="Organization" resultMap="OrganizationResult">
        <include refid="selectOrganizationVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="name != null  and name != '' "> and name = #{name}</if>
            <if test="creditNo != null  and creditNo != '' "> and credit_no = #{creditNo}</if>
            <if test="orgType != null  and orgType != '' "> and org_type = #{orgType}</if>
            <if test="status != null  and status != '' "> and status = #{status}</if>
            <if test="operName != null  and operName != '' "> and oper_name = #{operName}</if>
            <if test="regAddress != null  and regAddress != '' "> and reg_address = #{regAddress}</if>
            <if test="startDate != null  and startDate != '' "> and start_date = #{startDate}</if>
            <if test="scope != null  and scope != '' "> and scope = #{scope}</if>
            <if test="registCapi != null "> and regist_capi = #{registCapi}</if>
            <if test="scopeType != null  and scopeType != '' "> and scope_type = #{scopeType}</if>
            <if test="department != null  and department != '' "> and department = #{department}</if>
            <if test="creditLevel != null  and creditLevel != '' "> and credit_level = #{creditLevel}</if>
            <if test="creditScore != null "> and credit_score = #{creditScore}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
            <if test="delStatus != null  and delStatus != '' "> and del_status = #{delStatus}</if>
        </where>
    </select>
    
    <select id="selectOrganizationById" parameterType="Long" resultMap="OrganizationResult">
        <include refid="selectOrganizationVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertOrganization" parameterType="Organization" useGeneratedKeys="true" keyProperty="id">
        insert into organization
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="name != null  and name != ''  ">name,</if>
			<if test="creditNo != null  and creditNo != ''  ">credit_no,</if>
			<if test="orgType != null  and orgType != ''  ">org_type,</if>
			<if test="status != null  and status != ''  ">status,</if>
			<if test="operName != null  and operName != ''  ">oper_name,</if>
			<if test="regAddress != null  and regAddress != ''  ">reg_address,</if>
			<if test="startDate != null  and startDate != ''  ">start_date,</if>
			<if test="scope != null  and scope != ''  ">scope,</if>
			<if test="registCapi != null  ">regist_capi,</if>
			<if test="scopeType != null  and scopeType != ''  ">scope_type,</if>
			<if test="department != null  and department != ''  ">department,</if>
			<if test="creditLevel != null  and creditLevel != ''  ">credit_level,</if>
			<if test="creditScore != null  ">credit_score,</if>
			<if test="createTime != null  ">create_time,</if>
			<if test="updateTime != null  ">update_time,</if>
			<if test="delStatus != null  and delStatus != ''  ">del_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="name != null  and name != ''  ">#{name},</if>
			<if test="creditNo != null  and creditNo != ''  ">#{creditNo},</if>
			<if test="orgType != null  and orgType != ''  ">#{orgType},</if>
			<if test="status != null  and status != ''  ">#{status},</if>
			<if test="operName != null  and operName != ''  ">#{operName},</if>
			<if test="regAddress != null  and regAddress != ''  ">#{regAddress},</if>
			<if test="startDate != null  and startDate != ''  ">#{startDate},</if>
			<if test="scope != null  and scope != ''  ">#{scope},</if>
			<if test="registCapi != null  ">#{registCapi},</if>
			<if test="scopeType != null  and scopeType != ''  ">#{scopeType},</if>
			<if test="department != null  and department != ''  ">#{department},</if>
			<if test="creditLevel != null  and creditLevel != ''  ">#{creditLevel},</if>
			<if test="creditScore != null  ">#{creditScore},</if>
			<if test="createTime != null  ">#{createTime},</if>
			<if test="updateTime != null  ">#{updateTime},</if>
			<if test="delStatus != null  and delStatus != ''  ">#{delStatus},</if>
         </trim>
    </insert>
	 
    <update id="updateOrganization" parameterType="Organization">
        update organization
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null  and name != ''  ">name = #{name},</if>
            <if test="creditNo != null  and creditNo != ''  ">credit_no = #{creditNo},</if>
            <if test="orgType != null  and orgType != ''  ">org_type = #{orgType},</if>
            <if test="status != null  and status != ''  ">status = #{status},</if>
            <if test="operName != null  and operName != ''  ">oper_name = #{operName},</if>
            <if test="regAddress != null  and regAddress != ''  ">reg_address = #{regAddress},</if>
            <if test="startDate != null  and startDate != ''  ">start_date = #{startDate},</if>
            <if test="scope != null  and scope != ''  ">scope = #{scope},</if>
            <if test="registCapi != null  ">regist_capi = #{registCapi},</if>
            <if test="scopeType != null  and scopeType != ''  ">scope_type = #{scopeType},</if>
            <if test="department != null  and department != ''  ">department = #{department},</if>
            <if test="creditLevel != null  and creditLevel != ''  ">credit_level = #{creditLevel},</if>
            <if test="creditScore != null  ">credit_score = #{creditScore},</if>
            <if test="createTime != null  ">create_time = #{createTime},</if>
            <if test="updateTime != null  ">update_time = #{updateTime},</if>
            <if test="delStatus != null  and delStatus != ''  ">del_status = #{delStatus},</if>
        </trim>
        where id = #{id}
    </update>


    <update id="updateOrganizationByCode" parameterType="Organization">
        update organization
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null  and name != ''  ">name = #{name},</if>
            <if test="orgType != null  and orgType != ''  ">org_type = #{orgType},</if>
            <if test="status != null  and status != ''  ">status = #{status},</if>
            <if test="operName != null  and operName != ''  ">oper_name = #{operName},</if>
            <if test="regAddress != null  and regAddress != ''  ">reg_address = #{regAddress},</if>
            <if test="startDate != null  and startDate != ''  ">start_date = #{startDate},</if>
            <if test="scope != null  and scope != ''  ">scope = #{scope},</if>
            <if test="registCapi != null  ">regist_capi = #{registCapi},</if>
            <if test="scopeType != null  and scopeType != ''  ">scope_type = #{scopeType},</if>
            <if test="department != null  and department != ''  ">department = #{department},</if>
            <if test="creditLevel != null  and creditLevel != ''  ">credit_level = #{creditLevel},</if>
            <if test="creditScore != null  ">credit_score = #{creditScore},</if>
            <if test="createTime != null  ">create_time = #{createTime},</if>
            <if test="updateTime != null  ">update_time = #{updateTime},</if>
            <if test="delStatus != null  and delStatus != ''  ">del_status = #{delStatus},</if>
        </trim>
        where credit_no = #{creditNo}
    </update>

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

    <select id="selectAllOrganizationGroupLevel" resultType="java.util.Map">
        SELECT credit_level as creditLevel,count(*) as num from organization GROUP BY credit_level
    </select>

    <select id="selectAllOrganizationGroupReg" resultType="java.util.Map">
        SELECT registCapiStr,count(*) as num from ( select CASE
                                                        WHEN regist_capi &lt; 5 THEN '0(含)~5万'
                                                        WHEN regist_capi>=5 and regist_capi &lt; 10 THEN '5(含)~10万'
                                                        WHEN regist_capi>=10 and regist_capi &lt; 50 THEN '10(含)~50万'
                                                        WHEN regist_capi>=50 and regist_capi &lt; 100 THEN '50(含)~100万'
                                                        WHEN regist_capi>=100 and regist_capi &lt; 300 THEN '100(含)~300万'
                                                        WHEN regist_capi>=300 THEN '300万(含)以上'
                                                        END  as registCapiStr from organization
        ) as  org group by registCapiStr
    </select>

    <select id="selectAllOrganizationGroupOrgTyp" resultType="java.util.Map">
        SELECT org_type as orgType,count(*) as num from organization GROUP BY org_type
    </select>

    <select id="selectAllOrganizationGroupScopeTyp" resultType="java.util.Map">
        SELECT scope_type as scopeType,count(*) as num  from organization GROUP BY scope_type
    </select>

   <select id="selectAllOrganizationCount" resultType="Integer">
       SELECT count(*) as num from organization where del_status='0'
   </select>

    <select id="selectOrganizationListBy" parameterType="Organization" resultMap="OrganizationResult">
        select * from (SELECT TIMESTAMPDIFF(YEAR,start_date, NOW()) AS num,o.* FROM organization o) as org
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="name != null  and name != '' "> and name = #{name}</if>
            <if test="creditNo != null  and creditNo != '' "> and credit_no = #{creditNo}</if>
            <if test="orgType != null  and orgType != '' "> and org_type = #{orgType}</if>
            <if test="status != null  and status != '' "> and status = #{status}</if>
            <if test="operName != null  and operName != '' "> and oper_name = #{operName}</if>
            <if test="regAddress != null  and regAddress != '' "> and reg_address = #{regAddress}</if>
            <if test="scope != null  and scope != '' "> and scope = #{scope}</if>
            <if test="beginRegistCapi !=null">
                and regist_capi >= #{beginRegistCapi}
            </if>
            <if test="endRegistCapi !=null">
                and regist_capi &lt; #{endRegistCapi}
            </if>

            <if test="beginEstablish !=null">
                and num > #{beginEstablish}
            </if>
            <if test="endEstablish !=null">
                and mun &lt;= #{endEstablish}
            </if>
            <if test="scopeType != null  and scopeType != '' "> and scope_type = #{scopeType}</if>
            <if test="department != null  and department != '' "> and department = #{department}</if>
            <if test="creditLevel != null  and creditLevel != '' "> and credit_level = #{creditLevel}</if>
            <if test="creditScore != null "> and credit_score = #{creditScore}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
            <if test="delStatus != null  and delStatus != '' "> and del_status = #{delStatus}</if>
        </where>
    </select>

</mapper>