<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
  <info>
    <name>citizen_liability_fz53_once</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/04/22 17:49:36.858</created_date>
    <modified_user>-</modified_user>
    <modified_date>2025/04/22 17:49:36.858</modified_date>
  </info>
  <notepads>
  </notepads>
  <order>
    <hop>
      <from>Table input decision-document-service</from>
      <to>Table output ervu_dashboard.citizen_liability_fz53</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Table input decision-document-service</from>
      <to>Update</to>
      <enabled>Y</enabled>
    </hop>
  </order>
  <transform>
    <name>Table input decision-document-service</name>
    <type>TableInput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <connection>postgres.decision-document-service</connection>
    <execute_each_row>N</execute_each_row>
    <limit>0</limit>
    <sql>SELECT
	recruit_id,
	extra_info->>'preTrialNumber' AS case_number_before, -- номер дела об административном правонарушении (досудебный)
	extra_info->>'createInfringementDate' AS date_initiation, -- дата возбуждения дела об административном правонарушении
	extra_info->>'organization' AS body_initiated, -- орган, возбудивший дело об административном правонарушении
	decision_number AS case_number, -- номер дела об административном правонарушении
	decision_date AS date_resolution, -- дата постановления
	extra_info->>'reasonForAddEntry' AS article_koap_rf, -- пункт, часть, статья КоАП РФ
	extra_info->>'court' AS court_decision, -- суд, вынесший постановление
	extra_info->>'vkName' AS name_vc, -- военкомат, принявший решение о применении мер
	CASE
		WHEN decision_reason = '1' THEN 'Неисполнение гражданами обязанностей по воинскому учету'
		WHEN decision_reason = '2' THEN 'Уклонение от медицинского обследования'
		WHEN decision_reason = '3' THEN 'Умышленные порча или утрата документов воинского учета'
		ELSE NULL
	END AS reason_use, -- причина применения
	extra_info->>'dateApplication' AS start_date, -- дата с которой наложена мера
	extra_info->>'description' AS size_term_punishment, -- размер и срок наказания
	CASE
		WHEN extra_info->>'punishment' = '1' THEN 'Предупреждение'
		WHEN extra_info->>'punishment' = '2' THEN 'Административный штраф'
		ELSE NULL
	END AS type_punishment, -- вид наказания
	true AS has_liability_fz53
FROM public.infringement
WHERE hidden IS FALSE
AND type = 'ADMINISTRATIVE'</sql>
    <variables_active>N</variables_active>
    <attributes/>
    <GUI>
      <xloc>608</xloc>
      <yloc>288</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Table output ervu_dashboard.citizen_liability_fz53</name>
    <type>TableOutput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>20000</commit>
    <connection>ervu-dashboard</connection>
    <fields>
      <field>
        <column_name>recruit_id</column_name>
        <stream_name>recruit_id</stream_name>
      </field>
      <field>
        <column_name>article_koap_rf</column_name>
        <stream_name>article_koap_rf</stream_name>
      </field>
      <field>
        <column_name>body_initiated</column_name>
        <stream_name>body_initiated</stream_name>
      </field>
      <field>
        <column_name>case_number</column_name>
        <stream_name>case_number</stream_name>
      </field>
      <field>
        <column_name>case_number_before</column_name>
        <stream_name>case_number_before</stream_name>
      </field>
      <field>
        <column_name>court_decision</column_name>
        <stream_name>court_decision</stream_name>
      </field>
      <field>
        <column_name>date_initiation</column_name>
        <stream_name>date_initiation</stream_name>
      </field>
      <field>
        <column_name>date_resolution</column_name>
        <stream_name>date_resolution</stream_name>
      </field>
      <field>
        <column_name>name_vc</column_name>
        <stream_name>name_vc</stream_name>
      </field>
      <field>
        <column_name>reason_use</column_name>
        <stream_name>reason_use</stream_name>
      </field>
      <field>
        <column_name>size_term_punishment</column_name>
        <stream_name>size_term_punishment</stream_name>
      </field>
      <field>
        <column_name>start_date</column_name>
        <stream_name>start_date</stream_name>
      </field>
      <field>
        <column_name>type_punishment</column_name>
        <stream_name>type_punishment</stream_name>
      </field>
    </fields>
    <ignore_errors>N</ignore_errors>
    <only_when_have_rows>N</only_when_have_rows>
    <partitioning_daily>N</partitioning_daily>
    <partitioning_enabled>N</partitioning_enabled>
    <partitioning_field/>
    <partitioning_monthly>Y</partitioning_monthly>
    <return_field/>
    <return_keys>N</return_keys>
    <schema>ervu_dashboard</schema>
    <specify_fields>Y</specify_fields>
    <table>citizen_liability_fz53</table>
    <tablename_field/>
    <tablename_in_field>N</tablename_in_field>
    <tablename_in_table>Y</tablename_in_table>
    <truncate>N</truncate>
    <use_batch>Y</use_batch>
    <attributes/>
    <GUI>
      <xloc>1008</xloc>
      <yloc>288</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Update</name>
    <type>Update</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>100</commit>
    <connection>ervu-dashboard</connection>
    <error_ignored>Y</error_ignored>
    <lookup>
      <key>
        <condition>=</condition>
        <field>recruit_id</field>
        <name>recruit_id</name>
      </key>
      <schema>ervu_dashboard</schema>
      <table>citizen</table>
      <value>
        <name>has_liability_fz53</name>
        <rename>has_liability_fz53</rename>
      </value>
    </lookup>
    <skip_lookup>N</skip_lookup>
    <use_batch>Y</use_batch>
    <attributes/>
    <GUI>
      <xloc>1008</xloc>
      <yloc>400</yloc>
    </GUI>
  </transform>
  <transform_error_handling>
  </transform_error_handling>
  <attributes/>
</pipeline>
