|
@@ -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");
|
|
|
+
|
|
|
+ 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("报销金额大于标准金额");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
+}
|