feat: xml parse 진행

main
minuk926 2 years ago
parent 7570d050c6
commit 6d398fa381

@ -1,90 +0,0 @@
package kr.xit.framework.biz.cmm.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.Getter;
import lombok.Setter;
/**
* XmlRootElement
* JAXBContext
* XmlAccessorType
* FIELD - (static transient ) XML
* NONE - XML .
* PROPERTY - getter/setter XML .
* PUBLIC_MEMBER - public getter/setter XML .
*/
@Getter
@Setter
@XmlRootElement(name = "dmndinfo")
@XmlAccessorType(XmlAccessType.FIELD)
public class EcEsbInterfaceXmlDto {
/*
@XmlElement(name = "interface_seq_n")
private String interfaceSeqN;
sys_gubun_c
anc_code_v
peti_gubun_c
peti_anc_code_v
peti_no_c
civil_no_c
peter_name_v
zip_code_c
address_v
email_v
cel_no_v
tel_no_v
peti_title_v
peti_reason_l
open_yn_c
peti_reg_d
peti_reason_attach_yn_c
peti_file_size_n
peti_file_path1_v
peti_file_path2_v
peti_file_path3_v
peti_file_path4_v
peti_file_path5_v
civil_gist_v
civil_abstract_l
pcd_dept_v
pcd_dept_nm_v
duty_id_v
pcd_email_v
pcd_tel_v
pcd_rst_cont_l
do_reg_d
pcd_rst_cont_attach_yn_c
pcd_file_size_n
pcd_file_path1_v
pcd_file_path2_v
pcd_file_path3_v
pcd_file_path4_v
pcd_file_path5_v
pcd_anc_code_v
peti_proc_dur_n
peti_end_d
anc_reg_d
more_again_v
satisfy_c
satisfy2_c
satisfy3_c
satisfy_reg_d
reg_d
send_yn_c
send_d
apply_d
apply_gubun_c
pcd_gubun_v
pcd_gubun2_v
pcd_gubun3_v
ifid
srcorgcd
tgtorgcd
*/
}

@ -0,0 +1,177 @@
package kr.xit.framework.biz.cmm.model;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.traversal.DocumentTraversal;
import org.w3c.dom.traversal.NodeFilter;
import org.w3c.dom.traversal.NodeIterator;
import org.xml.sax.InputSource;
public class NatlNewspaper {
private NatlNewspaperXmlDto natlNewspaperXmlDto;
public static void main(String[] args) {
// String fileFullPath = "file:///D:/project_data/fims/01. 연계/01. 국민신문고/rcv/202209160959023e60d9$EPOUGA$1140100_2022091609485096255243399.xml";
// try {
// Document doc = XMLFilePath2Doc(fileFullPath);
// getNodeList(doc, "dmndinfo");
// //getNodeList(doc, "apndfilinfo");
// //getNodeList(doc, "apndfilcont1");
//
// //byte[] decode = Base64.decode(getNodeList(doc, "apndfilcont1"));
// //apndfilinfo
// } catch (Exception e) {
// e.printStackTrace();
// }
// String fpath = "D:/project_data/fims/01. 연계/01. 국민신문고/rcv/202209160959023e60d9$EPOUGA$1140100_2022091609485096255243399.xml";
//
// try(BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(fpath)),
// StandardCharsets.UTF_8) , 1024*1024*2)) {
// JSONObject json = XML.toJSONObject(reader);
// String jsonStr = json.toString(4);
// System.out.println(jsonStr);
// }catch(IOException fe){
//
// }
// try {
// Document doc = XMLFilePath2Doc(fileFullPath);
// getTraversalNodeList(doc);
// } catch (Exception e) {
// e.printStackTrace();
// }
}
/**
* XML String Document
* @param XMLString
* @return Document
*/
public static Document XMLString2Doc(String XMLString) throws Exception {
InputSource is = new InputSource(new StringReader(XMLString));
is.setEncoding(StandardCharsets.UTF_8.toString());
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
return dBuilder.parse(is);
}
/**
* XML Document
* @param fullFilePath
* @return
* @throws Exception
*/
public static Document XMLFilePath2Doc(String fullFilePath) throws Exception {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
return dBuilder.parse(fullFilePath);
}
/**
* Doc list
* @param doc
* @param getNodeList
*/
public static void getNodeList(Document doc, String getNodeList) {
doc.getDocumentElement().normalize();
String nm = doc.getDocumentElement().getNodeName();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList nList = doc.getElementsByTagName(getNodeList);
travNode(nList);
}
//노드 순회 메서드
public static void travNode (NodeList nodes) {
for (int i = 0; i < nodes.getLength(); i++) {
Node n = nodes.item(i);
if (n.getNodeType() == Node.ELEMENT_NODE) {
NodeList childNodes = n.getChildNodes();
int cnt = childNodes.getLength();
if (cnt == 1) {
System.out.printf("%s : %s%n", n.getNodeName(), n.getTextContent());
} else {
System.out.printf("--------[ " + n.getNodeName() + " ]--------%n");
}
if (cnt > 1) {
travNode(childNodes);
}
}
}
}
/**
*
* @param doc
*/
public static void getTraversalNodeList (Document doc) {
//Doc 순회
DocumentTraversal trav = (DocumentTraversal) doc;
DocFilter docFilter = new DocFilter("params");//조건에 따른 필터 처리
NodeIterator it = trav.createNodeIterator(doc.getDocumentElement(),
NodeFilter.SHOW_ELEMENT, docFilter, true);
for (Node n = it.nextNode(); n != null; n = it.nextNode()) {
int cnt = n.getChildNodes().getLength();
if (cnt == 1) {
System.out.printf("%s : %s%n", n.getNodeName(), n.getTextContent());
} else {
System.out.printf("--------[ " + n.getNodeName() + " ]--------%n");
}
}
}
//DocumentTraversal 필터
static class DocFilter implements NodeFilter {
String deptId = "";
public DocFilter (String deptId) {
this.deptId = deptId;
}
@Override
public short acceptNode(Node thisNode) {
if (thisNode.getNodeType() == Node.ELEMENT_NODE) {
Element e = (Element) thisNode;
String nodeName = e.getNodeName();
if (! "params".equals(this.deptId)) {
return NodeFilter.FILTER_REJECT;
}
}
return NodeFilter.FILTER_ACCEPT;// NodeFilter.FILTER_REJECT;
}
}
}

