package nc.impl.scp.com;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.jdbc.framework.SQLParameter;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.pub.scp.com.IComConst;
import nc.pub.scp.com.IDataOperateConst;
import nc.pub.scp.com.IDataTypeConst;
import nc.pub.uapbd.FormulaTool;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVO;
import nc.vo.scp.basicdata.BasicDataOperate;
import nc.vo.scp.err.ErrVO;
/**
* 下载服务实现类通用方法提供者
*
* @author:Rain
* @time:2015-3-28 下午11:14:50
*/
public abstract class DownLoadCommDeal extends CommDeal {
protected String OPERATE_SQL = "select * from scp_basicdata_operate where isnull(dr,0) = 0 and isnull(bsucceed,'N') = 'N' and data_type = ? order by operate_time asc";
protected nc.itf.scp.pub.IBasicDataOperate operateService = null;
public DownLoadCommDeal() throws BusinessException {
operateService = NCLocator.getInstance().lookup(
nc.itf.scp.pub.IBasicDataOperate.class);
}
private DataSend dataSendHandler = DataSend.getInstances();
protected abstract String getHeaderVOClass();
protected String getBodyVOClass() {
return null;
}
protected boolean bHaveBodyDom() {
return false; // 默认只处理表头List数据到XML
}
/**
* 将特殊符号转意成XML语言中字符
*
* @param strString
* @return
*/
public static String turnSpecialString(String strString) {
if (null == strString || "".equals(strString))
return strString;
return strString.replaceAll("<", "<").replaceAll(">", ">")
.replaceAll("&", "&").replaceAll("'", "'")
.replaceAll("\"", """);
}
/*
* 初始化表头fields
*/
protected String[] initHeadFields() throws BusinessException {
String headerClass = getHeaderVOClass();
if (null == headerClass)
throw new BusinessException("但没有设置表头VO类型!");
SuperVO obj = null;
try {
obj = (SuperVO) Class.forName(headerClass).newInstance(); // 利用反射实例化对象
} catch (Exception e) {
throw new BusinessException("实例化类" + headerClass + "的对象时失败,具体原因:"
+ e.getMessage());
}
return obj.getAttributeNames();
}
/*
* 初始化表体fields
*/
protected String[] initBodyFields() throws BusinessException {
if (!bHaveBodyDom())
return null;
String bodyClass = getBodyVOClass();
if (null == bodyClass)
throw new BusinessException("需要加载表体VO,但没有设置表体VO类型!");
SuperVO obj = null;
try {
obj = (SuperVO) Class.forName(bodyClass).newInstance();
} catch (Exception e) {
throw new BusinessException("实例化类" + bodyClass + "的对象时失败,具体原因:"
+ e.getMessage());
}
return obj.getAttributeNames();
}
@Override
public String sendDatas(SuperVO[] arrayVO) throws BusinessException {
return sendDataArray(arrayVO);
}
/**
* 将查询结果格式化成xml
*
* @param list
* @return
* @throws BusinessException
*/
protected String sendDataArray(SuperVO[] arrayVO) throws BusinessException {
if (null == arrayVO || 0 == arrayVO.length)
return null;
List<SuperVO> list = new ArrayList<SuperVO>();
list = Arrays.asList(arrayVO); // 数组转集合
return sendDataList(list);
}
protected String sendDataList(List<SuperVO> headVOList)
throws BusinessException {
return sendDataList(headVOList, IDataOperateConst.OPERATETYPE_A
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.jdbc.framework.SQLParameter;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.pub.scp.com.IComConst;
import nc.pub.scp.com.IDataOperateConst;
import nc.pub.scp.com.IDataTypeConst;
import nc.pub.uapbd.FormulaTool;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVO;
import nc.vo.scp.basicdata.BasicDataOperate;
import nc.vo.scp.err.ErrVO;
/**
* 下载服务实现类通用方法提供者
*
* @author:Rain
* @time:2015-3-28 下午11:14:50
*/
public abstract class DownLoadCommDeal extends CommDeal {
protected String OPERATE_SQL = "select * from scp_basicdata_operate where isnull(dr,0) = 0 and isnull(bsucceed,'N') = 'N' and data_type = ? order by operate_time asc";
protected nc.itf.scp.pub.IBasicDataOperate operateService = null;
public DownLoadCommDeal() throws BusinessException {
operateService = NCLocator.getInstance().lookup(
nc.itf.scp.pub.IBasicDataOperate.class);
}
private DataSend dataSendHandler = DataSend.getInstances();
protected abstract String getHeaderVOClass();
protected String getBodyVOClass() {
return null;
}
protected boolean bHaveBodyDom() {
return false; // 默认只处理表头List数据到XML
}
/**
* 将特殊符号转意成XML语言中字符
*
* @param strString
* @return
*/
public static String turnSpecialString(String strString) {
if (null == strString || "".equals(strString))
return strString;
return strString.replaceAll("<", "<").replaceAll(">", ">")
.replaceAll("&", "&").replaceAll("'", "'")
.replaceAll("\"", """);
}
/*
* 初始化表头fields
*/
protected String[] initHeadFields() throws BusinessException {
String headerClass = getHeaderVOClass();
if (null == headerClass)
throw new BusinessException("但没有设置表头VO类型!");
SuperVO obj = null;
try {
obj = (SuperVO) Class.forName(headerClass).newInstance(); // 利用反射实例化对象
} catch (Exception e) {
throw new BusinessException("实例化类" + headerClass + "的对象时失败,具体原因:"
+ e.getMessage());
}
return obj.getAttributeNames();
}
/*
* 初始化表体fields
*/
protected String[] initBodyFields() throws BusinessException {
if (!bHaveBodyDom())
return null;
String bodyClass = getBodyVOClass();
if (null == bodyClass)
throw new BusinessException("需要加载表体VO,但没有设置表体VO类型!");
SuperVO obj = null;
try {
obj = (SuperVO) Class.forName(bodyClass).newInstance();
} catch (Exception e) {
throw new BusinessException("实例化类" + bodyClass + "的对象时失败,具体原因:"
+ e.getMessage());
}
return obj.getAttributeNames();
}
@Override
public String sendDatas(SuperVO[] arrayVO) throws BusinessException {
return sendDataArray(arrayVO);
}
/**
* 将查询结果格式化成xml
*
* @param list
* @return
* @throws BusinessException
*/
protected String sendDataArray(SuperVO[] arrayVO) throws BusinessException {
if (null == arrayVO || 0 == arrayVO.length)
return null;
List<SuperVO> list = new ArrayList<SuperVO>();
list = Arrays.asList(arrayVO); // 数组转集合
return sendDataList(list);
}
protected String sendDataList(List<SuperVO> headVOList)
throws BusinessException {
return sendDataList(headVOList, IDataOperateConst.OPERATETYPE_A