/*     */ 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 TransferRouteXMLWriter
/*     */ {
/*     */   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();
/*     */     
/*  46 */     Element root = doc.createElement("ERPFramework");
/*  47 */     root.setAttribute("userId", user_id);
/*  48 */     root.setAttribute("time", UtilApi.getCurrentTime());
/*  49 */     root.setAttribute("actionType", actionType.toString());
/*  50 */     root.setAttribute("fileType", fileType.toString());
/*  51 */     root.setAttribute("aimType", aimType.toString());
/*  52 */     doc.appendChild(root);
/*     */     
/*  54 */     Iterator<String> iterator = map.keySet().iterator();
/*     */     
/*  56 */     while (iterator.hasNext()) {
/*  57 */       String item_number = iterator.next();
/*     */       
/*  59 */       Element routeInfo = doc.createElement("RouteInfo");
/*     */       
/*  61 */       Element assembly_item_number = doc.createElement("assembly_item_number");
/*     */       
/*  63 */       assembly_item_number.setTextContent(item_number);
/*     */       
/*  65 */       Element processes = doc.createElement("processes");
/*     */       
/*  67 */       List<String[]> list = map.get(item_number);
/*  68 */       int listSize = list.size();
/*  69 */       for (int i = 0; i < listSize; i++) {
/*  70 */         String[] arrStr = list.get(i);
/*  71 */         String operation_seq_num_str = arrStr[0];
/*  72 */         String department_code_str = arrStr[1];
/*  73 */         String operation_description_str = arrStr[2];
/*  74 */         String usage_rate_or_amount_str = arrStr[3];
/*  75 */         String usage_rate_or_amount_auxiliary_str = arrStr[4];
/*     */         
/*  77 */         Element process = doc.createElement("process");
/*  78 */         Element operation_seq_num = doc.createElement("operation_seq_num");
/*  79 */         Element department_code_new = doc.createElement("department_code_new");
/*  80 */         if (aimType.equals(AimType.chg)) {
/*  81 */           department_code_new = doc.createElement("department_code_new");
/*     */         } else {
/*  83 */           department_code_new = doc.createElement("department_code");
/*     */         } 
/*  85 */         Element operation_description = doc.createElement("operation_description");
/*  86 */         Element usage_rate_or_amount = doc.createElement("usage_rate_or_amount");
/*  87 */         Element usage_rate_or_amount_auxiliary = doc.createElement("usage_rate_or_amount_auxiliary");
/*     */         
/*  89 */         operation_seq_num.setTextContent(operation_seq_num_str);
/*  90 */         department_code_new.setTextContent(department_code_str);
/*  91 */         operation_description.setTextContent(operation_description_str);
/*  92 */         usage_rate_or_amount.setTextContent(usage_rate_or_amount_str);
/*  93 */         usage_rate_or_amount_auxiliary.setTextContent(usage_rate_or_amount_auxiliary_str);
/*     */         
/*  95 */         process.appendChild(operation_seq_num);
/*  96 */         process.appendChild(department_code_new);
/*  97 */         process.appendChild(operation_description);
/*  98 */         process.appendChild(usage_rate_or_amount);
/*  99 */         process.appendChild(usage_rate_or_amount_auxiliary);
/*     */         
/* 101 */         processes.appendChild(process);
/*     */       } 
/* 103 */       routeInfo.appendChild(assembly_item_number);
/* 104 */       routeInfo.appendChild(processes);
/* 105 */       root.appendChild(routeInfo);
/*     */     } 
/*     */     
/* 108 */     TransformerFactory tf = TransformerFactory.newInstance();
/* 109 */     Transformer transformer = tf.newTransformer();
/* 110 */     DOMSource source = new DOMSource(doc);
/* 111 */     transformer.setOutputProperty("encoding", "GB2312");
/* 112 */     transformer.setOutputProperty("indent", "yes");
/* 113 */     PrintWriter pw = new PrintWriter(new FileOutputStream(file));
/* 114 */     StreamResult result = new StreamResult(pw);
/* 115 */     transformer.transform(source, result);
/* 116 */     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\TransferRouteXMLWriter.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */