|
@@ -0,0 +1,49 @@
|
|
|
+package fi.er.formPlugin;
|
|
|
+
|
|
|
+import com.alibaba.druid.util.StringUtils;
|
|
|
+import kd.bos.entity.datamodel.events.ChangeData;
|
|
|
+import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
|
+import kd.bos.form.plugin.AbstractFormPlugin;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+public class TripreimbursePlugin extends AbstractFormPlugin {
|
|
|
+ @Override
|
|
|
+ public void propertyChanged(PropertyChangedArgs e) {
|
|
|
+ String fieldKey = e.getProperty().getName();
|
|
|
+ if (StringUtils.equals("nckd_amountfield1", fieldKey)) {
|
|
|
+ ChangeData changeData = e.getChangeSet()[0];
|
|
|
+ BigDecimal nckd_checkboxfield1 = (BigDecimal) changeData.getNewValue();
|
|
|
+ BigDecimal orientryamount = (BigDecimal) this.getModel().getValue("orientryamount");
|
|
|
+ orientryamount = orientryamount.add(nckd_checkboxfield1);
|
|
|
+ this.getModel().setValue("orientryamount", orientryamount);
|
|
|
+ }else if (StringUtils.equals("nckd_daterangefield_enddate", fieldKey)) {
|
|
|
+ ChangeData changeData = e.getChangeSet()[0];
|
|
|
+ Date nckd_daterangefield_enddate = (Date) changeData.getNewValue();
|
|
|
+ if (nckd_daterangefield_enddate == null) {
|
|
|
+ this.getModel().setValue("nckd_amountfield2", null);
|
|
|
+ }else {
|
|
|
+ Date nckd_daterangefield_startdate = (Date) this.getModel().getValue("nckd_daterangefield_startdate");
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ long differenceInMillies = nckd_daterangefield_enddate.getTime() - nckd_daterangefield_startdate.getTime();
|
|
|
+ long hoursDifference = TimeUnit.MILLISECONDS.toHours(differenceInMillies);
|
|
|
+ // 基础补助金额
|
|
|
+ long baseSubsidy = 60;
|
|
|
+ // 超过每小时补助10元
|
|
|
+ long additionalSubsidy = 10;
|
|
|
+ // 计算总补助
|
|
|
+ long totalSubsidy = 0;
|
|
|
+ if (hoursDifference >= 5) {
|
|
|
+ totalSubsidy = baseSubsidy;
|
|
|
+ // 计算超过5小时的部分
|
|
|
+ long extraHours = hoursDifference - 5;
|
|
|
+ totalSubsidy += additionalSubsidy * extraHours;
|
|
|
+ }
|
|
|
+ BigDecimal nckd_amountfield2 = BigDecimal.valueOf(totalSubsidy);
|
|
|
+ this.getModel().setValue("nckd_amountfield2", nckd_amountfield2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|