public List <DSTargetReturnDataCompany> GetDSTargetAddMissDataList(int Year, int Month, bool IsLatestVersion) { List <DSTargetReturnDataCompany> Showlist = new List <DSTargetReturnDataCompany>(); C_System SystemModel = C_SystemOperator.Instance.GetSystem(SysDescriptionID); if (SystemModel != null) { List <C_Target> TargetList = C_TargetOperator.Instance.GetTargetList(SystemModel.ID, DateTime.Now).Where(t => t.NeedReport == true && t.TargetName != "总部管理费用").ToList(); //上一个月以及当前月的信息 ReportInstance LastMonthReport = new ReportInstance(); List <MonthlyReportDetail> LastMonthReportDetails = null; if (Month > 1) { LastMonthReport = new ReportInstance(SystemModel.ID, Year, Month - 1, IsLatestVersion); LastMonthReportDetails = LastMonthReport.ReportDetails; } ReportInstance CurrentMonthReport = new ReportInstance(SystemModel.ID, Year, Month, IsLatestVersion); List <MonthlyReportDetail> CurrentMonthReportDetails = CurrentMonthReport.ReportDetails; //新建百货系统新增经营指标未完成情况的集合 int i = 1; foreach (C_Target titem in TargetList.OrderBy(t => t.Sequence)) { List <C_Company> CompanyList = new List <C_Company>(); if (Month == 1) { CompanyList = C_CompanyOperator.Instance.GetCompanyListBySystemIDAndTargetID(Year, Month, SystemModel.ID, 1, titem.ID, IsLatestVersion).ToList(); } else { List <C_Company> LastCompanyList = C_CompanyOperator.Instance.GetCompanyListBySystemIDAndTargetID(Year, Month - 1, SystemModel.ID, 0, titem.ID, IsLatestVersion).ToList(); List <C_Company> CurrentCompanyList = C_CompanyOperator.Instance.GetCompanyListBySystemIDAndTargetID(Year, Month, SystemModel.ID, 1, titem.ID, IsLatestVersion).ToList(); foreach (C_Company cc in LastCompanyList) { C_Company cModel = CurrentCompanyList.SingleOrDefault(t => t.ID == cc.ID); if (cModel != null && cModel.ID != Guid.Empty) { CompanyList.Add(cModel); } } } #region 添加公司 if (CompanyList != null && CompanyList.Count > 0) { foreach (C_Company c in CompanyList) { DSTargetReturnDataCompany DSCompany = new DSTargetReturnDataCompany(); DSCompany.ID = i; DSCompany.CompanyName = c.CompanyName; DSCompany.AddTargetName = titem.TargetName; List <DSTargetReturnData> dataList = new List <DSTargetReturnData>(); #region 根据指标 foreach (C_Target ct in TargetList.OrderBy(t => t.Sequence)) { DSTargetReturnData DSReturnData = new DSTargetReturnData(); DSReturnData.CompanyID = i; DSReturnData.ReturnTargetName = ct.TargetName; MonthlyReportDetail LastDetail = null; if (Month == 1) { LastDetail = GetMonthlyReportDetail(c, LastMonthReportDetails, CurrentMonthReportDetails, ct, true); } else { LastDetail = GetMonthlyReportDetail(c, LastMonthReportDetails, CurrentMonthReportDetails, ct, false); } if (LastDetail != null && LastDetail.ID != Guid.Empty) { DSReturnData.LastAccumulativePlan = Convert.ToDecimal(LastDetail.NAccumulativePlanAmmount.ToString("N2")); DSReturnData.LastAccumulativeActual = Convert.ToDecimal(LastDetail.NAccumulativeActualAmmount.ToString("N2")); DSReturnData.LastAccumulativeDifference = Convert.ToDecimal((LastDetail.NAccumulativeDifference).ToString("N2")); } MonthlyReportDetail CurrentDetail = GetMonthlyReportDetail(c, LastMonthReportDetails, CurrentMonthReportDetails, ct, true); if (CurrentDetail != null && CurrentDetail.ID != Guid.Empty) { DSReturnData.CurrentReturnAmount = Convert.ToDecimal((CurrentDetail.NAccumulativeDifference - LastDetail.NAccumulativeDifference).ToString("N2")); DSReturnData.CurrentAccumulativePlan = Convert.ToDecimal(CurrentDetail.NAccumulativePlanAmmount.ToString("N2")); DSReturnData.CurrentAccumulativeActual = Convert.ToDecimal(CurrentDetail.NAccumulativeActualAmmount.ToString("N2")); DSReturnData.CurrentAccumulativeDifference = Convert.ToDecimal((CurrentDetail.NAccumulativeDifference).ToString("N2")); DSReturnData.CurrentAccumulativeRate = CurrentDetail.NAccumulativeDisplayRate.ToString(); DSReturnData.CommitDate = string.Format("{0:yyyy-MM-dd}", CurrentDetail.CommitDate); DSReturnData.ReturnType = CurrentDetail.ReturnType; if (!string.IsNullOrEmpty(CurrentDetail.ReturnType.ToString()) && CurrentDetail.ReturnType > 0) { DSReturnData.ReturnTypeDescrible = EnumUtil.GetEnumDescription(typeof(EnumReturnType), CurrentDetail.ReturnType); } else { DSReturnData.ReturnTypeDescrible = "--"; } DSReturnData.Counter = CurrentDetail.Counter; } else { DSReturnData.CurrentAccumulativeRate = "--"; DSReturnData.ReturnTypeDescrible = "--"; DSReturnData.CommitDate = "--"; DSReturnData.Counter = 0; } dataList.Add(DSReturnData); } #endregion if (dataList.Where(p => p.ReturnType == (int)EnumReturnType.New).ToList().Count > 0) { DSCompany.ReturnDataList = dataList; Showlist.Add(DSCompany); } i++; } } #endregion } } return(Showlist); }
public List <DSTargetReturnDataCompany> GetDSTargetReturnDataList(int Year, int Month, bool IsLatestVersion) { List <DSTargetReturnDataCompany> Showlist = new List <DSTargetReturnDataCompany>(); C_System SystemModel = C_SystemOperator.Instance.GetSystem(SysDescriptionID); if (SystemModel != null) { List <C_Target> TargetList = C_TargetOperator.Instance.GetTargetList(SystemModel.ID, DateTime.Now).Where(t => t.NeedReport == true && t.TargetName != "总部管理费用").ToList(); List <C_Company> CompanyList = new List <C_Company>(); //上一个月以及当前月的信息 ReportInstance LastMonthReport = new ReportInstance(); List <MonthlyReportDetail> LastMonthReportDetails = null; if (Month > 1) { LastMonthReport = new ReportInstance(SystemModel.ID, Year, Month - 1, IsLatestVersion); LastMonthReportDetails = LastMonthReport.ReportDetails;//.Where(p => p.ReturnType >= (int)EnumReturnType.Accomplish).ToList(); CompanyList = C_CompanyOperator.Instance.GetCompanyListBySystemID(Year, Month - 1, SystemModel.ID, 1, IsLatestVersion).ToList(); } ReportInstance CurrentMonthReport = new ReportInstance(SystemModel.ID, Year, Month, IsLatestVersion); List <MonthlyReportDetail> CurrentMonthReportDetails = CurrentMonthReport.ReportDetails;//.Where(p => p.ReturnType >= (int)EnumReturnType.Accomplish).ToList(); //新建百货系统经营指标补回情况的集合 if (CompanyList != null && CompanyList.Count > 0) { int i = 1; foreach (C_Company c in CompanyList) { DSTargetReturnDataCompany DSCompany = new DSTargetReturnDataCompany(); DSCompany.ID = i; DSCompany.CompanyName = c.CompanyName; int isIsMissTargetCount = 0; int isReturnCount = 0; List <DSTargetReturnData> dataList = new List <DSTargetReturnData>(); foreach (C_Target ct in TargetList.OrderBy(t => t.Sequence)) { DSTargetReturnData DSReturnData = new DSTargetReturnData(); DSReturnData.CompanyID = i; DSReturnData.ReturnTargetName = ct.TargetName; //上个月 MonthlyReportDetail LastDetail = GetMonthlyReportDetail(c, LastMonthReportDetails, CurrentMonthReportDetails, ct, false); if (LastDetail != null && LastDetail.ID != Guid.Empty) { DSReturnData.LastAccumulativePlan = Convert.ToDecimal(LastDetail.NAccumulativePlanAmmount.ToString("N2")); DSReturnData.LastAccumulativeActual = Convert.ToDecimal(LastDetail.NAccumulativeActualAmmount.ToString("N2")); DSReturnData.LastAccumulativeDifference = Convert.ToDecimal((LastDetail.NAccumulativeActualAmmount - LastDetail.NAccumulativePlanAmmount).ToString("N2")); } //当前月 MonthlyReportDetail CurrentDetail = GetMonthlyReportDetail(c, LastMonthReportDetails, CurrentMonthReportDetails, ct, true); if (CurrentDetail != null && CurrentDetail.ID != Guid.Empty) { DSReturnData.CurrentReturnAmount = Convert.ToDecimal((CurrentDetail.NAccumulativeActualAmmount - CurrentDetail.NAccumulativePlanAmmount).ToString("N2")); DSReturnData.CurrentAccumulativePlan = Convert.ToDecimal(CurrentDetail.NAccumulativePlanAmmount.ToString("N2")); DSReturnData.CurrentAccumulativeActual = Convert.ToDecimal(CurrentDetail.NAccumulativeActualAmmount.ToString("N2")); DSReturnData.CurrentAccumulativeDifference = Convert.ToDecimal((CurrentDetail.NAccumulativeActualAmmount - CurrentDetail.NAccumulativePlanAmmount).ToString("N2")); DSReturnData.CurrentAccumulativeRate = CurrentDetail.NAccumulativeDisplayRate.ToString(); //if (string.IsNullOrEmpty(CurrentDetail.NAccumulativeDisplayRate)) //{ // DSReturnData.CurrentAccumulativeRate = ((CurrentDetail.NAccumulativeActualRate) * 100).ToString("N2") + "%"; //} //else //{ // DSReturnData.CurrentAccumulativeRate = CurrentDetail.NAccumulativeDisplayRate.ToString() + ((CurrentDetail.NAccumulativeActualRate) * 100).ToString("N2") + "%"; //} DSReturnData.CommitDate = string.Format("{0:yyyy-MM-dd}", CurrentDetail.CommitDate); DSReturnData.ReturnType = CurrentDetail.ReturnType; if (!string.IsNullOrEmpty(CurrentDetail.ReturnType.ToString()) && CurrentDetail.ReturnType > 0) { DSReturnData.ReturnTypeDescrible = EnumUtil.GetEnumDescription(typeof(EnumReturnType), CurrentDetail.ReturnType); } else { DSReturnData.ReturnTypeDescrible = "--"; } DSReturnData.Counter = CurrentDetail.Counter; if (CurrentDetail.ReturnType >= (int)EnumReturnType.Accomplish) { isReturnCount++; } if (CurrentDetail.IsMissTarget == false) { isIsMissTargetCount++; } } dataList.Add(DSReturnData); } if (isIsMissTargetCount > 0) { if (isIsMissTargetCount == TargetList.Count) { if (isReturnCount > 0) { DSCompany.IsAllReturn = true; DSCompany.ReturnDataList = dataList; Showlist.Add(DSCompany); } } else { if (isReturnCount > 0) { DSCompany.IsAllReturn = false; DSCompany.ReturnDataList = dataList; Showlist.Add(DSCompany); } } i++; } } } } return(Showlist); }