瀏覽代碼

refactor(cycle): 优化考核周期管理逻辑

- 移除冗余的组织机构相关代码
- 简化考核周期创建和保存流程
- 优化已归档周期的校验逻辑
- 清理无用的导入包和变量声明
- 统一错误提示信息格式
wyc 4 天之前
父節點
當前提交
58012b9954

+ 0 - 10
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/form/cycle/BatchEvalCycleFormPlugin.java

@@ -189,12 +189,6 @@ public class BatchEvalCycleFormPlugin extends AbstractFormPlugin implements Plug
 
     private void executeOperateSave() {
 
-        DynamicObject createOrg = OrgHelper.getCreateOrg(PerfManagerFormConstant.PERFMANAGER_ENTITYID);
-        String bdCtrlStrgy = null;
-        if(createOrg != null) {
-            bdCtrlStrgy = OrgHelper.getBdCtrlStrgy(PerfManagerFormConstant.PERFMANAGER_ENTITYID, createOrg.getLong(FormConstant.ID_KEY));
-        }
-        bdCtrlStrgy = StringUtils.isNotBlank(bdCtrlStrgy) ? bdCtrlStrgy : CtrlStrategyEnum.GLOBAL_SHARE.getCtrlStrategy();
 
         String isAddOrUpdate = ConvertUtil.toStr(this.getModel().getValue("nckd_isaddorupdate"));
         boolean isUpdate = "2".equalsIgnoreCase(isAddOrUpdate);
@@ -295,11 +289,7 @@ public class BatchEvalCycleFormPlugin extends AbstractFormPlugin implements Plug
                 //新增
                 savePerfManager = EntityHelper.newEntity(PerfManagerFormConstant.PERFMANAGER_ENTITYID);
                 DynamicObjectUtils.copy(dynamicObject, savePerfManager);
-                savePerfManager.set(PerfManagerFormConstant.CTRLSTRATEGY_KEY, bdCtrlStrgy);
                 savePerfManager.set(FormConstant.NAME_KEY, StrFormatter.format("【{}】{}~{}的考核周期",personName,beginYear.getYear(),endYear.getYear()));
-                savePerfManager.set(PerfManagerFormConstant.CREATEORG_KEY, createOrg);
-                savePerfManager.set(PerfManagerFormConstant.ORG_KEY, createOrg);
-                savePerfManager.set(PerfManagerFormConstant.USEORG_KEY, createOrg);
                 DynamicObject empPosOrgRel = savePerfManager.getDynamicObject(FormConstant.NCKD_EMPPOSORGREL);
                 savePerfManager.set(PerfManagerFormConstant.NCKD_DEP, empPosOrgRel.getDynamicObject(FormConstant.ADMINORG));
             }

+ 6 - 19
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/form/cycle/PerfManagerListPlugin.java

@@ -2,41 +2,28 @@ package nckd.jxccl.opmc.pm.plugin.form.cycle;
 
 import kd.bos.dataentity.OperateOption;
 import kd.bos.dataentity.entity.DynamicObject;
-import kd.bos.dataentity.entity.DynamicObjectCollection;
-import kd.bos.dataentity.entity.LocaleString;
-import kd.bos.entity.datamodel.IListModel;
 import kd.bos.entity.datamodel.ListSelectedRowCollection;
-import kd.bos.entity.datamodel.events.PackageDataEvent;
 import kd.bos.entity.operate.OperateOptionConst;
 import kd.bos.entity.operate.result.OperationResult;
-import kd.bos.form.*;
+import kd.bos.form.CloseCallBack;
+import kd.bos.form.FormShowParameter;
+import kd.bos.form.MessageBoxOptions;
+import kd.bos.form.ShowType;
+import kd.bos.form.StyleCss;
 import kd.bos.form.control.events.ItemClickEvent;
 import kd.bos.form.events.AfterDoOperationEventArgs;
-import kd.bos.form.events.BeforeCreateListColumnsArgs;
-import kd.bos.form.events.BeforeCreateListDataProviderArgs;
 import kd.bos.form.events.BeforeDoOperationEventArgs;
 import kd.bos.form.operate.FormOperate;
-import kd.bos.list.IListColumn;
-import kd.bos.list.IListView;
-import kd.bos.list.ListColumn;
 import kd.bos.list.plugin.AbstractListPlugin;
