|
|
@@ -0,0 +1,78 @@
|
|
|
+package nckd.xtpoc.fi.app.plugin.operate;
|
|
|
+
|
|
|
+import com.kingdee.util.StringUtils;
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.entity.ExtendedDataEntity;
|
|
|
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
|
+import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
|
|
+import kd.bos.entity.validate.AbstractValidator;
|
|
|
+import kd.bos.logging.Log;
|
|
|
+import kd.bos.logging.LogFactory;
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 对公费用报销单
|
|
|
+ * @author wanghaiwu_kd
|
|
|
+ * @date 2025/11/10
|
|
|
+ */
|
|
|
+public class PublicReimburseCusOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
+ private static final Log logger = LogFactory.getLog(PublicReimburseCusOpPlugin.class);
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onAddValidators(AddValidatorsEventArgs e) {
|
|
|
+ super.onAddValidators(e);
|
|
|
+
|
|
|
+ e.addValidator(new AbstractValidator() {
|
|
|
+ @Override
|
|
|
+ public void validate() {
|
|
|
+ ExtendedDataEntity[] dataEntitys = this.getDataEntities();
|
|
|
+
|
|
|
+ List<String> billList = new ArrayList<>();
|
|
|
+ for (ExtendedDataEntity dataEntity : dataEntitys) {
|
|
|
+ if(dataEntity == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ DynamicObject data = dataEntity.getDataEntity();
|
|
|
+
|
|
|
+ DynamicObjectCollection expenseEntrys = data.getDynamicObjectCollection("expenseentryentity");
|
|
|
+
|
|
|
+ int i = 0;
|
|
|
+ for(DynamicObject expenseEntry : expenseEntrys){
|
|
|
+ i++;
|
|
|
+ String contractno = expenseEntry.getString("entrycontractno");
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(contractno)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ QFilter qFilter = new QFilter("contractcode", QCP.equals, contractno);
|
|
|
+
|
|
|
+ DynamicObject contractInfo = BusinessDataServiceHelper.loadSingle("er_contractbill", qFilter.toArray());
|
|
|
+
|
|
|
+ if(contractInfo == null){
|
|
|
+ this.addErrorMessage(dataEntity, "费用明细第" + i + "行:合同号(" + contractno + ")未匹配到合同台账");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+
|
|
|
+ Date happenDate = expenseEntry.getDate("happendate");
|
|
|
+ Date startDate = contractInfo.getDate("startdate");
|
|
|
+ Date endDate = contractInfo.getDate("endDate");
|
|
|
+
|
|
|
+ if(happenDate.compareTo(startDate) < 0 || happenDate.compareTo(endDate) > 0){
|
|
|
+ this.addErrorMessage(dataEntity, "费用明细第" + i + "行:发生日期(" + sdf.format(happenDate) + ")不在合同的开始日期(" + sdf.format(startDate) + ")截止日期(" + sdf.format(endDate) + ")之间");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|