feat (farm):
- 基地,地块新增 编码字段 - 户主导入/出 重构 - 修复部分bug
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
WHEN fiur.current_spec_type = 2 THEN fiur.spec
|
||||
ELSE fiur.unit
|
||||
END AS unit,
|
||||
fiur.current_spec_type AS currentSpecType,
|
||||
AVG(fiur.unit_price) AS unitPrice,
|
||||
SUM(fiur.total_price) AS totalPrice
|
||||
FROM farm_input_usage_records fiur
|
||||
<where>
|
||||
@@ -40,7 +42,8 @@
|
||||
WHEN fiur.current_spec_type = 1 THEN fiur.unit
|
||||
WHEN fiur.current_spec_type = 2 THEN fiur.spec
|
||||
ELSE fiur.unit
|
||||
END
|
||||
END,
|
||||
fiur.current_spec_type
|
||||
ORDER BY usageAmount DESC
|
||||
|
||||
</select>
|
||||
@@ -49,43 +52,39 @@
|
||||
parameterType="cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.chart.ChartCommonReqVO"
|
||||
resultType="cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.FarmingReport1RespVO">
|
||||
SELECT
|
||||
fpp.base_id AS baseId,
|
||||
fpp.base_name AS baseName,
|
||||
fpp.plan_number AS planNumber,
|
||||
ffr.id AS farmRecordId,
|
||||
ffr.base_name AS baseName,
|
||||
ffr.task_scope AS planNumber,
|
||||
ffr.task_start_date AS taskStartDate,
|
||||
ffr.task_end_date AS taskEndDate,
|
||||
DATEDIFF(ffr.task_end_date, ffr.task_start_date) AS intervalDays,
|
||||
fiur.input_id AS inputId,
|
||||
fiur.input_name AS inputName,
|
||||
fiur.total_price AS inputTotalPrice,
|
||||
fiur.usage_amount AS usageAmount,
|
||||
fiur.current_spec_type AS currentSpecType,
|
||||
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
|
||||
FROM farm_input_usage_records fiur
|
||||
INNER JOIN farm_farming_record ffr ON fiur.farm_record_id = ffr.id
|
||||
INNER JOIN farm_production_plan fpp ON ffr.production_plan_id = fpp.id
|
||||
COALESCE(SUM(fiur.total_price), 0) AS inputTotalPrice
|
||||
FROM farm_farming_record ffr
|
||||
LEFT JOIN farm_input_usage_records fiur ON ffr.id = fiur.farm_record_id AND fiur.deleted = 0
|
||||
<where>
|
||||
fiur.deleted = 0
|
||||
ffr.deleted = 0
|
||||
<if test="tenantId != null">
|
||||
AND fiur.tenant_id = #{tenantId}
|
||||
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 fiur.base_id = #{baseId}
|
||||
AND ffr.base_id = #{baseId}
|
||||
</if>
|
||||
<if test="plotId != null and plotId != ''">
|
||||
AND fiur.plot_id = #{plotId}
|
||||
AND ffr.plot_id = #{plotId}
|
||||
</if>
|
||||
<if test="state != null and state != ''">
|
||||
AND fpp.plan_status = #{state}
|
||||
AND ffr.task_status = #{state}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY
|
||||
ffr.id,
|
||||
ffr.base_name,
|
||||
ffr.task_scope,
|
||||
ffr.task_start_date,
|
||||
ffr.task_end_date
|
||||
ORDER BY ffr.task_start_date DESC
|
||||
</select>
|
||||
|
||||
|
||||
@@ -110,52 +110,52 @@
|
||||
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
|
||||
fsl.cultivar_name AS speciesName,
|
||||
SUM(fpp.planting_quantity) AS plantingQuantity,
|
||||
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), '%')
|
||||
MAX(fpp.total_area)
|
||||
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), '%')
|
||||
(
|
||||
SELECT SUM(total_area)
|
||||
FROM farm_production_plan
|
||||
WHERE base_id = #{baseId}
|
||||
AND tenant_id = #{tenantId}
|
||||
AND deleted = 0
|
||||
)
|
||||
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
|
||||
(SELECT SUM(total_area)
|
||||
FROM farm_production_plan
|
||||
WHERE tenant_id = #{tenantId}
|
||||
AND deleted = 0)
|
||||
END AS totalArea
|
||||
FROM farm_production_plan fpp
|
||||
LEFT JOIN farm_species_library fsl ON fpp.plant_species_code = fsl.id
|
||||
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>
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user