<?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.csdevice.mapper.CsLinePOMapper">
  <resultMap id="BaseResultMap" type="com.njcn.csdevice.pojo.po.CsLinePO">
    <!--@mbg.generated-->
    <!--@Table cs_line-->
    <id column="line_id" jdbcType="VARCHAR" property="lineId" />
    <result column="dev_id" jdbcType="VARCHAR" property="devId" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="position" jdbcType="VARCHAR" property="position" />
    <result column="vol_grade" jdbcType="VARCHAR" property="volGrade" />
    <result column="pt_ratio" jdbcType="DECIMAL" property="ptRatio" />
    <result column="ct_ratio" jdbcType="DECIMAL" property="ctRatio" />
    <result column="status" jdbcType="BIT" property="status" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    line_id, dev_id, `name`, `position`, vol_grade, pt_ratio, ct_ratio, `status`, create_by,
    create_time, update_by, update_time
  </sql>

  <select id="findByNdid" resultType="CsLinePO">
    select
        t1.*
    from
        cs_equipment_delivery t0
    left join cs_line t1 on
        t0.id = t1.device_id
    where
        t0.ndid = #{id}
  </select>


  <select id="getCustomDetailByLineId" resultType="map">
    SELECT
      line.line_id as lineId,
      line.name as lineName,
      concat(round(line.pt_ratio,0), ':', round(IFNULL(line.pt2_ratio, 1), 0)) as pt,
      concat(round(line.ct_ratio,0), ':', round(IFNULL(line.ct2_ratio, 1), 0)) as ct,
      line.dev_capacity as Dev_Capacity,
      line.short_circuit_capacity as Short_Capacity,
      line.basic_capacity as Standard_Capacity,
      line.protocol_capacity as Deal_Capacity,
      line.vol_grade AS voltageLevel,
      dataSet.data_level AS level
    FROM
      cs_line line
          left JOIN cs_data_set dataSet on line.data_set_id = dataSet.id
    WHERE
      line.line_id = #{lineId}
  </select>
</mapper>
