Compare commits
No commits in common. "728ec480c0f20b68f0f04b32c7bbda5a6e9ec8fb" and "ad460d8b8009109d947cf82f4f739f582cdbcb6e" have entirely different histories.
728ec480c0
...
ad460d8b80
|
|
@ -11,10 +11,7 @@ import kd.bos.form.control.events.ItemClickEvent;
|
||||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.EventObject;
|
import java.util.EventObject;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 使用插件注册位置:支出合同结算表单插件
|
* 使用插件注册位置:支出合同结算表单插件
|
||||||
|
|
@ -60,12 +57,11 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin {
|
||||||
newProcessAllocEntity.set("zcgj_amountnotax", listEntry.get("thisamount"));//不含税金额-本期计量金额
|
newProcessAllocEntity.set("zcgj_amountnotax", listEntry.get("thisamount"));//不含税金额-本期计量金额
|
||||||
newProcessAllocEntity.set("zcgj_rateval", listEntry.get("entrytaxrate"));//税率(%)-税率(%)
|
newProcessAllocEntity.set("zcgj_rateval", listEntry.get("entrytaxrate"));//税率(%)-税率(%)
|
||||||
newProcessAllocEntity.set("zcgj_taxamt", listEntry.get("thistax"));//税额-本期税额
|
newProcessAllocEntity.set("zcgj_taxamt", listEntry.get("thistax"));//税额-本期税额
|
||||||
|
newProcessAllocEntity.set("zcgj_pa_remark", listEntry.get("desc"));//费用说明-说明
|
||||||
processAllocEntityCollection.add(newProcessAllocEntity);
|
processAllocEntityCollection.add(newProcessAllocEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 添加合并逻辑:按工序和税率组合合并相同项
|
|
||||||
mergeProcessAllocEntriesByProcessAndRate(processAllocEntityCollection);
|
|
||||||
}
|
}
|
||||||
this.getView().updateView("zcgj_processallocatentity");//工序分摊
|
this.getView().updateView("zcgj_processallocatentity");//工序分摊
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -128,87 +124,14 @@ public class CostAllocatorBillPlugin extends AbstractFormPlugin {
|
||||||
newProcessAllocEntity.set("zcgj_amountnotax", listEntry.get("thisamount"));//不含税金额-本期计量金额
|
newProcessAllocEntity.set("zcgj_amountnotax", listEntry.get("thisamount"));//不含税金额-本期计量金额
|
||||||
newProcessAllocEntity.set("zcgj_rateval", listEntry.get("entrytaxrate"));//税率(%)-税率(%)
|
newProcessAllocEntity.set("zcgj_rateval", listEntry.get("entrytaxrate"));//税率(%)-税率(%)
|
||||||
newProcessAllocEntity.set("zcgj_taxamt", listEntry.get("thistax"));//税额-本期税额
|
newProcessAllocEntity.set("zcgj_taxamt", listEntry.get("thistax"));//税额-本期税额
|
||||||
|
newProcessAllocEntity.set("zcgj_pa_remark", listEntry.get("desc"));//费用说明-说明
|
||||||
processAllocEntityCollection.add(newProcessAllocEntity);
|
processAllocEntityCollection.add(newProcessAllocEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 添加合并逻辑:按工序和税率组合合并相同项
|
|
||||||
mergeProcessAllocEntriesByProcessAndRate(processAllocEntityCollection);
|
|
||||||
this.getView().updateView("zcgj_processallocatentity");//工序分摊
|
this.getView().updateView("zcgj_processallocatentity");//工序分摊
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 按工序和税率组合合并工序分摊条目
|
|
||||||
*
|
|
||||||
* @param processAllocEntityCollection 工序分摊集合
|
|
||||||
*/
|
|
||||||
private void mergeProcessAllocEntriesByProcessAndRate(DynamicObjectCollection processAllocEntityCollection) {
|
|
||||||
// 使用Map来存储已存在的工序+税率组合,避免嵌套循环
|
|
||||||
Map<String, DynamicObject> processRateMap = new HashMap<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < processAllocEntityCollection.size(); i++) {
|
|
||||||
DynamicObject currentEntry = processAllocEntityCollection.get(i);
|
|
||||||
Object currentProcess = currentEntry.get("zcgj_pa_process"); // 工序
|
|
||||||
Object currentRate = currentEntry.get("zcgj_rateval"); // 税率
|
|
||||||
|
|
||||||
// 创建唯一键值:工序ID + 税率值
|
|
||||||
String key = (currentProcess != null ? currentProcess.toString() : "null") +
|
|
||||||
"_" +
|
|
||||||
(currentRate != null ? currentRate.toString() : "null");
|
|
||||||
|
|
||||||
if (processRateMap.containsKey(key)) {
|
|
||||||
// 如果已存在相同组合,则合并数值
|
|
||||||
DynamicObject existingEntry = processRateMap.get(key);
|
|
||||||
|
|
||||||
// 合并价税合计
|
|
||||||
BigDecimal currentAmount = toBigDecimal(existingEntry.get("zcgj_pa_amount"));
|
|
||||||
BigDecimal nextAmount = toBigDecimal(currentEntry.get("zcgj_pa_amount"));
|
|
||||||
existingEntry.set("zcgj_pa_amount", currentAmount.add(nextAmount));
|
|
||||||
|
|
||||||
// 合并不含税金额
|
|
||||||
BigDecimal currentAmountNoTax = toBigDecimal(existingEntry.get("zcgj_amountnotax"));
|
|
||||||
BigDecimal nextAmountNoTax = toBigDecimal(currentEntry.get("zcgj_amountnotax"));
|
|
||||||
existingEntry.set("zcgj_amountnotax", currentAmountNoTax.add(nextAmountNoTax));
|
|
||||||
|
|
||||||
// 合并税额
|
|
||||||
BigDecimal currentTaxAmt = toBigDecimal(existingEntry.get("zcgj_taxamt"));
|
|
||||||
BigDecimal nextTaxAmt = toBigDecimal(currentEntry.get("zcgj_taxamt"));
|
|
||||||
existingEntry.set("zcgj_taxamt", currentTaxAmt.add(nextTaxAmt));
|
|
||||||
|
|
||||||
// 移除当前条目
|
|
||||||
processAllocEntityCollection.remove(i);
|
|
||||||
i--; // 调整索引
|
|
||||||
} else {
|
|
||||||
// 如果不存在相同组合,则添加到Map中
|
|
||||||
processRateMap.put(key, currentEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将对象转换为BigDecimal类型
|
|
||||||
*
|
|
||||||
* @param obj 待转换对象
|
|
||||||
* @return BigDecimal值
|
|
||||||
*/
|
|
||||||
private BigDecimal toBigDecimal(Object obj) {
|
|
||||||
if (obj == null) {
|
|
||||||
return BigDecimal.ZERO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj instanceof BigDecimal) {
|
|
||||||
return (BigDecimal) obj;
|
|
||||||
} else if (obj instanceof Number) {
|
|
||||||
return new BigDecimal(obj.toString());
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return new BigDecimal(obj.toString());
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return BigDecimal.ZERO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
|
||||||
|
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
|
||||||
import kd.bos.entity.ExtendedDataEntity;
|
|
||||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
|
||||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
|
||||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
|
||||||
import kd.bos.entity.validate.AbstractValidator;
|
|
||||||
import kd.bos.orm.query.QFilter;
|
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工序期间成本预算保存提交操作插件;
|
|
||||||
* 说明:校验项目加期间加版本的组合是否存在,存在便提示不可重复创建
|
|
||||||
*/
|
|
||||||
public class PeriodCostBSaveOrSubOp extends AbstractOperationServicePlugIn {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
|
||||||
super.onPreparePropertys(e);
|
|
||||||
e.getFieldKeys().add("period");//期间
|
|
||||||
e.getFieldKeys().add("project");//项目
|
|
||||||
e.getFieldKeys().add("versionno");//版本号
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
|
||||||
super.onAddValidators(e);
|
|
||||||
e.getValidators().add(new PeriodCostBSaveOrSubOp.ValidatorExt());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ValidatorExt extends AbstractValidator {
|
|
||||||
@Override
|
|
||||||
public void validate() {
|
|
||||||
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
|
|
||||||
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
|
||||||
DynamicObject extendedData = extendedDataEntity.getDataEntity();
|
|
||||||
DynamicObject project = extendedData.getDynamicObject("project");//项目
|
|
||||||
DynamicObject period = extendedData.getDynamicObject("period");//期间
|
|
||||||
BigDecimal versionNo = extendedData.getBigDecimal("versionno");//版本号
|
|
||||||
QFilter filter = new QFilter("project", "=", project.getPkValue());
|
|
||||||
filter.and(new QFilter("period", "=", period.getPkValue()));
|
|
||||||
filter.and(new QFilter("versionno", "=", versionNo));
|
|
||||||
DynamicObject ecco_periodcostbillcbs = BusinessDataServiceHelper.loadSingle("ecco_periodcostbillcbs", "id", new QFilter[]{filter});
|
|
||||||
if (ecco_periodcostbillcbs != null) {
|
|
||||||
if (extendedData.getPkValue().equals(ecco_periodcostbillcbs.getPkValue())){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.addFatalErrorMessage(extendedDataEntity, "该期间的项目已编制预算,请勿重复创建!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue