Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
		
						commit
						192a891710
					
				| 
						 | 
				
			
			@ -23,6 +23,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
 | 
			
		|||
import kd.bos.servicehelper.QueryServiceHelper;
 | 
			
		||||
import kd.sdk.plugin.Plugin;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -48,15 +49,27 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
 | 
			
		|||
            HashMap<String, Object> paramters = new HashMap<>();
 | 
			
		||||
            DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("entryentity");//入库单分录
 | 
			
		||||
            List<Long> entryIds = new ArrayList<>();
 | 
			
		||||
            List<Long> entryIds2 = new ArrayList<>();
 | 
			
		||||
//            List<Long> entryIds2 = new ArrayList<>();
 | 
			
		||||
            for (DynamicObject entryEntity : entryEntityCollection) {
 | 
			
		||||
                Long entryEntityId = entryEntity.getLong("listingid");//合同清单id
 | 
			
		||||
                entryIds.add(entryEntityId);
 | 
			
		||||
                entryIds2.add(entryEntityId);
 | 
			
		||||
//                entryIds2.add(entryEntityId);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            long purchaseApplyId = purchaseApply.getLong("id");//采购申请单id
 | 
			
		||||
            QFilter[] qFilte = new QFilter[]{new QFilter("zcgj_purchaseapply.id", QCP.equals, purchaseApplyId)};
 | 
			
		||||
            QFilter[] qFilter = new QFilter[]{new QFilter("id", QCP.equals, purchaseApplyId)};
 | 
			
		||||
            DynamicObject ecma_purchaseApply = BusinessDataServiceHelper.loadSingle("ecma_purchaseapply",
 | 
			
		||||
                    "purchaseentry,purchaseentry.purchaseqty,purchaseentry.zcgj_incount,purchaseentry.id", qFilter);//采购申请单
 | 
			
		||||
            DynamicObjectCollection purchaseEntryCollection = ecma_purchaseApply.getDynamicObjectCollection("purchaseentry");//采购明细单据体
 | 
			
		||||
            for (DynamicObject purchaseEntry : purchaseEntryCollection) {
 | 
			
		||||
                BigDecimal purchaseQty = purchaseEntry.getBigDecimal("purchaseqty");//采购数量
 | 
			
		||||
                BigDecimal zcgj_inCount = purchaseEntry.getBigDecimal("zcgj_incount");//已入库数量
 | 
			
		||||
                if (purchaseQty.compareTo(zcgj_inCount) == 0) {
 | 
			
		||||
                    long purchaseEntryId = purchaseEntry.getLong("id");
 | 
			
		||||
                    entryIds.add(purchaseEntryId);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
/*            QFilter[] qFilte = new QFilter[]{new QFilter("zcgj_purchaseapply.id", QCP.equals, purchaseApplyId)};
 | 
			
		||||
            DynamicObject[] ecma_materialInBills = BusinessDataServiceHelper.load("ecma_materialinbill","entryentity,entryentity.listingid", qFilte);//入库单
 | 
			
		||||
            for (DynamicObject materialInBill : ecma_materialInBills) {
 | 
			
		||||
                DynamicObjectCollection entryEntityCollection1 = materialInBill.getDynamicObjectCollection("entryentity");//入库单分录
 | 
			
		||||
| 
						 | 
				
			
			@ -69,7 +82,7 @@ public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implement
 | 
			
		|||
                    }
 | 
			
		||||
                    entryIds.add(entryEntityId);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            }*/
 | 
			
		||||
            paramters.put("purchaseApplyId", purchaseApplyId);
 | 
			
		||||
            paramters.put("entryIds", entryIds);
 | 
			
		||||
            formShowParameter.setCustomParams(paramters);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,69 @@
 | 
			
		|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
 | 
			
		||||
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObject;
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
			
		||||
import kd.bos.entity.ExtendedDataEntity;
 | 
			
		||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
 | 
			
		||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
 | 
			
		||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
 | 
			
		||||
import kd.bos.entity.validate.AbstractValidator;
 | 
			
		||||
import kd.bos.orm.query.QFilter;
 | 
			
		||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
 | 
			
		||||
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 入库单审核操作插件:校验是否合计数量超过采购申请单数量
 | 
			
		||||
 */
 | 
			
		||||
public class MaterialInbValidatorAuditOp extends AbstractOperationServicePlugIn {
 | 
			
		||||
    public void onPreparePropertys(PreparePropertysEventArgs e) {
 | 
			
		||||
        super.onPreparePropertys(e);
 | 
			
		||||
        e.getFieldKeys().add("matinsource");
 | 
			
		||||
        e.getFieldKeys().add("zcgj_purchaseapply");
 | 
			
		||||
        e.getFieldKeys().add("entryentity");
 | 
			
		||||
        e.getFieldKeys().add("listingid");
 | 
			
		||||
        e.getFieldKeys().add("qty");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onAddValidators(AddValidatorsEventArgs e) {
 | 
			
		||||
        super.onAddValidators(e);
 | 
			
		||||
        e.getValidators().add(new ValidatorExt());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    class ValidatorExt extends AbstractValidator {
 | 
			
		||||
        @Override
 | 
			
		||||
        public void validate() {
 | 
			
		||||
            ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
 | 
			
		||||
            for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
 | 
			
		||||
                DynamicObject ecma_MaterialInBill = extendedDataEntity.getDataEntity();
 | 
			
		||||
                String matInSource = ecma_MaterialInBill.getString("matinsource");//入库来源
 | 
			
		||||
                DynamicObject zcgj_purchaseApply = ecma_MaterialInBill.getDynamicObject("zcgj_purchaseapply");//采购申请
 | 
			
		||||
                if ("6".equals(matInSource) && zcgj_purchaseApply != null) {
 | 
			
		||||
                    DynamicObject ecma_purchaseApply = BusinessDataServiceHelper.loadSingle("ecma_purchaseapply",
 | 
			
		||||
                            new QFilter[]{new QFilter("id", "=", zcgj_purchaseApply.getLong("id"))});//采购申请单
 | 
			
		||||
                    DynamicObjectCollection entryEntityCollection = ecma_MaterialInBill.getDynamicObjectCollection("entryentity");//入库单分录
 | 
			
		||||
                    DynamicObjectCollection purchaseEntryCollection = ecma_purchaseApply.getDynamicObjectCollection("purchaseentry");//采购明细单据体
 | 
			
		||||
                    for (int i = 0; i < entryEntityCollection.size(); i++) {
 | 
			
		||||
                        DynamicObject entryEntity = entryEntityCollection.get(i);
 | 
			
		||||
                        String listingId = entryEntity.getString("listingid");//入库单分录-合同清单id
 | 
			
		||||
 | 
			
		||||
                        for (DynamicObject purchaseEntry : purchaseEntryCollection) {
 | 
			
		||||
                            String purchaseEntryId = purchaseEntry.getString("id");//采购明细单据体-id
 | 
			
		||||
                            if (purchaseEntryId != null && purchaseEntryId.equals(listingId)) {
 | 
			
		||||
                                BigDecimal qty = entryEntity.getBigDecimal("qty");//入库单分录-数量
 | 
			
		||||
                                BigDecimal inCount = purchaseEntry.getBigDecimal("zcgj_incount");//采购明细单据体-已入库数量
 | 
			
		||||
                                BigDecimal purchaseQty = purchaseEntry.getBigDecimal("purchaseqty");//采购明细单据体-采购数量
 | 
			
		||||
                                BigDecimal sum = qty.add(inCount);
 | 
			
		||||
                                if (sum.compareTo(purchaseQty) > 0) {
 | 
			
		||||
                                    int i1 = i + 1;
 | 
			
		||||
                                    this.addFatalErrorMessage(extendedDataEntity, "第" + i1 + "行,填写数量大于采购申请对应的采购数量!!");
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -2,8 +2,12 @@ package zcgj.zcdev.zcdev.pr.plugin.operate;
 | 
			
		|||
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObject;
 | 
			
		||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
			
		||||
import kd.bos.entity.ExtendedDataEntity;
 | 
			
		||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
 | 
			
		||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
 | 
			
		||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
 | 
			
		||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
 | 
			
		||||
import kd.bos.entity.validate.AbstractValidator;
 | 
			
		||||
import kd.bos.orm.query.QFilter;
 | 
			
		||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
 | 
			
		||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
 | 
			
		||||
| 
						 | 
				
			
			@ -13,7 +17,7 @@ import java.util.ArrayList;
 | 
			
		|||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 入库单保存删除插件:保存、删除时,将入库单数量反写至采购申请单
 | 
			
		||||
 * 入库单审核反审核操作插件:审核、反审核时,将入库单数量反写至采购申请单
 | 
			
		||||
 */
 | 
			
		||||
public class PurchaseReqBackWriteOp extends AbstractOperationServicePlugIn {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -35,8 +39,8 @@ public class PurchaseReqBackWriteOp extends AbstractOperationServicePlugIn {
 | 
			
		|||
                //为采购申请单时反写数量
 | 
			
		||||
                DynamicObject ecma_purchaseApply = BusinessDataServiceHelper.loadSingle("ecma_purchaseapply",
 | 
			
		||||
                        new QFilter[]{new QFilter("id", "=", zcgj_purchaseApply.getLong("id"))});//采购申请单
 | 
			
		||||
                DynamicObjectCollection purchaseEntryCollection = ecma_purchaseApply.getDynamicObjectCollection("purchaseentry");//采购明细单据体
 | 
			
		||||
                DynamicObjectCollection entryEntityCollection = ecma_MaterialInBill.getDynamicObjectCollection("entryentity");//入库单分录
 | 
			
		||||
                DynamicObjectCollection purchaseEntryCollection = ecma_purchaseApply.getDynamicObjectCollection("purchaseentry");//采购明细单据体
 | 
			
		||||
                for (DynamicObject entryEntity : entryEntityCollection) {
 | 
			
		||||
                    String listingId = entryEntity.getString("listingid");//入库单分录-合同清单id
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -45,9 +49,11 @@ public class PurchaseReqBackWriteOp extends AbstractOperationServicePlugIn {
 | 
			
		|||
                        if (purchaseEntryId != null && purchaseEntryId.equals(listingId)) {
 | 
			
		||||
                            BigDecimal qty = entryEntity.getBigDecimal("qty");//入库单分录-数量
 | 
			
		||||
                            BigDecimal inCount = purchaseEntry.getBigDecimal("zcgj_incount");//采购明细单据体-已入库数量
 | 
			
		||||
                            if ("save".equals(operationKey)) {
 | 
			
		||||
                            if ("audit".equals(operationKey)) {
 | 
			
		||||
                                //审核时
 | 
			
		||||
                                purchaseEntry.set("zcgj_incount", inCount.add(qty));//采购明细单据体-已入库数量
 | 
			
		||||
                            } else {
 | 
			
		||||
                            } else if ("unaudit".equals(operationKey)) {
 | 
			
		||||
                                //反审核时
 | 
			
		||||
                                purchaseEntry.set("zcgj_incount", inCount.subtract(qty));//采购明细单据体-已入库数量
 | 
			
		||||
                            }
 | 
			
		||||
                            break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue