package com.youchain.modules.quartz.task;

import com.youchain.businessdata.inputJson.MoInfo;
import com.youchain.businessdata.inputJson.MoParams;
import com.youchain.businessdata.rest.MlsController;
import com.youchain.businessdata.service.MlsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.Set;

/**
 * 获取mo定时任务
 */


@Slf4j
@Service
public class moTask {
    @Autowired
    public MlsService mlsService;

    public void moTask() {

        try {
            log.info("获取mo信息");
            MoInfo moInfo = getMoInfo();
            String moJson = mlsService.getMoJson(moInfo);
            mlsService.getMoInfo(moJson);
        } catch (Exception e) {
            throw new RuntimeException("MLS异常信息:" + e);
        }

    }

    public MoInfo getMoInfo() {

        MoParams params = new MoParams();
        params.setOrgId(808);
        Set invCodes = new HashSet<>();
        invCodes.add("MA2111");
        params.setInvCodes(invCodes);
        //DateUtil.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd HH:mm:ss")
        params.setStartTime("2024-04-11 00:00:00");
        params.setEndTime("2024-04-11 23:59:59");
        MoInfo moInfo = new MoInfo();
        moInfo.setIfaceCode("MLS-WQ-003");
        moInfo.setSourceSystem("WQ");
        moInfo.setParams(params);
        return moInfo;
    }
}
