|
@@ -0,0 +1,111 @@
|
|
|
|
|
+package nckd.xtpoc.fi.app.plugin.operate;
|
|
|
|
|
+
|
|
|
|
|
+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.QueryServiceHelper;
|
|
|
|
|
+
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 差旅报销单
|
|
|
|
|
+ * @author wanghaiwu_kd
|
|
|
|
|
+ * @date 2025/11/10
|
|
|
|
|
+ */
|
|
|
|
|
+public class TripReimburseBillCusOpPlugin extends AbstractOperationServicePlugIn {
|
|
|
|
|
+ private static final Log logger = LogFactory.getLog(TripReimburseBillCusOpPlugin.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();
|
|
|
|
|
+ boolean isroomboard = data.getBoolean("nckd_isroomboard");
|
|
|
|
|
+ boolean isinnertrip = data.getBoolean("nckd_isinnertrip");
|
|
|
|
|
+
|
|
|
|
|
+ if(!isroomboard || !isinnertrip){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //校验 行程信息.差旅明细.标准天数,伙食补助和市内交通天数不能超过1
|
|
|
|
|
+ boolean isOver = false;
|
|
|
|
|
+ boolean exists = false;
|
|
|
|
|
+ DynamicObjectCollection tripEntrys = data.getDynamicObjectCollection("tripentry");
|
|
|
|
|
+
|
|
|
|
|
+ for(DynamicObject tripEntry : tripEntrys){
|
|
|
|
|
+ DynamicObjectCollection entryEntitys = tripEntry.getDynamicObjectCollection("entryentity");
|
|
|
|
|
+
|
|
|
|
|
+ for(DynamicObject entryEntity : entryEntitys){
|
|
|
|
|
+ DynamicObject expenseitem = entryEntity.getDynamicObject("expenseitem");
|
|
|
|
|
+
|
|
|
|
|
+ //判断是否统一安排食宿
|
|
|
|
|
+ if(isroomboard) {
|
|
|
|
|
+ if ("003".equals(expenseitem.getString("number"))
|
|
|
|
|
+ || "010".equals(expenseitem.getString("number"))) {
|
|
|
|
|
+ BigDecimal caldaycount = entryEntity.getBigDecimal("caldaycount");
|
|
|
|
|
+
|
|
|
|
|
+ if (caldaycount.compareTo(BigDecimal.ONE) > 0) {
|
|
|
|
|
+ isOver = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //判断是否内部出差
|
|
|
|
|
+ if(isinnertrip) {
|
|
|
|
|
+ if ("003".equals(expenseitem.getString("number"))) {
|
|
|
|
|
+ DynamicObjectCollection trip2travelers = entryEntity.getDynamicObjectCollection("trip2travelers");
|
|
|
|
|
+ List<Long> userIdList = (List)trip2travelers.stream().mapToLong((x) -> {
|
|
|
|
|
+ return x.getLong("fbasedataid_id");
|
|
|
|
|
+ }).boxed().collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ //费用承担公司
|
|
|
|
|
+ DynamicObject travelcostcompany = entryEntity.getDynamicObject("travelcostcompany");
|
|
|
|
|
+
|
|
|
|
|
+ //er_reimbursesetting
|
|
|
|
|
+ QFilter qFilter = new QFilter("user.id", QCP.in, userIdList);
|
|
|
|
|
+ qFilter.and(new QFilter("company.id", QCP.equals, travelcostcompany.getPkValue()));
|
|
|
|
|
+ qFilter.and(new QFilter("reimburselevel.number", QCP.equals, "Manager-02"));
|
|
|
|
|
+
|
|
|
|
|
+ if(QueryServiceHelper.exists("er_reimbursesetting_rel", qFilter.toArray())){
|
|
|
|
|
+ exists = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(isOver){
|
|
|
|
|
+ String msg = "差旅报销单(" + data.getString("billno") + ")是统一安排食宿并承担食宿费用的单据,伙食补助、市内交通标准天数不能大于1";
|
|
|
|
|
+ this.addErrorMessage(dataEntity, msg);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(exists){
|
|
|
|
|
+ String msg = "差旅报销单(" + data.getString("billno") + ")是内部出差,中层管理人员不能报销交通补助";
|
|
|
|
|
+ this.addErrorMessage(dataEntity, msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+}
|