package cn.estsh.i3plus.ext.mes.pcn.api.busi;

import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import io.swagger.annotations.ApiOperation;

import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * 获取生产过程上下文对象接口【BASE】
 */
public interface IMesProductionProcessContextStepService {

    @ApiOperation(value = "清除上下文中的所有基础数据")
    void flushProductionProcessContext(StationRequestBean reqBean);

    @ApiOperation(value = "存储生产过程上下文对象【工步根据业务实际情况执行,配置错误等情况无需执行】")
    Boolean dispatchProductionProcessContext(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext);

    @ApiOperation(value = "获取生产过程上下文对象", notes = "非工步调用传false")
    MesProductionProcessContext getProductionProcessContext(StationRequestBean reqBean, Boolean isCheckProcess);

    @ApiOperation(value = "获取生产过程上下文对象", notes = "工步专用")
    MesProductionProcessContext getProductionProcessContext(StationRequestBean reqBean);

    @ApiOperation(value = "获取工序工艺信息")
    MesProductionProcessContext processContext(StationRequestBean reqBean);

    @ApiOperation(value = "获取工序工艺信息")
    MesProductionProcessContext processContext(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext);

    @ApiOperation(value = "获取生产过程控制全局密码")
    MesProductionProcessContext productionPwdContext(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext);

    @ApiOperation(value = "验证组织模型有效性")
    MesProductionProcessContext checkBaseData(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, Boolean isCheckProcess);

    @ApiOperation(value = "获取工位设备集合信息")
    MesProductionProcessContext getCellEquipmentList(StationRequestBean reqBean);

    @ApiOperation(value = "获取工位设备集合信息")
    MesProductionProcessContext getCellEquipmentList(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext);

    //正常情况下均直接调用以下方法获取上下文
    @ApiOperation(value = "获取工位当前设备信息")
    MesProductionProcessContext dispatchCurCellEquipment(StationRequestBean reqBean);

    @ApiOperation(value = "获取工位当前设备信息")
    MesProductionProcessContext dispatchCurCellEquipment(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext);

    @ApiOperation(value = "获取工位当前设备信息")
    MesProductionProcessContext dispatchCurCellEquipment(StationRequestBean reqBean, Optional<Map<String, MesProdRouteOptParam>> stepParamMap);

    @ApiOperation(value = "获取工位当前设备信息")
    MesProductionProcessContext dispatchCurCellEquipment(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, Optional<Map<String, MesProdRouteOptParam>> stepParamMap);

    @ApiOperation(value = "获取设备数据变量接口逻辑信息")
    MesProductionProcessContext getEquipmentVariableCfgList(StationRequestBean reqBean);

    @ApiOperation(value = "获取设备数据变量接口逻辑信息")
    MesProductionProcessContext getEquipmentVariableCfgList(MesProductionProcessContext productionProcessContext);

    @ApiOperation(value = "根据变量类别搜集设备数据变量接口逻辑信息")
    List<MesEquipmentVariableCfg> collectEquipmentVariableCfgList(List<MesEquipmentVariableCfg> equipmentVariableCfgList, String... variableCategory);

    @ApiOperation(value = "验证设备数据变量接口逻辑信息中是否存在必要的变量类型信息")
    MesProductionProcessContext checkNecessaryEquipmentVariableCfg(MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, List<MesEquipmentVariableCfg> equipmentVariableCfgList, String... variableCategory);

    @ApiOperation(value = "验证设备数据变量接口逻辑信息中是否存在必要的变量类型信息, 并且参考值不能为空")
    MesProductionProcessContext checkNecessaryEquipmentVariableCfgAndValue(MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, List<MesEquipmentVariableCfg> equipmentVariableCfgList, String... variableCategory);

    @ApiOperation(value = "搜集设备数据变量接口逻辑信息中的二级变量")
    List<String> collectCategoryLevelTwoList(List<MesEquipmentVariableCfg> equipmentVariableCfgList);

    @ApiOperation(value = "获取设备数据变量信息")
    MesProductionProcessContext getEquipmentVariableList(StationRequestBean reqBean, Integer variableType);

    @ApiOperation(value = "获取设备数据变量信息")
    MesProductionProcessContext getEquipmentVariableList(MesProductionProcessContext productionProcessContext, Integer variableType);

    @ApiOperation(value = "获取设备数据变量信息")
    List<MesEquipmentVariable> findEquipmentVariableList(MesProductionProcessContext productionProcessContext, Integer variableType);

    @ApiOperation(value = "根据变量类型与二级变量获取设备数据变量信息")
    List<MesEquipmentVariable> findEquipmentVariableList(MesProductionProcessContext productionProcessContext, Integer variableType, List<String> categoryLevelTwoList);

    @ApiOperation(value = "获取设备数据变量信息")
    List<MesEquipmentVariable> findEquipmentVariableList(List<MesEquipmentVariable> equipmentVariableList, Integer variableType, List<String> categoryLevelTwoList);

    @ApiOperation(value = "验证设备数据变量信息是否为空")
    MesProductionProcessContext checkIsEmptyEquipmentVariableList(MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, List<MesEquipmentVariable> equipmentVariableList, MesExtEnumUtil.EQUIP_VARIABLE_TYPE production, List<String> categoryLevelTwoList);

    @ApiOperation(value = "查询工位设备装配件规则信息")
    List<MesProductionAssemblyNosortContext> findAssemblyNosortCfgList(StationRequestBean reqBean);

    @ApiOperation(value = "存储设备的装配件清单")
    Boolean dispatchAssemblyNosortCfgContext(StationRequestBean reqBean, List<MesProductionAssemblyNosortContext> assemblyNosortCfgList);

