package com.xisc.pm.app.service.strategy.pdrule;

import java.util.Map;

import org.springframework.stereotype.Component;

import com.xisc.pm.api.dto.RuleParamDTO;
import com.xisc.pm.app.service.strategy.RuleExecStrategyFactory;
import com.xisc.pm.domain.entity.PmContMscTech;
import com.xisc.pm.infra.constant.RuleSetConstants;
import com.xisc.pm.infra.enums.PdRuleItemType;

import io.choerodon.core.exception.CommonException;

/**
 * 非轴合同与轴合同走查模式相同要相同检查（C03）
 * 
 * @author jun.zeng
 * 
 */
@Deprecated
@Component
public class UltCheckMatchRuleExecStrategy implements RuleExecStrategy {

    @Override
    public void afterPropertiesSet() throws Exception {
        RuleExecStrategyFactory.register(PdRuleItemType.ULT_CHECK_MATCH, this);
    }

    @Override
    public boolean execRule(RuleParamDTO ruleParam) {
        Map<String, Object> bizData = ruleParam.getBizData();
        String orderNo = (String) bizData.get(RuleSetConstants.ORDER_NO);
        String mscLineNo = (String) bizData.get(RuleSetConstants.MSC_LINE_NO);

        PmContMscTech axisPmContMscTech = (PmContMscTech) bizData.get(RuleSetConstants.AXIS_PM_CONT_MSC_TECH);
        PmContMscTech pmContMscTech = (PmContMscTech) bizData.get(RuleSetConstants.PM_CONT_MSC_TECH);

        if (axisPmContMscTech == null || pmContMscTech == null) {
            // 读生产合同池没有找到记录，合同号【order_no】，产线号【msc_line_no】
            throw new CommonException("pm.pm_pd_rule_set_001", orderNo, mscLineNo);
        }
        return true;
    }

}
