Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
哈哈哈丿 2025-07-02 18:40:52 +08:00
commit 93bde50a7c
3 changed files with 77 additions and 40 deletions

View File

@ -11,6 +11,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import kd.bos.bill.AbstractBillPlugIn; import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.bill.OperationStatus; import kd.bos.bill.OperationStatus;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
@ -33,7 +34,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.ec.basedata.common.utils.OpenPageUtils; import kd.ec.basedata.common.utils.OpenPageUtils;
/** /**
* 出库单领料出库与领料申请关联逻辑 * 出库单领料出库与领料申请关联逻辑和使用设备赋值逻辑
*/ */
public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements BeforeF7SelectListener { public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements BeforeF7SelectListener {
private static final String APPLYBILL = "applybill"; private static final String APPLYBILL = "applybill";
@ -45,7 +46,7 @@ public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements Bef
public void registerListener(EventObject e) { public void registerListener(EventObject e) {
super.registerListener(e); super.registerListener(e);
BasedataEdit basedataEdit = (BasedataEdit)this.getControl("applybill"); BasedataEdit basedataEdit = (BasedataEdit) this.getControl("applybill");
basedataEdit.addBeforeF7SelectListener(this); basedataEdit.addBeforeF7SelectListener(this);
basedataEdit.addBeforeF7ViewDetailListener((beforeF7ViewDetailEvent) -> { basedataEdit.addBeforeF7ViewDetailListener((beforeF7ViewDetailEvent) -> {
beforeF7ViewDetailEvent.setCancel(true); beforeF7ViewDetailEvent.setCancel(true);
@ -63,9 +64,9 @@ public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements Bef
public void beforeDoOperation(BeforeDoOperationEventArgs args) { public void beforeDoOperation(BeforeDoOperationEventArgs args) {
super.beforeDoOperation(args); super.beforeDoOperation(args);
FormOperate operate = (FormOperate)args.getSource(); FormOperate operate = (FormOperate) args.getSource();
String operateKey = operate.getOperateKey(); String operateKey = operate.getOperateKey();
DynamicObject applyBill = (DynamicObject)this.getModel().getValue("applybill"); DynamicObject applyBill = (DynamicObject) this.getModel().getValue("applybill");
if (StringUtils.equals("addnewentry", operateKey)) { if (StringUtils.equals("addnewentry", operateKey)) {
if (applyBill != null) { if (applyBill != null) {
this.openApplyEntryForm(); this.openApplyEntryForm();
@ -77,8 +78,8 @@ public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements Bef
} }
protected void beforeApplyBillSelect(BeforeF7SelectEvent arg0) { protected void beforeApplyBillSelect(BeforeF7SelectEvent arg0) {
DynamicObject project = (DynamicObject)this.getModel().getValue("project"); DynamicObject project = (DynamicObject) this.getModel().getValue("project");
DynamicObject warehouse = (DynamicObject)this.getModel().getValue("warehouse"); DynamicObject warehouse = (DynamicObject) this.getModel().getValue("warehouse");
if (warehouse == null) { if (warehouse == null) {
this.getView().showTipNotification(ResManager.loadKDString("请先选中仓库。", "MaterialOutApplyPlugin_1", "ec-ecma-formplugin", new Object[0]), 3000); this.getView().showTipNotification(ResManager.loadKDString("请先选中仓库。", "MaterialOutApplyPlugin_1", "ec-ecma-formplugin", new Object[0]), 3000);
arg0.setCancel(true); arg0.setCancel(true);
@ -103,12 +104,24 @@ public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements Bef
ChangeData changeData = e.getChangeSet()[0]; ChangeData changeData = e.getChangeSet()[0];
if (StringUtils.equals(name, "applybill")) { if (StringUtils.equals(name, "applybill")) {
this.applyBillChanged(changeData); this.applyBillChanged(changeData);
} else if (StringUtils.equals(name, "material")) {
//资源编码
DynamicObject material = (DynamicObject) changeData.getNewValue();
int rowIndex = changeData.getRowIndex(); //修改行所在行行号
DynamicObject applybill = (DynamicObject) this.getModel().getValue("applybill");//领料申请单
if (material != null && rowIndex > 0 && applybill == null) {
DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("entryentity");//出库单明细
DynamicObject entryEntity = entryEntityCollection.get(0);
DynamicObject zcgj_shebei = entryEntity.getDynamicObject("zcgj_shebei");//使用设备
if (zcgj_shebei != null) {
this.getModel().setValue("zcgj_shebei", zcgj_shebei, rowIndex);//使用设备
}
}
} }
} }
protected void applyBillChanged(ChangeData changeData) { protected void applyBillChanged(ChangeData changeData) {
DynamicObject newValue = (DynamicObject)changeData.getNewValue(); DynamicObject newValue = (DynamicObject) changeData.getNewValue();
if (newValue != null) { if (newValue != null) {
newValue = BusinessDataServiceHelper.loadSingle(newValue.getPkValue(), "ecma_materialapplybill"); newValue = BusinessDataServiceHelper.loadSingle(newValue.getPkValue(), "ecma_materialapplybill");
this.carryHeadData(newValue); this.carryHeadData(newValue);
@ -128,8 +141,8 @@ public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements Bef
if (applyEntries != null && !applyEntries.isEmpty()) { if (applyEntries != null && !applyEntries.isEmpty()) {
Iterator var4 = applyEntries.iterator(); Iterator var4 = applyEntries.iterator();
while(var4.hasNext()) { while (var4.hasNext()) {
DynamicObject applyEntry = (DynamicObject)var4.next(); DynamicObject applyEntry = (DynamicObject) var4.next();
BigDecimal restQty = applyEntry.getBigDecimal("restqty"); BigDecimal restQty = applyEntry.getBigDecimal("restqty");
if (restQty.compareTo(BigDecimal.ZERO) != 0) { if (restQty.compareTo(BigDecimal.ZERO) != 0) {
DynamicObject newEntry = new DynamicObject(entries.getDynamicObjectType()); DynamicObject newEntry = new DynamicObject(entries.getDynamicObjectType());
@ -168,8 +181,8 @@ public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements Bef
if (applyEntries != null && !applyEntries.isEmpty()) { if (applyEntries != null && !applyEntries.isEmpty()) {
Iterator var5 = applyEntries.iterator(); Iterator var5 = applyEntries.iterator();
while(var5.hasNext()) { while (var5.hasNext()) {
DynamicObject applyEntry = (DynamicObject)var5.next(); DynamicObject applyEntry = (DynamicObject) var5.next();
if (applyEntryIdList.contains(applyEntry.getPkValue())) { if (applyEntryIdList.contains(applyEntry.getPkValue())) {
DynamicObject newEntry = new DynamicObject(entries.getDynamicObjectType()); DynamicObject newEntry = new DynamicObject(entries.getDynamicObjectType());
newEntry.set("applyentryid", applyEntry.getLong("id")); newEntry.set("applyentryid", applyEntry.getLong("id"));
@ -259,13 +272,13 @@ public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements Bef
} }
private void openApplyEntryForm() { private void openApplyEntryForm() {
DynamicObject applyBill = (DynamicObject)this.getModel().getValue("applybill");//领料申请单 DynamicObject applyBill = (DynamicObject) this.getModel().getValue("applybill");//领料申请单
DynamicObjectCollection entries = this.getModel().getEntryEntity("entryentity"); DynamicObjectCollection entries = this.getModel().getEntryEntity("entryentity");
StringBuffer selectedEntryIdBuff = new StringBuffer(); StringBuffer selectedEntryIdBuff = new StringBuffer();
Iterator var4 = entries.iterator(); Iterator var4 = entries.iterator();
while(var4.hasNext()) { while (var4.hasNext()) {
DynamicObject entry = (DynamicObject)var4.next(); DynamicObject entry = (DynamicObject) var4.next();
selectedEntryIdBuff.append(entry.get("applyentryid")).append(","); selectedEntryIdBuff.append(entry.get("applyentryid")).append(",");
} }
@ -284,10 +297,10 @@ public class MaterialOutApplyPluginExt extends AbstractBillPlugIn implements Bef
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) { public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
String actionID = closedCallBackEvent.getActionId(); String actionID = closedCallBackEvent.getActionId();
Object returnData = closedCallBackEvent.getReturnData(); Object returnData = closedCallBackEvent.getReturnData();
DynamicObject applyBill = (DynamicObject)this.getModel().getValue("applybill"); DynamicObject applyBill = (DynamicObject) this.getModel().getValue("applybill");
if (StringUtils.equals(actionID, "applyEntryCallback") && returnData != null) { if (StringUtils.equals(actionID, "applyEntryCallback") && returnData != null) {
Map<String, Object> data = (Map)returnData; Map<String, Object> data = (Map) returnData;
List<Long> applyEntryIdList = (List)data.get("applyEntryIdList"); List<Long> applyEntryIdList = (List) data.get("applyEntryIdList");
if (applyBill != null) { if (applyBill != null) {
DynamicObject applyBillData = BusinessDataServiceHelper.loadSingle(applyBill.getPkValue(), "ecma_materialapplybill"); DynamicObject applyBillData = BusinessDataServiceHelper.loadSingle(applyBill.getPkValue(), "ecma_materialapplybill");
this.carryEntryDataFromReturnData(applyBillData, applyEntryIdList); this.carryEntryDataFromReturnData(applyBillData, applyEntryIdList);

View File

@ -13,20 +13,22 @@ public class ContractPublicValidator extends AbstractValidator {
@Override @Override
public void validate() { public void validate() {
for (ExtendedDataEntity dataEntity : this.getDataEntities()) { for (ExtendedDataEntity dataEntity : this.getDataEntities()) {
DynamicObject dynamicObject = dataEntity.getDataEntity(); if (dataEntity!=null){
String zcgjPricetype = dynamicObject.getString("zcgj_pricetype"); DynamicObject dynamicObject = dataEntity.getDataEntity();
if (zcgjPricetype.equals("gddj")){ String zcgjPricetype = dynamicObject.getString("zcgj_pricetype");
DynamicObjectCollection modelEntries = dynamicObject.getDynamicObjectCollection("listmodelentry"); if (zcgjPricetype.equals("gddj")){
for (DynamicObject object : modelEntries) { DynamicObjectCollection modelEntries = dynamicObject.getDynamicObjectCollection("listmodelentry");
DynamicObjectCollection listingEntries = object.getDynamicObjectCollection("sublistentry"); for (DynamicObject object : modelEntries) {
if (listingEntries.size()==0){ DynamicObjectCollection listingEntries = object.getDynamicObjectCollection("sublistentry");
this.addErrorMessage(dataEntity, "“计价方式”为“固定单价”时“合同清单”不能为空!"); if (listingEntries.size()==0){
}else{ this.addErrorMessage(dataEntity, "“计价方式”为“固定单价”时“合同清单”不能为空!");
for (int i = 0; i < listingEntries.size(); i++) { }else{
DynamicObject listingEntrie = listingEntries.get(i); for (int i = 0; i < listingEntries.size(); i++) {
BigDecimal price = listingEntrie.getBigDecimal("price"); DynamicObject listingEntrie = listingEntries.get(i);
if (price.compareTo(new BigDecimal(0))==0 || price==null){ BigDecimal price = listingEntrie.getBigDecimal("price");
this.addErrorMessage(dataEntity, "“合同清单”中的单价不能为空!"); if (price.compareTo(new BigDecimal(0))==0 || price==null){
this.addErrorMessage(dataEntity, "“合同清单”中的单价不能为空!");
}
} }
} }
} }

View File

@ -5,6 +5,8 @@ import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.operate.result.OperationResult; import kd.bos.entity.operate.result.OperationResult;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn; import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs; import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper;
@ -13,17 +15,25 @@ public class ContractSettleOp extends AbstractOperationServicePlugIn {
@Override @Override
public void onAddValidators(AddValidatorsEventArgs e) { public void onAddValidators(AddValidatorsEventArgs e) {
System.out.println();
super.onAddValidators(e); super.onAddValidators(e);
}
@Override
public void beginOperationTransaction(BeginOperationTransactionArgs e) {
super.beginOperationTransaction(e);
DynamicObject[] dataEntities1 = e.getDataEntities(); DynamicObject[] dataEntities1 = e.getDataEntities();
if(dataEntities1!=null && dataEntities1.length>0){ if(dataEntities1!=null && dataEntities1.length>0){
DynamicObject object = dataEntities1[0]; DynamicObject object = dataEntities1[0];
Object changetype = object.getString("changetype"); DynamicObject ecoutrevision = BusinessDataServiceHelper.loadSingle("ec_outrevision", new QFilter[]{new QFilter("billno", "=", object.getString("billno"))});
Object changetype = ecoutrevision.getString("changetype");
if (changetype != null) { if (changetype != null) {
if (changetype.toString().equals("03")) { if (changetype.toString().equals("03")) {
DynamicObject contract = object.getDynamicObject("contract"); DynamicObject contract = ecoutrevision.getDynamicObject("contract");
String billName = contract.getDataEntityType().getName(); String billName = contract.getDataEntityType().getName();
DynamicObject zcgjpartb = object.getDynamicObject("zcgj_partb"); DynamicObject zcgjpartb = ecoutrevision.getDynamicObject("zcgj_partb");
DynamicObjectCollection zcgjOtherpart = object.getDynamicObjectCollection("zcgj_otherpart"); DynamicObjectCollection zcgjOtherpart = ecoutrevision.getDynamicObjectCollection("zcgj_otherpart");
if (billName.equals("ec_out_contract_f7")) { if (billName.equals("ec_out_contract_f7")) {
QFilter f1 = new QFilter("number", "=", contract.getString("number")); QFilter f1 = new QFilter("number", "=", contract.getString("number"));
DynamicObject outContractF7 = BusinessDataServiceHelper.loadSingle("ec_out_contract_f7", new QFilter[]{f1}); DynamicObject outContractF7 = BusinessDataServiceHelper.loadSingle("ec_out_contract_f7", new QFilter[]{f1});
@ -33,12 +43,24 @@ public class ContractSettleOp extends AbstractOperationServicePlugIn {
QFilter f2 = new QFilter("billno", "=", contract.getString("number")); QFilter f2 = new QFilter("billno", "=", contract.getString("number"));
DynamicObject outContract = BusinessDataServiceHelper.loadSingle("ec_out_contract", new QFilter[]{f2}); DynamicObject outContract = BusinessDataServiceHelper.loadSingle("ec_out_contract", new QFilter[]{f2});
outContract.set("partb", zcgjpartb); outContract.set("partb", zcgjpartb);
if (zcgjOtherpart != null) { if (zcgjOtherpart.size()>0) {
// DynamicObjectCollection otherpart = (DynamicObjectCollection) this.getModel().getValue("zcgj_otherpart"); // 深度克隆集合
outContract.set("otherpart", zcgjOtherpart); DynamicObjectCollection otherpart = outContract.getDynamicObjectCollection("otherpart");
DynamicObjectCollection clone =(DynamicObjectCollection) otherpart.clone();
clone.clear();
for(DynamicObject item : zcgjOtherpart) {
DynamicObject bd_supplier = new DynamicObject(otherpart.getDynamicObjectType());
bd_supplier.set("fbasedataid",item.get(2));
clone.add(bd_supplier);
}
// 设置并标记修改
outContract.set("otherpart", clone);
// outContract.set("otherpart", true); // 关键
outContract.set("ismulticontract", true); outContract.set("ismulticontract", true);
} }
OperationResult saveOperationResult1 = SaveServiceHelper.saveOperate("ec_out_contract", new DynamicObject[]{outContract}, null);//支出合同实体 SaveServiceHelper.save(new DynamicObject[]{outContract});//支出合同实体
} }
} }
} }