/// <summary> /// 导入经费记录 /// </summary> /// <param name="fundId">经费统计ID</param> /// <param name="departmentId">部门ID</param> /// <returns></returns> public List <AllowanceTarget> ImportFund(string fundId, string departmentId) { List <AllowanceTarget> data = new List <AllowanceTarget>(); var frBusiness = new FundRecordBusiness(); var fundRecord = frBusiness.FindByDepartment(fundId, departmentId); if (fundRecord == null) { return(data); } if (fundRecord.HorizontalResearch > 0) { AllowanceTarget at = new AllowanceTarget(); at.Name = "横向科研"; at.Code = EnergyConstant.HorizontalResearchCode; at.Cardinal = fundRecord.HorizontalResearch; at.Factor = 0.0005m; at.MonthCount = 1; at.MonthKilowatt = 1; at.UnitPrice = 0.6m; at.YearAmount = Math.Round(at.Factor * at.Cardinal, 0); at.YearKilowatt = Math.Round(at.YearAmount / at.UnitPrice, 0); at.Remark = ""; data.Add(at); } if (fundRecord.VerticalResearch > 0) { AllowanceTarget at = new AllowanceTarget(); at.Name = "纵向科研"; at.Code = EnergyConstant.VerticalResearchCode; at.Cardinal = fundRecord.VerticalResearch; at.Factor = 0.0025m; at.MonthCount = 1; at.MonthKilowatt = 1; at.UnitPrice = 0.6m; at.YearAmount = Math.Round(at.Factor * at.Cardinal, 0); at.YearKilowatt = Math.Round(at.YearAmount / at.UnitPrice, 0); at.Remark = ""; data.Add(at); } return(data); }
/// <summary> /// BsonDocument转实体对象 /// </summary> /// <param name="doc">Bson文档</param> /// <returns></returns> protected override TargetRecord DocToEntity(BsonDocument doc) { TargetRecord entity = new TargetRecord(); entity.Id = doc["_id"].ToString(); entity.TargetId = doc["targetId"].ToString(); entity.DepartmentId = doc["departmentId"].ToString(); entity.Type = doc["type"].ToInt32(); entity.Finance = doc["finance"].ToString(); entity.SchoolTake = doc["schoolTake"].ToDecimal(); entity.SelfTake = doc["selfTake"].ToDecimal(); entity.PlanQuantum = doc["planQuantum"].ToDecimal(); entity.PlanAmount = doc["planAmount"].ToDecimal(); var createBy = doc["createBy"].ToBsonDocument(); entity.CreateBy = new UpdateStamp { UserId = createBy["userId"].ToString(), Name = createBy["name"].ToString(), Time = createBy["time"].ToLocalTime() }; var updateBy = doc["updateBy"].ToBsonDocument(); entity.UpdateBy = new UpdateStamp { UserId = updateBy["userId"].ToString(), Name = updateBy["name"].ToString(), Time = updateBy["time"].ToLocalTime() }; entity.Remark = doc["remark"].ToString(); entity.Status = doc["status"].ToInt32(); entity.StaffTarget = new List <StaffTarget>(); if (doc.Contains("staffTarget")) { BsonArray array = doc["staffTarget"].AsBsonArray; foreach (BsonDocument item in array) { StaffTarget st = new StaffTarget(); st.Name = item["name"].ToString(); st.Code = item["code"].ToString(); st.Number = item["number"].ToInt32(); st.MonthKilowatt = item["monthKilowatt"].ToDecimal(); st.MonthCount = item["monthCount"].ToInt32(); st.UnitPrice = item["unitPrice"].ToDecimal(); st.YearKilowatt = item["yearKilowatt"].ToDecimal(); st.YearAmount = item["yearAmount"].ToDecimal(); st.Remark = item["remark"].ToString(); entity.StaffTarget.Add(st); } } entity.AllowanceTarget = new List <AllowanceTarget>(); if (doc.Contains("allowanceTarget")) { BsonArray array = doc["allowanceTarget"].AsBsonArray; foreach (BsonDocument item in array) { AllowanceTarget at = new AllowanceTarget(); at.Name = item["name"].ToString(); at.Code = item["code"].ToString(); at.Cardinal = item["cardinal"].ToDecimal(); at.Factor = item["factor"].ToDecimal(); at.MonthKilowatt = item["monthKilowatt"].ToDecimal(); at.MonthCount = item["monthCount"].ToInt32(); at.UnitPrice = item["unitPrice"].ToDecimal(); at.YearKilowatt = item["yearKilowatt"].ToDecimal(); at.YearAmount = item["yearAmount"].ToDecimal(); at.Remark = item["remark"].ToString(); entity.AllowanceTarget.Add(at); } } return(entity); }