Ejemplo n.º 1
0
        private bool Table644(Resolution resolution)
        {
            IRow row = SearchRowFromMark(sheet, mark.table1, false);

            if (row == null)
            {
                throw new Exception("Не найдена метка первой таблицы");
            }
            table = new MyTools.C_TableExcel(row.RowNum, row.FirstCellNum, Styles.s_RLTB_CC_T10_W);
            table.columns.AddRange(DefCol);

            table.columns.Add(new MyTools.C_ColumnExcel("T", 4, 2));
            table.columns.Add(new MyTools.C_ColumnExcel("Q", 5, 4, 0, 1));
            table.columns.Add(new MyTools.C_ColumnExcel("", 6, 2));
            table.columns.Add(new MyTools.C_ColumnExcel("K", 7, 5));

            BaseCalc_Class calc       = new Calc_644(_sample, obj, resolution);
            var            resultCalc = calc.Calc();

            if (resultCalc == null || resultCalc.Length == 0)
            {
                return(false);
            }
            FormulControl(calc);
            Calc644(calc);
            Summ(table.MaxRowValue, "123, 123(1) постановление РФ №644");

            CreateTable(sheet, table);
            ResizeWidth(sheet, MyTools.ETypeFormatBook.Vertical, table);
            ResizeHeight(sheet, table);
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>Заполнить лист хранилище</summary>
        private void DRAW_THIS()
        {
            PollutionBase_Class.LoadSelectedWells(DateControl_Class.SelectMonth);

            var actualSelectionWells = PollutionBase_Class.ListSelectionWell.Where(x => x.Number > 0).OrderBy(x => x.Number).ToArray();

            foreach (var actialSelectionWell in actualSelectionWells)
            {
                List <KeyValuePair <string, decimal> > Summs = new List <KeyValuePair <string, decimal> >();
                //расчеты
                if (!ColumnOff.Contains(ThisColumn.Summn))
                {
                    Sample  samp = actialSelectionWell.Sample;
                    Objecte obj  = actialSelectionWell.Well.Objecte;
                    KeyValuePair <uint, BaseCalc_Class.Summs>[] summs;
                    Resolution resolution;

                    #region 644
                    resolution = PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains("644"));
                    if (obj.CanResolution(resolution.ID))
                    {
                        calc  = new Calc_644(samp, obj, resolution);
                        summs = calc.Calc();

                        Summs.AddRange(summs.Select(x => new KeyValuePair <string, decimal>("644:", x.Value.SummNDS)));
                    }
                    #endregion

                    #region 621
                    resolution = PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains("621"));
                    if (obj.CanResolution(resolution.ID))
                    {
                        calc  = new Calc_621(samp, obj, resolution);
                        summs = calc.Calc();

                        Summs.AddRange(summs.Select(x => new KeyValuePair <string, decimal>("621:", x.Value.SummNDS)));
                    }
                    #endregion
                }

                Dictionary <string, ValueWork> values = new Dictionary <string, ValueWork>();
                //концентрации
                if (!ColumnOff.Contains(ThisColumn.Pollution))
                {
                    foreach (var pollution in PollutionBase_Class.AllPolutions)
                    {
                        values.Add(pollution.BindName, new ValueWork(pollution.ID, actialSelectionWell.ID));
                    }

                    foreach (var selectionValue in actialSelectionWell.ValueSelections)
                    {
                        values[selectionValue.Pollution.BindName] = new ValueWork(selectionValue.ID);
                    }
                }

                Values.Add(new SHOW(actialSelectionWell, Summs.ToArray(), values.Values.ToArray()));
            }
        }
Ejemplo n.º 3
0
            public calc(uint selectionID)
            {
                sw      = Helpers.LogicHelper.SelectionWellLogic.FirstModel(selectionID);
                client  = Helpers.LogicHelper.ClientsLogic.FirstModel(sw.ClientID);
                objecte = Helpers.LogicHelper.ObjecteLogic.FirstModel(sw.ObjectID);

                calc_621 = new Calc_621(sw.Sample, objecte, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains("621")));
                calc_621.Calc();
                calc_644 = new Calc_644(sw.Sample, objecte, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains("644")));
                calc_644.Calc();
                volume = sw.Sample.Volumes.ToArray();
            }
