|
@@ -1,12 +1,62 @@
|
|
|
package fi.em.opplugin;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
|
public class PublicExpenseOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
+ private static String nckd_orgamount = "nckd_orgamount";
|
|
|
|
|
|
+ //对公费用报销单
|
|
|
@Override
|
|
|
public void beginOperationTransaction(BeginOperationTransactionArgs e) {
|
|
|
+ //获取当前操作单据数组
|
|
|
+ DynamicObject[] dynamicObjects = e.getDataEntities();
|
|
|
+ for (int i = 0; i < dynamicObjects.length; i++) {
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ //当前单头数据包
|
|
|
+ DynamicObject info = BusinessDataServiceHelper.loadSingle(dynamicObjects[i].getPkValue(), dynamicObjects[i].getDynamicObjectType().getName());
|
|
|
+ //获取费用承担公司
|
|
|
+ DynamicObject costcompany = info.getDynamicObject("costcompany");
|
|
|
+ //公司编码
|
|
|
+ String number = costcompany.getString("number");
|
|
|
+ //公司id
|
|
|
+ long id = costcompany.getLong("id");
|
|
|
+ //循环费用明细分录
|
|
|
+ for (DynamicObject entryentity : info.getDynamicObjectCollection("expenseentryentity")) {
|
|
|
+ //取当前循环费用明细分录的报销金额
|
|
|
+ BigDecimal expenseamount = entryentity.getBigDecimal("expenseamount");
|
|
|
+ //金额标准查询条件
|
|
|
+ QFilter nckd_orgamountFilter = new QFilter("nckd_orgfield.number", QCP.equals,number);
|
|
|
+ nckd_orgamountFilter.and("nckd_combofield", QCP.equals,"A");
|
|
|
+ DynamicObject[] nckd_orgamountaccount = BusinessDataServiceHelper.load(nckd_orgamount,"id,nckd_orgfield,nckd_combofield",new QFilter[] {nckd_orgamountFilter});
|
|
|
+ //判断组织是否维护金额,没有则查询集团金额
|
|
|
+ if(nckd_orgamountaccount.length == 0){
|
|
|
+ nckd_orgamountFilter = new QFilter("nckd_orgfield.number", QCP.equals,"jxyh");
|
|
|
+ nckd_orgamountFilter.and("nckd_combofield", QCP.equals,"A");
|
|
|
+ nckd_orgamountaccount = BusinessDataServiceHelper.load(nckd_orgamount,"id,nckd_orgfield,nckd_combofield",new QFilter[] {nckd_orgamountFilter});
|
|
|
+ }
|
|
|
+ //循环数组获取组织金额标准数据包 默认取组织,没有取集团
|
|
|
+ for (int c=0;c<nckd_orgamountaccount.length;c++){
|
|
|
+ //组织金额标准数据包
|
|
|
+ DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(nckd_orgamountaccount[i].getPkValue(), nckd_orgamountaccount[i].getDynamicObjectType().getName());
|
|
|
+ //获取标准金额
|
|
|
+ BigDecimal nckdAmountfield = dynamicObject.getBigDecimal("nckd_amountfield");
|
|
|
+ //判断报销金额大于标准金额
|
|
|
+ if(expenseamount.compareTo(nckdAmountfield) == 1){
|
|
|
+ System.out.println("报销金额大于标准金额");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
+}
|