예제 #1
0
        /// <summary>
        /// 根据预算部门取项目支出预算申报总数、申报总额、有哪些项目及金额饼图
        /// </summary>
        /// <param name="Dept"></param>
        /// <param name="Year"></param>
        /// <returns></returns>
        public object GetinfoByDept2(string Dept, string Year)
        {
            var dicWhereys = new Dictionary <string, object>();

            new CreateCriteria(dicWhereys)
            .Add(ORMRestrictions <string> .Eq("FBudgetDept", Dept))
            .Add(ORMRestrictions <string> .Eq("FYear", Year))
            .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0))
            .Add(ORMRestrictions <string> .Eq("FApproveStatus", "3"))
            .Add(ORMRestrictions <String> .Eq("FMidYearChange", "0"));
            var           budgetMsts      = BudgetMstFacade.Find(dicWhereys).Data;
            Decimal       MstsFProjAmount = 0;
            Decimal       MstsFrozenSum   = 0;
            Decimal       MstsUsedSum     = 0;
            Decimal       MstsFPlayamount = 0;
            List <object> Msts            = new List <object>();

            if (budgetMsts.Count > 0)
            {
                foreach (var budgetMst in budgetMsts)
                {
                    Decimal FProjAmount = budgetMst.FBudgetAmount; //核定预算数
                    Decimal FrozenSum   = 0;                       //冻结数
                    Decimal UsedSum     = 0;                       //已使用数
                    var     dicWhere    = new Dictionary <string, object>();
                    new CreateCriteria(dicWhere).Add(ORMRestrictions <string> .Eq("FProjcode", budgetMst.FProjCode))
                    .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0))
                    .Add(ORMRestrictions <System.Int32> .NotEq("FIfpurchase", 1));  //去除被额度返还的原单据
                    var findedresultmst = base.Find(dicWhere).Data;

                    for (var i = 0; i < findedresultmst.Count; i++)
                    {
                        if (findedresultmst[i].FApprovestatus == "3" || findedresultmst[i].FApprovestatus == "4")
                        {
                            UsedSum += findedresultmst[i].FSurplusamount;
                            UsedSum -= findedresultmst[i].FReturnamount;
                        }
                        else
                        {
                            FrozenSum += findedresultmst[i].FSurplusamount;
                            FrozenSum -= findedresultmst[i].FReturnamount;
                        }
                    }
                    Decimal FPlayamount = FProjAmount - FrozenSum - UsedSum;//可编报数
                    object  Mst         = new
                    {
                        FProjAmount = FProjAmount,
                        FrozenSum   = FrozenSum,
                        UsedSum     = UsedSum,
                        FPlayamount = FPlayamount,
                        data        = budgetMst
                    };
                    MstsFProjAmount += FProjAmount;
                    MstsFrozenSum   += FrozenSum;
                    MstsUsedSum     += UsedSum;
                    MstsFPlayamount += FPlayamount;
                    Msts.Add(Mst);
                }
            }
            object result = new
            {
                Msts            = Msts,
                MstsFProjAmount = MstsFProjAmount,
                MstsFrozenSum   = MstsFrozenSum,
                MstsUsedSum     = MstsUsedSum,
                MstsFPlayamount = MstsFPlayamount,
                Num             = budgetMsts.Count
            };

            return(result);
        }