Ejemplo n.º 4
0
 public bool Calc()
 {
     _644 = new Calc_644(SelectionWell.Sample, SelectionWell.Objecte, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains("644")));
     _644.Calc();
     _621 = new Calc_621(SelectionWell.Sample, SelectionWell.Objecte, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains("621")));
     _621.Calc();
     return(((_644.Answer == null || _644.Answer.Length == 0 ? 0 : _644.Answer.Max(x => x.Value.SummNDS))
             >
             (_621.Answer == null || _621.Answer.Length == 0 ? 0 : _621.Answer.Max(x => x.Value.SummNDS))
         ?
             (_644.Answer == null || _644.Answer.Length == 0 ? 0 : _644.Answer.Max(x => x.Value.SummNDS))
         :
             (_621.Answer == null || _621.Answer.Length == 0 ? 0 : _621.Answer.Max(x => x.Value.SummNDS)))
            > AdditionnTable.GetPeriod.MinLimits);
 }
Ejemplo n.º 5
0
        private void DrawValue()
        {
            var showList      = new List <IThisWell>();
            var defaultValues = getDefaultValues();

            var sample     = selectionWell.Sample;
            var pollutions = Logic.LogicInstances.PollutionLogic.Find();

            var calc = new Calc_644(sample, obj, PollutionBase_Class.AllResolution.First(x => x.CurtName == "644"));

            var middles = pollutions.Select(x => new MiddleValue(x.CurtName, x.Index)).ToArray();

            foreach (var selectionWell in sample.SelectionWells)
            {
                {
                    var selectionWellViewModel = new SelectionWellViewModel(selectionWell.Well.ShortName, defaultValues.ToArray());

                    foreach (var selectionValue in selectionWell.ValueSelections)
                    {
                        selectionWellViewModel.Values[selectionValue.Pollution.Index].Value = selectionValue.Value;
                    }

                    showList.Add(selectionWellViewModel);
                }

                {
                    var declarationViewModel = new NamedValues("Декларация", defaultValues.ToArray());

                    var declaration = selectionWell.Well.Declaration;

                    foreach (var declarationValue in declaration.DeclarationValues)
                    {
                        declarationViewModel.Values[declarationValue.Pollution.Index] = new NamedValue(declarationValue.Pollution.CurtName, declarationValue.Pollution.GetRounded(declarationValue.To));
                    }

                    showList.Add(declarationViewModel);
                }

                {
                    var selectedValues = new NamedValues("Выбран", defaultValues.ToArray());

                    var values = calc.ValueFromResolution(selectionWell.ValueSelections);

                    foreach (var value in values)
                    {
                        var pollutionIndex = value.Pollution.Index;
                        var resultValue    = value.Pollution.GetRounded(value.Value);

                        selectedValues.Values[pollutionIndex].Value = resultValue;
                    }

                    foreach (var middle in middles)
                    {
                        var pollutionIndex = middle.Index;

                        middles[pollutionIndex].AddValue(selectedValues.Values[pollutionIndex]);
                    }

                    showList.Add(selectedValues);
                }
            }

            {
                var middleValues = new NamedValues("Среднее", middles);

                showList.Add(middleValues);
            }

            dgValues.ItemsSource = showList.ToArray();
        }
