public List <InitApprovalResultForm> Query(List <string> projectids, List <string> taskids, string currentuserid) { #region init dao List <InitApprovalResultForm> result = new List <InitApprovalResultForm>(); if (projectids == null || projectids.Count == 0) { return(new List <InitApprovalResultForm>()); } ISqlMapper mapper = Common.GetMapperFromSession(); ProjectDao dao = new ProjectDao(mapper); Customer_ProjectDao cpdao = new Customer_ProjectDao(mapper); Customer_AssetDao cadao = new Customer_AssetDao(mapper); Asset_ProjectDao apdao = new Asset_ProjectDao(mapper); WorkflowDao workflowdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); ApprovalDao appvoraldao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); UserInfoDao uidao = new UserInfoDao(mapper); User_RoleDao urdao = new User_RoleDao(mapper); TrackingChangeOwnerDao tcodao = new TrackingChangeOwnerDao(mapper); TrackingMortgageDao tmdao = new TrackingMortgageDao(mapper); LinkDao linkdao = new LinkDao(mapper); Role_Module_ActionDao rmadao = new Role_Module_ActionDao(mapper); ReturnBackConfirmDao rbcdao = new ReturnBackConfirmDao(mapper); CreditReceiverInfoDao cridao = new CreditReceiverInfoDao(mapper); #endregion #region 查询数据 List <Customer_Project> cps = new List <Customer_Project>(); List <Customer_Asset> cas = new List <Customer_Asset>(); List <Asset_Project> aps = new List <Asset_Project>(); List <Activity> activities = new List <Activity>(); List <Approval> approvals = new List <Approval>(); List <Task> tasks = new List <Task>(); List <TrackingChangeOwner> tco = new List <TrackingChangeOwner>(); List <TrackingMortgage> tm = new List <TrackingMortgage>(); List <string> projectidlist = new List <string>(); List <string> workflowids = new List <string>(); List <CreditReceiverInfo> criList = new List <CreditReceiverInfo>(); List <Link> links = new List <Link>(); List <ReturnBackConfirm> returnBackMoneyInfo = new List <ReturnBackConfirm>(); List <Workflow> workflows = null; List <Project> list = null; var rma = rmadao.Query(new Role_Module_ActionQueryForm { }); if (taskids != null && taskids.Count > 0) { tasks = taskdao.Query(new TaskQueryForm { IDs = taskids }); workflowids = (from t in tasks select t.WorkflowID).Distinct().ToList(); workflows = workflowdao.Query(new WorkflowQueryForm { IDs = workflowids }); activities = activitydao.Query(new ActivityQueryForm { WorkflowIDs = workflowids }); approvals = appvoraldao.Query(new ApprovalQueryForm { WorkflowIDs = workflowids }); projectidlist = (from w in workflows select w.ProcessID).ToList(); list = dao.Query(new ProjectQueryForm { IDs = projectidlist }); } else if (projectids != null && projectids.Count > 0) { list = dao.Query(new ProjectQueryForm { IDs = projectids }); projectidlist = (from p in list select p.ID).ToList(); workflows = workflowdao.Query(new WorkflowQueryForm { ProcessIDs = projectidlist }); workflowids = (from w in workflows select w.ID).ToList(); if (workflowids.Count > 0) { activities = activitydao.Query(new ActivityQueryForm { WorkflowIDs = workflowids }); approvals = appvoraldao.Query(new ApprovalQueryForm { WorkflowIDs = workflowids }); tasks = taskdao.Query(new TaskQueryForm { WorkflowIDs = workflowids }); } } else { return(result); } if (projectidlist.Count > 0) { cps = cpdao.Query(new Customer_ProjectQueryForm { ProjectIDs = projectidlist }); cas = cadao.Query(new Customer_AssetQueryForm { ProjectIDs = projectidlist }); aps = apdao.Query(new Asset_ProjectQueryForm { ProjectIDs = projectidlist }); } var users = uidao.Query(new UserInfoQueryForm { }); var userroles = urdao.Query(new User_RoleQueryForm { }); criList = cridao.Query(new CreditReceiverInfoQueryForm { ProjectIDs = projectids }); tco = tcodao.Query(new TrackingChangeOwnerQueryForm { ProjectIDs = projectidlist }); tm = tmdao.Query(new TrackingMortgageQueryForm { ProjectIDs = projectidlist }); returnBackMoneyInfo = rbcdao.Query(new ReturnBackConfirmQueryForm { ProjectIDs = projectidlist }); //从缓存中取得 var customers = TableCacheHelper.GetDataFromCache <Customer>(typeof(CustomerDao)); var assets = TableCacheHelper.GetDataFromCache <Asset>(typeof(AssetDao)); #endregion #region 处理废单权限 //处理废单权限 var hasDisplayDiscard = (from ur in userroles join r in rma on ur.RoleID equals r.RoleID where r.ModuleID == "4" && r.ActionID == "4" && ur.UserID == currentuserid select r).FirstOrDefault(); #endregion foreach (Project project in list) { var data = QueryDetail(project, customers, assets, cps, cas, aps, workflows, activities, approvals, tasks, users, userroles, tco, tm, returnBackMoneyInfo, criList, currentuserid); if (hasDisplayDiscard != null) { data.DisplayDiscard = true; } result.Add(data); } return(result); }
public string Save(Project project, List <Asset> assets, List <Customer> buyers, List <Customer> sellers, List <Customer> thirdpart, List <Guarantor> Guarantor, List <CreditReceiverInfo> creditInfo, string userid) { #region 初始化变量 ISqlMapper mapper = Common.GetMapperFromSession(); ProjectDao projectdao = new ProjectDao(mapper); AssetDao assetdao = new AssetDao(mapper); Asset_ProjectDao apdao = new Asset_ProjectDao(mapper); Customer_ProjectDao cpdao = new Customer_ProjectDao(mapper); CustomerDao customerdao = new CustomerDao(mapper); Customer_AssetDao cadao = new Customer_AssetDao(mapper); CreditReceiverInfoDao cridao = new CreditReceiverInfoDao(mapper); AssetBLL assetbll = new AssetBLL(); CustomerBLL customerbll = new CustomerBLL(); #endregion #region 处理项目信息 DateTime createstart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); DateTime createend = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); if (string.IsNullOrEmpty(project.Name)) { int index = projectdao.QueryMaxProjectIndex(new ProjectQueryForm { CreateTime_Start = createstart, CreateTime_End = createend }); string code = DateTime.Now.ToString("yyMMdd") + (index + 1).ToString(); project.Name = code; project.Index = index + 1; } project.Creator = project.LastUpdator = userid; project.IsDeleted = 0; var projecttemp = projectdao.Query(new ProjectQueryForm { ID = project.ID }).FirstOrDefault(); if (projecttemp == null) { projectdao.Add(project); } else { projectdao.Update(new ProjectUpdateForm { Entity = project, ProjectQueryForm = new ProjectQueryForm { ID = project.ID }, }); } cpdao.Delete(new Customer_ProjectQueryForm { ProjectID = project.ID }); cadao.Delete(new Customer_AssetQueryForm { ProjectID = project.ID }); apdao.Delete(new Asset_ProjectQueryForm { ProjectID = project.ID }); #endregion #region 处理房产信息 if (assets != null) { foreach (var asset in assets) { asset.Creator = userid; var a = assetbll.Save(asset); //处理房产和公权人 foreach (var j in asset.Joint) { var c = customerbll.Save(new Customer { Creator = userid, Name = j.Name, IdentityCode = j.IdentityCode, Phone = j.Phone, }); cadao.Add(new Customer_Asset { AssetID = a.ID, CustomerID = c.ID, ProjectID = project.ID, Type = j.JointType, }); } //处理房产和项目关系 Asset_Project ap = new Asset_Project { AssetID = a.ID, ProjectID = project.ID, }; apdao.Add(ap); } } #endregion #region 处理客户信息 ProcessCustomer(buyers, customerdao, cpdao, project.ID, userid, CustomerType.Buyer); ProcessCustomer(sellers, customerdao, cpdao, project.ID, userid, CustomerType.Seller); ProcessCustomer(thirdpart, customerdao, cpdao, project.ID, userid, CustomerType.ThirdParty); #endregion #region 处理共权人信息 if (Guarantor != null) { foreach (Guarantor g in Guarantor) { g.Creator = userid; var c = customerbll.Save(g); Customer_Project cp = new Customer_Project { CustomerID = c.ID, ProjectID = project.ID, Type = (int)CustomerType.Guarantor, }; cpdao.Add(cp); foreach (var asset in g.Assets) { asset.Creator = userid; var a = assetbll.Save(asset); Customer_Asset ca = new Customer_Asset { AssetID = a.ID, CustomerID = c.ID, ProjectID = project.ID, Type = (int)CustomerAssetType.Guarantor, }; cadao.Add(ca); } } } #endregion #region 处理贷款接收账号信息 cridao.Delete(new CreditReceiverInfoQueryForm { ProjectID = project.ID }); if (creditInfo != null) { foreach (var c in creditInfo) { c.ProjectID = project.ID; cridao.Add(c); } } #endregion return(project.ID); }