Commit 8a6d0627 authored by dahai's avatar dahai

上传生成XML

parent 85a84c47
......@@ -186,10 +186,15 @@ public class ExportXMLApi {
newFilesEntity.setVersionCode(filesEntity.getVersionCode());
newFilesEntity.setRecordNumber((long)preproPersonEntities.size());
long l = newFilesService.saveNewFiles(newFilesEntity);
newFilesEntity.setNewFileName("ZAGL_ZZJH_"+filesEntity.getDwdm()+simpleDateFormat.format(new Date())+""+newFilesEntity.getId());
String files_seq =autoGenericCode(newFilesEntity.getId()+"",4) ;
newFilesEntity.setNewFileName("ZAGL_ZZJH_"+filesEntity.getDwdm()+simpleDateFormat.format(new Date())+preproPersonEntities.get(0).getCardTypeId()+files_seq);
newFilesService.updateNewFileName(newFilesEntity);
Element SJBBH=PACKAGEHEAD.addElement("SJBBH");
SJBBH.setText(filesEntity.getDwdm()+simpleDateFormat.format(new Date())+preproPersonEntities.get(0).getCardTypeId()+files_seq);
int NO=1;
long cardType =0;
for (PreproPersonEntity preproPersonEntity : preproPersonEntities) {
Element RECORD = DATA.addElement("RECORD");
RECORD.addAttribute("no", NO+"");
......@@ -242,16 +247,16 @@ public class ExportXMLApi {
SJR_TXDZ.setText(replaceNullString(preproPersonEntity.getSjrTxdz()));
NO++;
preproPersonEntity.setNewFileId(newFilesEntity.getId());
cardType = preproPersonEntity.getCardTypeId();
}
preproPersonService.updatePreproPerson_NewFileName(preproPersonEntities);
String files_seq = newFilesEntity.getId()+"";
try {
FileOutputStream fos = new FileOutputStream("D:\\XML\\"+"ZAGL_ZZJH_"+filesEntity.getDwdm() + simpleDateFormat.format(new Date())+"-"+files_seq+ ".xml");
FileOutputStream fos = new FileOutputStream("D:\\XML\\"+"ZAGL_ZZJH_"+filesEntity.getDwdm() + simpleDateFormat.format(new Date())+cardType+files_seq+ ".xml");
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
OutputFormat of = new OutputFormat();
of.setEncoding("UTF-8");
of.setIndent(true);
of.setIndent(" ");
of.setNewlines(true);
of.setNewLineAfterDeclaration(false);
XMLWriter writer = new XMLWriter(osw, of);
......@@ -260,12 +265,8 @@ public class ExportXMLApi {
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("XML文件生成成功..." + new Date());
// return document;
return "D:\\XML\\" +"ZAGL_ZZJH_"+filesEntity.getDwdm()+ simpleDateFormat.format(new Date())+"-"+files_seq+ ".xml";
return "D:\\XML\\" +"ZAGL_ZZJH_"+filesEntity.getDwdm()+ simpleDateFormat.format(new Date())+cardType+files_seq+ ".xml";
}
/**
......@@ -288,4 +289,20 @@ public class ExportXMLApi {
return str.replace("-", "");
}
/**
* 不够位数的在前面补0,保留code的长度位数字
* @param code
* @return
*/
private String autoGenericCode(String code, int num) {
String result = "";
// 保留num的位数
// 0 代表前面补充0
// num 代表长度为4
// d 代表参数为正数型
result = String.format("%0" + num + "d", Integer.parseInt(code) + 1);
return result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment