public with sharing class MergeAgencyActivityController {
    public String oldAgencyCode {get; set;} 
    public String newAgencyCode {get; set;} 
    public boolean forceFlg {get; set;} 
    public boolean startFlg {get; set;} 

    public MergeAgencyActivityController() {   
        startFlg = false; 
        forceFlg = true;
    }

    public void startJob() {
        if (String.isBlank(oldAgencyCode)) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'旧经销商编码未设置'));
            return;
        }
        if (String.isBlank(newAgencyCode)) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'新经销商编码未设置'));
            return;
        }
        MergeAgencyActivityBatch mBatch = new MergeAgencyActivityBatch(oldAgencyCode, newAgencyCode, forceFlg);
        Database.executeBatch(mBatch);
        startFlg = true;
    }
}