ApprovalMapper.xml 7.14 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="cn.com.glsx.admin.modules.mapper.ApprovalMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.Approval">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="biz_id" jdbcType="INTEGER" property="bizId"/>
        <result column="biz_type" jdbcType="TINYINT" property="bizType"/>
        <result column="status" jdbcType="TINYINT" property="status"/>
        <result column="node" jdbcType="INTEGER" property="node"/>
        <result column="node_name" jdbcType="VARCHAR" property="nodeName"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="version" jdbcType="INTEGER" property="version"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
        <result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, biz_id, biz_type, `status`, node, node_name, remark, version, del_flag, created_date,
        created_by, updated_date, updated_by, `result`
    </sql>

    <delete id="logicDeleteById">
    update t_approval set del_flag=1 where id=#{id}
  </delete>

    <select id="findAppByUser" resultMap="BaseResultMap">
        select * from t_approval
        and created_by in
        <foreach collection="userlist" item="userId" index="index" open="(" close=")" separator=",">
            #{userId}
        </foreach>
    </select>
    <select id="search" resultType="cn.com.glsx.admin.modules.model.ApprovalDto">
        select
        app.id as approvalId,
        app.biz_type as bizType,
        td.dict_label as busType,
        tu.username as username,
        app.status as status,
        app.created_date as createdDate
        from t_approval app
        left join t_vehicle tvd on app.biz_id = tvd.id and tvd.del_flag = 0
        left join t_user tu on app.created_by = tu.id and tu.del_flag = 0
        left join t_dict_data td on app.biz_type=td.dict_value
        where app.del_flag = 0 and app.status in (1,2,3) and td.dict_type='approval_bustype'
        <if test="approvalSearch.status == 1 ">
            and app.status=1
        </if>
        <if test="approvalSearch.status ==2 ">
            and app.status in (2,3)
        </if>
        <if test="approvalSearch.busType !=null and approvalSearch.busType != ''">
            and app.biz_type=#{approvalSearch.busType}
        </if>
        ORDER BY app.created_date desc
    </select>


    <select id="searchVehiclelicApp" resultType="cn.com.glsx.admin.modules.model.VehicleApproDto">
        SELECT
        t5.id as approvalId,
        t1.id as vehicleId,
        t6.username AS shopName,
        t6.account AS shopCode,
        t4.shop_level AS shopLevel,
        t1.vin,
        t1.created_by as createdBy,
        t1.inner_color AS innerColor,
        t1.color AS color,
        t1.model_name AS modelName,
        t1.vehicle_type AS vehicleType,
        t1.config_desc AS configDesc,
        t1.sale_manager as saleManager,
        t1.license_plate as licensePlate,
        t1.sale_manager_phone as saleManagerPhone,
        t1.remark as velRemark,
        t5.status as approvalStatus,
        (select dict_label from t_dict_data  where dict_value=t5.status and dict_type = 'approval_status') AS approvalResult,
        t5.remark as remark,
        t5.created_date as submitTime
        FROM
        t_approval t5
        LEFT JOIN t_vehicle t1 ON t1.ID = t5.biz_id
        LEFT JOIN t_trial_drive_shop t4 ON t1.created_by = t4.created_by
        LEFT JOIN t_user t6 ON t6.id = t1.created_by
        left join t_electric_fence t7 on t4.fence_id=t7.id
        WHERE
        t1.del_flag = 0
        and t5.status in (1,2,3)
        and t5.biz_type=2
        and t6.del_flag = 0
        and t5.id in(select max(id) from t_approval group by biz_id)
        <if test="search.approvalStatus !=null and search.approvalStatus != ''">
            and t5.status=#{search.approvalStatus}
        </if>
        <if test="search.keywords !=null and search.keywords != ''">
            and (t6.username like concat('%',#{search.keywords},'%')
            or t6.account like concat('%',#{search.keywords},'%')
            or t7.fence_name like concat('%',#{search.keywords},'%')

            )
        </if>
        GROUP BY
        t5.biz_id
        ORDER BY t5.created_date desc

    </select>
    <select id="searchFenceApp" resultType="cn.com.glsx.admin.modules.model.FenceApproDto">
        select
        app.id as approvalId,
        t6.username AS shopName,
        t6.account AS shopCode,
        shop.shop_level AS shopLevel,
        tvd.created_by as createdBy,
        app.remark as remark,
        tef.fence_name as fenceName,
        tvd.biz_fence_type as fenceTypeId,
        app.status as approvalStatus,
        td.dict_label as approvalResult,
        app.biz_id as bizId,
        if(tvd.fence_id is null,'1','2') as isAdd,
        tvd.fence_id as fenceId
        from t_approval app
        left join t_electric_fence_copy tvd on app.biz_id = tvd.id and tvd.del_flag = 0
        left join t_electric_fence tef on tvd.fence_id=tef.id
        left join t_trial_drive_shop shop on tvd.created_by=shop.created_by and shop.del_flag = 0
        LEFT JOIN t_user t6 ON t6.id = tvd.created_by
        left join t_dict_data td on app.status=td.dict_value
        where app.del_flag = 0 and app.status in (1,2,3) and td.dict_type='approval_status'
        AND APP.biz_type=1 and t6.username is not null
        and t6.del_flag = 0
        and tvd.id is not null
        <if test="search.approvalStatus !=null and search.approvalStatus != ''">
            and app.status=#{search.approvalStatus}
        </if>
        <if test="search.keywords !=null and search.keywords != ''">
            and (t6.username like concat('%',#{search.keywords},'%')
            or t6.account like concat('%',#{search.keywords},'%')
            or tvd.fence_name like concat('%',#{search.keywords},'%')
            )
        </if>

        GROUP BY
        app.id
        ORDER BY app.created_date desc
    </select>
    <select id="selectByTypeAndId" resultMap="BaseResultMap"
            parameterType="cn.com.glsx.admin.modules.entity.Approval">
        select * from t_approval
        where
        del_flag = 0
        <if test="approval.bizType==1">
        and status in (1)
        </if>
        <if test="approval.bizType==2">
            and status in (1,2)
        </if>
        and biz_type=#{approval.bizType}
        and biz_id=#{approval.bizId}
    </select>
    <select id="selectbyId" resultMap="BaseResultMap"
            parameterType="cn.com.glsx.admin.modules.entity.Approval">
        select * from t_approval
        where
        del_flag = 0 and status=1 and id=#{approval.id}
    </select>
</mapper>