package cn.quantgroup.customer.service.impl;

import static cn.quantgroup.customer.constant.Constant.GSON;

import cn.quantgroup.customer.enums.ErrorCodeEnum;
import cn.quantgroup.customer.rest.vo.JsonResult;
import cn.quantgroup.customer.rest.vo.thirdworkorder.ThirdWorkOrderExportVo;
import cn.quantgroup.customer.service.IKdspService;
import cn.quantgroup.customer.service.http.IHttpService;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author Wang Xiangwei
 * @version 2020/3/9
 */
@Slf4j
@Service
public class KdspServiceImpl implements IKdspService {


//    @Value("${kdsp.operation.http}")
    private String kdspOperationUrl;

    @Autowired
    private IHttpService httpService;

    @Override
    public JsonResult<List<ThirdWorkOrderExportVo>> getOrderDetailForWorkOder(
        List<String> orderNos) {

        String url = "http://kdsp-operation-yxm.liangkebang.net/api/kdsp/op/order/getOrderDetailForWorkOder";
        JsonResult<List<ThirdWorkOrderExportVo>> jsonResult = null;
        try {
            String result = httpService.postJson(url, orderNos);
            jsonResult = GSON.fromJson(result, JsonResult.class);
            log.info("工单查询订单详情返回值:{}", result);
        } catch (Exception ex) {
            log.error("工单查询订单详情异常",ex);
            return JsonResult.buildErrorStateResult(ErrorCodeEnum.NET_ERROR.getMessage(), null);
        }
        return  jsonResult;
    }
}
