package com.sw.mes.yb.fls.service.impl;

import com.sw.mes.core.annotation.ServiceLogs;
import com.sw.mes.core.response.Result;
import com.sw.mes.yb.fls.dto.*;
import com.sw.mes.yb.fls.service.MesToFlsService;
import com.sw.mes.yb.fls.utils.*;
import com.sw.mes.yb.plan.dto.PlanWaterLineManageToWmsDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * @Author: GaoXinJian
 * @Date: 2022-02-16 12:30
 */
@Service
@Transactional
public class MesToFlsServiceImpl implements MesToFlsService {
    @Autowired
    private RequestUtil requestUtil;
    private final String callAgvUrl = "";
    private final String kfReturnMaterialStatusOutUrl = "/mes/kfback";
    @Autowired
    private FlsRequestUtil flsRequestUtil;
    private final String flsRecycledUrl = "/fls/mk/mes.fls";
    private final String planWaterLineUrl = "/fls2/project/tyjk/mes/mes.fls";
    @Value("${spring.flsServiceUrl}")
    private String flsServiceUrl;

    @Value("${spring.fls3ServiceUrl}")
    private String fls3ServiceUrl;

//    @Value("${spring.fls2ServiceUrl}")
//    private String fls2ServiceUrl;

    @Override
    public ResultDto callAgv(CallAGVDto callAGVDto) {
        return requestUtil.postForFls(new RequestDto(callAgvUrl, callAGVDto), flsServiceUrl);
    }

    @Override
    @ServiceLogs(description = "开方退料状态下发smcs")
    public ResultDto kfReturnMaterialStatusOut(KfReturnMaterialStatusDto kfReturnMaterialStatusDto) {
        return requestUtil.postForFls(new RequestDto(kfReturnMaterialStatusOutUrl, kfReturnMaterialStatusDto), flsServiceUrl);
    }

    @Override
    public FlsResultDto unbindBracketNo(BracketNoRequestDto bracketNoRequestDto) {

        return flsRequestUtil.postForFls(new RequestDto(flsRecycledUrl, bracketNoRequestDto), flsServiceUrl);
    }

    @Override
    public FlsResultDto recycledMaterialToAGV(RecycledMaterialToAGVDtos recycledMaterialToAGVDto) {

        return flsRequestUtil.postForFls(new RequestDto(flsRecycledUrl, recycledMaterialToAGVDto), flsServiceUrl);

    }

    @Override
    public FlsResultDto sendSectionForInfo(BracketNoToFlsDto bracketNoToFlsDto) {
        return flsRequestUtil.postForFls(new RequestDto(flsRecycledUrl, bracketNoToFlsDto), flsServiceUrl);

    }

    @Override
    public FlsResultDto planWaterLineManageToWmsDto(PlanWaterLineManageToWmsDto planWaterLineManageToWmsDto) {
        planWaterLineManageToWmsDto.setMode("ybDownOrderUpdate");
        return flsRequestUtil.postForFls(new RequestDto(planWaterLineUrl, planWaterLineManageToWmsDto),fls3ServiceUrl);
    }

}
