diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java new file mode 100644 index 0000000..090e86d --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/ContractSettleBillPlugin.java @@ -0,0 +1,87 @@ +package zcgj.zcdev.zcdev.pr.plugin.form; + +import com.alibaba.druid.util.StringUtils; +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.entity.operate.result.OperationResult; +import kd.bos.form.control.Control; +import kd.bos.form.control.events.BeforeClickEvent; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.util.EventObject; + +/** + * 单据界面插件 + */ +public class ContractSettleBillPlugin extends AbstractBillPlugIn implements Plugin { + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + // 注册按钮点击事件 + this.addClickListeners("bar_save"); + } + + @Override + public void beforeClick(BeforeClickEvent evt) { + super.beforeClick(evt); + Control source = (Control) evt.getSource(); + if (StringUtils.equals("bar_save", source.getKey())) { + // 在此添加业务逻辑 + Object changetype = this.getModel().getValue("changetype"); + if (changetype != null) { + if (changetype.toString().equals("03")) { + Object contract = this.getModel().getValue("contract"); + DynamicObject contractInfo = (DynamicObject) contract; + String billName = contractInfo.getDataEntityType().getName(); + DynamicObject zcgjParta = (DynamicObject)this.getModel().getValue("zcgj_parta"); + Object zcgjOtherpart = this.getModel().getValue("zcgj_otherpart"); + if (billName.equals("ec_out_contract_f7")) { + QFilter f1 = new QFilter("number", "=", contractInfo.getString("number")); + DynamicObject outContractF7 = BusinessDataServiceHelper.loadSingle("ec_out_contract_f7", new QFilter[]{f1}); + outContractF7.set("parta",zcgjParta); + OperationResult saveOperationResult = SaveServiceHelper.saveOperate("ec_out_contract_f7", new DynamicObject[]{outContractF7}, null);//支出合同F7实体 + + QFilter f2 = new QFilter("billno", "=", contractInfo.getString("number")); + DynamicObject outContract = BusinessDataServiceHelper.loadSingle("ec_out_contract", new QFilter[]{f2}); + outContract.set("parta",zcgjParta); + if(zcgjOtherpart!=null){ + DynamicObjectCollection otherpart = (DynamicObjectCollection) this.getModel().getValue("zcgj_otherpart"); + outContract.set("otherpart",otherpart); + outContract.set("ismulticontract",true); + } + OperationResult saveOperationResult1 = SaveServiceHelper.saveOperate("ec_out_contract", new DynamicObject[]{outContractF7}, null);//支出合同实体 + System.out.println(saveOperationResult1); + }else{ + + } + } + } + evt.setCancel(true); // 取消后续处理,将不会再触发click事件 + + } + } + + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + if(name.equals("changetype")){ + Object changetype = this.getModel().getValue("changetype"); + if(changetype!=null){ + if(changetype.toString().equals("03")){ + this.getView().setVisible(true,"zcgj_parta"); + this.getView().setVisible(true,"zcgj_otherpart"); + }else { + this.getView().setVisible(false,"zcgj_parta"); + this.getView().setVisible(false,"zcgj_otherpart"); + } + } + } + } +} \ No newline at end of file diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractFromPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractFromPlugin.java index 39438ef..18af7b1 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractFromPlugin.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractFromPlugin.java @@ -5,6 +5,8 @@ import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType; import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.sdk.plugin.Plugin; /** @@ -14,7 +16,7 @@ public class OutContractFromPlugin extends AbstractBillPlugIn implements Plugin private String entryName = "treelistentry";//分录标识 - private String ecContract = "";// + private String ecContract = "incontract";// @Override public void propertyChanged(PropertyChangedArgs e) { super.propertyChanged(e); @@ -22,28 +24,44 @@ public class OutContractFromPlugin extends AbstractBillPlugIn implements Plugin if(changeName.equals(ecContract)){//收入合同字段值改变 Object outC = this.getModel().getValue(ecContract); if(outC!=null){ - DynamicObject outContract = (DynamicObject) outC; - DynamicObjectCollection ecCEntrys = outContract.getDynamicObjectCollection(entryName);//获取收入合同合同清单 - for (int i = 0; i < ecCEntrys.size(); i++) { - DynamicObject ecCEntry = ecCEntrys.get(i); - int row = this.getModel().insertEntryRow(entryName, i); - this.getModel().setValue(entryName, ecCEntry.get(""), row); - } - DynamicObjectCollection outCEntry = this.getModel().getEntryEntity(entryName); - if (outCEntry.size() < 0) { - for (int i = 0; i < ecCEntrys.size(); i++) { - outCEntry.add(i, ecCEntrys.get(i)); + DynamicObject contractF7 = (DynamicObject) outC; + String paydirection = contractF7.getString("paydirection");//支出/收入 + String contractNumber = contractF7.getString("number");//获取收入合同合同清单 + if(paydirection.equals("in")){ + QFilter f1 = new QFilter("billno", "=", contractNumber); + DynamicObject inContract = BusinessDataServiceHelper.loadSingle("ec_in_contract", new QFilter[]{f1}); + DynamicObjectCollection listmodelentry = inContract.getDynamicObjectCollection("listmodelentry"); + for (int x = 0; x < listmodelentry.size(); x++ ) { + DynamicObject dynamicObject = listmodelentry.get(x); + this.getModel().getEntryEntity("listmodelentry").add(x,dynamicObject); + DynamicObjectCollection sublistentry = dynamicObject.getDynamicObjectCollection("sublistentry"); + for (int i = 0; i < sublistentry.size(); i++) { + DynamicObject object = sublistentry.get(i); + int row = this.getModel().insertEntryRow("sublistentry", i+1); + this.getModel().setValue("sysnumber",object.getString("sysnumber"),row+1); + this.getModel().setValue("listnumber",object.getString("listnumber"),row); + this.getModel().setValue("listname",object.getString("listname"),row); + this.getModel().setValue("resourceitem",object.getString("resourceitem"),row); + this.getModel().setValue("measureunit",object.getString("measureunit"),row); + this.getModel().setValue("qty",object.getString("qty"),row); + this.getModel().setValue("price",object.getString("price"),row); + this.getModel().setValue("amount",object.getString("amount"),row); + this.getModel().setValue("rateobj",object.getString("rateobj"),row); + this.getModel().setValue("tax",object.getString("tax"),row); + this.getModel().setValue("taxprice",object.getString("taxprice"),row); + this.getModel().setValue("oftax",object.getString("oftax"),row); + this.getModel().setValue("listunitproject",object.getString("listunitproject"),row); + this.getModel().setValue("desc",object.getString("desc"),row); + } } - this.getView().updateView(entryName); - } - outCEntry = this.getModel().getEntryEntity(entryName); - if (outCEntry.size() < 0) { - for (int i = 0; i < ecCEntrys.size(); i++) { - outCEntry.add(ecCEntrys.get(i)); - } - this.getView().updateView(entryName); + this.getView().updateView("listmodelentry"); + this.getView().updateView("treelistentry"); + } else if (paydirection.equals("out")) { + } + } } } + } \ No newline at end of file diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractWorkFlowPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractWorkFlowPlugin.java new file mode 100644 index 0000000..7d1b6be --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/workflow/OutContractWorkFlowPlugin.java @@ -0,0 +1,42 @@ +package zcgj.zcdev.zcdev.pr.plugin.workflow; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.bos.workflow.api.AgentExecution; +import kd.bos.workflow.engine.extitf.IWorkflowPlugin; + +public class OutContractWorkFlowPlugin implements IWorkflowPlugin { + + @Override + public void notify(AgentExecution execution) { + String businessKey = execution.getBusinessKey(); + String entityNumber = execution.getEntityNumber(); + DynamicObject outContractSettle = BusinessDataServiceHelper.loadSingle(businessKey, entityNumber); + String changetype = outContractSettle.getString("changetype"); + if(changetype.equals("03")) { + DynamicObject contractInfo = outContractSettle.getDynamicObject("contract"); +// DynamicObject contractInfo = (DynamicObject) contract; +// String billName = contractInfo.getDataEntityType().getName(); + DynamicObject zcgjParta = outContractSettle.getDynamicObject("zcgj_parta"); + DynamicObjectCollection zcgjOtherpart = outContractSettle.getDynamicObjectCollection("zcgj_otherpart"); + QFilter f1 = new QFilter("number", "=", contractInfo.getString("number")); + DynamicObject outContractF7 = BusinessDataServiceHelper.loadSingle("ec_out_contract_f7", new QFilter[]{f1}); + outContractF7.set("parta", zcgjParta); + SaveServiceHelper.saveOperate("ec_out_contract_f7", new DynamicObject[]{outContractF7}, null);//支出合同F7实体 + + QFilter f2 = new QFilter("billno", "=", contractInfo.getString("number")); + DynamicObject outContract = BusinessDataServiceHelper.loadSingle("ec_out_contract", new QFilter[]{f2}); + outContract.set("parta", zcgjParta); + if (zcgjOtherpart != null) { +// DynamicObjectCollection otherpart = (DynamicObjectCollection) this.getModel().getValue("zcgj_otherpart"); + outContract.set("otherpart", zcgjOtherpart); + outContract.set("ismulticontract", true); + } + SaveServiceHelper.saveOperate("ec_out_contract", new DynamicObject[]{outContract}, null);//支出合同实体 + } + IWorkflowPlugin.super.notify(execution); + } +}