Talend,带有子条件的If语句

huangapple go评论68阅读模式
英文:

Talend, If Statement with subconditions

问题

我正在处理一个Talend作业在这个作业中我需要根据另一列的信息向一列中插入信息例如目标是在"Code_direction"等于"D45""Fonction_libelle"不等于"CHEF DE SERVICE""Fonction_Libelle"不等于"CHEF DE SERVICE ADJOINT""Saisie_manuelle_O_pour_Oui_sinon_rien"中插入"O"

目前我尝试了以下代码

```java
if ("D45".equals(input_row.Code_direction) && (!("CHEF DE SERVICE".equals(input_row.Fonction_libelle) && !"CHEF DE SERVICE ADJOINT".equals(input_row.Fonction_libelle)))) {
    output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = "O";}

它可以工作,但不是100%准确。它会在"Code_direction"等于"D45"时,无论"Fonction_libelle"是否等于"CHEF DE SERVICE"或"CHEF DE SERVICE ADJOINT",都会将"O"放在所有地方...

我认为我做错了一些事情,但我无法看到是什么...

任何帮助将不胜感激!


<details>
<summary>英文:</summary>

I&#39;m working on a Talend job where i need to insert informations in a column depending of informations to another column. For example, the target here is to insert &quot;O&quot; into &quot;Saisie_manuelle_O_pour_Oui_sinon_rien&quot; if &quot;Code_direction&quot; equals &quot;D45&quot; and &quot;Fonction_libelle&quot; not equals CHEF DE SERVICE or &quot;Fonction_Libelle&quot; not equals CHEF DE SERVICE ADJOINT. 

For the moment i tried this : 

if ("D45".equals(input_row.Code_direction) && (!("CHEF DE SERVICE".equals(input_row.Fonction_libelle) && !"CHEF DE SERVICE ADJOINT".equals(input_row.Fonction_libelle))) {
output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = "O";}


It work but not 100%. It put &quot;O&quot; everywhere where &quot;Code_direction&quot; = &quot;D45&quot; even if Fonction_libelle not equal CHEF DE SERVICE OR CHEF DE SERVICE ADJOINT...

I think i did something wrong but i&#39;m not able to see what...

Any help will be very appreciated ! 


</details>


# 答案1
**得分**: 0

不要紧,暂时我会做其他事情...我可以通过在此之后添加另一个if语句来实现我想要的,例如:

```java
if ("D45".equals(input_row.Code_direction)) {
    output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = "O";
}

if ("CHEF DE SERVICE".equals(input_row.Fonction_libelle) || "CHEF DE SERVICE ADJOINT".equals(input_row.Fonction_libelle)) {
    output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = "";
}

这不太规范,但它能够正常工作!我会继续这样做暂时。

英文:

Never mind, for the moment i will do something else... I can do what i want by doing an other if statement after it, for example :

if (&quot;D45&quot;.equals(input_row.Code_direction)) {
    output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = &quot;O&quot;;
}

if (&quot;CHEF DE SERVICE&quot;.equals(input_row.Fonction_libelle) || &quot;CHEF DE SERVICE ADJOINT&quot;.equals(input_row.Fonction_libelle)) {
    output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = &quot;&quot;;
}

This is not very clean but it's working ! I'll continue like this for the moment.

huangapple
  • 本文由 发表于 2023年7月13日 19:34:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76678922.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定