package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method;

import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesPackageDataContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesPackageRuleContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
import cn.estsh.i3plus.pojo.mes.bean.MesPackage;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.LinkedList;
import java.util.List;

public interface IMesPackageNoGenerateStepService {

    @ApiOperation(value = "根据包装ID查询包装信息")
    MesPackage getMesPackage(String organizeCode, Long packageId);

    @ApiOperation(value = "强制打包业务处理")
    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = {ImppBusiException.class, Exception.class})
    void doForcePrint(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, List<MesPackageDataContext> packageDataContextList, MesPackage packageDb);

    @ApiOperation(value = "删除包装信息")
    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = {ImppBusiException.class, Exception.class})
    void deletePackageData(StationRequestBean reqBean, MesPackage packageDb, Integer generateType);

    @ApiOperation(value = "修改包装信息的数量")
    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = {ImppBusiException.class, Exception.class})
    void savePackageData(StationRequestBean reqBean, MesPackage packageDb, Double qty);

    @ApiOperation(value = "获取包装规则信息")
    MesPackageRuleContext getPackageRuleContext(StationRequestBean reqBean, StepResult stepResult, String partNo, Boolean isAsyn);

    @ApiOperation(value = "零件打包业务处理")
    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = {ImppBusiException.class, Exception.class})
    void doHandlePackagePart(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesPackageDataContext packageDataContext);

    @ApiOperation(value = "生成包装及明细, 根据标包数量判断是否执行打印")
    List<MesPackageDataContext> doHandlePackagePrint(StationRequestBean reqBean, StepResult stepResult, MesPackageRuleContext packageRuleContext,
                                                     List<MesPackageDataContext> packageDataContextList, LinkedList<String> productSnList, Boolean isAsyn);

    @ApiOperation(value = "进行打印")
    MesProduceSnPrintModel doPrintPackageNo(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesPackageRuleContext packageRuleContext,
                                            MesLabelTemplate labelTemplate, IPrintTemplateStrategyService strategyService, List<MesPackage> packageList, Boolean isAsyn);

    @ApiOperation(value = "生成虚拟条码,零件打包不写包装明细数据, 只是为了适配工步中的方法去递归生成包装条码")
    LinkedList<String> generateVirtualPs(Double qty);

    @ApiOperation(value = "生成一样的虚拟条码, 适配弹框输入工单数量")
    LinkedList<String> generateVirtualPs(Double qty, String productSn);

}
