public int UpdateTargetReturn(string info, string isday) { int result = 0; try { A_MonthlyReportDetail detail = JsonHelper.Deserialize <A_MonthlyReportDetail>(info); if (isday == "true") { detail.IsMissTarget = false; detail.IsDelayComplete = true; detail.Counter = 0; //detail.CurrentMonthCommitDate = null; } A_MonthlyreportdetailOperator.Instance.UpdateMonthlyreportdetail(detail); } catch (Exception) { result = 100; } return(result); }
/// <summary> /// A表重新计算 /// </summary> /// <param name="RptDetail"></param> /// <param name="TemplateType"></param> /// <returns></returns> public object Calculation(A_MonthlyReportDetail RptDetail, string TemplateType) { string InterfaceName = "*"; C_System sys = StaticResource.Instance[RptDetail.SystemID, DateTime.Now]; if (sys.Category == 2 || sys.GroupType == "ProSystem") //如果系统是项目系统 { InterfaceName = "RProject"; //项目公司有单独的计算 } else if (sys.Category == 3) { InterfaceName = "RGroup"; //集团总部有单独的计算 } else { C_Target T = StaticResource.Instance.TargetList[RptDetail.SystemID].Find(t => t.ID == RptDetail.TargetID); if (T != null) { InterfaceName = "R" + T.TargetType.ToString(); } } return(this[InterfaceName].Calculation(RptDetail)); }
public int UpdateTargetDetail(string info) { int result = 0; try { A_MonthlyReportDetail detail = JsonHelper.Deserialize <A_MonthlyReportDetail>(info); A_MonthlyreportdetailOperator.Instance.UpdateReportdetail(detail); } catch (Exception) { result = 100; } return(result); }
public void Execute(Quartz.IJobExecutionContext context) { Common.ScheduleService.Log.Instance.Info("计算未完成指标考核范围Stare!"); //获取需要的项目系统 List <C_System> sysList = C_SystemOperator.Instance.GetSystemListBySeq().ToList(); //获取上报年 C_ReportTime RTime = C_ReportTimeOperator.Instance.GetReportTime(); sysList.ForEach(S => { Common.ScheduleService.Log.Instance.Info("循环系统 Stare! " + S.SystemName); //筛选指标类型是 收入和净利润 (这里还包含了,旅业的客流量) ,不包含成本类的指标 List <C_Target> targetList = StaticResource.Instance.GetTargetList(S.ID, DateTime.Now).Where(T => T.NeedEvaluation == true && (T.TargetType != (int)EnumTargetType.Cost)).ToList(); targetList.ForEach(t => { Common.ScheduleService.Log.Instance.Info("循环系统下的考核指标 Stare! " + t.TargetName.ToString()); //获取上报年计划指标 (参数,公司ID, 指标ID, 系统ID) List <A_TargetPlanDetail> targetPlanList = A_TargetplandetailOperator.Instance.GetTargetplandetailList(S.ID, RTime.ReportTime.Value.Year).ToList(); for (int i = 1; i <= 12; i++) { Common.ScheduleService.Log.Instance.Info("循环系统下的考核指标的 全年12月 Stare! " + i.ToString() + "月"); #region 循环12月,在里面查询公司 //每个月,上报的月报单独指标 A表 List <A_MonthlyReportDetail> currentMRDList = A_MonthlyreportdetailOperator.Instance.GetAMonthlyreportdetailList(S.ID, RTime.ReportTime.Value.Year, i).Where(M => M.TargetID == t.ID).ToList(); //每个月,上报的月报单独指标, B表 List <B_MonthlyReportDetail> currentB_MRDList = B_MonthlyreportdetailOperator.Instance.GetMonthlyreportdetailList(S.ID, RTime.ReportTime.Value.Year, i, Guid.Empty).Where(M => M.TargetID == t.ID).ToList(); //未完成数量 int MissTargetA = 0; int MissTargetB = 0; MissTargetA = currentMRDList.Where(p => p.IsMissTarget == true).ToList().Count(); MissTargetB = currentB_MRDList.Where(p => p.IsMissTarget == true).ToList().Count(); //每个月的单独计划指标公司 List <A_TargetPlanDetail> currentTargetPlanList = targetPlanList.Where(tp => tp.FinMonth <= i && tp.TargetID == t.ID).ToList(); //获取上报且考核的公司 List <C_Company> companyList = C_CompanyOperator.Instance.GetCompanyListByNeedEvaluation(t.ID, S.ID).ToList(); //该list 作为记数用 A表的 List <C_Company> companyListCount = new List <C_Company>(); //该list 作为记数用 B表的 List <C_Company> companyB_ListCount = new List <C_Company>(); //这里循环有效的考核范围公司 companyList.ForEach(c => { //首先判断当月公司是否存在,存在代表:大于0 int isCompanyCount = currentTargetPlanList.Where(P => P.CompanyID == c.ID).Count(); //获取当月指标等于0的个数 int tempCount = currentTargetPlanList.Where(P => P.CompanyID == c.ID && P.Target == 0).Count(); //记录A表数据 int isMonthRotCount = currentMRDList.Where(MR => MR.CompanyID == c.ID).Count(); //记录B表数据 int isB_MonthRotCount = currentB_MRDList.Where(MR => MR.CompanyID == c.ID).Count(); A_MonthlyReportDetail MonthRpt = currentMRDList.Where(MR => MR.CompanyID == c.ID).FirstOrDefault(); B_MonthlyReportDetail B_MonthRpt = currentB_MRDList.Where(MR => MR.CompanyID == c.ID).FirstOrDefault(); //A表数据的List if (isMonthRotCount > 0 && isCompanyCount > 0 && tempCount != i) { //这里排除总部 if (c.CompanyName.IndexOf("总部") == -1 && MonthRpt.CompanyProperty1 != "筹备门店") { companyListCount.Add(c); } } //B表数据的List if (isB_MonthRotCount > 0 && isCompanyCount > 0 && tempCount != i) { //这里排除总部 if (c.CompanyName.IndexOf("总部") == -1 && B_MonthRpt.CompanyProperty1 != "筹备门店") { companyB_ListCount.Add(c); } } }); //End companyList try { //首先获取数据 , 这里区分A表 和B表的数据 (A表数据) R_MissTargetEvaluationScope UpdateModel = R_MissTargetEvaluationScopeOperator.Instance.GetEvaluationDetailByType(S.ID, t.ID, RTime.ReportTime.Value.Year, i, "NeedEvaluation"); if (UpdateModel != null) { //修改 if (companyListCount != null) { UpdateModel.EvaluationNumber = companyListCount.Count; } else { UpdateModel.EvaluationNumber = 0; } UpdateModel.MissTargetNumber = MissTargetA; UpdateModel.ModifierName = "Sys"; UpdateModel.ModifyTime = DateTime.Now; R_MissTargetEvaluationScopeOperator.Instance.UpdateMissTargetEvaluationScope(UpdateModel); } else { //新增 R_MissTargetEvaluationScope ScopeModel = new R_MissTargetEvaluationScope(); if (companyListCount != null) { ScopeModel.EvaluationNumber = companyListCount.Count; } else { ScopeModel.EvaluationNumber = 0; } ScopeModel.MissTargetNumber = MissTargetA; ScopeModel.FinMonth = i; ScopeModel.FinYear = RTime.ReportTime.Value.Year; ScopeModel.SystemID = S.ID; ScopeModel.TargetID = t.ID; ScopeModel.EvaluationType = "NeedEvaluation"; ScopeModel.CreateTime = DateTime.Now; ScopeModel.CreatorName = "Sys"; //12个月的,每个月,添加一次 R_MissTargetEvaluationScopeOperator.Instance.AddMissTargetEvaluationScope(ScopeModel); } //----------------------------------------------------------------------------------------------------------------- //这里代表B表的数据 R_MissTargetEvaluationScope B_UpdateModel = R_MissTargetEvaluationScopeOperator.Instance.GetEvaluationDetailByType(S.ID, t.ID, RTime.ReportTime.Value.Year, i, "BNeedEvaluation"); if (UpdateModel != null) { //修改 if (companyB_ListCount != null) { B_UpdateModel.EvaluationNumber = companyB_ListCount.Count; } else { B_UpdateModel.EvaluationNumber = 0; } B_UpdateModel.MissTargetNumber = MissTargetB; B_UpdateModel.ModifierName = "Sys"; B_UpdateModel.ModifyTime = DateTime.Now; R_MissTargetEvaluationScopeOperator.Instance.UpdateMissTargetEvaluationScope(B_UpdateModel); } else { //新增 R_MissTargetEvaluationScope ScopeModel = new R_MissTargetEvaluationScope(); if (companyB_ListCount != null) { ScopeModel.EvaluationNumber = companyB_ListCount.Count; } else { ScopeModel.EvaluationNumber = 0; } ScopeModel.MissTargetNumber = MissTargetB; ScopeModel.FinMonth = i; ScopeModel.FinYear = RTime.ReportTime.Value.Year; ScopeModel.SystemID = S.ID; ScopeModel.TargetID = t.ID; ScopeModel.EvaluationType = "BNeedEvaluation"; ScopeModel.CreateTime = DateTime.Now; ScopeModel.CreatorName = "Sys"; //12个月的,每个月,添加一次 R_MissTargetEvaluationScopeOperator.Instance.AddMissTargetEvaluationScope(ScopeModel); } } catch (Exception Exp) { Common.ScheduleService.Log.Instance.Error("添加错误 TargetID" + t.ID + "SystemID" + S.ID + "FinMonth" + i + "FinYear" + RTime.ReportTime.Value.Year); } #endregion } Common.ScheduleService.Log.Instance.Info("循环系统下的考核指标 End!" + t.TargetName.ToString()); }); //End targetList Common.ScheduleService.Log.Instance.Info("循环系统 End!" + S.SystemName.ToString()); });// End sysList Common.ScheduleService.Log.Instance.Info("计算未完成指标考核范围End!"); }
public List <DictionaryVmodel> GetReturnRptDataSource(ReportInstance RptModel, C_System sys) { VLastList = new List <MonthlyReportDetail>(); _System = sys; FinMonth = RptModel.FinMonth; FinYear = RptModel.FinYear; ReportDetails = RptModel.ReportDetails; List <VGroup> GroupList = new List <VGroup>(); XElement element = null; //加载XML,系统配置信息 element = _System.Configuration; if (element.Elements("MisstargetReturn").Elements("Group") != null) { List <XElement> Groups = element.Elements("MisstargetReturn").Elements("Group").ToList(); foreach (XElement group in Groups) { GroupList.Add(new VGroup(group)); } } //上个月A表单一指标 if (VLastList == null || VLastList.Count <= 0) { int lastFinMonth = 0; if (FinMonth == 1) { lastFinMonth = 0; } else { lastFinMonth = FinMonth - 1; } //上月A表的数据 //List<A_MonthlyReportDetail> Lastlist = A_MonthlyreportdetailOperator.Instance.GetAMonthlyreportdetailList(_System.ID, FinYear, lastFinMonth).ToList(); List <A_MonthlyReportDetail> Lastlist = A_MonthlyreportdetailOperator.Instance.GetAMonthlyReportDetailListForTargetPlanID(_System.ID, FinYear, lastFinMonth, RptModel.TargetPlanID).ToList(); //当月A表数据 //List<A_MonthlyReportDetail> list_A = A_MonthlyreportdetailOperator.Instance.GetAMonthlyreportdetailList(_System.ID, FinYear, FinMonth).ToList(); List <A_MonthlyReportDetail> list_A = A_MonthlyreportdetailOperator.Instance.GetAMonthlyReportDetailListForTargetPlanID(_System.ID, FinYear, FinMonth, RptModel.TargetPlanID).ToList(); //当月B表数据 List <B_MonthlyReportDetail> list_B = B_MonthlyreportdetailOperator.Instance.GetMonthlyreportdetailList(_System.ID, FinYear, FinMonth, RptModel._MonthReportID).ToList(); List <Guid> Companies = new List <Guid>(); //调用引擎 Companies = LastMonthCompaniesEngine.LastMonthCompaniesService.GetLastMonthCompaniesID(Lastlist, _System.ID); ReportDetails.RemoveAll(R => !Companies.Contains(R.CompanyID)); foreach (MonthlyReportDetail item in ReportDetails) //循环当月 { A_MonthlyReportDetail lastMRD = Lastlist.Find(p => p.CompanyID == item.CompanyID && p.TargetID == item.TargetID); if (lastMRD != null) { item.LastNAccumulativeActualAmmount = lastMRD.NAccumulativeActualAmmount; item.LastNAccumulativeDifference = lastMRD.NAccumulativeDifference; item.LastNAccumulativePlanAmmount = lastMRD.NAccumulativePlanAmmount; item.LastIsMissTarget = lastMRD.IsMissTarget; item.AddDifference = item.NAccumulativeDifference - item.LastNAccumulativeDifference; } VLastList.Add(item); } } List <DictionaryVmodel> ReturnList = new List <DictionaryVmodel>(); //补回情况,分组List foreach (var Group in GroupList.OrderBy(G => G.Senquence)) { DictionaryVmodel Vmodel = new DictionaryVmodel(); Vmodel.Name = Group.TargetName; Vmodel.ObjValue = FormartVData(Group, "TargetReturn", Group.TargetName); Vmodel.Mark = "Group"; Vmodel.GuoupID = Group.TargetName; Vmodel.SystemName = _System.SystemName; Vmodel.TargetGroupCount = Group.TargetIDs.Count(); Vmodel.HtmlTemplate = GetRetuenHtmlTemplate(element); ReturnList.Add(Vmodel); } return(ReturnList); }
/// <summary> /// A To B /// </summary> /// <param name="value"></param> /// <returns></returns> public static B_MonthlyReportDetail ToBModel(this A_MonthlyReportDetail value) { B_MonthlyReportDetail result = new B_MonthlyReportDetail { ID = value.ID, SystemID = value.SystemID, IsDeleted = value.IsDeleted, FinMonth = value.FinMonth, FinYear = value.FinYear, CreateTime = value.CreateTime, CreatorName = value.CreatorName, ModifierName = value.ModifierName, ModifyTime = value.ModifyTime, TargetID = value.TargetID, CompanyID = value.CompanyID, TargetPlanID = value.TargetPlanID, OPlanAmmount = value.OPlanAmmount, OActualAmmount = value.OActualAmmount, OActualRate = value.OActualRate, ODisplayRate = value.ODisplayRate, NPlanAmmount = value.NPlanAmmount, NActualAmmount = value.NActualAmmount, NActualRate = value.NActualRate, NDisplayRate = value.NDisplayRate, OAccumulativePlanAmmount = value.OAccumulativePlanAmmount, OAccumulativeActualAmmount = value.OAccumulativeActualAmmount, OAccumulativeActualRate = value.OAccumulativeActualRate, OAcccumulativeDisplayRate = value.OAcccumulativeDisplayRate, NAccumulativePlanAmmount = value.NAccumulativePlanAmmount, NAccumulativeActualAmmount = value.NAccumulativeActualAmmount, NAccumulativeActualRate = value.NAccumulativeActualRate, NAccumulativeDisplayRate = value.NAccumulativeDisplayRate, IsMissTarget = value.IsMissTarget, IsMissTargetCurrent = value.IsMissTargetCurrent, Counter = value.Counter, FirstMissTargetDate = value.FirstMissTargetDate, PromissDate = value.PromissDate, CommitDate = value.CommitDate, MIssTargetReason = value.MIssTargetReason, MIssTargetDescription = value.MIssTargetDescription, CurrentMIssTargetDescription = value.CurrentMIssTargetDescription, CurrentMIssTargetReason = value.CurrentMIssTargetReason, NAccumulativeDifference = value.NAccumulativeDifference, NDifference = value.NDifference, OAccumulativeDifference = value.OAccumulativeDifference, ODifference = value.ODifference, ReturnType = value.ReturnType, MonthlyReportID = value.MonthlyReportID, MeasureRate = value.MeasureRate, ReturnDescription = value.ReturnDescription, Display = value.Display, CompanyProperty1 = value.CompanyProperty1, IsCommitDate = value.IsCommitDate, CommitReason = value.CommitReason, CurrentMonthCommitDate = value.CurrentMonthCommitDate, CurrentMonthCommitReason = value.CurrentMonthCommitReason, ReturnType_Sub = value.ReturnType_Sub, NewCounter = value.NewCounter, CompanyProperty = value.CompanyProperty }; return(result); }
/// <summary> /// B To A 这里个方法只是同于 提交审批最后进入最终的数据,IsBToA:True ,标识特殊处理, false:表示正常处理B 表到A表数据 /// </summary> /// <param name="value"></param> /// <param name="IsBToA">是否B表数据转换成A表数据</param> /// <returns></returns> public static A_MonthlyReportDetail ToAModel(this B_MonthlyReportDetail value, bool IsBToA) { int _IsCommitDate = 0; if (IsBToA) //审批 { if (value.PromissDate != null && value.PromissDate.Value.AddMonths(-1).Month == value.FinMonth && value.PromissDate.Value.AddMonths(-1).Year == value.FinYear) { _IsCommitDate = 1; } } else { _IsCommitDate = value.IsCommitDate; } A_MonthlyReportDetail result = new A_MonthlyReportDetail { ID = value.ID, SystemID = value.SystemID, IsDeleted = value.IsDeleted, FinMonth = value.FinMonth, FinYear = value.FinYear, CreateTime = value.CreateTime, CreatorName = value.CreatorName, ModifierName = value.ModifierName, ModifyTime = value.ModifyTime, TargetID = value.TargetID, CompanyID = value.CompanyID, TargetPlanID = value.TargetPlanID, OPlanAmmount = value.OPlanAmmount, OActualAmmount = value.OActualAmmount, OActualRate = value.OActualRate, ODisplayRate = value.ODisplayRate, NPlanAmmount = value.NPlanAmmount, NActualAmmount = value.NActualAmmount, NActualRate = value.NActualRate, NDisplayRate = value.NDisplayRate, OAccumulativePlanAmmount = value.OAccumulativePlanAmmount, OAccumulativeActualAmmount = value.OAccumulativeActualAmmount, OAccumulativeActualRate = value.OAccumulativeActualRate, OAcccumulativeDisplayRate = value.OAcccumulativeDisplayRate, NAccumulativePlanAmmount = value.NAccumulativePlanAmmount, NAccumulativeActualAmmount = value.NAccumulativeActualAmmount, NAccumulativeActualRate = value.NAccumulativeActualRate, NAccumulativeDisplayRate = value.NAccumulativeDisplayRate, IsMissTarget = value.IsMissTarget, Counter = value.Counter, FirstMissTargetDate = value.FirstMissTargetDate, PromissDate = value.PromissDate, CommitDate = value.CommitDate, MIssTargetReason = value.MIssTargetReason, MIssTargetDescription = value.MIssTargetDescription, CurrentMIssTargetReason = value.CurrentMIssTargetReason, CurrentMIssTargetDescription = value.CurrentMIssTargetDescription, ReturnType = value.ReturnType, IsMissTargetCurrent = value.IsMissTargetCurrent, NAccumulativeDifference = value.NAccumulativeDifference, NDifference = value.NDifference, OAccumulativeDifference = value.OAccumulativeDifference, ODifference = value.ODifference, MonthlyReportID = value.MonthlyReportID, MeasureRate = value.MeasureRate, ReturnDescription = value.ReturnDescription, Display = value.Display, CompanyProperty1 = value.CompanyProperty1, IsCommitDate = _IsCommitDate, CommitReason = value.CommitReason, IsDelayComplete = false, CurrentMonthCommitDate = value.CurrentMonthCommitDate, CurrentMonthCommitReason = value.CurrentMonthCommitReason, ReturnType_Sub = value.ReturnType_Sub, NewCounter = value.NewCounter, CompanyProperty = value.CompanyProperty }; return(result); }
public static MonthlyReportDetail ToVModel(this A_MonthlyReportDetail value) { //这是为了前台显示,美观强制去掉“\n” string tempMIssTargetReason = value.MIssTargetReason.TrimStart('\n').TrimStart('\r').TrimEnd('\n').TrimEnd('\r'); if (string.IsNullOrEmpty(tempMIssTargetReason)) { tempMIssTargetReason = ""; } else { tempMIssTargetReason = "\n" + tempMIssTargetReason; } string tempMIssTargetDescription = value.MIssTargetDescription.TrimStart('\n').TrimStart('\r').TrimEnd('\n').TrimEnd('\r'); if (string.IsNullOrEmpty(tempMIssTargetDescription)) { tempMIssTargetDescription = ""; } else { tempMIssTargetDescription = "\n" + tempMIssTargetDescription; } string tempCurrentMIssTargetReason = value.CurrentMIssTargetReason.TrimStart('\n').TrimStart('\r').TrimEnd('\n').TrimEnd('\r'); if (string.IsNullOrEmpty(tempCurrentMIssTargetReason)) { tempCurrentMIssTargetReason = ""; } else { tempCurrentMIssTargetReason = "\n" + tempCurrentMIssTargetReason; } string tempCurrentMIssTargetDescription = value.CurrentMIssTargetDescription.TrimStart('\n').TrimStart('\r').TrimEnd('\n').TrimEnd('\r'); if (string.IsNullOrEmpty(tempCurrentMIssTargetDescription)) { tempCurrentMIssTargetDescription = ""; } else { tempCurrentMIssTargetDescription = "\n" + tempCurrentMIssTargetDescription; } string tempReturnDescription = value.ReturnDescription.TrimStart('\n').TrimStart('\r').TrimEnd('\n').TrimEnd('\r'); if (string.IsNullOrEmpty(tempReturnDescription)) { tempReturnDescription = ""; } string tempCommitReason = value.CommitReason.TrimStart('\n').TrimStart('\r').TrimEnd('\n').TrimEnd('\r'); if (string.IsNullOrEmpty(tempCommitReason)) { tempCommitReason = ""; } string strSystemName = string.Empty; C_System _cSystem = StaticResource.Instance[value.SystemID, DateTime.Now]; if (_cSystem != null) { strSystemName = _cSystem.SystemName; } string strCompanyName = string.Empty; C_Company _cCompany = StaticResource.Instance.GetCompanyModel(value.CompanyID); if (_cCompany != null) { strCompanyName = _cCompany.CompanyName; } string strTargetName = string.Empty; C_Target _cTarget = StaticResource.Instance.TargetList[value.SystemID].Where(p => p.ID == value.TargetID).FirstOrDefault(); if (_cTarget != null) { strTargetName = _cTarget.TargetName; } MonthlyReportDetail result = new MonthlyReportDetail { ID = value.ID, SystemID = value.SystemID, IsDeleted = value.IsDeleted, FinMonth = value.FinMonth, FinYear = value.FinYear, CreateTime = value.CreateTime, CreatorName = value.CreatorName, ModifierName = value.ModifierName, ModifyTime = value.ModifyTime, TargetID = value.TargetID, CompanyID = value.CompanyID, TargetPlanID = value.TargetPlanID, OPlanAmmount = value.OPlanAmmount, OActualAmmount = value.OActualAmmount, OActualRate = value.OActualRate, ODisplayRate = value.ODisplayRate, NPlanAmmount = value.NPlanAmmount, NActualAmmount = value.NActualAmmount, NActualRate = value.NActualRate, NDisplayRate = value.NDisplayRate, OAccumulativePlanAmmount = value.OAccumulativePlanAmmount, OAccumulativeActualAmmount = value.OAccumulativeActualAmmount, OAccumulativeActualRate = value.OAccumulativeActualRate, OAcccumulativeDisplayRate = value.OAcccumulativeDisplayRate, NAccumulativePlanAmmount = value.NAccumulativePlanAmmount, NAccumulativeActualAmmount = value.NAccumulativeActualAmmount, NAccumulativeActualRate = value.NAccumulativeActualRate, NAccumulativeDisplayRate = value.NAccumulativeDisplayRate, IsMissTarget = value.IsMissTarget, IsMissTargetCurrent = value.IsMissTargetCurrent, Counter = value.Counter, FirstMissTargetDate = value.FirstMissTargetDate, PromissDate = value.PromissDate, CommitDate = value.CommitDate, MIssTargetReason = tempMIssTargetReason, MIssTargetDescription = tempMIssTargetDescription, CurrentMIssTargetDescription = tempCurrentMIssTargetDescription, CurrentMIssTargetReason = tempCurrentMIssTargetReason, ReturnType = value.ReturnType, NAccumulativeDifference = value.NAccumulativeDifference, NDifference = value.NDifference, OAccumulativeDifference = value.OAccumulativeDifference, ODifference = value.ODifference, Title = value.Title, GroupTile = value.GroupTile, MonthlyReportID = value.MonthlyReportID, MeasureRate = value.MeasureRate, ReturnDescription = tempReturnDescription, SystemName = strSystemName, Company = _cCompany, CompanyName = strCompanyName, TargetName = strTargetName, Display = value.Display, CompanyProperty1 = value.CompanyProperty1, IsCommitDate = value.IsCommitDate, CommitReason = tempCommitReason, IsDelayComplete = value.IsDelayComplete, CurrentMonthCommitDate = value.CurrentMonthCommitDate, CurrentMonthCommitReason = value.CurrentMonthCommitReason, ReturnType_Sub = value.ReturnType_Sub, NewCounter = value.NewCounter, CompanyProperty = value.CompanyProperty }; return(result); }
public A_MonthlyReportDetail GetMonthLyRModel(string ID) { A_MonthlyReportDetail result = A_MonthlyreportdetailOperator.Instance.GetMonthlyreportdetail(Guid.Parse(ID)); return(result); }
public void UpLoadExcel2(out string error, HttpContext context, string filePathName) { string templetePath = filePathName; error = ""; ExcelEngine excel = new ExcelEngine(); Workbook book = new Workbook(templetePath); int count = book.Worksheets.Count; List <DictionaryVmodel> ListDV = new List <DictionaryVmodel>(); List <A_MonthlyReportDetail> CommitDetailList = new List <A_MonthlyReportDetail>(); if (excel.GetStringCustomProperty(book.Worksheets[0], "Time") != FinYear + "-" + FinMonth) { error = "请上传所选月的文件!"; return; } for (int i = 0; i < count; i++) { #region 验证excel string aa = excel.GetStringCustomProperty(book.Worksheets[0], "SheetName"); string bb = excel.GetStringCustomProperty(book.Worksheets[0], "SystemID"); if (excel.GetStringCustomProperty(book.Worksheets[0], "SheetName") != "CommitUpdate") { error = "请上传正确的报表文件!"; return; } if (excel.GetStringCustomProperty(book.Worksheets[0], "SystemID") != SysId.ToString()) { error = "请下载当前系统的模板!"; return; } Worksheet workSheet = book.Worksheets[i]; Cells cells = workSheet.Cells; #endregion if (cells.MaxDataRow - 2 > 0 && cells.MaxDataColumn == 8) { try { DataTable dt = cells.ExportDataTable(3, 1, cells.MaxDataRow - 2, cells.MaxDataColumn); { string NowDate = null; if (FinMonth == 12) { int a = FinYear + 01; NowDate = a + "-" + 01; } else { int a = FinMonth + 1; if (a < 10) { NowDate = FinYear + "-0" + a; } else { NowDate = FinYear + "-" + a; } }//获取下个月 为判断IsCommitDate做准备 foreach (DataRow item in dt.Rows) { try { Amodel = A_MonthlyreportdetailOperator.Instance.GetAMonthlyreportdetail(SysId, item[6].ToString().ToGuid(), item[7].ToString().ToGuid(), FinYear, FinMonth); } catch (Exception) { error = "数据模板错误,请重新下载填写";//添加数据有问题,请重新添加。 return; } try { DateTime time = DateTime.Parse(item[3].ToString());//获取excel要求时间 Amodel.CurrentMonthCommitDate = time; string changtime = time.ToString("yyyy-MM"); if (DateTime.Parse(changtime) < DateTime.Parse(FinYear + "-" + FinMonth)) { error = "要求时间填写错误!"; return; } if (changtime == NowDate) { Amodel.IsCommitDate = 1; } else { Amodel.IsCommitDate = 0; } } catch (Exception) { error = "要求时间填写错误!";//添加数据有问题,请重新添加。 return; } Amodel.CurrentMonthCommitReason = item[4].ToString(); CommitDetailList.Add(Amodel); } } } catch (Exception) { error = "数据填写错误!";//添加数据有问题,请重新添加。 return; } } } updateModle(CommitDetailList); }
public void UpLoadExcel(out string error, HttpContext context, string filePathName) { string templetePath = filePathName; error = ""; ExcelEngine excel = new ExcelEngine(); Workbook book = new Workbook(templetePath); List <C_Target> Targetlist = StaticResource.Instance.GetTargetList(SysId, T).Where(p => p.NeedEvaluation = true).ToList(); //var newTargetlist = Targetlist.Where( // p => p.TargetName != "客流量" // ).OrderBy(p => p.Sequence); //List<C_Target> NewTarget = new List<C_Target>(); //foreach (C_Target item in newTargetlist) //{ // NewTarget.Add(item); //} int count = book.Worksheets.Count; List <DictionaryVmodel> ListDV = new List <DictionaryVmodel>(); List <A_MonthlyReportDetail> CommitDetailList = new List <A_MonthlyReportDetail>(); if (excel.GetStringCustomProperty(book.Worksheets[0], "Time") != FinYear + "-" + FinMonth) { error = "请上传所选月的文件!"; return; } for (int i = 0; i < count; i++) { #region 验证excel if (excel.GetStringCustomProperty(book.Worksheets[i], "SheetName") != "CommitUpdate") { error = "请上传正确的报表文件!"; return; } if (excel.GetStringCustomProperty(book.Worksheets[i], "SystemID") != SysId.ToString()) { error = "请下载当前系统的模板!"; return; } if (Targetlist.Where(p => p.TargetName == book.Worksheets[i].Name).ToList().Count < 0) { error = "上传数据中的指标不是当前系统的指标,请重新添加!"; return; } #endregion string TargetID = excel.GetStringCustomProperty(book.Worksheets[i], "TargetID").ToString(); Worksheet workSheet = book.Worksheets[i]; Cells cells = workSheet.Cells; if (cells.MaxDataRow - 2 > 0 && cells.MaxDataColumn == 7) { DataTable dt = cells.ExportDataTable(3, 1, cells.MaxDataRow - 2, cells.MaxDataColumn); { string NowDate = null; if (FinMonth == 12) { int a = FinYear + 01; NowDate = a + "-" + 01; } else { int a = FinMonth + 1; if (a < 10) { NowDate = FinYear + "-0" + a; } else { NowDate = FinYear + "-" + a; } }//获取下个月 为判断IsCommitDate做准备 foreach (DataRow item in dt.Rows) { try { Amodel = A_MonthlyreportdetailOperator.Instance.GetAMonthlyreportdetail(SysId, item[6].ToString().ToGuid(), TargetID.ToGuid(), FinYear, FinMonth); } catch (Exception) { error = "数据模板错误,请重新下载填写";//添加数据有问题,请重新添加。 return; } try { if (item[3].ToString() != "" && item[3].ToString() != null) { DateTime time = DateTime.Parse(item[3].ToString());//获取excel要求时间 Amodel.CurrentMonthCommitDate = time; string changtime = time.ToString("yyyy-MM"); if (DateTime.Parse(changtime) < DateTime.Parse(FinYear + "-" + FinMonth)) { error = "时间格式错误,请检查!"; return; } if (changtime == NowDate) { Amodel.IsCommitDate = 1; } else { Amodel.IsCommitDate = 0; } } else { error = "时间不能为空,请检查!"; return; } } catch (Exception) { error = "要求时间填写错误!";//添加数据有问题,请重新添加。 return; } Amodel.CurrentMonthCommitReason = item[4].ToString(); CommitDetailList.Add(Amodel); } } } } updateModle(CommitDetailList); }
public B_MonthlyReportDetail Calculation(B_MonthlyReportDetail RptDetail, bool WithCounter = true) { B_MonthlyReportDetail rpt = RptDetail; rpt.ReturnType = 0; rpt.Counter = 0; rpt.IsMissTarget = false; rpt.IsMissTargetCurrent = false; C_Target T = StaticResource.Instance.TargetList[RptDetail.SystemID].Find(t => t.ID == RptDetail.TargetID); bool IsBaseline = false; if (T != null && T.BaseLine.Year == rpt.FinYear && T.BaseLine.Month == rpt.FinMonth) { IsBaseline = true; } //是否能够改动计划,如果能改,取Excel数据,不能改取系统计划数(在Taget Configuration配置) List <A_TargetPlanDetail> listCurrentMonthData = StaticResource.Instance.GetTargetPlanList(rpt.SystemID, rpt.FinYear).ToList().Where(p => p.FinMonth == rpt.FinMonth && p.CompanyID == rpt.CompanyID).ToList(); if (listCurrentMonthData.Count > 0) { A_TargetPlanDetail currentMonthData = listCurrentMonthData[0]; bool IsModifiy = false; if (currentMonthData.Target != RptDetail.OPlanAmmount) { //获取当前指标 List <C_Target> listTarget = StaticResource.Instance.GetTargetList(RptDetail.SystemID, RptDetail.CreateTime).ToList().Where(p => p.ID == RptDetail.TargetID).ToList(); if (listTarget.Count > 0) { //获取当前指标的Configuration IList <System.Xml.Linq.XElement> xmlConfiguration = listTarget[0].Configuration.Elements("IsModifyTargetPlanDetail").ToList(); if (xmlConfiguration.Count > 0) { //判断当前指标是否可以修改 if (xmlConfiguration.ToList()[0].GetAttributeValue("IsModifiy", "") == "True") { IsModifiy = true; } } } } //如果IsModifiy为True,则计划数可以修改,否则反之。 if (IsModifiy == false) { RptDetail.OPlanAmmount = currentMonthData.Target; } } A_MonthlyReportDetail lastMonthData = A_MonthlyreportdetailOperator.Instance.GetAMonthlyreportdetail(rpt.SystemID, rpt.CompanyID, rpt.TargetID, rpt.FinYear, rpt.FinMonth - 1); if (lastMonthData != null) { rpt.NAccumulativeActualAmmount = lastMonthData.NAccumulativeActualAmmount + rpt.NActualAmmount; rpt.OAccumulativeActualAmmount = lastMonthData.OAccumulativeActualAmmount + rpt.OActualAmmount; //重新考核需要特殊处理,直接获取累计指标,无承诺补回时间 if (!IsBaseline) { rpt.NAccumulativePlanAmmount = lastMonthData.NAccumulativePlanAmmount + rpt.NPlanAmmount; rpt.OAccumulativePlanAmmount = lastMonthData.OAccumulativePlanAmmount + rpt.OPlanAmmount; rpt.CommitDate = lastMonthData.CurrentMonthCommitDate; rpt.CommitReason = lastMonthData.CurrentMonthCommitReason; } else { IList <A_TargetPlanDetail> ATPD = StaticResource.Instance.GetTargetPlanList(rpt.SystemID, rpt.FinYear).FindAll(P => P.CompanyID == rpt.CompanyID && P.TargetID == rpt.TargetID && P.FinMonth <= rpt.FinMonth); rpt.NAccumulativePlanAmmount = ATPD.Sum(p => p.Target); rpt.OAccumulativePlanAmmount = ATPD.Sum(p => p.Target); } } else { if (WithCounter) { rpt.NAccumulativeActualAmmount = rpt.NActualAmmount; rpt.NAccumulativePlanAmmount = rpt.NPlanAmmount; rpt.OAccumulativeActualAmmount = rpt.OActualAmmount; rpt.OAccumulativePlanAmmount = rpt.OPlanAmmount; } } //特殊处理差额,针对指标 XElement element = null; if (T != null) { element = T.Configuration; } XElement subElement = null; bool IsDifferenceException = false; if (element != null && element.Element("IsDifferenceExceptionTarget") != null) { subElement = element.Elements("IsDifferenceExceptionTarget").ToList()[0]; IsDifferenceException = subElement.GetAttributeValue("value", false); } if (!IsDifferenceException) { rpt.NAccumulativeDifference = rpt.NAccumulativeActualAmmount - rpt.NAccumulativePlanAmmount; rpt.OAccumulativeDifference = rpt.OAccumulativeActualAmmount - rpt.OAccumulativePlanAmmount; rpt.NDifference = rpt.NActualAmmount - rpt.NPlanAmmount; rpt.ODifference = rpt.OActualAmmount - rpt.OPlanAmmount; } rpt = (B_MonthlyReportDetail)this[T.TargetType.ToString()].Calculation(RptDetail); if (T != null && T.NeedEvaluation) { DateTime ReportDate = DateTime.MinValue; DateTime.TryParse(rpt.FinYear + "-" + rpt.FinMonth + "-1 00:00:00", out ReportDate); ReportDate = ReportDate.AddMonths(1).AddMinutes(-5); //累计未完成情况 //上月累计未完成 if (!IsBaseline) //从1月开始重新计算 { if (lastMonthData != null && (lastMonthData.IsMissTarget || lastMonthData.NAccumulativeDifference < 0)) { if (rpt.IsMissTarget || rpt.NAccumulativeDifference < 0) { if (lastMonthData.CurrentMonthCommitDate >= ReportDate) { rpt.ReturnType = (int)EnumReturnType.Returning; if (lastMonthData.ReturnType_Sub == EnumHelper.GetEnumDescription(typeof(EnumReturnType_Sub), (int)EnumReturnType_Sub.Sub_UnableReturnByYear)) { rpt.ReturnDescription = lastMonthData.ReturnDescription; } } else { rpt.ReturnType = (int)EnumReturnType.NotReturn; } if (rpt.IsMissTarget && WithCounter) { rpt.Counter = lastMonthData.Counter + 1; } } else { if (lastMonthData.CurrentMonthCommitDate >= ReportDate) { rpt.ReturnType = (int)EnumReturnType.AccomplishInadvance; } else { rpt.ReturnType = (int)EnumReturnType.Accomplish; } if (WithCounter) { rpt.Counter = 0; rpt.FirstMissTargetDate = null; } } //要求期限,是本月 if (lastMonthData.CurrentMonthCommitDate < ReportDate && lastMonthData.CurrentMonthCommitDate >= ReportDate.AddMonths(-1)) { rpt.IsCommitDate = 1; } else { rpt.IsCommitDate = 0; } } //无上月数据(1月)或上月累计完成 else { if (rpt.IsMissTarget || rpt.NAccumulativeDifference < 0) { rpt.ReturnType = (int)EnumReturnType.New; if (rpt.IsMissTarget && WithCounter) { rpt.Counter = 1; rpt.FirstMissTargetDate = ReportDate; } } } } //无上月数据(1月)或上月累计完成 //重新计算 else { if (rpt.IsMissTarget || rpt.NAccumulativeDifference < 0) { rpt.ReturnType = (int)EnumReturnType.New; if (rpt.IsMissTarget && WithCounter) { rpt.Counter = 1; rpt.FirstMissTargetDate = ReportDate; } } } } else { rpt.IsMissTarget = false; rpt.IsMissTargetCurrent = false; } return(rpt); }