<?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.tc.mapper.AssetCurrentMapper">


    <select id="page" resultType="com.ruoyi.tc.entity.AssetCurrent">
        select * from asset_current
        <where>
            del_flag = '0'
            <if test="req.xtmc!=null and req.xtmc!='' ">
                and xtmc like concat('%',#{req.xtmc},'%')
            </if>
            <if test="req.dwmc!=null and req.dwmc!='' ">
                and dwmc like concat('%',#{req.dwmc},'%')
            </if>
            <if test="req.xtlx!=null">
                and xtlx = #{req.xtlx}
            </if>
            <if test="req.xtzt!=null">
                and xtzt = #{req.xtzt}
            </if>
            <if test="req.startTime != null ">
                and create_time &gt;= #{req.startTime}
            </if>
            <if test="req.endTime != null">
                and create_time &lt;= #{req.endTime}
            </if>
        </where>
        order by create_time desc
    </select>

    <select id="page1" resultType="com.ruoyi.tc.entity.AssetExport">
        SELECT
        a.*,
        b.*,
        c.*,
        d.*,
        e.*,
        l.*
        FROM
        asset_current a
        LEFT JOIN ( SELECT asset_id, NAME, tyshxydm, lxr, lxdh, gyszcdz, sfwtc FROM asset_supply_chain WHERE type = 5 GROUP BY asset_id ) b ON a.id = b.asset_id
        LEFT JOIN (
        SELECT
        asset_id,
        NAME AS name1,
        tyshxydm AS tyshxydm1,
        lxr AS lxr1,
        lxdh AS lxdh1,
        gyszcdz AS gyszcdz1,
        sfwtc AS sfwtc1
        FROM
        asset_supply_chain
        WHERE
        type = 7
        GROUP BY
        asset_id
        ) c ON a.id = c.asset_id
        LEFT JOIN (
        SELECT
        asset_id,
        sblx,
        pp,
        sb_ip AS sbIp,
        czxt,
        czxtbb,
        yjxh,
        yjxlh,
        yjbbxx,
        yjyt,
        yjbsxx
        FROM
        asset_basic_network
        WHERE
        type = 1
        GROUP BY
        asset_id
        ) d ON a.id = d.asset_id
        LEFT JOIN (
        SELECT
        asset_id,
        sblx AS wlsblx,
        pp AS wlpp,
        sb_ip AS wlsbIp,
        yjxh AS wlyjxh,
        yjxlh AS wlyjxlh,
        yjbbxx AS wlyjbbxx,
        yjyt AS wlyjyt,
        yjbsxx AS wlyjbsxx
        FROM
        asset_basic_network
        WHERE
        type = 2
        GROUP BY
        asset_id
        ) e ON a.id = e.asset_id
        LEFT JOIN ( SELECT
                        asset_id, sblx AS aqwlsblx, pp AS aqwlpp, sb_ip AS aqwlsbIp
                    FROM asset_basic_network WHERE type = 3 GROUP BY asset_id ) l ON a.id = l.asset_id
        <where>
            a.del_flag = '0' and a.isbf = '0'
            <if test="req.xtmc!=null and req.xtmc!='' ">
                and a.xtmc like concat('%',#{req.xtmc},'%')
            </if>
            <if test="req.dwmc!=null and req.dwmc!='' ">
                and a.dwmc like concat('%',#{req.dwmc},'%')
            </if>
            <if test="req.xtlx!=null">
                and a.xtlx = #{req.xtlx}
            </if>
            <if test="req.xtzt!=null">
                and a.xtzt = #{req.xtzt}
            </if>
            <if test="req.startTime != null ">
                and a.create_time &gt;= #{req.startTime}
            </if>
            <if test="req.endTime != null">
                and a.create_time &lt;= #{req.endTime}
            </if>
        </where>
        order by create_time desc
    </select>
    <update id="deleteByUnitIds">
        update asset_current
        set del_flag = '2'
        where id = #{id}
    </update>
</mapper>