Ejemplo n.º 1
0
        public ActionResult AbnormalPODSearch(AbnormalPODSearchModel model, int?PageIndex)
        {
            if (model.IsExport)
            {
                model.Config = ((Projects)ApplicationConfigHelper.GetApplicationConfig()).ProjectCollection.First(p => p.Id == base.UserInfo.ProjectID.ToString()).ModuleCollection.First(m => m.Id == "M001").Tables.TableCollection.First(t => t.Name == "Pod");
                return(this.GetAbnormalPODSearchToExcel(model));
            }
            else if (model.IsExportTrack)
            {
                return(this.GetAbnormalPODTrackSearchToExcel(model));
            }
            else
            {
                var Result = new AKZOService().GetAbnormalPODSearch(new GetAbnormalPODSearchRequest()
                {
                    SqlWhere = this.GetWhere(model), PageSize = UtilConstants.PAGESIZE, PageIndex = PageIndex ?? 0
                }).Result;
                model.AbnormalTable = Result.AbnormalTable;
                model.PageIndex     = Result.PageIndex;
                model.PageSize      = Result.PageSize;
                model.PageCount     = Result.PageCount;
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult GetAbnormalPODTrackSearchToExcel(AbnormalPODSearchModel model)
        {
            var Result = new AKZOService().GetAbnormalPODTrackSearchToExcel(new GetAbnormalPODSearchRequest()
            {
                SqlWhere = this.GetWhere(model)
            }).Result;

            var columns = ((Projects)ApplicationConfigHelper.GetApplicationConfig()).ProjectCollection.First(p => p.Id == base.UserInfo.ProjectID.ToString()).ModuleCollection.First(m => m.Id == "M001").Tables.TableCollection.First(t => t.Name == "PodTrack")
                          .ColumnCollection.Where(c => (c.IsKey && c.ForView) || (!c.IsKey && !c.IsHide) || (!c.IsKey && c.IsHide && c.InnerColumns.Any(innerc => innerc.CustomerID == _CustomerID)))
                          .Select(c =>
            {
                if (c.InnerColumns.Count == 0)
                {
                    return(c);
                }
                else
                {
                    if (c.InnerColumns.Any(innerc => innerc.CustomerID == _CustomerID))
                    {
                        return(c.InnerColumns.First(innerc => innerc.CustomerID == _CustomerID));
                    }

                    return(c);
                }
            });

            return(this.ExportPodTracksToExcel(Result, columns));



            //var Result = new AKZOService().GetAbnormalPODTrackSearchToExcel(new GetAbnormalPODSearchRequest() { SqlWhere = this.GetWhere(model) }).Result;
            //DataTable Exprottable = Result.AbnormalTable;


            //string ReportName = "POD跟踪异常数据报表" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";

            //ExcelHelper excelHelper = new ExcelHelper();
            //string targetPath = Path.Combine(Runbow.TWS.Common.Constants.UPLOAD_FOLDER_PATH, base.UserInfo.ProjectID.ToString(), "Temp");
            //string fileFullPath = Path.Combine(targetPath, ReportName);
            //excelHelper.CreateExcelByDataTable(fileFullPath, Exprottable);
            //excelHelper.Dispose();

            //string mimeType = "application/msexcel";
            //FileStream fs = MyFile.Open(fileFullPath, FileMode.Open);
            //return File(fs, mimeType, Url.Encode(ReportName));
        }
Ejemplo n.º 3
0
        public ActionResult GetAbnormalPODSearchToExcel(AbnormalPODSearchModel model)
        {
            var podCollection = new AKZOService().GetAbnormalPODSearchToExcel(new GetAbnormalPODSearchRequest()
            {
                SqlWhere = this.GetWhere(model)
            }).Result;

            this.GenQueryAbnormalPODSearchModel(model);
            long?customerID;

            if (model.Customers.Count() == 1)
            {
                customerID = model.Customers.First().Value.ObjectToInt64();
            }
            else
            {
                customerID = model.SearchCondition.CustomerID;
            }

            return(this.ExportPodsToExcel(podCollection, model.Config.ColumnCollection, customerID));
        }
Ejemplo n.º 4
0
        public string UpdateAKZOModelsPodSettledInfo()
        {
            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase;
                if (hpf.ContentLength > 0)
                {
                    DataSet ds = this.GetDataFromExcel(hpf);

                    if (ds != null && ds.Tables[0] != null)
                    {
                        IList <UpdateAKZOModelsPod> pods = new List <UpdateAKZOModelsPod>();
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            pods.Add(new UpdateAKZOModelsPod()
                            {
                                CustomerOrderNumber = ds.Tables[0].Rows[i]["Delivery number"].ToString().Trim(),

                                Models = ds.Tables[0].Rows[i]["Car Models"].ToString().Trim(),
                            });
                        }

                        var groupedPods = from p in pods group p by new { p.CustomerOrderNumber, p.Models } into g select new UpdateAKZOModelsPod()
                        {
                            CustomerOrderNumber = g.Key.CustomerOrderNumber, Models = g.Key.Models
                        };
                        var response = new AKZOService().UpdateAkzoModelsPodAndGetTheDifference(new UpdateAkzoModelsPodAndGetTheDifferenceRequest()
                        {
                            Pods = groupedPods
                        });
                        if (response.IsSuccess)
                        {
                            StringBuilder successSB = new StringBuilder();
                            successSB.Append("<h3>共导入数据").Append(pods.Count).Append("条,合并后数据为").Append(groupedPods.Count()).Append("条.<br/>");
                            if (response.Result.UpdatedPods != null && response.Result.UpdatedPods.Any())
                            {
                                successSB.Append("<h3>下列运单(").Append(response.Result.UpdatedPods.Count()).Append("条)更新成Excel中内容</h3><br/>");
                                successSB.Append("<table><thead><tr><th>").Append("运单号")
                                .Append("</th><th>").Append("车型")
                                .Append("</th></tr></thead><tbody>");
                                foreach (var o in response.Result.UpdatedPods)
                                {
                                    successSB.Append("<tr><td>").Append(o.CustomerOrderNumber)
                                    .Append("</td><td>").Append(o.Models.ToString())
                                    .Append("</td></tr>");
                                }

                                successSB.Append("</tbody></table>");
                            }

                            if (response.Result.NotUpdatedPods != null && response.Result.NotUpdatedPods.Any())
                            {
                                successSB.Append("<h3>下列运单(").Append(response.Result.NotUpdatedPods.Count()).Append("条)没有更新成Excel中内容,系统中无对应运单</h3><br/>");
                                successSB.Append("<table><thead><tr><th>").Append("运单号")
                                .Append("</th><th>").Append("车型")
                                .Append("</th></tr></thead><tbody>");
                                foreach (var o in response.Result.NotUpdatedPods)
                                {
                                    successSB.Append("<tr><td>").Append(o.CustomerOrderNumber)
                                    .Append("</td><td>").Append(o.Models.ToString())
                                    .Append("</td></tr>");
                                }

                                successSB.Append("</tbody></table>");
                            }

                            return(new { result = successSB.ToString(), IsSuccess = true }.ToJsonString());
                        }

                        return(new { result = "数据库存储出错!", IsSuccess = false }.ToJsonString());
                    }

                    return(new { result = "<h3>更新运单失败</h3><br/>excel内容有误!", IsSuccess = false }.ToJsonString());
                }

                return(new { result = "文件内容为空", IsSuccess = false }.ToJsonString());
            }

            return(new { result = "请选择文件", IsSuccess = false }.ToJsonString());
        }
