<?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.njcn.device.mapper.LineMapper">


    <select id="getDeviceBySubId" resultType="Device">
        select * from pq_line a
        inner join pq_device b on a.id=b.id
        where a.pid = #{subId}
        and a.state = 1
        and b.ip in
        <foreach collection="list" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
    </select>

    <select id="getDeviceBySubIdForUpdate" resultType="Device">
        select * from pq_line a
        inner join pq_device b on a.id=b.id
        where a.pid = #{subId}
        and a.state = 1
        and b.ip in
        <foreach collection="ipList" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and a.id not in
        <foreach collection="devList" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>


    <select id="getLineDetailByDeviceId" resultType="com.njcn.device.pojo.po.LineDetail">
        select c.id,
               c.num,
               c.pt1,
               c.pt2,
               c.ct1,
               c.ct2,
               c.Dev_Capacity      devCapacity,
               c.short_capacity    shortCapacity,
               c.standard_capacity standardCapacity,
               c.deal_capacity     dealCapacity
        from pq_line a
                 inner join pq_line b on a.id = b.pid
                 inner join pq_line_detail c on b.id = c.id
        where a.pid = #{devId}
          and a.state = 1
    </select>


    <select id="getVoltageByLineId" resultType="Voltage">
        select *
        from pq_line a
                 inner join pq_voltage b on a.pid = b.id
        where a.id = #{lineId}
          and a.state = 1
    </select>

    <select id="getAllList" resultType="TerminalTree">
        select id, pid, name, level, sort
        from pq_line
        where state = 1
    </select>

    <select id="getProvinceList" resultType="TerminalTree">
        select a.id,a.pid,b.name,a.level,a.sort from pq_line a
        inner join sys_area b on a.name = b.id
        where a.level = 1
        <if test="type == 1 and type !=null">
            and a.id in
            <foreach collection="pids" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        and a.state = 1
        order by a.sort
    </select>

    <select id="getInfoByIdList" resultType="TerminalTree">
        select id,pid,name,level,sort from pq_line
        where id in
        <foreach collection="ids" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and state = 1
        order by sort
    </select>

    <select id="getInfoByPidList">
        select a.id,a.pid,a.name,a.level,a.sort from pq_line
        where pid in
        <foreach collection="list" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and a.state = 1
        order by a.sort
    </select>

    <select id="getAllDeviceList" resultType="TerminalTree">
        select a.id,a.pid,b.com_flag comFlag,a.level,a.sort from pq_line a
        inner join pq_device b on a.id = b.id
        where a.id in
        <foreach collection="ids" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and a.level = 4
        and a.state = 1
        order by a.sort
    </select>

    <select id="getAllVolList" resultType="TerminalTree">
        select a.id,a.pid,a.name,c.name scale,a.level,a.sort from pq_line a
        inner join pq_voltage b on a.id = b.id
        inner join sys_dict_data c on b.scale = c.id
        where a.id in
        <foreach collection="ids" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and a.level = 5
        and a.state = 1
        order by a.sort
    </select>


    <select id="getAllLineList" resultType="TerminalTree">
        select a.id,a.pid,a.name,a.level,a.sort,b.pt_type
        from pq_line a
        inner join pq_line_detail b on a.id = b.id
        where a.id in
        <foreach collection="ids" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and a.state = 1
        order by sort
    </select>

    <!--华丽分割线   ++++                          -->

    <select id="getVoltageListByLineIds" resultType="TerminalTree">
        select distinct b.id,c.name,b.scale,b.level,b.sort from pq_line a
        inner join pq_voltage b on a.pid = b.id
        inner join sys_dict_data c on b.scale = c.id
        where a.id in
        <foreach collection="list" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        a.level = 5
        and a.state = 1
        order by a.sort
    </select>

    <!--母线-->
    <select id="getDevListByLineIds" resultType="TerminalTree">
        select c.id,c.pid,c.name,e.name manufacturer,c.level,c.sort
        from pq_line a
        inner join pq_line b on a.pid = b.id
        inner join pq_line c on b.pid = c.id
        inner join pq_device d on c.id = d.id
        inner join sys_dict_data e on d.manufacturer = e.id
        where a.id in
        <foreach collection="list" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and d.manufacturer = #{manufacturer}
        a.level = 5
        and a.state = 1
        order by a.sort
    </select>

    <!--设备-->
    <select id="getDevListByLineIds" resultType="TerminalTree">
        select c.id,c.pid,c.name,e.name manufacturer,c.level,c.sort
        from pq_line a
        inner join pq_line b on a.pid = b.id
        inner join pq_line c on b.pid = c.id
        inner join pq_device d on c.id = d.id
        inner join sys_dict_data e on d.manufacturer = e.id
        where a.id in
        <foreach collection="list" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and d.manufacturer = #{manufacturer}
        a.level = 5
        and a.state = 1
        order by a.sort
    </select>

    <select id="getDevListByLineIds" resultType="TerminalTree">
        select d.id,d.pid,d.name,f.name scale,d.level,d.sort
        from pq_line a
        inner join pq_line b on a.pid = b.id
        inner join pq_line c on b.pid = c.id
        inner join pq_line d on c.pid = d.id
        inner join pq_linedetail e on d.id = e.id
        inner join sys_dict_data f on e.scale = f.id
        where a.id in
        <foreach collection="list" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and d.manufacturer = #{manufacturer}
        a.level = 5
        and a.state = 1
        order by a.sort
    </select>


    <select id="getUnBindList" resultType="TerminalTree">
        select id, pid, name, level, sort
        from pq_line
        where state = 1
          and id not in (select Line_Id from pq_dept_line)
        order by sort
    </select>

    <select id="getBindList" resultType="TerminalTree">
        select id, pid, name, level, sort
        from pq_line
        where state = 1
          and id in (select Line_Id from pq_dept_line)
        order by sort
    </select>

    <select id="selectProject" resultType="String">
        select pid
        from pq_line
        where name = #{areaId}
    </select>

    <select id="getProviceName" resultType="String">
        select name
        from sys_area
        where id = #{areaId}
    </select>

    <select id="getDeviceById" resultType="Line">
        SELECT
        t1.*
        FROM
        pq_line t1,
        pq_device t2
        WHERE
        t1.id = t2.id
        <if test="deviceType.devModel!=null">
            AND t2.Dev_Model in
            <foreach collection="deviceType.devModel" open="(" close=")" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="deviceType.runFlag!=null">
            AND t2.Run_Flag in
            <foreach collection="deviceType.runFlag" open="(" close=")" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="deviceType.dataType!=null">
            AND t2.Dev_Data_Type in
            <foreach collection="deviceType.dataType" open="(" close=")" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        AND t1.id IN
        <foreach collection="devIds" open="(" close=")" item="item" separator=",">
            #{item}
        </foreach>
    </select>


    <select id="getLineDetail" resultType="com.njcn.web.pojo.vo.LineDataVO">
        SELECT line.*
        FROM PQ_LINE line
        WHERE line.id IN
        <foreach collection="ids" open="(" close=")" item="item" separator=",">
            #{item}
        </foreach>
        order by line.level asc
    </select>

    <select id="getLineByCondition" resultType="Line">
        select
        t1.*
        from
        pq_line t1 ,
        pq_line_detail t2
        where
        t1.id = t2.id
        and
        t1.id in
        <foreach collection="ids" separator="," open="(" close=")" item="item">
            #{item}
        </foreach>
        <if test="deviceInfoParam.monitorFlag!=2">
            and t2.Monitor_Flag = #{deviceInfoParam.monitorFlag}
        </if>
        <if test="deviceInfoParam.powerFlag!=2">
            and t2.Power_Flag = #{deviceInfoParam.powerFlag}
        </if>
        <if test="deviceInfoParam.loadType!=null">
            AND t2.Load_Type in
            <foreach collection="deviceInfoParam.loadType" open="(" close=")" item="item" separator=",">
                #{item.id}
            </foreach>
        </if>
        <!-- xy -->
        <choose>
            <when test="deviceInfoParam.statFlag">
                AND t2.Stat_Flag = 1
            </when>
        </choose>
        <!-- -->
    </select>

    <select id="getDeviceByCondition" resultType="Line">
        SELECT
        t1.*
        FROM
        pq_line t1,
        pq_device t2
        WHERE
        t1.id = t2.id
        <if test="deviceType.devModel!=null">
            AND t2.Dev_Model in
            <foreach collection="deviceType.devModel" open="(" close=")" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="deviceType.runFlag!=null">
            AND t2.Run_Flag in
            <foreach collection="deviceType.runFlag" open="(" close=")" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="deviceType.dataType!=null">
            AND t2.Dev_Data_Type in
            <foreach collection="deviceType.dataType" open="(" close=")" item="item" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="manufacturer!=null">
            AND t2.manufacturer in
            <foreach collection="manufacturer" open="(" close=")" item="item" separator=",">
                #{item.id}
            </foreach>
        </if>
        AND t1.id IN
        <foreach collection="devIds" open="(" close=")" item="item" separator=",">
            #{item}
        </foreach>
    </select>


    <select id="getVoltageByCondition" resultType="Line">
        select
        t1.*
        from
        pq_line t1 ,
        pq_voltage t2
        where
        t1.id = t2.id
        and
        t1.id in
        <foreach collection="voltageIds" separator="," open="(" close=")" item="item">
            #{item}
        </foreach>
        <if test="scale!=null">
            AND t2.scale in
            <foreach collection="scale" open="(" close=")" item="item" separator=",">
                #{item.id}
            </foreach>
        </if>
    </select>

    <select id="getVoltageIdByScale" resultType="String">
        select
        t1.id
        from
        pq_line t1 ,
        pq_voltage t2
        where
        t1.id = t2.id
        and
        t1.id in
        <foreach collection="voltageIds" separator="," open="(" close=")" item="item">
            #{item}
        </foreach>
        AND
        t2.scale = #{scale}
    </select>

    <select id="getLineIdByLoadType" resultType="String">
        select
        t1.id
        from
        pq_line t1 ,
        pq_line_detail t2
        where
        t1.id = t2.id
        and
        t1.id in
        <foreach collection="lineIds" separator="," open="(" close=")" item="item">
            #{item}
        </foreach>
        AND
        t2.Load_Type = #{loadType}
    </select>

    <select id="getDeviceIdByManufacturer" resultType="String">
        select
        t1.id
        from
        pq_line t1 ,
        pq_device t2
        where
        t1.id = t2.id
        and
        t1.id in
        <foreach collection="deviceIds" separator="," open="(" close=")" item="item">
            #{item}
        </foreach>
        AND
        t2.Manufacturer = #{manufacturer}
    </select>


    <select id="getAllLineOverLimit" resultType="OverLimit">
        select f.* from pq_line a
        inner join pq_line_detail b on a.id = b.id
        inner join pq_line c on a.pid = c.id
        inner join pq_line d on c.pid = d.id
        inner join pq_device e on d.id = e.id
        inner join pq_overlimit f on a.id=f.id
        where e.dev_data_type in
        <foreach collection="list" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and e.run_flag = 0
        and e.dev_model = 1
    </select>

    <select id="getBaseLineInfo" resultType="BaseLineInfo">
        SELECT
        line.Id,
        area.`Name` provincialName,
        gd.`Name` gdName,
        substation.`Name` subName,
        subscale.`Name` subScale,
        device.`Name` deviceName,
        pqdevice.IP networkParam,
        pqdevice.Com_Flag comState,
        factory.`Name` factoryName,
        pqdevice.Update_Time time,
        voltage.`Name` subvName,
        scale.`Name` subvScale,
        line.`Name` lineName,
        line.Sort
        FROM
        pq_line line,
        pq_line voltage,
        pq_voltage pqvoltage,
        pq_line device,
        pq_device pqdevice,
        pq_line substation,
        pq_substation pqsubstation,
        pq_line gd,
        pq_line provincial,
        sys_dict_data scale,
        sys_dict_data factory,
        sys_dict_data loadtype,
        sys_dict_data subscale,
        sys_area area
        WHERE
        line.pid = voltage.id
        AND voltage.id = pqvoltage.id
        AND pqvoltage.Scale = scale.id
        AND voltage.pid = device.id
        AND voltage.pid = pqdevice.id
        AND pqdevice.Manufacturer = factory.id
        AND device.pid = substation.id
        AND substation.id = pqsubstation.id
        AND pqsubstation.Scale = subscale.id
        AND substation.pid = gd.id
        AND gd.pid = provincial.id
        AND provincial.NAME = area.id
        AND line.Id IN
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
        GROUP BY line.id
    </select>

    <select id="getLineDeviceStateVO" resultType="com.njcn.device.pojo.vo.LineDeviceStateVO">
        SELECT
        t.id id,
        t.pids pids,
        t.NAME name,
        device.Com_Flag state
        FROM
        pq_line t,
        pq_line subv,
        pq_device device
        WHERE
        subv.id = t.pid
        AND device.id = subv.pid
        AND t.id in
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>

    <select id="getSubstationInfo" resultType="PollutionSubstationDTO">
        SELECT A.id,
               A.`Name` name,
               C.`Name` voltageLevel
        FROM pq_line A,
             pq_substation B,
             sys_dict_data C
        WHERE A.Id = #{id}
          AND A.Id = B.Id
          AND B.Scale = C.Id
    </select>

    <select id="getLineInfo" resultType="PollutionLineDTO">
        SELECT
        A.Id,
        A.`Name`,
        A1.Name busBar,
        A3.Name substation,
        A3.Id substationId,
        A4.Name powerCompany
        FROM
        pq_line A,
        pq_line A1,
        pq_line A2,
        pq_line A3,
        pq_line A4
        WHERE
        A.Id IN
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
        AND A.Pid = A1.Id
        AND A.State = 1
        AND A1.Pid = A2.Id
        AND A2.Pid = A3.Id
        AND A3.Pid = A4.Id
    </select>
    <select id="getLineSubGdDetail" resultType="com.njcn.device.pojo.vo.LineDetailVO">
        SELECT DISTINCT gd.NAME         gdName,
                        substation.NAME subName,
                        line.NAME       lineName
        FROM pq_line line,
             pq_line voltage,
             pq_line device,
             pq_line substation,
             pq_line gd
        WHERE line.pid = voltage.id
          AND voltage.pid = device.id
          AND device.pid = substation.id
          AND substation.pid = gd.id
          AND line.id = #{id}
    </select>

    <select id="getWarningSub" resultType="WarningSubstationDTO">
        SELECT
        A1.Id,
        A1.`Name` subName,
        B.`Name` scale,
        A2.`Name` city,
        D.`Name` province
        FROM
        pq_line A1,
        pq_line A2,
        pq_line A3,
        sys_dict_data B,
        pq_substation C,
        sys_area D
        WHERE
        A1.Id in
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
        AND A1.Pid = A2.Id AND A2.Pid = A3.Id AND A3.`Name` = D.Area_Code AND A1.Id = C.Id AND C.Scale = B.Id
    </select>

    <select id="getOverLimitLineInfo" resultType="OverLimitLineDTO">
        SELECT
        A1.id,
        A1.`Name` lineName,
        C1.`Name` lineScale,
        C2.`Name` loadType,
        D.Obj_Name lineObjectName,
        D.Monitor_Id monitorNumber,
        A4.`Name` subName,
        C3.`Name` subScale,
        A5.`Name` cityCompany,
        F.`Name` provinceCompany
        FROM
        pq_line A1,
        pq_line A2,
        pq_line A3,
        pq_line A4,
        pq_line A5,
        pq_line A6,
        pq_voltage B,
        sys_dict_data C1,
        sys_dict_data C2,
        sys_dict_data C3,
        pq_line_detail D,
        pq_substation E,
        sys_area F
        WHERE
        A1.id in
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
        AND A1.Pid = A2.Id AND A2.Id = B.Id AND B.Scale = C1.Id AND A1.Id = D.Id AND D.Load_Type = C2.Id
        AND A2.Pid = A3.Id AND A3.Pid = A4.Id AND A4.Pid = A5.Id AND A4.Id = E.Id AND E.Scale = C3.Id
        AND A5.Pid = A6.Id AND A6.`Name` = F.Area_Code
    </select>

    <select id="getLineStatisticsDetail" resultType="LineStateVO">
        SELECT
        count(IF( device.Run_Flag = 0, IF ( device.Com_Flag = 1, 1, NULL ), NULL )) normalStateNum,
        count(IF( device.Run_Flag = 0, IF ( device.Com_Flag = 0, 1, NULL ), NULL )) suspendStateNum,
        count( device.Run_Flag = 1 OR NULL ) hotSpareStateNum,
        count( device.Run_Flag = 2 OR NULL ) offStreamStateNum
        FROM
        pq_line line
        INNER JOIN pq_line voltage ON voltage.id = line.pid
        INNER JOIN pq_device device ON device.id = voltage.pid
        WHERE
        line.id IN
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>

    <select id="getLineInfoByTableList" resultType="LineStatisticsTableVO">
        SELECT
        Id,
        Pid,
        Pids,
        `Name`
        FROM
        pq_line
        WHERE
        Id IN
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>

    <select id="getLineStatisticsTableData" resultType="LineStatisticsTableVO">
        SELECT
        A.Id,
        A.Pid,
        A.Pids,
        A.`Name` name,
        D.run_flag runFlag,
        D.com_flag comFlag
        FROM
        pq_line A,
        pq_line B,
        pq_device D
        WHERE
        A.Id IN
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
        AND A.Pid = B.Id
        AND B.Pid = D.Id
    </select>
    <select id="getLineRunStatistics" resultType="LineFlowMealDetailVO">
        select t.*
        from (SELECT a.id,
        a.pid,
        a.pids,
        a.NAME name,
        a.level,
        a.update_Time updateTime,
        b.run_flag runFlag,
        b.com_flag comFlag,
        ifnull(d.flow, (select flow from cld_flow_meal where type = 0 and flag = 1)) +
        ifnull(d1.flow, 0) flowMeal
        FROM pq_line a
        INNER JOIN pq_line vol ON a.pid = vol.id
        INNER JOIN pq_device b ON vol.pid = b.id
        LEFT JOIN cld_dev_meal c ON b.id = c.line_id
        LEFT JOIN cld_flow_meal d ON c.Base_Meal_Id = d.id
        LEFT JOIN cld_flow_meal d1 ON c.Ream_Meal_Id = d1.id
        LEFT JOIN sys_dict_data e ON b.dev_type = e.id
        where a.id in
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
        )t
    </select>

    <select id="getFlowLineInfoByTableList" resultType="LineFlowMealDetailVO">
        SELECT
        Id,
        Pid,
        Pids,
        `level`,
        `Name`
        FROM
        pq_line
        WHERE
        Id IN
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>

    <select id="getFlowLineRunStatistics" resultType="LineFlowMealDetailVO">
        select t.*
        from (SELECT a.id,
        a.pid,
        a.pids,
        a.NAME name,
        a.level,
        a.update_Time updateTime,
        b.run_flag runFlag,
        b.com_flag comFlag,
        ifnull(d.flow, (select flow from cld_flow_meal where type = 0 and flag = 1)) +
        ifnull(d1.flow, 0) flowMeal
        FROM pq_line a
        INNER JOIN pq_device b ON a.id = b.id
        LEFT JOIN cld_dev_meal c ON b.id = c.line_id
        LEFT JOIN cld_flow_meal d ON c.Base_Meal_Id = d.id
        LEFT JOIN cld_flow_meal d1 ON c.Ream_Meal_Id = d1.id
        LEFT JOIN sys_dict_data e ON b.dev_type = e.id
        where a.id in
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
            )t
    </select>

    <select id="getLineList" resultType="string">
        SELECT
            A1.Id
        FROM
            pq_line A1,
            pq_line A2,
            pq_line A3,
            pq_line_detail B,
            pq_device C
        WHERE
          A1.`Level` = 6 AND A1.Id = B.Id AND
          A1.Pid = A2.Id AND A2.Pid = A3.Id AND A3.Id = C.Id AND
          C.Dev_Model = 1 AND C.Dev_Data_Type IN (1,2) AND C.Run_Flag = 0
    </select>




    <select id="getTerminalBaseExcel" resultType="TerminalBaseExcel">
        SELECT
	pj.NAME projectName,
	area.NAME provinceName,
	gd.NAME gdName,
	sub.NAME substationName,
	dic.NAME subStationScale,
	su.Lat,
	su.Lng,
	dev.NAME deviceName,
	d.Dev_Model,
	d.Dev_Data_Type,
	d.call_flag,
	d.Run_Flag,
	d.Com_Flag,
	dic6.name Manufacturer,
	dic7.name Dev_Type,
	d.ip,
	d.PORT,
	d.Series,
	d.Dev_Key,
	dic8.name frontType,
	node.NAME nodeName,
	vol.NAME subvName,
	vo.Num subvNum,
	dic2.NAME subvScale,
	vo.Model subvModel,
	line.NAME lineName,
	de.Num lineNum,
	concat( de.PT1, "/", de.PT2 ) AS pt,
	concat( de.CT1, "/", de.CT2 ) AS ct,
	de.Dev_Capacity,
	de.Short_Capacity,
	de.Standard_Capacity,
	de.Deal_Capacity,
	de.PT_Type,
	de.Time_Interval,
	dic4.name LoadType,
	dic5.name BusinessType,
	de.Monitor_Id,
	de.Obj_Name,
	de.power_flag,
	de.Stat_Flag,
	dic3.name lineGrade,
	de.Remark
