|
|
@@ -3,6 +3,7 @@ package nckd.jxccl.swc.mas.plugin.form.structappr;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
import kd.bos.entity.constant.StatusEnum;
|
|
|
+import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
|
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
|
@@ -11,15 +12,23 @@ import kd.bos.orm.query.QFilter;
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
import kd.sdk.plugin.Plugin;
|
|
|
import nckd.jxccl.base.common.constant.FormConstant;
|
|
|
-import nckd.jxccl.base.common.enums.ProjectCategoryEnum;
|
|
|
+import nckd.jxccl.base.common.enums.mas.ProjectCategoryEnum;
|
|
|
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.orm.helper.QFilterCommonHelper;
|
|
|
import nckd.jxccl.swc.mas.common.MasConstant;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
+import java.util.EventObject;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
@@ -31,7 +40,20 @@ import java.util.stream.Stream;
|
|
|
*/
|
|
|
public class EntleaderAnlSalStdFormPlugin extends AbstractFormPlugin implements Plugin {
|
|
|
|
|
|
+ @Override
|
|
|
+ public void afterBindData(EventObject e) {
|
|
|
+ DynamicObjectCollection entryCollection = this.getModel().getEntryEntity(FormConstant.NCKD_ENTRYENTITY);
|
|
|
+ for (int rowIndex = 0; rowIndex < entryCollection.size(); rowIndex++) {
|
|
|
+ DynamicObject entry = entryCollection.get(rowIndex);
|
|
|
+ int installmentYears = entry.getInt(MasConstant.NCKD_INSTALLMENTYEARS);
|
|
|
+ initOperateOption(installmentYears,rowIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public void afterAddRow(AfterAddRowEventArgs e) {
|
|
|
+ initOperateOption(0,e.getInsertRow());
|
|
|
+ }
|
|
|
@Override
|
|
|
public void propertyChanged(PropertyChangedArgs e) {
|
|
|
String fieldKey = e.getProperty().getName();
|
|
|
@@ -39,12 +61,113 @@ public class EntleaderAnlSalStdFormPlugin extends AbstractFormPlugin implements
|
|
|
int rowIndex = changeSet[0].getRowIndex();
|
|
|
Object oldValue = changeSet[0].getOldValue();
|
|
|
Object newValue = changeSet[0].getNewValue();
|
|
|
- if(Stream.of(MasConstant.NCKD_PAYUNIT, MasConstant.NCKD_LAWENTITY, MasConstant.NCKD_YEAR)
|
|
|
+ if(MasConstant.NCKD_INSTALLMENTYEARS.equalsIgnoreCase(fieldKey)){
|
|
|
+ if(!Objects.equals(oldValue, newValue)){
|
|
|
+ initOperateOption(ConvertUtil.toInt(newValue),rowIndex);
|
|
|
+ }
|
|
|
+ }else if(Stream.of(MasConstant.NCKD_PAYUNIT, MasConstant.NCKD_LAWENTITY, MasConstant.NCKD_YEAR)
|
|
|
.anyMatch(op -> op.equalsIgnoreCase(fieldKey))){
|
|
|
if(!Objects.equals(oldValue, newValue)){
|
|
|
DynamicObjectCollection entryEntities = getModel().getEntryEntity(FormConstant.NCKD_ENTRYENTITY);
|
|
|
load();
|
|
|
}
|
|
|
+ }else if(MasConstant.NCKD_APPRSTD.equalsIgnoreCase(fieldKey)){
|
|
|
+ DynamicObject payUnit = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(MasConstant.NCKD_PAYUNIT));
|
|
|
+ DynamicObject lawEntity = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(MasConstant.NCKD_LAWENTITY));
|
|
|
+ DynamicObject projectCategory = ConvertUtil.toDynamicObjectOrNull(this.getModel().getValue(MasConstant.NCKD_PROJECTCATEGORY));
|
|
|
+ Date year = ConvertUtil.toDate(this.getModel().getValue(MasConstant.NCKD_YEAR));
|
|
|
+ //判断“核定标准”是否大于0
|
|
|
+ BigDecimal apprStd = ConvertUtil.toBigDecimal(newValue);
|
|
|
+ if(apprStd != null && apprStd.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (payUnit != null && lawEntity != null && year != null && projectCategory != null) {
|
|
|
+ if (!Objects.equals(oldValue, newValue)) {
|
|
|
+ //计算:延期支付总金额、支付年份1、支付年份1....
|
|
|
+ //====================================== 获取延期支付比例 begin ======================================
|
|
|
+ LocalDateTime localDateTime = DateUtil.toLocalDateTime(year);
|
|
|
+ LocalDateTime beginOfYear = DateUtil.beginOfYear(localDateTime);
|
|
|
+ LocalDateTime endOfYear = DateUtil.endOfYear(localDateTime);
|
|
|
+
|
|
|
+ QueryFieldBuilder deferPayRatoConfQueryFieldBuilder = QueryFieldBuilder.create()
|
|
|
+ .add(MasConstant.NCKD_PROJECTCATEGORY)
|
|
|
+ .addIdNumberName(MasConstant.NCKD_PAYUNIT)
|
|
|
+ .addIdNumberName(MasConstant.NCKD_DEFERPAYMONEY)
|
|
|
+ .add(MasConstant.NCKD_DEFERPAYRATIO)
|
|
|
+ .add(MasConstant.NCKD_DEFERPAYRATIO)
|
|
|
+ .add(MasConstant.NCKD_PAYOUTTIMES)
|
|
|
+ .add(MasConstant.NCKD_YEAR)
|
|
|
+ .add(FormConstant.NCKD_ENTRYENTITY)
|
|
|
+ .add(FormConstant.NCKD_ENTRYENTITY, MasConstant.NCKD_TIMES)
|
|
|
+ .add(FormConstant.NCKD_ENTRYENTITY, MasConstant.NCKD_PAYOUTRATIO)
|
|
|
+ .add(FormConstant.NCKD_ENTRYENTITY, MasConstant.NCKD_PAYOUTMONEY)
|
|
|
+ .add(FormConstant.NCKD_ENTRYENTITY, MasConstant.NCKD_DEFERREDPAYITEM)
|
|
|
+ .add(FormConstant.NCKD_ENTRYENTITY, MasConstant.NCKD_DEFERREDPAYDESC)
|
|
|
+ .add(FormConstant.NCKD_ENTRYENTITY, MasConstant.NCKD_TERMPAYDESC)
|
|
|
+ .orderDesc(MasConstant.CREATE_TIME_KEY)
|
|
|
+ .orderAsc(String.join(".",FormConstant.NCKD_ENTRYENTITY, MasConstant.NCKD_TIMES));
|
|
|
+ QFilter deferPayRatoConfFilter = new QFilter(MasConstant.NCKD_PAYUNIT, QCP.equals, payUnit.getLong(FormConstant.ID_KEY))
|
|
|
+ .and(MasConstant.NCKD_LAWENTITY, QCP.equals, lawEntity.getLong(FormConstant.ID_KEY))
|
|
|
+ .and(MasConstant.NCKD_YEAR, QCP.large_equals, DateUtil.toDate(beginOfYear))
|
|
|
+ .and(MasConstant.NCKD_YEAR, QCP.less_equals, DateUtil.toDate(endOfYear))
|
|
|
+ .and(QFilterCommonHelper.getEnableFilter());
|
|
|
+ DynamicObject[] dbDeferPayRatoConfArray = BusinessDataServiceHelper.load(MasConstant.DEFERPAYRATOCONF_ENTITYID, deferPayRatoConfQueryFieldBuilder.buildSelect(), new QFilter[]{deferPayRatoConfFilter});
|
|
|
+ Map<String, List<DynamicObject>> dbDeferPayRatoConfMap = Arrays.stream(dbDeferPayRatoConfArray)
|
|
|
+ .collect(Collectors.groupingBy(obj -> {
|
|
|
+ DynamicObject dbProjectCategory = obj.getDynamicObject(MasConstant.NCKD_PROJECTCATEGORY);
|
|
|
+ if (dbProjectCategory != null) {
|
|
|
+ return dbProjectCategory.getString(FormConstant.NUMBER_KEY);
|
|
|
+ }
|
|
|
+ return ""; // 处理无项目分类的情况
|
|
|
+ }));
|
|
|
+ List<DynamicObject> dbDeferPayRatoConfList = dbDeferPayRatoConfMap.get(projectCategory.getString(FormConstant.NUMBER_KEY));
|
|
|
+
|
|
|
+ if (dbDeferPayRatoConfList != null && !dbDeferPayRatoConfList.isEmpty()) {
|
|
|
+ DynamicObject deferPayRatoConf = dbDeferPayRatoConfList.get(0);
|
|
|
+ //延期支付比例(%)
|
|
|
+ BigDecimal deferPayRatio = deferPayRatoConf.getBigDecimal(MasConstant.NCKD_DEFERPAYRATIO);
|
|
|
+ //延期支付金额
|
|
|
+ BigDecimal deferPayMoney = deferPayRatoConf.getBigDecimal(MasConstant.NCKD_DEFERPAYMONEY);
|
|
|
+ LocalDateTime beginYear = DateUtil.toLocalDateTime(deferPayRatoConf.getDate(MasConstant.NCKD_YEAR));
|
|
|
+ BigDecimal deferPayTotalAmt;
|
|
|
+ if(deferPayMoney != null && deferPayMoney.compareTo(BigDecimal.ZERO) > 0){
|
|
|
+ //优先使用【延期支付金额】
|
|
|
+ deferPayTotalAmt = deferPayMoney;
|
|
|
+ }else {
|
|
|
+ //核算标准*延期支付比例/100
|
|
|
+ deferPayTotalAmt = apprStd.multiply(deferPayRatio.divide(new BigDecimal(100), 2, RoundingMode.DOWN));
|
|
|
+ }
|
|
|
+ this.getModel().setValue(MasConstant.NCKD_DEFERPAYTOTALAMT, deferPayTotalAmt,rowIndex);
|
|
|
+ DynamicObjectCollection entryColl = deferPayRatoConf.getDynamicObjectCollection(FormConstant.NCKD_ENTRYENTITY);
|
|
|
+ int i = 0;
|
|
|
+ for (DynamicObject entry : entryColl) {
|
|
|
+ int times = entry.getInt(MasConstant.NCKD_TIMES);
|
|
|
+ //兑现比例(%)
|
|
|
+ BigDecimal payoutRatio = entry.getBigDecimal(MasConstant.NCKD_PAYOUTRATIO);
|
|
|
+ //兑现金额
|
|
|
+ BigDecimal payoutMoney = entry.getBigDecimal(MasConstant.NCKD_PAYOUTMONEY);
|
|
|
+ BigDecimal payaMount;
|
|
|
+ if(payoutMoney != null && payoutMoney.compareTo(BigDecimal.ZERO) > 0){
|
|
|
+ //优先使用【兑现金额】
|
|
|
+ payaMount = payoutMoney;
|
|
|
+ }else{
|
|
|
+ //延期支付总金额*兑现比例
|
|
|
+ payaMount = deferPayTotalAmt.multiply(payoutRatio.divide(new BigDecimal(100), 2, RoundingMode.DOWN));
|
|
|
+ }
|
|
|
+ if(i != 0){
|
|
|
+ beginYear = DateUtil.addYears(beginYear, 1);
|
|
|
+ }
|
|
|
+ this.getModel().setValue(MasConstant.NCKD_PAYYEAR+(i+1), DateUtil.toDate(beginYear),rowIndex);
|
|
|
+ this.getModel().setValue(MasConstant.NCKD_PAYAMOUNT+(i+1), payaMount,rowIndex);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //====================================== 获取延期支付比例 end ======================================
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.getModel().setValue(MasConstant.NCKD_DEFERPAYTOTALAMT, null);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -96,6 +219,32 @@ public class EntleaderAnlSalStdFormPlugin extends AbstractFormPlugin implements
|
|
|
this.getView().showTipNotification("未加载到数据,根据【所属二级单位】、【法人组织】及【年度】未加载到对应“子企业负责人薪酬结构”数据!");
|
|
|
}
|
|
|
//====================================== 获取子企业负责人薪酬结构 end ======================================
|
|
|
+ //====================================== 获取延期支付比例 begin ======================================
|
|
|
+ QueryFieldBuilder deferPayRatoConfQueryFieldBuilder = QueryFieldBuilder.create()
|
|
|
+ .addIdNumberName(MasConstant.NCKD_PROJECTCATEGORY)
|
|
|
+ .addIdNumberName(MasConstant.NCKD_PAYUNIT)
|
|
|
+ .addIdNumberName(MasConstant.NCKD_LAWENTITY)
|
|
|
+ .add(MasConstant.NCKD_DEFERPAYRATIO)
|
|
|
+ .add(MasConstant.NCKD_PAYOUTTIMES)
|
|
|
+ .add(MasConstant.NCKD_YEAR)
|
|
|
+ .orderDesc(MasConstant.CREATE_TIME_KEY);
|
|
|
+ QFilter deferPayRatoConfFilter = new QFilter(MasConstant.NCKD_PAYUNIT, QCP.equals, payUnit.getLong(FormConstant.ID_KEY))
|
|
|
+ .and(MasConstant.NCKD_LAWENTITY, QCP.equals, lawEntity.getLong(FormConstant.ID_KEY))
|
|
|
+ .and(MasConstant.NCKD_YEAR, QCP.large_equals, DateUtil.toDate(beginOfYear))
|
|
|
+ .and(MasConstant.NCKD_YEAR, QCP.less_equals, DateUtil.toDate(endOfYear))
|
|
|
+ .and(QFilterCommonHelper.getEnableFilter());
|
|
|
+ DynamicObject[] dbDeferPayRatoConfArray = BusinessDataServiceHelper.load(MasConstant.DEFERPAYRATOCONF_ENTITYID, deferPayRatoConfQueryFieldBuilder.buildSelect(), new QFilter[]{deferPayRatoConfFilter});
|
|
|
+ Map<String, List<DynamicObject>> dbDeferPayRatoConfMap = Arrays.stream(dbDeferPayRatoConfArray)
|
|
|
+ .collect(Collectors.groupingBy(obj -> {
|
|
|
+ DynamicObject projectCategory = obj.getDynamicObject(MasConstant.NCKD_PROJECTCATEGORY);
|
|
|
+ if (projectCategory != null) {
|
|
|
+ return projectCategory.getString(FormConstant.NUMBER_KEY);
|
|
|
+ }
|
|
|
+ return ""; // 处理无项目分类的情况
|
|
|
+ }));
|
|
|
+ //====================================== 获取延期支付比例 end ======================================
|
|
|
+
|
|
|
+
|
|
|
DynamicObjectCollection entryEntities = getModel().getEntryEntity(FormConstant.NCKD_ENTRYENTITY);
|
|
|
entryEntities.clear();
|
|
|
//====================================== 构建分录数据 begin ======================================
|
|
|
@@ -106,8 +255,9 @@ public class EntleaderAnlSalStdFormPlugin extends AbstractFormPlugin implements
|
|
|
for (DynamicObject dbEntryEntity : dbEntryColl) {
|
|
|
DynamicObject projectCategory = dbEntryEntity.getDynamicObject(MasConstant.NCKD_PROJECTCATEGORY);
|
|
|
String projectCategoryNumber = projectCategory.getString(FormConstant.NUMBER_KEY);
|
|
|
- if(!projectCategoryNumber.equalsIgnoreCase(ProjectCategoryEnum.TERM_INCENTIVE.getCode()) && !projectCategoryNumber.equalsIgnoreCase(ProjectCategoryEnum.LONGTERM_INCENTIVE.getCode())) {
|
|
|
+ if(projectCategoryNumber.equalsIgnoreCase(ProjectCategoryEnum.YEARLY_SALARY.getCode())) {
|
|
|
DynamicObject entry = entryEntities.addNew();
|
|
|
+ entry.set(MasConstant.NCKD_PROJECTCATEGORY, dbEntryEntity.getDynamicObject(MasConstant.NCKD_PROJECTCATEGORY));
|
|
|
entry.set(MasConstant.NCKD_EMPLOYEE, dbSubCoHeadService.get(MasConstant.NCKD_EMPLOYEE));
|
|
|
entry.set(MasConstant.NCKD_POSNAME, dbSubCoHeadService.get(MasConstant.NCKD_POSNAME));
|
|
|
entry.set(MasConstant.NCKD_SERVICEMONTHS, dbSubCoHeadService.get(MasConstant.NCKD_SERVICEMONTHS));
|
|
|
@@ -117,6 +267,13 @@ public class EntleaderAnlSalStdFormPlugin extends AbstractFormPlugin implements
|
|
|
entry.set(MasConstant.NCKD_POSTLEVEL, dbSubCoHeadService.get(MasConstant.NCKD_POSTLEVEL));
|
|
|
entry.set(MasConstant.NCKD_SALNEGOT, dbSubCoHeadService.get(MasConstant.NCKD_SALNEGOT));
|
|
|
entry.set(MasConstant.NCKD_SALARYITEM, dbEntryEntity.get(MasConstant.NCKD_SALARYITEM));
|
|
|
+ entry.set(MasConstant.NCKD_DEFERREDPAYITEM, dbEntryEntity.getBoolean(MasConstant.NCKD_DEFERREDPAYITEM));
|
|
|
+ //根据【项目分类】获取延期支付比例配置
|
|
|
+ List<DynamicObject> dbDeferPayRatoConfList = dbDeferPayRatoConfMap.get(projectCategoryNumber);
|
|
|
+ if(dbDeferPayRatoConfList != null && !dbDeferPayRatoConfList.isEmpty()){
|
|
|
+ DynamicObject dbDeferPayRatoConf = dbDeferPayRatoConfList.get(0);
|
|
|
+ entry.set(MasConstant.NCKD_INSTALLMENTYEARS, dbDeferPayRatoConf.getInt(MasConstant.NCKD_PAYOUTTIMES));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -125,9 +282,36 @@ public class EntleaderAnlSalStdFormPlugin extends AbstractFormPlugin implements
|
|
|
this.getView().showSuccessNotification("数据加载成功!");
|
|
|
}
|
|
|
//====================================== 构建分录数据 end ======================================
|
|
|
+ for (int rowIndex = 0; rowIndex < entryEntities.size(); rowIndex++) {
|
|
|
+ DynamicObject entry = entryEntities.get(rowIndex);
|
|
|
+ int installmentYears = entry.getInt(MasConstant.NCKD_INSTALLMENTYEARS);
|
|
|
+ initOperateOption(installmentYears,rowIndex);
|
|
|
+ }
|
|
|
getModel().updateEntryCache(entryEntities);
|
|
|
getView().updateView(FormConstant.NCKD_ENTRYENTITY);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置支付N锁定或解锁
|
|
|
+ * @param installmentYears 分期支付年
|
|
|
+ * @param rowIndex 行索引
|
|
|
+ * @return: void
|
|
|
+ * @author W.Y.C
|
|
|
+ * @date: 2025/11/29 20:48
|
|
|
+ */
|
|
|
+ private void initOperateOption(int installmentYears, int rowIndex) {
|
|
|
+ if(rowIndex > -1) {
|
|
|
+ for (int i = 1; i <= 10; i++) {
|
|
|
+ this.getView().setEnable(false, rowIndex, MasConstant.NCKD_PAYYEAR + i);
|
|
|
+ this.getView().setEnable(false, rowIndex, MasConstant.NCKD_PAYAMOUNT + i);
|
|
|
+ }
|
|
|
+ for (int i = 1; i <= installmentYears; i++) {
|
|
|
+ this.getView().setEnable(true, rowIndex, MasConstant.NCKD_PAYYEAR + i);
|
|
|
+ this.getView().setEnable(true, rowIndex, MasConstant.NCKD_PAYAMOUNT + i);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|