-import kd.bos.mvc.list.ListDataProvider;
-import kd.bos.mvc.list.QueryBuilderFactory;
-import kd.bos.orm.query.QCP;
-import kd.bos.orm.query.QFilter;
-import kd.bos.servicehelper.QueryServiceHelper;
 import kd.bos.servicehelper.operation.OperationServiceHelper;
-import kd.sdk.hr.haos.business.helper.HAOSServiceHelper;
 import kd.sdk.plugin.Plugin;
 import nckd.jxccl.base.common.constant.FormConstant;
 import nckd.jxccl.base.common.exception.ValidationException;
 import nckd.jxccl.base.common.utils.ConvertUtil;
-import nckd.jxccl.base.common.utils.DateUtil;
-import nckd.jxccl.base.common.utils.QueryFieldBuilder;
 import nckd.jxccl.base.entity.helper.EntityHelper;
 import nckd.jxccl.opmc.pm.common.PerfManagerFormConstant;
 
-import java.util.*;
+import java.util.List;
 import java.util.stream.Collectors;
 
 /**

+ 0 - 16
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/form/print/PerfBatchPrintListPlugin.java

@@ -2,39 +2,23 @@ package nckd.jxccl.opmc.pm.plugin.form.print;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.kingdee.bos.ctrl.reportone.r1.print.data.R1PrintDataSource;
-import kd.bos.dataentity.SqlParameter;
-import kd.bos.dataentity.entity.DynamicObject;
-import kd.bos.dataentity.entity.DynamicObjectCollection;
-import kd.bos.dataentity.utils.ObjectUtils;
 import kd.bos.dataentity.utils.StringUtils;
-import kd.bos.entity.EntityType;
-import kd.bos.entity.datamodel.ListField;
 import kd.bos.entity.datamodel.events.PackageDataEvent;
-import kd.bos.entity.list.IListDataProvider;
-import kd.bos.entity.list.SummaryResult;
-import kd.bos.entity.list.option.ListUserOption;
 import kd.bos.entity.report.ReportColumn;
 import kd.bos.form.CloseCallBack;
 import kd.bos.form.FormShowParameter;
 import kd.bos.form.ShowType;
 import kd.bos.form.control.Toolbar;
 import kd.bos.form.control.events.ItemClickEvent;
-import kd.bos.form.events.BeforeCreateListDataProviderArgs;
 import kd.bos.form.events.ClosedCallBackEvent;
-import kd.bos.list.plugin.AbstractListPlugin;
-import kd.bos.mvc.list.ListDataProvider;
-import kd.bos.orm.query.QFilter;
 import kd.bos.report.plugin.AbstractReportFormPlugin;
 import kd.sdk.plugin.Plugin;
 import nckd.jxccl.base.common.constant.FormConstant;
 import nckd.jxccl.base.common.utils.ConvertUtil;
 import nckd.jxccl.base.common.utils.DateUtil;
 
-import java.util.Collections;
 import java.util.Date;
 import java.util.EventObject;
-import java.util.List;
 import java.util.Map;
 
 /**

+ 0 - 6
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/operate/cycle/CycleGenerateOpPlugin.java

@@ -99,18 +99,12 @@ public class CycleGenerateOpPlugin extends AbstractOperationServicePlugIn implem
         }
         SaveServiceHelper.update(dbPerfManagerArray);*/
 
