55 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Java
		
	
	
	
package tqq9.lc123.cloud.app.plugin.form.sm;
 | 
						|
 | 
						|
import kd.bos.bill.AbstractBillPlugIn;
 | 
						|
import kd.bos.dataentity.entity.DynamicObject;
 | 
						|
import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
						|
import kd.bos.dataentity.utils.StringUtils;
 | 
						|
import kd.bos.form.events.AfterDoOperationEventArgs;
 | 
						|
import kd.bos.logging.Log;
 | 
						|
import kd.bos.logging.LogFactory;
 | 
						|
import kd.bos.servicehelper.operation.SaveServiceHelper;
 | 
						|
import kd.sdk.plugin.Plugin;
 | 
						|
import tqq9.lc123.cloud.app.plugin.operate.ap.PayBillOperationPlugin;
 | 
						|
 | 
						|
import java.util.ArrayList;
 | 
						|
import java.util.List;
 | 
						|
 | 
						|
/**
 | 
						|
 * 销售订单界面插件
 | 
						|
 */
 | 
						|
public class SaleOrderBillPlugin extends AbstractBillPlugIn implements Plugin {
 | 
						|
    private final static Log logger = LogFactory.getLog(PayBillOperationPlugin.class);
 | 
						|
 | 
						|
    /**
 | 
						|
     * 汇总分录仓库到单头
 | 
						|
     * @param afterDoOperationEventArgs
 | 
						|
     */
 | 
						|
    @Override
 | 
						|
    public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
 | 
						|
        super.afterDoOperation(afterDoOperationEventArgs);
 | 
						|
        String operateKey = afterDoOperationEventArgs.getOperateKey();
 | 
						|
        if (StringUtils.equals("save",operateKey)) {
 | 
						|
            //物料明细
 | 
						|
            DynamicObject dataEntity = this.getModel().getDataEntity(true);
 | 
						|
            DynamicObjectCollection billentry = dataEntity.getDynamicObjectCollection("billentry");
 | 
						|
            DynamicObjectCollection tqq9_ck = (DynamicObjectCollection) this.getModel().getValue("tqq9_ck");
 | 
						|
            tqq9_ck.clear();
 | 
						|
            List<String> ids=new ArrayList<>();
 | 
						|
            for (DynamicObject dynamicObject : billentry) {
 | 
						|
                DynamicObject warehouse = dynamicObject.getDynamicObject("warehouse");//仓库
 | 
						|
                if (warehouse!=null) {
 | 
						|
                    String id = warehouse.getString("id");
 | 
						|
                    DynamicObject newbrand = new DynamicObject(tqq9_ck.getDynamicObjectType());
 | 
						|
                    newbrand.set("fbasedataid",warehouse);
 | 
						|
                    if (!ids.contains(id)) {
 | 
						|
                        tqq9_ck.add(newbrand);
 | 
						|
                        ids.add(id);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            dataEntity.set("tqq9_ck",tqq9_ck);
 | 
						|
            SaveServiceHelper.save(new DynamicObject[]{dataEntity});
 | 
						|
            this.getView().updateView();
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |