Esempio n. 1
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="counter"></param>
        /// <param name="TargetIDs"></param>
        /// <returns></returns>
        private List <MonthlyReportDetail> Calclatedata(VCounter counter, List <Guid> TargetIDs, ref List <MonthlyReportDetail> Source)
        {
            List <Guid> Companys = new List <Guid>();

            List <Guid> targets = new List <Guid>();

            List <MonthlyReportDetail> Result = new List <MonthlyReportDetail>();
            List <MonthlyReportDetail> Filter = new List <MonthlyReportDetail>();

            foreach (MonthlyReportDetail d in Source)
            {
                if (TargetIDs.Contains(d.TargetID)) //上月指标包含当前指标
                {
                    d.TargetGroupCount = 1;
                    Filter.Add(d); //添加

                    Hashtable        bizContext = BizContextEngine.BizContextService.GetBizContext(Source.FindAll(R => R.TargetID == d.TargetID), "A_MonthlyReportDetail");
                    ExpressionParser _parser    = new ExpressionParser(bizContext);

                    //解析这个公式
                    //一个公司多个指标数据属于同一个Group
                    //其中任何一个指标数据满足Counter的条件,此公司的数据都应该归类于该Counter

                    if (_parser.CacluateCondition(counter.Expression))
                    {
                        if (!targets.Contains(d.TargetID))
                        {
                            targets.Add(d.TargetID);
                        }
                    }
                }
            }


            foreach (Guid itemtarget in targets)
            {
                //将筛选出来的值,添加到结果后,马上移除
                Result.AddRange(Filter.FindAll(R => R.TargetID == itemtarget)); ///

                //从总数据中移除已经分类的数据
                Source.RemoveAll(Re => Result.Exists(R => R.ID == Re.ID));
            }

            List <MonthlyReportDetail> returnList = SequenceEngine.SequenceService.GetSequence(_System.ID, "Return", Result, JsonHelper.Serialize(TargetIDs));

            return(returnList);
        }
        /// <summary>
        /// 分组数据
        /// </summary>
        /// <param name="Group">分组条件</param>
        /// <param name="XmlType">补回情况/未完成说明</param>
        /// <returns></returns>
        List <DictionaryVmodel> FormartCounterData(VCounter counter, VGroup Group, string XmlType, string GroupStr, ref List <MonthlyReportDetail> Source)
        {
            List <DictionaryVmodel> result = new List <DictionaryVmodel>();

            List <MonthlyReportDetail> tempList = CalclateMissTargetdata(counter, Group.TargetIDs);

            string TitleName = MonthDescriptionTools(counter.Title, Group.TargetIDs, counter.Expression, tempList);

            DictionaryVmodel dictM = new DictionaryVmodel(TitleName, tempList);

            dictM.Mark             = "Data";
            dictM.GuoupID          = GroupStr;
            dictM.TargetGroupCount = Group.TargetIDs.Count();
            dictM.SystemName       = _System.SystemName;
            dictM.Value            = counter.Senquence.ToString();
            result.Add(dictM);

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 分组数据
        /// </summary>
        /// <param name="Group">分组条件</param>
        /// <param name="XmlType">补回情况/未完成说明</param>
        /// <returns></returns>
        List <DictionaryVmodel> FormartCounterData(VCounter counter, VGroup Group, string XmlType, string GroupStr, ref List <MonthlyReportDetail> Source)
        {
            List <DictionaryVmodel> result = new List <DictionaryVmodel>();

            if (counter.SubCounterList != null && counter.SubCounterList.Count > 0)
            {
                List <MonthlyReportDetail> subSource = Calclatedata(counter, Group.TargetIDs, ref Source);

                foreach (VCounter c in counter.SubCounterList)
                {
                    if (c.SubCounterList != null && c.SubCounterList.Count > 0)
                    {
                        DictionaryVmodel dictC = new DictionaryVmodel(c.Title, FormartCounterData(c, Group, XmlType, GroupStr, ref subSource));
                        dictC.Mark             = "Counter";
                        dictC.GuoupID          = GroupStr;
                        dictC.TargetGroupCount = 1;
                        dictC.SystemName       = _System.SystemName;
                        result.Add(dictC);
                    }
                    else
                    {
                        result.AddRange(FormartCounterData(c, Group, XmlType, GroupStr, ref subSource));
                    }
                }
            }
            else
            {
                DictionaryVmodel dictR = new DictionaryVmodel(counter.Title, Calclatedata(counter, Group.TargetIDs, ref Source));
                dictR.Mark             = "Data";
                dictR.GuoupID          = GroupStr;
                dictR.TargetGroupCount = 1;
                dictR.SystemName       = _System.SystemName;
                result.Add(dictR);
            }
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="counter"></param>
        /// <param name="TargetIDs"></param>
        /// <returns></returns>
        private List <MonthlyReportDetail> Calclatedata(VCounter counter, List <Guid> TargetIDs, ref List <MonthlyReportDetail> Source)
        {
            List <Guid> Companys = new List <Guid>();

            List <MonthlyReportDetail> Result = new List <MonthlyReportDetail>();
            List <MonthlyReportDetail> Filter = new List <MonthlyReportDetail>();

            foreach (MonthlyReportDetail d in Source)
            {
                if (TargetIDs.Contains(d.TargetID)) //上月指标包含当前指标
                {
                    d.TargetGroupCount = TargetIDs.Count();
                    Filter.Add(d); //添加

                    Hashtable        bizContext = BizContextEngine.BizContextService.GetBizContext(Source.FindAll(R => R.CompanyID == d.CompanyID), "A_MonthlyReportDetail");
                    ExpressionParser _parser    = new ExpressionParser(bizContext);

                    //解析这个公式
                    //一个公司多个指标数据属于同一个Group
                    //其中任何一个指标数据满足Counter的条件,此公司的数据都应该归类于该Counter
                    if (_parser.CacluateCondition(counter.Expression))
                    {
                        if (!Companys.Contains(d.CompanyID))
                        {
                            Companys.Add(d.CompanyID);
                        }
                    }
                }
            }

            foreach (Guid CompanyID in Companys)
            {
                //判断当前公司的数量,是否相同
                if (Filter.Where(r => r.CompanyID == CompanyID).Count() == TargetIDs.Count())
                {
                    //将筛选出来的值,添加到结果后,马上移除
                    Result.AddRange(Filter.FindAll(R => R.CompanyID == CompanyID)); ///
                }
                else
                {
                    //xml定义的指标数比数据库里的指标多
                    int rowCount = TargetIDs.Count() - Filter.Where(r => r.CompanyID == CompanyID).Count();

                    MonthlyReportDetail model = Filter.Where(p => p.CompanyID == CompanyID).FirstOrDefault();

                    List <MonthlyReportDetail> NewDetail = new List <MonthlyReportDetail>();

                    //根据相差指标数目,补齐这些数据
                    for (int i = 0; i < rowCount; i++)
                    {
                        NewDetail.Add(new MonthlyReportDetail()
                        {
                            GroupTile  = model.GroupTile, TargetGroupCount = model.TargetGroupCount,
                            Title      = model.Title, CompanyName = model.CompanyName,
                            CompanyID  = model.CompanyID, TargetID = model.TargetID,      //
                            ReturnType = model.ReturnType, Counter = 0,
                            NAccumulativeActualAmmount = 0, NAccumulativeDifference = 0,
                            AddDifference = 0, NAccumulativePlanAmmount = 0,
                            LastNAccumulativeActualAmmount = 0, LastNAccumulativeDifference = 0,
                            LastNAccumulativePlanAmmount   = 0, TargetName = "--",
                            SystemID = model.SystemID, CreateTime = model.CreateTime
                        });
                    }

                    //将筛选出来的值,添加到结果后,马上移除
                    Result.AddRange(Filter.FindAll(R => R.CompanyID == CompanyID));
                    Result.AddRange(NewDetail);
                }

                //从总数据中移除已经分类的数据
                Source.RemoveAll(Re => Result.Exists(R => R.ID == Re.ID));
            }

            List <MonthlyReportDetail> returnList = SequenceEngine.SequenceService.GetSequence(_System.ID, "Return", Result, JsonHelper.Serialize(TargetIDs));

            return(returnList);
        }
        /// <summary>
        /// 未完成说明
        /// </summary>
        /// <param name="counter"></param>
        /// <param name="TargetIDs"></param>
        /// <returns></returns>
        private List <MonthlyReportDetail> CalclateMissTargetdata(VCounter counter, List <Guid> TargetIDs)
        {
            // List<Guid> Companys = new List<Guid>();

            Hashtable CompanyHt = new Hashtable();

            List <MonthlyReportDetail> Result = new List <MonthlyReportDetail>();
            List <MonthlyReportDetail> Filter = new List <MonthlyReportDetail>();

            foreach (MonthlyReportDetail d in MissTargetList)
            {
                if (TargetIDs.Contains(d.TargetID)) //上月指标包含当前指标
                {
                    d.TargetGroupCount = TargetIDs.Count();
                    Filter.Add(d); //添加

                    Hashtable        bizContext = BizContextEngine.BizContextService.GetBizContext(MissTargetList.FindAll(R => R.CompanyID == d.CompanyID), "A_MonthlyReportDetail");
                    ExpressionParser _parser    = new ExpressionParser(bizContext);

                    //解析这个公式
                    //一个公司多个指标数据属于同一个Group
                    //其中任何一个指标数据满足Counter的条件,此公司的数据都应该归类于该Counter
                    if (_parser.CacluateCondition(counter.Expression))
                    {
                        //if (!Companys.Contains(d.CompanyID))
                        //{
                        //    Companys.Add(d.CompanyID);
                        //}

                        if (!CompanyHt.ContainsKey(d.CompanyID))
                        {
                            CompanyHt.Add(d.CompanyID, counter.TextExpression);
                        }
                    }
                }
            }


            foreach (Guid CompanyID in CompanyHt.Keys)
            {
                //判断当前公司的数量
                if (Filter.Where(r => r.CompanyID == CompanyID).Count() == TargetIDs.Count())
                {
                    //将筛选出来的值,添加到结果后,马上移除
                    Result.AddRange(Filter.FindAll(R => R.CompanyID == CompanyID));

                    if (CompanyHt[CompanyID].ToString() == "Return") // 针对的是补回项的数据,如果是补回数据,则未完成原因和采取措施清空 by dubiao 2015/4/15
                    {
                        foreach (var item in Result)
                        {
                            item.MIssTargetReason      = "";
                            item.MIssTargetDescription = "";
                        }
                    }
                }
                else
                {
                    //xml定义的指标数比数据库里的指标多
                    int rowCount = TargetIDs.Count() - Filter.Where(r => r.CompanyID == CompanyID).Count();

                    MonthlyReportDetail model = Filter.Where(p => p.CompanyID == CompanyID).FirstOrDefault();

                    List <MonthlyReportDetail> NewDetail = new List <MonthlyReportDetail>();

                    //根据相差指标数目,补齐这些数据
                    for (int i = 0; i < rowCount; i++)
                    {
                        NewDetail.Add(new MonthlyReportDetail()
                        {
                            GroupTile                      = model.GroupTile,
                            TargetGroupCount               = model.TargetGroupCount,
                            Title                          = model.Title,
                            CompanyName                    = model.CompanyName,
                            CompanyID                      = model.CompanyID,
                            TargetID                       = Guid.Empty,
                            ReturnType                     = 0,
                            Counter                        = 0,
                            NAccumulativeActualAmmount     = 0,
                            NAccumulativeDifference        = 0,
                            AddDifference                  = 0,
                            NAccumulativePlanAmmount       = 0,
                            LastNAccumulativeActualAmmount = 0,
                            LastNAccumulativeDifference    = 0,
                            LastNAccumulativePlanAmmount   = 0,
                            TargetName                     = "--",
                            SystemID                       = model.SystemID,
                            ReturnDescription              = "",
                            MIssTargetDescription          = "",
                            MIssTargetReason               = ""
                        });
                    }

                    Result.AddRange(Filter.FindAll(R => R.CompanyID == CompanyID));
                    Result.AddRange(NewDetail);
                }

                //从Group的总数据中移除已经分类的数据
                MissTargetList.RemoveAll(Re => Result.Exists(R => R.ID == Re.ID));
            }


            List <MonthlyReportDetail> ResultTempSum = new List <MonthlyReportDetail>();

            //SystemEngine 对商管做了特殊处理,其它系统直接调用排序的Engine
            object NewModel = SystemEngine.SystemEngineService.GetSystem(Result, _System.ID, TargetIDs);

            ResultTempSum = (List <MonthlyReportDetail>)NewModel;



            #region  这里只有项目系统需要单独处理,其它系统都是需要合并的
            //if (_System.GroupType != "ProSystem")
            //{
            //    //未完成说明的合并
            //    for (int i = TargetIDs.Count; i <= ResultTempSum.Count; i = i + TargetIDs.Count)
            //    {
            //        if (TargetIDs.Count > 1)
            //        {
            //            string StrDescription = ResultTempSum[i - TargetIDs.Count].MIssTargetDescription;

            //            string SrtReason = ResultTempSum[i - TargetIDs.Count].MIssTargetReason;

            //            for (int j = 1; j < TargetIDs.Count; j++)
            //            {
            //                StrDescription = StrDescription + ResultTempSum[i - j].MIssTargetDescription; ;

            //                SrtReason = SrtReason + ResultTempSum[i - j].MIssTargetReason;
            //            }

            //            ResultTempSum[i - TargetIDs.Count].MIssTargetDescription = StrDescription;

            //            ResultTempSum[i - TargetIDs.Count].MIssTargetReason = SrtReason;
            //        }
            //    }
            //}
            # endregion

            return(ResultTempSum);