-        MainEntityType bosOrgEntityType = EntityMetadataCache.getDataEntityType(FormConstant.BOS_ORG);
-        Long createOrg = OrgHelper.getCreateOrgList(SalAdjTrackerConstant.SALADJTRACKER_ENTITYID);
-        DynamicObject org = new DynamicObject(bosOrgEntityType);
-        org.set(FormConstant.ID_KEY, createOrg);
-
 
         //调用save-op
         List<DynamicObject> savePerfManager = new ArrayList<>();
         for (PerfManagerSaveOpPlugin.PersonPerfInfo value : pendingCyclePersonnelMap.values()) {
             DynamicObject newPerfManager = EntityHelper.newEntity(PerfManagerFormConstant.PERFMANAGER_ENTITYID);
             String personName = value.getPerson().getString(FormConstant.NAME_KEY);
-            newPerfManager.set(FormConstant.CREATEORG_KEY, org);
             newPerfManager.set(FormConstant.NCKD_EMPPOSORGREL, value.getEmpPosOrgRel());
             newPerfManager.set(FormConstant.NCKD_DEP, value.getAdminOrg());
             newPerfManager.set(FormConstant.NCKD_PERSON, value.getPerson());

+ 14 - 12
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/operate/cycle/PerfManagerDeleteOpPlugin.java

@@ -96,19 +96,21 @@ public class PerfManagerDeleteOpPlugin extends AbstractOperationServicePlugIn im
                     String personName = person.getString(FormConstant.NAME_KEY);
                     List<Date> dates = archivedPersonYearPairs.get(personId);
                     // 获取dates中年份最大的日期
-                    Date maxDate = dates.stream()
-                            .filter(Objects::nonNull)
-                            .max(Comparator.comparing(date -> DateUtil.toLocalDateTime(date).getYear()))
-                            .orElse(null);
-                    if (maxDate != null) {
-                        LocalDateTime maxLocalDate = DateUtil.toLocalDateTime(maxDate);
-                        if (maxLocalDate.getYear() >= beginYear.getYear() || maxLocalDate.getYear() >= endYear.getYear()) {
-                            addFatalErrorMessage(rowDataEntity,
-                                    StrFormatter.format("人员【{}】考核周期已归档,不能修改删除【{}】年及之前的考核周期。",
-                                            personName,
-                                            maxLocalDate.getYear()));
-                        }
+                    if(dates != null) {
+                        Date maxDate = dates.stream()
+                                .filter(Objects::nonNull)
+                                .max(Comparator.comparing(date -> DateUtil.toLocalDateTime(date).getYear()))
+                                .orElse(null);
+                        if (maxDate != null) {
+                            LocalDateTime maxLocalDate = DateUtil.toLocalDateTime(maxDate);
+                            if (maxLocalDate.getYear() >= beginYear.getYear() || maxLocalDate.getYear() >= endYear.getYear()) {
+                                addFatalErrorMessage(rowDataEntity,
+                                        StrFormatter.format("人员【{}】考核周期已归档,不能修改删除【{}】年及之前的考核周期。",
+                                                personName,
+                                                maxLocalDate.getYear()));
+                            }
 
+                        }
                     }
                 }
             }

+ 42 - 40
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/operate/cycle/PerfManagerSaveOpPlugin.java

@@ -360,52 +360,54 @@ public class PerfManagerSaveOpPlugin extends AbstractOperationServicePlugIn impl
                                 LocalDateTime dbEndDate = DateUtil.toLocalDateTime(dbPef.getDate(PerfManagerFormConstant.NCKD_ENDYEAR));
                                 List<Date> dates = archivedPersonYearPairs.get(personId);
                                 // 获取dates中年份最大的日期
