- 浏览: 17442 次
- 性别:
- 来自: 北京
最新评论
采用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);
}
}
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导出Word和Excel是一种灵活且可扩展的方法,它允许开发人员以结构化的方式处理数据,便于数据交换和跨平台兼容。通过Apache POI和其他相关库,开发者能够高效地生成和导出符合特定需求的文档。
在C#编程中,打印预览和XML导出是两个重要的功能,特别是在开发桌面应用程序时。下面我们将详细探讨这两个主题。 一、C# 打印预览 打印预览是程序在实际打印前向用户展示文档将如何呈现的界面。在C#中,可以使用...
总结来说,从XML文件读取数据并导出到Excel文件,首先需要选择合适的XML解析器,如SAX,因为它适用于处理大型XML文件。然后,利用SAX解析XML,将解析到的数据存储在适当的数据结构中,如列表或DataFrame。最后,通过...
确保安装了pandas和lxml库(用于XML处理)后,运行这段代码,它将创建一个名为'bugzilla.xlsx'的Excel文件,其中包含了从XML导出的Bug数据。 这个过程在软件开发团队中非常实用,因为它允许团队成员分析Bug趋势,找...
在这个场景中,我们需要利用mxGraph前端插件来绘制流程图,并通过Java后端将XML数据转换为图片。 在前端部分,mxGraph允许用户通过JavaScript代码动态构建图形,这些图形可以是流程图、组织结构图等。用户可以...
在本示例中,“XML导出到Excel”指的是将XML文件中的数据转换并输出到Microsoft Excel电子表格中,这样的操作在数据处理、报表生成以及数据分析等领域非常常见。 首先,XML文件作为数据载体,其优点在于数据与显示...
在XML导出时,若单sheet数据量超过限制,可以创建多个sheet来存放数据,例如,文件名后缀添加“_1”、“_2”等来区分不同的sheet。 4. **数据拆分**: 当单sheet数据超过6万条时,可以通过编程方式自动拆分数据到...
标题 "xml导出javascript&css多级导航栏" 涉及到的技术点主要集中在XML、JavaScript和CSS三个核心领域,这些技术在Web开发中扮演着至关重要的角色。以下是关于这些知识点的详细说明: 1. **XML(Extensible Markup ...
支持多个strings.xml导出excel,暂不支持特殊标签如:<xliff:g id="NAME">%1$s。 使用说明: 打开powershell,进入脚本当前目录,执行命令 ./string2excel "strings.xml所在目录" "excel输出路径" 示范: ./string2...
本文将深入探讨如何使用XML方式在C#中导出Excel,以解决在处理大量数据时可能出现的问题,比如使用Microsoft.Office.Interop.Excel库可能导致的性能瓶颈。 首先,让我们了解XML(可扩展标记语言)的背景。XML是一种...
XML导出则涉及将程序内部的数据结构转换成XML格式。`XmlWriter`类是用于创建XML文档的主要工具。我们可以创建一个`XmlWriter`实例,然后使用它的Write方法来写入元素和属性。例如: ```csharp using (XmlWriter ...
根据给定的信息,本文将详细解释如何利用XML技术来实现数据导出至Excel的功能,并对提供的部分代码进行解析。此方法对于需要频繁处理数据导出任务的开发人员来说非常实用。 ### 一、导出数据至Excel的基本原理 在...
二、XML导出 1. 创建XML:使用XMLDOM对象的`CreateElement()`方法创建新的XML元素,`AppendChild()`方法将元素添加到父节点,`SetAttribute()`设置属性值,从而构建XML树。 2. 保存XML:创建并填充了XML树后,可以...
这些步骤确保数据符合XML导出的要求。 3. **数据格式化**:为了生成XML文件,数据需要按照XML的结构进行格式化。Kettle的“XML输出”步骤可以用于此目的。用户需要定义XML的根元素、子元素以及元素间的层级关系。 ...
在本篇文档中,我们主要探讨了使用Spring MVC和Ajax技术实现导出和导入XML文件的功能。这一技术在Web开发中十分常见,用于在客户端与服务器之间传输数据,且常常用于文件操作场景。 首先,我们来看文档中提及的导入...
(1)支持web及winform从DataTable导出到Excel; (2)生成速度很快; (3)准确判断数据类型,不会出现身份证转数值等问题; (4)如果单页条数大于65535时会新建工作表; (5)列宽自适应;
根据提供的文件信息,本文将对Oracle数据库中导入导出XML文件的相关知识点进行详细的解析与介绍。主要内容包括如何通过Java代码实现Oracle数据库与XML文件之间的数据交互,并深入理解所提供代码的具体功能。 ### ...
TestLink的XML导出包含了测试用例的所有详细信息,如ID、标题、步骤、预期结果等。 - **Excel**:Excel是Microsoft Office套件的一部分,用于处理表格数据,包括计算、数据分析和可视化。在测试领域,Excel常用于...
这个示例源码"XML文件导出Excel(xmlToExcel)示例源码"提供了一种方法,将XML数据转换为可编辑和可视化的Excel格式。下面将详细解释这一过程涉及的关键知识点。 1. **XML(Extensible Markup Language)**:XML是一...
这里我们将深入探讨如何使用Java实现XML到Excel的转换以及如何创建一个通用的Excel导出工具类。首先,我们需要理解XML和Excel两种文件格式的基本概念。 XML(Extensible Markup Language)是一种用于存储和传输数据...