मुझे प्रत्येक सबजॉब को "रियलाइजेशन रिलेशनशिप" के साथ नौकरी से जोड़ने की जरूरत है और पिछले और अगले सबजॉब के बीच के संबंध में एक "ट्रिगरिंग रिलेशनशिप" है: जॉब इस प्रारूप का है उदाहरण के लिए ACGN100Q जबकि संलग्न किए गए सबजॉब अनुक्रमिक हैं और इसके प्रारूप: ACGN-100Q-000T; ACGN-100Q-010T; ACGN-100Q-020T; ACGN-100Q-030T

मेरी सीएसवी फ़ाइल में इस कार्य का प्रकार ACGN100Q "TechnologyInteraction" है, जबकि उप-कार्य "TechnologyService" प्रकार के हैं। मैं एक स्क्रिप्ट विकसित कर रहा हूं जो मुझे उदाहरण के लिए कहने की अनुमति देता है कि ACGN-100Q-000T और ACGN-100Q-010T के बीच का लिंक "TrigerringRelation" प्रकार का है और ACGN100Q और ACGN-100Q-000T के बीच का लिंक "RealizationRelation" प्रकार का है। . मुझे मदद चाहिए क्योंकि मैं लिंक नहीं बना सकता।

और अंत में "TechnologyInteraction" प्रकार की नौकरी और "TechnologyEvent" प्रकार की नौकरी के बीच संबंध "TriggeringRelationship मेरे पास पिछली पोस्ट में उत्तर की शुरुआत है, लेकिन यह पता चला है कि विषय को अच्छी तरह से समझ में नहीं आया था, अब मैं क्या हूं की तलाश स्पष्ट है।

ID,"Type","Name","Documentation", "planification" 

eb214110-2b6a-48b2-ba5a-7c13dc3bba39,"TechnologyInteraction","ACGN100Q","Begin Of JobStream"
a46681e7-19a8-4fc5-b747-09679c15ff26,"TechnologyService","ACGN-100Q-000T","Transfert UDM (xACGN000)"
85761a09-1145-4037-a527-66a743def45f,"TechnologyService","ACGN-100Q-010T","move fichier REF to work"
27b126fb-c708-427d-b0a6-ce4747114ac4,"TechnologyService","ACGN-100Q-020T","w_read_account"
bb0c5e42-5fad-4bd9-8ee9-f41d0b824e82,"TechnologyService","ACGN-100Q-030T","w_read_referential"
0b8b76e3-62fa-4527-9f05-2eb4dbaa8e97,"TechnologyService","ACGN-100Q-040T","w_load_CompanyGroup"
1f487986-3cac-4af8-bda2-6400a1c71f48,"TechnologyService","ACGN-100Q-050T","w_load_Company"
40bec2d6-4545-48c2-acd5-089a05d4a723,"TechnologyInteraction","ADMR061Q","Begin Of JobStream", "23h30" 
14b2e8ce-cceb-4a72-a22b-1518ca582dfe,"TechnologyEvent","Create list files 23h30","ADMR-061Q-090T", "23h30" 
fe7d7052-a3e5-4cea-a987-567e29fdf685,"TechnologyEvent","w_F_REF08_BROKER 23h30","ADMR-061Q-100T",  "23h30" 
ddc3713b-57ec-4152-8dc7-01b8166c969a,"TechnologyEvent","w_F_REF08_CEDENT 23h30","ADMR-061Q-100T", "23h30" 

और मैं एक ऐसी फाइल प्राप्त करना चाहता हूं जो इस तरह दिखती है:

संबंध.सीएसवी

"ID","Type","Name","Documentation","Source","Target"

