<?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.fizz.business.mapper.SegmentMapper">

    <select id="getStripValue" resultType="com.fizz.business.domain.PdoStripvalue">
        select
            sum(val1avg)  as val1sum,  max(val1avg)  as val1max,  min(val1avg)  as val1min,  sum(val9cnt)  as val1cnt,  avg(val1avg)  as val1avg,
            sum(val2avg)  as val2sum,  max(val2avg)  as val2max,  min(val2avg)  as val2min,  sum(val9cnt)  as val2cnt,  avg(val2avg)  as val2avg,
            sum(val3avg)  as val3sum,  max(val3avg)  as val3max,  min(val3avg)  as val3min,  sum(val9cnt)  as val3cnt,  avg(val3avg)  as val3avg,
            sum(val4avg)  as val4sum,  max(val4avg)  as val4max,  min(val4avg)  as val4min,  sum(val9cnt)  as val4cnt,  avg(val4avg)  as val4avg,
            sum(val5avg)  as val5sum,  max(val5avg)  as val5max,  min(val5avg)  as val5min,  sum(val9cnt)  as val5cnt,  avg(val5avg)  as val5avg,
            sum(val6avg)  as val6sum,  max(val6avg)  as val6max,  min(val6avg)  as val6min,  sum(val9cnt)  as val6cnt,  avg(val6avg)  as val6avg,
            sum(val7avg)  as val7sum,  max(val7avg)  as val7max,  min(val7avg)  as val7min,  sum(val9cnt)  as val7cnt,  avg(val7avg)  as val7avg,
            sum(val8avg)  as val8sum,  max(val8avg)  as val8max,  min(val8avg)  as val8min,  sum(val9cnt)  as val8cnt,  avg(val8avg)  as val8avg,
            sum(val9avg)  as val9sum,  max(val9avg)  as val9max,  min(val9avg)  as val9min,  sum(val9cnt)  as val9cnt,  avg(val9avg)  as val9avg,
            sum(val10avg) as val10sum, max(val10avg) as val10max, min(val10avg) as val10min, sum(val10cnt) as val10cnt, avg(val10avg) as val10avg,
            sum(val11avg) as val11sum, max(val11avg) as val11max, min(val11avg) as val11min, sum(val11cnt) as val11cnt, avg(val11avg) as val11avg,
            sum(val12avg) as val12sum, max(val12avg) as val12max, min(val12avg) as val12min, sum(val12cnt) as val12cnt, avg(val12avg) as val12avg,
            sum(val13avg) as val13sum, max(val13avg) as val13max, min(val13avg) as val13min, sum(val13cnt) as val13cnt, avg(val13avg) as val13avg,
            sum(val14avg) as val14sum, max(val14avg) as val14max, min(val14avg) as val14min, sum(val14cnt) as val14cnt, avg(val14avg) as val14avg,
            sum(val15avg) as val15sum, max(val15avg) as val15max, min(val15avg) as val15min, sum(val15cnt) as val15cnt, avg(val15avg) as val15avg,
            sum(val16avg) as val16sum, max(val16avg) as val16max, min(val16avg) as val16min, sum(val16cnt) as val16cnt, avg(val16avg) as val16avg,
            sum(val17avg) as val17sum, max(val17avg) as val17max, min(val17avg) as val17min, sum(val17cnt) as val17cnt, avg(val17avg) as val17avg,
            sum(val18avg) as val18sum, max(val18avg) as val18max, min(val18avg) as val18min, sum(val18cnt) as val18cnt, avg(val18avg) as val18avg,
            sum(val19avg) as val19sum, max(val19avg) as val19max, min(val19avg) as val19min, sum(val19cnt) as val19cnt, avg(val19avg) as val19avg,
            sum(val20avg) as val20sum, max(val20avg) as val20max, min(val20avg) as val20min, sum(val20cnt) as val20cnt, avg(val20avg) as val20avg,
            sum(val21avg) as val21sum, max(val21avg) as val21max, min(val21avg) as val21min, sum(val21cnt) as val21cnt, avg(val21avg) as val21avg,
            sum(val22avg) as val22sum, max(val22avg) as val22max, min(val22avg) as val22min, sum(val22cnt) as val22cnt, avg(val22avg) as val22avg,
            sum(val23avg) as val23sum, max(val23avg) as val23max, min(val23avg) as val23min, sum(val23cnt) as val23cnt, avg(val23avg) as val23avg,
            sum(val24avg) as val24sum, max(val24avg) as val24max, min(val24avg) as val24min, sum(val24cnt) as val24cnt, avg(val24avg) as val24avg,
            sum(val25avg) as val25sum, max(val25avg) as val25max, min(val25avg) as val25min, sum(val25cnt) as val25cnt, avg(val25avg) as val25avg,
            sum(val26avg) as val26sum, max(val26avg) as val26max, min(val26avg) as val26min, sum(val26cnt) as val26cnt, avg(val26avg) as val26avg,
            sum(val27avg) as val27sum, max(val27avg) as val27max, min(val27avg) as val27min, sum(val27cnt) as val27cnt, avg(val27avg) as val27avg,
            sum(val28avg) as val28sum, max(val28avg) as val28max, min(val28avg) as val28min, sum(val28cnt) as val28cnt, avg(val28avg) as val28avg,
            sum(val29avg) as val29sum, max(val29avg) as val29max, min(val29avg) as val29min, sum(val29cnt) as val29cnt, avg(val29avg) as val29avg,
            sum(val30avg) as val30sum, max(val30avg) as val30max, min(val30avg) as val30min, sum(val30cnt) as val30cnt, avg(val30avg) as val30avg,
            sum(val31avg) as val31sum, max(val31avg) as val31max, min(val31avg) as val31min, sum(val31cnt) as val31cnt, avg(val31avg) as val31avg,
            sum(val32avg) as val32sum, max(val32avg) as val32max, min(val32avg) as val32min, sum(val32cnt) as val32cnt, avg(val32avg) as val32avg,
            sum(val33avg) as val33sum, max(val33avg) as val33max, min(val33avg) as val33min, sum(val33cnt) as val33cnt, avg(val33avg) as val33avg,
            sum(val34avg) as val34sum, max(val34avg) as val34max, min(val34avg) as val34min, sum(val34cnt) as val34cnt, avg(val34avg) as val34avg,
            sum(val35avg) as val35sum, max(val35avg) as val35max, min(val35avg) as val35min, sum(val35cnt) as val35cnt, avg(val35avg) as val35avg,
            sum(val36avg) as val36sum, max(val36avg) as val36max, min(val36avg) as val36min, sum(val36cnt) as val36cnt, avg(val36avg) as val36avg,
            sum(val37avg) as val37sum, max(val37avg) as val37max, min(val37avg) as val37min, sum(val37cnt) as val37cnt, avg(val37avg) as val37avg,
            sum(val38avg) as val38sum, max(val38avg) as val38max, min(val38avg) as val38min, sum(val38cnt) as val38cnt, avg(val38avg) as val38avg,
            sum(val39avg) as val39sum, max(val39avg) as val39max, min(val39avg) as val39min, sum(val39cnt) as val39cnt, avg(val39avg) as val39avg,
            sum(val40avg) as val40sum, max(val40avg) as val30max, min(val40avg) as val40min, sum(val40cnt) as val40cnt, avg(val40avg) as val40avg,
            sum(val41avg) as val41sum, max(val41avg) as val41max, min(val41avg) as val41min, sum(val41cnt) as val41cnt, avg(val41avg) as val41avg,
            sum(val42avg) as val42sum, max(val42avg) as val42max, min(val42avg) as val42min, sum(val42cnt) as val42cnt, avg(val42avg) as val42avg,
            sum(val43avg) as val43sum, max(val43avg) as val43max, min(val43avg) as val43min, sum(val43cnt) as val43cnt, avg(val43avg) as val43avg,
            sum(val44avg) as val44sum, max(val44avg) as val44max, min(val44avg) as val44min, sum(val44cnt) as val44cnt, avg(val44avg) as val44avg,
            sum(val45avg) as val45sum, max(val45avg) as val45max, min(val45avg) as val45min, sum(val45cnt) as val45cnt, avg(val45avg) as val45avg,
            sum(val46avg) as val46sum, max(val46avg) as val46max, min(val46avg) as val46min, sum(val46cnt) as val46cnt, avg(val46avg) as val46avg,
            sum(val47avg) as val47sum, max(val47avg) as val47max, min(val47avg) as val47min, sum(val47cnt) as val47cnt, avg(val47avg) as val47avg,
            sum(val48avg) as val48sum, max(val48avg) as val48max, min(val48avg) as val48min, sum(val48cnt) as val48cnt, avg(val48avg) as val48avg,
            sum(val49avg) as val49sum, max(val49avg) as val49max, min(val49avg) as val49min, sum(val49cnt) as val49cnt, avg(val49avg) as val49avg,
            sum(val50avg) as val50sum, max(val50avg) as val50max, min(val50avg) as val50min, sum(val50cnt) as val50cnt, avg(val50avg) as val50avg
        from cpg_segment
        where entry_mat_id = #{entryMatId} and start_position >= #{startPos} and end_position &lt; #{endPos}
    </select>

    <select id="getLatestRecord" resultType="com.fizz.business.domain.Segment">
        SELECT * FROM cpg_segment where id=(SELECT max(id) FROM cpg_segment)
    </select>

    <select id="queryParamByEnCoilId" resultType="com.fizz.business.vo.SegmentParamVO">
        SELECT seg_no AS segNo,
               JSON_UNQUOTE(JSON_EXTRACT(total_values_json, CONCAT('$.', #{paramField}, '_avg'))) AS value
        FROM cpl_segment_total
        WHERE en_coil_id = #{enCoilID}
        ORDER BY seg_no
    </select>

</mapper>
