通用付款事项代码更新

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