package com.yem.wm.bd.warehouse.op;

import com.yem.wm.utils.YunzhijiaUtils;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.plugin.args.BeforeOperationArgs;
import kd.bos.servicehelper.operation.SaveServiceHelper;

public class UpdateWareHouseSortOp extends AbstractOperationServicePlugIn {
    @Override
    public void onPreparePropertys(PreparePropertysEventArgs e) {
        e.getFieldKeys().add("yem_sort");
        super.onPreparePropertys(e);
    }

    @Override
    public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
        super.beforeExecuteOperationTransaction(e);
        //获取按钮
        String key = e.getOperationKey().toLowerCase();

        for (ExtendedDataEntity dataEntity : e.getSelectedRows()) {
            DynamicObject wh = dataEntity.getDataEntity();
            if ("updateNormal".toLowerCase().equals(key)) {
                //批量修改正常仓库
                wh.set("yem_sort","C");
            }
            if ("updateVMI".toLowerCase().equals(key)) {
                //批量修改VMI仓库
                wh.set("yem_sort","V");
            }
            if ("updateZZZX".toLowerCase().equals(key)) {
                //批量修改制造中心仓库
                wh.set("yem_sort","Z");
            }
            if ("updateGM".toLowerCase().equals(key)) {
                //批量修改国贸各事业部仓库
                wh.set("yem_sort","D");
            }
            SaveServiceHelper.update(wh);
        }
    }
}
