package com.tofly.watermeter.handler;

import com.tofly.watermeter.custom.service.sxj.SynchronousAboutService;
import com.tofly.watermeter.service.InstallationService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author bubble
 */
@Component
@AllArgsConstructor
public class GeneratePlanHandler {

    private final SynchronousAboutService synchronousAboutService;

    private final InstallationService installationService;


    /**
     * 同步基础信息
     *
     * @param param param
     * @return ReturnT
     */
    @XxlJob("synFoundationInfo")
    public ReturnT<String> synFoundationInfo(String param) {
        synchronousAboutService.syncArea();
        synchronousAboutService.syncFactory();
        synchronousAboutService.synUseNatures();
        synchronousAboutService.synMeterReading();
        synchronousAboutService.synTableType();
        synchronousAboutService.synTableCaliber();
        return ReturnT.SUCCESS;
    }

    @XxlJob("synCustomerInfo")
    public ReturnT<String> synCustomerInfo(String param) {
        synchronousAboutService.synCustomerInfo();
        return ReturnT.SUCCESS;
    }


    @XxlJob("initRegionSection")
    public ReturnT<String> initRegionSection(String param){
        synchronousAboutService.initRegionSection();
        return ReturnT.SUCCESS;
    }

    /**
     * 同步报装水表信息
     * @param param param
     * @return true
     */
    @XxlJob("syncInstallation")
    public ReturnT<String> syncInstallation(String param){
        installationService.syncInstallation();
        return ReturnT.SUCCESS;
    }

    /**
     * 定时处理部分未同步抄表数据
     * @param param param
     * @return true
     */
    @XxlJob("handleNotSyncReadWater")
    public ReturnT<String> handleNotSyncReadWater(String param){
        synchronousAboutService.handleNotSyncReadWater();
        return ReturnT.SUCCESS;
    }

    @XxlJob("synchronousReadMeter")
    public ReturnT<String> synchronousReadMeter(String param){
        synchronousAboutService.synchronousReadMeter();
        return ReturnT.SUCCESS;
    }

    @XxlJob("syncReadHisRecord")
    public ReturnT<String> syncReadHisRecord(String param){
        synchronousAboutService.syncReadHisRecord(0,null);
        return ReturnT.SUCCESS;
    }

}