예제 #2
0
        /// <summary>
        /// 根据预算部门取项目支出预算申报总数、申报总额、有哪些项目及金额饼图
        /// </summary>
        /// <param name="Dept"></param>
        /// <param name="Year"></param>
        /// <returns></returns>
        public object GetinfoByDept(string Dept, string Year)
        {
            var dicWhereys = new Dictionary <string, object>();

            new CreateCriteria(dicWhereys)
            .Add(ORMRestrictions <string> .Eq("FBudgetDept", Dept))
            .Add(ORMRestrictions <string> .Eq("FYear", Year))
            .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0))
            .Add(ORMRestrictions <string> .Eq("FApproveStatus", "3"))
            .Add(ORMRestrictions <String> .Eq("FMidYearChange", "0"));
            var           budgetMsts      = BudgetMstFacade.Find(dicWhereys).Data;
            Decimal       MstsFProjAmount = 0;
            Decimal       MstsFrozenSum   = 0;
            Decimal       MstsUsedSum     = 0;
            Decimal       MstsFPlayamount = 0;
            List <object> Msts            = new List <object>();

            if (budgetMsts != null && budgetMsts.Count > 0)
            {
                //取出所有这些预算对应的用款单据
                List <string>           budList         = budgetMsts.Select(t => t.FProjCode).Distinct().ToList();
                IList <ExpenseMstModel> findedresultmst = new List <ExpenseMstModel>();
                IList <ExpenseDtlModel> expenseDtls     = new List <ExpenseDtlModel>();
                IList <QTSysSetModel>   qTSysSets       = new List <QTSysSetModel>();
                if (budList != null && budList.Count > 0)
                {
                    var dicWhere = new Dictionary <string, object>();
                    new CreateCriteria(dicWhere).Add(ORMRestrictions <List <string> > .In("FProjcode", budList))
                    .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0))
                    .Add(ORMRestrictions <System.Int32> .NotEq("FIfpurchase", 1));  //去除被额度返还的原单据
                    findedresultmst = base.Find(dicWhere).Data;

                    if (findedresultmst != null && findedresultmst.Count > 0)
                    {
                        //所有用款单据的主键
                        List <long> exPhids = findedresultmst.Select(t => t.PhId).Distinct().ToList();
                        if (exPhids != null && exPhids.Count > 0)
                        {
                            expenseDtls = this.ExpenseDtlFacade.Find(t => exPhids.Contains(t.MstPhid)).Data;
                        }
                        //所有用款单据的申报单位
                        List <string> orgList = findedresultmst.Select(t => t.FDeclarationunit).Distinct().ToList();
                        if (orgList != null && orgList.Count > 0)
                        {
                            qTSysSets = this.QTSysSetFacade.Find(t => t.DicType == "ZjlzCode" && orgList.Contains(t.Orgcode)).Data;
                        }
                    }
                }

                foreach (var budgetMst in budgetMsts)
                {
                    if (budgetMst.FProjCode == "2019101.010192")
                    {
                        var ff = 1;
                    }
                    Decimal FProjAmount = budgetMst.FBudgetAmount; //核定预算数
                    Decimal FrozenSum   = 0;                       //冻结数
                    Decimal UsedSum     = 0;                       //已使用数
                    //先去该项目的用款主表数据
                    if (findedresultmst != null && findedresultmst.Count > 0)
                    {
                        var expMsts = findedresultmst.ToList().FindAll(t => t.FProjcode == budgetMst.FProjCode);
                        if (expMsts != null && expMsts.Count > 0)
                        {
                            var mstPhids = expMsts.Select(t => t.PhId).ToList();
                            if (mstPhids != null && mstPhids.Count > 0 && expenseDtls != null && expenseDtls.Count > 0)
                            {
                                var expDtls = expenseDtls.ToList().FindAll(t => mstPhids.Contains(t.MstPhid));
                                if (expDtls != null && expMsts.Count > 0)
                                {
                                    for (var i = 0; i < expDtls.Count; i++)
                                    {
                                        var mst = findedresultmst.ToList().Find(t => t.PhId == expDtls[i].MstPhid);
                                        if (qTSysSets != null && qTSysSets.Count > 0)
                                        {
                                            var set = qTSysSets.ToList().Find(t => t.Orgcode == mst.FDeclarationunit);
                                            if (set != null)
                                            {
                                                if (set.Value == expDtls[i].FPaymentmethod)
                                                {
                                                    if (mst.FApprovestatus == "3" || mst.FApprovestatus == "4")
                                                    {
                                                        UsedSum += expDtls[i].FAmount + expDtls[i].FAmountedit;
                                                        UsedSum -= expDtls[i].FReturnamount;
                                                    }
                                                    else
                                                    {
                                                        FrozenSum += expDtls[i].FAmount + expDtls[i].FAmountedit;
                                                        FrozenSum -= expDtls[i].FReturnamount;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    Decimal FPlayamount = FProjAmount - FrozenSum - UsedSum;//可编报数
                    object  Mst         = new
                    {
                        FProjAmount = FProjAmount,
                        FrozenSum   = FrozenSum,
                        UsedSum     = UsedSum,
                        FPlayamount = FPlayamount,
                        data        = budgetMst
                    };
                    MstsFProjAmount += FProjAmount;
                    MstsFrozenSum   += FrozenSum;
                    MstsUsedSum     += UsedSum;
                    MstsFPlayamount += FPlayamount;
                    Msts.Add(Mst);
                }
            }
            object result = new
            {
                Msts            = Msts,
                MstsFProjAmount = MstsFProjAmount,
                MstsFrozenSum   = MstsFrozenSum,
                MstsUsedSum     = MstsUsedSum,
                MstsFPlayamount = MstsFPlayamount,
                Num             = budgetMsts.Count
            };

            return(result);
        }
예제 #3
0
        /// <summary>
        /// 根据预算主键获取信息
        /// </summary>
        /// <param name="YsPhid"></param>
        /// <returns></returns>
        public object GetinfoByProjCode(long YsPhid)
        {
            //一些必要数据加入中文名
            RichHelpDac    helpdac   = new RichHelpDac();
            BudgetMstModel budgetMst = BudgetMstFacade.Find(YsPhid).Data;

            helpdac.CodeToName <BudgetMstModel>(budgetMst, "FExpenseCategory", "FExpenseCategory_EXName", "GHExpenseCategory");
            string  FExpenseCategory                   = budgetMst.FExpenseCategory; //项目类型
            string  FExpenseCategory_EXName            = budgetMst.FExpenseCategory_EXName;
            Decimal FProjAmount                        = budgetMst.FBudgetAmount;    //核定预算数
            IList <BudgetDtlBudgetDtlModel> budgetDtls = BudgetDtlBudgetDtlFacade.FacadeHelper.FindByForeignKey(YsPhid).Data;

            helpdac.CodeToName <BudgetDtlBudgetDtlModel>(budgetDtls, "FSourceOfFunds", "FSourceOfFunds_EXName", "GHSourceOfFunds", "");
            helpdac.CodeToName <BudgetDtlBudgetDtlModel>(budgetDtls, "FPaymentMethod", "FPaymentMethod_EXName", "GHPaymentMethod", "");
            helpdac.CodeToName <BudgetDtlBudgetDtlModel>(budgetDtls, "FExpensesChannel", "FExpensesChannel_EXName", "GHExpensesChannel", "");
            helpdac.CodeToName <BudgetDtlBudgetDtlModel>(budgetDtls, "FBudgetAccounts", "FBudgetAccounts_EXName", "GHBudgetAccounts", "");
            helpdac.CodeToName <BudgetDtlBudgetDtlModel>(budgetDtls, "FQtZcgnfl", "FQtZcgnfl_EXName", "GHQtZcgnfl", "");

            var dicWhere = new Dictionary <string, object>();

            new CreateCriteria(dicWhere).Add(ORMRestrictions <string> .Eq("FProjcode", budgetMst.FProjCode))
            .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0))
            .Add(ORMRestrictions <System.Int32> .NotEq("FIfpurchase", 1));  //去除被额度返还的原单据
            var findedresultmst = base.Find(dicWhere).Data;

            Decimal FrozenSum = 0; //冻结数
            Decimal UsedSum   = 0; //已使用数

            for (var i = 0; i < findedresultmst.Count; i++)
            {
                if (findedresultmst[i].FApprovestatus == "3" || findedresultmst[i].FApprovestatus == "4")
                {
                    UsedSum += findedresultmst[i].FSurplusamount;
                    UsedSum -= findedresultmst[i].FReturnamount;
                }
                else
                {
                    FrozenSum += findedresultmst[i].FSurplusamount;
                    FrozenSum -= findedresultmst[i].FReturnamount;
                }
            }
            Decimal FPlayamount = FProjAmount - FrozenSum - UsedSum;//可编报数

            Dictionary <string, Decimal> Yskm_Amount = new Dictionary <string, Decimal>();
            List <Decimal> AmountList = new List <Decimal>();

            for (var a = 0; a < budgetDtls.Count; a++)
            {
                if (!Yskm_Amount.ContainsKey(budgetDtls[a].FBudgetAccounts))
                {
                    Yskm_Amount.Add(budgetDtls[a].FBudgetAccounts, budgetDtls[a].FBudgetAmount);
                }
                else
                {
                    Yskm_Amount[budgetDtls[a].FBudgetAccounts] += budgetDtls[a].FBudgetAmount;
                }
            }
            //去除已经做的单据
            var dicWhere2 = new Dictionary <string, object>();

            new CreateCriteria(dicWhere2).Add(ORMRestrictions <string> .Eq("FProjcode", budgetMst.FProjCode))
            .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0))
            .Add(ORMRestrictions <System.Int32> .NotEq("FIfpurchase", 1));
            IList <ExpenseMstModel> ExpenseMstList = ExpenseMstFacade.Find(dicWhere2).Data;

            for (var i = 0; i < ExpenseMstList.Count; i++)
            {
                IList <ExpenseDtlModel> ExpenseDtlList = ExpenseDtlFacade.FindByForeignKey(ExpenseMstList[i].PhId).Data;
                for (var j = 0; j < ExpenseDtlList.Count; j++)
                {
                    if (!string.IsNullOrEmpty(ExpenseDtlList[j].FBudgetaccounts) && Yskm_Amount.ContainsKey(ExpenseDtlList[j].FBudgetaccounts))
                    {
                        Yskm_Amount[ExpenseDtlList[j].FBudgetaccounts] = Yskm_Amount[ExpenseDtlList[j].FBudgetaccounts] - ExpenseDtlList[j].FAmount + ExpenseDtlList[j].FReturnamount;
                    }
                }
            }

            object result = new
            {
                FExpenseCategory        = FExpenseCategory,
                FExpenseCategory_EXName = FExpenseCategory_EXName,
                FProjAmount             = FProjAmount,
                FrozenSum   = FrozenSum,
                UsedSum     = UsedSum,
                FPlayamount = FPlayamount,
                Yskm_Amount = Yskm_Amount,
                budgetDtls  = budgetDtls
            };

            return(result);
        }