|
@@ -1,30 +1,60 @@
|
|
|
package nckd.jxccl.swc.mas.plugin.form.structappr;
|
|
package nckd.jxccl.swc.mas.plugin.form.structappr;
|
|
|
|
|
|
|
|
|
|
+import com.google.common.collect.Sets;
|
|
|
|
|
+import kd.bos.bill.BillShowParameter;
|
|
|
|
|
+import kd.bos.dataentity.OperateOption;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
|
+import kd.bos.dataentity.metadata.IDataEntityProperty;
|
|
|
|
|
+import kd.bos.dataentity.metadata.clr.DataEntityPropertyCollection;
|
|
|
import kd.bos.entity.constant.StatusEnum;
|
|
import kd.bos.entity.constant.StatusEnum;
|
|
|
import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
|
|
import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
|
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
|
|
|
+import kd.bos.entity.operate.result.OperationResult;
|
|
|
|
|
+import kd.bos.entity.report.CellStyle;
|
|
|
|
|
+import kd.bos.entity.validate.BillStatus;
|
|
|
|
|
+import kd.bos.form.ConfirmCallBackListener;
|
|
|
|
|
+import kd.bos.form.ConfirmTypes;
|
|
|
|
|
+import kd.bos.form.IFormView;
|
|
|
|
|
+import kd.bos.form.IPageCache;
|
|
|
|
|
+import kd.bos.form.MessageBoxOptions;
|
|
|
|
|
+import kd.bos.form.MessageBoxResult;
|
|
|
|
|
+import kd.bos.form.ShowType;
|
|
|
|
|
+import kd.bos.form.control.EntryGrid;
|
|
|
|
|
+import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
|
|
|
+import kd.bos.form.events.MessageBoxClosedEvent;
|
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
|
|
|
+import kd.bos.mvc.SessionManager;
|
|
|
import kd.bos.orm.query.QCP;
|
|
import kd.bos.orm.query.QCP;
|
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.orm.query.QFilter;
|
|
|
|
|
+import kd.bos.servicehelper.AttachmentServiceHelper;
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
|
+import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
|
|
+import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
|
|
+import kd.drp.mem.er.BillStatusEnum;
|
|
|
|
|
+import kd.hr.hbp.common.util.HRDynamicObjectUtils;
|
|
|
import kd.sdk.plugin.Plugin;
|
|
import kd.sdk.plugin.Plugin;
|
|
|
import nckd.jxccl.base.common.constant.FormConstant;
|
|
import nckd.jxccl.base.common.constant.FormConstant;
|
|
|
import nckd.jxccl.base.common.enums.mas.ProjectCategoryEnum;
|
|
import nckd.jxccl.base.common.enums.mas.ProjectCategoryEnum;
|
|
|
|
|
+import nckd.jxccl.base.common.exception.ValidationException;
|
|
|
import nckd.jxccl.base.common.utils.ConvertUtil;
|
|
import nckd.jxccl.base.common.utils.ConvertUtil;
|
|
|
import nckd.jxccl.base.common.utils.DateUtil;
|
|
import nckd.jxccl.base.common.utils.DateUtil;
|
|
|
import nckd.jxccl.base.common.utils.QueryFieldBuilder;
|
|
import nckd.jxccl.base.common.utils.QueryFieldBuilder;
|
|
|
|
|
+import nckd.jxccl.base.common.utils.ShowOperExecuteResult;
|
|
|
|
|
+import nckd.jxccl.base.common.utils.StrFormatter;
|
|
|
|
|
+import nckd.jxccl.base.entity.helper.EntityHelper;
|
|
|
import nckd.jxccl.base.orm.helper.QFilterCommonHelper;
|
|
import nckd.jxccl.base.orm.helper.QFilterCommonHelper;
|
|
|
import nckd.jxccl.swc.mas.common.MasConstant;
|
|
import nckd.jxccl.swc.mas.common.MasConstant;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.EventObject;
|
|
import java.util.EventObject;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
@@ -171,8 +201,11 @@ public class SubcorpChiefSalStdFormPlugin extends AbstractFormPlugin implements
|
|
|
this.getModel().setValue(MasConstant.NCKD_DEFERPAYTOTALAMT, null);
|
|
this.getModel().setValue(MasConstant.NCKD_DEFERPAYTOTALAMT, null);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private void load(){
|
|
private void load(){
|
|
|
DynamicObject payUnit = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(MasConstant.NCKD_PAYUNIT));
|
|
DynamicObject payUnit = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(MasConstant.NCKD_PAYUNIT));
|
|
|
DynamicObject lawEntity = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(MasConstant.NCKD_LAWENTITY));
|
|
DynamicObject lawEntity = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(MasConstant.NCKD_LAWENTITY));
|
|
@@ -301,4 +334,100 @@ public class SubcorpChiefSalStdFormPlugin extends AbstractFormPlugin implements
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
|
|
|
|
|
+ if(afterDoOperationEventArgs.getOperationResult() != null && afterDoOperationEventArgs.getOperationResult().isSuccess()){
|
|
|
|
|
+ String operateKey = afterDoOperationEventArgs.getOperateKey();
|
|
|
|
|
+ if(operateKey.equalsIgnoreCase("change")){
|
|
|
|
|
+ DynamicObject data = this.getModel().getDataEntity();
|
|
|
|
|
+ //校验有没有暂存或进行中的审批单
|
|
|
|
|
+ QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create()
|
|
|
|
|
+ .add(FormConstant.BILL_NO_KEY);
|
|
|
|
|
+ QFilter filter = new QFilter(FormConstant.BILL_STATUS_KEY, QCP.not_equals, BillStatus.C.toString())
|
|
|
|
|
+ .and(String.join(".", MasConstant.SUBCORPCHIEFSALSTD_ENTITYID, FormConstant.ID_KEY), QCP.in, data.getLong(FormConstant.ID_KEY));
|
|
|
|
|
+ DynamicObjectCollection query = QueryServiceHelper.query(MasConstant.SUBCPCHFSALSTDCHG_ENTITYID, queryFieldBuilder.buildSelect(), new QFilter[]{filter});
|
|
|
|
|
+ if(!query.isEmpty()){
|
|
|
|
|
+ String number = query.get(0).getString(FormConstant.BILL_NO_KEY);
|
|
|
|
|
+ throw new ValidationException(StrFormatter.format("已存在暂存或进行中的变更单【单据号:{}】,请勿重复申请。", number));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DynamicObjectCollection entryColl = data.getDynamicObjectCollection(FormConstant.NCKD_ENTRYENTITY);
|
|
|
|
|
+ DynamicObject newSubcpChfSalStdChg = EntityHelper.newEntity("nckd_subcpchfsalstdchg");
|
|
|
|
|
+ HRDynamicObjectUtils.copy(data,newSubcpChfSalStdChg);
|
|
|
|
|
+ newSubcpChfSalStdChg.set(FormConstant.NCKD_DESCRIPTION,data.getString(FormConstant.DESCRIPTION_KEY));
|
|
|
|
|
+ newSubcpChfSalStdChg.set(MasConstant.SUBCORPCHIEFSALSTD_ENTITYID,data);
|
|
|
|
|
+ newSubcpChfSalStdChg.set(FormConstant.BILL_STATUS_KEY, BillStatusEnum.SAVED.getValue());
|
|
|
|
|
+ List<Map<String, Object>> attachments = AttachmentServiceHelper.getAttachments("nckd_subcorpchiefsalstd", data.getLong(FormConstant.ID_KEY), "nckd_attachmentpanelap");
|
|
|
|
|
+
|
|
|
|
|
+ //变更前
|
|
|
|
|
+ DynamicObjectCollection newEntryColl = newSubcpChfSalStdChg.getDynamicObjectCollection(FormConstant.NCKD_ENTRYENTITY);
|
|
|
|
|
+ DynamicObjectCollection newOldEntryColl = newSubcpChfSalStdChg.getDynamicObjectCollection("nckd_oldentryentity");
|
|
|
|
|
+ for (DynamicObject newEntry : newEntryColl) {
|
|
|
|
|
+ //设置源id
|
|
|
|
|
+ int seq = newEntry.getInt(FormConstant.SEQ_KEY);
|
|
|
|
|
+ List<DynamicObject> filteredEntries = entryColl.stream().filter(entry -> entry.getInt(FormConstant.SEQ_KEY) == seq).collect(Collectors.toList());
|
|
|
|
|
+ long originId = 0L;
|
|
|
|
|
+ if(!filteredEntries.isEmpty()){
|
|
|
|
|
+ originId = filteredEntries.get(0).getLong(FormConstant.ID_KEY);
|
|
|
|
|
+ }
|
|
|
|
|
+ newEntry.set("nckd_originid", originId);
|
|
|
|
|
+
|
|
|
|
|
+ DynamicObject newOldEntry = newOldEntryColl.addNew();
|
|
|
|
|
+ newOldEntry.set(MasConstant.NCKD_PROJECTCATEGORY+"old", newEntry.getDynamicObject(MasConstant.NCKD_PROJECTCATEGORY));
|
|
|
|
|
+ newOldEntry.set(MasConstant.NCKD_SALARYITEM+"old", newEntry.getDynamicObject(MasConstant.NCKD_SALARYITEM));
|
|
|
|
|
+ newOldEntry.set(MasConstant.NCKD_DEFERREDPAYITEM+"old", newEntry.getBoolean(MasConstant.NCKD_DEFERREDPAYITEM));
|
|
|
|
|
+ newOldEntry.set(MasConstant.NCKD_APPRSTD+"old", newEntry.getInt(MasConstant.NCKD_APPRSTD));
|
|
|
|
|
+ newOldEntry.set(MasConstant.NCKD_DEFERPAYTOTALAMT+"old", newEntry.getInt(MasConstant.NCKD_DEFERPAYTOTALAMT));
|
|
|
|
|
+ newOldEntry.set(MasConstant.NCKD_INSTALLMENTYEARS+"old", newEntry.getInt(MasConstant.NCKD_INSTALLMENTYEARS));
|
|
|
|
|
+ newOldEntry.set("nckd_originidold", originId);
|
|
|
|
|
+ for (int i = 1; i <= 10; i++) {
|
|
|
|
|
+ newOldEntry.set(MasConstant.NCKD_PAYAMOUNT+i+"old", newEntry.get(MasConstant.NCKD_PAYAMOUNT+i));
|
|
|
|
|
+ newOldEntry.set(MasConstant.NCKD_PAYYEAR+i+"old", newEntry.get(MasConstant.NCKD_PAYYEAR+i));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ OperationResult operationResult = SaveServiceHelper.saveOperate("nckd_subcpchfsalstdchg", new DynamicObject[]{newSubcpChfSalStdChg}, OperateOption.create());
|
|
|
|
|
+ if (!operationResult.isSuccess()) {
|
|
|
|
|
+ String parentPageId = this.getView().getFormShowParameter().getPageId();
|
|
|
|
|
+ IFormView parentView = SessionManager.getCurrent().getViewNoPlugin(parentPageId);
|
|
|
|
|
+ IPageCache pageCache = (IPageCache) parentView.getService(IPageCache.class);
|
|
|
|
|
+ Map<String, String> customData = operationResult.getCustomData();
|
|
|
|
|
+ //成功的记录
|
|
|
|
|
+ Map<Object, Object> successMap = new HashMap<>();
|
|
|
|
|
+ for (Object successPkId : operationResult.getSuccessPkIds()) {
|
|
|
|
|
+ successMap.put(successPkId, customData.get(successPkId.toString()));
|
|
|
|
|
+ }
|
|
|
|
|
+ this.getView().showForm(ShowOperExecuteResult.getOperResultForm("载入党政职务履历", successMap, pageCache, operationResult));
|
|
|
|
|
+ this.getView().invokeOperation(FormConstant.REFRESH_OP);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 自定义确认框按钮名称
|
|
|
|
|
+ Map<Integer, String> btnNameMaps = new HashMap<Integer, String>();
|
|
|
|
|
+ btnNameMaps.put(2, "我知道了");
|
|
|
|
|
+ btnNameMaps.put(6, "进入变更单");
|
|
|
|
|
+ ConfirmCallBackListener confirmCallBackListener =
|
|
|
|
|
+ new ConfirmCallBackListener("openchange", this);
|
|
|
|
|
+ List<Object> successPkIds = operationResult.getSuccessPkIds();
|
|
|
|
|
+ this.getPageCache().put("changeid", ConvertUtil.toStr(successPkIds.get(0)));
|
|
|
|
|
+ this.getView().showConfirm("提示","发起暂存状态「变更单」成功,点击“进入变更单”按钮或在列表页面点击“查看变更单”即可进行数据变更并提交审批。",MessageBoxOptions.OKCancel,ConfirmTypes.Default, confirmCallBackListener,btnNameMaps);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
|
|
|
|
|
+ if ("openchange".equals(messageBoxClosedEvent.getCallBackId())
|
|
|
|
|
+ && messageBoxClosedEvent.getResult() == MessageBoxResult.Yes) {
|
|
|
|
|
+ BillShowParameter billShowParameter = new BillShowParameter();
|
|
|
|
|
+ billShowParameter.setFormId("nckd_subcpchfsalstdchg");
|
|
|
|
|
+ billShowParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
|
|
|
|
|
+ String id = this.getPageCache().get("changeid");
|
|
|
|
|
+ // 设置单据主键ID(关键步骤)
|
|
|
|
|
+ billShowParameter.setPkId(id);
|
|
|
|
|
+ this.getView().showForm(billShowParameter);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|