NC参照 根据名称转换为主键值,如部门、人员等参照根据部门名称、人员名称获取对应的主键值
private BillCardPanel getEditBillCardPanel() {
return getEditor().getBillCardPanel();
}
private BillData getEditorBillData() {
return this.getEditor().getBillCardPanel().getBillData();
}
public ArapBillImportForm getEditor() {
return (ArapBillImportForm) this.getBean(IArapImportConstant.BIZCATOR_EDITOR_BEAN_NAME);
}
String pkorg = (String) headVO.getAttributeValue(IArapImportConstant.IMPORT_PK_ORG);
String[] attributeNames = headVO.getAttributeNames();
Object attributeValue;
for (String key : attributeNames) {
attributeValue = headVO.getAttributeValue(key);
}
BillItem headItem = getEditBillCardPanel().getHeadItem(key);
CustBankaccDefaultRefModel CustModel = (CustBankaccDefaultRefModel) ((UIRefPane) headItem.getComponent()).getRefModel();
CustModel.setPk_cust((String) headVO.getAttributeValue(IBillFieldGet.CUSTOMER));
((UIRefPane) headItem.getComponent()).setBlurValue(String.valueOf(attributeValue));
attributeValue = ((UIRefPane) headItem.getComponent()).getRefPK();
String[] attributeNames = bodyVO.getAttributeNames();
if (attributeNames != null) {
for (String strKey : attributeNames) {
Object attributeValue = vo.getAttributeValue(strKey);
if (attributeValue != null) {
BillItem bodyItem = getEditBillCardPanel().getBodyItem(strKey);
convert2RefPK(bodyItem, attributeValue, pkorg);
}
}
}
public static String convert2RefPK(BillItem bodyItem, String value, String pk_org) {
if (StringUtil.isEmpty(value)) {
return value;
}
if (IBillFieldGet.SCOMMENT.equals(bodyItem.getKey()) || IBillFieldGet.CHECKNO.equals(bodyItem.getKey()))
return value;
String docpk = null;
JComponent component = bodyItem.getComponent();
((UIRefPane) component).setPk_org(pk_org);
if (component != null && component instanceof UIRefPane) {
if (bodyItem.getKey().equals(IBillFieldGet.PK_DEPTID) || bodyItem.getKey().equals(IBillFieldGet.PU_DEPTID) || bodyItem.getKey().equals(IBillFieldGet.SO_DEPTID)) {
DeptDefaultNCRefModel deptModel = (DeptDefaultNCRefModel) ((UIRefPane) component).getRefModel();
deptModel.setBusifuncode("all");
((UIRefPane) component).setBlurValue(value);
docpk = ((UIRefPane) component).getRefPK();
if (docpk == null) {
docpk = dealMultiOrgValue(pk_org, value, component);
if (docpk != null)
return docpk;
}
} else if (bodyItem.getKey().equals(IBillFieldGet.PK_DEPTID_V) || bodyItem.getKey().equals(IBillFieldGet.PU_DEPTID_V) || bodyItem.getKey().equals(IBillFieldGet.SO_DEPTID_V)) {
DeptVersionDefaultNCRefModel deptModel = (DeptVersionDefaultNCRefModel) ((UIRefPane) component).getRefModel();
deptModel.setBusifuncode("all");
((UIRefPane) component).setBlurValue(value);
docpk = ((UIRefPane) component).getRefPK();
if (docpk == null) {
docpk = dealMultiOrgValue(pk_org, value, component);
if (docpk != null)
return docpk;
}
} else if (bodyItem.getKey().equals(IBillFieldGet.PK_PSNDOC) || bodyItem.getKey().equals(IBillFieldGet.SO_PSNDOC) || bodyItem.getKey().equals(IBillFieldGet.PU_PSNDOC)) {
PsndocDefaultNCRefModel psnModel = (PsndocDefaultNCRefModel) ((UIRefPane) component).getRefModel();
psnModel.setBusifuncode("all");
} else if (bodyItem.getKey().equals(IBillFieldGet.SUBJCODE)) {
if (value.indexOf("\\") > 0) {
value = value.substring(0, value.indexOf("\\"));
}
}
((UIRefPane) component).setBlurValue(value);
docpk = ((UIRefPane) component).getRefPK();
}
if (docpk == null) {
StringBuffer sbException = new StringBuffer();
sbException.append(bodyItem.getName()).append(":[").append(value).append("]不存在!");
throw new BusinessRuntimeException(sbException.toString());
}
return docpk;
}
private static String dealMultiOrgValue(String pk_org, String value, JComponent component) {
String docpk = null;
try {
Set<String> set = OrgConsignationUtils.getOrgConsignationList(pk_org);
for (String org : set) {
((UIRefPane) component).setPk_org(org);
((UIRefPane) component).setBlurValue(value);
docpk = ((UIRefPane) component).getRefPK();
if (docpk != null)
break;
}
} catch (Exception e) {
throw new BusinessRuntimeException(e.getMessage(), e);
}
return docpk;
}