WorkstationRequireMappingMapper.xml 3.17 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.laowu.mapper.WorkstationRequireMappingMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.laowu.model.WorkstationRequireMappingDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="delete_date" property="deleteDate" />
        <result column="station_id" property="stationId" />
        <result column="require_id" property="requireId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, station_id, require_id
    </sql>

    <select id="requires" resultType="com.laowu.vo.station.RequiresVO">
        SELECT
        distinct t.id,
        t.company_id,
        t.item_status,
        t2.company_name,
        t.province,
        t.city,
        t.county,
        t.item_name,
        t.job_id,
        t4.station_id
        FROM
        position_require_item t
        LEFT JOIN company_dict t2 ON t.company_id = t2.id
        LEFT JOIN position_item_info t3 ON t.id = t3.position_require_id
        left join workstation_require_mapping t4 on t.id = t4.require_id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        and t3.delete_date is null
        and t4.delete_date is null
        <if test="itemName != null and itemName != ''">
            and t.item_name like concat('%', #{itemName}, '%')
        </if>
        <if test="itemStatus != null and itemStatus != ''">
            and t.item_status = #{itemStatus}
        </if>
        <if test="province != null and province !=''">
            AND t.province = #{province}
        </if>
        <if test="city != null and city != ''">
            AND t.city = #{city}
        </if>
        <if test="county != null and county != ''">
            AND t.county = #{county}
        </if>
        <if test="positionId != null and positionId != ''">
            and t3.position_id = #{positionId}
        </if>
        <if test="stationId != null and stationId != ''">
            and t4.station_id = #{stationId}
        </if>
        <if test="stationId == null ">
            and t.origin_id is null
        </if>
    </select>

    <select id="requiresStations" parameterType="long" resultType="long">
        SELECT
            t.station_id
        FROM
            workstation_require_mapping t
        WHERE
            t.delete_date IS NULL
            AND t.require_id = #{requireId}
    </select>

    <select id="requireWorkstations" parameterType="long" resultType="com.laowu.vo.position.RequireWorkstationsVO">
        SELECT
            t2.id,
            t2.workstation_name,
            t.create_date
        FROM
            workstation_require_mapping t
            LEFT JOIN workstation_dict t2 ON t.station_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.require_id = #{requireId}
    </select>

</mapper>