<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
  <info>
    <name>citizen_appealing_violations_fz53_flow4</name>
    <name_sync_with_filename>Y</name_sync_with_filename>
    <description/>
    <extended_description/>
    <pipeline_version/>
    <pipeline_type>Normal</pipeline_type>
    <parameters>
    </parameters>
    <capture_transform_performance>N</capture_transform_performance>
    <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
    <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
    <created_user>-</created_user>
    <created_date>2025/05/21 14:05:02.260</created_date>
    <modified_user>-</modified_user>
    <modified_date>2025/05/21 14:05:02.260</modified_date>
  </info>
  <notepads>
  </notepads>
  <order>
    <hop>
      <from>Table input</from>
      <to>Insert / update</to>
      <enabled>Y</enabled>
    </hop>
  </order>
  <transform>
    <name>Insert / update</name>
    <type>InsertUpdate</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>100</commit>
    <connection>ervu-dashboard</connection>
    <lookup>
      <key>
        <condition>=</condition>
        <field>recruit_id</field>
        <name>recruit_id</name>
      </key>
      <key>
        <condition>=</condition>
        <field>create_date</field>
        <name>create_date</name>
      </key>
      <schema>ervu_dashboard</schema>
      <table>citizen_appealing_violations_fz53</table>
      <value>
        <name>recruit_id</name>
        <rename>recruit_id</rename>
        <update>N</update>
      </value>
      <value>
        <name>create_date</name>
        <rename>create_date</rename>
        <update>N</update>
      </value>
      <value>
        <name>number_appealed</name>
        <rename>number_appealed</rename>
        <update>Y</update>
      </value>
      <value>
        <name>date_appealed</name>
        <rename>date_appealed</rename>
        <update>Y</update>
      </value>
      <value>
        <name>case_number</name>
        <rename>case_number</rename>
        <update>Y</update>
      </value>
      <value>
        <name>decision_date</name>
        <rename>decision_date</rename>
        <update>Y</update>
      </value>
      <value>
        <name>result_appeal</name>
        <rename>result_appeal</rename>
        <update>Y</update>
      </value>
      <value>
        <name>name_commission</name>
        <rename>name_commission</rename>
        <update>Y</update>
      </value>
      <value>
        <name>grounds</name>
        <rename>grounds</rename>
        <update>Y</update>
      </value>
      <value>
        <name>hidden</name>
        <rename>hidden</rename>
        <update>Y</update>
      </value>
    </lookup>
    <update_bypassed>N</update_bypassed>
    <attributes/>
    <GUI>
      <xloc>896</xloc>
      <yloc>368</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Table input</name>
    <type>TableInput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <connection>ervu-dashboard</connection>
    <execute_each_row>N</execute_each_row>
    <limit>0</limit>
    <sql>SELECT
	ad.recruit_id,
	ad.create_date, -- дата создания обжалования
	ad.appeal_number AS number_appealed, -- номер обжалуемого решения
	ad.appeal_date AS date_appealed, -- дата обжалуемого решения
	ad.result_number AS case_number, -- номер принятого решения
	ad.result_date AS decision_date, -- дата принятия решения
	CASE
		WHEN ad.result = '1' THEN 'Удовлетворена'
		WHEN ad.result = '2' THEN 'Частично удовлетворена'
		WHEN ad.result = '3' THEN 'Отказано в удовлетворении'
		ELSE NULL
	END AS result_appeal, -- код рассмотрения
	ad.commission_name AS name_commission, -- наименование комиссии, принявшей решение
	ad.reason_for_add_entry AS grounds, -- основание для внесения записи
	ad.hidden --has_appealing_violations_fz53
FROM public.appeal_document_dto ad
JOIN public.recruit r ON r.id = ad.recruit_id AND '${ID_F4}' != ''  -- Проверка на пустую строку
	    AND COALESCE(r.current_recruitment, r.target_recruitment) = '${ID_F4}'
	    --AND '${INFRINGEMENT_DATE}'::timestamp &lt;= coalesce(ad.updated_at, ad.created_at) -- для дельты
--WHERE hidden IS FALSE</sql>
    <variables_active>Y</variables_active>
    <attributes/>
    <GUI>
      <xloc>480</xloc>
      <yloc>368</yloc>
    </GUI>
  </transform>
  <transform_error_handling>
  </transform_error_handling>
  <attributes/>
</pipeline>
