DriverMapper.xml 20.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
<?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.ruoyi.driver.mapper.DriverMapper">

    <resultMap type="Driver" id="DriverResult">
        <result property="id" column="id"/>
        <result property="jobCode" column="job_code"/>
        <result property="companyCode" column="company_code"/>
        <result property="brancheCompanyCode" column="branche_company_code"/>
        <result property="personnelName" column="personnel_name"/>
        <result property="papersCode" column="papers_code"/>
        <result property="icCardCode" column="ic_card_code"/>
        <result property="personnelType" column="personnel_type"/>
        <result property="posts" column="posts"/>
        <result property="card" column="card"/>
        <result property="telphone" column="telphone"/>
        <result property="icRfid" column="ic_rfid"/>
        <result property="idRfid" column="id_rfid"/>
        <result property="tagRfid" column="tag_rfid"/>
        <result property="remark" column="remark"/>
        <result property="lineName" column="line_name"/>
        <result property="lineCode" column="line_code"/>
        <result property="updateTime" column="update_time"/>
        <result property="fleetName" column="fleet_name"/>
    </resultMap>
    <resultMap id="PeopleResult" type="com.ruoyi.pojo.vo.PeopleResponseVo">

        <result property="jobCode" column="job_code"/>
        <result property="fleetName" column="fleet_name"/>
        <result property="posts" column="posts"/>
        <result property="name" column="personnel_name"/>
        <result property="startDate" column="start_date"/>
    </resultMap>
    <sql id="selectDriverVo">
        select id,
               job_code,
               company_code,
               branche_company_code,
               personnel_name,
               papers_code,
               ic_card_code,
               personnel_type,
               posts,
               card,
               telphone,
               ic_rfid,
               id_rfid,
               tag_rfid,
               remark,
               line_name,
               line_code,
               face_sign_in,
               image,
               update_time,
               sign_in_equipment,
               fleet_name
        from driver
    </sql>
    <sql id="insertDriverVo">
        job_code
        , company_code, branche_company_code, personnel_name, papers_code, ic_card_code, personnel_type, posts, card, telphone, ic_rfid, id_rfid, tag_rfid, remark, line_name, line_code,face_sign_in,image,update_time,sign_in_equipment,fleet_name
    </sql>

    <select id="selectDriverList" parameterType="Driver" resultMap="DriverResult">
        select
        distinct
        driver.id,
        driver.job_code,
        driver.company_code,
        driver.branche_company_code,
        driver.personnel_name,
        driver.papers_code,
        driver.ic_card_code,
        driver.personnel_type,
        driver.posts,
        driver.card,
        driver.telphone,
        driver.ic_rfid,
        driver.id_rfid,
        driver.tag_rfid,
        driver.remark,
        driver.line_name,
        driver.line_code,
        driver.face_sign_in,
        driver.image,
        driver.update_time,
        driver.sign_in_equipment,
        driver.fleet_name
        from driver
        left join driver_face_device_id on driver.job_code = driver_face_device_id.job_code
        <where>
            <if test="deviceId != null and deviceId != ''">and device_id = #{deviceId}</if>
            <if test="jobCode != null  and jobCode != ''">and driver.job_code = #{jobCode}</if>
            <if test="companyCode != null  and companyCode != ''">and driver.company_code = #{companyCode}</if>
            <if test="brancheCompanyCode != null  and brancheCompanyCode != ''">and driver.branche_company_code =
                #{brancheCompanyCode}
            </if>
            <if test="personnelName != null  and personnelName != ''">and driver.personnel_name like concat('%',
                #{personnelName}, '%')
            </if>
            <if test="papersCode != null  and papersCode != ''">and driver.papers_code = #{papersCode}</if>
            <if test="icCardCode != null  and icCardCode != ''">and driver.ic_card_code = #{icCardCode}</if>
            <if test="personnelType != null  and personnelType != ''">and driver.personnel_type = #{personnelType}</if>
            <if test="posts != null  and posts != ''">and driver.posts = #{posts}</if>
            <if test="card != null  and card != ''">and driver.card = #{card}</if>
            <if test="telphone != null  and telphone != ''">and driver.telphone = #{telphone}</if>
            <if test="icRfid != null  and icRfid != ''">and driver.ic_rfid = #{icRfid}</if>
            <if test="idRfid != null  and idRfid != ''">and driver.id_rfid = #{idRfid}</if>
            <if test="tagRfid != null  and tagRfid != ''">and driver.tag_rfid = #{tagRfid}</if>
            <if test="lineName != null  and lineName != ''">and driver.line_name like concat('%', #{lineName}, '%')</if>
            <if test="lineCode != null  and lineCode != ''">and driver.line_code = #{lineCode}</if>
            <if test="faceSignIn != null ">and driver.face_sign_in = #{faceSignIn}</if>
            <if test="fleetName != null  and fleet_name != ''">and driver.fleet_name = #{fleetName}</if>
        </where>
    </select>

    <select id="selectDriverById" parameterType="Long" resultMap="DriverResult">
        <include refid="selectDriverVo"/>
        where id = #{id}
    </select>
    <select id="getNameByJobCode" resultMap="DriverResult">
        select personnel_name,job_code
        from driver

        <if test="jobCodes != null and jobCodes.size() > 0">
            <where>
                job_code IN
                <foreach collection="jobCodes" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </where>
        </if>
    </select>
    <select id="jobCodeIsEmpty" resultType="java.lang.Integer">
        select count(*)
        from driver
        where job_code = #{jobCode}
    </select>
    <select id="getDriverImageByJobCode" resultType="String">
        select image
        from driver
        where job_code = #{jobCode}
    </select>
    <select id="getDrivers" resultType="com.ruoyi.driver.domain.Driver">
        <include refid="selectDriverVo"/>
        <where>
            <if test="jobCode != null  and jobCode != ''">and job_code = #{jobCode}</if>
            <if test="companyCode != null  and companyCode != ''">and company_code = #{companyCode}</if>
            <if test="brancheCompanyCode != null  and brancheCompanyCode != ''">and branche_company_code =
                #{brancheCompanyCode}
            </if>
            <if test="personnelName != null  and personnelName != ''">and personnel_name like concat('%',
                #{personnelName}, '%')
            </if>
            <if test="papersCode != null  and papersCode != ''">and papers_code = #{papersCode}</if>
            <if test="icCardCode != null  and icCardCode != ''">and ic_card_code = #{icCardCode}</if>
            <if test="personnelType != null  and personnelType != ''">and personnel_type = #{personnelType}</if>
            <if test="posts != null  and posts != ''">and posts = #{posts}</if>
            <if test="card != null  and card != ''">and card = #{card}</if>
            <if test="telphone != null  and telphone != ''">and telphone = #{telphone}</if>
            <if test="icRfid != null  and icRfid != ''">and ic_rfid = #{icRfid}</if>
            <if test="idRfid != null  and idRfid != ''">and id_rfid = #{idRfid}</if>
            <if test="tagRfid != null  and tagRfid != ''">and tag_rfid = #{tagRfid}</if>
            <if test="lineName != null  and lineName != ''">and line_name like concat('%', #{lineName}, '%')</if>
            <if test="lineCode != null  and lineCode != ''">and line_code = #{lineCode}</if>
            <if test="faceSignIn != null  and faceSignIn != ''">and face_sign_in = #{faceSignIn}</if>
        </where>
    </select>
    <select id="getDriverInfoByJobCode" resultType="com.ruoyi.driver.domain.Driver">
        <include refid="selectDriverVo"></include>
        where job_code = #{jobCode}
    </select>
    <select id="queryJobCodesIsExists" resultType="java.lang.String">
        select job_code
        from driver
        where job_code in
        <foreach collection="jobCodes" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
    <select id="queryAttendanceInfoById" resultType="com.ruoyi.pojo.vo.PeopleResponseVo" resultMap="PeopleResult">
        SELECT driver.job_code,
               driver.personnel_name,
               driver.posts,
               driver.fleet_name,
               rule_setting_driver.start_date
        FROM driver,
             rule_setting_driver
        WHERE driver.job_code = rule_setting_driver.job_code
          and rule_setting_driver.setting_id = #{id}
    </select>
    <select id="queryAttendanceInfoAll" resultType="com.ruoyi.pojo.vo.PeopleResponseVo" resultMap="PeopleResult">
        SELECT job_code,
               personnel_name,
               posts,
               fleet_name
        FROM driver
--         WHERE driver.posts != "驾驶员" and driver.posts != "售票员"
    </select>
    <select id="queryEmptyJob" resultType="java.lang.String">
        SELECT
        d1.job_code
        FROM
        (
        SELECT job_code FROM driver WHERE job_code IN
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        ) d1
    </select>
    <select id="selectDriverListAll" resultType="com.ruoyi.driver.domain.Driver">
        select job_code, line_name, personnel_name, posts, fleet_name from driver
    </select>

    <insert id="insertDriver" parameterType="Driver" useGeneratedKeys="true" keyProperty="id">
        insert into driver
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jobCode != null and jobCode != ''">job_code,</if>
            <if test="companyCode != null and companyCode != ''">company_code,</if>
            <if test="brancheCompanyCode != null">branche_company_code,</if>
            <if test="personnelName != null">personnel_name,</if>
            <if test="papersCode != null">papers_code,</if>
            <if test="icCardCode != null">ic_card_code,</if>
            <if test="personnelType != null">personnel_type,</if>
            <if test="posts != null">posts,</if>
            <if test="card != null">card,</if>
            <if test="telphone != null">telphone,</if>
            <if test="icRfid != null">ic_rfid,</if>
            <if test="idRfid != null">id_rfid,</if>
            <if test="tagRfid != null">tag_rfid,</if>
            <if test="remark != null">remark,</if>
            <if test="lineName != null">line_name,</if>
            <if test="lineCode != null">line_code,</if>
            <if test="faceSignIn != null">face_sign_in,</if>
            <if test="image != null">image,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="fleetName != null">fleet_name</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="jobCode != null and jobCode != ''">#{jobCode},</if>
            <if test="companyCode != null and companyCode != ''">#{companyCode},</if>
            <if test="brancheCompanyCode != null">#{brancheCompanyCode},</if>
            <if test="personnelName != null">#{personnelName},</if>
            <if test="papersCode != null">#{papersCode},</if>
            <if test="icCardCode != null">#{icCardCode},</if>
            <if test="personnelType != null">#{personnelType},</if>
            <if test="posts != null">#{posts},</if>
            <if test="card != null">#{card},</if>
            <if test="telphone != null">#{telphone},</if>
            <if test="icRfid != null">#{icRfid},</if>
            <if test="idRfid != null">#{idRfid},</if>
            <if test="tagRfid != null">#{tagRfid},</if>
            <if test="remark != null">#{remark},</if>
            <if test="lineName != null">#{lineName},</if>
            <if test="lineCode != null">#{lineCode},</if>
            <if test="faceSignIn != null">#{faceSignIn},</if>
            <if test="image != null">#{image},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="fleetName != null">#{fleetName}</if>
        </trim>
        on duplicate key update
        job_code = values(job_code)
    </insert>

    <update id="updateDriver" parameterType="Driver">
        update driver
        <trim prefix="SET" suffixOverrides=",">
            <if test="jobCode != null and jobCode != ''">job_code = #{jobCode},</if>
            <if test="companyCode != null and companyCode != ''">company_code = #{companyCode},</if>
            <if test="brancheCompanyCode != null">branche_company_code = #{brancheCompanyCode},</if>
            <if test="personnelName != null">personnel_name = #{personnelName},</if>
            <if test="papersCode != null">papers_code = #{papersCode},</if>
            <if test="icCardCode != null">ic_card_code = #{icCardCode},</if>
            <if test="personnelType != null">personnel_type = #{personnelType},</if>
            <if test="posts != null">posts = #{posts},</if>
            <if test="card != null">card = #{card},</if>
            <if test="telphone != null">telphone = #{telphone},</if>
            <if test="icRfid != null">ic_rfid = #{icRfid},</if>
            <if test="idRfid != null">id_rfid = #{idRfid},</if>
            <if test="tagRfid != null">tag_rfid = #{tagRfid},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="lineName != null">line_name = #{lineName},</if>
            <if test="lineCode != null">line_code = #{lineCode},</if>
            <if test="faceSignIn != null">face_sign_in = #{faceSignIn},</if>
            <if test="image != null">image = #{image},</if>
            <if test="signInEquipment != null">sign_in_equipment = #{signInEquipment},</if>
            <if test="fleetName != null">fleet_name = #{fleetName}</if>
        </trim>
        where id = #{id}
    </update>
    <update id="updateDriverByComputed">
        update driver
        set face_sign_in = 0
        WHERE face_sign_in != 1 and job_code in (
            SELECT job_code
            FROM driver_face_device_id,equipment
            WHERE equipment.`status` = 1 and driver_face_device_id.device_id = equipment.device_id
            GROUP BY job_code
            HAVING COUNT(*) = #{count}
            );
        update driver
        set face_sign_in = 0
        WHERE face_sign_in = 1
          and job_code in (SELECT job_code
                           FROM driver_face_device_id,
                                equipment
                           WHERE equipment.`status` = 1
                             and driver_face_device_id.device_id = equipment.device_id
                           GROUP BY job_code
                           HAVING COUNT(*) = #{count});
        update driver
        set face_sign_in = 2
        WHERE face_sign_in != 1 and job_code not in (
            SELECT job_code
            FROM driver_face_device_id,equipment
            WHERE equipment.`status` = 1 and driver_face_device_id.device_id = equipment.device_id
            GROUP BY job_code
            HAVING COUNT(*) = #{count}
            );
    </update>
    <update id="updateSignStatusDriversByJobCodes">
        <foreach collection="list" item="item" separator=";">
            update driver set face_sign_in = 1,update_time = #{item.updateTime}
            <if test="item.image != null and item.image != ''">
                ,image = #{item.image}
            </if>
            where job_code = #{item.jobCode,jdbcType=VARCHAR}
        </foreach>
    </update>
    <update id="updateDriverInfoByJobCodes">
        <foreach collection="drivers" item="item" separator=";">
            update driver set
            line_name=#{item.lineName,jdbcType=VARCHAR},fleet_name=#{item.fleetName,jdbcType=VARCHAR},personnel_name =
            #{item.personnelName,jdbcType=VARCHAR},posts = #{item.posts,jdbcType=VARCHAR}
            where job_code = #{item.jobCode,jdbcType=VARCHAR}
        </foreach>
    </update>
    <update id="updateDriverBaseInfoByJobCodes">
        <foreach collection="list" item="item" separator=";">
            update driver set update_time = #{item.updateTime}
            <if test="item.lineName != null and item.lineName != ''">
                ,line_name =#{item.lineName}
            </if>
            <if test="item.fleetName != null and item.fleetName != ''">
                ,fleet_name =#{item.fleetName}
            </if>
            <if test="item.posts != null and item.posts != ''">
                ,`posts` =#{item.posts}
            </if>
            <if test="item.personnelName != null and item.personnelName != ''">
                ,`personnel_name` =#{item.personnelName}
            </if>
            <if test="item.image != null and item.image != '' and filterImage == 0">
                ,image = #{item.image},face_sign_in = 1
            </if>
            where job_code = #{item.jobCode,jdbcType=VARCHAR}
        </foreach>
    </update>

    <delete id="deleteDriverById" parameterType="Long">
        delete
        from driver
        where id = #{id}
    </delete>

    <delete id="deleteDriverByIds" parameterType="String">
        delete from driver where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteDeviceIdAssociatedJobCode">
        delete from driver_face_device_id where
        job_code in
        ( <foreach collection="jobCodes" item="item" separator=",">
        #{item}
    </foreach> )
    </delete>
    <delete id="deleteNotEmptyJob">
        DELETE
        FROM driver WHERE job_code NOT IN (
        SELECT
        d1.job_code
        FROM
        (
        SELECT job_code FROM driver WHERE job_code IN
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        ) d1
        )
    </delete>


    <insert id="saveDrivers">

        INSERT INTO driver (
        <include refid="insertDriverVo"></include>
        )
        VALUES
        <foreach collection="drivers" item="item" index="index" separator=",">
            (
            #{item.jobCode,jdbcType=VARCHAR},
            #{item.companyCode,jdbcType=VARCHAR},
            #{item.brancheCompanyCode,jdbcType=VARCHAR},
            #{item.personnelName,jdbcType=VARCHAR},
            #{item.papersCode,jdbcType=VARCHAR},
            #{item.icCardCode,jdbcType=VARCHAR},
            #{item.personnelType,jdbcType=VARCHAR},
            #{item.posts,jdbcType=VARCHAR},
            #{item.card,jdbcType=VARCHAR},
            #{item.telphone,jdbcType=VARCHAR},
            #{item.icRfid,jdbcType=VARCHAR},
            #{item.idRfid,jdbcType=VARCHAR},
            #{item.tagRfid,jdbcType=VARCHAR},
            #{item.remark,jdbcType=VARCHAR},
            #{item.lineName,jdbcType=VARCHAR},
            #{item.lineCode,jdbcType=VARCHAR},
            #{item.faceSignIn},
            #{item.image},
            #{item.updateTime},
            #{item.signInEquipment},
            #{item.fleetName}
            )
        </foreach>
        on duplicate key update
        job_code = values(job_code)
    </insert>
    <insert id="insertDriverFace">
        INSERT INTO driver_face_device_id ( job_code,device_id )
        values
        <foreach collection="jobCodes" item="item" index="index" separator=",">
            (
            #{item},#{deviceId}
            )
        </foreach>
        on duplicate key update
        job_code = values(job_code),
        device_id = values(device_id)
    </insert>
    <insert id="saveScheduling">
        insert into
        scheduling
        (id,schedule_date,line_name,line_code,job_code,posts,lp_name,nbbm,jsy,spy,up_down,qdz_code,qdz_name,zdz_code,zdz_name,fcsj_t,dfsj_t,zdsj_t,fcsj_actual_time,zdsj_actual_time,jhlc,jhlc_orig,bcsj,bc_type,`status`,adjust_exps,sflj,remarks)
        values
        <foreach collection="responseSchedulingDto" item="item" open="(" separator="," close=")">
            #{item.id},
            #{item.scheduleDate},
            #{item.lineName},
            #{item.lineCode},
            #{item.jobCode},
            #{item.posts},
            #{item.lpName},
            #{item.nbbm},
            #{item.jsy},
            #{item.spy},
            #{item.upDown},
            #{item.qdzCode},
            #{item.qdzName},
            #{item.zdzCode},
            #{item.zdzName},
            #{item.fcsjT},
            #{item.dfsjT},
            #{item.zdsjT},
            #{item.fcsjActualTime},
            #{item.zdsjActualTime},
            #{item.jhlc},
            #{item.jhlcOrig},
            #{item.bcsj},
            #{item.bcType},
            #{item.status},
            #{item.adjustExps},
            #{item.sflj},
            #{item.remarks}
        </foreach>

    </insert>

</mapper>