2024-11-21 01:21:00 +00:00
|
|
|
|
package shkd.repc.rebm.formplugin;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import kd.bos.bill.AbstractBillPlugIn;
|
|
|
|
|
import kd.bos.bill.BillShowParameter;
|
|
|
|
|
import kd.bos.bill.OperationStatus;
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
|
import kd.bos.dataentity.entity.LocaleString;
|
|
|
|
|
import kd.bos.dataentity.metadata.IDataEntityProperty;
|
|
|
|
|
import kd.bos.dataentity.resource.ResManager;
|
|
|
|
|
import kd.bos.dataentity.utils.StringUtils;
|
|
|
|
|
import kd.bos.entity.AppInfo;
|
|
|
|
|
import kd.bos.entity.AppMenuInfo;
|
|
|
|
|
import kd.bos.entity.AppMetadataCache;
|
|
|
|
|
import kd.bos.entity.datamodel.IDataModel;
|
|
|
|
|
import kd.bos.exception.KDException;
|
|
|
|
|
import kd.bos.form.*;
|
|
|
|
|
import kd.bos.form.container.Tab;
|
|
|
|
|
import kd.bos.form.control.Control;
|
|
|
|
|
import kd.bos.form.control.Toolbar;
|
|
|
|
|
import kd.bos.form.control.events.ItemClickEvent;
|
|
|
|
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
|
|
|
import kd.bos.form.field.AmountEdit;
|
|
|
|
|
import kd.bos.form.field.DecimalEdit;
|
|
|
|
|
import kd.bos.portal.util.OpenPageUtils;
|
2024-11-22 03:08:28 +00:00
|
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
2024-11-21 01:21:00 +00:00
|
|
|
|
import kd.sdk.plugin.Plugin;
|
|
|
|
|
import kd.svc.control.events.AppNavigationMenuEvent;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 单据界面插件
|
|
|
|
|
*/
|
|
|
|
|
public class DecisionJumpToConPlanPlugin extends AbstractBillPlugIn implements Plugin {
|
|
|
|
|
|
|
|
|
|
/*
|
2024-11-22 03:08:28 +00:00
|
|
|
|
* 定标
|
|
|
|
|
* 1.点击‘变更合约规划’按钮跳转到成本管理的 目标成本调整
|
|
|
|
|
* 2.将采购明细中的规划金额 < 供应商信息的最终价 所对应的采购项目带到目标成本调整中
|
|
|
|
|
* */
|
2024-11-21 01:21:00 +00:00
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void afterBindData(EventObject e) {
|
|
|
|
|
super.afterBindData(e);
|
|
|
|
|
IDataModel model = this.getModel();
|
|
|
|
|
String conPlanAdjust = (String) model.getValue("qeug_conplan_adjust");// 关联合约规划调整
|
|
|
|
|
if (!conPlanAdjust.isEmpty()) {
|
|
|
|
|
IFormView view = this.getView();
|
|
|
|
|
view.setVisible(true, "qeug_planamount");
|
|
|
|
|
view.setVisible(true, "qeug_botcontrolamount");
|
|
|
|
|
|
|
|
|
|
DecimalEdit planAmount = getControl("planamount");// 规划金额(含税)
|
|
|
|
|
AmountEdit controlAmount = getControl("botcontrolamount");// 采购控制金额(含税)
|
|
|
|
|
|
|
|
|
|
planAmount.setCaption(new LocaleString("规划金额(变更后)"));
|
|
|
|
|
controlAmount.setCaption(new LocaleString("采购控制金额(变更后)"));
|
|
|
|
|
|
|
|
|
|
Map<String, IDataEntityProperty> allFields = this.getModel().getDataEntityType().getAllFields();
|
|
|
|
|
IDataEntityProperty field1 = allFields.get("planamount");
|
|
|
|
|
IDataEntityProperty field2 = allFields.get("botcontrolamount");
|
|
|
|
|
field1.getDisplayName().setLocaleValue("规划金额(变更后)");
|
|
|
|
|
field2.getDisplayName().setLocaleValue("采购控制金额(变更后)");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void afterDoOperation(AfterDoOperationEventArgs eventArgs) {
|
|
|
|
|
String operateKey = eventArgs.getOperateKey();
|
|
|
|
|
if ("changeplan".equals(operateKey)) {
|
|
|
|
|
IFormView mainView = this.getView().getMainView();
|
|
|
|
|
IPageCache pageCache = mainView.getPageCache();
|
|
|
|
|
String tabPageKeys = pageCache.get("_Tab_Items_TabPageKeys");
|
|
|
|
|
boolean result = false;
|
|
|
|
|
String key = "";
|
|
|
|
|
if (!tabPageKeys.isEmpty()) {
|
|
|
|
|
String[] splits = tabPageKeys.replaceAll("\\[", "").replaceAll("]", "").split(",");
|
|
|
|
|
for (String split : splits) {
|
|
|
|
|
if (split.contains("recos")) {
|
|
|
|
|
key = split.replaceAll("\"", "");
|
|
|
|
|
result = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
|
FormShowParameter formShowParameter = new FormShowParameter();
|
|
|
|
|
formShowParameter.setAppId("recos");
|
|
|
|
|
formShowParameter.getOpenStyle().setShowType(ShowType.NewTabPage);
|
|
|
|
|
formShowParameter.getOpenStyle().setTargetKey("tabap");
|
|
|
|
|
formShowParameter.setCustomParam("formId", "recos_conplan");
|
|
|
|
|
formShowParameter.setCustomParam("appImageUrl", "icons/pc/application/fdc_cbgl_48_48.png");
|
|
|
|
|
formShowParameter.setCustomParam("appid", "recos");
|
|
|
|
|
formShowParameter.setFormId("recos_apphome");
|
|
|
|
|
formShowParameter.setCaption("成本管理");
|
|
|
|
|
formShowParameter.setPageId("recos" + mainView.getPageId());
|
|
|
|
|
mainView.showForm(formShowParameter);
|
|
|
|
|
getView().sendFormAction(mainView);
|
|
|
|
|
} else {
|
|
|
|
|
Tab tab = mainView.getControl("tabap");
|
|
|
|
|
tab.activeTab(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IDataModel model = this.getModel();
|
|
|
|
|
String purProjectNum = "";
|
|
|
|
|
DynamicObjectCollection bidSections = model.getEntryEntity("bidsection");// 标段
|
|
|
|
|
DynamicObjectCollection bottomSections = model.getEntryEntity("bottomsection");// 标底标段
|
2024-11-22 03:08:28 +00:00
|
|
|
|
|
|
|
|
|
int seqNum = 0;
|
|
|
|
|
if (bidSections != null && bottomSections != null) {
|
2024-11-21 01:21:00 +00:00
|
|
|
|
for (DynamicObject bidSection : bidSections) {
|
|
|
|
|
BigDecimal finalPriceSum = new BigDecimal(0);
|
|
|
|
|
int seq = bidSection.getInt("seq");
|
2024-11-22 03:08:28 +00:00
|
|
|
|
DynamicObjectCollection supplierEntries = bidSection.getDynamicObjectCollection("supplierentry");// 定标供应商
|
|
|
|
|
if (supplierEntries == null) continue;
|
2024-11-21 01:21:00 +00:00
|
|
|
|
for (DynamicObject supplierEntry : supplierEntries) {
|
2024-11-22 03:08:28 +00:00
|
|
|
|
if (supplierEntry.getBoolean("isrecommended")) {// 是否中标单位
|
|
|
|
|
BigDecimal finalPrice = supplierEntry.getBigDecimal("finalprice");
|
|
|
|
|
finalPriceSum = finalPriceSum.add(finalPrice);
|
2024-11-21 01:21:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-22 03:08:28 +00:00
|
|
|
|
if (finalPriceSum.equals(new BigDecimal(0))) continue;
|
|
|
|
|
|
2024-11-21 01:21:00 +00:00
|
|
|
|
DynamicObject project = null;
|
|
|
|
|
BigDecimal controlAmountSum = new BigDecimal(0);
|
|
|
|
|
for (DynamicObject bottomSection : bottomSections) {
|
|
|
|
|
int bottomSeq = bottomSection.getInt("seq");
|
|
|
|
|
if (seq == bottomSeq) {
|
2024-11-22 03:08:28 +00:00
|
|
|
|
DynamicObjectCollection bottomEntries = bottomSection.getDynamicObjectCollection("bottomentry");// 采购明细
|
|
|
|
|
if (bottomEntries != null) {
|
|
|
|
|
if (!bottomEntries.isEmpty())
|
|
|
|
|
project = bottomEntries.get(0).getDynamicObject("botpurentryproject");
|
2024-11-21 01:21:00 +00:00
|
|
|
|
|
2024-11-22 03:08:28 +00:00
|
|
|
|
for (DynamicObject bottomEntry : bottomEntries) {
|
2024-11-21 01:21:00 +00:00
|
|
|
|
BigDecimal controlAmount = bottomEntry.getBigDecimal("botcontrolamount");// 采购控制金额(含税)
|
|
|
|
|
controlAmountSum = controlAmountSum.add(controlAmount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (finalPriceSum.compareTo(controlAmountSum) >= 1) {
|
2024-11-22 03:08:28 +00:00
|
|
|
|
if (project != null) {
|
2024-11-21 01:21:00 +00:00
|
|
|
|
purProjectNum = project.getString("number");
|
2024-11-22 03:08:28 +00:00
|
|
|
|
seqNum = seq;
|
2024-11-21 01:21:00 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String appPageID = "recos" + mainView.getPageId();
|
|
|
|
|
IFormView appPageView = mainView.getViewNoPlugin(appPageID);
|
|
|
|
|
|
|
|
|
|
BillShowParameter billShowParameter = new BillShowParameter();
|
|
|
|
|
billShowParameter.setFormId("recos_aimadjust");
|
|
|
|
|
billShowParameter.setBillStatusValue(0);
|
|
|
|
|
billShowParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
|
|
|
|
|
billShowParameter.getOpenStyle().setTargetKey("_submaintab_");
|
|
|
|
|
|
|
|
|
|
billShowParameter.setCustomParam("decision_id", model.getDataEntity().getLong("id"));
|
|
|
|
|
billShowParameter.setCustomParam("purproject_number", purProjectNum);
|
2024-11-22 03:08:28 +00:00
|
|
|
|
billShowParameter.setCustomParam("seqNum", seqNum);
|
2024-11-21 01:21:00 +00:00
|
|
|
|
|
|
|
|
|
appPageView.showForm(billShowParameter);
|
|
|
|
|
getView().sendFormAction(appPageView);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|