Ejemplo n.º 6
0
            protected override bool Do()
            {
                summa = 0;
                IRow row = SearchRowFromMark(sheet, "{таблица}", false);

                if (row == null)
                {
                    throw new Exception("Не найдена метка первой таблицы");
                }
                table = new MyTools.C_TableExcel(row.RowNum, row.FirstCellNum, Styles.s_RLTB_CC_T10_W);
                table.columns.Add(new MyTools.C_ColumnExcel("№\nп/п", 0, 1));
                table.columns.Add(new MyTools.C_ColumnExcel("Наименование предприятия", 1, 50));
                table.columns.Add(new MyTools.C_ColumnExcel("ИНН", 2, 10));
                table.columns.Add(new MyTools.C_ColumnExcel("Сумма с\nучётом НДС", 3, 10));
                shows = new List <ThisShow>();
                int sam = 0;

                var samples = Helpers.LogicHelper.SampleLogic.Find(DateControl_Class.SelectMonth, 1);

                samples = samples.Where(x => x.SelectionWells.Any()).ToArray();
                var count = samples.Count();

                foreach (var sample in samples)
                {
                    Action(count, ++sam);

                    var sw = sample.SelectionWells.First();

                    Client  client = sw.Objecte.Client;
                    Objecte obj    = client.Objects.First(x => x.ID == sw.ObjectID);
                    switch (name)
                    {
                    case "621":
                    {
                        calc = new Calc_621(sample, obj, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains(name)));
                        break;
                    }

                    case "644":
                    {
                        calc = new Calc_644(sample, obj, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains(name)));
                        break;
                    }
                    }
                    calc.Calc();
                    if (calc.Answer == null || calc.Answer.Sum(x => x.Value.SummNDS) < AdditionnTable.GetPeriod.MinLimits)
                    {
                        continue;
                    }
                    shows.Add(new ThisShow(client.Detail.FullName, client.INN, calc.Answer.Sum(x => x.Value.SummNDS), obj.OrderDistrict));
                }
                int index = 0;

                if (shows.Count == 0)
                {
                    MessageBox.Show("Не найдены превышения!");
                    return(false);
                }
                //shows = shows.OrderBy(x => x.Order).ThenByDescending(x => x.Summa).ToList();
                shows = shows.OrderByDescending(x => x.Summa).ToList();
                foreach (var one in shows)
                {
                    table.value.Add(new MyTools.C_ValueCell(index + 1, index, 0, style: Styles.s_RLTB_RC_T10_W));
                    table.value.Add(new MyTools.C_ValueCell(one.Name.StringDivision(70), index, 1, style: Styles.s_RLTB_LC_T10_W));
                    table.value.Add(new MyTools.C_ValueCell(one.INN, index, 2, style: Styles.s_RLTB_LC_T10_W));
                    table.value.Add(new MyTools.C_ValueCell(one.Summa.ToMoney(), index, 3, style: Styles.s_RLTB_RC_T10_W));
                    summa += one.Summa;
                    index++;
                }
                CreateTable(sheet, table);
                ResizeWidth(sheet, MyTools.ETypeFormatBook.Vertical, table);
                ResizeHeight(sheet, table);
                return(true);
            }
Ejemplo n.º 7
0
        private void DrawValue()
        {
            var showList = new List<IThisWell>();

            var pollutions = Helpers.LogicHelper.PollutionLogic.Find();
            var defaultValues = getDefaultValues();
            var values = pollutions.Select(x => new MiddleValue(x.CurtName)).ToArray();

            {
                var calc = new Calc_644(_values, obj, PollutionBase_Class.AllResolution.First(x => x.CurtName == "644"));

                var sample = selectionWell.Sample;

                foreach (var selectionWell in sample.SelectionWells)
                {
                    {
                        var selectionWellViewModel = new ThisWell(selectionWell, pollutions.Select(x => new SelectionValueInternal(selectionWell, x)).ToArray());

                        foreach (var selectionValue in selectionWell.ValueSelections)
                        {
                            var pollutionIndex = selectionValue.Pollution.Index;

                            selectionWellViewModel.Values[pollutionIndex] = new SelectionValueInternal(selectionValue);
                        }

                        showList.Add(selectionWellViewModel);
                    }

                    {
                        var declaration = selectionWell.Well.Declaration;
                        var declarationViewModel = new ThisCalc("Декларация", pollutions.Select(x => new DeclarationValueInternal(declaration, x)).ToArray());

                        if (declaration != null)
                        {

                            foreach (var declarationValue in declaration.DeclarationValues)
                            {
                                if (declarationValue.PollutionID > 0)
                                {
                                    declarationViewModel.Values[declarationValue.Pollution.Index] = new DeclarationValueInternal(declarationValue);
                                }
                            }
                        }

                        showList.Add(declarationViewModel);
                    }

                    {
                        var selectionViewModel = new ThisCalc("Выбран", defaultValues.ToArray());

                        foreach (var selectionValue in calc.ValueFromResolution(selectionWell.ValueSelections))
                        {
                            var pollutionIndex = selectionValue.Pollution.Index;
                            var value = Math.Round(selectionValue.Value, selectionValue.Pollution.Round);

                            selectionViewModel.Values[pollutionIndex] = new ValueCalc(selectionValue.Pollution.CurtName, value);
                            values[pollutionIndex].Add(value);
                        }

                        showList.Add(selectionViewModel);
                    }
                }
            }

            {
                var middleViewModel = new ThisCalc("Среднее", values);

                showList.Add(middleViewModel);
            }


            dgValues.ItemsSource = showList.ToArray();
        }
