package nc.ui.fbm.gather.actions;
import java.awt.event.ActionEvent;
import nc.bs.pf.pub.PfDataCache;
import nc.desktop.ui.WorkbenchEnvironment;
import nc.funcnode.ui.FuncletInitData;
import nc.funcnode.ui.FuncletWindowLauncher;
import nc.ui.fbm.gather.model.GatherModel;
import nc.ui.fbm.gather.view.GatherCardEditor;
import nc.ui.fbm.pub.FbmClientUtil;
import nc.ui.tmpub.busidate.TMBusiDateManager;
import nc.ui.uif2.NCAction;
import nc.vo.arap.gathering.AggGatheringBillVO;
import nc.vo.arap.gathering.GatheringBillItemVO;
import nc.vo.arap.gathering.GatheringBillVO;
import nc.vo.fbm.pub.constant.RegisterStatusConstant;
import nc.vo.fbm.pub.util.FbmPublicUtil;
import nc.vo.fbm.register.AggRegisterVO;
import nc.vo.fbm.register.RegisterVO;
import nc.vo.ml.AbstractNCLangRes;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.pub.BusinessException;
import nc.vo.pub.billtype.BilltypeVO;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
import nc.vo.sm.funcreg.FuncRegisterVO;
import nc.vo.tmpub.util.DialogTool;
import nc.vo.tmpub.util.TMCurrencyUtil;
import nc.vo.uif2.LoginContext;
public class GatherBusiARAction extends NCAction
{
private static final long serialVersionUID = 1L;
private GatherModel model;
private GatherCardEditor editor;
public GatherBusiARAction()
{
setBtnName(NCLangRes4VoTransl.getNCLangRes().getStrByID("3637fbm_add_0", "03637fbm_add-0002"));
setCode("busiaraction");
}
public void doAction(ActionEvent e) throws Exception
{
FbmClientUtil.checkSameOrgCurr(getModel().getSelectedOperaDatas());
FbmClientUtil.checkSamePaybillunit(getModel().getSelectedOperaDatas());
FbmClientUtil.checkIsBookOrPlan(getModel().getSelectedOperaDatas());
FbmClientUtil.checkRegisterStatus(getModel().getSelectedOperaDatas());
String funcode = "20060GBR";
String pk_desbilltype = "F2";
String tradetype = "D2";
String billclass = "sk";
Object[] objects = getModel().getSelectedOperaDatas();
if ((objects != null) && (objects.length != 0)) {
String pk_org = ((AggRegisterVO)objects[0]).getparentVO().getPk_org();
String pk_org_v = ((AggRegisterVO)objects[0]).getparentVO().getPk_org_v();
String pk_group = ((AggRegisterVO)objects[0]).getparentVO().getPk_group();
String pk_curr = ((AggRegisterVO)objects[0]).getparentVO().getPk_curr();
String paybillunit = ((AggRegisterVO)objects[0]).getparentVO().getPaybillunit();
String fbmbilltype = ((AggRegisterVO)objects[0]).getparentVO().getFbmbilltype();
if ((fbmbilltype.equals("FBMTZ6E0000000000001")) || (fbmbilltype.equals("FBMTZ6E0000000000002"))) {
FbmClientUtil.checkHasReceiveComplete(getModel().getSelectedOperaDatas());
}
if (!FbmPublicUtil.isAREnable(pk_group)) {
throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("3637fbm_add_0", "03637fbm_add-0003"));
}
if (!FbmPublicUtil.isTogatherWithOther(pk_org, "FBM2002")) {
throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("3637fbm_add_0", "03637fbm_add-0004"));
}
UFDate busidate = TMBusiDateManager.getTMBusiDate();
UFDouble orgcurrrate = TMCurrencyUtil.getOrgCurrRate(pk_org, pk_curr, busidate);
UFDouble glcurrrate = TMCurrencyUtil.getGroupCurrRate(pk_group, pk_org, pk_curr, busidate);
UFDouble gllcurrrate = TMCurrencyUtil.getGlobalCurrRate(pk_org, pk_curr, busidate);
UFDouble summoney_cr = new UFDouble();
UFDouble sumolcmoney_cr = new UFDouble();
UFDouble sumglcmoney_cr = new UFDouble();
UFDouble sumgllcmoney_cr = new UFDouble();
AggGatheringBillVO araggvo = new AggGatheringBillVO();
GatheringBillItemVO[] childrenvos = new GatheringBillItemVO[objects.length];
AggRegisterVO aggvo = null;
for (int i = 0; i < childrenvos.length; i++) {
aggvo = (AggRegisterVO)objects[i];
childrenvos[i] = new GatheringBillItemVO();
childrenvos[i].setPk_org(pk_org);
childrenvos[i].setPk_org_v(pk_org_v);
childrenvos[i].setSett_org(pk_org);
childrenvos[i].setSett_org_v(pk_org_v);
childrenvos[i].setPk_group(pk_group);
childrenvos[i].setObjtype(Integer.valueOf(0));
childrenvos[i].setCustomer(paybillunit);
childrenvos[i].setPrepay(Integer.valueOf(0));
childrenvos[i].setChecktype(aggvo.getparentVO().getFbmbilltype());
childrenvos[i].setCheckno(aggvo.getparentVO().getPk_register());
childrenvos[i].setPk_currtype(pk_curr);
childrenvos[i].setDirection(Integer.valueOf(-1));
childrenvos[i].setMoney_cr(aggvo.getparentVO().getMoney());
childrenvos[i].setRate(orgcurrrate);
childrenvos[i].setGrouprate(glcurrrate);
childrenvos[i].setGlobalrate(gllcurrrate);
childrenvos[i].setBilldate(busidate);
childrenvos[i].setBusidate(busidate);
childrenvos[i].setPk_billtype(pk_desbilltype);
childrenvos[i].setBillclass(billclass);
childrenvos[i].setPk_tradetype(tradetype);
childrenvos[i].setPk_tradetypeid(PfDataCache.getBillType(tradetype) == null ? null : PfDataCache.getBillType(tradetype).getPk_billtypeid());
summoney_cr = summoney_cr.add(aggvo.getparentVO().getMoney());
UFDouble orgmoney = TMCurrencyUtil.getOrgLocalMoney(pk_org, pk_curr, aggvo.getparentVO().getMoney(), orgcurrrate, busidate);
if (orgmoney != null) {
orgmoney = FbmPublicUtil.getOrgDigitmoney(pk_org, pk_curr, orgmoney);
sumolcmoney_cr = sumolcmoney_cr.add(orgmoney);
}
childrenvos[i].setLocal_money_cr(orgmoney);
UFDouble glmoney = TMCurrencyUtil.getGroupLocalMoney(pk_group, pk_org, pk_curr, aggvo.getparentVO().getMoney(), glcurrrate, orgcurrrate, busidate);
if (glmoney != null) {
glmoney = FbmPublicUtil.getGroupDigitmoney(pk_group, pk_org, pk_curr, glmoney);
sumglcmoney_cr = sumglcmoney_cr.add(glmoney);
}
childrenvos[i].setGroupcrebit(glmoney);
UFDouble gllmoney = TMCurrencyUtil.getGlobalLocalMoney(pk_org, pk_curr, aggvo.getparentVO().getMoney(), gllcurrrate, orgcurrrate, busidate);
if (gllmoney != null) {
gllmoney = FbmPublicUtil.getGlobalDigitmoney(pk_org, pk_curr, gllmoney);
sumgllcmoney_cr = sumgllcmoney_cr.add(gllmoney);
}
childrenvos[i].setGlobalcrebit(glmoney);
}
GatheringBillVO parentvo = new GatheringBillVO();
parentvo.setPk_org(pk_org);
parentvo.setPk_org_v(pk_org_v);
parentvo.setSett_org(pk_org);
parentvo.setSett_org_v(pk_org_v);
parentvo.setPk_group(pk_group);
parentvo.setObjtype(Integer.valueOf(0));
parentvo.setCustomer(paybillunit);
parentvo.setPk_currtype(pk_curr);
parentvo.setBillmaker(getModel().getContext().getPk_loginUser());
parentvo.setBilldate(busidate);
parentvo.setBusidate(busidate);
parentvo.setCreator(getModel().getContext().getPk_loginUser());
parentvo.setCreationtime(WorkbenchEnvironment.getServerTime());
parentvo.setPk_billtype(pk_desbilltype);
parentvo.setBillclass(billclass);
parentvo.setPk_tradetype(tradetype);
parentvo.setPk_tradetypeid(PfDataCache.getBillType(tradetype) == null ? null : PfDataCache.getBillType(tradetype).getPk_billtypeid());
parentvo.setSyscode(Integer.valueOf(0));
parentvo.setSrc_syscode(Integer.valueOf(0));
parentvo.setBillstatus(Integer.valueOf(-1));
parentvo.setMoney(summoney_cr);
parentvo.setRate(orgcurrrate);
parentvo.setGrouprate(glcurrrate);
parentvo.setGlobalrate(gllcurrrate);
parentvo.setLocal_money(sumolcmoney_cr);
parentvo.setGrouplocal(sumglcmoney_cr);
parentvo.setGloballocal(sumgllcmoney_cr);
araggvo.setParentVO(parentvo);
araggvo.setChildrenVO(childrenvos);
FuncletInitData initData = null;
initData = new FuncletInitData();
initData.setInitType(0);
initData.setInitData(araggvo);
FuncRegisterVO funvo = WorkbenchEnvironment.getInstance().getFuncRegisterVO(funcode);
FuncletWindowLauncher.openFuncNodeFrame((nc.funcnode.ui.AbstractFunclet)getModel().getContext().getEntranceUI(), funvo, initData, null, false, DialogTool.getWindowOfScreenCenter());
}
}
public GatherModel getModel()
{
return model;
}
public void setModel(GatherModel model) {
this.model = model;
model.addAppEventListener(this);
}
public GatherCardEditor getEditor() {
return editor;
}
public void setEditor(GatherCardEditor editor) {
this.editor = editor;
}
String funcode = "20060GBR";
String pk_desbilltype = "F2";
String tradetype = "D2";
String billclass = "sk";
FuncletInitData initData = null;
initData = new FuncletInitData();
initData.setInitType(0);
initData.setInitData(araggvo);
FuncRegisterVO funvo = WorkbenchEnvironment.getInstance().getFuncRegisterVO(funcode);
FuncletWindowLauncher.openFuncNodeFrame((nc.funcnode.ui.AbstractFunclet)getModel().getContext().getEntranceUI(), funvo, initData, null, false, DialogTool.getWindowOfScreenCenter());
原文链接:https://blog.csdn.net/Cc_Rain0624/article/details/109624417