xml导出

   采用dom4j解析技术实现xml的解析,下面代码为功能实现。

package com.css.action;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.css.bean.VXfSfrDj;
import com.css.business.QueryBusiness;
import com.css.common.action.BaseAction;
import com.css.common.util.DateUtils;
import com.css.common.util.QueryUtils;
import com.css.common.util.StringUtils;
import com.css.common.util.dicache.Authority;
import com.css.dto.TXfSfrDTO;
import com.css.dto.TXtYhDTO;
import com.css.dto.VXfZhDTO;
import com.css.service.SfWtService;
import com.css.service.ZhQueryService;
import com.css.util.ConstantParam;
import com.css.bean.TXtJg;
import com.css.bean.VXfZh;

/**
* @function 上访人信息XML文件导出
* @description 从数据库导出数据生成XML文件
* @version 1.0
* @author liangbo
* @modify by liangbo 新增xml导出数据头文件从系统配置读取数据功能
* @modify by liangbo 新增交办地区交办单位批量设置功能
*/
@Controller("sfrXxXMLAction")
@Scope("prototype")
public class SfrXxXMLAction extends BaseAction {
@Resource
private ZhQueryService zhQueryService;
@Resource
private QueryBusiness queryBusiness;
@Resource
private SfWtService sfWtService;
private String relation;
private VXfZhDTO vxfZhDTO; // 综合查询DTO
private List<VXfZhDTO> excelList;
private List<TXfSfrDTO> sfrList;// 上访人列表
//liangbo 30/05/2012
private String thdqid;
private String thdwid;

public List<TXfSfrDTO> getSfrList() {
  return sfrList;
}

public void setSfrList(List<TXfSfrDTO> sfrList) {
  this.sfrList = sfrList;
}

private InputStream istream;// 下载输入流
private String downloadFileName = "信访人信访问题信息汇总(" + DateUtils.formatDate2Str(DateUtils.FORMAT_YYYYMMDD_HHMMSS_ZN, new Date()) + ")";
private String[] checkedIds;
private String[] curIds;

public InputStream getIstream() {
  return istream;
}

public void setIstream(InputStream istream) {
  this.istream = istream;
}

public String[] getCheckedIds() {
  return checkedIds;
}

public void setCheckedIds(String[] checkedIds) {
  this.checkedIds = checkedIds;
}


public String[] getCurIds() {
  return curIds;
}

public void setCurIds(String[] curIds) {
  this.curIds = curIds;
}

public String getDownloadFileName() {
  try {
   downloadFileName = new String(downloadFileName.getBytes(), "ISO8859-1");
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  }
  return downloadFileName;
}

public String download() throws Exception {
  Set<String> idSet = (Set<String>) ServletActionContext.getRequest().getSession().getAttribute("idSet");
  if (idSet != null) {
   if (curIds != null && curIds.length != 0) {
    for (String s : curIds) {
     if (idSet.contains(s)) {
      idSet.remove(s);
     }
    }
   }
   if (checkedIds != null && checkedIds.length != 0) {
    for (String s : checkedIds) {
     idSet.add(s);
    }
   }
   int i = 0;
   String[] temp = new String[idSet.size()];
   for (String string : idSet) {
    temp[i] = string;
    i++;
   }
   checkedIds = temp;
  }
  Map<VXfZhDTO, Set<VXfSfrDj>> sfrwtMap = null;
  if (checkedIds != null && checkedIds.length != 0) {
   sfrwtMap = zhQueryService.getsfrsfwt(checkedIds);
  }
  else
  {
   addActionMessage("请选择需要导出的数据!!");
   return SUCCESS;
  }
 
       //导出数据前对交办单位交办地区进行判重判空
  Set<VXfZhDTO> keySet = sfrwtMap.keySet();
  List dqdwList = checkDqDw(keySet);
  if(dqdwList == null || dqdwList.size() <=0)
  {
   addActionMessage("导出失败!");
   return SUCCESS;
  }

  if (sfrwtMap.size() != 0) {
   istream = new ByteArrayInputStream(createXML(sfrwtMap,dqdwList));
  }
  return "download";
}
//批量设置数据
public void thSet() throws Exception
{
  PrintWriter out = null;
  ServletActionContext.getResponse().setContentType("text/html;charset=utf-8");
  out = ServletActionContext.getResponse().getWriter();
 
  Set<String> idSet = (Set<String>) ServletActionContext.getRequest().getSession().getAttribute("idSet");
 
  if(thdqid == null || thdqid.equals(""))
  {
   out.print("请录入交办地区!");
   return ;
  }
  if(thdwid == null || thdwid.equals(""))
  {
   out.print("请录入交办单位!");
   return;
  }
 
  if (idSet != null) {
   if (curIds != null && curIds.length != 0) {
    for (String s : curIds) {
     if (idSet.contains(s)) {
      idSet.remove(s);
     }
    }
   }
   if (checkedIds != null && checkedIds.length != 0) {
    for (String s : checkedIds) {
     idSet.add(s);
    }
   }
   int i = 0;
   String[] temp = new String[idSet.size()];
   for (String string : idSet) {
    temp[i] = string;
    i++;
   }
   checkedIds = temp;
  }
  List<VXfZh> zhList = null;
  if (checkedIds != null && checkedIds.length != 0) {
   zhList = zhQueryService.getlList(checkedIds);
  }
  else
  {
   out.print("请选择需要设置的数据!");
   return;
  }
 
  if(zhList != null || zhList.size() > 0)
  {
   for(VXfZh vXfZh : zhList)
   {
    sfWtService.updateTh(vXfZh.getWtid(), thdqid, thdwid);
   }
  }
  out.print("设置成功!");
  return;
}


public byte[] createXML(Map<VXfZhDTO, Set<VXfSfrDj>> sfrwtMap, List dqdwList) {
  //获得当前会话的用户
  TXtYhDTO yhDTO = (TXtYhDTO)session.get(ConstantParam.USER_SESSION_KEY);
  //根据用户获取系统组织配置
  TXtJg txtJg = zhQueryService.findJg(yhDTO.getId());
  if(txtJg == null)
  {
   return null;
  }
  byte[] xmlString = null;
  Document document = DocumentHelper.createDocument();
  Element element = document.addElement("gbsfss");
  Element headElement = element.addElement("head");
  headElement.addElement("function").addText(ConstantParam.XML_BiaoB);
  headElement.addElement("description").addText(ConstantParam.XML_BiaoBName);
  headElement.addElement("fromxzqh").addText(txtJg.getXzqh());
  headElement.addElement("fromzfbm").addText(txtJg.getJgjb());
  headElement.addElement("toxzqh").addText((String) dqdwList.get(0));
  headElement.addElement("tozfbm").addText((String) dqdwList.get(1));
  headElement.addElement("date").addText(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
  Element resourceElement = element.addElement("resource");
  Set<VXfZhDTO> keySet = sfrwtMap.keySet();
  for (VXfZhDTO vXfZh : keySet) {
   Element listElement = resourceElement.addElement("list");
   Element sfwtElement = listElement.addElement("xfwt");
   addElementText(sfwtElement.addElement("id"), vXfZh.getWtid());// 问题主键
   addElementText(sfwtElement.addElement("sfly"), vXfZh.getSflx()); // 上访类型
   addElementText(sfwtElement.addElement("lfsj"), vXfZh.getLfsj() == null ? null : getDatetoString(vXfZh.getLfsj()));// 信访时间
   addElementText(sfwtElement.addElement("lxxs"), vXfZh.getLxxs());//  初信初访形式
   addElementText(sfwtElement.addElement("wtfsd"), vXfZh.getWtfsd());// 上访问题发生地
   addElementText(sfwtElement.addElement("wtfsdxz"), vXfZh.getWtfsdxz());// 信访问题发生地详址
   addElementText(sfwtElement.addElement("lxcs"), vXfZh.getLxcs());// 重复访来信次数
   addElementText(sfwtElement.addElement("lfcs"), vXfZh.getLfcs());// 重复访来访次数
   addElementText(sfwtElement.addElement("jjzcf"), vXfZh.getJjzcf());// 进京正常访
   addElementText(sfwtElement.addElement("jjfzcf"), vXfZh.getJjfzcf());//  进京非正常访
   addElementText(sfwtElement.addElement("yjfcs"), vXfZh.getYjfcs());// 越级访次数
   addElementText(sfwtElement.addElement("sjbmjsfwt"), vXfZh.getSjbmjsfwt());// 涉及部门及上访问题
   addElementText(sfwtElement.addElement("xfsq"), vXfZh.getXfsq());// 信访诉求
   addElementText(sfwtElement.addElement("jyaq"), vXfZh.getJyaq());// 简要案情
   addElementText(sfwtElement.addElement("sfsksfl"), vXfZh.getSfsksfl());// 是否三跨三分离
   addElementText(sfwtElement.addElement("ajfssj"), vXfZh.getAjfssj() == null ? null : getDatetoString(vXfZh.getAjfssj()));// 案件发生时间
   addElementText(sfwtElement.addElement("jjzcfcs"), vXfZh.getJjzcfcs());// 进京正常访次数
   addElementText(sfwtElement.addElement("jjfzcfcs"), vXfZh.getJjzcfcs());// 进京正常访次数
   addElementText(sfwtElement.addElement("djr"), vXfZh.getDjr());//登记人
   addElementText(sfwtElement.addElement("djbm"), vXfZh.getDjbm());// 登记部门
   addElementText(sfwtElement.addElement("ah"), vXfZh.getAh());// 案件编号
   addElementText(sfwtElement.addElement("xfly"), vXfZh.getXfly());// 信访来源
   addElementText(sfwtElement.addElement("thdqid"), vXfZh.getThdqid());// 交办地区id
   addElementText(sfwtElement.addElement("thdwid"), vXfZh.getThdwid());// 交办单位ID
   addElementText(sfwtElement.addElement("ldcs"), vXfZh.getLdcs());// 信访来源
   addElementText(sfwtElement.addElement("czcs"), vXfZh.getCzcs());// 信访来源
   addElementText(sfwtElement.addElement("wsxfcs"), vXfZh.getWsxfcs());// 信访来源
   addElementText(sfwtElement.addElement("yjfcs"), vXfZh.getYjfcs());// 信访来源
   addElementText(sfwtElement.addElement("xfsqqt"),vXfZh.getXfsqqt());// 信访来
   //addElementText(sfwtElement.addElement("sjdwxzqh"), vXfZh.getsjd);// 信访来源
   //addElementText(sfwtElement.addElement("sjdwxzid"), vXfZh.);// 信访来源
   addElementText(sfwtElement.addElement("yxbz"), vXfZh.getYxbz());// 有效标志
   addElementText(sfwtElement.addElement("wtzt"), vXfZh.getWtzt());// 问题状态
   addElementText(sfwtElement.addElement("cjsj"), vXfZh.getCjsj() == null ? null : getDatetoString(vXfZh.getCjsj()));// 采集时间
   addElementText(sfwtElement.addElement("gxsj"), vXfZh.getGxsj() == null ? null : getDatetoString(vXfZh.getGxsj()));// 有效标志

   Set<VXfSfrDj> sfrDjSet = sfrwtMap.get(vXfZh);
  
   for(VXfSfrDj sfrDj : sfrDjSet){
    Element sfrElement = listElement.addElement("xfr");
    addElementText(sfrElement.addElement("id"), sfrDj.getId());// 人员id
    addElementText(sfrElement.addElement("xm"), sfrDj.getXm()); // 姓名
    addElementText(sfrElement.addElement("xb"), sfrDj.getXb());// 性别
    addElementText(sfrElement.addElement("mz"), sfrDj.getMz());//民族
    addElementText(sfrElement.addElement("csrq"), sfrDj.getCsrq() == null ? null : getDatetoString(sfrDj.getCsrq()));// 出生日期
    addElementText(sfrElement.addElement("hjd"), sfrDj.getHjd());//户籍地
    addElementText(sfrElement.addElement("xzd"), sfrDj.getXzd());// 现住地
    addElementText(sfrElement.addElement("zjlx"), sfrDj.getZjlx());// 证件类型
    addElementText(sfrElement.addElement("zjhm"), sfrDj.getZjhm());// 证件号码
    addElementText(sfrElement.addElement("yddh"), sfrDj.getYddh());// 移动电话
    addElementText(sfrElement.addElement("gddh"), sfrDj.getGddh());// 固定电话
    addElementText(sfrElement.addElement("mqdx"), sfrDj.getMqdx());// 目前动向
    addElementText(sfrElement.addElement("yyadsrgx"), sfrDj.getYyadsrgx());// 与原案当事人关系
    addElementText(sfrElement.addElement("txdz"), sfrDj.getTxdz());// 通讯地址
    addElementText(sfrElement.addElement("yzbm"), sfrDj.getYzbm());// 邮政编码
    addElementText(sfrElement.addElement("xzdxz"), sfrDj.getXzdxz());// 现住地详址
    addElementText(sfrElement.addElement("hjdxz"), sfrDj.getHjdxz());// 户籍地详址
    addElementText(sfrElement.addElement("gddhqh"), sfrDj.getGddhqh());//固定电话区号
    addElementText(sfrElement.addElement("zy"), sfrDj.getZy());//职业
    addElementText(sfrElement.addElement("djr"), sfrDj.getDjr());// 登记人
    addElementText(sfrElement.addElement("djbm"), sfrDj.getDjbm());// 登记部门
    addElementText(sfrElement.addElement("xfly"), sfrDj.getXfly());// 信访来源
    addElementText(sfrElement.addElement("cym"), sfrDj.getCym());// 信访来源
    addElementText(sfrElement.addElement("zjlxqt"), sfrDj.getZjlxqt());// 信访来源
    addElementText(sfrElement.addElement("gzdw"), sfrDj.getGzdw());// 信访来源
    addElementText(sfrElement.addElement("zw"), sfrDj.getZw());// 信访来源
    addElementText(sfrElement.addElement("whcd"), sfrDj.getWhcd());// 信访来源
    addElementText(sfrElement.addElement("zzmm"), sfrDj.getZzmm());// 信访来源
    addElementText(sfrElement.addElement("hyzk"), sfrDj.getHyzk());// 信访来源
    addElementText(sfrElement.addElement("dzyx"), sfrDj.getDzyx());// 信访来源
    //addElementText(sfrElement.addElement("xmpy"), sfrDj.getXm());// 信访来源
    //addElementText(sfrElement.addElement("pyzt"), sfrDj.getp);// 信访来源
    //addElementText(sfrElement.addElement("qtqk"), sfrDj.getqtq);// 信访来源
    addElementText(sfrElement.addElement("zc"), sfrDj.getZc());// 信访来源
    //addElementText(sfrElement.addElement("finaldate"), sfrDj.getf);// 信访来源
    addElementText(sfrElement.addElement("zjqsxm"), sfrDj.getZjqsxm());// 信访来源
    addElementText(sfrElement.addElement("zjqszz"), sfrDj.getZjqszz());// 信访来源
    addElementText(sfrElement.addElement("zjqsdh"), sfrDj.getZjqsdh());// 信访来源
    addElementText(sfrElement.addElement("zjqsgx"), sfrDj.getZjqsgx());// 信访来源
    addElementText(sfrElement.addElement("zjljddz"), sfrDj.getZjljddz());// 信访来源
    addElementText(sfrElement.addElement("zjljdlxfs"), sfrDj.getZjljdlxfs());// 信访来源
    addElementText(sfrElement.addElement("zjwgdwmc"), sfrDj.getZjwgdwmc());// 信访来源
    addElementText(sfrElement.addElement("zjwgdwdz"), sfrDj.getZjwgdwdz());// 信访来源
    addElementText(sfrElement.addElement("zjwgdwlxfs"), sfrDj.getZjwgdwlxfs());// 信访来源
   // addElementText(sfrElement.addElement("zjxzqt"), sfrDj.zjxz);// 信访来源
    addElementText(sfrElement.addElement("yxbz"), sfrDj.getYxbz());// 有效标志
    addElementText(sfrElement.addElement("cjsj"), sfrDj.getCjsj() == null ? null : getDatetoString(sfrDj.getCjsj()));// 有效标志
    addElementText(sfrElement.addElement("gxsj"), sfrDj.getGxsj() == null ? null : getDatetoString(sfrDj.getGxsj()));// 采集时间

   }
  }
  // 内存方式,不通过文件.
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  try {
   XMLWriter output = new XMLWriter(os, new OutputFormat("", true, "UTF-8"));
   output.write(document);
  } catch (Exception e) {
   e.printStackTrace();
   return null;
  }
  xmlString = os.toByteArray();
  return xmlString;
}

public void addElementText(Element element, String text) {
  if (text != null) {
   element.addText(text);
  }
}
//进行判重判空,成功后返回交办地区交办单位List用于header的toxzqh和tozfbm元素设置
public List checkDqDw(Set<VXfZhDTO> keySet)
{
  List dqdw = new ArrayList();
  for(VXfZhDTO vxfzh : keySet){
   if(vxfzh != null){
    if(vxfzh.getThdqid() == null || vxfzh.getThdqid().equals(""))
    {
     addActionMessage("交办地区不能为空,请设置后重新导出!");
     return null;
    }
    if(vxfzh.getThdwid() == null || vxfzh.getThdwid().equals(""))
    {
     addActionMessage("交办单位不能为空,请设置后重新导出!");
     return null;
    }
   
    //找到第一个交办地区交办单位不为空的进行判重
    String dq = vxfzh.getThdqid();
    String dw = vxfzh.getThdwid();
   
    for(VXfZhDTO zh : keySet)
    {
     if(zh != null)
     {
      if(!(dq.equals(zh.getThdqid())))
      {
       addActionMessage("交办地区不一致,请检查设置后重新导出!");
       return null;
      }
      if(!(dw.equals(zh.getThdwid())))
      {
       addActionMessage("交办单位不一致,请检查设置后重新导出!");
       return null;
      }
     }
    }
    dqdw.add(dq);
    dqdw.add(dw);
   }
 
  }
 
  return dqdw;
}

public Map<VXfZhDTO, Set<VXfSfrDj>> getDownloadFileMap() throws Exception {
  vxfZhDTO = (VXfZhDTO) session.get("vxfZhDTO");
  Map<VXfZhDTO, Set<VXfSfrDj>> sfrwtMap = new HashMap<VXfZhDTO, Set<VXfSfrDj>>();
  TXtYhDTO yhDTO = (TXtYhDTO) session.get(ConstantParam.USER_SESSION_KEY);
  StringBuilder where = new StringBuilder(ConstantParam.BYTJ);
  if (vxfZhDTO != null) {
   relation = QueryUtils.getSQL(vxfZhDTO, yhDTO, true, null);
  }
  if (StringUtils.isNotEmpty(relation)) {
   where.append(ConstantParam.BYTJ_AND).append(relation);
  }
  where.append(Authority.newInstance().getRelation(yhDTO));
  List<?> excelCountList = queryBusiness.getDistinctZh(where.toString());
  if (excelCountList != null && excelCountList.size() > 0) {
   Map<String, String> dataMap = StringUtils.listConvertMap(excelCountList);
   StringBuffer sb = new StringBuffer();
   for (Map.Entry<String, String> me : dataMap.entrySet()) {
    if (!"".equals(me.getKey())) {
     sb.append(" wtid = '" + me.getKey() + "' OR ");
    }
   }
   sb.delete(sb.lastIndexOf("OR"), sb.length());
   excelList = queryBusiness.queryExcelPage(sb.toString() + " ORDER BY lfsj DESC,wtid");
   List<VXfZhDTO> delList = new ArrayList<VXfZhDTO>();
   String id = "";
   String tempId = "";
   String clfsStr = "";
   String jzsjStr = "";
   String pzsjStr = "";
   for (int index = 0; excelList != null && excelList != null && index < excelList.size(); index++) {
    VXfZhDTO vxfZhDTO = excelList.get(index);
    id = vxfZhDTO.getWtid();
    if (id.equals(tempId)) {
     if (vxfZhDTO.getClfsStr() == null || "".equals(vxfZhDTO.getClfsStr())) {
      vxfZhDTO.setClfsStr("\r\n" + clfsStr);
     } else {
      vxfZhDTO.setClfsStr(vxfZhDTO.getClfsStr() + "\r\n" + clfsStr);
     }
     if (vxfZhDTO.getJzsjStr() == null || "".equals(vxfZhDTO.getJzsjStr())) {
      vxfZhDTO.setJzsjStr("\r\n" + jzsjStr);
     } else {
      vxfZhDTO.setJzsjStr(vxfZhDTO.getJzsjStr() + "\r\n" + jzsjStr);
     }
     if (vxfZhDTO.getPzychjzsjStr() == null || "".equals(vxfZhDTO.getPzychjzsjStr())) {
      vxfZhDTO.setPzychjzsjStr("\r\n" + pzsjStr);
     } else {
      vxfZhDTO.setPzychjzsjStr(vxfZhDTO.getPzychjzsjStr() + "\r\n" + pzsjStr);
     }
     delList.add(excelList.get(index - 1));
    }
    clfsStr = vxfZhDTO.getClfsStr();
    jzsjStr = vxfZhDTO.getJzsjStr();
    pzsjStr = vxfZhDTO.getPzychjzsjStr();
    tempId = id;
   }
   if (delList.size() > 0) {
    excelList.removeAll(delList);
   }
  
   if(excelList != null && excelList.size()>0){
    for(VXfZhDTO vxfZhDTO : excelList){
     Set<VXfSfrDj> sfrDj = new HashSet<VXfSfrDj>();
     String sfrSql = "WHERE sfwtid='" + vxfZhDTO.getWtid() + "' AND yxbz IN ('"+ConstantParam.YXBZ_YX+"','"+ConstantParam.YXBZ_DJ+"')";
     List<VXfSfrDj>  sfrDjList =  zhQueryService.getSfrDj(sfrSql);
     if( sfrDjList != null && sfrDjList.size() > 0 ) {
      for( VXfSfrDj sfr : sfrDjList ) {
       sfrDj.add(sfr);
      }
     }
     sfrwtMap.put(vxfZhDTO, sfrDj);
    }
   }
  
  }

  return sfrwtMap;
}

public List<?> getDownloadFileList() throws Exception {
  vxfZhDTO = (VXfZhDTO) session.get("vxfZhDTO");
  TXtYhDTO yhDTO = (TXtYhDTO) session.get(ConstantParam.USER_SESSION_KEY);
  StringBuilder where = new StringBuilder(ConstantParam.BYTJ);
  where.append(ConstantParam.BYTJ_AND).append("substr(xfly,0,2) ='").append(ConstantParam.XFLY_RD).append("'"); // yuhj 只读取人大数据2012-05-16
  if (vxfZhDTO != null) {
   relation = QueryUtils.getSQL(vxfZhDTO, yhDTO, true, null);
  }
  if (StringUtils.isNotEmpty(relation)) {
   where.append(ConstantParam.BYTJ_AND).append(relation);
  }
  where.append(Authority.newInstance().getRelation(yhDTO));
  List<?> excelCountList = queryBusiness.getDistinctZh(where.toString());
  if (excelCountList != null && excelCountList.size() > 0) {
   Map<String, String> dataMap = StringUtils.listConvertMap(excelCountList);
   StringBuffer sb = new StringBuffer();
   for (Map.Entry<String, String> me : dataMap.entrySet()) {
    if (!"".equals(me.getKey())) {
     sb.append(" wtid = '" + me.getKey() + "' OR ");
    }
   }
   sb.delete(sb.lastIndexOf("OR"), sb.length());
   excelList = queryBusiness.queryExcelPage(sb.toString() + " ORDER BY lfsj DESC,wtid");
   List<VXfZhDTO> delList = new ArrayList<VXfZhDTO>();
   String id = "";
   String tempId = "";
   String clfsStr = "";
   String jzsjStr = "";
   String pzsjStr = "";
   for (int index = 0; excelList != null && excelList != null && index < excelList.size(); index++) {
    VXfZhDTO vxfZhDTO = excelList.get(index);
    id = vxfZhDTO.getWtid();
    if (id.equals(tempId)) {
     if (vxfZhDTO.getClfsStr() == null || "".equals(vxfZhDTO.getClfsStr())) {
      vxfZhDTO.setClfsStr("\r\n" + clfsStr);
     } else {
      vxfZhDTO.setClfsStr(vxfZhDTO.getClfsStr() + "\r\n" + clfsStr);
     }
     if (vxfZhDTO.getJzsjStr() == null || "".equals(vxfZhDTO.getJzsjStr())) {
      vxfZhDTO.setJzsjStr("\r\n" + jzsjStr);
     } else {
      vxfZhDTO.setJzsjStr(vxfZhDTO.getJzsjStr() + "\r\n" + jzsjStr);
     }
     if (vxfZhDTO.getPzychjzsjStr() == null || "".equals(vxfZhDTO.getPzychjzsjStr())) {
      vxfZhDTO.setPzychjzsjStr("\r\n" + pzsjStr);
     } else {
      vxfZhDTO.setPzychjzsjStr(vxfZhDTO.getPzychjzsjStr() + "\r\n" + pzsjStr);
     }
     delList.add(excelList.get(index - 1));
    }
    clfsStr = vxfZhDTO.getClfsStr();
    jzsjStr = vxfZhDTO.getJzsjStr();
    pzsjStr = vxfZhDTO.getPzychjzsjStr();
    tempId = id;
   }
   if (delList.size() > 0) {
    excelList.removeAll(delList);
   }
  }

  return excelList;
}

public void setThdqid(String thdqid) {
  this.thdqid = thdqid;
}

public String getThdqid() {
  return thdqid;
}

public void setThdwid(String thdwid) {
  this.thdwid = thdwid;
}

public String getThdwid() {
  return thdwid;
}

public String getDatetoString(Date date)
{
  Date dt = date;
  //创建日期格式化对象
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  return  sdf.format(dt);
}
}

你可能感兴趣的:(java,xml,dom4j)