private List <SqlCommand> DoImportToBom(BomInfo BomInfo, List <BomFormatDetail> ExcelFormatDtls, bool IsTopLevelBom)
        {
            //导入到BOM上,
            //   要不要区分开 T8, Sunlike 不同,做工厂模式? 答:不用区分,使用:DefaultFieldValue
            //   先从 顶->叶  还是 叶->顶生成 Bom?
            //          非顶级的,要看 子BOM是否存在,如果已存在则不用生成子BOM
            //   字段 SYS + DefaultFieldValue + Z
            //          SYS + DefaultFieldValue冲突时 考虑优先级
            //      防呆:如何BOM已存在, BOM 是否本人的?  是否已使用[MRP, MO]
            //      In_NO 要不要计算?
            List <SqlCommand> cmds  = new List <SqlCommand>();
            string            bomNo = BomInfo.bom_no;

            if (bomNo.IsNullOrEmpty())
            {
                throw new Exception("配方号[{0}]为空!".FormatOrg(BomInfo.HeadRow.GetSting("prd_no")));
            }
            bool isNew = Service.GetBom(BomInfo.prd_no, BomInfo.bom_no) == null ? true : false;

            if (IsTopLevelBom == true && isNew == false)
            {
                isNew = true;
                //二次导入时,重构顶级Bom
                cmds.AddRange(removeBom(bomNo));
            }

            //2019-12-25 考虑升级BOM与覆盖BOM
            if (IsTopLevelBom == false && isNew == false)
            {
                if (BomInfo.HeadRow.GetSting("check_ask_radio").IsNotEmpty() &&
                    BomInfo.HeadRow.GetSting("check_ask_radio").GetInt() > 0)
                {
                    //1.覆盖 2.升级BOM版本
                    int bomConflictHandleWay = BomInfo.HeadRow.GetSting("check_ask_radio").GetInt();
                    if (bomConflictHandleWay == 1)
                    {
                        isNew = true;
                        cmds.AddRange(removeBom(bomNo));
                    }
                    else
                    {
                        throw new Exception("BOM冲突未处理!");
                    }
                    //else
                    //{   有问题,如果系统上存在 多个BOM,也会报错
                    //    //升级BOM版本,找出最新的版本号 + 1
                    //    var maxPF_Bom = Service.GetMaxPF_Bom(BomInfo.prd_no);
                    //    int maxPF = maxPF_Bom == null ? 2 : ++maxPF_Bom.pf_no;

                    //}
                }
            }


            List <SqlCommand> thisCmds = new List <SqlCommand>();

            if (isNew == true)
            {
                thisCmds.AddRange(createBomHeaderCmd(bomNo, BomInfo, BomInfo.HeadRow, ExcelFormatDtls));
            }

            foreach (BomInfo item in BomInfo.BodyInfos)
            {
                cmds.AddRange(DoImportToBom(item, ExcelFormatDtls, false));
            }

            if (isNew == true)
            {
                thisCmds.AddRange(createBomBodyCmd(bomNo, BomInfo.BodyRows, ExcelFormatDtls));
            }

            cmds.AddRange(thisCmds);
            return(cmds);
        }