|
|
@@ -1,9 +1,11 @@
|
|
|
package nckd.jxccl.hr.psms.plugin.form.contribution;
|
|
|
|
|
|
+import kd.bos.bill.OperationStatus;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
|
+import kd.bos.form.FormShowParameter;
|
|
|
import kd.bos.form.field.BasedataEdit;
|
|
|
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
|
|
import kd.bos.form.field.events.BeforeF7SelectListener;
|
|
|
@@ -11,9 +13,12 @@ import kd.bos.form.plugin.AbstractFormPlugin;
|
|
|
import kd.bos.list.ListShowParameter;
|
|
|
import kd.bos.orm.query.QCP;
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
import kd.sdk.plugin.Plugin;
|
|
|
import nckd.jxccl.base.common.constant.FormConstant;
|
|
|
+import nckd.jxccl.base.common.enums.psms.ScoreItemEnum;
|
|
|
import nckd.jxccl.base.common.utils.ConvertUtil;
|
|
|
+import nckd.jxccl.base.entity.helper.EntityHelper;
|
|
|
import nckd.jxccl.hr.psms.common.ContributionConstant;
|
|
|
import nckd.jxccl.hr.psms.helper.ContributionHelper;
|
|
|
|
|
|
@@ -22,6 +27,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.EventObject;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
@@ -33,6 +39,38 @@ import java.util.Objects;
|
|
|
*/
|
|
|
public class ContribBillFormPlugin extends AbstractFormPlugin implements Plugin, BeforeF7SelectListener {
|
|
|
|
|
|
+ @Override
|
|
|
+ public void afterCreateNewData(EventObject e) {
|
|
|
+ FormShowParameter formShowParameter = this.getView().getFormShowParameter();
|
|
|
+ if (formShowParameter.getStatus() == OperationStatus.ADDNEW) {
|
|
|
+ Object value = this.getModel().getValue(ContributionConstant.NCKD_SCOREITEM);
|
|
|
+ if (value != null) {
|
|
|
+ DynamicObject scoreItem = ConvertUtil.toDynamicObjectOrNull(value);
|
|
|
+ if (scoreItem != null) {
|
|
|
+ String scoreItemNumber = scoreItem.getString(FormConstant.NUMBER_KEY);
|
|
|
+ if (ScoreItemEnum.SKILL_CONTEST_SCORE.getCode().equalsIgnoreCase(scoreItemNumber)) {
|
|
|
+ //技能竞赛积分默认三行分录
|
|
|
+ DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection(ContributionConstant.NCKD_ENTRYENTITY);
|
|
|
+ DynamicObjectCollection scoreItemRankColl = QueryServiceHelper.query(ContributionConstant.NCKD_SCOREITEMRANK,
|
|
|
+ FormConstant.ID_KEY+","+FormConstant.NAME_KEY+","+FormConstant.NUMBER_KEY,
|
|
|
+ new QFilter[]{new QFilter(ContributionConstant.NCKD_SCOREITEM, QCP.equals, scoreItem.getLong(FormConstant.ID_KEY))},
|
|
|
+ ContributionConstant.INDEX_KEY
|
|
|
+ );
|
|
|
+ for (DynamicObject scoreItemRank : scoreItemRankColl) {
|
|
|
+ DynamicObject dynamicObject = dynamicObjectCollection.addNew();
|
|
|
+ DynamicObject newScoreItemRank = EntityHelper.newEntity(ContributionConstant.NCKD_SCOREITEMRANK, scoreItemRank.getLong(FormConstant.ID_KEY));
|
|
|
+ newScoreItemRank.set(ContributionConstant.NAME_KEY, scoreItemRank.getString(FormConstant.NAME_KEY));
|
|
|
+ newScoreItemRank.set(ContributionConstant.NUMBER_KEY, scoreItemRank.getString(FormConstant.NUMBER_KEY));
|
|
|
+
|
|
|
+ dynamicObject.set(ContributionConstant.NCKD_SCOREITEMRANKEN,newScoreItemRank);
|
|
|
+ }
|
|
|
+ this.getView().updateView(ContributionConstant.NCKD_ENTRYENTITY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void registerListener(EventObject e) {
|
|
|
super.registerListener(e);
|
|
|
@@ -118,6 +156,49 @@ public class ContribBillFormPlugin extends AbstractFormPlugin implements Plugin,
|
|
|
DynamicObject scoreItemRank = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_SCOREITEMRANK));
|
|
|
DynamicObject person = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_PERSON, rowIndex));
|
|
|
BigDecimal oriScore = ConvertUtil.toBigDecimal(this.getModel().getValue(ContributionConstant.NCKD_ORISCORE, rowIndex));
|
|
|
+ if (date != null && scoreItem != null && scoreItemSub != null) {
|
|
|
+ String scoreItemNumber = scoreItem.getString(FormConstant.NUMBER_KEY);
|
|
|
+ if (ScoreItemEnum.RESEARCH_SCORE.getCode().equalsIgnoreCase(scoreItemNumber)) {
|
|
|
+ if (person != null && oriScore != null && oriScore.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ //科研与创新需要需要匹配积分规则
|
|
|
+ QFilter filter = new QFilter(String.join(".", FormConstant.NCKD_ENTRYENTITY, ContributionConstant.NCKD_SCOREITEM), QCP.equals, scoreItem.getLong(FormConstant.ID_KEY))
|
|
|
+ .and(new QFilter(String.join(".", FormConstant.NCKD_ENTRYENTITY, ContributionConstant.NCKD_SCOREITEMSUB), QCP.equals, scoreItemSub.getLong(FormConstant.ID_KEY)))
|
|
|
+ .and(new QFilter(String.join(".", FormConstant.NCKD_ENTRYENTITY, ContributionConstant.NCKD_SCOREITEMRANK), QCP.equals, scoreItemRank.getLong(FormConstant.ID_KEY)));
|
|
|
+ Map<String, BigDecimal> scoreConf = ContributionHelper.getScoreConf(filter);
|
|
|
+ String key = scoreItem.getLong(FormConstant.ID_KEY) + "-" + scoreItemSub.getLong(FormConstant.ID_KEY) + "-" + scoreItemRank.getLong(FormConstant.ID_KEY);
|
|
|
+ BigDecimal validScore = oriScore;
|
|
|
+ if (!scoreConf.isEmpty() && scoreConf.containsKey(key)) {
|
|
|
+ BigDecimal maxScore = scoreConf.get(key);
|
|
|
+ if (maxScore != null) {
|
|
|
+ validScore = oriScore.compareTo(maxScore) > 0 ? maxScore : oriScore;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.getModel().setValue(ContributionConstant.NCKD_SCORE, validScore, rowIndex);
|
|
|
+ this.getView().updateView(ContributionConstant.NCKD_SCORE, rowIndex);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.getModel().setValue(ContributionConstant.NCKD_SCORE, oriScore, rowIndex);
|
|
|
+ this.getView().updateView(ContributionConstant.NCKD_SCORE, rowIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理分录行变更
|
|
|
+ * 分录变更则针对当前分录计算积分
|
|
|
+ * @param rowIndex 行索引
|
|
|
+ * @return: void
|
|
|
+ * @author W.Y.C
|
|
|
+ * @date: 2025/10/26 19:47
|
|
|
+ */
|
|
|
+ private void handleEntryRowChange1(int rowIndex) {
|
|
|
+ Long id = ConvertUtil.toLong(this.getModel().getValue(FormConstant.ID_KEY));
|
|
|
+ Date date = ConvertUtil.toDate(this.getModel().getValue(ContributionConstant.NCKD_YEAR));
|
|
|
+ DynamicObject scoreItem = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_SCOREITEM));
|
|
|
+ DynamicObject scoreItemSub = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_SCOREITEMSUB));
|
|
|
+ DynamicObject scoreItemRank = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_SCOREITEMRANK));
|
|
|
+ DynamicObject person = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_PERSON, rowIndex));
|
|
|
+ BigDecimal oriScore = ConvertUtil.toBigDecimal(this.getModel().getValue(ContributionConstant.NCKD_ORISCORE, rowIndex));
|
|
|
|
|
|
if (date != null && scoreItem != null && scoreItemSub != null && person != null
|
|
|
&& oriScore != null && oriScore.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
@@ -149,6 +230,61 @@ public class ContribBillFormPlugin extends AbstractFormPlugin implements Plugin,
|
|
|
DynamicObject scoreItemSub = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_SCOREITEMSUB));
|
|
|
DynamicObject scoreItemRank = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_SCOREITEMRANK));
|
|
|
|
|
|
+
|
|
|
+ if (date != null && scoreItem != null && scoreItemSub != null) {
|
|
|
+
|
|
|
+ DynamicObjectCollection entryEntity = this.getModel().getEntryEntity(FormConstant.NCKD_ENTRYENTITY);
|
|
|
+ String scoreItemNumber = scoreItem.getString(FormConstant.NUMBER_KEY);
|
|
|
+ if(ScoreItemEnum.RESEARCH_SCORE.getCode().equalsIgnoreCase(scoreItemNumber)){
|
|
|
+ if(scoreItemRank != null) {
|
|
|
+ //科研与创新需要需要匹配积分规则
|
|
|
+ QFilter filter = new QFilter(String.join(".", FormConstant.NCKD_ENTRYENTITY, ContributionConstant.NCKD_SCOREITEM), QCP.equals, scoreItem.getLong(FormConstant.ID_KEY))
|
|
|
+ .and(new QFilter(String.join(".", FormConstant.NCKD_ENTRYENTITY, ContributionConstant.NCKD_SCOREITEMSUB), QCP.equals, scoreItemSub.getLong(FormConstant.ID_KEY)))
|
|
|
+ .and(new QFilter(String.join(".", FormConstant.NCKD_ENTRYENTITY, ContributionConstant.NCKD_SCOREITEMRANK), QCP.equals, scoreItemRank.getLong(FormConstant.ID_KEY)));
|
|
|
+ Map<String, BigDecimal> scoreConf = ContributionHelper.getScoreConf(filter);
|
|
|
+ String key = scoreItem.getLong(FormConstant.ID_KEY)+"-"+scoreItemSub.getLong(FormConstant.ID_KEY)+"-"+scoreItemRank.getLong(FormConstant.ID_KEY);
|
|
|
+ for (int i = 0; i < entryEntity.size(); i++) {
|
|
|
+ DynamicObject entry = entryEntity.get(i);
|
|
|
+ BigDecimal oriScore = entry.getBigDecimal(ContributionConstant.NCKD_ORISCORE);
|
|
|
+ BigDecimal validScore = oriScore;
|
|
|
+ if(!scoreConf.isEmpty() && scoreConf.containsKey(key)){
|
|
|
+ BigDecimal maxScore = scoreConf.get(key);
|
|
|
+ if (maxScore != null && oriScore != null) {
|
|
|
+ validScore = oriScore.compareTo(maxScore) > 0 ? maxScore : oriScore;
|
|
|
+ } else {
|
|
|
+ // 根据业务需求处理 null 值情况
|
|
|
+ validScore = oriScore != null ? oriScore : BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.getModel().setValue(ContributionConstant.NCKD_SCORE, validScore, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ for (int i = 0; i < entryEntity.size(); i++) {
|
|
|
+ DynamicObject entry = entryEntity.get(i);
|
|
|
+ BigDecimal oriScore = entry.getBigDecimal(ContributionConstant.NCKD_ORISCORE);
|
|
|
+ this.getModel().setValue(ContributionConstant.NCKD_SCORE, oriScore, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理表头字段变更
|
|
|
+ * 表头变更则重新计算所有分录(已维护人员和原积分的数据)的积分
|
|
|
+ * @param
|
|
|
+ * @return: void
|
|
|
+ * @author W.Y.C
|
|
|
+ * @date: 2025/10/26 19:47
|
|
|
+ */
|
|
|
+ private void handleHeadFieldChange1() {
|
|
|
+ Long id = ConvertUtil.toLong(this.getModel().getValue(FormConstant.ID_KEY));
|
|
|
+ Date date = ConvertUtil.toDate(this.getModel().getValue(ContributionConstant.NCKD_YEAR));
|
|
|
+ DynamicObject scoreItem = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_SCOREITEM));
|
|
|
+ DynamicObject scoreItemSub = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_SCOREITEMSUB));
|
|
|
+ DynamicObject scoreItemRank = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(ContributionConstant.NCKD_SCOREITEMRANK));
|
|
|
+
|
|
|
if (date != null && scoreItem != null && scoreItemSub != null) {
|
|
|
//重置分录所有分录的"录用积分"字段
|
|
|
DynamicObjectCollection entryEntity = this.getModel().getEntryEntity(FormConstant.NCKD_ENTRYENTITY);
|