/*     */ package com.connor.erp.ProcessImport;
/*     */ 
/*     */ import com.connor.erp.toolkit.ActionType;
/*     */ import com.connor.erp.toolkit.AimType;
/*     */ import com.connor.erp.toolkit.FileType;
/*     */ import com.connor.erp.toolkit.UtilApi;
/*     */ import java.io.FileNotFoundException;
/*     */ import java.io.FileOutputStream;
/*     */ import java.io.PrintWriter;
/*     */ import java.util.Iterator;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.xml.parsers.DocumentBuilder;
/*     */ import javax.xml.parsers.DocumentBuilderFactory;
/*     */ import javax.xml.parsers.ParserConfigurationException;
/*     */ import javax.xml.transform.Transformer;
/*     */ import javax.xml.transform.TransformerException;
/*     */ import javax.xml.transform.TransformerFactory;
/*     */ import javax.xml.transform.dom.DOMSource;
/*     */ import javax.xml.transform.stream.StreamResult;
/*     */ import org.w3c.dom.Document;
/*     */ import org.w3c.dom.Element;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class ValidateRouteXMLWriter
/*     */ {
/*     */   public static void createXML(String user_id, String file, ActionType actionType, FileType fileType, AimType aimType, Map<String, List<String>> map) throws ParserConfigurationException, FileNotFoundException, TransformerException {
/*  42 */     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
/*  43 */     DocumentBuilder db = dbf.newDocumentBuilder();
/*  44 */     Document doc = db.newDocument();
/*     */ 
/*     */     
/*  47 */     Element root = doc.createElement("ERPFramework");
/*  48 */     root.setAttribute("userId", user_id);
/*  49 */     root.setAttribute("time", UtilApi.getCurrentTime());
/*  50 */     root.setAttribute("actionType", actionType.toString());
/*  51 */     root.setAttribute("fileType", fileType.toString());
/*  52 */     root.setAttribute("aimType", aimType.toString());
/*  53 */     doc.appendChild(root);
/*     */     
/*  55 */     Iterator<String> iterator = map.keySet().iterator();
/*  56 */     if (aimType.equals(AimType.chg)) {
/*  57 */       while (iterator.hasNext()) {
/*  58 */         String item_number = iterator.next();
/*     */         
/*  60 */         Element routeInfo = doc.createElement("RouteInfo");
/*     */         
/*  62 */         Element assembly_item_number = doc.createElement("assembly_item_number");
/*     */         
/*  64 */         assembly_item_number.setTextContent(item_number);
/*     */         
/*  66 */         Element processes = doc.createElement("processes");
/*     */         
/*  68 */         List<String> list = map.get(item_number);
/*  69 */         int listSize = list.size();
/*  70 */         for (int i = 0; i < listSize; i++) {
/*  71 */           String operation_seq_num_str = ((String)list.get(i)).split(";")[0];
/*  72 */           String department_code_new_str = ((String)list.get(i)).split(";")[1];
/*  73 */           Element process = doc.createElement("process");
/*  74 */           Element operation_seq_num = doc.createElement("operation_seq_num");
/*  75 */           Element department_code_new = doc.createElement("department_code_new");
/*  76 */           operation_seq_num.setTextContent(operation_seq_num_str);
/*  77 */           department_code_new.setTextContent(department_code_new_str);
/*  78 */           process.appendChild(operation_seq_num);
/*  79 */           process.appendChild(department_code_new);
/*  80 */           processes.appendChild(process);
/*     */         } 
/*  82 */         routeInfo.appendChild(assembly_item_number);
/*  83 */         routeInfo.appendChild(processes);
/*  84 */         root.appendChild(routeInfo);
/*     */       } 
/*     */     } else {
/*  87 */       while (iterator.hasNext()) {
/*  88 */         String item_number = iterator.next();
/*     */         
/*  90 */         Element routeInfo = doc.createElement("RouteInfo");
/*     */         
/*  92 */         Element assembly_item_number = doc.createElement("assembly_item_number");
/*     */         
/*  94 */         assembly_item_number.setTextContent(item_number);
/*     */         
/*  96 */         Element processes = doc.createElement("processes");
/*     */         
/*  98 */         List<String> list = map.get(item_number);
/*  99 */         int listSize = list.size();
/* 100 */         for (int i = 0; i < listSize; i++) {
/* 101 */           Element process = doc.createElement("process");
/* 102 */           Element department_code = doc.createElement("department_code");
/* 103 */           department_code.setTextContent(list.get(i));
/* 104 */           process.appendChild(department_code);
/* 105 */           processes.appendChild(process);
/*     */         } 
/* 107 */         routeInfo.appendChild(assembly_item_number);
/* 108 */         routeInfo.appendChild(processes);
/* 109 */         root.appendChild(routeInfo);
/*     */       } 
/*     */     } 
/*     */     
/* 113 */     TransformerFactory tf = TransformerFactory.newInstance();
/* 114 */     Transformer transformer = tf.newTransformer();
/* 115 */     DOMSource source = new DOMSource(doc);
/* 116 */     transformer.setOutputProperty("encoding", "GB2312");
/* 117 */     transformer.setOutputProperty("indent", "yes");
/* 118 */     PrintWriter pw = new PrintWriter(new FileOutputStream(file));
/* 119 */     StreamResult result = new StreamResult(pw);
/* 120 */     transformer.transform(source, result);
/* 121 */     pw.close();
/*     */   }
/*     */ }


/* Location:              C:\Users\cyh\Documents\WeChat Files\wxid_ztg4pdvd5bjn12\FileStorage\File\2022-03\com.origin.erpintegration_1.0.0.jar!\com\origin\erp\ProcessImport\ValidateRouteXMLWriter.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */