 package com.connor.erp.ItemAddTransferSendToERP;
 
 import com.connor.erp.toolkit.FileType;
 import com.connor.erp.toolkit.IsContinueDialog;
 import com.connor.erp.toolkit.UtilApi;
 import com.teamcenter.rac.aif.AbstractAIFCommand;
 import com.teamcenter.rac.aif.AbstractAIFUIApplication;
 import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
 import com.teamcenter.rac.kernel.TCComponent;
 import com.teamcenter.rac.kernel.TCComponentBOMLine;
 import com.teamcenter.rac.kernel.TCComponentItemRevision;
 import com.teamcenter.rac.kernel.TCComponentMEProcessRevision;
 import com.teamcenter.rac.kernel.TCComponentSignoff;
 import com.teamcenter.rac.kernel.TCComponentTask;
 import com.teamcenter.rac.kernel.TCComponentUser;
 import com.teamcenter.rac.kernel.TCException;
 import com.teamcenter.rac.kernel.TCPreferenceService;
 import com.teamcenter.rac.kernel.TCSession;
 import com.teamcenter.rac.util.MessageBox;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.swing.SwingUtilities;
 
 public class SendToERPCommand extends AbstractAIFCommand {
   private static final String NHL_ITEMIMPERP_PRIVILEGES = "NHL_ItemimpERP_Privileges";
   
   private static final String NHL_ITEMIMPERP_MENUAUTH = "NHL_ItemimpERP_MenuAuth";
   
   private static final String NHL_ITEMTYPEMOULD = "NHL_ItemtypeMould";
   
   private static final String NHL_ITEMTRANSFERTYPE = "NHL_ItemTransferType";
   
   private TCSession session;
   
   private AbstractAIFUIApplication application;
   
/*  59 */   private List<TCComponentItemRevision> ItemRevision = new ArrayList<TCComponentItemRevision>();
   
/*  60 */   private StringBuffer detailInfo = new StringBuffer("");
   
   private InterfaceAIFComponent[] targets;
   
   private String[] NHL_ItemtypeMould;
   
/*  69 */   private Map<String, String[]> typeToProsMap = (Map)new HashMap<String, String>();
   
   private TCPreferenceService ps;
   
   private int targetNum;
   
   private TCComponentUser currentUser;
   
/*  77 */   private List<String> listTypes = new ArrayList<String>();
   
   public SendToERPCommand(TCSession pSession, AbstractAIFUIApplication application) throws TCException {
/*  80 */     this.session = pSession;
/*  81 */     this.application = application;
/*  82 */     application.getTargetComponent();
/*  83 */     checkTarget();
   }
   
   public static void main(String[] args) {
/*  87 */     String str = "NHL8TESTRevsion:nhl8_test1,nhl8_test2".replace("：", ":").replace("，", ",");
/*  88 */     String[] arrStr = str.split(":");
/*  89 */     System.out.println("arrStr[0]===" + arrStr[0]);
/*  90 */     System.out.println("arrStr[1]===" + arrStr[1].split(",")[0]);
   }
   
   private void checkTarget() throws TCException {
/* 115 */     this.targets = this.application.getTargetComponents();
/* 116 */     if (this.targets == null || this.targets.length == 0) {
/* 117 */       MessageBox.post("请选择一个对象！", "提示", 2);
       return;
     } 
			for(InterfaceAIFComponent comp:targets) {
				TCComponent com = (TCComponent)comp;
				System.out.println("刷新"+com.toString());
				com.refresh();
			}
/* 121 */     this.ps = this.session.getPreferenceService();
/* 123 */     this.NHL_ItemtypeMould = this.ps.getStringArray(4, "NHL_ItemtypeMould");
/* 124 */     if (this.NHL_ItemtypeMould == null || this.NHL_ItemtypeMould.length == 0) {
/* 125 */       MessageBox.post("首选项NHL_ItemtypeMould尚未配置，请联系系统管理员！", "提示", 4);
       return;
     } 
/* 129 */     String[] NHL_ItemTransferType = this.ps.getStringArray(4, "NHL_ItemTransferType");
/* 131 */     if (NHL_ItemTransferType == null || NHL_ItemTransferType.length == 0) {
/* 132 */       MessageBox.post("首选项NHL_ItemTransferType尚未配置，请联系系统管理员！", "提示", 4);
       return;
     } 
/* 135 */     int typesLen = NHL_ItemTransferType.length;
/* 136 */     for (int n = 0; n < typesLen; n++) {
/* 137 */       String typeAndProNames = NHL_ItemTransferType[n].replace("：", ":").replace("，", ",");
/* 138 */       if (typeAndProNames.contains(":")) {
/* 139 */         String[] arrStr = typeAndProNames.split(":");
/* 140 */         this.typeToProsMap.put(arrStr[0], arrStr[1].split(","));
/* 141 */         this.listTypes.add(arrStr[0]);
       } else {
/* 143 */         this.listTypes.add(typeAndProNames);
       } 
     } 
/* 147 */     System.out.println("listTypes===" + this.listTypes);
/* 148 */     boolean isPrivilege = false;
/* 149 */     String[] userNames = this.ps.getStringArray(4, "NHL_ItemimpERP_Privileges");
/* 150 */     this.currentUser = this.session.getUser();
/* 151 */     String userID = "";
     try {
/* 153 */       userID = this.currentUser.getProperty("user_id");
/* 154 */     } catch (TCException e1) {
/* 155 */       e1.printStackTrace();
     } 
/* 157 */     if (userNames != null && userNames.length > 0) {
/* 158 */       int nameLen = userNames.length;
/* 159 */       for (int i = 0; i < nameLen; i++) {
/* 160 */         if (userNames[i].trim().equals(userID)) {
/* 161 */           isPrivilege = true;
           break;
         } 
       } 
     } else {
/* 166 */       MessageBox.post(this.application.getDesktop().getShell(), "请配置首选项NHL_ItemimpERP_Privileges！！", "警告", 4);
       return;
     } 
/* 170 */     this.targetNum = this.targets.length;
/* 171 */     TCComponent targetComponent = (TCComponent)this.targets[0];
/* 172 */     String targetType = "";
/* 173 */     if (targetComponent instanceof TCComponentBOMLine) {
/* 174 */       if (!isPrivilege) {
/* 175 */         MessageBox.post(this.application.getDesktop().getShell(), "您是普通用户权限不够，请联系管理员！", "警告", 4);
         return;
       } 
/* 178 */       targetType = ((TCComponentBOMLine)targetComponent).getItemRevision().getType();
     } else {
/* 180 */       targetType = targetComponent.getType();
     } 
/* 182 */     System.out.println("targetType===" + targetType);
/* 183 */     if (!this.detailInfo.equals(""))
/* 184 */       this.detailInfo = new StringBuffer(""); 
/* 186 */     if (targetComponent instanceof TCComponentTask) {
	System.out.println("目标是流程类型");
/* 187 */       if (isPrivilege) {
	System.out.println("用户有权限");
/* 188 */         for (int i = 0; i < this.targetNum; i++) {
/* 189 */           if (this.targets[i] instanceof TCComponentTask) {
/* 190 */             TCComponentTask task = (TCComponentTask)this.targets[i];
             try {
/* 192 */               TCComponent[] attachmentComponents = task.getRelatedComponents("root_target_attachments");
/* 193 */               int attachmentsLen = attachmentComponents.length;
System.out.println("流程目标下的对象数量为："+attachmentsLen);
/* 194 */               int virtualNum = 0;
/* 195 */               boolean existProcess = false;
/* 196 */               for (int j = 0; j < attachmentsLen; j++) {
/* 197 */                 String type = attachmentComponents[j].getType();
System.out.println("版本类型："+type);
/* 198 */                 if (this.listTypes.contains(type)) {
/* 199 */                   TCComponentItemRevision revision = (TCComponentItemRevision)attachmentComponents[j];
/* 200 */                   if ((revision.getReferenceListProperty("release_status_list")).length == 0)
/* 201 */                     this.detailInfo.append(revision + " 对象未发布<br>"); 
/* 203 */                   if (!this.ItemRevision.contains(revision)) {
	System.out.println("添加"+revision);
	/* 204 */                     this.ItemRevision.add(revision); 
}
/* 206 */                 } else if (attachmentComponents[j] instanceof TCComponentMEProcessRevision) {
/* 207 */                   TCComponentMEProcessRevision meprocessRev = (TCComponentMEProcessRevision)attachmentComponents[j];
/* 208 */                   if (meprocessRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision") && !meprocessRev.getType().equals("NHL8_RigOutGXRevision")) {
/* 209 */                     existProcess = true;
/* 210 */                     TCComponent[] meTargetComs = meprocessRev.getRelatedComponents("IMAN_METarget");
/* 211 */                     if (meTargetComs.length == 0) {
/* 212 */                       this.detailInfo.append(meprocessRev + " 制造目标关系没有关联任何零组件<br>");
/* 214 */                     } else if (meTargetComs[0].getType().equals("NHL8_VirtualPartRevision")) {
/* 215 */                       virtualNum++;
/* 216 */                       TCComponentItemRevision revision = (TCComponentItemRevision)meTargetComs[0];
/* 217 */                       if ((revision.getReferenceListProperty("release_status_list")).length == 0)
/* 218 */                         this.detailInfo.append(revision + " 对象未发布"); 
/* 220 */                       if (!this.ItemRevision.contains(revision))
/* 221 */                         this.ItemRevision.add(revision); 
                     } 
                   } 
                 } 
               } 
/* 228 */               if (existProcess && virtualNum == 0) {
/* 229 */                 MessageBox.post(this.application.getDesktop().getShell(), "制造目标均非工艺虚拟件，不可导入！", "警告", 4);
                 return;
               } 
/* 232 */             } catch (TCException e) {
/* 233 */               e.printStackTrace();
/* 234 */             } catch (Exception e) {
/* 235 */               e.printStackTrace();
             } 
           } else {
/* 238 */             MessageBox.post(this.application.getDesktop().getShell(), "请确认选中的是任务对象！！", "警告", 4);
             return;
           } 
         } 
/* 242 */         if (!this.detailInfo.toString().equals("")) {
/* 243 */           setRunnable((Runnable)new IsContinueDialog(this, "所选部分基础物料版本对象未发布", this.detailInfo.toString()));
         } else {
/* 245 */           setRunnable((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap));
         } 
/* 248 */       } else if (!UtilApi.getTaskItemAddResult(this.application, this.session, FileType.item, "基础物料新增结果", Boolean.valueOf(false), this, "task")) {
         return;
       } 
/* 253 */     } else if (this.listTypes.contains(targetType)) {
/* 254 */       if (isPrivilege) {
/* 255 */         for (int i = 0; i < this.targetNum; i++) {
/* 256 */           String type = "";
/* 257 */           TCComponentItemRevision revision = null;
/* 258 */           if (this.targets[i] instanceof TCComponentBOMLine) {
/* 259 */             revision = ((TCComponentBOMLine)this.targets[i]).getItemRevision();
/* 260 */             type = revision.getType();
           } else {
/* 262 */             revision = (TCComponentItemRevision)this.targets[i];
/* 263 */             type = this.targets[i].getType();
           } 
/* 265 */           if (revision != null && this.listTypes.contains(type)) {
/* 266 */             if ((revision.getReferenceListProperty("release_status_list")).length == 0)
/* 267 */               this.detailInfo.append(revision + " 对象未发布<br>"); 
/* 269 */             this.ItemRevision.add(revision);
           } else {
/* 271 */             MessageBox.post(this.application.getDesktop().getShell(), "请选中首选项中配置的Item版本对象！！", "警告", 4);
             return;
           } 
         } 
/* 275 */         if (!this.detailInfo.toString().equals("")) {
/* 276 */           setRunnable((Runnable)new IsContinueDialog(this, "所选部分基础物料版本对象未发布", this.detailInfo.toString()));
         } else {
/* 278 */           setRunnable((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap));
         } 
/* 281 */       } else if (!UtilApi.getTaskItemAddResult(this.application, this.session, FileType.item, "基础物料新增结果", Boolean.valueOf(false), this, "item")) {
         return;
       } 
/* 285 */     } else if (targetComponent instanceof TCComponentBOMLine || targetComponent instanceof TCComponentMEProcessRevision) {
/* 286 */       TCComponentMEProcessRevision meprocessRev = null;
/* 287 */       if (targetComponent instanceof TCComponentBOMLine) {
/* 288 */         if (((TCComponentBOMLine)targetComponent).getItemRevision() instanceof TCComponentMEProcessRevision)
/* 289 */           meprocessRev = (TCComponentMEProcessRevision)((TCComponentBOMLine)targetComponent).getItemRevision(); 
       } else {
/* 292 */         meprocessRev = (TCComponentMEProcessRevision)targetComponent;
       } 
/* 294 */       if (meprocessRev != null && meprocessRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision")) {
/* 295 */         if (isPrivilege) {
/* 296 */           int virtualNum = 0;
/* 297 */           boolean existProcess = false;
/* 298 */           for (int i = 0; i < this.targetNum; i++) {
/* 299 */             if (this.targets[i] instanceof TCComponentMEProcessRevision) {
/* 300 */               TCComponentMEProcessRevision processRev = (TCComponentMEProcessRevision)this.targets[i];
/* 301 */               if (processRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision") && !meprocessRev.getType().equals("NHL8_RigOutGXRevision")) {
/* 302 */                 existProcess = true;
/* 303 */                 TCComponent[] meTargetComs = processRev.getRelatedComponents("IMAN_METarget");
/* 304 */                 if (meTargetComs.length == 0) {
/* 305 */                   this.detailInfo.append(processRev + " 制造目标关系没有关联任何零组件<br>");
/* 310 */                 } else if (meTargetComs[0].getType().equals("NHL8_VirtualPartRevision")) {
/* 311 */                   virtualNum++;
/* 312 */                   TCComponentItemRevision revision = (TCComponentItemRevision)meTargetComs[0];
/* 313 */                   if ((revision.getReferenceListProperty("release_status_list")).length == 0)
/* 314 */                     this.detailInfo.append(revision + " 对象未发布<br>"); 
/* 316 */                   if (!this.ItemRevision.contains(revision))
/* 317 */                     this.ItemRevision.add(revision); 
                 } 
               } else {
/* 322 */                 MessageBox.post(this.application.getDesktop().getShell(), "请选中工艺版本对象！！", "警告", 4);
                 return;
               } 
             } else {
/* 326 */               MessageBox.post(this.application.getDesktop().getShell(), "请选中工艺版本对象！！", "警告", 4);
               return;
             } 
           } 
/* 330 */           if (existProcess && virtualNum == 0) {
/* 331 */             MessageBox.post(this.application.getDesktop().getShell(), "制造目标均非工艺虚拟件，不可导入！", "警告", 4);
             return;
           } 
/* 334 */           if (!this.detailInfo.toString().equals("")) {
/* 335 */             setRunnable((Runnable)new IsContinueDialog(this, "所选部分基础物料版本对象未发布", this.detailInfo.toString()));
           } else {
/* 337 */             setRunnable((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap));
           } 
/* 340 */         } else if (!UtilApi.getTaskItemAddResult(this.application, this.session, FileType.item, "基础物料新增结果", Boolean.valueOf(false), this, "process")) {
           return;
         } 
       } else {
/* 345 */         MessageBox.post(this.application.getDesktop().getShell(), "请您选择流程中的任务或ITEM版本对象！！", "警告", 4);
         return;
       } 
     } else {
/* 349 */       MessageBox.post(this.application.getDesktop().getShell(), "请您选择流程中的任务或ITEM版本对象！！", "警告", 4);
       return;
     } 
   }
   
   public boolean isRightProcess(TCComponentMEProcessRevision meProcessRevision, List<String> listProcessAndTaskNames) throws TCException {
/* 363 */     TCComponent[] processStageList = meProcessRevision.getReferenceListProperty("process_stage_list");
/* 364 */     int listSize = processStageList.length;
/* 365 */     TCComponentTask referenceTask = null;
/* 366 */     if (listSize > 0) {
/* 367 */       String rootTaskName = processStageList[0].getProperty("object_name");
/* 368 */       for (int j = 1; j < listSize; j++) {
/* 369 */         if (listProcessAndTaskNames.contains(rootTaskName + ":" + processStageList[j].getProperty("object_name"))) {
/* 370 */           referenceTask = (TCComponentTask)processStageList[j];
           break;
         } 
       } 
/* 374 */       if (referenceTask != null) {
/* 375 */         TCComponentTask[] subTasks = referenceTask.getSubtasks();
/* 376 */         int subTaskNum = subTasks.length;
/* 377 */         boolean isTaskPerformer = false;
/* 378 */         for (int i = 0; i < subTaskNum; i++) {
/* 379 */           TCComponentTask subTask = subTasks[i];
/* 380 */           String taskType = subTask.getType();
/* 381 */           if (taskType.equals("EPMPerformSignoffTask")) {
/* 382 */             TCComponentSignoff[] signoffs = subTask.getPredecessors()[0].getValidSignoffs();
/* 383 */             int signoffNum = signoffs.length;
/* 384 */             for (int k = 0; k < signoffNum; k++) {
/* 385 */               if (signoffs[k].getGroupMember().getUser().equals(this.currentUser)) {
/* 386 */                 isTaskPerformer = true;
                 break;
               } 
             } 
             break;
           } 
         } 
/* 393 */         if (isTaskPerformer)
/* 394 */           return true; 
/* 396 */         MessageBox.post(this.application.getDesktop().getShell(), "请确定对工艺版本对象的操作权限！！", "警告", 4);
/* 397 */         return false;
       } 
/* 400 */       MessageBox.post(this.application.getDesktop().getShell(), "请选中在正确流程节点中的工艺版本对象！！", "警告", 4);
/* 401 */       return false;
     } 
/* 404 */     MessageBox.post(this.application.getDesktop().getShell(), "请选中在正确流程节点中的工艺版本对象！！", "警告", 4);
/* 405 */     return false;
   }
   
   public void postDialogForTask() {
/* 410 */     String[] processAndTaskNames = this.ps.getStringArray(4, "NHL_ItemimpERP_MenuAuth");
/* 411 */     List<String> listProcessAndTaskNames = new ArrayList<String>();
/* 412 */     if (processAndTaskNames == null || processAndTaskNames.length == 0) {
/* 413 */       MessageBox.post("首选项NHL_ItemimpERP_MenuAuth尚未配置，请联系系统管理员！", "提示", 4);
       return;
     } 
/* 416 */     int nameLen = processAndTaskNames.length;
/* 417 */     for (int j = 0; j < nameLen; j++)
/* 418 */       listProcessAndTaskNames.add(processAndTaskNames[j].trim().replace("：", ":")); 
/* 421 */     for (int i = 0; i < this.targetNum; i++) {
/* 422 */       if (this.targets[i] instanceof TCComponentTask) {
/* 423 */         TCComponentTask task = (TCComponentTask)this.targets[i];
/* 424 */         String taskType = task.getType();
/* 425 */         String processAndTaskName = "";
/* 426 */         boolean isTaskPerformer = false;
         try {
/* 428 */           if (taskType.equals("EPMPerformSignoffTask")) {
/* 429 */             processAndTaskName = task.getRoot().getProcessDefinition().getName() + ":" + task.getParent().getName();
/* 430 */             TCComponentSignoff[] signoffs = task.getPredecessors()[0].getValidSignoffs();
/* 431 */             int signoffNum = signoffs.length;
/* 432 */             for (int k = 0; k < signoffNum; k++) {
/* 433 */               if (signoffs[k].getGroupMember().getUser().equals(this.currentUser)) {
/* 434 */                 isTaskPerformer = true;
                 break;
               } 
             } 
           } 
/* 439 */           if (isTaskPerformer) {
/* 440 */             if (listProcessAndTaskNames.contains(processAndTaskName)) {
/* 441 */               TCComponent[] attachmentComponents = task.getRelatedComponents("root_target_attachments");
/* 442 */               int attachmentsLen = attachmentComponents.length;
System.out.println("流程目标下的对象数量："+attachmentsLen);
/* 443 */               boolean existMEPro = false;
/* 444 */               int virtualNum = 0;
/* 445 */               for (int k = 0; k < attachmentsLen; k++) {
/* 446 */                 String type = attachmentComponents[k].getType();
System.out.println("目标类型："+type);
/* 447 */                 if (this.listTypes.contains(type)) {
	System.out.println("符合类型");
/* 448 */                   TCComponentItemRevision revision = (TCComponentItemRevision)attachmentComponents[k];
/* 449 */                   if ((revision.getReferenceListProperty("release_status_list")).length == 0) {
/* 450 */                     MessageBox.post(revision + " 对象未发布", "警告", 4);
                     return;
                   } 
/* 453 */                   if (!this.ItemRevision.contains(revision)) {
	System.out.println("添加："+revision);
	/* 454 */                     this.ItemRevision.add(revision); 
}
/* 457 */                 } else if (attachmentComponents[k] instanceof TCComponentMEProcessRevision) {
/* 458 */                   TCComponentMEProcessRevision meprocessRev = (TCComponentMEProcessRevision)attachmentComponents[k];
/* 459 */                   if (meprocessRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision") && !meprocessRev.getType().equals("NHL8_RigOutGXRevision")) {
/* 460 */                     existMEPro = true;
/* 461 */                     TCComponent[] meTargetComs = meprocessRev.getRelatedComponents("IMAN_METarget");
/* 462 */                     if (meTargetComs.length == 0) {
/* 463 */                       MessageBox.post(meprocessRev + "制造目标关系没有关联任何零组件!", "提示", 4);
                       return;
                     } 
/* 469 */                     if (meTargetComs[0].getType().equals("NHL8_VirtualPartRevision")) {
/* 470 */                       TCComponentItemRevision revision = (TCComponentItemRevision)meTargetComs[0];
/* 471 */                       if ((revision.getReferenceListProperty("release_status_list")).length == 0) {
/* 472 */                         MessageBox.post(revision + " 对象未发布", "警告", 4);
                         return;
                       } 
/* 475 */                       virtualNum++;
/* 476 */                       if (!this.ItemRevision.contains(revision))
/* 477 */                         this.ItemRevision.add(revision); 
                     } 
                   } 
                 } 
               } 
/* 485 */               if (existMEPro && virtualNum == 0) {
/* 486 */                 MessageBox.post(this.application.getDesktop().getShell(), "制造目标均非工艺虚拟件，不可导入！", "警告", 4);
                 return;
               } 
             } else {
/* 490 */               MessageBox.post(this.application.getDesktop().getShell(), "请选中在正确流程节点中的对象！！", "警告", 4);
               return;
             } 
           } else {
/* 494 */             MessageBox.post(this.application.getDesktop().getShell(), "请选中有权限的任务对象！！", "警告", 4);
             return;
           } 
/* 497 */         } catch (TCException e) {
/* 498 */           e.printStackTrace();
/* 499 */         } catch (Exception e) {
/* 500 */           e.printStackTrace();
         } 
       } else {
/* 503 */         MessageBox.post(this.application.getDesktop().getShell(), "请确认选中的是任务对象！！", "警告", 4);
         return;
       } 
     } 
/* 507 */     if (this.ItemRevision.size() > 0) {
/* 508 */       SwingUtilities.invokeLater((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap));
     } else {
/* 510 */       MessageBox.post(this.application.getDesktop().getShell(), "没有在流程下面找到合适的版本对象！", "警告", 4);
       return;
     } 
   }
   
   public void postDialogForItem() {
/* 516 */     String[] processAndTaskNames = this.ps.getStringArray(4, "NHL_ItemimpERP_MenuAuth");
/* 517 */     List<String> listProcessAndTaskNames = new ArrayList<String>();
/* 518 */     if (processAndTaskNames == null || processAndTaskNames.length == 0) {
/* 519 */       MessageBox.post("首选项NHL_ItemimpERP_MenuAuth尚未配置，请联系系统管理员！", "提示", 4);
       return;
     } 
/* 522 */     int nameLen = processAndTaskNames.length;
/* 523 */     for (int j = 0; j < nameLen; j++)
/* 524 */       listProcessAndTaskNames.add(processAndTaskNames[j].trim().replace("：", ":")); 
/* 527 */     for (int i = 0; i < this.targetNum; i++) {
/* 528 */       String type = this.targets[i].getType();
/* 529 */       if (this.listTypes.contains(type)) {
/* 530 */         TCComponentItemRevision revision = (TCComponentItemRevision)this.targets[i];
         try {
/* 532 */           if ((revision.getReferenceListProperty("release_status_list")).length == 0) {
/* 533 */             MessageBox.post(this.application.getDesktop().getShell(), revision + " 对象未发布！！", "警告", 4);
             return;
           } 
/* 536 */           TCComponent[] processStageList = revision.getReferenceListProperty("fnd0StartedWorkflowTasks");
/* 537 */           int listSize = processStageList.length;
/* 538 */           TCComponentTask referenceTask = null;
/* 539 */           if (listSize > 0) {
/* 540 */             String rootTaskName = processStageList[0].getProperty("object_name");
/* 541 */             for (int k = 1; k < listSize; k++) {
/* 542 */               if (listProcessAndTaskNames.contains(rootTaskName + ":" + processStageList[k].getProperty("object_name"))) {
/* 543 */                 referenceTask = (TCComponentTask)processStageList[k];
                 break;
               } 
             } 
/* 547 */             if (referenceTask != null) {
/* 548 */               TCComponentTask[] subTasks = referenceTask.getSubtasks();
/* 549 */               int subTaskNum = subTasks.length;
/* 550 */               boolean isTaskPerformer = false;
/* 551 */               for (int m = 0; m < subTaskNum; m++) {
/* 552 */                 TCComponentTask subTask = subTasks[m];
/* 553 */                 String taskType = subTask.getType();
/* 554 */                 if (taskType.equals("EPMPerformSignoffTask")) {
/* 555 */                   TCComponentSignoff[] signoffs = subTask.getPredecessors()[0].getValidSignoffs();
/* 556 */                   int signoffNum = signoffs.length;
/* 557 */                   for (int n = 0; n < signoffNum; n++) {
/* 558 */                     if (signoffs[n].getGroupMember().getUser().equals(this.currentUser)) {
/* 559 */                       isTaskPerformer = true;
                       break;
                     } 
                   } 
                   break;
                 } 
               } 
/* 566 */               if (isTaskPerformer) {
/* 567 */                 this.ItemRevision.add(revision);
               } else {
/* 569 */                 MessageBox.post(this.application.getDesktop().getShell(), "请确定对Item版本对象的操作权限！！", "警告", 4);
                 return;
               } 
             } else {
/* 573 */               MessageBox.post(this.application.getDesktop().getShell(), "请选中在正确流程节点中的Item版本对象！！", "警告", 4);
               return;
             } 
           } else {
/* 577 */             MessageBox.post(this.application.getDesktop().getShell(), "请选中流程中的ITEM对象！！！", "警告", 4);
             return;
           } 
/* 581 */         } catch (TCException e) {
/* 582 */           e.printStackTrace();
         } 
       } else {
/* 585 */         MessageBox.post(this.application.getDesktop().getShell(), "请选中首选项中配置的Item版本对象！！", "警告", 4);
         return;
       } 
     } 
/* 589 */     if (this.ItemRevision.size() > 0) {
/* 590 */       SwingUtilities.invokeLater((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap));
     } else {
/* 592 */       MessageBox.post(this.application.getDesktop().getShell(), "没有在流程下面找到合适的版本对象！", "警告", 4);
       return;
     } 
   }
   
   public void postDialogForMeProcess() {
/* 598 */     String[] processAndTaskNames = this.ps.getStringArray(4, "NHL_ItemimpERP_MenuAuth");
/* 599 */     List<String> listProcessAndTaskNames = new ArrayList<String>();
/* 600 */     if (processAndTaskNames == null || processAndTaskNames.length == 0) {
/* 601 */       MessageBox.post("首选项NHL_ItemimpERP_MenuAuth尚未配置，请联系系统管理员！", "提示", 4);
       return;
     } 
/* 604 */     int nameLen = processAndTaskNames.length;
/* 605 */     for (int i = 0; i < nameLen; i++)
/* 606 */       listProcessAndTaskNames.add(processAndTaskNames[i].trim().replace("：", ":")); 
/* 609 */     int virtualNum = 0;
/* 610 */     boolean existProcess = false;
/* 611 */     for (int j = 0; j < this.targetNum; j++) {
/* 612 */       if (this.targets[j] instanceof TCComponentMEProcessRevision) {
/* 613 */         TCComponentMEProcessRevision processRev = (TCComponentMEProcessRevision)this.targets[j];
         try {
/* 615 */           if (processRev.getTCClass().getSuperClass().toString().equals("NHL8_MeprocessRevision") && !processRev.getType().equals("NHL8_RigOutGXRevision")) {
/* 616 */             if (!isRightProcess(processRev, listProcessAndTaskNames))
               return; 
/* 619 */             existProcess = true;
/* 620 */             TCComponent[] meTargetComs = processRev.getRelatedComponents("IMAN_METarget");
/* 621 */             if (meTargetComs.length == 0) {
/* 622 */               MessageBox.post(this.application.getDesktop().getShell(), processRev + " 制造目标关系没有关联任何零组件！", "警告", 4);
               return;
             } 
/* 627 */             if (meTargetComs[0].getType().equals("NHL8_VirtualPartRevision")) {
/* 628 */               TCComponentItemRevision revision = (TCComponentItemRevision)meTargetComs[0];
/* 629 */               if ((revision.getReferenceListProperty("release_status_list")).length == 0) {
/* 630 */                 MessageBox.post(this.application.getDesktop().getShell(), revision + " 对象未发布！", "警告", 4);
                 return;
               } 
/* 633 */               virtualNum++;
/* 634 */               if (!this.ItemRevision.contains(revision))
/* 635 */                 this.ItemRevision.add(revision); 
             } 
           } else {
/* 641 */             MessageBox.post(this.application.getDesktop().getShell(), "请选中工艺版本对象！！", "警告", 4);
             return;
           } 
/* 644 */         } catch (TCException e) {
/* 645 */           e.printStackTrace();
         } 
       } else {
/* 648 */         MessageBox.post(this.application.getDesktop().getShell(), "请选中工艺版本对象！！", "警告", 4);
         return;
       } 
     } 
/* 652 */     if (existProcess && virtualNum == 0) {
/* 653 */       MessageBox.post(this.application.getDesktop().getShell(), "制造目标均非工艺虚拟件，不可导入！", "警告", 4);
       return;
     } 
/* 656 */     if (this.ItemRevision.size() > 0) {
/* 657 */       SwingUtilities.invokeLater((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap));
     } else {
/* 659 */       MessageBox.post(this.application.getDesktop().getShell(), "没有在流程下面找到合适的版本对象！", "警告", 4);
       return;
     } 
   }
   
   public void postDialog() {
/* 665 */     if (this.ItemRevision.size() > 0) {
/* 666 */       SwingUtilities.invokeLater((Runnable)new SendToERPDialog(this.session, this.NHL_ItemtypeMould, this.ItemRevision, this.typeToProsMap));
     } else {
/* 668 */       MessageBox.post(this.application.getDesktop().getShell(), "没有在流程下面找到合适的版本对象！", "警告", 4);
       return;
     } 
   }
 }

