Ejemplo n.º 1
0
        private string GetExcelPath(RequiremetMstDto mstDto, string modelType, string quotationType)
        {
            string name    = mstDto.Province + "_" + mstDto.City + "_" + mstDto.ProjectShortName + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_确认单" + suffix;
            string absPath = Server.MapPath(basePath);

            if (!Directory.Exists(absPath))
            {
                Directory.CreateDirectory(absPath);
            }
            string fullName = absPath + name;

            if (modelType == "内部采购")
            {//内部采购  无形商品(其他2)=>wuxingshangpin 有形商品(其他1)=>youxingshangpin
                if (mstDto.RequirementType == "Youxingshangpincaigou")
                {
                    quotationType = "Youxingshangpincaigou";
                }
                if (mstDto.RequirementType == "Wuxingshangpincaigou")
                {
                    quotationType = "Wuxingshangpincaigou";
                }
            }

            string templateFile = Server.MapPath(tempPath + quotationType + suffix);

            System.IO.File.Copy(templateFile, fullName);

            return(fullName);
        }
Ejemplo n.º 2
0
        private List <QuotationDto> QuotationGenSearch(RequiremetMstDto mstDto, string quotationType)
        {
            if (quotationType == "Zhixing")
            {
                return(quotationService.QuotationGenSearch_Zhixing(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>());
            }
            else if (quotationType == "Fuhe")
            {
                return(quotationService.QuotationGenSearch_Fuhe(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>());
            }
            else if (quotationType == "Biancheng")
            {
                return(quotationService.QuotationGenSearch_Biancheng(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>());
            }
            else if (quotationType == "Yanjiu")
            {
                return(quotationService.QuotationGenSearch_Yanjiu(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>());
            }
            else if (quotationType == "Zhichi")
            {
                var lst1 = quotationService.QuotationGenSearch_Zhichi01(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>();
                var lst2 = quotationService.QuotationGenSearch_Zhichi02(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>();

                lst1.AddRange(lst2);
                return(lst1);
            }
            else if (quotationType == "Qita1")
            {
                return(quotationService.QuotationGenSearch_Qita1(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>());
            }
            else if (quotationType == "Qita2")
            {
                return(quotationService.QuotationGenSearch_Qita2(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>());
            }
            else if (quotationType == "Chezhan")
            {
                var lst1 = quotationService.QuotationGenSearch_Chenzhan01(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>();
                var lst2 = quotationService.QuotationGenSearch_Chenzhan02(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>();
                var lst3 = quotationService.QuotationGenSearch_Chenzhan02(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>();

                lst1.AddRange(lst2);
                lst1.AddRange(lst3);
                return(lst1);
            }
            else
            {
                if (mstDto.RequirementType == "Youxingshangpincaigou")
                {
                    return(quotationService.QuotationGenSearch_Qita1(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>());
                }
                else if (mstDto.RequirementType == "Wuxingshangpincaigou")
                {
                    return(quotationService.QuotationGenSearch_Qita2(mstDto.ProjectId, mstDto.SeqNO, mstDto.RequirementType, mstDto.RequirementId).ToList <QuotationDto>());
                }
            }
            return(new List <QuotationDto>());
        }
Ejemplo n.º 3
0
        // GET: QuotationExport
        public ActionResult ExportList(string list, ProjectDto projectDto, string supplierName, string modelType)
        {
            string[] listArry = new string[] { };
            string   result   = "";

            if (list.Length > 0)
            {
                listArry = list.Split(';');
            }

            foreach (string item in listArry)
            {
                string[]         subItems = item.Split(',');
                RequiremetMstDto mstDto   = new RequiremetMstDto()
                {
                    ProjectId        = "",
                    SeqNO            = "",
                    RequirementId    = subItems[0],
                    RequirementType  = subItems[1],
                    Province         = subItems[2],
                    City             = subItems[3],
                    ProjectShortName = subItems[4],
                    Responsibilites  = subItems[5],
                    ModelType        = modelType,
                };
                string quotationType = "";
                respQuotationTypeDic.TryGetValue(mstDto.RequirementType, out quotationType);
                if (typeQuotationDic.ContainsKey(quotationType))
                {
                    List <QuotationDto> value = null;
                    typeQuotationDic.TryGetValue(quotationType, out value);
                    value.AddRange(QuotationGenSearch(mstDto, quotationType));
                }
                else
                {
                    List <QuotationDto> value = new List <QuotationDto>();
                    value.AddRange(QuotationGenSearch(mstDto, quotationType));
                    typeQuotationDic.Add(quotationType, value);
                }
                if (!typePathDic.ContainsKey(quotationType))
                {
                    typePathDic.Add(quotationType, GetExcelPath(mstDto, modelType, quotationType));
                }
            }

            foreach (KeyValuePair <string, List <QuotationDto> > keyValue in typeQuotationDic)
            {
                MethodInfo method = null;
                try
                {
                    string path = "";
                    typePathDic.TryGetValue(keyValue.Key, out path);

                    QuotationExport export = new QuotationExport();

                    method = export.GetType().GetMethod("Export" + keyValue.Key);
                    if (method != null)
                    {
                        method.Invoke(export, new object[] { path, keyValue.Value, projectDto, supplierName });
                    }

                    string fileName = Path.GetFileName(path);
                    result += fileName + "," + path + ";";
                }
                catch (Exception ex)
                {
                    Utils.log(ex.ToString());
                }

                if (method == null)
                {
                    throw new Exception("没有找到该类型的确认单导出方法,请检查确认单类型!");
                }
            }
            if (result.Length > 0)
            {
                result = result.Substring(0, result.Length - 1);
            }
            return(Json(result));
        }