diff --git a/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java b/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java new file mode 100644 index 0000000..0f7f193 --- /dev/null +++ b/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java @@ -0,0 +1,187 @@ +package shkd.repc.rebm.formplugin; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.metadata.IDataEntityProperty; +import kd.bos.dataentity.metadata.dynamicobject.DynamicPropertyCollection; +import kd.bos.entity.datamodel.IDataModel; +import kd.bos.entity.datamodel.ListSelectedRow; +import kd.bos.entity.datamodel.ListSelectedRowCollection; +import kd.bos.entity.list.option.ListUserOption; +import kd.bos.form.CloseCallBack; +import kd.bos.form.ShowFormHelper; +import kd.bos.form.ShowType; +import kd.bos.form.events.BeforeDoOperationEventArgs; +import kd.bos.form.events.ClosedCallBackEvent; +import kd.bos.form.operate.FormOperate; +import kd.bos.list.ListShowParameter; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.sdk.plugin.Plugin; + +/** + * 单据界面插件 + */ +public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements Plugin { + + String[] fields = new String[]{ + "qeug_auditoption", + "qeug_option", + "qeug_linetype", + "qeug_materialmasterid", + "qeug_materialname", + "qeug_materialversion", + "qeug_auxpty", + "qeug_unit", + "qeug_qty", + "qeug_classtype", + "qeug_baseunit", + "qeug_baseqty", + "qeug_auxunit", + "qeug_auxqty", + "qeug_reqdate", + "qeug_reqkind", + "qeug_entrybizorg", + "qeug_reqdes", + "qeug_project", + "qeug_supplier", + "qeug_originorg", + "qeug_material", + "qeug_entryorg", + "qeug_rowclosestatus", + "qeug_rowterminatestatus", + "qeug_entrycomment", + "qeug_entrycreator", + "qeug_entrycreatetime", + "qeug_entrymodifier", + "qeug_entrymodifytime", + "qeug_reqsource", + "qeug_srcbillentity", + "qeug_srcbillid", + "qeug_srcbillnumber", + "qeug_srcbillentryid", + "qeug_srcbillentryseq", + "qeug_propurqty", + "qeug_propurbaseqty", + "qeug_unionsumqty", + "qeug_unionsumbaseqty", + "qeug_sumqty", + "qeug_sumbaseqty", + "qeug_applyqty", + "qeug_applybaseqty", + "qeug_promatqty", + "qeug_promatbaseqty", + "qeug_matapplyqty", + "qeug_matapplybaseqty", + "qeug_matoutqty", + "qeug_matoutbaseqty", + "qeug_protranqty", + "qeug_protranbaseqty", + "qeug_balancestatus", + "qeug_project_info", + "qeug_quantities", + "qeug_added_tax", + "qeug_exctax_price", + "qeug_added_taxamount", + "qeug_price_includetax", + "qeug_totalprice_tax", + "qeug_labor_cost", + "qeug_auxmaterial_cost", + "qeug_mainma_price", + "qeug_mainma_brand", + "qeug_mainma_consum", + "qeug_mainma_unit", + "qeug_mainma_cost", + "qeug_equipment_costs", + "qeug_omnibus_fee", + "qeug_linetype_id", + "qeug_materialmasterid_id", + "qeug_materialversion_id", + "qeug_auxpty_id", + "qeug_unit_id", + "qeug_baseunit_id", + "qeug_auxunit_id", + "qeug_entrybizorg_id", + "qeug_project_id", + "qeug_supplier_id", + "qeug_originorg_id", + "qeug_material_id", + "qeug_entryorg_id", + "qeug_entrycreator_id", + "qeug_entrymodifier_id"}; + + @Override + public void beforeDoOperation(BeforeDoOperationEventArgs args) { + super.beforeDoOperation(args); + FormOperate operate = (FormOperate) args.getSource(); + String operateKey = operate.getOperateKey(); + if ("importpurchase".equals(operateKey)) { + showPurchaseApplyBill("purchase"); + } else if ("importpurchase2".equals(operateKey)) { + showPurchaseApplyBill("purchase2"); + } + } + + private void showPurchaseApplyBill(String actionId) { + ListShowParameter listShowParameter = ShowFormHelper.createShowListForm("qeug_purchaseapplybill", true); + listShowParameter.setFormId("bos_listf7"); + listShowParameter.getOpenStyle().setShowType(ShowType.Modal); + listShowParameter.setCloseCallBack(new CloseCallBack(this, actionId)); + this.getView().showForm(listShowParameter); + } + + @Override + public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) { + super.closedCallBack(closedCallBackEvent); + String actionId = closedCallBackEvent.getActionId(); + if ("purchase".equals(actionId)) { + IDataModel model = this.getModel(); + ListSelectedRowCollection selectedRows = (ListSelectedRowCollection) closedCallBackEvent.getReturnData(); + if (selectedRows != null && !selectedRows.isEmpty()) { + for (ListSelectedRow selectedRow : selectedRows) { + Object keyValue = selectedRow.getPrimaryKeyValue(); + int rowKey = selectedRow.getRowKey(); + DynamicObject purchase = BusinessDataServiceHelper.loadSingle(keyValue, "qeug_purchaseapplybill"); + DynamicObjectCollection entryEntities = purchase.getDynamicObjectCollection("qeug_entryentity");// 明细 + DynamicObject entry = entryEntities.get(rowKey); + int index = model.createNewEntryRow("entryentity"); + + for (String field : fields) { + model.setValue(field, entry.get(field), index); + } + + model.setValue("planname", entry.get("qeug_materialname"), index); + DynamicObject project = entry.getDynamicObject("qeug_project"); + if (project != null) { + QFilter projectQF = new QFilter("number", QCP.equals, project.getString("number")); + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("rebm_purproject", projectQF.toArray()); + model.setValue("purentryproject", dynamicObject, index); + } + } + } + } else if ("purchase2".equals(actionId)) { + IDataModel model = this.getModel(); + ListSelectedRowCollection selectedRows = (ListSelectedRowCollection) closedCallBackEvent.getReturnData(); + if (selectedRows != null && !selectedRows.isEmpty()) { + for (ListSelectedRow selectedRow : selectedRows) { + Object keyValue = selectedRow.getPrimaryKeyValue(); + int rowKey = selectedRow.getRowKey(); + DynamicObject purchase = BusinessDataServiceHelper.loadSingle(keyValue, "qeug_purchaseapplybill"); + DynamicObjectCollection entryEntities = purchase.getDynamicObjectCollection("qeug_entryentity");// 明细 + DynamicObject entry = entryEntities.get(rowKey); + + int index = model.createNewEntryRow("projectentry"); + model.setValue("purentrycontent", entry.get("qeug_materialname"), index); + DynamicObject project = entry.getDynamicObject("qeug_project"); + if (project != null) { + QFilter projectQF = new QFilter("number", QCP.equals, project.getString("number")); + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("rebm_purproject", projectQF.toArray()); + model.setValue("purentryproject", dynamicObject, index); + } + } + } + } + } +} \ No newline at end of file