Esempio n. 1
0
        /// <summary>
        /// 查询导出
        /// </summary>
        /// <param name="modelType"></param>
        /// <param name="projectCode"></param>
        /// <param name="projectName"></param>
        /// <param name="projectShortName"></param>
        /// <param name="supplierCode"></param>
        /// <param name="supplierName"></param>
        /// <param name="supplierShortName"></param>
        /// <param name="lastChk"></param>
        /// <param name="QuotationGroupId"></param>
        /// <param name="quotationType"></param>
        /// <returns></returns>
        public ActionResult ExportQuotation(string modelType, string projectCode, string projectName, string projectShortName,
                                            string supplierCode, string supplierName, string supplierShortName, string lastChk, string QuotationGroupId, string quotationTypes)
        {
            string zip           = "";
            string absPath       = Server.MapPath(basePath);
            string createFloader = absPath + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "\\";

            if (!Directory.Exists(createFloader))
            {
                Directory.CreateDirectory(createFloader);
            }
            foreach (string type in quotationTypes.Split(','))
            {
                string quotationType    = type;
                List <QuotationDto> lst = new List <QuotationDto>();
                #region ==================竖向的确认单模板 先注释===============================
                //if (quotationType == "Zhixing")
                //{
                //    lst.AddRange(quotationService.Quotation_ZhiXingSearch(modelType, projectCode, projectName, projectShortName,
                //      supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                //}
                //else if (quotationType == "Fuhe")
                //{
                //    lst.AddRange(quotationService.Quotation_FuHeSearch(modelType, projectCode, projectName, projectShortName,
                //      supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                //}
                //else if (quotationType == "Biancheng")
                //{
                //    lst.AddRange(quotationService.Quotation_BianChengSearch(modelType, projectCode, projectName, projectShortName,
                //        supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                //}
                //else if (quotationType == "Yanjiu")
                //{
                //    lst.AddRange(quotationService.Quotation_YanJiuSearch(modelType, projectCode, projectName, projectShortName,
                //        supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                //}
                //else if (quotationType == "Zhichi")
                //{
                //    lst.AddRange(quotationService.Quotation_ZhichiSearch(modelType, projectCode, projectName, projectShortName,
                //        supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                //}
                //else if (quotationType == "Qita1")
                //{
                //    lst.AddRange(quotationService.Quotation_QiTa1Search(modelType, projectCode, projectName, projectShortName,
                //        supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                //}
                //else if (quotationType == "Qita2")
                //{
                //    lst.AddRange(quotationService.Quotation_QiTa2Search(modelType, projectCode, projectName, projectShortName,
                //        supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                //}
                //else if (quotationType == "Chezhan")
                //{
                //    lst.AddRange(quotationService.Quotation_ChezhanSearch(modelType, projectCode, projectName, projectShortName,
                //        supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                //}
                #endregion

                #region ========横向确认单========
                string typeText = "";
                QuotationTypeAndText.TryGetValue(quotationType, out typeText);
                string createFileName = projectShortName + "_" + typeText + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_确认单" + ".xlsx";
                string path           = createFloader + createFileName;
                string templateFile   = "";
                if (modelType == "业务" && (quotationType == "Qita1" || quotationType == "Qita2"))
                {
                    //横向确认单
                    List <QuotationExport_Data_Dto> DataDtoList = quotationService.QuotationExport_DataSearch(modelType, projectCode, projectName, projectShortName,
                                                                                                              supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId, quotationType);
                    List <QuotationExport_Head_Dto> HeaderDtoList = quotationService.QuotationExport_HeadSearch(modelType, projectCode, projectName, projectShortName,
                                                                                                                supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId, quotationType);
                    List <QuotationExport_Left_Dto> LeftDtoList = quotationService.QuotationExport_LeftSearch(modelType, projectCode, projectName, projectShortName,
                                                                                                              supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId, quotationType);

                    templateFile = Server.MapPath(tempPathHor + quotationType + suffix);
                    System.IO.File.Copy(templateFile, path);

                    QuotationHorExport export = new QuotationHorExport();
                    export.ExportQuotationHorQita(path, projectName, projectShortName, projectCode, HeaderDtoList, LeftDtoList, DataDtoList);
                }
                else
                {
                    switch (quotationType)
                    {
                    case "Biancheng":
                    case "Zhixing":
                    case "Fuhe":
                    case "Yanjiu":
                        //横向确认单
                        List <QuotationExport_Data_Dto> DataDtoList = quotationService.QuotationExport_DataSearch(modelType, projectCode, projectName, projectShortName,
                                                                                                                  supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId, quotationType);
                        List <QuotationExport_Head_Dto> HeaderDtoList = quotationService.QuotationExport_HeadSearch(modelType, projectCode, projectName, projectShortName,
                                                                                                                    supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId, quotationType);
                        List <QuotationExport_Left_Dto> LeftDtoList = quotationService.QuotationExport_LeftSearch(modelType, projectCode, projectName, projectShortName,
                                                                                                                  supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId, quotationType);

                        templateFile = Server.MapPath(tempPathHor + quotationType + suffix);
                        System.IO.File.Copy(templateFile, path);

                        if (quotationType == "Qita1" || quotationType == "Qita2")
                        {
                            QuotationHorExport export = new QuotationHorExport();
                            export.ExportQuotationHor(path, projectName, projectShortName, projectCode, HeaderDtoList, LeftDtoList, DataDtoList);
                        }
                        else
                        {
                            QuotationHorExport export = new QuotationHorExport();
                            export.ExportQuotationHor(path, projectName, projectShortName, projectCode, HeaderDtoList, LeftDtoList, DataDtoList);
                        }
                        break;

                    case "Zhichi":
                    case "Chezhan":
                    case "Qita1":
                    case "Qita2":
                        if (quotationType == "Zhichi")
                        {
                            lst.AddRange(quotationService.Quotation_ZhichiSearch(modelType, projectCode, projectName, projectShortName,
                                                                                 supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                        }
                        else if (quotationType == "Qita1")
                        {
                            lst.AddRange(quotationService.Quotation_QiTa1Search(modelType, projectCode, projectName, projectShortName,
                                                                                supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                        }
                        else if (quotationType == "Qita2")
                        {
                            lst.AddRange(quotationService.Quotation_QiTa2Search(modelType, projectCode, projectName, projectShortName,
                                                                                supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                        }
                        else if (quotationType == "Chezhan")
                        {
                            lst.AddRange(quotationService.Quotation_ChezhanSearch(modelType, projectCode, projectName, projectShortName,
                                                                                  supplierCode, supplierName, supplierShortName, lastChk, QuotationGroupId));
                        }

                        if (modelType != "业务")
                        {    //内部采购  无形商品(其他2)=>wuxingshangpin 有形商品(其他1)=>youxingshangpin
                            if (quotationType == "Qita1")
                            {
                                quotationType = "Youxingshangpincaigou";
                            }
                            if (quotationType == "Qita2")
                            {
                                quotationType = "Wuxingshangpincaigou";
                            }
                        }
                        templateFile = Server.MapPath(tempPath + quotationType + suffix);
                        System.IO.File.Copy(templateFile, path);

                        QuotationQueryExport export2 = new QuotationQueryExport();
                        MethodInfo           method  = null;
                        method = export2.GetType().GetMethod("Export" + quotationType);
                        if (method != null)
                        {
                            method.Invoke(export2, new object[] { path, lst, new ProjectDto {
                                                                      ProjectShortName = projectShortName
                                                                  } });
                        }
                        break;

                    default:
                        break;
                    }
                }

                #endregion
            }
            string          zipName  = absPath + projectShortName + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_确认单" + ".zip";
            List <FileInfo> fileList = new List <FileInfo>();

            foreach (string file in Directory.GetFiles(createFloader))
            {
                fileList.Add(new FileInfo(file));
            }
            Compress(fileList, zipName, 9, 100);
            zip = zipName;

            return(Json(new { ExportPath = zip }));
        }