//审批基本信息
public static Map<String, String> writeBasicToMap(Class gcprojcheckupClas,String fileDirPath,Map<String, Object> map) throws Exception{
Document doc = DocumentHelper.createDocument();
//增加根节点
Element root = doc.addElement("GCData");
//获取类名
String className= StrUtils.getClassnameByPackage(gcprojcheckupClas.getName());
//增加子元素
Element GCProjCheckup = root.addElement(className);//不需要小写
//增加结点
Field [] gcprojcheckupFields = gcprojcheckupClas.getDeclaredFields();
for (int i = 0; i < gcprojcheckupFields.length; i++) {
System.out.println(gcprojcheckupFields[i].getName());
String key = gcprojcheckupFields[i].getName();
Element element = GCProjCheckup.addElement(key);//标签和属性命名一致
element.setText(map.get(key.toLowerCase())==null ? "": (String)map.get(key.toLowerCase()));
}
// //特殊处理LeaderGXUniCode_OrganOfLeader
// Element element = root.addElement("LeaderGXUniCode_OrganOfLeader");
// element.addText(map.get("LGOL")==null? "" :(String)map.get("LGOL"));
//实例化输出格式对象
OutputFormat format = OutputFormat.createPrettyPrint();
//设置输出编码
format.setEncoding("UTF-8");
//创建需要写入的File对象
String fileName = NameUtils.getFileName(map.get("unitid")==null?"":map.get("unitid").toString(),map.get("unitname")==null?"":map.get("unitname").toString(), StrUtils.getClassnameByPackage(gcprojcheckupClas.getName()));
String finalPath=CommonPath.INROOTPATH+fileDirPath + File.separator+ fileName+".xml";
System.out.println(finalPath);
File file = new File(finalPath);
//生成XMLWriter对象,构造函数中的参数为需要输出的文件流和格式
FileOutputStream fileoutputstream = new FileOutputStream(file);
XMLWriter writer = new XMLWriter(fileoutputstream, format);
//开始写入,write方法中包含上面创建的Document对象
writer.write(doc);
if(writer!=null) writer.close();
if(fileoutputstream!=null) fileoutputstream.close();
Map<String, String> backMap = new HashMap<String, String>();
backMap.put("filename", fileName);
FileInputStream inputStream = new FileInputStream(finalPath);
String md5 = DigestUtils.md5Hex(inputStream);
if(inputStream!=null) {inputStream.close();};
backMap.put("md5",md5);
return backMap;
}