439 lines
15 KiB
Java
439 lines
15 KiB
Java
|
package shkd.repc.recos.formplugin;
|
||
|
|
||
|
import kd.bos.dataentity.OperateOption;
|
||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||
|
import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
||
|
import kd.bos.entity.datamodel.IDataModel;
|
||
|
import kd.bos.form.IFormView;
|
||
|
import kd.bos.form.control.TreeEntryGrid;
|
||
|
import kd.bos.form.control.events.ItemClickEvent;
|
||
|
import kd.bos.form.control.events.RowClickEvent;
|
||
|
import kd.bos.form.events.*;
|
||
|
import kd.bos.orm.query.QFilter;
|
||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||
|
import kd.repc.rebas.common.util.ReDigitalUtil;
|
||
|
import kd.repc.rebas.formplugin.helper.RebasTreeEntryGridHelper;
|
||
|
import kd.repc.recos.business.split.ReConSplitHelper;
|
||
|
import kd.repc.recos.formplugin.split.base.ReBillSplitTplEditPlugin;
|
||
|
import kd.repc.recos.formplugin.split.base.helper.*;
|
||
|
import kd.repc.recos.formplugin.split.consplit.ReConSplitEditPlugin;
|
||
|
import kd.repc.recos.formplugin.split.consplit.ReConSplitPropertyChanged;
|
||
|
import kd.sdk.plugin.Plugin;
|
||
|
|
||
|
import java.math.BigDecimal;
|
||
|
import java.util.*;
|
||
|
|
||
|
/**
|
||
|
* 成本合约规划拆分继承ReBillSplitTplEditPlugin
|
||
|
*
|
||
|
*/
|
||
|
public class ReConSplitEditPluginExt extends ReConSplitEditPlugin implements Plugin {
|
||
|
public ReConSplitEditPluginExt() {
|
||
|
super();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected ReConSplitPropertyChanged getPropertyChanged() {
|
||
|
return super.getPropertyChanged();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected ReConSplitHelper getReBillSplitHelper() {
|
||
|
return super.getReBillSplitHelper();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String getSrcBillProps() {
|
||
|
return super.getSrcBillProps();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected List<String> getNoTaxColumns() {
|
||
|
return super.getNoTaxColumns();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public List<String> getSummaryColumns() {
|
||
|
return super.getSummaryColumns();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void afterCreateNewData(EventObject e) {
|
||
|
super.afterCreateNewData(e);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void afterLoadData(EventObject e) {
|
||
|
super.afterLoadData(e);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void afterBindData(EventObject e) {
|
||
|
super.afterBindData(e);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void clearEntryByContractBizDptChanged() {
|
||
|
super.clearEntryByContractBizDptChanged();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void handleControlVisible() {
|
||
|
super.handleControlVisible();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String[] costAccumulateCanEditFieldsInWf() {
|
||
|
return super.costAccumulateCanEditFieldsInWf();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String[] costAccumulateCanEditButtonsInWf() {
|
||
|
return super.costAccumulateCanEditButtonsInWf();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void setConBill(DynamicObject dataEntity, DynamicObject srcBillObj) {
|
||
|
super.setConBill(dataEntity, srcBillObj);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void loadCustomColumns() {
|
||
|
super.loadCustomColumns();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void closedCallBackSelectConPlan(ClosedCallBackEvent evt) {
|
||
|
super.closedCallBackSelectConPlan(evt);
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public void afterDoOperation(AfterDoOperationEventArgs args) {
|
||
|
super.afterDoOperation(args);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void initSplitData(DynamicObject srcBillObj) {
|
||
|
super.initSplitData(srcBillObj);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void itemClick(ItemClickEvent evt) {
|
||
|
super.itemClick(evt);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void registerProjectF7() {
|
||
|
super.registerProjectF7();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected ReConPlanSplitHelper getConPlanSplitHelper() {
|
||
|
return super.getConPlanSplitHelper();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected ReProductSplitHelper getProductSplitHelper() {
|
||
|
return super.getProductSplitHelper();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected ReBuildingSplitHelper getBuildingSplitHelper() {
|
||
|
return super.getBuildingSplitHelper();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected ReSplitConPlanBorHelper getReSplitConPlanBorHelper() {
|
||
|
return super.getReSplitConPlanBorHelper();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void registerListener(EventObject e) {
|
||
|
super.registerListener(e);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void beforeFieldPostBack(BeforeFieldPostBackEvent e) {
|
||
|
super.beforeFieldPostBack(e);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void setOpenSource() {
|
||
|
super.setOpenSource();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected DynamicObject getSrcBill(Object srcBillId) {
|
||
|
return super.getSrcBill(srcBillId);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean isTaxCtrl() {
|
||
|
return super.isTaxCtrl();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void setSplitAmount(DynamicObject dataEntity, DynamicObject srcBillObj) {
|
||
|
super.setSplitAmount(dataEntity, srcBillObj);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void initSplitEntryData() {
|
||
|
super.initSplitEntryData();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String getUpperSplitPropertys() {
|
||
|
return super.getUpperSplitPropertys();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected Long getUpperSplitSrcBill() {
|
||
|
return super.getUpperSplitSrcBill();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected String getUpperSplitEntityName() {
|
||
|
return super.getUpperSplitEntityName();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void setSplitEntryByUpperSplitEntry(DynamicObjectCollection splitEntrys, DynamicObjectType splitEntryType, DynamicObjectCollection upperSplitEntrys) {
|
||
|
super.setSplitEntryByUpperSplitEntry(splitEntrys, splitEntryType, upperSplitEntrys);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void setSplitEntryProperty(DynamicObject upperSplitEntry, DynamicObject splitEntry) {
|
||
|
super.setSplitEntryProperty(upperSplitEntry, splitEntry);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void loadBorColumn() {
|
||
|
super.loadBorColumn();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void loadConPlanBor() {
|
||
|
super.loadConPlanBor();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void showCanUseAmt() {
|
||
|
super.showCanUseAmt();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected boolean getNeedBor(DynamicObjectCollection billsplitentrys, boolean flag) {
|
||
|
return super.getNeedBor(billsplitentrys, flag);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected boolean showCanUse(DynamicObject dataModel) {
|
||
|
return super.showCanUse(dataModel);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String getSrcBillType() {
|
||
|
return super.getSrcBillType();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void costVerifyCtrl() {
|
||
|
super.costVerifyCtrl();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean getHideCanSplitAmtFlag(IDataModel dataModel) {
|
||
|
return super.getHideCanSplitAmtFlag(dataModel);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void entryRowClick(RowClickEvent evt) {
|
||
|
super.entryRowClick(evt);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void click(EventObject evt) {
|
||
|
super.click(evt);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void closedCallBack(ClosedCallBackEvent evt) {
|
||
|
super.closedCallBack(evt);
|
||
|
switch (evt.getActionId()) {
|
||
|
case "recos_selectconplantreef7":
|
||
|
this.closedCallBackSelectConPlanExt(evt);
|
||
|
default:
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected void closedCallBackSelectConPlanExt(ClosedCallBackEvent evt) {
|
||
|
DynamicObject split = this.getModel().getDataEntity(true);
|
||
|
Set<Long> returnData = (Set)this.getView().getReturnData();
|
||
|
if (null != returnData) {
|
||
|
if (returnData.isEmpty()) {
|
||
|
this.getModel().getEntryEntity("billsplitentry").clear();
|
||
|
} else {
|
||
|
this.conPlanSplit(returnData.toArray(new Object[0]));
|
||
|
this.getConPlanSplitHelper().setConPayPlanData(returnData.toArray(new Object[0]));
|
||
|
this.loadConPlanBor();
|
||
|
this.getPropertyChanged().getConPlanBor(split);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void conPlanSplit(Object[] conPlanIds) {
|
||
|
if (null != conPlanIds && conPlanIds.length > 0) {
|
||
|
DynamicObject[] conPlanEntrys = BusinessDataServiceHelper.load("recos_conplanentry", String.join(",", "id", "name", "project", "balance", "notaxbalance", "estchgbalance", "estchgnotaxbalance", "hashappenamt", "hashappennotaxamt", "amount", "notaxamt", "ctrmodel", "parent", "costitem", "citem_costaccount", "citem_amount", "citem_notaxamt"), new QFilter[]{new QFilter("id", "in", conPlanIds), new QFilter("isleaf", "=", Boolean.TRUE)});
|
||
|
String srcBillType = super.getSrcBillType();
|
||
|
IFormView view = this.getView();
|
||
|
IDataModel dataModel = this.getModel();
|
||
|
DynamicObject split = dataModel.getDataEntity(true);
|
||
|
Map<Long, Map<String, BigDecimal>> valuesMap = this.calcConPlanScale(split, conPlanEntrys, srcBillType);
|
||
|
DynamicObjectCollection splitEntrys = split.getDynamicObjectCollection("billsplitentry");
|
||
|
DynamicObjectCollection newSplitEntrys = new DynamicObjectCollection(splitEntrys.getDynamicObjectType(), splitEntrys.getParent());
|
||
|
super.getReBillSplitHelper().handleOldSplitEntrys(split, valuesMap, newSplitEntrys, srcBillType);
|
||
|
super.getReBillSplitHelper().handleNewSplitEntrys(split, conPlanEntrys, valuesMap, newSplitEntrys, srcBillType);
|
||
|
splitEntrys.clear();
|
||
|
|
||
|
for(int i = 0; i < newSplitEntrys.size(); ++i) {
|
||
|
DynamicObject newSplitEntry = (DynamicObject)newSplitEntrys.get(i);
|
||
|
newSplitEntry.set("seq", i + 1);
|
||
|
//newSplitEntry.set("entry_splitscale",BigDecimal.ZERO);
|
||
|
splitEntrys.add(newSplitEntry);
|
||
|
}
|
||
|
|
||
|
super.loadCustomColumns();
|
||
|
ReBillSplitTplEditHelper.setLevelSpace(split.getDynamicObjectCollection("billsplitentry"));
|
||
|
view.updateView("billsplitentry");
|
||
|
TreeEntryGrid grid = (TreeEntryGrid)view.getControl("billsplitentry");
|
||
|
RebasTreeEntryGridHelper.expandNodes(grid, "entry_level", 2);
|
||
|
ReBillSplitTplEditHelper.setCustomSummary(this.getView(), this.getModel(), super.getSummaryColumns());
|
||
|
view.setVisible(Boolean.FALSE, new String[]{"bar_productsplit", "bar_buildingsplit"});
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public Map<Long, Map<String, BigDecimal>> calcConPlanScale(DynamicObject split, DynamicObject[] conPlanEntrys, String srcBillType) {
|
||
|
Map<String, BigDecimal> splitFieldParentAmts = getSplitFieldParentAmts(split, true);
|
||
|
BigDecimal sumConPlanAmount = BigDecimal.ZERO;
|
||
|
for (int i = 0; i < conPlanEntrys.length; i++) {
|
||
|
DynamicObject conPlanEntry = conPlanEntrys[i];
|
||
|
sumConPlanAmount = ReDigitalUtil.add(sumConPlanAmount, conPlanEntry.getBigDecimal("amount"));
|
||
|
}
|
||
|
BigDecimal maxScale = ReDigitalUtil.ZERO;
|
||
|
Long maxKey = Long.valueOf(0L);
|
||
|
Map<String, BigDecimal> subAmounts = new HashMap<>();
|
||
|
subAmounts.putAll(splitFieldParentAmts);
|
||
|
//subAmounts.put("entry_splitscale", ReDigitalUtil.ONE_HUNDRED);
|
||
|
subAmounts.put("entry_splitscale", BigDecimal.ZERO);
|
||
|
Map<Long, Map<String, BigDecimal>> valuesMap = new HashMap<>();
|
||
|
for (int j = 0; j < conPlanEntrys.length; j++) {
|
||
|
DynamicObject conPlanEntry = conPlanEntrys[j];
|
||
|
Long conPlanEntryId = Long.valueOf(conPlanEntry.getLong("id"));
|
||
|
//BigDecimal conPlanAmount = conPlanEntry.getBigDecimal("amount");
|
||
|
//BigDecimal scale = ReDigitalUtil.divide(conPlanAmount, sumConPlanAmount, 10);
|
||
|
BigDecimal scale = BigDecimal.ZERO;
|
||
|
Map<String, BigDecimal> map = new HashMap<>();
|
||
|
this.reCalcValueMapAmtByScale(map, scale, splitFieldParentAmts, subAmounts);
|
||
|
valuesMap.put(conPlanEntryId, map);
|
||
|
if (0L == maxKey.longValue()) {
|
||
|
maxKey = conPlanEntryId;
|
||
|
maxScale = scale;
|
||
|
} else if (ReDigitalUtil.compareTo(scale, maxScale) > 0) {
|
||
|
maxKey = conPlanEntryId;
|
||
|
maxScale = scale;
|
||
|
}
|
||
|
}
|
||
|
Map<String, BigDecimal> valueMap = valuesMap.get(maxKey);
|
||
|
super.getReBillSplitHelper().handleValueMapSub(valueMap, subAmounts);
|
||
|
return valuesMap;
|
||
|
}
|
||
|
|
||
|
public Map<String, BigDecimal> getSplitFieldParentAmts(DynamicObject parentOrEntry, boolean isHead) {
|
||
|
Map<String, BigDecimal> splitFieldParentAmts = new HashMap<>();
|
||
|
if (isHead) {
|
||
|
splitFieldParentAmts.put("entry_amount", BigDecimal.ZERO);
|
||
|
splitFieldParentAmts.put("entry_notaxamt", BigDecimal.ZERO);
|
||
|
} else {
|
||
|
splitFieldParentAmts.put("entry_amount", parentOrEntry
|
||
|
.getBigDecimal("entry_amount"));
|
||
|
splitFieldParentAmts.put("entry_notaxamt", parentOrEntry
|
||
|
.getBigDecimal("entry_notaxamt"));
|
||
|
}
|
||
|
return splitFieldParentAmts;
|
||
|
}
|
||
|
|
||
|
public void reCalcValueMapAmtByScale(Map<String, BigDecimal> valueMap, BigDecimal scale, Map<String, BigDecimal> splitFieldParentAmts, Map<String, BigDecimal> subAmounts) {
|
||
|
valueMap.put("entry_splitscale", BigDecimal.ZERO);
|
||
|
for (String fieldKey : splitFieldParentAmts.keySet())
|
||
|
valueMap.put(fieldKey, ReDigitalUtil.multiply(scale, splitFieldParentAmts.get(fieldKey), 2));
|
||
|
for (String fieldKey : subAmounts.keySet())
|
||
|
subAmounts.put(fieldKey, ReDigitalUtil.subtract(subAmounts.get(fieldKey), valueMap.get(fieldKey)));
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
protected void closedCallBackConPlanBor(ClosedCallBackEvent evt) {
|
||
|
super.closedCallBackConPlanBor(evt);
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void closedCallBackSelectProduct(ClosedCallBackEvent evt) {
|
||
|
super.closedCallBackSelectProduct(evt);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void closedCallBackSelectBuild(ClosedCallBackEvent evt) {
|
||
|
super.closedCallBackSelectBuild(evt);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||
|
super.beforeDoOperation(args);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void syncConPlanBorBill(DynamicObject model, String operateKey, OperateOption option) {
|
||
|
super.syncConPlanBorBill(model, operateKey, option);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void setSplitIndexRefersh(BeforeDoOperationEventArgs args, String operateKey) {
|
||
|
super.setSplitIndexRefersh(args, operateKey);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void checkSrcBillExit(BeforeDoOperationEventArgs args, String operateKey) {
|
||
|
super.checkSrcBillExit(args, operateKey);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void setConToSrcBillByCheckVild(String operateKey) {
|
||
|
super.setConToSrcBillByCheckVild(operateKey);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void setOpenSourceToOption(OperateOption option, String operateKey) {
|
||
|
super.setOpenSourceToOption(option, operateKey);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void beforeClosed(BeforeClosedEvent e) {
|
||
|
super.beforeClosed(e);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void ctrlCheckDataChanged(BeforeClosedEvent e) {
|
||
|
super.ctrlCheckDataChanged(e);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
|
||
|
super.confirmCallBack(messageBoxClosedEvent);
|
||
|
}
|
||
|
|
||
|
}
|