标签:
http://zhidao.baidu.com/link?url=78anKNC_EkjKqIJnqW9pjpWWk0BpKwbEAYwue5If0_HtWs4oXUf_hGO_JyDpGLe2fUS_j71aBTC_LBvSRYLAka
File file= new File(dirPath);//不需要/
File[] mailFiles = file.listFiles();
if (mailFiles!=null || mailFiles.length>0) {
for (int i = 0; i < mailFiles.length; i++) {
if (mailFiles[i].isDirectory()) {
System.out.println("===="+mailFiles[i].getAbsolutePath());
readFeedBack(clazz,mailFiles[i].getAbsolutePath(),connection);
}else {
String fileFullName = mailFiles[i].getName();
if (mailFiles[i].isFile()
&& !"envelope.xml".equals(fileFullName)
&& !"controllers.xml".equals(fileFullName)
&& !"services.xml".equals(fileFullName)
&& !"units.xml".equals(fileFullName)
&& !".done".equals(fileFullName)
&& !".log".equals(fileFullName)
&& !"info.txt".equals(fileFullName)
&& !".svn".equals(fileFullName)
) {
String prefix = fileFullName.substring(fileFullName.lastIndexOf(".")+1);
if (fileFullName!=null && "xml".equals(prefix)) {
SAXReader reader = new SAXReader();
System.out.println(mailFiles[i]);
System.out.println(mailFiles[i].getAbsoluteFile());
// Document document = reader.read("D:\\books.xml");
System.out.println("mailFiles[i].getAbsoluteFile()="+mailFiles[i].getAbsoluteFile());
System.out.println("mailFiles[i].getAbsolutePath()="+mailFiles[i].getAbsolutePath());
System.out.println("mailFiles[i].getName()="+mailFiles[i].getName());
System.out.println("mailFiles[i].getParentFile()="+mailFiles[i].getParentFile());
System.out.println("mailFiles[i].getParentFile().getName="+mailFiles[i].getParentFile().getName());
System.out.println("mailFiles[i].getParent()"+mailFiles[i].getParent());
System.out.println("mailFiles[i].getPath()="+mailFiles[i].getPath());
//Document document = reader.read(mailFiles[i].getAbsoluteFile());
Document document = null;
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(mailFiles[i].getAbsoluteFile());
document = reader.read(fileInputStream);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Element root = document.getRootElement();
// List<Element> childElements = root.elements();
List<Element> childElements = root.elements( StrUtils.getClassnameByPackage(clazz.getName()));
//GCProjReturn gcprojreturn = new GCProjReturn();
for (Element child : childElements) {
//child.getText();
// System.out.println("id: " + child.attributeValue("id"));
// System.out.println("title" + child.elementText("title"));
//增加结点
/* Field [] fields = clazz.getDeclaredFields();
for (int j = 0; j < fields.length; j++) {
//System.out.println(fields[j].getName());
System.out.println(child.elementText(fields[j].getName())==null?"你好":child.elementText(fields[j].getName()));
FeedBackService feedBackService = new FeedBackService(connection);
feedBackService.update("","","1");
}*/
/**
* 0 null
*
* 发送完 ==》3
*
* 如果受理成功 3-》1 失败 3-》0
*
* 如果审批审批成功》3--》1
* 失败
* 如果他受理的是1 即受理的gcinfotype!=null ->== GCAplProj 3->0
* 如果受理是 0或null 即受理受理的gcinfotype==null -> 3->0
*
*
*
*
*/
//因为不需要记录反馈的其他信息
String gcprojissucceed = child.elementText("GCProjIsSucceed");
String specsysprojcodeid = child.elementText("SpecSysProjCodeId");
/*String gcinfotype = child.elementText("GCInfoType");
if (gcprojissucceed != null && specsysprojcodeid != null) {//反馈成功
String flag = null;
if("GCAplProj".equals(gcinfotype)){//受理 --》4
flag = "4";
}
if("GCProjCheckup".equals(gcinfotype)){//审批-->11
flag = "11";
}
if("GCProjGetWrit".equals(gcinfotype)){//取件
}
if(gcinfotype==null || "".equals(gcinfotype)){//沒有传受理信息,或传的受理适配器没反应过来,审批发送失败
flag = "11";
}
if(flag !=null){
FeedBackService feedBackService = new FeedBackService(connection);
feedBackService.update(specsysprojcodeid,
flag,gcprojissucceed);
}
}
*/
/*if(child.getName().equalsIgnoreCase("SpecSysProjCodeId")){//部门业务系统办件号
gcprojreturn.setSpecSysProjCodeId(child.getText());
}
if(child.getName().equalsIgnoreCase("GCInfoType")){//信息类型
gcprojreturn.setGCInfoType(child.getText());
}
if(child.getName().equalsIgnoreCase("GCProjIsSucceed")){//是否接受成功 1 0
gcprojreturn.setGCProjIsSucceed(child.getText());
}
if(child.getName().equalsIgnoreCase("GCProjGetTime")){//接收时间 400
gcprojreturn.setGCProjGetTime(child.getText());
}*/
}
try {
if (fileInputStream !=null ) fileInputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//这里应该执行更新字段状态 1--》2 2--》
//updateExchangeStatus();
//Object[] args=new Object[]{gcprojreturn.getSpecSysProjCodeId(),gcprojreturn.getGCInfoType(),gcprojreturn.getGCProjIsSucceed(),gcprojreturn.getGCProjGetTime()};
//FeedBackDao newBackDao
//然后进行备份
//System.out.println("路径:"+mailFiles[i].getAbsoluteFile().toString());
//System.out.println("目标:"+mailFiles[i].getParentFile().getName());
NameUtils nameutils= new NameUtils();
nameutils.backUpFeedBackFile(mailFiles[i].getAbsoluteFile().toString(), mailFiles[i].getParentFile().getName());
nameutils.deleteFile(mailFiles[i].getParent());
}
}
}
}
}
标签:
原文地址:http://www.cnblogs.com/zshboke-2015/p/4981500.html