package com.djhk.uav.uav.service.impl;

import com.djhk.common.core.domain.R;
import com.djhk.common.core.page.TableDataInfo;
import com.djhk.uav.airspace.domain.UavInfo;
import com.djhk.uav.uav.model.UavRepair;
import com.djhk.uav.uav.service.IUavRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 维修信息维护   Service接口
 * @description
 * @author mayongkai
 * @date 2023/3/11 19:16:58
 * @version 1.0
 */
@Service
public class UavRepairServiceImpl implements IUavRepairService
{

//    @Autowired
////    private UavRepairClient uavRepairClient;
//    @Autowired
//    private UavInfoClient uavInfoClient;
    @Override
    public R<List<UavRepair>> selectUavRepairList(Map<String, Object> param) {
//        return uavRepairClient.findUavRepairList(param);
        return R.ok();
    }

    @Override
    public TableDataInfo selectUavTableData(Map<String, Object> param) {
//        return uavRepairClient.list(param);
        return null;
    }

    @Override
    public R<UavRepair> selectUavRepairById(Long id) {
//        return uavRepairClient.selectUavRepairInfoById(id);
        return R.ok();
    }

    @Override
    public R insertUavRepair(UavRepair uavRepair) {
//        return uavRepairClient.add(uavRepair);
        return R.ok();
    }

    @Override
    public R updateUavRepair(UavRepair uavRepair) {
//        return uavRepairClient.edit(uavRepair);
        return R.ok();
    }

    @Override
    public R deleteUavRepairByIds(Long[] ids) {
//        return uavRepairClient.removeTask(ids);
        return R.ok();
    }

    @Override
    public R<UavInfo> getInfoByUavNum(String uavNum) {
        Map<String,Object> param = new HashMap<>();
        param.put("uavNum",uavNum);
//        R<List<UavInfo>> r = uavInfoClient.findUavInfoList(param);
        R<List<UavInfo>> r = new R<List<UavInfo>>();
        if(r.getCode() == R.SUCCESS){
            List<UavInfo> uavInfos = r.getData();
            UavInfo uavInfo = uavInfos.stream().filter(x -> x.getUavNum().equals(uavNum)).findFirst().orElse(new UavInfo());
            if(uavInfo != null){
                return R.ok(uavInfo);
            }
        }
        return R.fail("无人机编号不存在");
    }

    @Override
    public TableDataInfo selectUavRepairSubData(Map<String, Object> param) {
//        return uavRepairClient.selectUavRepairSubData(param);
        return null;
    }
}
