Merge branch 'susu' into dev
This commit is contained in:
@@ -150,4 +150,275 @@
|
||||
</foreach>
|
||||
ORDER BY household_num
|
||||
</select>
|
||||
|
||||
<select id="forestProductsExcel"
|
||||
resultType="app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain.GetForestProducts">
|
||||
/* 엑셀 다운로드 - 일계부 등록데이터 ( 1.임산물현황 ) 조회 */
|
||||
WITH unit_codes AS (
|
||||
SELECT id, code_value
|
||||
FROM uicode
|
||||
WHERE parent_id = 'code.record.unit'
|
||||
AND is_deleted = false
|
||||
)
|
||||
SELECT
|
||||
h.household_num,
|
||||
h.owner_name,
|
||||
fp.street_num,
|
||||
fp.land_type,
|
||||
fp.town,
|
||||
fp.available_area,
|
||||
fp.crop_name,
|
||||
fp.crop_code,
|
||||
fp.land_area,
|
||||
fp.main_yield,
|
||||
CASE WHEN fp.main_yield_unit_code = 'code.record.unit.self' THEN fp.main_yield_unit
|
||||
ELSE (select code_value from unit_codes where id = fp.main_yield_unit_code) END AS main_yield_unit_code_name,
|
||||
fp.main_sale_amount,
|
||||
CASE WHEN fp.main_sale_unit_code = 'code.record.unit.self' THEN fp.main_sale_unit
|
||||
ELSE (select code_value from unit_codes where id = fp.main_sale_unit_code) END AS main_sale_unit_code_name,
|
||||
fp.sub_yield,
|
||||
CASE WHEN fp.sub_yield_unit_code = 'code.record.unit.self' THEN fp.sub_yield_unit
|
||||
ELSE (select code_value from unit_codes where id = fp.sub_yield_unit_code) END AS sub_yield_unit_code_name,
|
||||
fp.sub_sale_amount ,
|
||||
CASE WHEN fp.sub_sale_unit_code = 'code.record.unit.self' THEN fp.sub_sale_unit
|
||||
ELSE (select code_value from unit_codes where id = fp.sub_sale_unit_code) END AS sub_sale_unit_code_name
|
||||
FROM forest_product fp
|
||||
JOIN household h on fp.household_seq = h.seq and h.is_deleted = false
|
||||
WHERE fp.is_deleted = false
|
||||
AND fp.month = #{recordMonth}
|
||||
AND fp.household_seq IN
|
||||
<foreach collection="householdSeqs" item="seq" open="(" separator="," close=")">
|
||||
#{seq}
|
||||
</foreach>
|
||||
ORDER BY household_num
|
||||
</select>
|
||||
|
||||
<select id="bankAutoTransfersExcel"
|
||||
resultType="app.module.admin.usecase.household.excelDownload.getHouseholdsExcel.ports.application.domain.GetBankAutoTransfers">
|
||||
/* 엑셀 다운로드 - 일계부 등록데이터 ( 2.자동이체_수입(지출) ) 조회 */
|
||||
WITH category_codes AS (
|
||||
SELECT id, code_text
|
||||
FROM uicode
|
||||
WHERE (parent_id = 'code.bank.input' OR parent_id = 'code.bank.output')
|
||||
AND is_deleted = false
|
||||
)
|
||||
SELECT
|
||||
h.household_num,
|
||||
h.owner_name,
|
||||
transfer_type.code_text as transfer_type_name,
|
||||
bat.income_code,
|
||||
bat.expense_code,
|
||||
split_part( bat.crop_code,'code.record.crop.',2 ) as crop_code,
|
||||
case when bat.transfer_category_code = 'code.bank.input.self' OR bat.transfer_category_code = 'code.bank.output.self' THEN bat.transfer_category
|
||||
else (select code_text from category_codes where id = bat.transfer_category_code) END AS transfer_category_code_name,
|
||||
bat.source_purpose,
|
||||
bat.count,
|
||||
case when bat.unit_code = 'code.count.unit.self' then bat.unit
|
||||
else unit_code.code_text end as unit_code_name,
|
||||
bat.price
|
||||
FROM bank_auto_transfer bat
|
||||
JOIN household h on bat.household_seq = h.seq and h.is_deleted = false
|
||||
LEFT JOIN uicode transfer_type on transfer_type.parent_id = 'code.bank' and transfer_type.id = bat.transfer_type
|
||||
LEFT JOIN uicode unit_code on unit_code.parent_id = 'code.count.unit' and unit_code.id = bat.unit_code and unit_code.is_deleted = false
|
||||
WHERE bat.is_deleted = false
|
||||
AND bat.month = #{recordMonth}
|
||||
AND bat.household_seq IN
|
||||
<foreach collection="householdSeqs" item="seq" open="(" separator="," close=")">
|
||||
#{seq}
|
||||
</foreach>
|
||||
ORDER BY household_num
|
||||
</select>
|
||||
|
||||
<select id="carryOversExcel">
|
||||
select
|
||||
h.household_num,
|
||||
h.owner_name,
|
||||
ds.carry_over
|
||||
from daily_summary ds
|
||||
JOIN household h on ds.household_seq = h.seq and h.is_deleted = false
|
||||
where ds.record_month = #{recordMonth}
|
||||
AND ds.household_seq IN
|
||||
<foreach collection="householdSeqs" item="seq" open="(" separator="," close=")">
|
||||
#{seq}
|
||||
</foreach>
|
||||
order by household_num desc
|
||||
</select>
|
||||
|
||||
<select id="dailyIncomeExpensesExcel">
|
||||
select
|
||||
h.household_num,
|
||||
h.owner_name,
|
||||
dg.start_day ,
|
||||
case when dg.start_day = dg.end_day then null else dg.end_day end as end_day ,
|
||||
di.category ,
|
||||
di.income_mark ,
|
||||
di.expense_mark ,
|
||||
split_part( di.crop_code,'code.record.crop.',2 ) as crop_code,
|
||||
di.income_kind as kind,
|
||||
di.source_purpose ,
|
||||
di.quantity,
|
||||
unit_code.code_text as unit_code_name ,
|
||||
di.price,
|
||||
di.estimated_value
|
||||
from household h
|
||||
join daily_record dr on h.seq = dr.household_seq and dr.is_deleted = false
|
||||
left join daily_day_group dg on dg.group_no = dr.day_group_no and dg.is_deleted = false
|
||||
join daily_income di on dr.id = di.daily_record_seq and di.is_deleted = false
|
||||
left join uicode unit_code on unit_code.parent_id = 'code.record.unit' and unit_code.id = di.unit_code and unit_code.is_deleted = false
|
||||
where h.is_deleted = false
|
||||
AND dr.record_month = #{recordMonth}
|
||||
AND h.seq IN
|
||||
<foreach collection="householdSeqs" item="seq" open="(" separator="," close=")">
|
||||
#{seq}
|
||||
</foreach>
|
||||
union all
|
||||
select
|
||||
h.household_num,
|
||||
h.owner_name,
|
||||
dg.start_day ,
|
||||
case when dg.start_day = dg.end_day then null else dg.end_day end as end_day ,
|
||||
de.category ,
|
||||
de.income_mark ,
|
||||
de.expense_mark ,
|
||||
null as crop_code,
|
||||
de.expense_kind as kind,
|
||||
de.source_purpose ,
|
||||
de.quantity,
|
||||
unit_code.code_text as unit_code_name ,
|
||||
de.price,
|
||||
de.estimated_value
|
||||
from household h
|
||||
join daily_record dr on h.seq = dr.household_seq and dr.is_deleted = false
|
||||
left join daily_day_group dg on dg.group_no = dr.day_group_no and dg.is_deleted = false
|
||||
join daily_expense de on dr.id = de.daily_record_seq and de.is_deleted = false
|
||||
left join uicode unit_code on unit_code.parent_id = 'code.record.unit' and unit_code.id = de.unit_code and unit_code.is_deleted = false
|
||||
where h.is_deleted = false
|
||||
AND dr.record_month = #{recordMonth}
|
||||
AND h.seq IN
|
||||
<foreach collection="householdSeqs" item="seq" open="(" separator="," close=")">
|
||||
#{seq}
|
||||
</foreach>
|
||||
order by household_num
|
||||
</select>
|
||||
|
||||
<select id="dailyWorksExcel">
|
||||
select
|
||||
h.household_num ,
|
||||
h.owner_name ,
|
||||
dg.start_day ,
|
||||
case when dg.start_day = dg.end_day then null else dg.end_day end as end_day ,
|
||||
dw.item_name ,
|
||||
dw.item_mark ,
|
||||
dw.work_name ,
|
||||
dw.work_mark ,
|
||||
dw.work_land_area ,
|
||||
case when dw.area_unit_code = 'code.record.area.self' then dw.area_unit_self
|
||||
else unit_code.code_value end as area_unit_name,
|
||||
dw.harvest_quantity ,
|
||||
case when dw.harvest_unit_code = 'code.record.unit.self' then dw.harvest_unit_self
|
||||
else unit_code.code_value end as harvest_unit_name,
|
||||
dw.owner_time ,
|
||||
dw.spouse_time ,
|
||||
dw.family_m_hours ,
|
||||
dw.family_f_hours ,
|
||||
dw.hired_m_hours ,
|
||||
dw.hired_f_hours ,
|
||||
dw.shared_m_hours,
|
||||
dw.shared_f_hours,
|
||||
dw.volunteer_m_hours ,
|
||||
dw.volunteer_f_hours
|
||||
from household h
|
||||
join daily_record dr on h.seq = dr.household_seq and dr.is_deleted = false
|
||||
left join daily_day_group dg on dg.group_no = dr.day_group_no and dg.is_deleted = false
|
||||
join daily_work dw on dw.daily_record_seq = dr.id and dw.is_deleted = false
|
||||
left join uicode area_code on area_code.parent_id = 'code.record.area' and area_code.id = dw.area_unit_code
|
||||
left join uicode unit_code on unit_code.parent_id = 'code.record.unit' and unit_code.id = dw.harvest_unit_code and unit_code.is_deleted = false
|
||||
where h.is_deleted = false
|
||||
AND dr.record_month = #{recordMonth}
|
||||
AND h.seq IN
|
||||
<foreach collection="householdSeqs" item="seq" open="(" separator="," close=")">
|
||||
#{seq}
|
||||
</foreach>
|
||||
order by household_num
|
||||
</select>
|
||||
|
||||
<select id="dailyPowersExcel">
|
||||
select
|
||||
h.household_num ,
|
||||
h.owner_name ,
|
||||
dg.start_day ,
|
||||
case when dg.start_day = dg.end_day then null else dg.end_day end as end_day ,
|
||||
dp.equipment_name ,
|
||||
dp.equipment_mark ,
|
||||
dp.owned_hours ,
|
||||
dp.leased_hours
|
||||
from household h
|
||||
join daily_record dr on h.seq = dr.household_seq and dr.is_deleted = false
|
||||
left join daily_day_group dg on dg.group_no = dr.day_group_no and dg.is_deleted = false
|
||||
join daily_power dp on dp.daily_record_seq = dr.id and dp.is_deleted = false
|
||||
where h.is_deleted = false
|
||||
AND dr.record_month = #{recordMonth}
|
||||
AND h.seq IN
|
||||
<foreach collection="householdSeqs" item="seq" open="(" separator="," close=")">
|
||||
#{seq}
|
||||
</foreach>
|
||||
order by household_num
|
||||
</select>
|
||||
|
||||
<select id="dailyForestryExcel">
|
||||
select
|
||||
h.household_num ,
|
||||
h.owner_name ,
|
||||
extract(week from dr.start_date) - extract(week from DATE_TRUNC('month', dr.start_date)) + 1 AS week_of_month,
|
||||
df.income_mark,
|
||||
df.expense_mark,
|
||||
df.product_name,
|
||||
df."usage",
|
||||
df.quantity,
|
||||
case when df.unit_code = 'code.record.unit.self' then df.unit_self
|
||||
else unit_code.code_value end as unit_name,
|
||||
df.estimated_value
|
||||
from household h
|
||||
join daily_record dr on h.seq = dr.household_seq and dr.is_deleted = false
|
||||
left join daily_day_group dg on dg.group_no = dr.day_group_no and dg.is_deleted = false
|
||||
join daily_forestry df on df.daily_record_seq = dr.id and df.is_deleted = false
|
||||
left join uicode unit_code on unit_code.parent_id = 'code.record.unit' and unit_code.id = df.unit_code
|
||||
where h.is_deleted = false
|
||||
AND dr.record_month = #{recordMonth}
|
||||
AND h.seq IN
|
||||
<foreach collection="householdSeqs" item="seq" open="(" separator="," close=")">
|
||||
#{seq}
|
||||
</foreach>
|
||||
order by household_num
|
||||
</select>
|
||||
|
||||
<select id="dailyFarmingsExcel">
|
||||
select
|
||||
h.household_num ,
|
||||
h.owner_name ,
|
||||
dg.start_day ,
|
||||
case when dg.start_day = dg.end_day then null else dg.end_day end as end_day ,
|
||||
df.income_mark ,
|
||||
df.expense_mark ,
|
||||
case when df.product_code = 'code.record.farming.self' then df.product_self
|
||||
else product_code.code_text end as product_name ,
|
||||
df."usage" ,
|
||||
df.quantity ,
|
||||
case when df.unit_code = 'code.record.unit.self' then df.unit_self
|
||||
else unit_code.code_value end as unit_name,
|
||||
df.estimated_value
|
||||
from household h
|
||||
join daily_record dr on h.seq = dr.household_seq and dr.is_deleted = false
|
||||
left join daily_day_group dg on dg.group_no = dr.day_group_no and dg.is_deleted = false
|
||||
join daily_farming df on df.daily_record_seq = dr.id and df.is_deleted = false
|
||||
left join uicode product_code on product_code.parent_id = 'code.record.farming' and product_code.id = df.product_code
|
||||
left join uicode unit_code on unit_code.parent_id = 'code.record.unit' and unit_code.id = df.unit_code
|
||||
where h.is_deleted = false
|
||||
AND dr.record_month = #{recordMonth}
|
||||
AND h.seq IN
|
||||
<foreach collection="householdSeqs" item="seq" open="(" separator="," close=")">
|
||||
#{seq}
|
||||
</foreach>
|
||||
order by household_num
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user