Ejemplo n.º 5
0
        public string UpdateAKZOPodSettledInfo()
        {
            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase;
                if (hpf.ContentLength > 0)
                {
                    DataSet ds = this.GetDataFromExcel(hpf);

                    if (ds != null && ds.Tables[0] != null)
                    {
                        IList <UpdateAKZOPod> pods = new List <UpdateAKZOPod>();
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            pods.Add(new UpdateAKZOPod()
                            {
                                CustomerOrderNumber = ds.Tables[0].Rows[i]["Delivery number"].ToString().Trim(),
                                Weight             = ds.Tables[0].Rows[i]["Gross wght per stage"].ToString().Trim().ObjectToDouble(),
                                TS                 = ds.Tables[0].Rows[i]["QTY per stage"].ToString().Trim().ObjectToDouble(),
                                SS                 = ds.Tables[0].Rows[i]["Volume per stage"].ToString().Trim().ObjectToDouble(),
                                EndCityName        = ds.Tables[0].Rows[i]["City Name"].ToString().Trim(),
                                ActualDeliveryDate = ds.Tables[0].Rows[i]["Calendar day"].ToString().Trim().ObjectToDateTime(),
                                CustomerAccount    = ds.Tables[0].Rows[i]["Customer Account"].ToString().Trim()
                            });
                        }

                        var groupedPods = from p in pods group p by new { p.CustomerOrderNumber, p.ActualDeliveryDate, p.EndCityName, p.CustomerAccount } into g select new UpdateAKZOPod()
                        {
                            CustomerOrderNumber = g.Key.CustomerOrderNumber, Weight = g.Sum(k => k.Weight), TS = g.Sum(k => k.TS), SS = g.Sum(k => k.SS), EndCityName = g.Key.EndCityName, ActualDeliveryDate = g.Key.ActualDeliveryDate, CustomerAccount = g.Key.CustomerAccount
                        };
                        var response = new AKZOService().UpdateAkzoPodAndGetTheDifference(new UpdateAkzoPodAndGetTheDifferenceRequest()
                        {
                            Pods = groupedPods
                        });
                        if (response.IsSuccess)
                        {
                            StringBuilder successSB = new StringBuilder();
                            successSB.Append("<h3>共导入数据").Append(pods.Count).Append("条,合并后数据为").Append(groupedPods.Count()).Append("条.<br/>");
                            if (response.Result.UpdatedPods != null && response.Result.UpdatedPods.Any())
                            {
                                successSB.Append("<h3>下列运单(").Append(response.Result.UpdatedPods.Count()).Append("条)更新成Excel中内容</h3><br/>");
                                successSB.Append("<table><thead><tr><th>").Append("运单号")
                                .Append("</th><th>").Append("实际发货日期")
                                .Append("</th><th>").Append("重量")
                                .Append("</th><th>").Append("桶数")
                                .Append("</th><th>").Append("升数")
                                .Append("</th><th>").Append("客户账号")
                                .Append("</th></tr></thead><tbody>");
                                foreach (var o in response.Result.UpdatedPods)
                                {
                                    successSB.Append("<tr><td>").Append(o.CustomerOrderNumber)
                                    .Append("</td><td>").Append(o.ActualDeliveryDate.DateTimeToString())
                                    .Append("</td><td>").Append(o.Weight.ToString())
                                    .Append("</td><td>").Append(o.TS.ToString())
                                    .Append("</td><td>").Append(o.SS.ToString())
                                    .Append("</td><td>").Append(o.CustomerAccount.ToString())
                                    .Append("</td></tr>");
                                }

                                successSB.Append("</tbody></table>");
                            }

                            if (response.Result.NotUpdatedPods != null && response.Result.NotUpdatedPods.Any())
                            {
                                successSB.Append("<h3>下列运单(").Append(response.Result.NotUpdatedPods.Count()).Append("条)没有更新成Excel中内容,系统中无对应运单</h3><br/>");
                                successSB.Append("<table><thead><tr><th>").Append("运单号")
                                .Append("</th><th>").Append("实际发货日期")
                                .Append("</th><th>").Append("重量")
                                .Append("</th><th>").Append("桶数")
                                .Append("</th><th>").Append("升数")
                                .Append("</th><th>").Append("客户账号")
                                .Append("</th></tr></thead><tbody>");
                                foreach (var o in response.Result.NotUpdatedPods)
                                {
                                    successSB.Append("<tr><td>").Append(o.CustomerOrderNumber)
                                    .Append("</td><td>").Append(o.ActualDeliveryDate.DateTimeToString())
                                    .Append("</td><td>").Append(o.Weight.ToString())
                                    .Append("</td><td>").Append(o.TS.ToString())
                                    .Append("</td><td>").Append(o.SS.ToString())
                                    .Append("</td><td>").Append(o.CustomerAccount.ToString())
                                    .Append("</td></tr>");
                                }

                                successSB.Append("</tbody></table>");
                            }

                            if (response.Result.CityNotMatchPods != null && response.Result.CityNotMatchPods.Any())
                            {
                                successSB.Append("<h3>下列运单(").Append(response.Result.CityNotMatchPods.Count()).Append("条)与系统中运单目的城市不一致</h3><br/>");
                                successSB.Append("<table><thead><tr><th>").Append("运单号")
                                .Append("</th><th>").Append("实际发货日期")
                                .Append("</th><th>").Append("目的城市")
                                .Append("</th></tr></thead><tbody>");
                                foreach (var o in response.Result.CityNotMatchPods)
                                {
                                    successSB.Append("<tr><td>").Append(o.CustomerOrderNumber)
                                    .Append("</td><td>").Append(o.ActualDeliveryDate.DateTimeToString())
                                    .Append("</td><td>").Append(o.EndCityName)
                                    .Append("</td></tr>");
                                }

                                successSB.Append("</tbody></table>");
                            }

                            return(new { result = successSB.ToString(), IsSuccess = true }.ToJsonString());
                        }

                        return(new { result = "数据库存储出错!", IsSuccess = false }.ToJsonString());
                    }

                    return(new { result = "<h3>更新运单失败</h3><br/>excel内容有误!", IsSuccess = false }.ToJsonString());
                }

                return(new { result = "文件内容为空", IsSuccess = false }.ToJsonString());
            }

            return(new { result = "请选择文件", IsSuccess = false }.ToJsonString());
        }