通用付款事项代码更新

This commit is contained in:
zengweihai 2024-07-02 15:16:41 +08:00
parent b79ec03395
commit df016beeb1
1 changed files with 61 additions and 48 deletions

View File

@ -41,16 +41,20 @@ public class CommonBillOsPaymentBillFormPlugin extends AbstractBillPlugIn implem
@Override @Override
public void registerListener(EventObject e) { public void registerListener(EventObject e) {
super.registerListener(e); super.registerListener(e);
BasedataEdit edit = this.getView().getControl("shkd_firstpayment");
if (edit != null){
edit.addBeforeF7SelectListener(this);
}
if (entityName.equals("员工借款单") || entityName.equals("员工还款单")){ if (entityName.equals("员工借款单") || entityName.equals("员工还款单")){
BasedataEdit edit = this.getView().getControl("shkd_paymentitem"); BasedataEdit edit1 = this.getView().getControl("shkd_paymentitem");
if (edit != null){ if (edit1 != null){
edit.addBeforeF7SelectListener(this); edit1.addBeforeF7SelectListener(this);
} }
logger.info("此单据类型为员工借款单或员工还款单"); logger.info("此单据类型为员工借款单或员工还款单");
}else { }else {
BasedataEdit edit = this.getView().getControl("shkd_payment"); BasedataEdit edit1 = this.getView().getControl("shkd_payment");
if (edit != null){ if (edit1 != null){
edit.addBeforeF7SelectListener(this); edit1.addBeforeF7SelectListener(this);
} }
logger.info("此单据类型不为员工借款单、员工还款单"); logger.info("此单据类型不为员工借款单、员工还款单");
} }
@ -60,70 +64,79 @@ public class CommonBillOsPaymentBillFormPlugin extends AbstractBillPlugIn implem
public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) { public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) {
String name = beforeF7SelectEvent.getProperty().getName(); String name = beforeF7SelectEvent.getProperty().getName();
if (name.equals("shkd_payment") || name.equals("shkd_paymentitem")){ if (name.equals("shkd_payment") || name.equals("shkd_paymentitem")){
DynamicObject shkd_firstpayment = (DynamicObject) this.getModel().getValue("shkd_firstpayment");//一级事项
//设置付款事项约束
if (shkd_firstpayment != null){//当一级事项字段不为空时开始过滤
logger.info("此时一级付款事项不为空,开始执行过滤逻辑"+shkd_firstpayment.toString());
ArrayList<Object> paymentNumbers = new ArrayList<>();
String paymentNumber = shkd_firstpayment.getString("number");//由于辅助资料包含的付款事项可能存在非叶子节点的情况查询对象的下级叶子对象
logger.info("开始查询该付款事项及其下游叶子事项");
String sql_number = "%"+paymentNumber+"%";
QFilter QFSon = new QFilter("longnumber", QCP.like, sql_number);
QFSon.and("isleaf",QCP.equals,"1");//是叶子节点
DynamicObject[] datum = BusinessDataServiceHelper.load("bos_assistantdata_detail", "id,number,longnumber,level", QFSon.toArray());
for (DynamicObject data : datum) {
String longnumber = data.getString("longnumber");//长编码
logger.info("该付款事项长编码为"+longnumber);
if (data.getInt("level")>1){
int index = longnumber.indexOf("!");
String substr = longnumber.substring(0, index);
if (substr.equals(paymentNumber)){
paymentNumbers.add(data.getString("number"));
}
}else {
if (longnumber.equals(paymentNumber)){
paymentNumbers.add(paymentNumber);
}
}
}
if (!paymentNumbers.isEmpty()){
logger.info("付款事项编码集合为"+paymentNumbers.toString());
QFilter qF = new QFilter("number", QCP.in,paymentNumbers);
ListShowParameter formShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
formShowParameter.getListFilterParameter().setFilter(qF);
}
}else {
beforeF7SelectEvent.setCancel(true);
this.getView().showTipNotification("请先选择付款事项");
}
} else if ("shkd_firstpayment".equals(name)) {//一级事项过滤
String billType = ""; String billType = "";
//赋值单据类型 //赋值单据类型
if (entityName.equals("对公报销单")){ if (entityName.equals("对公报销单")) {
DynamicObject shkd_billtype = (DynamicObject) this.getModel().getValue("shkd_billtypefield"); DynamicObject shkd_billtype = (DynamicObject) this.getModel().getValue("shkd_billtypefield");
billType = shkd_billtype.getString("name"); billType = shkd_billtype.getString("name");
logger.info("此单据为对公报销单,额外需取单据类型值,单据类型字段编码为shkd_billtypefield___"+billType); logger.info("此单据为对公报销单,额外需取单据类型值,单据类型字段编码为shkd_billtypefield___" + billType);
} else if (entityName.equals("预付单")) { } else if (entityName.equals("预付单")) {
DynamicObject shkd_billtype = (DynamicObject) this.getModel().getValue("stdbilltype"); DynamicObject shkd_billtype = (DynamicObject) this.getModel().getValue("stdbilltype");
billType = shkd_billtype.getString("name"); billType = shkd_billtype.getString("name");
logger.info("此单据为预付单,额外需取单据类型值,单据类型字段编码为stdbilltype___"+billType); logger.info("此单据为预付单,额外需取单据类型值,单据类型字段编码为stdbilltype___" + billType);
}else { } else {
billType = entityName; billType = entityName;
logger.info("单据类型就是单据名称"); logger.info("单据类型就是单据名称");
} }
//设置付款事项约束 //设置付款事项约束
if (billType.length() > 0){//当单据类型字段不为空时 if (billType.length() > 0) {//当单据类型字段不为空时
QFilter QF = new QFilter("shkd_typename", QCP.equals, billType); QFilter QF = new QFilter("shkd_typename", QCP.equals, billType);
DynamicObject org = (DynamicObject) this.getModel().getValue("org"); DynamicObject org = (DynamicObject) this.getModel().getValue("org");
String orgName = org.getString("name"); String orgName = org.getString("name");
QF.and("shkd_org.name",QCP.equals,orgName); QF.and("shkd_org.name",QCP.equals,orgName);
QF.and("enable",QCP.equals,"1");//使用状态为可用 QF.and("enable",QCP.equals,"1");//使用状态为可用
logger.info("过滤条件单据类型为"+billType+",组织名称为:"+orgName); logger.info("过滤条件单据类型为"+billType+",组织名称为:"+orgName);
ArrayList<Object> paymentNumbers = new ArrayList<>();
HashSet<Object> sets = new HashSet<Object>(); HashSet<Object> sets = new HashSet<Object>();
DynamicObject[] loads = BusinessDataServiceHelper.load("shkd_paymatter", "id,shkd_paymatterinfo.number", QF.toArray()); DynamicObject[] loads = BusinessDataServiceHelper.load("shkd_paymatter", "id,shkd_paymatterinfo.number", QF.toArray());
for (DynamicObject load : loads) { for (DynamicObject load : loads) {
String paymentNumber = load.getString("shkd_paymatterinfo.number");//由于辅助资料包含的付款事项可能存在非叶子节点的情况查询对象的下级叶子对象 String paymentNumber = load.getString("shkd_paymatterinfo.number");//获取编码添加进集合
logger.info("开始查询该付款事项及其下游叶子事项"); sets.add(paymentNumber);
String sql_number = "%"+paymentNumber+"%";
QFilter QFSon = new QFilter("longnumber", QCP.like, sql_number);
QFSon.and("isleaf",QCP.equals,"1");//是叶子节点
DynamicObject[] datum = BusinessDataServiceHelper.load("bos_assistantdata_detail", "id,number,longnumber,level", QFSon.toArray());
for (DynamicObject data : datum) {
String longnumber = data.getString("longnumber");//长编码
String[] split = longnumber.split("!");
for (String str : split) {
sets.add(str);
}
logger.info("该付款事项长编码为"+longnumber);
if (data.getInt("level")>1){
int index = longnumber.indexOf("!");
String substr = longnumber.substring(0, index);
if (substr.equals(paymentNumber)){
paymentNumbers.add(data.getString("number"));
}
}else {
if (longnumber.equals(paymentNumber)){
paymentNumbers.add(paymentNumber);
}
}
}
} }
if (!paymentNumbers.isEmpty()){ if (!sets.isEmpty()){
logger.info("付款事项编码集合为"+paymentNumbers.toString());
QFilter qF = new QFilter("number", QCP.in,paymentNumbers);
ListShowParameter formShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter(); ListShowParameter formShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
QFilter Qf= new QFilter("number", QCP.in, sets); QFilter payment_qf= new QFilter("number", QCP.in, sets);
logger.info("付款事项编码树集合为"+sets.toString()); payment_qf.or("shkd_isshare",QCP.equals,"1");
formShowParameter.getTreeFilterParameter().getQFilters().add(new QFilter("number", QCP.in, sets)); payment_qf.and("enable",QCP.equals,"1");
formShowParameter.getListFilterParameter().setFilter(qF);
List<QFilter> qFilters = formShowParameter.getTreeFilterParameter().getQFilters(); formShowParameter.getListFilterParameter().setFilter(payment_qf);
logger.info("付款事项编码树过滤条件为"+qFilters.toString());
}else { }else {
beforeF7SelectEvent.setCancel(true); beforeF7SelectEvent.setCancel(true);
this.getView().showTipNotification("此类型单据无关联付款事项"); this.getView().showTipNotification("此类型单据无关联付款事项");