-                                Date maxDate = dates.stream()
-                                        .filter(Objects::nonNull)
-                                        .max(Comparator.comparing(date -> DateUtil.toLocalDateTime(date).getYear()))
-                                        .orElse(null);
-                                if (maxDate != null) {
-                                    LocalDateTime maxLocalDate = DateUtil.toLocalDateTime(maxDate);
-                                    if (maxLocalDate.getYear() >= dbBeginYear.getYear() || maxLocalDate.getYear() >= dbEndDate.getYear()) {
-                                        //判断本次是否有变更,如果有变更返回错误
-                                        if(!isArchived) {
-                                            if (dbBeginYear.getYear() != beginYear.getYear() || dbEndDate.getYear() != endYear.getYear()) {
-                                                addFatalErrorMessage(rowDataEntity,
-                                                        StrFormatter.format("人员【{}】考核周期已归档,不能修改【{}】年及之前的考核周期范围。",
-                                                                personName,
-                                                                maxLocalDate.getYear()));
+                                if(dates != null) {
+                                    Date maxDate = dates.stream()
+                                            .filter(Objects::nonNull)
+                                            .max(Comparator.comparing(date -> DateUtil.toLocalDateTime(date).getYear()))
+                                            .orElse(null);
+                                    if (maxDate != null) {
+                                        LocalDateTime maxLocalDate = DateUtil.toLocalDateTime(maxDate);
+                                        if (maxLocalDate.getYear() >= dbBeginYear.getYear() || maxLocalDate.getYear() >= dbEndDate.getYear()) {
+                                            //判断本次是否有变更,如果有变更返回错误
+                                            if (!isArchived) {
+                                                if (dbBeginYear.getYear() != beginYear.getYear() || dbEndDate.getYear() != endYear.getYear()) {
+                                                    addFatalErrorMessage(rowDataEntity,
+                                                            StrFormatter.format("人员【{}】考核周期已归档,不能修改【{}】年及之前的考核周期范围。",
+                                                                    personName,
+                                                                    maxLocalDate.getYear()));
+                                                }
+                                                isArchived = true;
                                             }
-                                            isArchived = true;
                                         }
-                                    }
 
-                                    Date appraisalYear = dbPef.getDate(String.join(".", PerfManagerFormConstant.NCKD_PERFMANAGERENTRY, PerfManagerFormConstant.NCKD_APPRAISALYEAR));
-                                    if (appraisalYear != null) {
-                                        LocalDateTime appraisalYearLocalDate = DateUtil.toLocalDateTime(appraisalYear);
-                                        String dbAppraisalResultNumber = dbPef.getString(String.join(".", PerfManagerFormConstant.NCKD_PERFMANAGERENTRY, PerfManagerFormConstant.NCKD_APPRAISALRESULT, FormConstant.NUMBER_KEY));
-                                        String dbAppraisalResultName = dbPef.getString(String.join(".", PerfManagerFormConstant.NCKD_PERFMANAGERENTRY, PerfManagerFormConstant.NCKD_APPRAISALRESULT, FormConstant.NAME_KEY));
-                                        if(entrys != null && !entrys.isEmpty()) {
-                                            for (DynamicObject entry : entrys) {
-                                                DynamicObject appraisalResult = entry.getDynamicObject(PerfManagerFormConstant.NCKD_APPRAISALRESULT);
-                                                String appraisalResultNumber = appraisalResult != null ? appraisalResult.getString(FormConstant.NUMBER_KEY) : null;
-                                                if (maxLocalDate.getYear() >= appraisalYearLocalDate.getYear()) {
-                                                    if (!Objects.equals(appraisalResultNumber, dbAppraisalResultNumber)) {
-                                                        addFatalErrorMessage(rowDataEntity,
-                                                                StrFormatter.format("人员【{}】考核周期已归档,不能修改【{}】年的考核结果,修改前考核结果【{}】。",
-                                                                        personName,
-                                                                        appraisalYearLocalDate.getYear(),
-                                                                        dbAppraisalResultName));
+                                        Date appraisalYear = dbPef.getDate(String.join(".", PerfManagerFormConstant.NCKD_PERFMANAGERENTRY, PerfManagerFormConstant.NCKD_APPRAISALYEAR));
+                                        if (appraisalYear != null) {
+                                            LocalDateTime appraisalYearLocalDate = DateUtil.toLocalDateTime(appraisalYear);
+                                            String dbAppraisalResultNumber = dbPef.getString(String.join(".", PerfManagerFormConstant.NCKD_PERFMANAGERENTRY, PerfManagerFormConstant.NCKD_APPRAISALRESULT, FormConstant.NUMBER_KEY));
+                                            String dbAppraisalResultName = dbPef.getString(String.join(".", PerfManagerFormConstant.NCKD_PERFMANAGERENTRY, PerfManagerFormConstant.NCKD_APPRAISALRESULT, FormConstant.NAME_KEY));
+                                            if (entrys != null && !entrys.isEmpty()) {
+                                                for (DynamicObject entry : entrys) {
+                                                    DynamicObject appraisalResult = entry.getDynamicObject(PerfManagerFormConstant.NCKD_APPRAISALRESULT);
+                                                    String appraisalResultNumber = appraisalResult != null ? appraisalResult.getString(FormConstant.NUMBER_KEY) : null;
+                                                    if (maxLocalDate.getYear() >= appraisalYearLocalDate.getYear()) {
+                                                        if (!Objects.equals(appraisalResultNumber, dbAppraisalResultNumber)) {
+                                                            addFatalErrorMessage(rowDataEntity,
+                                                                    StrFormatter.format("人员【{}】考核周期已归档,不能修改【{}】年的考核结果,修改前考核结果【{}】。",
+                                                                            personName,
+                                                                            appraisalYearLocalDate.getYear(),
+                                                                            dbAppraisalResultName));
+                                                        }
                                                     }
                                                 }
                                             }
-                                        }
-                                    }else{
-                                        if(entrys != null && !entrys.isEmpty()) {
-                                            //原来没有考核结果
-                                            addFatalErrorMessage(rowDataEntity,
-                                                    StrFormatter.format("人员【{}】考核周期已归档,不能修改【{}】年及之前的考核结果。",
-                                                            personName,
-                                                            maxLocalDate.getYear()));
+                                        } else {
+                                            if (entrys != null && !entrys.isEmpty()) {
+                                                //原来没有考核结果
+                                                addFatalErrorMessage(rowDataEntity,
+                                                        StrFormatter.format("人员【{}】考核周期已归档,不能修改【{}】年及之前的考核结果。",
+                                                                personName,
+                                                                maxLocalDate.getYear()));
+                                            }
                                         }
                                     }
                                 }

+ 0 - 9
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/operate/salary/SalaryAdjOpPlugin.java

@@ -7,7 +7,6 @@ import kd.bos.context.RequestContext;
 import kd.bos.dataentity.OperateOption;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
-import kd.bos.entity.EntityMetadataCache;
 import kd.bos.entity.MainEntityType;
 import kd.bos.entity.operate.OperateOptionConst;
 import kd.bos.entity.operate.result.IOperateInfo;
@@ -23,7 +22,6 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
 import kd.bos.servicehelper.DispatchServiceHelper;
 import kd.bos.servicehelper.MetadataServiceHelper;
 import kd.bos.servicehelper.QueryServiceHelper;
-import kd.bos.servicehelper.basedata.BaseDataServiceHelper;
 import kd.bos.servicehelper.operation.SaveServiceHelper;
 import kd.bos.servicehelper.user.UserServiceHelper;
 import kd.hr.hbp.common.model.AuthorizedOrgResultWithSub;
@@ -42,7 +40,6 @@ import nckd.jxccl.base.common.utils.DateUtil;
 import nckd.jxccl.base.common.utils.QueryFieldBuilder;
 import nckd.jxccl.base.common.utils.StrFormatter;
 import nckd.jxccl.base.entity.helper.EntityHelper;
-import nckd.jxccl.base.org.helper.OrgHelper;
 import nckd.jxccl.opmc.pm.common.PerfManagerFormConstant;
 import nckd.jxccl.opmc.pm.common.SalAdjTrackerConstant;
 import org.apache.commons.lang3.StringUtils;
@@ -387,15 +384,9 @@ public class SalaryAdjOpPlugin extends AbstractOperationServicePlugIn implements
                 }
                 List<DynamicObject> addSalAdjTrackerList = new ArrayList<>();
                 List<Long> ids = new ArrayList<>(salaryAdjustmentResultList.size());
-                MainEntityType bosOrgEntityType = EntityMetadataCache.getDataEntityType(FormConstant.BOS_ORG);
-                Long createOrg = OrgHelper.getCreateOrgList(SalAdjTrackerConstant.SALADJTRACKER_ENTITYID);
-                DynamicObject org = new DynamicObject(bosOrgEntityType);
-                org.set(FormConstant.ID_KEY, createOrg);
                 for (SalaryAdjustmentResult result : salaryAdjustmentResultList) {
                     if (result.salaryStDv != null && result.oldStandardItem != null && result.oldSalaryRank != null) {
                         DynamicObject newSalAdjTracker = EntityHelper.newEntity(SalAdjTrackerConstant.SALADJTRACKER_ENTITYID);
-                        newSalAdjTracker.set(FormConstant.CREATEORG_KEY, org);
-                        newSalAdjTracker.set(FormConstant.CTRLSTRATEGY_KEY, CtrlStrategyEnum.GLOBAL_SHARE.getCtrlStrategy());
                         newSalAdjTracker.set(FormConstant.NAME_KEY, StrFormatter.format("{}的调薪", result.personName));
                         newSalAdjTracker.set(SalAdjTrackerConstant.NCKD_PERFMANAGER, EntityHelper.newEntity(PerfManagerFormConstant.PERFMANAGER_ENTITYID, result.id));
                         newSalAdjTracker.set(SalAdjTrackerConstant.NCKD_ADJFILEINFO, result.adjFileInfo);