Exemplo n.º 1
0
        public void CreateReport(List <int> ScheduleResult, ObservableCollection <Gantt> GanttTree)
        {
            Excel.Range range = (Excel.Range)ws.Range[ws.Cells[2, 2], ws.Cells[2, 4]];
            range.VerticalAlignment   = Excel.XlVAlign.xlVAlignCenter;
            range.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
            range.Font.Size           = 16;
            ws.Columns[1].ColumnWidth = 1.5;
            ws.Columns[2].ColumnWidth = 7.5;
            ws.Columns[3].ColumnWidth = 65;
            ws.Columns[4].ColumnWidth = 33;
            ws.Columns[5].ColumnWidth = 1.5;
            ws.Columns[6].ColumnWidth = 39;
            range.Merge(Type.Missing);
            ws.Cells[2, 2] = "Результат планирования загрузки Печей";

            int offset = 0;;

            for (int t = 0; t < GanttTree.Count; t++)
            {
                ws.Cells[2][3 + offset] = GanttTree[t].MachineTool;
                offset++;

                G_Nomenclature nom = null;
                for (int n = 0; n < GanttTree[t].Nomenclatures.Count; n++)
                {
                    nom = GanttTree[t].Nomenclatures[n];
                    ws.Cells[3][3 + offset] = $"Партии с номенклатурой {nom.GN_NomenclatureName} (Начало: {nom.GN_Start} - Конец: {nom.GN_End}) обработки";
                    offset++;

                    G_PartiesParametrs pp = null;
                    for (int p = 0; p < nom.PartiesParametrs.Count; p++)
                    {
                        pp = nom.PartiesParametrs[p];
                        ws.Cells[4][3 + offset] = $"Партия {pp.GP_Batch_ID} (Начало: {pp.GP_Start} - Конец: {pp.GP_End})";
                        offset++;
                    }
                }
            }

            ws.Cells[2, 6]            = "Полное время обработки всех партий:";
            ws.Cells[2, 7]            = GanttTree.LastOrDefault().Nomenclatures.LastOrDefault().PartiesParametrs.LastOrDefault().GP_End.ToString().ToString() + " у.е.";
            range                     = (Excel.Range)ws.Range[ws.Cells[2, 6], ws.Cells[2, 7]];
            range.VerticalAlignment   = Excel.XlVAlign.xlVAlignCenter;
            range.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
            range.Font.Size           = 14;
            range.Interior.Color      = ColorTranslator.ToOle(Color.FromArgb(185, 146, 89));

            range = (Excel.Range)ws.Range[ws.Cells[2, 2], ws.Cells[2 + offset, 4]];
            range.Borders.get_Item(Excel.XlBordersIndex.xlEdgeBottom).LineStyle       = Excel.XlLineStyle.xlContinuous;
            range.Borders.get_Item(Excel.XlBordersIndex.xlEdgeRight).LineStyle        = Excel.XlLineStyle.xlContinuous;
            range.Borders.get_Item(Excel.XlBordersIndex.xlEdgeLeft).LineStyle         = Excel.XlLineStyle.xlContinuous;
            range.Borders.get_Item(Excel.XlBordersIndex.xlInsideHorizontal).LineStyle = Excel.XlLineStyle.xlContinuous;
            range.Borders.get_Item(Excel.XlBordersIndex.xlInsideVertical).LineStyle   = Excel.XlLineStyle.xlContinuous;
            range.Borders.get_Item(Excel.XlBordersIndex.xlEdgeTop).LineStyle          = Excel.XlLineStyle.xlContinuous;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Функция заполнения дерева для Диаграммы Гантта
        /// </summary>
        /// <param name="result">Списо ди номенклатур после планирования</param>
        public ObservableCollection <Gantt> CreateGanttTree(List <int> result)
        {
            GanttTree = new ObservableCollection <Gantt>();

            for (int i = 0; i < TimeMap.Count; i++)
            {
                ObservableCollection <G_Nomenclature> G_N = new ObservableCollection <G_Nomenclature>();
                foreach (var nomenclature_id in result)
                {
                    ObservableCollection <G_PartiesParametrs> G_PP = new ObservableCollection <G_PartiesParametrs>();
                    var nName = nomenclatures.FirstOrDefault(n => n.id == nomenclature_id).nomenclature;
                    G_PartiesParametrs LastRec_PP = null;
                    G_PartiesParametrs LastRec_GN = null;

                    if (TimeMap[i][nomenclature_id] == 0)
                    {
                        continue;
                    }
                    else
                    {
                        foreach (var batch in parties.Where(c => c.nomenclature_id == nomenclature_id))
                        {
                            LastRec_PP = G_PP.LastOrDefault();
                            if (LastRec_PP == null)
                            {
                                if (G_N.LastOrDefault() != null)
                                {
                                    LastRec_GN = G_N.LastOrDefault().PartiesParametrs.LastOrDefault();
                                }
                                else if (GanttTree.LastOrDefault() != null)
                                {
                                    if (GanttTree.LastOrDefault().Nomenclatures.FirstOrDefault(n => n.GN_NomenclatureName == nName) != null)
                                    {
                                        LastRec_GN = GanttTree.LastOrDefault().Nomenclatures.FirstOrDefault(n => n.GN_NomenclatureName == nName).PartiesParametrs.FirstOrDefault();
                                    }
                                }
                                LastRec_PP = LastRec_GN;
                            }
                            G_PP.Add(new G_PartiesParametrs
                            {
                                GP_Batch_ID     = batch.id + 1,
                                GP_WorkingHours = TimeMap[i][nomenclature_id],
                                GP_Start        = LastRec_PP == null ? 0 : LastRec_PP.GP_End,
                                GP_LeftMargin   = new System.Windows.Thickness(LastRec_PP == null ? -20 : LastRec_PP.GP_End - 20, 0, 0, 0),
                                GP_End          = LastRec_PP == null ? 0 + TimeMap[i][nomenclature_id] : LastRec_PP.GP_End + TimeMap[i][nomenclature_id]
                            });
                        }
                    }
                    G_N.Add(new G_Nomenclature
                    {
                        GN_NomenclatureName = nName,
                        GN_Start            = LastRec_GN == null ? 0 : LastRec_GN.GP_End,
                        GN_End           = G_PP.LastOrDefault().GP_End,
                        GN_WorkingHours  = G_PP.LastOrDefault().GP_End - (LastRec_GN == null ? 0 : LastRec_GN.GP_End),
                        GN_LeftMargin    = new System.Windows.Thickness(G_PP.FirstOrDefault().GP_Start, 0, 0, 0),
                        PartiesParametrs = G_PP
                    });
                }
                GanttTree.Add(new Gantt
                {
                    MachineTool    = $"Печь {i + 1}",
                    IsNodeExpanded = true,
                    Nomenclatures  = G_N
                });
            }
            return(GanttTree);
        }