    @ApiOperation(value = "获取手动选择的腔数及工单信息上下文")
    List<StationKvBean> getFunctionChooseCavityOrderContext(StationRequestBean reqBean);

    @ApiOperation(value = "保存选择/扫描/读取的腔数及工单信息上下文", notes = "[StationKvBean(key=cavity, name=腔数, value=3, seq=0), StationKvBean(key=cellMessageSource, name=工位信息来源, value=10, seq=1), StationKvBean(key=workOrderNo, name=加工单, value=工单1;工单2;工单3, seq=2)]")
    Boolean dispatchFunctionChooseCavityOrderContext(StationRequestBean reqBean, List<StationKvBean> resultList);

    @ApiOperation(value = "删除手动选择的腔数及工单信息上下文")
    void removeFunctionChooseCavityOrderContext(StationRequestBean reqBean);

    @ApiOperation(value = "获取手动选择的腔数及零件信息上下文")
    List<StationKvBean> getFunctionChooseCavityPartContext(StationRequestBean reqBean);

    @ApiOperation(value = "保存选择/扫描/读取的腔数及零件信息上下文", notes = "[StationKvBean(key=cavity, name=腔数, value=3, seq=0), StationKvBean(key=cellMessageSource, name=工位信息来源, value=10, seq=1), StationKvBean(key=workOrderNo, name=零件编码, value=零件1;零件2;零件3, seq=2)]")
    Boolean dispatchFunctionChooseCavityPartContext(StationRequestBean reqBean, List<StationKvBean> resultList);

    @ApiOperation(value = "删除手动选择的腔数及零件信息上下文")
    void removeFunctionChooseCavityPartContext(StationRequestBean reqBean);

    @ApiOperation(value = "获取上下文工位扫描监控信息")
    MesScanMonitorContext dispatchScanMonitorContext(StationRequestBean reqBean, Boolean isSave);

    @ApiOperation(value = "保存上下文工位扫描监控信息", notes = "工序开始时记录雪花ID,工序开始时间等基础信息, 处理基础上下文时赋值设备信息")
    Boolean dispatchScanMonitorContext(StationRequestBean reqBean);

    @ApiOperation(value = "获取上下文工位扫描监控信息")
    MesScanMonitorContext getScanMonitorContext(String organizeCode, String workCenterCode, String workCellCode);

    @ApiOperation(value = "获取上下文工位扫描监控信息的开模记录ID")
    String getScanMonitorContextMouldRecordId(StationRequestBean reqBean);

    @ApiOperation(value = "删除上下文工位扫描监控信息")
    void removeScanMonitorContext(StationRequestBean reqBean);

    @ApiOperation(value = "获取生产线类型")
    Integer getCenterType(StationRequestBean reqBean);

    @ApiOperation(value = "获取生产线下的工位集合")
    Map<String, MesWorkCell> dispatchWorkCellMap(StationRequestBean reqBean);

    @ApiOperation(value = "获取包装规则信息")
    Map<String, MesPackageRuleContext> getPackageRuleContext(StationRequestBean reqBean);

    @ApiOperation(value = "保存包装规则信息")
    Boolean dispatchPackageRuleContext(StationRequestBean reqBean, Map<String, MesPackageRuleContext> packageRuleContextMap);

    @ApiOperation(value = "删除包装规则信息")
    void removePackageRuleContext(StationRequestBean reqBean);

    @ApiOperation(value = "获取设备点检上下文对象")
    MesEquipSpotCheckContext dispatchEquipSpotCheckContext(StationRequestBean reqBean, String equipmentCode);

    @ApiOperation(value = "处理加工不可用规则")
    MesProductionProcessContext dispatchProdRuleIgnoreCfgContext(StationRequestBean reqBean);

    @ApiOperation(value = "处理加工不可用规则")
    MesProductionProcessContext dispatchProdRuleIgnoreCfgContext(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext);

    @ApiOperation(value = "获取加工不可用规则")
    List<MesProdRuleIgnoreCfg> getProdRuleIgnoreCfgContext(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext);

    @ApiOperation(value = "获取加工不可用规则, key = 数据来源&来源ID")
    Map<String, List<MesProdRuleIgnoreCfg>> getProdRuleIgnoreCfgContextMap(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext);

    @ApiOperation(value = "处理排序线推单配置上下文, 返回推送工位类型对应的配置信息")
    List<MesQueueOrderPushCellCfg> dispatchQueueOrderPushCellCfgContext(StationRequestBean reqBean, Integer pushType);

    @ApiOperation(value = "处理工位零件打印机配置")
    List<MesWorkCellPartPrinterCfg> disPatchWorkCellPartPrinterCfg(StationRequestBean reqBean, Boolean pcNosortPrinterCfg);

    @ApiOperation(value = "获取发运RFID生产模式")
    String getShippingRfidRouteModeContext(StationRequestBean reqBean);

    @ApiOperation(value = "处理发运RFID生产模式")
    String disPatchShippingRfidRouteModeContext(StationRequestBean reqBean);

    @ApiOperation(value = "处理切换发运RFID生产模式的标志")
    Boolean disPatchChooseShippingRfidRouteMode(StationRequestBean reqBean);

    @ApiOperation(value = "处理设备站点")
    List<MesStation> dispatchEquipmentStationContext(StationRequestBean reqBean, String equipmentCode);

    @ApiOperation(value = "处理设备站点")
    List<MesStation> dispatchEquipmentStationContext(StationRequestBean reqBean, String equipmentCode, List<Integer> stationTypeList);

}
