package com.uavps.system.service.impl;

import com.uavps.system.domain.UavpsAlgorithmTaskFormation;
import com.uavps.system.domain.UavpsMultiTargetFormation;
import com.uavps.system.mapper.UavpsAlgorithmTaskFormationMapper;
import com.uavps.system.service.IUavpsAlgorithmTaskFormationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 算法任务和多目标集群关联Service业务层处理
 *
 * @author ruoyi
 * @date 2025-02-18
 */
@Service
public class UavpsAlgorithmTaskFormationServiceImpl implements IUavpsAlgorithmTaskFormationService {
    @Autowired
    private UavpsAlgorithmTaskFormationMapper uavpsAlgorithmTaskFormationMapper;

    /**
     * 查询算法任务和多目标集群关联
     *
     * @param algorithmTaskId 算法任务和多目标集群关联主键
     * @return 算法任务和多目标集群关联
     */
    @Override
    public UavpsAlgorithmTaskFormation selectUavpsAlgorithmTaskFormationByAlgorithmTaskId(Long algorithmTaskId) {
        return uavpsAlgorithmTaskFormationMapper.selectUavpsAlgorithmTaskFormationByAlgorithmTaskId(algorithmTaskId);
    }

    /**
     * 查询算法任务和多目标集群关联列表
     *
     * @param uavpsAlgorithmTaskFormation 算法任务和多目标集群关联
     * @return 算法任务和多目标集群关联
     */
    @Override
    public List<UavpsAlgorithmTaskFormation> selectUavpsAlgorithmTaskFormationList(UavpsAlgorithmTaskFormation uavpsAlgorithmTaskFormation) {
        return uavpsAlgorithmTaskFormationMapper.selectUavpsAlgorithmTaskFormationList(uavpsAlgorithmTaskFormation);
    }

    /**
     * 新增算法任务和多目标集群关联
     *
     * @param uavpsAlgorithmTaskFormation 算法任务和多目标集群关联
     * @return 结果
     */
    @Override
    public int insertUavpsAlgorithmTaskFormation(UavpsAlgorithmTaskFormation uavpsAlgorithmTaskFormation) {
        return uavpsAlgorithmTaskFormationMapper.insertUavpsAlgorithmTaskFormation(uavpsAlgorithmTaskFormation);
    }

    /**
     * 修改算法任务和多目标集群关联
     *
     * @param uavpsAlgorithmTaskFormation 算法任务和多目标集群关联
     * @return 结果
     */
    @Override
    public int updateUavpsAlgorithmTaskFormation(UavpsAlgorithmTaskFormation uavpsAlgorithmTaskFormation) {
        return uavpsAlgorithmTaskFormationMapper.updateUavpsAlgorithmTaskFormation(uavpsAlgorithmTaskFormation);
    }

    /**
     * 批量删除算法任务和多目标集群关联
     *
     * @param algorithmTaskIds 需要删除的算法任务和多目标集群关联主键
     * @return 结果
     */
    @Override
    public int deleteUavpsAlgorithmTaskFormationByAlgorithmTaskIds(Long[] algorithmTaskIds) {
        return uavpsAlgorithmTaskFormationMapper.deleteUavpsAlgorithmTaskFormationByAlgorithmTaskIds(algorithmTaskIds);
    }

    /**
     * 删除算法任务和多目标集群关联信息
     *
     * @param algorithmTaskId 算法任务和多目标集群关联主键
     * @return 结果
     */
    @Override
    public int deleteUavpsAlgorithmTaskFormationByAlgorithmTaskId(Long algorithmTaskId) {
        return uavpsAlgorithmTaskFormationMapper.deleteUavpsAlgorithmTaskFormationByAlgorithmTaskId(algorithmTaskId);
    }

    @Override
    public List<Long> selectFormationByTaskId(Long taskId) {
        return uavpsAlgorithmTaskFormationMapper.selectFormationByTaskId(taskId);
    }

    @Override
    public List<UavpsMultiTargetFormation> selectFormationListByTaskId(Long taskId) {
        return uavpsAlgorithmTaskFormationMapper.selectFormationListByTaskId(taskId);
    }

    @Override
    public String initTaskFormationParams(Long taskId) {
        /*StringBuffer sbf = new StringBuffer();
        sbf.append("BB1401"); //帧头
        if (taskId != null) {
            List<UavpsMultiTargetFormation> list = uavpsAlgorithmTaskFormationMapper.selectFormationListByTaskId(taskId);
            if (list != null && list.size() > 0) {
                sbf.append("01"); //包ID
                sbf.append("00"); //包循环计数
                sbf.append("01"); //目标集群类型
                for (UavpsMultiTargetFormation uavpsMultiTargetFormation : list) {
                    sbf.append(String.format("%02X ", uavpsMultiTargetFormation.getId().toString()));//目标1 ID
                }
            }
        }
        sbf.append("1B");
        return sbf.toString();*/
        String str = "BB 14 03 01 00 01 01 00 D2 57 05 08 B4 18 6D 2F 64 00 0A 00 14 00 0A 00 15 CD 5B 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 44 1B";
        return str;
    }


}