@ -0,0 +1,510 @@
package kr.xit.framework.biz.cmm.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import lombok.Getter;
import lombok.Setter;
/**
* <pre>
* interface
* XmlRootElement
* JAXBContext
* XmlAccessorType
* FIELD - (static transient ) XML
* NONE - XML .
* PROPERTY - getter/setter XML .
* PUBLIC_MEMBER - public getter/setter XML .
*
* comment / /
* / /
* </pre>
*/
@Getter
@Setter
@XmlRootElement(name = "dmndinfo")
@XmlAccessorType(XmlAccessType.FIELD)
public class NatlNewspaperXmlDto {
/**
* :
* PK : number(30) - YYYYMMDDHH24MISSFF+random(9)
*/
@XmlElement(name = "interface_seq_n")
private String interfaceSeqN;
/**
* :
* char(88)
* EC010008
*/
@XmlElement(name = "sys_gubun_c")
private String sysGubunC;
/**
* :
* varchar2(7)
* 1140100 / /
* ex) - 641000
*/
@XmlElement(name = "anc_code_v")
private String ancCodeV;
/**
* :
* char(3)
* 140:(-) / 180: / 140: (-)
*/
@XmlElement(name = "peti_gubun_c")
private String petiGubunC;
/**
* :
* varchar2(7)
* ()
*/
@XmlElement(name = "peti_anc_code_v")
private String petiAncCodeV;
/**
* :
* varchar2(16)
* ( ), null .
* ( )
*/
@XmlElement(name = "peti_no_c")
private String petiNoC;
/**
* :
* varchar2(16)
* ( ), null .
* ( )"
*/
@XmlElement(name = "civil_no_c")
private String civilNoC;
/**
* : /
* varchar2(128)
*/
@XmlElement(name = "peter_name_v")
private String peterNameV;
/**
* : /
* varchar2(7)
*/
@XmlElement(name = "zip_code_c")
private String zipCodeC;
/**
* : /
* varchar2(400)
*/
@XmlElement(name = "address_v")
private String addressV;
/**
*
* varchar2(64)
*/
@XmlElement(name = "email_v")
private String emailV;
/**
*
* varchar2(20)
*/
@XmlElement(name = "cel_no_v")
private String celNoV;
/**
*
* varchar2(20)
*/
@XmlElement(name = "tel_no_v")
private String telNoV;
/**
* : /
* varchar2(500)
*/
@XmlElement(name = "peti_title_v")
private String petiTitleV;
/**
* : /
* clob
*/
@XmlElement(name = "peti_reason_l")
private String petiReasonL;
/**
* : /
* char(1)
* Y = , N = (default N)
* Y ()
* N
*/
@XmlElement(name = "open_yn_c")
private String openYnC;
/**
* : /
* date : YYYYMMDDHH24MISS
*/
@XmlElement(name = "peti_reg_d")
private String petiRegD;
/**
* :
* char(1)
* Y = , N = (default)
*/
@XmlElement(name = "peti_reason_attach_yn_c")
private String petiReasonAttachYnC;
/**
* :
* number(10)
*/
@XmlElement(name = "peti_file_size_n")
private String petiFileSizeN;
//-------------------------------------------------------------
/**
* 1
* varchar2(2000)
*/
@XmlElement(name = "peti_file_path1_v")
private String petiFilePath1V;
/**
* 2
* varchar2(2000)
*/
@XmlElement(name = "peti_file_path2_v")
private String petiFilePath2V;
/**
* 3
* varchar2(2000)
*/
@XmlElement(name = "peti_file_path3_v")
private String petiFilePath3V;
/**
* 4
* varchar2(2000)
*/
@XmlElement(name = "peti_file_path4_v")
private String petiFilePath4V;
/**
* 5
* varchar2(2000)
*/
@XmlElement(name = "peti_file_path5_v")
private String petiFilePath5V;
//-----------------------------------------------------------------------------
/*
@Getter
@Setter
@XmlRootElement(name="petiFilePaths")
private static class PetiFilePaths{
private List<PetiFilePath> petiFilePath;
@Getter
@Setter
@XmlRootElement(name="petiFilePath")
public static class PetiFilePath {
private String petiFilePath;
}
}
*/
/**
*
* date
*/
@XmlElement(name = "anc_reg_d")
private String ancRegD;
/**
*
* varchar2(4000)
*/
@XmlElement(name = "more_again_v")
private String moreAgainV;
//------------------------------------------------------------------------------
/**
* 1
* char(8)
*/
@XmlElement(name = "satisfy_c")
private String satisfyC;
/**
* 2
* char(8)
*/
@XmlElement(name = "satisfy2_c")
private String satisfy2C;
/**
* 3
* char(8)
*/
@XmlElement(name = "satisfy3_c")
private String satisfy3C;
//------------------------------------------------------------------------------
/**
*
* date
*/
@XmlElement(name = "satisfy_reg_d")
private String satisfyRegD;
/**
* :
* date
* sysdate(YYYYMMDDHH24MISS)
*/
@XmlElement(name = "reg_d")
private String regD;
/**
* :
* char(1)
* 1: / 2: / 1:
*/
@XmlElement(name = "send_yn_c")
private String sendYnC;
/**
*
* date : YYYYMMDDHH24MISS
*/
@XmlElement(name = "send_d")
private String sendD;
/**
* :
* date
* interface DB->XML sysdate(YYYYMMDDHH24MISS)
*/
@XmlElement(name = "apply_d")
private String applyD;
/**
* :
* char(1)
* :Y OR N (default:N , DB Y )
*/
@XmlElement(name = "apply_gubun_c")
private String applyGubunC;
//------------------------------------------------------------------------------------
/**
* 1:
* varchar2(400)
* 0 / / 0
*/
@XmlElement(name = "pcd_gubun_v")
private String pcdGubunV;
/**
* 2:
* varchar2(400)
*/
@XmlElement(name = "pcd_gubun2_v")
private String pcdGubun2V;
/**
* 3:
* varchar2(400)
*/
@XmlElement(name = "pcd_gubun3_v")
private String pcdGubun3V;
//-------------------------------------------------------------------------------------
/**
* xml :
* varchar2(10)
*/
@XmlElement(name = "ifid")
private String ifid;
/**
* :
* varchar2(7)
*
*/
@XmlElement(name = "srcorgcd")
private String srcorgcd;
/**
* :
* varchar2(7)
* insert 1140100
*/
@XmlElement(name = "tgtorgcd")
private String tgtorgcd;
//----------------------------------------------------------------------------------------------------
// 결과(응답) 처리
//----------------------------------------------------------------------------------------------------
/**
* :
* varchar2(512)
*
*/
@XmlElement(name = "civil_gist_v")
private String civilGistV;
/**
* :
* clob
*
*/
@XmlElement(name = "civil_abstract_l")
private String civilAbstractL;
/**
* :
* varchar2(7)
*/
@XmlElement(name = "pcd_dept_v")
private String pcdDeptV;
/**
* :
* varchar2(50)
*/
@XmlElement(name = "pcd_dept_nm_v")
private String pcdDeptNmV;
/**
* :
* varchar2(50)
*/
@XmlElement(name = "duty_id_v")
private String dutyIdV;
/**
* :
* varchar2(64)
*/
@XmlElement(name = "pcd_email_v")
private String pcdEmailV;
/**
* :
* varchar2(20)
*/
@XmlElement(name = "pcd_tel_v")
private String pcdTelV;
/**
* :
* clob
*/
@XmlElement(name = "pcd_rst_cont_l")
private String pcdRstContL;
/**
* :
* varchar2(14) : YYYYMMDDHH24MISS
*/
@XmlElement(name = "do_reg_d")
private String doRegD;
/**
* :
* char(1)
* Y = , N = (default)
*/
@XmlElement(name = "pcd_rst_cont_attach_yn_c")
private String pcdRstContAttachYnC;
/**
*
* number(10)
*/
@XmlElement(name = "pcd_file_size_n")
private String pcdFileSizeN;
//------------------------------------------------------------------------
/**
* 1
* varchar2(2000)
*/
@XmlElement(name = "pcd_file_path1_v")
private String pcdFilePath1V;
/**
* 2
* varchar2(2000)
*/
@XmlElement(name = "pcd_file_path2_v")
private String pcdFilePath2V;
/**
* 3
* varchar2(2000)
*/
@XmlElement(name = "pcd_file_path3_v")
private String pcdFilePath3V;
/**
* 4
* varchar2(2000)
*/
@XmlElement(name = "pcd_file_path4_v")
private String pcdFilePath4V;
/**
* 5
* varchar2(2000)
*/
@XmlElement(name = "pcd_file_path5_v")
private String pcdFilePath5V;
//----------------------------------------------------------------------
/**
* :
* varchar2(7)
* ex) 6410000
*/
@XmlElement(name = "pcd_anc_code_v")
private String pcdAncCodeV;
/**
*
* number(5)
*/
@XmlElement(name = "peti_proc_dur_n")
private String petiProcDurN;
/**
*
* date
*/
@XmlElement(name = "peti_end_d")
private String petiEndD;
}
Loading…
Cancel
Save