package com.yem.wm.es.xsalesorder.validator;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.validate.AbstractValidator;
import kd.bos.servicehelper.user.UserServiceHelper;

/**
 * @author ljw
 * @date 2024/8/21 14:21
 * @description XSalesOrderSubmitAuthorValidator
 */
public class XSalesOrderSubmitAuthorValidator extends AbstractValidator {

    @Override
    public void validate() {
        ExtendedDataEntity[] dataEntities = this.getDataEntities();
        for (ExtendedDataEntity dataEntitie : dataEntities) {
            DynamicObject dataEntity = dataEntitie.getDataEntity();
            DynamicObject yemOperator = dataEntity.getDynamicObject("yem_operator");
            long currentUserId = UserServiceHelper.getCurrentUserId();
            if (yemOperator!=null){
                long aLong = yemOperator.getLong("id");
                if (aLong != currentUserId){
                    this.addMessage(dataEntitie,"当前提交人与销售人不同，请注意!!!");
                }
            }else {
//                this.addErrorMessage(dataEntitie,"当前提交人与销售人不同，请注意!!!");
                this.addMessage(dataEntitie,"当前销售人为空");
            }
        }
    }
}
