Talend,带有子条件的If语句

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

Talend, If Statement with subconditions

问题

  1. 我正在处理一个Talend作业在这个作业中我需要根据另一列的信息向一列中插入信息例如目标是在"Code_direction"等于"D45""Fonction_libelle"不等于"CHEF DE SERVICE""Fonction_Libelle"不等于"CHEF DE SERVICE ADJOINT""Saisie_manuelle_O_pour_Oui_sinon_rien"中插入"O"
  2. 目前我尝试了以下代码
  3. ```java
  4. if ("D45".equals(input_row.Code_direction) && (!("CHEF DE SERVICE".equals(input_row.Fonction_libelle) && !"CHEF DE SERVICE ADJOINT".equals(input_row.Fonction_libelle)))) {
  5. output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = "O";}

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

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

任何帮助将不胜感激!

  1. <details>
  2. <summary>英文:</summary>
  3. 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.
  4. 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";}

  1. 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...
  2. I think i did something wrong but i&#39;m not able to see what...
  3. Any help will be very appreciated !
  4. </details>
  5. # 答案1
  6. **得分**: 0
  7. 不要紧,暂时我会做其他事情...我可以通过在此之后添加另一个if语句来实现我想要的,例如:
  8. ```java
  9. if ("D45".equals(input_row.Code_direction)) {
  10. output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = "O";
  11. }
  12. if ("CHEF DE SERVICE".equals(input_row.Fonction_libelle) || "CHEF DE SERVICE ADJOINT".equals(input_row.Fonction_libelle)) {
  13. output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = "";
  14. }

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

英文:

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 :

  1. if (&quot;D45&quot;.equals(input_row.Code_direction)) {
  2. output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = &quot;O&quot;;
  3. }
  4. if (&quot;CHEF DE SERVICE&quot;.equals(input_row.Fonction_libelle) || &quot;CHEF DE SERVICE ADJOINT&quot;.equals(input_row.Fonction_libelle)) {
  5. output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = &quot;&quot;;
  6. }

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:

确定