feat (farm): 设备商接口重构
- 设备厂接口 - 吉水两山 代码临时性解决现场问题
This commit is contained in:
@@ -52,7 +52,6 @@
|
||||
COALESCE(SUM(practical_yields), 0) AS practicalYields
|
||||
FROM farm_production_plan
|
||||
<where>
|
||||
plan_status = 3
|
||||
AND deleted = 0
|
||||
AND production_start_date IS NOT NULL
|
||||
<if test="tenantId != null and tenantId != ''">AND tenant_id = #{tenantId}</if>
|
||||
|
||||
@@ -9,4 +9,63 @@
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
<resultMap id="DisasterAnalysisResultMap"
|
||||
type="cn.iocoder.yudao.module.farm.controller.admin.api.vo.DisasterAnalysisRespVO">
|
||||
<result property="year" column="year"/>
|
||||
<collection property="disasterReports"
|
||||
ofType="cn.iocoder.yudao.module.farm.controller.admin.api.vo.DisasterAnalysisRespVO$DisasterReports">
|
||||
<result property="month" column="month"/>
|
||||
<result property="meteorologyCount" column="meteorology_count"/>
|
||||
<result property="pestCount" column="pest_count"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="countDisasterAnalysis"
|
||||
parameterType="cn.iocoder.yudao.module.farm.controller.admin.api.vo.DisasterAnalysisReqVO"
|
||||
resultMap="DisasterAnalysisResultMap">
|
||||
|
||||
SELECT y.year,
|
||||
m.month,
|
||||
COALESCE(SUM(CASE WHEN f.category = '0' THEN COALESCE(f.disaster_count, 0) ELSE 0 END),0) as meteorology_count,
|
||||
COALESCE(SUM(CASE WHEN f.category != '0' THEN COALESCE(f.disaster_count, 0) ELSE 0 END), 0) as pest_count
|
||||
FROM (SELECT YEAR (CURDATE()) as year UNION SELECT YEAR (CURDATE()) - 1) y
|
||||
CROSS JOIN
|
||||
(SELECT 1 as month
|
||||
UNION
|
||||
SELECT 2
|
||||
UNION
|
||||
SELECT 3
|
||||
UNION
|
||||
SELECT 4
|
||||
UNION
|
||||
SELECT 5
|
||||
UNION
|
||||
SELECT 6
|
||||
UNION
|
||||
SELECT 7
|
||||
UNION
|
||||
SELECT 8
|
||||
UNION
|
||||
SELECT 9
|
||||
UNION
|
||||
SELECT 10
|
||||
UNION
|
||||
SELECT 11
|
||||
UNION
|
||||
SELECT 12) m
|
||||
LEFT JOIN farm_screen_disaster_data f ON y.year = YEAR (STR_TO_DATE(f.disaster_time, '%Y-%m'))
|
||||
AND m.month = MONTH (STR_TO_DATE(f.disaster_time, '%Y-%m'))
|
||||
AND f.deleted = 0
|
||||
<if test="baseId != null and baseId != ''">
|
||||
AND f.base_id = #{baseId}
|
||||
</if>
|
||||
<if test="tenantId != null and tenantId != ''">
|
||||
AND f.tenant_id = #{tenantId}
|
||||
</if>
|
||||
AND f.disaster_time IS NOT NULL
|
||||
GROUP BY y.year, m.month
|
||||
ORDER BY y.year DESC, m.month
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user