Ejemplo n.º 8
0
        private bool LoadTable()
        {
            if (!LoadBase())
            {
                return(false);
            }

            loadData();

            LoadCap();

            int indexRow = 0;

            var pollutions = new Dictionary <Pollution, int>();

            {   //делаю список показателей
                var prePollutions = new HashSet <Pollution>();

                foreach (var selectionWell in _selectionWells)
                {
                    foreach (var selectionValue in selectionWell.ValueSelections)
                    {
                        if (!prePollutions.Contains(selectionValue.Pollution))
                        {
                            prePollutions.Add(selectionValue.Pollution);
                        }
                    }
                }

                int index = 0;
                pollutions = prePollutions.ToDictionary(x => x, x => index++);
            }

            foreach (var selectionWell in _selectionWells)
            {
                foreach (var selectionValue in selectionWell.ValueSelections)
                {
                }

                if (ShowNorms)
                {
                }
                if (ShowCalcs)
                {
                }
            }

            foreach (var one in values.GroupBy(x => x.Pollution).OrderBy(x => x.Key.Number).ToArray())
            {
                table.value.Add(new MyTools.C_ValueCell(indexRow + 1, indexRow + 2, 0));
                table.value.Add(new MyTools.C_ValueCell(MyTools.TextToUpper(one.Key.FullName).SymbolConverter(), indexRow + 2, 1));
                normPage normPage = null;
                if (ShowNorms)
                {
                    normPage = LoadNorm(one.Key, one.First().SelectionWell.Well, indexRow);
                }
                foreach (var sw in one.OrderBy(x => x.SelectionWell.Number).ThenBy(x => x.SelectionWell.YMDHM).GroupBy(x => MyTools.YM_From_YMDHM(x.SelectionWell.YMDHM)).ToArray())
                {
                    string value = string.Empty;
                    foreach (var val in sw)
                    {
                        value += $"{val.ValueRound}\n";
                    }
                    ICellStyle style = null;
                    if (normPage != null)
                    {
                        style = normPage.Verify(sw.Sum(x => x.ValueRound) / sw.Count());
                    }
                    table.value.Add(new MyTools.C_ValueCell(value.Trim('\n'), indexRow + 2, sw.Key - StartYM + 2, style: style));
                }
                table.value.Add(new MyTools.C_ValueCell(Math.Round(one.Sum(x => x.Value) / one.Count(), one.Key.Round, MidpointRounding.AwayFromZero), indexRow + 2, MonthCount + 2));
                indexRow++;
            }
            LoadVolume();
            for (int i = 2; i < 2 + MonthCount; i++)
            {
                for (int j = 2; j < indexRow + 2; j++)
                {
                    if (table.value.Find(x => x.row == j && x.col == i) == null)
                    {
                        table.value.Add(new MyTools.C_ValueCell('-', j, i));
                    }
                }
            }
            if (ShowCalcs)
            {
                indexRow += 2;
                table.value.Add(new MyTools.C_ValueCell("Расчёт 621-П", 1 + indexRow, 1));
                table.value.Add(new MyTools.C_ValueCell("Расчёт 644", 2 + indexRow, 1));
                foreach (var one in values.GroupBy(x => MyTools.YM_From_YMDHM(x.SelectionWell.YMDHM)).ToArray())
                {
                    Calc_621 calc_621 = new Calc_621(Helpers.LogicHelper.SampleLogic.FirstModel(one.First().SampleID), this._selectionWell.Objecte, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains("621")));
                    calc_621.Calc();
                    table.value.Add(new MyTools.C_ValueCell(calc_621.Answer != null ? calc_621.Answer.Sum(x => x.Value.SummNDS).ToMoney() : "", 1 + indexRow, one.Key - StartYM + 2, style: style[0]));

                    Calc_644 calc_644 = new Calc_644(Helpers.LogicHelper.SampleLogic.FirstModel(one.First().SampleID), this._selectionWell.Objecte, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains("644")));
                    calc_644.Calc();
                    table.value.Add(new MyTools.C_ValueCell(calc_644.Answer != null ? calc_644.Answer.Sum(x => x.Value.SummNDS).ToMoney() : "", 2 + indexRow, one.Key - StartYM + 2, style: style[1]));
                }
                for (int i = 0; i < MonthCount; i++)
                {
                    if (table.value.Find(x => x.col == i + 2 && x.row == indexRow + 1) == null)
                    {
                        table.value.Add(new MyTools.C_ValueCell("", 1 + indexRow, i + 2, style: style[0]));
                    }
                    if (table.value.Find(x => x.col == i + 2 && x.row == indexRow + 2) == null)
                    {
                        table.value.Add(new MyTools.C_ValueCell("", 2 + indexRow, i + 2, style: style[1]));
                    }
                }
            }
            CreateTable(sheet, table);
            ResizeWidth(sheet, MonthCount > 6 ? MyTools.ETypeFormatBook.Horizontal : MyTools.ETypeFormatBook.Vertical, table);
            ResizeHeight(sheet, table);
            return(true);
        }