package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;

import cn.estsh.i3plus.ext.mes.pcn.api.busi.IPackageExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.ISxSubassemblyRemadeStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.SxSubassemblyRemadeDetailModel;
import cn.estsh.i3plus.pojo.mes.bean.MesPackage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wangjie
 * @version 1.0
 * @date 2021/1/13 9:28
 **/
@Slf4j
@Service
public class SxSubassemblyRemadePackageNoService extends SxSubassemblyRemadeDispatchService implements ISxSubassemblyRemadeStrategyService {

    @Autowired
    private IPackageExtService packageExtService;

    private static final String SN_TYPE = "包装";

    @Override
    public SxSubassemblyRemadeDetailModel querySubassemblyRemadeSn(String organizeCode, String sn, String workOrderNo, String partNo, String workCenterCode) {

        MesPackage packageDb = packageExtService.getPackageByPackageNo(organizeCode, sn);

        checkPackage(organizeCode, sn, packageDb, SN_TYPE);

        checkPart(organizeCode, sn, packageDb, workOrderNo, partNo, SN_TYPE);

        return packDetail(sn, packageDb, workCenterCode, workOrderNo);
    }

}

