**
7、NC单据左侧实现查询数据加载至新界面
**
//代码类
package nc.ui.hfet.hfet_fininvoiceandorg.ace.action1;
import java.awt.event.ActionEvent;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.itf.hffin.IHffin_bankwatereseiptMaintain;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.IVOPersistence;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.ColumnListProcessor;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.ui.pubapp.uif2app.query2.action.DefaultQueryAction;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.ui.querytemplate.querytree.QueryScheme;
import nc.vo.hfet.hfet_fininvoiceandorg.AggHfet_fininvoiceandorg;
import nc.vo.hfet.hfet_fininvoiceandorg.Hfet_fininvoiceandorg;
import nc.vo.hffin.hffin_bankwatereseipt.Hffin_bankwatereseipt;
import nc.vo.hffin.hffin_bankwatereseipt.Hffin_selectbwr;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.AppContext;
public class HFAddQueryAction extends DefaultQueryAction {
private static final long serialVersionUID = 1L;
public HFAddQueryAction(){
this.setCode("HFAddQuery");
this.setBtnName("查询");
}
@Override
public void doAction(ActionEvent e) throws Exception {
super.doAction(e);
//获取查询参数的WHERE条件进行查询
/* QueryScheme queryScheme = (QueryScheme) getQryDLGDelegator().getQueryScheme();
String whereSQL = queryScheme.getWhereSQLOnly();
if(null == whereSQL || “”.equals(whereSQL)){
return;
}
whereSQL = whereSQL.replace(" 00:00:00", “”).replace(" 23:59:59", “”);
whereSQL = whereSQL.replace(" AND cwqszt = ‘2’", “”).replace(" AND cwqszt = ‘1’", “”).replace(" AND cwqszt in (‘1’,‘2’)", “”);
whereSQL = whereSQL.replace(" AND cnqszt = ‘2’", “”).replace(" AND cnqszt = ‘1’", “”).replace(" AND cnqszt in (‘1’,‘2’)", “”);*/
//insertBillsByWhereSQL(whereSQL);
}
@Override
protected void executeQuery(IQueryScheme queryScheme) {
super.executeQuery(queryScheme);
//获取查询参数的WHERE条件进行查询
String whereSQL = ((QueryScheme)queryScheme).getWhereSQLOnly();
/*if(null == whereSQL || "".equals(whereSQL)){
return;
}*/
//whereSQL = whereSQL.replace(" 00:00:00", "").replace(" 23:59:59", "");
//whereSQL = whereSQL.replace(" AND cwqszt = '2'", "").replace(" AND cwqszt = '1'", "").replace(" AND cwqszt in ('1','2')", "");
//whereSQL = whereSQL.replace(" AND cnqszt = '2'", "").replace(" AND cnqszt = '1'", "").replace(" AND cnqszt in ('1','2')", "");
if(null != whereSQL ){
whereSQL = whereSQL.replace("(", "").replace(")", "");
}
try {
insertBillsByWhereSQL(whereSQL);
} catch (Exception e) {
e.printStackTrace();
}
}
public void insertBillsByWhereSQL(String whereSQL) throws Exception {
IUAPQueryBS server = NCLocator.getInstance().lookup(IUAPQueryBS.class);
List<Hfet_fininvoiceandorg> retvos = new ArrayList<Hfet_fininvoiceandorg>();
//if(!"".equals(whereSQL) && null != whereSQL){
String cuserid = AppContext.getInstance().getPkUser();
String sqluser = "select pk_org from bd_defdoc a where a.pk_defdoclist in (select pk_defdoclist from bd_defdoclist a where a.name like'%出口公司操作员维护%') and a.code = (select user_code from sm_user a where a.cuserid='"+cuserid+"') ;";
List<String> userorgs =(List<String>) server.executeQuery(sqluser, new ColumnListProcessor());
String orgs= "";
if(userorgs!=null){
for (String string : userorgs) {
orgs +=",'"+string+"'";
}
orgs = orgs.substring(1);
}
try {
StringBuilder sbuSql = new StringBuilder();
sbuSql.append(" select * from ( ");
sbuSql.append(" select a.sfckgskp,a.sfgccwkp,a.tssbpc,b.ystse,b.tsl,b.sftsbs,bd_customer.name def4,bd_customer.code def3,b.def5 bbkpje,bd_countryzone.name ydg,a.ckrq,a.ckkprq,a.ckzzsfph,a.pk_sggs,a.yf,a.bf,a.zybje,a.pk_bz,a.pk_mdg,a.pk_ysfs,a.pk_sfg,a.pk_myfs,a.hth,a.pk_shr,a.pkckgs pkckgs,a.pk_hfet_declearinfomt,b.pk_hfet_declearzb,a.transtype,a.pk_ghdw,a.bgdh,a.xsfph,b.rownumber bghh ,b.spbm,b.spmc,b.jjsl,b.def3 dyfddw,b.jz,b.ybkpje,b.spl,b.spje,b.jjdj,a.zzsfph,a.gccwkprq");
sbuSql.append(" from hfet_declearinfomt a");
sbuSql.append(" inner join hfet_declearzb b");
sbuSql.append(" on a.pk_hfet_declearinfomt = b.pk_hfet_declearinfomt left join bd_customer on a.pk_shr = bd_customer.pk_customer left join bd_countryzone on bd_customer.pk_country = bd_countryzone.pk_country");
sbuSql.append(" where a.dr=0 and b.dr=0 ");
sbuSql.append(" and a.sfscbgd = 'Y'");
sbuSql.append(" and a.pkckgs in ("+orgs+")");
if(null != whereSQL ){
sbuSql.append(" and ");
sbuSql.append(" "+whereSQL+" ");
}
sbuSql.append(" )");
List<Hfet_fininvoiceandorg> retvo =(List<Hfet_fininvoiceandorg>) server.executeQuery(sbuSql.toString(),new BeanListProcessor(Hfet_fininvoiceandorg.class) );
List<AggHfet_fininvoiceandorg> AggHfet_fininvoiceandorgs = new ArrayList<AggHfet_fininvoiceandorg>();
if(null != retvo){
//设置单据日期制单人制单日期集团PK等等字段值
for(int i =0; i < retvo.size(); i++){
Hfet_fininvoiceandorg vo = retvo.get(i);
Hfet_fininvoiceandorg headvo = new Hfet_fininvoiceandorg();
AggHfet_fininvoiceandorg AggHfet_fininvoiceandorg = new AggHfet_fininvoiceandorg();
headvo.setBbkpje(vo.getBbkpje());
headvo.setDef4(vo.getDef4());
headvo.setDef3(vo.getDef3());
headvo.setYdg(vo.getYdg());
headvo.setCkrq(vo.getCkrq());
headvo.setCkkprq(vo.getCkkprq());
headvo.setCkzzsfph(vo.getCkzzsfph());
headvo.setPk_sggs(vo.getPk_sggs());
headvo.setYf(vo.getYf());
headvo.setBf(vo.getBf());
headvo.setZybje(vo.getZybje());
headvo.setPk_bz(vo.getPk_bz());
//月初汇率
BigDecimal rate=null;
try {
//月初汇率
String sql = "select a.rate from bd_currrate a left join bd_currinfo d on a.pk_currinfo = d.pk_currinfo where d.oppcurrtype='1002Z0100000000001K1' and a.ratedate<'"+new UFDate().toString().substring(0,8)+"01"+"' and d.pk_currtype = '"+vo.getPk_bz()+"' and a.dr=0 and d.dr=0 order by a.ratedate desc";
rate = (BigDecimal)server.executeQuery(sql,new ColumnProcessor());
headvo.setHl(new UFDouble(rate));
} catch (Exception e) {
throw new Exception("查询汇率出错"+e.getMessage());
}
headvo.setPk_mdg(vo.getPk_mdg());
headvo.setPk_sfg(vo.getPk_sfg());
headvo.setPk_ysfs(vo.getPk_ysfs());
headvo.setHth(vo.getHth());
headvo.setPk_myfs(vo.getPk_myfs());
headvo.setPk_shr(vo.getPk_shr());
headvo.setTranstype(vo.getTranstype());
headvo.setPk_org("GLOBLE00000000000000");
headvo.setPk_group("0001A110000000000L9C");
headvo.setVbilldate(new UFDate());
headvo.setBillmaker(cuserid);
headvo.setMaketime(new UFDateTime());
headvo.setCreator(cuserid);
headvo.setCreationtime(new UFDateTime());
headvo.setDr(0);
headvo.setPk_ghdw(vo.getPk_ghdw());
headvo.setBgdh(vo.getBgdh());
headvo.setXsfph(vo.getXsfph());
headvo.setBghh(vo.getBghh());
headvo.setSpbm(vo.getSpbm());
headvo.setBgrq(vo.getBgrq());
headvo.setSpmc(vo.getSpmc());
headvo.setJjsl(vo.getJjsl());
headvo.setDyfddw(vo.getDyfddw());
headvo.setJz(vo.getJz());
headvo.setYbkpje(vo.getYbkpje());
headvo.setSpl(vo.getSpl());
headvo.setSpje(vo.getSpje());
headvo.setJjdj(vo.getJjdj());
headvo.setZzsfph(vo.getZzsfph());
headvo.setGccwkprq(vo.getGccwkprq());
headvo.setApprovestatus(-1);
headvo.setPkckgs(vo.getPkckgs());
headvo.setPk_hfet_declearinfomt(vo.getPk_hfet_declearinfomt());
headvo.setPk_hfet_declearzb(vo.getPk_hfet_declearzb());
headvo.setDef7("2");
headvo.setTssbpc(vo.getTssbpc());
headvo.setTsl(vo.getTsl());
headvo.setYstse(vo.getYstse());
headvo.setSftsbs(vo.getSftsbs());
headvo.setSfgccwkp(vo.getSfgccwkp());
headvo.setSfckgskp(vo.getSfckgskp());
AggHfet_fininvoiceandorg.setParentVO(headvo);
AggHfet_fininvoiceandorgs.add(AggHfet_fininvoiceandorg);
}
/*IVOPersistence inSrv = NCLocator.getInstance().lookup(IVOPersistence.class);
String sql = "select * from hfet_fininvoiceandorg ";
List<Hfet_fininvoiceandorg> deletevos = (List<Hfet_fininvoiceandorg>) server.executeQuery(sql, new BeanListProcessor(Hfet_fininvoiceandorg.class));
inSrv.deleteVOList(deletevos);
inSrv.insertVOList(retvos);*/
getModel().initModel(AggHfet_fininvoiceandorgs.toArray(new AggHfet_fininvoiceandorg[]{}));
//刷新即重新查值
//getDataManager().refresh();
}
} catch (BusinessException e) {
Logger.error(e);
}
//}
}
}