费用申请单下推费用报销单触发获取费用标准逻辑-龚宇杰
This commit is contained in:
parent
a53916fda1
commit
37f456ac38
|
@ -5,6 +5,7 @@ import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.entity.datamodel.IDataModel;
|
import kd.bos.entity.datamodel.IDataModel;
|
||||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||||
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||||
import kd.bos.logging.Log;
|
import kd.bos.logging.Log;
|
||||||
import kd.bos.logging.LogFactory;
|
import kd.bos.logging.LogFactory;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
|
@ -27,6 +28,53 @@ public class GetExpenseStandardPlugin extends AbstractBillPlugIn implements Plug
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(GetExpenseStandardPlugin.class);
|
private static final Log log = LogFactory.getLog(GetExpenseStandardPlugin.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterBindData(EventObject e) {
|
||||||
|
IDataModel model = this.getModel();
|
||||||
|
boolean pushChanged = model.getDataEntity().getDataEntityState().isPushChanged();
|
||||||
|
if (pushChanged) {
|
||||||
|
DynamicObject bill = model.getDataEntity(true);
|
||||||
|
|
||||||
|
String reimburseType = bill.getString("zf47_reimburse_type");// 报账类型
|
||||||
|
if (reimburseType == null || reimburseType.isEmpty()) return;
|
||||||
|
|
||||||
|
DynamicObjectCollection expenseEntries = bill.getDynamicObjectCollection("expenseentryentity");// 费用明细分录
|
||||||
|
if (expenseEntries == null || expenseEntries.isEmpty()) return;
|
||||||
|
|
||||||
|
//获取 监听值变更分录字段集合
|
||||||
|
QFilter entryParamQF = new QFilter("number", QCP.equals, "ExpenseListeningEntryFields");
|
||||||
|
DynamicObject entryParam = BusinessDataServiceHelper.loadSingle("zf47_system_params", "zf47_val", entryParamQF.toArray());
|
||||||
|
if (entryParam == null) {
|
||||||
|
log.warn("GetExpenseStandardPlugin:ExpenseListeningEntryFields参数未配置");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String entryVal = entryParam.getString("zf47_val");
|
||||||
|
ArrayList<String> entryFields;
|
||||||
|
if (entryVal.contains(",")) {
|
||||||
|
String[] splits = entryVal.split(",");
|
||||||
|
entryFields = new ArrayList<>(Arrays.asList(splits));
|
||||||
|
} else {
|
||||||
|
entryFields = new ArrayList<>(Collections.singletonList(entryVal));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < expenseEntries.size(); i++) {
|
||||||
|
DynamicObject expenseEntry = expenseEntries.get(i);
|
||||||
|
DynamicObject expenseItem = expenseEntry.getDynamicObject("expenseitem");
|
||||||
|
if (expenseItem != null) {
|
||||||
|
HashMap<String, Object> result = getExpenseStandard(entryFields, reimburseType, expenseItem.getString("number"), expenseEntry);
|
||||||
|
if (result != null && !result.isEmpty()) {
|
||||||
|
for (String field : result.keySet()) {
|
||||||
|
model.setValue(field, result.get(field), i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
model.setValue("zf47_expense_standards", BigDecimal.ZERO, i);
|
||||||
|
model.setValue("zf47_standard_unit", "", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChanged(PropertyChangedArgs e) {
|
public void propertyChanged(PropertyChangedArgs e) {
|
||||||
IDataModel model = this.getModel();
|
IDataModel model = this.getModel();
|
||||||
|
@ -71,7 +119,6 @@ public class GetExpenseStandardPlugin extends AbstractBillPlugIn implements Plug
|
||||||
}
|
}
|
||||||
|
|
||||||
String changeName = e.getProperty().getName();
|
String changeName = e.getProperty().getName();
|
||||||
// log.info("GetExpenseStandardPlugin:值更新字段标识(" + changeName + ")");
|
|
||||||
if (headFields.contains(changeName)) {//值更新字段在单据头
|
if (headFields.contains(changeName)) {//值更新字段在单据头
|
||||||
for (int i = 0; i < expenseEntries.size(); i++) {
|
for (int i = 0; i < expenseEntries.size(); i++) {
|
||||||
DynamicObject expenseEntry = expenseEntries.get(i);
|
DynamicObject expenseEntry = expenseEntries.get(i);
|
||||||
|
@ -103,9 +150,7 @@ public class GetExpenseStandardPlugin extends AbstractBillPlugIn implements Plug
|
||||||
model.setValue("zf47_standard_unit", "", rowIndex);
|
model.setValue("zf47_standard_unit", "", rowIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}/* else {
|
}
|
||||||
log.warn("GetExpenseStandardPlugin:值更新字段(" + changeName + ")不在HeadFields(" + headFields + ")、EntryFields(" + entryFields + ")");
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue