feat (farm): 农事报表
- 农事任务分类统计 - 种植类信息 - 投入品分类统计/金额统计
This commit is contained in:
@@ -24,4 +24,34 @@
|
||||
<if test="tenantId != null and tenantId != ''">AND tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getFarmTypeChart"
|
||||
parameterType="cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.chart.ChartCommonReqVO"
|
||||
resultType="cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.chart.FarmTypeChartRespVO">
|
||||
SELECT
|
||||
fftm.farming_name AS farmTypeName,
|
||||
COUNT(ffr.id) AS recordCount
|
||||
FROM farm_farming_record ffr
|
||||
LEFT JOIN farm_farming_type_maintenance fftm ON ffr.task_type = fftm.id
|
||||
<where>
|
||||
fftm.deleted = 0
|
||||
<if test="tenantId != null">
|
||||
AND ffr.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="yearDate != null">
|
||||
AND YEAR(ffr.task_start_date) = #{yearDate}
|
||||
</if>
|
||||
<if test="baseId != null and baseId != ''">
|
||||
AND ffr.base_id = #{baseId}
|
||||
</if>
|
||||
<if test="plotId != null and plotId != ''">
|
||||
AND ffr.plot_id = #{plotId}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY fftm.farming_name
|
||||
ORDER BY recordCount DESC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -9,4 +9,39 @@
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
<select id="getInputUsageChart"
|
||||
parameterType="cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.chart.ChartCommonReqVO"
|
||||
resultType="cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.chart.InputUsageChartRespVO">
|
||||
|
||||
SELECT
|
||||
fiur.input_name AS inputName,
|
||||
SUM(fiur.usage_amount) AS usageAmount,
|
||||
CASE
|
||||
WHEN fiur.current_spec_type = 1 THEN fiur.unit
|
||||
WHEN fiur.current_spec_type = 2 THEN fiur.spec
|
||||
ELSE fiur.unit
|
||||
END AS unit,
|
||||
SUM(fiur.total_price) AS totalPrice
|
||||
FROM farm_input_usage_records fiur
|
||||
<where>
|
||||
fiur.deleted = 0
|
||||
<if test="tenantId != null">
|
||||
AND fiur.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="baseId != null and baseId != ''">
|
||||
AND fiur.base_id = #{baseId}
|
||||
</if>
|
||||
<if test="plotId != null and plotId != ''">
|
||||
AND fiur.plot_id = #{plotId}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY fiur.input_name,
|
||||
CASE
|
||||
WHEN fiur.current_spec_type = 1 THEN fiur.unit
|
||||
WHEN fiur.current_spec_type = 2 THEN fiur.spec
|
||||
ELSE fiur.unit
|
||||
END
|
||||
ORDER BY usageAmount DESC
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -110,5 +110,55 @@
|
||||
GROUP BY plant_species_code
|
||||
|
||||
</select>
|
||||
<select id="getPlantingAreaChart"
|
||||
parameterType="cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.chart.ChartCommonReqVO"
|
||||
resultType="cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.chart.PlantingAreaChartRespVO">
|
||||
|
||||
SELECT
|
||||
fsl.cultivar_name AS speciesName,
|
||||
SUM(fpp.predicted_area) AS plantingArea,
|
||||
CASE
|
||||
WHEN #{plotId} IS NOT NULL AND #{plotId} != '' THEN
|
||||
CONCAT(ROUND(SUM(fpp.predicted_area) / MAX(fpp.total_area) * 100, 2), '%')
|
||||
WHEN #{baseId} IS NOT NULL AND #{baseId} != '' AND (#{plotId} IS NULL OR #{plotId} = '') THEN
|
||||
CONCAT(ROUND(SUM(fpp.predicted_area) / (
|
||||
SELECT SUM(total_area)
|
||||
FROM farm_production_plan
|
||||
WHERE base_id = #{baseId}
|
||||
AND tenant_id = #{tenantId}
|
||||
AND deleted = 0
|
||||
GROUP BY base_id
|
||||
) * 100, 2), '%')
|
||||
ELSE
|
||||
CONCAT(ROUND(SUM(fpp.predicted_area) / (
|
||||
SELECT SUM(total_area)
|
||||
FROM farm_production_plan
|
||||
WHERE tenant_id = #{tenantId}
|
||||
AND deleted = 0
|
||||
) * 100, 2), '%')
|
||||
END AS areaPercentage
|
||||
FROM farm_production_plan fpp
|
||||
LEFT JOIN farm_species_library fsl ON fpp.plant_species_code = fsl.id
|
||||
WHERE
|
||||
fpp.deleted = 0 AND fsl.deleted = 0
|
||||
<if test="tenantId != null">
|
||||
AND fpp.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="yearDate != null">
|
||||
AND YEAR(fpp.production_start_date) = #{yearDate}
|
||||
</if>
|
||||
<if test="baseId != null and baseId != ''">
|
||||
AND fpp.base_id = #{baseId}
|
||||
</if>
|
||||
<if test="plotId != null and plotId != ''">
|
||||
AND fpp.plot_id = #{plotId}
|
||||
</if>
|
||||
<if test="state != null and state != ''">
|
||||
AND fpp.plan_status = #{state}
|
||||
</if>
|
||||
GROUP BY fsl.cultivar_name
|
||||
ORDER BY plantingArea DESC
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user