package nc.plugin.testTable.test;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import nc.itf.so.m32.ISaleInvoiceMaintain;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.ColumnListProcessor;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.pubitf.arap.bill.IArapBillPubService;
import nc.vo.pu.m23.entity.ArriveVO;
import nc.vo.pu.m23.env.ArrivalUIToBSEnv;
import nc.vo.pubapp.pattern.log.Log;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.NCLocator;
import nc.bs.pub.pa.PreAlertObject;
import nc.bs.pub.pa.PreAlertReturnType;
import nc.bs.pub.taskcenter.BgWorkingContext;
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.so.m32.entity.SaleInvoiceBVO;
import nc.vo.so.m32.entity.SaleInvoiceHVO;
import nc.vo.so.m32.entity.SaleInvoiceVO;
public class Test implements IBackgroundWorkPlugin{
private Lock lock = new ReentrantLock();
private IUAPQueryBS queryBS=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class);
@Override
public PreAlertObject executeTask(BgWorkingContext context)
throws BusinessException {
//获取参数
Map<String,Object> map=context.getKeyMap();
String p01=(String)map.get("para01");
Log.getInstance().info(p01);
//创建单据对象
SaleInvoiceHVO saleInvoiceHVO=new SaleInvoiceHVO();//主实体
SaleInvoiceBVO saleInvoiceBVO=new SaleInvoiceBVO();//子实体
//数据库操作
BaseDAO dao=new BaseDAO();
lock.lock();//加锁
try{
//表头设置
saleInvoiceHVO.setCreationtime(new UFDateTime(System.currentTimeMillis()));//获取当前时间
saleInvoiceHVO.setCtrantypeid("发票类型");//发票类型,字符串
saleInvoiceHVO.setCcurrencyid("本位币");//本位币
saleInvoiceHVO.setCinvoicecustid("客户名称");//客户名称
saleInvoiceHVO.setPk_org_v("开票组织");//开票组织
saleInvoiceHVO.setCorigcurrencyid("币种");//币种
//saleInvoiceVO.getParentVO().setCbiztypeid("业务流程");//业务流程
saleInvoiceHVO.setCbiztypeid("业务流程");//业务流程
UFDouble uf=new UFDouble().setScale(1, 1);
uf.add(1);
saleInvoiceHVO.setNexchangerate(uf);//折本汇率UFDouble
saleInvoiceHVO.setFbuysellflag(1);//购销类型Integer
dao.insertVO(saleInvoiceHVO);//插入主实体
//获取新插入的主键
String sql="select csaleinvoiceid from("+
"select csaleinvoiceid from so_saleinvoice where nvl(dr,0)=0 order by TS desc )"+
" where rownum<=1";
String csaleinvoiceid=(String) queryBS.executeQuery(sql, new ColumnProcessor());
//Object csaleinvoiceid2=queryBS.executeQuery(sql, new ColumnProcessor());
//List<String> csaleinvoiceidList=(List<String>) queryBS.executeQuery(sql, new ColumnListProcessor());
saleInvoiceBVO.setCsaleinvoiceid(csaleinvoiceid);//主实体主键
saleInvoiceBVO.setCmaterialvid("物料编码");//物料编码
saleInvoiceBVO.setCastunitid("单位");//单位
saleInvoiceBVO.setCunitid("主单位");//主单位
saleInvoiceBVO.setNorigtaxmny(uf);//价税合计UFDouble
saleInvoiceBVO.setCtaxcodeid("税码");//税码
saleInvoiceBVO.setFtaxtypeflag(2);//扣税类别Integer
saleInvoiceBVO.setNtaxmny(uf);//本币价税合计UFDouble
dao.insertVO(saleInvoiceBVO);
}catch(Exception e){
e.printStackTrace();
}finally{
lock.unlock();//解锁
}
/*SaleInvoiceVO[] rvos = nc.bs.framework.common.NCLocator.getInstance()
.lookup(nc.itf.so.m32.ISaleInvoiceMaintain.class)
.insertSaleInvoice(saleInvoiceVO);
*/
//ISaleInvoiceMaintain service = NCLocator.getInstance().lookup(ISaleInvoiceMaintain.class);
//service.insertSaleInvoice(sa);
//返回值封装
PreAlertObject preAlertObject=new PreAlertObject();
preAlertObject.setReturnType(PreAlertReturnType.RETURNMESSAGE);
preAlertObject.setReturnObj("sucess");
preAlertObject.setMsgTitle("msg");
// TODO 自动生成的方法存根
return preAlertObject;
}
}
注意点:
需要查看设置的是否存在子表,存在子表一般存的是子表的编码