1、编写自己的导入类
package com.kingdee.eas.custom.unify.utils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.AbstractObjectCollection;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.framework.batch.BatchExecuteParamsEntry;
import com.kingdee.bos.framework.batch.BatchExecuteResult;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.unify.caiwu.HongPiaoCollection;
import com.kingdee.eas.custom.unify.caiwu.HongPiaoEntryInfo;
import com.kingdee.eas.custom.unify.caiwu.HongPiaoFactory;
import com.kingdee.eas.custom.unify.caiwu.HongPiaoInfo;
import com.kingdee.eas.custom.unify.caiwu.IHongPiao;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.scm.common.ISCMBillBase;
import com.kingdee.eas.scm.sd.sale.SaleOrderCollection;
import com.kingdee.eas.scm.ws.app.importbill.BillResultInfo;
import com.kingdee.eas.scm.ws.app.importbill.IBillSupport;
import com.kingdee.eas.scm.ws.app.importbill.ScmbillImportUtils;
import com.kingdee.util.BaseException;
public class HongPiaoSupport implements IBillSupport {
protected BigDecimal zero;
private Context ctx;
public HongPiaoSupport() {
this.zero = new BigDecimal("0.00");
}
public boolean isSupportSubmit() {
return false;
}
public boolean isSupportAudit() {
return false;
}
public void setContext(Context ctx) {
this.ctx = ctx;
}
public Context getContext() {
return this.ctx;
}
public Class getInfoClass() {
return HongPiaoCollection.class; //替换为具体单据集合类
}
private List<String> setData(Context ctx, HongPiaoInfo info) //替换具体单据对象
throws BOSException, EASBizException {
List errorMsg = new ArrayList();
dealWithData(ctx, info, errorMsg);
setDefaultData(info, errorMsg);
verifyData(info, errorMsg);
return errorMsg;
}
protected void setDefaultData(HongPiaoInfo model, List<String> errorMsg)
throws BOSException, EASBizException {
setDefaultHeadData(model, errorMsg);
IObjectCollection entries = model.getEntrys();
int i = 0;
for (int size = entries.size(); i < size; ++i) {
HongPiaoEntryInfo entryInfo = (HongPiaoEntryInfo) entries //替换具体单据对象分录
.getObject(i);
setDefaultEntryData(entryInfo, model, errorMsg);
}
}
protected void setDefaultHeadData(HongPiaoInfo info,
List<String> errorMsg) throws BOSException, EASBizException {
if (info.getBizDate() == null)
info.setBizDate(new Date());
}
protected void setDefaultEntryData(HongPiaoEntryInfo entryModel,
HongPiaoInfo model, List<String> errorMsg) throws BOSException,
EASBizException {
}
protected void dealWithData(Context ctx, HongPiaoInfo model,
List<String> errorMsg) throws BOSException, EASBizException {
dealWithHeadData(model, errorMsg);
IObjectCollection entries = model.getEntrys();
int i = 0;
for (int size = entries.size(); i < size; ++i) {
HongPiaoEntryInfo entryInfo = (HongPiaoEntryInfo) entries
.getObject(i);
dealWithEntryData(entryInfo, model, errorMsg);
}
ScmbillImportUtils.setInfoByNumber(ctx, model, errorMsg);
}
protected void dealWithHeadData(HongPiaoInfo model, List<String> errorMsg)
throws BOSException, EASBizException {
}
protected void dealWithEntryData(HongPiaoEntryInfo entryModel,
HongPiaoInfo model, List<String> errorMsg) throws BOSException,
EASBizException {
}
protected void verifyData(HongPiaoInfo model, List<String> errorMsg)
throws BOSException, EASBizException {
verifyHeadData(model, errorMsg);
IObjectCollection entries = model.getEntrys();
int i = 0;
for (int size = entries.size(); i < size; ++i) {
HongPiaoEntryInfo entryInfo = (HongPiaoEntryInfo) entries
.getObject(i);
verifyEntryData(entryInfo, model, errorMsg);
}
}
protected void verifyHeadData(HongPiaoInfo model, List<String> errorMsg)
throws BOSException, EASBizException {
}
protected void verifyEntryData(HongPiaoEntryInfo entryModel,
HongPiaoInfo model, List<String> errorMsg) throws BOSException,
EASBizException {
}
public List<BillResultInfo> audit(List<BillResultInfo> results)
throws EASBizException, BOSException {
BatchExecuteResult result = null;
BatchExecuteParamsEntry[] paramEntries = new BatchExecuteParamsEntry[results
.size()];
BatchExecuteParamsEntry entry = null;
for (int i = 0; i < results.size(); ++i) {
BillResultInfo resultInfo = (BillResultInfo) results.get(i);
if ((resultInfo != null) && (resultInfo.getStatus() == 0)) {
String billid = resultInfo.getId();
entry = new BatchExecuteParamsEntry(
new Class[] { IObjectPK.class });
entry.add(new ObjectUuidPK(billid));
paramEntries[i] = entry;
}
}
Class[] batchMethod = { IObjectPK.class };
String methodPK = "audit";
try {
result = getInterface().batchExecute(methodPK, batchMethod,
paramEntries);
} catch (BaseException e) {
throw new BOSException(e);
}
Object[] objs = result.getReturnValues();
int i = 0;
for (int size = objs.length; i < size; ++i) {
List errorMsg = new ArrayList();
BillResultInfo resultInfo = new BillResultInfo();
if (result.getException(i) == null) {
resultInfo.setId(result.getReturnValue(i).toString());
resultInfo.setStatus(0);
} else {
errorMsg.add(result.getException(i).getMessage());
resultInfo.setErrorMsgs(errorMsg);
resultInfo.setStatus(1);
}
results.add(resultInfo);
}
return results;
}
public List<BillResultInfo> save(AbstractObjectCollection col)
throws EASBizException, BOSException {
List results = saveOrSubmitData(col, true);
return results;
}
public List<BillResultInfo> submit(AbstractObjectCollection col)
throws EASBizException, BOSException {
List results = saveOrSubmitData(col, false);
return results;
}
private List<BillResultInfo> saveOrSubmitData(AbstractObjectCollection col,
boolean isSave) throws BOSException, EASBizException {
List results = new ArrayList();
HongPiaoInfo info = null;
int i = 0;
for (int size = col.size(); i < size; ++i) {
info = (HongPiaoInfo) col.getObject(i);
List errorMsg = setData(this.ctx, info);
if ((errorMsg != null) && (errorMsg.size() > 0)) {
BillResultInfo result = new BillResultInfo();
result.setErrorMsgs(errorMsg);
result.setNumber(info.getNumber());
result.setStatus(1);
results.add(result);
col.removeObject(i);
--i;
--size;
}
}
if ((col != null) && (col.size() > 0)) {
BatchExecuteResult result = null;
BatchExecuteParamsEntry[] paramEntries = new BatchExecuteParamsEntry[col
.size()];
BatchExecuteParamsEntry entry = null;
i = 0;
for (int size = col.size(); i < size; ++i) {
entry = new BatchExecuteParamsEntry(
new Class[] { CoreBaseInfo.class });
entry.add(col.getObject(i));
paramEntries[i] = entry;
}
Class[] batchMethod = { CoreBaseInfo.class };
String methodPK = "submit";
if (isSave) {
methodPK = "save";
}
try {
result = getInterface().batchExecute(methodPK, batchMethod,
paramEntries);
} catch (BaseException e) {
throw new BOSException(e);
}
Object[] objs = result.getReturnValues();
i = 0;
for (int size = objs.length; i < size; ++i) {
info = (HongPiaoInfo) col.getObject(i);
List errorMsg = new ArrayList();
BillResultInfo resultInfo = new BillResultInfo();
resultInfo.setNumber(info.getNumber());
if (result.getException(i) == null) {
resultInfo.setId(result.getReturnValue(i).toString());
resultInfo.setStatus(0);
} else {
errorMsg.add(result.getException(i).getMessage());
resultInfo.setErrorMsgs(errorMsg);
resultInfo.setStatus(1);
}
results.add(resultInfo);
}
}
return results;
}
public IHongPiao getInterface() throws BOSException {
return HongPiaoFactory.getLocalInstance(getContext());
}
}
2、配置文件增加自己的导入类全路径
包名: com.kingdee.eas.scm.ws 文件名称 :WSimportclasses_l1.properties
文件内容:
10000=com.kingdee.eas.custom.unify.utils.HongPiaoSupport
注意事项
:标准jar 的同名包路径中也有同名的配置文件,bos启动服务器默认读取的是jar 中的配置文件,里面内容为空
这里是直接把标准的配置文件删除