二开系统插件标记
This commit is contained in:
parent
bc497f295c
commit
077a42523f
|
@ -0,0 +1,291 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.bill.OperationStatus;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.resource.ResManager;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.CloseCallBack;
|
||||
import kd.bos.form.FormShowParameter;
|
||||
import kd.bos.form.ShowType;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.bos.form.events.ClosedCallBackEvent;
|
||||
import kd.bos.form.field.BasedataEdit;
|
||||
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
||||
import kd.bos.form.field.events.BeforeF7SelectListener;
|
||||
import kd.bos.form.operate.FormOperate;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.ec.basedata.common.utils.OpenPageUtils;
|
||||
|
||||
public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements BeforeF7SelectListener {
|
||||
private static final String APPLYBILL = "applybill";
|
||||
private static final String MATERIAL_APPLY_ENTRY_FORM = "ecma_materialapplyentry";
|
||||
private static final String APPLY_ENTRY_CALLBACK = "applyEntryCallback";
|
||||
|
||||
public MaterialOutApplyPluginExt() {
|
||||
}
|
||||
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
BasedataEdit basedataEdit = (BasedataEdit)this.getControl("applybill");
|
||||
basedataEdit.addBeforeF7SelectListener(this);
|
||||
basedataEdit.addBeforeF7ViewDetailListener((beforeF7ViewDetailEvent) -> {
|
||||
beforeF7ViewDetailEvent.setCancel(true);
|
||||
this.getView().showForm(OpenPageUtils.buildBillShowParam(beforeF7ViewDetailEvent.getPkId(), "ecma_materialapplybill"));
|
||||
});
|
||||
}
|
||||
|
||||
public void beforeF7Select(BeforeF7SelectEvent arg0) {
|
||||
String name = arg0.getProperty().getName();
|
||||
if (StringUtils.equals(name, "applybill")) {
|
||||
this.beforeApplyBillSelect(arg0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
super.beforeDoOperation(args);
|
||||
FormOperate operate = (FormOperate)args.getSource();
|
||||
String operateKey = operate.getOperateKey();
|
||||
DynamicObject applyBill = (DynamicObject)this.getModel().getValue("applybill");
|
||||
if (StringUtils.equals("addnewentry", operateKey)) {
|
||||
if (applyBill != null) {
|
||||
this.openApplyEntryForm();
|
||||
} else {
|
||||
this.getModel().createNewEntryRow("entryentity");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void beforeApplyBillSelect(BeforeF7SelectEvent arg0) {
|
||||
DynamicObject project = (DynamicObject)this.getModel().getValue("project");
|
||||
DynamicObject warehouse = (DynamicObject)this.getModel().getValue("warehouse");
|
||||
if (warehouse == null) {
|
||||
this.getView().showTipNotification(ResManager.loadKDString("请先选中仓库。", "MaterialOutApplyPlugin_1", "ec-ecma-formplugin", new Object[0]), 3000);
|
||||
arg0.setCancel(true);
|
||||
} else {
|
||||
if (project == null) {
|
||||
}
|
||||
|
||||
QFilter warehouseFilter = new QFilter("warehouse", "=", warehouse.getPkValue());
|
||||
QFilter materialOutFilter = new QFilter("materialout", "=", "0");
|
||||
materialOutFilter = materialOutFilter.and(warehouseFilter);
|
||||
if (project != null) {
|
||||
materialOutFilter.and(new QFilter("project", "=", project.getPkValue()));
|
||||
}
|
||||
|
||||
arg0.getCustomQFilters().add(materialOutFilter);
|
||||
}
|
||||
}
|
||||
|
||||
public void propertyChanged(PropertyChangedArgs e) {
|
||||
super.propertyChanged(e);
|
||||
String name = e.getProperty().getName();
|
||||
ChangeData changeData = e.getChangeSet()[0];
|
||||
if (StringUtils.equals(name, "applybill")) {
|
||||
this.applyBillChanged(changeData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void applyBillChanged(ChangeData changeData) {
|
||||
DynamicObject newValue = (DynamicObject)changeData.getNewValue();
|
||||
if (newValue != null) {
|
||||
newValue = BusinessDataServiceHelper.loadSingle(newValue.getPkValue(), "ecma_materialapplybill");
|
||||
this.carryHeadData(newValue);
|
||||
this.carryEntryData(newValue);
|
||||
this.getView().updateView();
|
||||
} else {
|
||||
this.getModel().deleteEntryData("entryentity");
|
||||
this.getModel().setValue("outamt", 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void carryEntryData(DynamicObject applyBill) {
|
||||
DynamicObjectCollection entries = this.getModel().getEntryEntity("entryentity");
|
||||
entries.clear();
|
||||
DynamicObjectCollection applyEntries = applyBill.getDynamicObjectCollection("entryentity");
|
||||
if (applyEntries != null && !applyEntries.isEmpty()) {
|
||||
Iterator var4 = applyEntries.iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
DynamicObject applyEntry = (DynamicObject)var4.next();
|
||||
BigDecimal restQty = applyEntry.getBigDecimal("restqty");
|
||||
if (restQty.compareTo(BigDecimal.ZERO) != 0) {
|
||||
DynamicObject newEntry = new DynamicObject(entries.getDynamicObjectType());
|
||||
newEntry.set("applyentryid", applyEntry.getLong("id"));
|
||||
newEntry.set("material", applyEntry.get("material"));
|
||||
newEntry.set("modelnum", applyEntry.get("modelnum"));
|
||||
newEntry.set("lotid", applyEntry.get("lotid"));
|
||||
newEntry.set("lot", applyEntry.get("lot"));
|
||||
newEntry.set("assmeasureunit", applyEntry.get("assmeasureunit"));
|
||||
newEntry.set("assqty", applyEntry.get("assqty"));
|
||||
newEntry.set("measureunit", applyEntry.get("measureunit"));
|
||||
newEntry.set("qty", applyEntry.get("restqty"));
|
||||
newEntry.set("applyqty", applyEntry.get("qty"));
|
||||
newEntry.set("price", applyEntry.get("price"));
|
||||
newEntry.set("amount", applyEntry.get("amount"));
|
||||
newEntry.set("ismainmaterial", applyEntry.get("ismainmaterial"));
|
||||
newEntry.set("unitproject", applyEntry.get("unitprojectentry"));
|
||||
newEntry.set("procbs", applyEntry.get("procbs"));
|
||||
newEntry.set("ca", applyEntry.get("ca"));
|
||||
newEntry.set("prowbs", applyEntry.get("prowbs"));
|
||||
newEntry.set("proboq", applyEntry.get("proboq"));
|
||||
newEntry.set("matinventory", applyEntry.get("matinventory"));
|
||||
entries.add(newEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.getModel().updateEntryCache(entries);
|
||||
}
|
||||
|
||||
protected void carryEntryDataFromReturnData(DynamicObject applyBill, List<Long> applyEntryIdList) {
|
||||
DynamicObjectCollection entries = this.getModel().getEntryEntity("entryentity");
|
||||
DynamicObjectCollection applyEntries = applyBill.getDynamicObjectCollection("entryentity");
|
||||
if (applyEntries != null && !applyEntries.isEmpty()) {
|
||||
Iterator var5 = applyEntries.iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
DynamicObject applyEntry = (DynamicObject)var5.next();
|
||||
if (applyEntryIdList.contains(applyEntry.getPkValue())) {
|
||||
DynamicObject newEntry = new DynamicObject(entries.getDynamicObjectType());
|
||||
newEntry.set("applyentryid", applyEntry.getLong("id"));
|
||||
newEntry.set("material", applyEntry.get("material"));
|
||||
newEntry.set("modelnum", applyEntry.get("modelnum"));
|
||||
newEntry.set("lotid", applyEntry.get("lotid"));
|
||||
newEntry.set("lot", applyEntry.get("lot"));
|
||||
newEntry.set("assmeasureunit", applyEntry.get("assmeasureunit"));
|
||||
newEntry.set("assqty", applyEntry.get("assqty"));
|
||||
newEntry.set("measureunit", applyEntry.get("measureunit"));
|
||||
newEntry.set("qty", applyEntry.get("restqty"));
|
||||
newEntry.set("applyqty", applyEntry.get("qty"));
|
||||
newEntry.set("price", applyEntry.get("price"));
|
||||
newEntry.set("amount", applyEntry.get("amount"));
|
||||
newEntry.set("ismainmaterial", applyEntry.get("ismainmaterial"));
|
||||
newEntry.set("unitproject", applyEntry.get("unitprojectentry"));
|
||||
newEntry.set("procbs", applyEntry.get("procbs"));
|
||||
newEntry.set("ca", applyEntry.get("ca"));
|
||||
newEntry.set("prowbs", applyEntry.get("prowbs"));
|
||||
newEntry.set("proboq", applyEntry.get("proboq"));
|
||||
newEntry.set("matinventory", applyEntry.get("matinventory"));
|
||||
entries.add(newEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.getModel().updateEntryCache(entries);
|
||||
this.getView().updateView("entryentity");
|
||||
}
|
||||
|
||||
protected void carryHeadData(DynamicObject applyBill) {
|
||||
this.getModel().beginInit();
|
||||
DynamicObject transType = applyBill.getDynamicObject("transtype");
|
||||
if (transType != null) {
|
||||
this.getModel().setValue("transtype", transType.getPkValue());
|
||||
}
|
||||
|
||||
DynamicObject supplier = applyBill.getDynamicObject("supplier");
|
||||
if (supplier != null) {
|
||||
this.getModel().setValue("supplier", supplier.getPkValue());
|
||||
}
|
||||
|
||||
DynamicObject labour = applyBill.getDynamicObject("labour");
|
||||
if (labour != null) {
|
||||
this.getModel().setValue("labour", labour.getPkValue());
|
||||
}
|
||||
|
||||
DynamicObject requestPerson = applyBill.getDynamicObject("requestperson");
|
||||
if (requestPerson != null) {
|
||||
this.getModel().setValue("requestperson", requestPerson.getPkValue());
|
||||
}
|
||||
|
||||
this.getModel().setValue("reqpersonname", applyBill.getString("reqpersonname"));
|
||||
DynamicObject warehouse = applyBill.getDynamicObject("warehouse");
|
||||
if (warehouse != null) {
|
||||
this.getModel().setValue("warehouse", warehouse.getPkValue());
|
||||
}
|
||||
|
||||
this.getModel().setValue("ismulticurrency", applyBill.getString("ismulticurrency"));
|
||||
DynamicObject currency = applyBill.getDynamicObject("currency");
|
||||
if (currency != null) {
|
||||
this.getModel().setValue("currency", currency.getPkValue());
|
||||
}
|
||||
|
||||
DynamicObject stdCurrency = applyBill.getDynamicObject("stdcurrency");
|
||||
if (stdCurrency != null) {
|
||||
this.getModel().setValue("stdcurrency", stdCurrency.getPkValue());
|
||||
}
|
||||
|
||||
DynamicObject exRateTable = applyBill.getDynamicObject("exratetable");
|
||||
if (exRateTable != null) {
|
||||
this.getModel().setValue("exratetable", exRateTable.getPkValue());
|
||||
}
|
||||
|
||||
DynamicObject cont = applyBill.getDynamicObject("contract");
|
||||
if (null != cont) {
|
||||
this.getModel().setValue("contract", cont);
|
||||
}
|
||||
|
||||
this.getModel().setValue("exchangedate", applyBill.getString("exchangedate"));
|
||||
this.getModel().setValue("exchangerate", applyBill.getString("exchangerate"));
|
||||
this.getModel().setValue("outamt", applyBill.getString("totalapplyamount"));
|
||||
this.getModel().setValue("stdoutamt", applyBill.getString("stdtotalapplyamount"));
|
||||
this.getModel().endInit();
|
||||
}
|
||||
|
||||
private void openApplyEntryForm() {
|
||||
DynamicObject applyBill = (DynamicObject)this.getModel().getValue("applybill");
|
||||
DynamicObjectCollection entries = this.getModel().getEntryEntity("entryentity");
|
||||
StringBuffer selectedEntryIdBuff = new StringBuffer();
|
||||
Iterator var4 = entries.iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
DynamicObject entry = (DynamicObject)var4.next();
|
||||
selectedEntryIdBuff.append(entry.get("applyentryid")).append(",");
|
||||
}
|
||||
|
||||
String selectedEntryId = selectedEntryIdBuff.toString();
|
||||
HashMap<String, Object> map = new HashMap();
|
||||
map.put("formId", "ecma_materialapplyentry");
|
||||
map.put("applyBillId", applyBill.getPkValue());
|
||||
map.put("selectedEntryId", selectedEntryId);
|
||||
FormShowParameter showParameter = FormShowParameter.createFormShowParameter(map);
|
||||
showParameter.getOpenStyle().setShowType(ShowType.Modal);
|
||||
showParameter.setStatus(OperationStatus.ADDNEW);
|
||||
showParameter.setCloseCallBack(new CloseCallBack(this, "applyEntryCallback"));
|
||||
this.getView().showForm(showParameter);
|
||||
}
|
||||
|
||||
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
||||
String actionID = closedCallBackEvent.getActionId();
|
||||
Object returnData = closedCallBackEvent.getReturnData();
|
||||
DynamicObject applyBill = (DynamicObject)this.getModel().getValue("applybill");
|
||||
if (StringUtils.equals(actionID, "applyEntryCallback") && returnData != null) {
|
||||
Map<String, Object> data = (Map)returnData;
|
||||
List<Long> applyEntryIdList = (List)data.get("applyEntryIdList");
|
||||
if (applyBill != null) {
|
||||
DynamicObject applyBillData = BusinessDataServiceHelper.loadSingle(applyBill.getPkValue(), "ecma_materialapplybill");
|
||||
this.carryEntryDataFromReturnData(applyBillData, applyEntryIdList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue