<?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.system.mapper.EleEpdPqdMapper">

    <select id="page" resultType="EleEpdPqdVO">
        select
            sdd.Name dataTypeName,
            ele_epd_pqd.Id,
            ele_epd_pqd.Name,
            ele_epd_pqd.Other_Name otherName,
            ele_epd_pqd.Show_Name showName,
            ele_epd_pqd.Sort,
            ele_epd_pqd.`Type` ,
            ele_epd_pqd.Phase ,
            ele_epd_pqd.Unit ,
            case when ele_epd_pqd.Harm_Start = 1 then 0.5 else ele_epd_pqd.Harm_Start end harmStart,
            case when ele_epd_pqd.Harm_Start = 1 then 49.5 else ele_epd_pqd.Harm_End end harmEnd ,
            ele_epd_pqd.Stat_Method statMethod,
            ele_epd_pqd.Class_Id classId,
            ele_epd_pqd.System_Type systemType,
            ele_epd_pqd.data_type dataType,
            ele_epd_pqd.tran_flag tranFlag,
            ele_epd_pqd.tran_rule tranRule,
            ele_epd_pqd.event_type eventType,
            ele_epd_pqd.store_flag storeFlag,
            ele_epd_pqd.cur_sts curSts,
            ele_epd_pqd.ctl_sts ctlSts,
            ele_epd_pqd.max_num maxNum,
            ele_epd_pqd.min_num minNum,
            ele_epd_pqd.set_value setValue,
            ele_epd_pqd.strlen ,
            ele_epd_pqd.default_value defaultValue,
            ele_epd_pqd.resources_id resourcesId,
            ele_epd_pqd.status,
            ele_epd_pqd.limit_name limitName,
            ele_epd_pqd.limit_table limitTable,
            ele_epd_pqd.formula formula
        from
            ele_epd_pqd ele_epd_pqd
        left join
            sys_dict_data sdd
        on
            ele_epd_pqd.data_type = sdd.Id
            <where>
                1=1
                and ${ew.sqlSegment}
            </where>
    </select>

    <select id="findAll" resultType="EpdDTO">
        select
            t0.Name dictName,
            t1.Name tableName,
            t0.Harm_Start harmStart,
	        t0.Harm_End harmEnd
        from
            ele_epd_pqd t0
        left join sys_dict_data t1 on
            t0.Class_Id = t1.Id
        where t0.status = 1
        group by t0.Name,t1.Name,t0.Harm_Start,t0.Harm_End
    </select>
</mapper>
