优化代码 解决合同计量行带出有误的问题

This commit is contained in:
xiaoshi 2024-12-13 15:55:26 +08:00
parent fed724c980
commit e19f96774d
4 changed files with 102 additions and 34 deletions

View File

@ -6,6 +6,7 @@ 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.Button;
import kd.bos.form.control.Control;
import kd.bos.form.control.events.BeforeClickEvent;
import kd.bos.form.control.events.BeforeItemClickEvent;
@ -41,8 +42,10 @@ public class ContractSettleBillPlugin extends AbstractBillPlugIn implements Plug
public void registerListener(EventObject e) {
super.registerListener(e);
// 注册按钮点击事件
this.addClickListeners("bar_audit");
this.addItemClickListeners("bar_audit");
// this.addClickListeners("bar_audit");
// this.addItemClickListeners("bar_audit");
// Button button = this.getView().getControl("bar_audit");
// button.addClickListener(this);
}
@Override
@ -54,13 +57,15 @@ public class ContractSettleBillPlugin extends AbstractBillPlugIn implements Plug
@Override
public void click(EventObject evt) {
super.click(evt);
System.out.println();
}
@Override
public void beforeItemClick(BeforeItemClickEvent evt) {
super.beforeItemClick(evt);
Control source = (Control) evt.getSource();
if (StringUtils.equals("bar_audit", source.getKey())) {
String key = source.getKey();
if (StringUtils.equals("bar_audit", key)) {
// 在此添加业务逻辑
Object changetype = this.getModel().getValue("changetype");
if (changetype != null) {

View File

@ -1,20 +1,45 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.entity.tree.TreeNode;
import kd.bos.form.FormShowParameter;
import kd.bos.form.IPageCache;
import kd.bos.form.control.TreeView;
import kd.ec.basedata.common.enums.ResourceTypeEnum;
import kd.ec.basedata.formplugin.ResourceFilterPlugin;
import kd.ec.basedata.formplugin.ResourceItemListPlugin;
import java.util.EventObject;
import java.util.Map;
public class ResourceFilterExtPlugin extends ResourceItemListPlugin {
@Override
public void beforeBindData(EventObject e) {
// super.afterBindData(e);
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
Map<String, Object> customParams = formShowParameter.getCustomParams();
Object contractType = customParams.get("contractType");
String firstOpen = this.getPageCache().get("firstOpen");
if (firstOpen != null) {
// this.getPageCache().put("firstOpen", "false");
this.getPageCache().remove("firstOpen");
if (contractType != null) {
if (contractType.toString().equals("wzcg")) {//物资采购
this.setResourceTypeStyle("material");
this.afterSelectedTag("material");
} else if (contractType.toString().equals("sbcg")) {//设备采购
this.setResourceTypeStyle("equipment");
this.afterSelectedTag("equipment");
}else if (contractType.toString().equals("qtcc") || contractType.toString().equals("lwlcc")) {//产出物
this.setResourceTypeStyle("turnover");
this.afterSelectedTag("turnover");
}
}
}else{
this.getPageCache().put("firstOpen","false");
}
System.out.println();
}
@Override
public void afterBindData(EventObject e) {
super.afterBindData(e);
FormShowParameter formShowParameter = this.getView().getFormShowParameter();
Map<String, Object> customParams = formShowParameter.getCustomParams();
Object contractType = customParams.get("contractType");
@ -25,24 +50,14 @@ public class ResourceFilterExtPlugin extends ResourceItemListPlugin {
if (contractType.toString().equals("wzcg")) {//物资采购
this.getView().setVisible(true, new String[]{"flexpanelmaterial"});
this.getView().setVisible(false, new String[]{"flexpanelsub", "flexpanellabour", "flexpanelcomposite", "flexpanelequipment", "flexpanelturnover","flexpanelother"});
this.setResourceTypeStyle("material");
this.afterSelectedTag("material");
} else if (contractType.toString().equals("cs2")) {//设备采购
} else if (contractType.toString().equals("sbcg")) {//设备采购
this.getView().setVisible(true, new String[]{"flexpanelequipment"});
this.getView().setVisible(false, new String[]{"flexpanelsub", "flexpanellabour", "flexpanelcomposite", "flexpanelmaterial", "flexpanelturnover","flexpanelother"});
this.setResourceTypeStyle("equipment");
this.afterSelectedTag("equipment");
}else if (contractType.toString().equals("qtcc") || contractType.toString().equals("lwlcc")) {//产出物
this.getView().setVisible(true, new String[]{"flexpanelturnover"});
this.getView().setVisible(false, new String[]{"flexpanelsub", "flexpanellabour", "flexpanelcomposite", "flexpanelequipment", "flexpanelmaterial","flexpanelother"});
this.setResourceTypeStyle("turnover");
this.afterSelectedTag("turnover");
}
}
}
System.out.println();
}
}

View File

@ -0,0 +1,46 @@
package zcgj.zcdev.zcdev.pr.plugin.operate;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
public class ContractSettleOp extends AbstractOperationServicePlugIn {
@Override
public void onAddValidators(AddValidatorsEventArgs e) {
super.onAddValidators(e);
DynamicObject[] dataEntities1 = e.getDataEntities();
DynamicObject object = dataEntities1[0];
Object changetype = object.getString("changetype");
if (changetype != null) {
if (changetype.toString().equals("03")) {
DynamicObject contract = object.getDynamicObject("contract");
String billName = contract.getDataEntityType().getName();
DynamicObject zcgjpartb = object.getDynamicObject("zcgj_partb");
DynamicObjectCollection zcgjOtherpart = object.getDynamicObjectCollection("zcgj_otherpart");
if (billName.equals("ec_out_contract_f7")) {
QFilter f1 = new QFilter("number", "=", contract.getString("number"));
DynamicObject outContractF7 = BusinessDataServiceHelper.loadSingle("ec_out_contract_f7", new QFilter[]{f1});
outContractF7.set("partb", zcgjpartb);
OperationResult saveOperationResult = SaveServiceHelper.saveOperate("ec_out_contract_f7", new DynamicObject[]{outContractF7}, null);//支出合同F7实体
QFilter f2 = new QFilter("billno", "=", contract.getString("number"));
DynamicObject outContract = BusinessDataServiceHelper.loadSingle("ec_out_contract", new QFilter[]{f2});
outContract.set("partb", zcgjpartb);
if (zcgjOtherpart != null) {
// DynamicObjectCollection otherpart = (DynamicObjectCollection) this.getModel().getValue("zcgj_otherpart");
outContract.set("otherpart", zcgjOtherpart);
outContract.set("ismulticontract", true);
}
OperationResult saveOperationResult1 = SaveServiceHelper.saveOperate("ec_out_contract", new DynamicObject[]{outContractF7}, null);//支出合同实体
System.out.println(saveOperationResult1);
}
}
}
}
}

View File

@ -29,20 +29,22 @@ public class InContractSettlementValidator extends InContractSettleValidator {
long id = dataEntity.getDataEntity().getLong("id");
QFilter f1 = new QFilter("id", "=", id);
DynamicObject incontractsettle = BusinessDataServiceHelper.loadSingle("ec_in_contract_settle", new QFilter[]{f1});
DynamicObjectCollection itementry = incontractsettle.getDynamicObjectCollection("itementry");
if(itementry == null) {
if(itementry.isEmpty()) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
}
DynamicObject contract = BusinessDataServiceHelper.loadSingle(dataEntity.getDataEntity().getDynamicObject("contract").getPkValue(), "ec_in_contract");
BigDecimal totalSettleOfTaxAmount = contract.getBigDecimal("totalsettleoftaxamount");
BigDecimal totalOfTaxAmount = contract.getBigDecimal("totaloftaxamount");
DynamicObject contractType = contract.getDynamicObject("contracttype");
DynamicObject contractAttr = contractType == null ? null : contractType.getDynamicObject("contattr");
boolean validateAmount = true;
if (contractAttr != null) {
contractAttr = BusinessDataServiceHelper.loadSingle(contractAttr.getPkValue(), "ec_contattr");
validateAmount = !StringUtils.equals("09", contractAttr.getString("basictype"));
if(incontractsettle!=null){
DynamicObjectCollection itementry = incontractsettle.getDynamicObjectCollection("itementry");
if(itementry == null) {
if(itementry.isEmpty()) {
this.addErrorMessage(dataEntity, ResManager.loadKDString("支付合同项不能为空", "InContractSettleValidator_0", "ec-contract-opplugin", new Object[0]));
}
DynamicObject contract = BusinessDataServiceHelper.loadSingle(dataEntity.getDataEntity().getDynamicObject("contract").getPkValue(), "ec_in_contract");
BigDecimal totalSettleOfTaxAmount = contract.getBigDecimal("totalsettleoftaxamount");
BigDecimal totalOfTaxAmount = contract.getBigDecimal("totaloftaxamount");
DynamicObject contractType = contract.getDynamicObject("contracttype");
DynamicObject contractAttr = contractType == null ? null : contractType.getDynamicObject("contattr");
boolean validateAmount = true;
if (contractAttr != null) {
contractAttr = BusinessDataServiceHelper.loadSingle(contractAttr.getPkValue(), "ec_contattr");
validateAmount = !StringUtils.equals("09", contractAttr.getString("basictype"));
}
}
}
// DynamicObjectCollection payitemdetailap = incontractsettle.getDynamicObjectCollection("payitemdetailap");