"New ID","RealizationRelationship","","","eb214110-2b6a-48b2-ba5a-7c13dc3bba39","a46681e7-19a8-4fc5-b747-09679c15ff26"
"New ID","RealizationRelationship","","","eb214110-2b6a-48b2-ba5a-7c13dc3bba39","85761a09-1145-4037-a527-66a743def45f"
"New ID","RealizationRelationship","","","eb214110-2b6a-48b2-ba5a-7c13dc3bba39","27b126fb-c708-427d-b0a6-ce4747114ac4"
"New ID","RealizationRelationship","","","eb214110-2b6a-48b2-ba5a-7c13dc3bba39","bb0c5e42-5fad-4bd9-8ee9-f41d0b824e82"
"New ID","RealizationRelationship","","","eb214110-2b6a-48b2-ba5a-7c13dc3bba39","0b8b76e3-62fa-4527-9f05-2eb4dbaa8e97"
"New ID","RealizationRelationship","","","eb214110-2b6a-48b2-ba5a-7c13dc3bba39","1f487986-3cac-4af8-bda2-6400a1c71f48"
"New ID","TriggeringRelationship","","","a46681e7-19a8-4fc5-b747-09679c15ff26","85761a09-1145-4037-a527-66a743def45f"
"New ID","TriggeringRelationship","","","85761a09-1145-4037-a527-66a743def45f","27b126fb-c708-427d-b0a6-ce4747114ac4"
"New ID","TriggeringRelationship","","","27b126fb-c708-427d-b0a6-ce4747114ac4","bb0c5e42-5fad-4bd9-8ee9-f41d0b824e82"
"New ID","TriggeringRelationship","","","bb0c5e42-5fad-4bd9-8ee9-f41d0b824e82","0b8b76e3-62fa-4527-9f05-2eb4dbaa8e97"
"New ID","TriggeringRelationship","","","0b8b76e3-62fa-4527-9f05-2eb4dbaa8e97","1f487986-3cac-4af8-bda2-6400a1c71f48"

"New ID","TriggeringRelationship","","","40bec2d6-4545-48c2-acd5-089a05d4a723","14b2e8ce-cceb-4a72-a22b-1518ca582dfe"
"New ID","TriggeringRelationship","","","40bec2d6-4545-48c2-acd5-089a05d4a723","fe7d7052-a3e5-4cea-a987-567e29fdf685"
"New ID","TriggeringRelationship","","","40bec2d6-4545-48c2-acd5-089a05d4a723","ddc3713b-57ec-4152-8dc7-01b8166c969a"
$result= @()
    
function linkedRelationCsvToElementsCsv{
 Write-Host "beginning linkedRelationCsvToElementsCsv"
$elements2Csv=Import-Csv $path\elements.csv

$jobTypes = @( "TechnologyInteraction");
$jobTypes2= @("TechnologyEvent");
$subTypes = @( "TechnologyService");

$previousItem = $null;

foreach( $item in $elements2Csv )
{
  
    if( $item.Type -in $jobTypes )
    {
        # start of a new job, but output  the link between TWS and Job name

          $result0=  new-object PSCustomObject -Property ([ordered] @{
            "ID"            = [guid]::NewGuid().ToString()
            "Type"          = "RealizationRelationship"
            "Name"          = "";
            "Documentation" = ""
            "Source"        ="ef2f510b-924b-439d-8720-0183c7294eb3"
            "Target"        = $item.ID
        });
        $result= $result + $result0
         
    }
     elseif( $item.Type -in $jobTypes2 )
    {
        # start of a new job, but output  the link between TWS and Job name

          $result3=  new-object PSCustomObject -Property ([ordered] @{
            "ID"            = [guid]::NewGuid().ToString()
            "Type"          = "RealizationRelationship"
            "Name"          = "";
            "Documentation" = ""
            "Source"        =$previousItem.ID
            "Target"        = $item.ID
        });
        $result= $result + $result3
         
    }
    elseif( $item.Type -in $subJobTypes)
    {
        # not a subjob type that we recognise
        throw "unrecognised subjob type '$($item.Type)' for subjob '$($item.ID)'";
    }
    elseif( $null -eq $previousItem )
    {
        # we've got a subjob, but there was no previous job or subjob
          throw "no preceding item for subjob '$($item.ID)'  with name: '$($item.Name)'";
       
    } 
    
    elseif( $previousItem.Type -in $jobTypes )
    {
     
        # this is the first subjob after the parent job
        
        $result1=  new-object PSCustomObject -Property ([ordered] @{
            "ID"            = [guid]::NewGuid().ToString()
            "Type"          = "TriggeringRelationship"
            "Name"          = ""
            "Documentation" = ""
            "Source"        = $previousItem.ID
            "Target"        = $item.ID
        });
        $result= $result + $result1
    }
  
    else
    {
        # the preceding item was a subjob as well
        $result2=  new-object PSCustomObject -Property ([ordered] @{
            "ID"            = [guid]::NewGuid().ToString()
            "Type"          = "TriggeringRelationship"
            "Name"          = ""
            "Documentation" = ""
            "Source"        = $previousItem.ID
            "Target"        = $item.ID
        });

        $result =$result + $result2
    }

    $previousItem = $item;
    #$elements2Csv
    Write-Host "previousItem value is '$($previousItem)'  and Item value is '$($item)'"
  
    }

$result |Select-Object -Property ID,"Type","Name","Documentation","Source","Target"| Export-Csv $path\relations.csv -NoTypeInformation -Encoding UTF8 
notepad $path\relations.csv 
   Write-Host "Ending  linkedRelationCsvToElementsCsv"
}linkedRelationCsvToElementsCsv # Call the function

0
Amakouladji 6 अक्टूबर 2021, 19:06
पहली CSV की अंतिम 4 पंक्तियाँ गड़बड़ दिखती हैं, क्या आप सुनिश्चित हैं कि आपने डेटा को सही ढंग से चिपकाया है?
 – 
Mathias R. Jessen
6 अक्टूबर 2021, 20:25
हां यह सही है।
 – 
Amakouladji
6 अक्टूबर 2021, 20:46
तीसरी से आखिरी नौकरी का नाम "Create list files 23h30" है? आप इन पंक्तियों के साथ क्या करना चाहते हैं जहां नाम किसी नौकरी पहचानकर्ता से मेल नहीं खाता है?
 – 
Mathias R. Jessen
6 अक्टूबर 2021, 20:48
TechnologyEvent एक ट्रिगर है जो आमतौर पर उस समय से मेल खाता है जब नौकरी शुरू हो जाती है। ट्रिगर किए गए कार्य का नाम "प्लानिफिकेशन" कॉलम में है।
 – 
Amakouladji
6 अक्टूबर 2021, 23:32

1 उत्तर

सबसे बढ़िया उत्तर

आप मास्टर रिकॉर्ड के नाम फ़ील्ड के एक्सट्रपलेशन के आधार पर नाम और दस्तावेज़ीकरण पर रेगेक्स मैच कर सकते हैं (इसे आधे में विभाजित करें, बीच में एक हाइफ़न छोड़ दें, और इसे वापस एक साथ चिपका दें)। वह मास्टर से बच्चे को आसानी से मिला देगा। फिर आप उन्हें माता-पिता द्वारा समूहित करना चाहते हैं और एक को अगले से जोड़ना चाहते हैं? यह काफी सरल होना चाहिए।

$Records=@'
ID,"Type","Name","Documentation", "planification" 

eb214110-2b6a-48b2-ba5a-7c13dc3bba39,"TechnologyInteraction","ACGN100Q","Begin Of JobStream"
a46681e7-19a8-4fc5-b747-09679c15ff26,"TechnologyService","ACGN-100Q-000T","Transfert UDM (xACGN000)"
85761a09-1145-4037-a527-66a743def45f,"TechnologyService","ACGN-100Q-010T","move fichier REF to work"
27b126fb-c708-427d-b0a6-ce4747114ac4,"TechnologyService","ACGN-100Q-020T","w_read_account"
bb0c5e42-5fad-4bd9-8ee9-f41d0b824e82,"TechnologyService","ACGN-100Q-030T","w_read_referential"
0b8b76e3-62fa-4527-9f05-2eb4dbaa8e97,"TechnologyService","ACGN-100Q-040T","w_load_CompanyGroup"
1f487986-3cac-4af8-bda2-6400a1c71f48,"TechnologyService","ACGN-100Q-050T","w_load_Company"
40bec2d6-4545-48c2-acd5-089a05d4a723,"TechnologyInteraction","ADMR061Q","Begin Of JobStream", "23h30" 
14b2e8ce-cceb-4a72-a22b-1518ca582dfe,"TechnologyEvent","Create list files 23h30","ADMR-061Q-090T", "23h30" 
fe7d7052-a3e5-4cea-a987-567e29fdf685,"TechnologyEvent","w_F_REF08_BROKER 23h30","ADMR-061Q-100T",  "23h30" 
ddc3713b-57ec-4152-8dc7-01b8166c969a,"TechnologyEvent","w_F_REF08_CEDENT 23h30","ADMR-061Q-100T", "23h30" 
'@ -split '[\r\n]+'|ConvertFrom-Csv
$HT = [Ordered]@{}
$Records|%{$HT.Add($_.ID,$_)}
$Relations = ForEach($Master in $Records|?{$_.Name -notmatch '-' -and $_.Documentation -notmatch '-'}){
    $Child = $Master.Name -split '(?<=^.{4})' -join '-'
    $Children = $Records|?{$_.Name -match "(.*$child.*)" -or $_.Documentation -match "(.*$child.*)"}|%{
        [pscustomobject]@{
            "ID"            = [guid]::NewGuid().ToString()
            "Type"          = "RealizationRelationship"
            "Name"          = "";
            "Documentation" = ""
            "Source"        =$Master.ID
            "Target"        = $_.ID
        }
    }
    $Children
    $Children|Group Source|%{
        For($i=1;$i -lt $_.Group.Count;$i++){
            [PSCustomObject]@{
                "ID"            = [guid]::NewGuid().ToString()
                "Type"          = "TriggeringRelationship"
                "Name"          = ""
                "Documentation" = ""
                "Source"        = $_.Group[$i-1].Target
                "Target"        = $_.Group[$i].Target
            }
        }
    }
}
$Relations|ft

वह आउटपुट:

ID                                   Type                    Name Documentation Source                               Target                              
--                                   ----                    ---- ------------- ------                               ------                              
9113f645-831a-4c86-9518-d8b0c95eae7a RealizationRelationship                    eb214110-2b6a-48b2-ba5a-7c13dc3bba39 a46681e7-19a8-4fc5-b747-09679c15ff26
db4436be-7dd7-4bba-8387-32ed97ed9885 RealizationRelationship                    eb214110-2b6a-48b2-ba5a-7c13dc3bba39 85761a09-1145-4037-a527-66a743def45f
94cc2eb4-63cf-4cae-a139-1628307e938b RealizationRelationship                    eb214110-2b6a-48b2-ba5a-7c13dc3bba39 27b126fb-c708-427d-b0a6-ce4747114ac4
c738adf7-dddb-45d3-aa99-ceb2113b969b RealizationRelationship                    eb214110-2b6a-48b2-ba5a-7c13dc3bba39 bb0c5e42-5fad-4bd9-8ee9-f41d0b824e82
11d94a45-2313-45b8-94d5-e5422bfc15c2 RealizationRelationship                    eb214110-2b6a-48b2-ba5a-7c13dc3bba39 0b8b76e3-62fa-4527-9f05-2eb4dbaa8e97
b1ff9e89-301d-4681-b6b5-d8418c41299d RealizationRelationship                    eb214110-2b6a-48b2-ba5a-7c13dc3bba39 1f487986-3cac-4af8-bda2-6400a1c71f48
25d4eb64-d580-40cd-9f7a-ff1c41217875 TriggeringRelationship                     a46681e7-19a8-4fc5-b747-09679c15ff26 85761a09-1145-4037-a527-66a743def45f
5a9f160e-5956-4a70-b8cb-ccfca764f772 TriggeringRelationship                     85761a09-1145-4037-a527-66a743def45f 27b126fb-c708-427d-b0a6-ce4747114ac4
c04434d3-1a22-47ba-a057-df430be0d5a9 TriggeringRelationship                     27b126fb-c708-427d-b0a6-ce4747114ac4 bb0c5e42-5fad-4bd9-8ee9-f41d0b824e82
b50754f9-145e-44a9-92ee-c1bceb8dea71 TriggeringRelationship                     bb0c5e42-5fad-4bd9-8ee9-f41d0b824e82 0b8b76e3-62fa-4527-9f05-2eb4dbaa8e97
0686e961-a90a-4f7f-a021-395b31157edf TriggeringRelationship                     0b8b76e3-62fa-4527-9f05-2eb4dbaa8e97 1f487986-3cac-4af8-bda2-6400a1c71f48
ae8b3626-859f-4426-b9f0-4ab4921a2ba0 RealizationRelationship                    40bec2d6-4545-48c2-acd5-089a05d4a723 14b2e8ce-cceb-4a72-a22b-1518ca582dfe
7acaaf00-bbc5-4944-993b-cdf6cafebc7b RealizationRelationship                    40bec2d6-4545-48c2-acd5-089a05d4a723 fe7d7052-a3e5-4cea-a987-567e29fdf685
5e8733ec-990c-408d-ab01-732cfcd7c76e RealizationRelationship                    40bec2d6-4545-48c2-acd5-089a05d4a723 ddc3713b-57ec-4152-8dc7-01b8166c969a
af4ba86f-3ab9-4996-a127-0ece6d1bca67 TriggeringRelationship                     14b2e8ce-cceb-4a72-a22b-1518ca582dfe fe7d7052-a3e5-4cea-a987-567e29fdf685
296447fc-3601-44ec-9f16-0907edcfffc1 TriggeringRelationship                     fe7d7052-a3e5-4cea-a987-567e29fdf685 ddc3713b-57ec-4152-8dc7-01b8166c969a
1
TheMadTechnician 7 अक्टूबर 2021, 00:56
नमस्ते, बहुत-बहुत धन्यवाद, यह ठीक काम कर रहा है
 – 
Amakouladji
7 अक्टूबर 2021, 15:02