202 lines
8.4 KiB
XML
202 lines
8.4 KiB
XML
<?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.example.demo.mapper.YpxxNyclMapper">
|
||
|
||
<resultMap id="BaseResultMap" type="com.example.demo.domain.YpxxNycl">
|
||
<result property="jcId" column="JC_ID" jdbcType="OTHER"/>
|
||
<result property="yzhen" column="YZHEN" jdbcType="OTHER"/>
|
||
<result property="bcyrmc" column="BCYRMC" jdbcType="OTHER"/>
|
||
<result property="cyddlx" column="CYDDLX" jdbcType="OTHER"/>
|
||
<result property="bcydwmc" column="BCYDWMC" jdbcType="OTHER"/>
|
||
<result property="dzS" column="DZ_S" jdbcType="OTHER"/>
|
||
<result property="dzQx" column="DZ_QX" jdbcType="OTHER"/>
|
||
<result property="dzszm" column="DZSZM" jdbcType="OTHER"/>
|
||
<result property="cydwszsf" column="CYDWSZSF" jdbcType="OTHER"/>
|
||
<result property="scxkzbh" column="SCXKZBH" jdbcType="OTHER"/>
|
||
<result property="yyzzh" column="YYZZH" jdbcType="OTHER"/>
|
||
<result property="jyxkz" column="JYXKZ" jdbcType="OTHER"/>
|
||
<result property="wlptmc" column="WLPTMC" jdbcType="OTHER"/>
|
||
<result property="wlptyyzzh" column="WLPTYYZZH" jdbcType="OTHER"/>
|
||
<result property="ypmc" column="YPMC" jdbcType="OTHER"/>
|
||
<result property="spDl" column="SP_DL" jdbcType="OTHER"/>
|
||
<result property="spPz" column="SP_PZ" jdbcType="OTHER"/>
|
||
<result property="spXl" column="SP_XL" jdbcType="OTHER"/>
|
||
<result property="spYl" column="SP_YL" jdbcType="OTHER"/>
|
||
<result property="cysj" column="CYSJ" jdbcType="DATE"/>
|
||
<result property="jcdw" column="JCDW" jdbcType="OTHER"/>
|
||
<result property="jcxm" column="JCXM" jdbcType="OTHER"/>
|
||
<result property="jcz" column="JCZ" jdbcType="FLOAT"/>
|
||
<result property="jczdw" column="JCZDW" jdbcType="OTHER"/>
|
||
<result property="jcbz" column="JCBZ" jdbcType="OTHER"/>
|
||
<result property="pjbz" column="PJBZ" jdbcType="OTHER"/>
|
||
<result property="ffjcx" column="FFJCX" jdbcType="OTHER"/>
|
||
<result property="ffjcxdw" column="FFJCXDW" jdbcType="OTHER"/>
|
||
<result property="zxyxx" column="ZXYXX" jdbcType="OTHER"/>
|
||
<result property="zxyxxdw" column="ZXYXXDW" jdbcType="OTHER"/>
|
||
<result property="zdyxx" column="ZDYXX" jdbcType="OTHER"/>
|
||
<result property="zdyxxdw" column="ZDYXXDW" jdbcType="OTHER"/>
|
||
<result property="nd2" column="ND2" jdbcType="OTHER"/>
|
||
<result property="gxsj2" column="GXSJ2" jdbcType="OTHER"/>
|
||
<result property="equivalent" column="Equivalent" jdbcType="FLOAT"/>
|
||
</resultMap>
|
||
|
||
<sql id="Base_Column_List">
|
||
JC_ID,YZHEN,BCYRMC,
|
||
CYDDLX,BCYDWMC,DZ_S,
|
||
DZ_QX,DZSZM,CYDWSZSF,
|
||
SCXKZBH,YYZZH,JYXKZ,
|
||
WLPTMC,WLPTYYZZH,YPMC,
|
||
SP_DL,SP_PZ,SP_XL,
|
||
SP_YL,CYSJ,JCDW,
|
||
JCXM,JCZ,JCZDW,
|
||
JCBZ,PJBZ,FFJCX,
|
||
FFJCXDW,ZXYXX,ZXYXXDW,
|
||
ZDYXX,ZDYXXDW,ND2,
|
||
GXSJ2,Equivalent
|
||
</sql>
|
||
<select id="getMEPList" resultType="com.example.demo.entity.vo.PingGuVo">
|
||
SELECT SP_XL,
|
||
JCXM,
|
||
avg(Equivalent) * avg_xiaofei_sum / avgBodyWeight / 1000 as MEP,
|
||
avg_xiaofei_sum,
|
||
avgBodyWeight,
|
||
avg(JCZ) as avg_jcz
|
||
from YPXX_NYCL as a
|
||
join
|
||
(SELECT SP_XL,
|
||
AVG(bodyWeight) as avgBodyWeight,
|
||
AVG(xiaofei_sum) as avg_xiaofei_sum
|
||
from XIAOFEILIANG_NEW xn
|
||
${xiaofeiQueryStr}
|
||
group by SP_XL) as b on
|
||
a.SP_XL = b.SP_XL
|
||
${ew.customSqlSegment}
|
||
group by JCXM,
|
||
SP_XL,
|
||
avgBodyWeight,
|
||
avg_xiaofei_sum
|
||
ORDER by SP_XL
|
||
</select>
|
||
|
||
<select id="getVegetablesList" resultType="com.example.demo.entity.vo.YPXXVegetablesVo">
|
||
SELECT SP_DL, SP_YL, SP_PZ, SP_XL
|
||
from YPXX_NYCL
|
||
group by SP_DL, SP_YL, SP_PZ, SP_XL
|
||
order by SP_DL, SP_YL, SP_PZ, SP_XL
|
||
</select>
|
||
|
||
<select id="getYpxxJcz" resultType="com.example.demo.entity.vo.PingGuYpxxJczVo">
|
||
SELECT
|
||
SP_XL,
|
||
JCXM,
|
||
count(*) AS jczCount,
|
||
avg(JCZ) AS jczAvg,
|
||
max(JCZ) AS jczMax
|
||
FROM YPXX_NYCL ${ew.customSqlSegment}
|
||
GROUP BY SP_XL,
|
||
JCXM
|
||
</select>
|
||
|
||
<select id="getSpxlEquivalent" resultType="com.example.demo.entity.vo.PingGuYpxxJczVo">
|
||
SELECT SP_XL,
|
||
sum(Equivalent_AVG) as equivalentSum
|
||
from (SELECT SP_XL, JCXM, avg(Equivalent) Equivalent_AVG
|
||
FROM YPXX_NYCL yn
|
||
${ew.customSqlSegment}
|
||
GROUP BY
|
||
SP_XL, JCXM,SP_PZ) as A
|
||
GROUP by SP_XL
|
||
</select>
|
||
|
||
<select id="getEquivalentBySpjb" resultType="com.example.demo.entity.vo.PingGuYpxxJczVo">
|
||
SELECT ${spjb} as vegetableName,
|
||
sum(Equivalent_AVG) as equivalentSum
|
||
from (SELECT SP_XL, JCXM, avg(Equivalent) Equivalent_AVG, SP_PZ
|
||
FROM YPXX_NYCL yn
|
||
${ew.customSqlSegment}
|
||
GROUP BY
|
||
SP_XL,
|
||
JCXM,
|
||
SP_PZ,
|
||
SP_YL,) as A
|
||
GROUP by ${spjb}
|
||
</select>
|
||
|
||
<!-- 这个是原来的没有对LSH区分,现在已经被弃用-->
|
||
<select id="getYpxxJczBySpjbOld" resultType="com.example.demo.entity.vo.PingGuYpxxJczVo">
|
||
SELECT ${spjb} AS vegetableName,
|
||
sum(jczCountSpxl) AS jczCount,
|
||
avg(jczAvgSpxl) AS jczAvg,
|
||
max(jczMaxSpxl) AS jczMax,
|
||
sum(jczAvgSpxl) AS jczSum,
|
||
sum(jczAvgSpxl * RPF) AS equivalentAvgSum,
|
||
sum(jczMaxSpxl * RPF) AS equivalentMaxSum,
|
||
quantile(0.5)(jczAvgSpxl) AS jczP50, quantile(0.95) (jczAvgSpxl) AS jczP95
|
||
FROM (SELECT SP_XL,
|
||
JCXM,
|
||
SP_PZ,
|
||
SP_YL,
|
||
RPF,
|
||
count(*) AS jczCountSpxl,
|
||
avg(JCZ_XZ) AS jczAvgSpxl,
|
||
max(JCZ_XZ) AS jczMaxSpxl
|
||
FROM YPXX_NYCL yn
|
||
${ew.customSqlSegment}
|
||
GROUP BY SP_XL,
|
||
JCXM,
|
||
RPF,
|
||
SP_PZ,
|
||
SP_YL,
|
||
JCZDW) a
|
||
GROUP BY ${spjb}
|
||
</select>
|
||
|
||
|
||
<select id="getYpxxJczBySpjb" resultType="com.example.demo.entity.vo.PingGuYpxxJczVo">
|
||
WITH sp_xl_counts AS (SELECT SP_XL,
|
||
COUNT(DISTINCT LSH) AS jczCountSpxl
|
||
FROM YPXX_NYCL ${ew.customSqlSegment}
|
||
GROUP BY SP_XL),
|
||
aggregated_data AS (SELECT a.SP_XL,
|
||
a.JCXM,
|
||
a.SP_PZ,
|
||
a.SP_YL,
|
||
a.RPF,
|
||
b.jczCountSpxl,
|
||
AVG(a.JCZ_XZ) AS jczAvgSpxl,
|
||
MAX(a.JCZ_XZ) AS jczMaxSpxl,
|
||
quantile(0.95)(a.JCZ_XZ) AS jczP95Spxl,
|
||
quantile(0.50)(a.JCZ_XZ) AS jczP50Spxl
|
||
FROM YPXX_NYCL a
|
||
JOIN
|
||
sp_xl_counts b
|
||
ON
|
||
a.SP_XL = b.SP_XL
|
||
${ew.customSqlSegment}
|
||
GROUP BY a.SP_XL,
|
||
a.JCXM,
|
||
a.RPF,
|
||
a.SP_PZ,
|
||
a.SP_YL,
|
||
b.jczCountSpxl,
|
||
JCZDW)
|
||
SELECT ${spjb} AS vegetableName,
|
||
SUM(jczCountSpxl) AS jczCount,
|
||
AVG(jczAvgSpxl) AS jczAvg,
|
||
MAX(jczMaxSpxl) AS jczMax,
|
||
SUM(jczAvgSpxl) AS jczSum,
|
||
SUM(jczAvgSpxl * RPF) AS equivalentAvgSum,
|
||
SUM(jczMaxSpxl * RPF) AS equivalentMaxSum,
|
||
SUM(jczP95Spxl * RPF) AS equivalentP95Sum,
|
||
SUM(jczP50Spxl * RPF) AS equivalentP50Sum,
|
||
quantile(0.5)(jczAvgSpxl) AS jczP50,
|
||
quantile(0.95) (jczAvgSpxl) AS jczP95
|
||
FROM aggregated_data
|
||
GROUP BY ${spjb}
|
||
</select>
|
||
|
||
|
||
</mapper>
|