package com.aps.service;

import com.aps.common.util.R;
import com.aps.entity.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 设备日历服务接口
 */
public interface LanuchService {
    
    /**
     * 生成设备日历数据
     *
     * @author: jdt
     * @return 结果
     */
    R<ProdSceneConfig> lanuch( String sceneId, String username);

    /**
     * 生成设备日历数据
     *
     * @author: jdt
     * @return 结果
     */
    R<ProdSceneConfig> copyScene( String oldSceneId, String username,String newSceneId);


    /**
     * 下发场景数据到mes_order
     */

    R<String> exportPlan( String sceneId);

     List<RoutingDetail> getRoutingDetails(Integer routingHeaderId);

     List<RoutingDetail> getRoutingDetails(List<Long> routingHeaderIds);

    List<RoutingDetailEquip> getRoutingDetailEquip(Integer routingHeaderId, String routingCode);

    List<RoutingDetailEquip> getRoutingDetailEquip(List<Long> routingHeaderId);



    ProdProcessExec createProcessExec(ProdLaunchOrder prodOrderMain,
                                      RoutingDetail detail,
                                      String sceneId, List<RoutingDetailEquip> routingDetailEquip,
                                      RoutingHeader routingHeader);

    List<ProdEquipment> batchInsertEquipMent(
            List<RoutingDetailEquip> routingDetailEquips,
            String sceneId,List<ProdProcessExec> processExecList,Boolean isSave,List<Equipinfo> equipinfo);

    List<ProdOrderProcess> createProcessRelations(ProdLaunchOrder prodOrderMain, String sceneId, Map<String, String> routingDetailIdToExecIdMap);



    ProdOrderProcess createProcessRelation(ProdLaunchOrder prodOrderMain,
                                           RoutingDetailConnect connection,
                                           String sceneId,
                                           Map<String, String> routingDetailIdToExecIdMap);

    /**
     * 保存方案：将新创建的订单添加到PROD_LAUNCH_ORDER表
     */
    R<String> savePlan(String sceneId);

    /**
     * 插单功能：向现有场景添加新订单
     * orderId 会在方法内部自动生成 UUID
     * 
     * @param sceneId 场景ID
     * @param orderCode 订单编码
     * @param materialId 物料ID
     * @param startDate 开始时间
     * @param endDate 结束时间
     * @param priority 优先级
     * @param quantity 数量
     * @return 结果
     */
    R<String> insertOrder(String sceneId, String orderCode, String materialId, 
                         LocalDateTime startDate, LocalDateTime endDate, Integer priority, Double quantity);

}