protected com.kingdee.bos.dao.IObjectValue createNewData() {
//设置公司的初始值
com.kingdee.eas.custom.fapiaozuofei.HongChongSQDInfo objectValue = new com.kingdee.eas.custom.fapiaozuofei.HongChongSQDInfo();
if (com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentOrgUnit(com.kingdee.eas.basedata.org.OrgType.getEnum("Company")) != null && com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentOrgUnit(com.kingdee.eas.basedata.org.OrgType.getEnum("Company")).getBoolean("isBizUnit")) {
objectValue.put("FICompany", com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentOrgUnit(com.kingdee.eas.basedata.org.OrgType.getEnum("Company")));
objectValue.setCreator((com.kingdee.eas.base.permission.UserInfo) (com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentUser()));
} else {
try {
CoreBaseCollection coreBaseC = CompanyOrgUnitFactory.getRemoteInstance().getCollection("select where isBizUnit = '1'");
CompanyOrgUnitInfo info = (CompanyOrgUnitInfo) coreBaseC.get(0);
objectValue.setCompany(info);
} catch (BOSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//设置申请日期的初始值
objectValue.setApplyDate(new Date());
return objectValue;
}
/**
* 设置主业务组织的组织类型
*/
protected OrgType getMainBizOrgType() {
// 主业务组织的组织类型:请根据需求自行添加
// OrgType.Admin 行政组织
// OrgType.Company 财务组织
// OrgType.ControlUnit 管理单元
// OrgType.CostCenter 成本中心
// OrgType.HRO HR组织
// OrgType.NONE 无组织属性
// OrgType.ProfitCenter 利润中心
// OrgType.Purchase 采购组织
// OrgType.Quality 质检组织
// OrgType.Sale 销售组织
// OrgType.Storage 库存组织
// OrgType.Transport 发运组织
// OrgType.UnionDebt 合并范围
return OrgType.Company;
}
public KDBizPromptBox getMainOrgUnit() {
// 主业务组织的F7控件
super.getMainOrgUnit();
return prmtcompany;
}
//增加法人过滤条件
CompanyOrgUnitInfo currentFIUnit = SysContext.getSysContext().getCurrentFIUnit();
EntityViewInfo view=new EntityViewInfo();
FilterInfo filter =new FilterInfo();
filter.getFilterItems().add(new FilterItemInfo("CU.id",currentFIUnit.getCU().getId().toString(),CompareType.EQUALS));
view.setFilter(filter);
prmtpayerAccountBank.setEntityViewInfo(view);
prmtpayerAccountBank.getQueryAgent().resetRuntimeEntityView();
/**
* 栏位校验
*/
public void validateRequiredEntry() {
//“确定”弹窗 import com.kingdee.eas.util.client.MsgBox;
if (this.kdtE1.getRowCount() < 1) {
MsgBox.showInfo("至少存在一条分录!");
SysUtil.abort();
}
//“确定、取消”弹窗 import com.kingdee.eas.util.client.MsgBox;
int showConfirm2 = MsgBox.showConfirm2("以下单据:" + numbers.toString() + " 已经生成应收单,将不会再批量生成。其他单据若要批量生成应收单,请点击“确定”。");// 确定0 取消2
if (showConfirm2 == 2) {
return;
}
//txt文本框获得所填写的值
String invoiceNoStr = this.txtoriginInvoiceNo.getStringValue();
if (invoiceNoStr == null || invoiceNoStr == "") {
MsgBox.showInfo("原发票号码,不能为空!");
SysUtil.abort();
} else {
String regEx = "[0-9]{8}";
Pattern pattern = Pattern.compile(regEx);
Matcher matcher = pattern.matcher(invoiceNoStr);
if (!matcher.matches()) {
MsgBox.showInfo("请输入8位的发票号码!");
SysUtil.abort();
}
}
//获得下拉选择框的文字内容
if (this.certifications.getSelectedItem() == null) {
MsgBox.showInfo("认证情况,不能为空!");
SysUtil.abort();
}
//获得下拉选择框的枚举值(int 类型)
if (this.certifications.getSelectedIndex() == 0) {
if (this.txtredInfoTableNo.getStringValue() == null || this.txtredInfoTableNo.getStringValue().equals("")) {
MsgBox.showInfo("认证情况为已认证时,红字信息表编码不能为空!");
SysUtil.abort();
}
}
if (this.prmtacquiringNames.getValue() == null) {
MsgBox.showInfo("购方名称,不能为空!");
SysUtil.abort();
}
//操作分录
for (int i = 0; i < this.kdtEntry.getRowCount(); i++) {
IRow row = this.kdtEntry.getRow(i);
if (row.getCell("amount").getValue() != null) {
BigDecimal value = new BigDecimal(row.getCell("amount").getValue().toString());
if (value.intValue() < 0) {
MsgBox.showInfo("第" + (i + 1) + "行分录数量不能小于0!");
SysUtil.abort();
}
if (row.getCell("originalQuantity").getValue() != null && row.getCell("materialName").getValue() != null) {
BigDecimal oldValue = new BigDecimal(row.getCell("originalQuantity").getValue().toString());
if (value.intValue() > oldValue.intValue()) {
MsgBox.showInfo("第" + (i + 1) + "行分录数量不能大于原分录数量" + oldValue);
SysUtil.abort();
}
}
}
}
}
/**
* 打开页面时加载
*/
@Override
public void onLoad() throws Exception {
super.onLoad();
//禁用编辑
this.txtnumber.setEditable(false);
this.txtnumber.setEnable(false);
//给分录设置标题
this.kdtE1_detailPanel.setTitle("分录");
//给文本框增加获得和失去焦点事件
this.txtreceivedOrderNo.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
try {
addEntryByReceiveNumber(e);
} catch (EASBizException e1) {
e1.printStackTrace();
} catch (BOSException e1) {
e1.printStackTrace();
}
}
});
//给日期选择框添加监听事件
this.pkplanPayDate.addDataChangeListener(new DataChangeListener() {
@Override
public void dataChanged(DataChangeEvent arg0) {
txtfinancePayLot.setStringValue(sdf.format((Date) arg0.getNewValue()));
}
});
//给选择提示框增加监听事件
this.prmtacquiringNames.addDataChangeListener(new DataChangeListener() {
public void dataChanged(DataChangeEvent e) {
boolean flag = (e.getOldValue() != null && e.getNewValue() == null) || (e.getOldValue() == null && e.getNewValue() != null) || (e.getOldValue() != null && e.getNewValue() != null && !e.getOldValue().toString().equals(e.getNewValue().toString()));
if (flag) {
try {
acquiringNameFillData();
} catch (BOSException e1) {
e1.printStackTrace();
}
}
}
});
//给分录增加监听事件
this.kdtE1.addKDTEditListener(new KDTEditAdapter() {
public void editStarting(KDTEditEvent e) {
super.editStarting(e);
try {
setEntryValueByMaterial(e);
} catch (EASBizException e1) {
e1.printStackTrace();
} catch (BOSException e1) {
e1.printStackTrace();
}
}
public void editStopped(KDTEditEvent e) {
super.editStopped(e);
try {
setEntryValueByMaterial(e);
} catch (EASBizException e1) {
e1.printStackTrace();
} catch (BOSException e1) {
e1.printStackTrace();
}
}
});
}
//设置必填背景色
txtredReceiveNumber.setCustomBackgroundColor(new Color(252, 251, 223));
footRow.getStyleAttributes().setBackground(new Color(252, 251, 223));
protected void acquiringNameFillData() throws BOSException {
if (this.prmtacquiringNames.getData() != null) {
// Object value = this.prmtacquiringNames.getValue();
CustomerInfo customerInfo = (CustomerInfo) this.prmtacquiringNames.getData();
CoreBaseCollection coreBaseC = CustomerTaxFactory.getRemoteInstance().getCollection("select telephone, bank where customer.id = '" + customerInfo.getId().toString() + "'");
if (coreBaseC != null && coreBaseC.size() > 0) {
CustomerTaxInfo customerTaxInfo = (CustomerTaxInfo) coreBaseC.get(0);
try {
if (customerTaxInfo.getBank() != null) {
BOSUuid id = customerTaxInfo.getBank().getId();
//通过UUID获得对象
BankInfo bankInfo = BankFactory.getRemoteInstance().getBankInfo(new ObjectUuidPK(id));
this.txtbank.setStringValue(bankInfo.getName());
}
} catch (EASBizException e) {
e.printStackTrace();
}
this.txtacquiringTaxNo.setStringValue(customerTaxInfo.getCompantTFN());
}
}
}
private void setEntryValueByMaterial(KDTEditEvent e) throws EASBizException, BOSException {
this.kdtE1.getColumn("modes").getStyleAttributes().setLocked(true);
this.kdtE1.getRow(i).getCell("modes").getStyleAttributes().setLocked(true);
if (kdtE1.getRow(i).getCell("materialNames").getValue() != null) {
MaterialInfo materialInfo = (MaterialInfo) kdtE1.getRow(i).getCell("materialNames").getValue();
materialInfo = MaterialFactory.getRemoteInstance().getMaterialInfo(new ObjectUuidPK(materialInfo.getId()));
//二开字段获取对象的值
kdtE1.getRow(i).getCell("taxRate").setValue(materialInfo.get("taxNum"));
kdtE1.getRow(i).getCell("modes").setValue(materialInfo.getModel());
}
//BigDecimal 用法
if (kdtE1.getRow(i).getCell("taxRate").getValue() != null && kdtE1.getRow(i).getCell("money").getValue() != null) {
BigDecimal money = new BigDecimal(kdtE1.getRow(i).getCell("money").getValue().toString());
BigDecimal taxRate = new BigDecimal(kdtE1.getRow(i).getCell("taxRate").getValue().toString()).multiply(new BigDecimal("0.01"));
BigDecimal taxSum = money.multiply(taxRate);
taxSum = taxSum.setScale(2, BigDecimal.ROUND_HALF_UP);
kdtE1.getRow(i).getCell("taxSum").setValue(taxSum);
}
this.calculateValue();
}
public void calculateValue() {
IRow footRow = this.kdtE1.getFootManager().getFootRow(0);
BigDecimal totalMoney = new BigDecimal(0);
BigDecimal totalTaxSum = new BigDecimal(0);
for (int i = 0; i < this.kdtE1.getRowCount(); i++) {
if (this.kdtE1.getRow(i).getCell("money").getValue() != null) {
BigDecimal money = new BigDecimal(this.kdtE1.getRow(i).getCell("money").getValue().toString());
totalMoney = totalMoney.add(money);
}
}
}
protected void addEntryByReceiveNumber(FocusEvent e) throws EASBizException, BOSException {
this.kdtE1.removeRows();
if (this.txtreceivedOrderNo.getText() != null) {
EntityViewInfo view = new EntityViewInfo();
FilterInfo filter = new FilterInfo();
filter.getFilterItems().add(new FilterItemInfo("number", txtreceivedOrderNo.getText(), CompareType.EQUALS));
view.setFilter(filter);
OtherBillCollection collection = OtherBillFactory.getRemoteInstance().getOtherBillCollection(view);
if (collection.size() > 0) {
OtherBillInfo otherBillInfo = collection.get(0);
}
}
}
/**
* 生成付款单时批量维护字段:付款方式、付款科目、付款账户、结算方式
*/
public void actionCreateTo_actionPerformed(ActionEvent e) throws Exception {
ArrayList otherBillIds = getSelectedIdValues();
if (otherBillIds == null || otherBillIds.size() == 0) {
MsgBox.showWarning("请先选择记录行!");
return;
}
List<String> oldPaymentIds = new ArrayList<String>();
for(int k = 0; k < otherBillIds.size(); k++) {
String otherBillId = otherBillIds.get(k).toString();
List<String> destObjectIds = getDestObjectId("48DA3A71", "40284E81", otherBillId);
oldPaymentIds.addAll(destObjectIds);
}
super.actionCreateTo_actionPerformed(e);
List<String> newPaymentIds = new ArrayList<String>();
for(int k = 0; k < otherBillIds.size(); k++) {
String otherBillId = otherBillIds.get(k).toString();
List<String> destObjectIds = getDestObjectId("48DA3A71", "40284E81", otherBillId);
for(int j = 0; j < destObjectIds.size(); j++) {
String destObjectId = destObjectIds.get(j);
if(oldPaymentIds == null || !oldPaymentIds.contains(destObjectId)) {
newPaymentIds.add(destObjectId);
}
}
}
if(newPaymentIds.size() > 0) {
UIContext uiContext = new UIContext(this);
prepareUIContext(uiContext, e);
IUIWindow paymentUI = UIFactory.createUIFactory(UIFactoryName.MODEL).create("com.kingdee.eas.custom.paymentbilldialog.client.PaymentInformationEditUI", uiContext, null, OprtState.ADDNEW);
getUIContext().put("newPaymentIds", newPaymentIds);
paymentUI.show();
}
}
/**
* 通过源单据得到新生成单据的ID或者判断某单据是否有下游单据
*/
public static List<String> getDestObjectId(String srcEntityName, String destEntityName, String srcObjectId) throws BOSException, EASBizException {
List<String> destObjectIds = new ArrayList<String>();
FilterInfo filterInfo = new FilterInfo();
filterInfo.getFilterItems().add(new FilterItemInfo("srcEntityID", srcEntityName, CompareType.EQUALS));
filterInfo.getFilterItems().add(new FilterItemInfo("destEntityID", destEntityName, CompareType.EQUALS));
filterInfo.getFilterItems().add(new FilterItemInfo("srcObjectID", srcObjectId, CompareType.EQUALS));
EntityViewInfo viewInfo = new EntityViewInfo();
viewInfo.setFilter(filterInfo);
BOTRelationCollection collec;
try {
collec = BOTRelationFactory.getRemoteInstance().getCollection(viewInfo);
for(int i = 0; i < collec.size(); i++) {
BOTRelationInfo relationInfo = collec.get(i);
if(relationInfo != null) {
destObjectIds.add(relationInfo.getDestObjectID());
}
}
} catch (Exception e) {
e.printStackTrace();
throw new EASBizException(new NumericExceptionSubItem("10000", e.toString()));
}
return destObjectIds;
}
/**
* 操作选择的块
*/
ArrayList blocks = this.tblMain.getSelectManager().getBlocks();
for (int i = 0; i < blocks.size(); i++) {
KDTSelectBlock block = (KDTSelectBlock) blocks.get(i);
int top = block.getTop();
int bottom = block.getBottom();
for (int rowIndex = top; rowIndex <= bottom; ++rowIndex) {
ICell cell = this.tblMain.getRow(rowIndex).getCell(getKeyFieldName());
if ((cell != null) && (cell.getValue() != null)) {
String id = this.tblMain.getRow(rowIndex).getCell(getKeyFieldName()).getValue().toString();
// int countBlocks = 0;
if (ids.contains(id)) {
// 判断块首
if (rowIndex == block.getTop()) {
// 删除块
if (block.getTop() == block.getBottom()) {
blocks.remove(block);
i--;
} else {
block.setTop(rowIndex + 1);
}
// 判断块尾
} else if (rowIndex == block.getBottom()) {
block.setBottom(rowIndex - 1);
// 判断块中间
} else {
block.setBottom(rowIndex - 1);
// 中间块新增一个块
block = new KDTSelectBlock();
block.setMode(2);
block.setTop(rowIndex + 1);
block.setBottom(bottom);
blocks.add(block);
}
}
}
}
}
// 得到下一个星期四 Calendar calendar = Calendar.getInstance();
calendar.setTime(planPayDate);
int nowDayNum = calendar.get(Calendar.DAY_OF_WEEK);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
if (nowDayNum == 1 || nowDayNum > 4) {
calendar.add(Calendar.DATE, 7);
}
planPayDate = calendar.getTime();
金蝶生成UUID
select newbosid('409D7D39')
}
// 设置付款条件根据供应商付款条件过滤 提示选择框设置过滤
this.prmtPayCondition.addSelectorListener(new SelectorListener() {
@Override
public void willShow(SelectorEvent arg0) {
SupplierInfo supplierInfo = (SupplierInfo) prmtAccountCussentF7.getValue();
// 申请组织,收货组织,库存组织
CompanyOrgUnitInfo cou = null;// 财务组织
IOrgUnitRelation iOrgRelation = null;
try {
iOrgRelation = OrgUnitRelationFactory.getRemoteInstance();
} catch (BOSException e) {
e.printStackTrace();
}
PurchaseOrgUnitInfo purchaseOrgUnitInfo = (PurchaseOrgUnitInfo) prmtPurOrgUnit.getValue();
OrgUnitCollection orgCollection = null;
try {
if (purchaseOrgUnitInfo != null) {
orgCollection = iOrgRelation.getToUnit(purchaseOrgUnitInfo.getId().toString(), 3, 1);
if ((orgCollection != null) && (orgCollection.size() > 0)) {
cou = (CompanyOrgUnitInfo) orgCollection.get(0);
} else {
MsgBox.showInfo("采购组织委托的财务组织为空!");
SysUtil.abort();
}
} else {
cou = (CompanyOrgUnitInfo) prmtCompanyOrgUnit.getValue();
}
} catch (EASBizException e) {
e.printStackTrace();
} catch (BOSException e) {
e.printStackTrace();
}
EntityViewInfo viewInfo = new EntityViewInfo();
FilterInfo filter = new FilterInfo();
filter.getFilterItems().add(new FilterItemInfo("supplier.id", supplierInfo.getId().toString(), CompareType.EQUALS));
filter.getFilterItems().add(new FilterItemInfo("companyOrgUnit.id", cou.getId().toString(), CompareType.EQUALS));
viewInfo.setFilter(filter);
try {
SupplierCompanyInfoCollection supplierCompanyInfoCollection = SupplierCompanyInfoFactory.getRemoteInstance().getSupplierCompanyInfoCollection(viewInfo);
if (supplierCompanyInfoCollection.size() > 0) {
SupplierCompanyInfoInfo supplierCompanyInfoInfo = supplierCompanyInfoCollection.get(0);
String sql = "select CFPaymentTremConll payCId from CT_MS_Paymentconllection where FParentID='" + supplierCompanyInfoInfo.getId().toString() + "'";
IRowSet executeQuery = SQLExecutorFactory.getRemoteInstance(sql).executeSQL();
HashSet<String> set = new HashSet<String>();
ArrayList list = new ArrayList();
while (executeQuery.next()) {
String payCId = executeQuery.getString("payCId");
list.add(payCId);
set.add(payCId);
}
/* set.add("lbYAAAAAshCu4Nue"); */// M0000
String sql1 = "select FID from T_BD_PayCondition where FNumber in ('F001','F002')";
IRowSet executeQuery1 = SQLExecutorFactory.getRemoteInstance(sql1).executeSQL();
ArrayList list1 = new ArrayList();
while (executeQuery1.next()) {
String payCId = executeQuery1.getString("FID");
list1.add(payCId);
set.add(payCId);
}
/*
* set.add("lbYAAAAp232u4Nue");
* set.add("lbYAAAAp23+u4Nue");
*/
if (supplierCompanyInfoInfo.getPayCondition() != null && !"".equals(supplierCompanyInfoInfo.getPayCondition())) {
set.add(supplierCompanyInfoInfo.getPayCondition().getId().toString());
}
if (set.size() > 0) {
EntityViewInfo companyView1 = new EntityViewInfo();
FilterInfo companyFilter1 = new FilterInfo();
companyFilter1.getFilterItems().add(new FilterItemInfo("id", set, CompareType.INCLUDE));
companyView1.setFilter(companyFilter1);
prmtPayCondition.setEntityViewInfo(companyView1);
prmtPayCondition.getQueryAgent().resetRuntimeEntityView();
}
}
} catch (BOSException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
});
//SaleOrderEditUICTEx 有多种 submit 提交校验入口
//DEP动态拓展增加白名单
Bos\workspace\Project_20180802\runtime\server\properties\dep\whitelist
//使用editUI选择快捷键
alt+shift+d
EditUI归纳
最新推荐文章于 2020-04-16 20:51:07 发布