package com.reptileclient.jlifeapp.web;

import com.reptileclient.jlifeapp.result.ResponseInfoEnum;
import com.reptileclient.jlifeapp.result.ResultBody;
import com.reptileclient.jlifeapp.schedule.HmETLTask;
import com.reptileclient.jlifeapp.service.HmBookOrderService;
import com.reptileclient.jlifeapp.service.HmEncryptPhoneRepairService;
import com.reptileclient.jlifeapp.util.DateUtils;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author fuxubing
 */
@RestController
@Api(value = "服务单管理", description = "服务单管理")
public class HmBookOrderController {

    private static final Logger logger = LoggerFactory.getLogger(HmBookOrderController.class);
    @Resource
    private HmBookOrderService hmBookOrderService;

    @Autowired
    HmETLTask hmBookOrderTask;

    @Autowired
    HmEncryptPhoneRepairService hmEncryptPhoneRepairService;

    @ApiOperation(value = "通过预约人手机号同步盒马服务单")
    @GetMapping("syncHmBookOrderByPhone")
    public ResultBody syncHmBookOrderByPhone(String phone) {
        logger.info("通过预约人手机号同步盒马服务单:" + phone);

        if (StringUtils.isBlank(phone)) {
            return new ResultBody(ResponseInfoEnum.PHONE_IS_NULL);
        }
        int row = hmBookOrderService.syncHmBookOrderByPhone(phone);
        return new ResultBody(row);
    }

    @ApiOperation(value = "同步盒马服务单")
    @GetMapping("addHmBookOrder")
    public ResultBody addHmBookOrder() {
        new Thread(() -> {
            //hmBookOrderService.addBookOrderList();
        }).start();
        return new ResultBody();
    }

  

}