FROM
	pq_line line
	INNER JOIN pq_line vol ON line.pid = vol.id
	INNER JOIN pq_line dev ON vol.pid = dev.id
	INNER JOIN pq_line sub ON dev.pid = sub.id
	INNER JOIN pq_line gd ON sub.pid = gd.id
	INNER JOIN pq_line pro ON gd.pid = pro.id
	INNER JOIN pq_line pj ON pro.pid = pj.id
	INNER JOIN pq_line_detail de ON line.id = de.id
	INNER JOIN pq_voltage vo ON vol.id = vo.id
	INNER JOIN pq_device d ON dev.id = d.id
	INNER JOIN pq_substation su ON sub.id = su.id
	LEFT JOIN sys_area area ON pro.NAME = area.id
	LEFT JOIN sys_dict_data dic ON su.Scale = dic.id
	LEFT JOIN sys_dict_data dic2 ON vo.Scale = dic2.id
	left join sys_dict_data dic3 on de.Line_Grade = dic3.id
	left join sys_dict_data dic4 on de.Load_Type = dic4.id
	left join sys_dict_data dic5 on de.Business_Type = dic5.id
	left join sys_dict_data dic6 on d.Manufacturer = dic6.id
	left join sys_dict_data dic7 on d.Dev_Type = dic7.id
	left join sys_dict_data dic8 on d.front_type = dic8.id
	LEFT JOIN pq_node node ON d.Node_Id = node.id
    order by pj.sort,pro.sort,gd.sort,sub.sort,dev.sort,vol.sort,line.sort
    </select>

    <select id="getDevIndex" resultType="String">
        select vo.pid
        from pq_line line,
             pq_line vo
        where vo.id = line.pid
        and line.id = #{lineId}
    </select>
</mapper>
