/// <summary> /// 根据地址获取外线员 /// </summary> /// <param name="matchingAddress">匹配地址</param> /// <returns></returns> public UserOTM getOTM(string matchingAddress) { List <FIX_MatchingModel> list = m_Rep.FindList().Where(m => m.Address == matchingAddress).ToList(); UserOTM _UserOTM = null; if (list.Count > 0) { FIX_MatchingModel _FIX_MatchingModel = list.First(); _UserOTM = new UserOTM(); _UserOTM.Id = _FIX_MatchingModel.OTM; _UserOTM.UserName = _FIX_MatchingModel.OTM_Name; } return(_UserOTM); }
/// <summary> /// 保存数据 /// </summary> public void SaveImportData(IEnumerable <FIX_CustomerModel> customerList) { try { var matchAddressList = new List <string>(); DbContexts db = new DbContexts(); foreach (var model in customerList) { FIX_CustomerModel entity = new FIX_CustomerModel(); entity.Name = model.Name; entity.Phone = model.Phone; entity.Tel = model.Tel; entity.Address = model.Address; entity.ONU = model.ONU; entity.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd HH:mm:ss"); db.FIX_CustomerModel.Add(entity); var matchingAddress = entity.Address.ToString().Substring(0, entity.Address.ToString().IndexOf("号") + 1); if (!matchAddressList.Contains(matchingAddress)) { FIX_MatchingModel matching = new FIX_MatchingModel(); matching.CreatePerson = "System"; matching.CreateTime = DateTime.Now.ToShortDateString(); matching.Address = matchingAddress; matching.OTM = "0"; matchAddressList.Add(matchingAddress); db.FIX_MatchingModel.Add(matching); } } db.SaveChanges(); } catch (Exception ex) { throw; } }
public HttpResponseMessage CreateOrder(FIX_OrderModel order) { log.Debug("OrderController.CreateOrder Start!"); log.Debug("Address is " + order.Address + ", MatchingAddress is " + order.MatchingAddress + ", Phone is " + order.Phone + ", Tel is " + order.Tel + ", Type is " + order.Type + ", Description is " + order.Description); var response = new Response(); response.Code = 0; response.Message = "添加订单成功!"; FIX_CustomerModel customer = new FIX_CustomerModel(); customer.CreatePerson = order.Phone; customer.CreateTime = DateTime.Now.ToShortDateString(); customer.UpdateTime = DateTime.Now.ToShortDateString(); customer.Name = order.Name; customer.Phone = order.Phone; customer.Tel = order.Tel; customer.Address = order.Province + order.City + order.Area + order.Address; if (customer_BLL.IsCustomerExist(customer.Name, customer.Tel, customer.Address, null) == 0) { customer_BLL.m_Rep.Create(customer); } order.CreatePerson = "Mobile"; order.CreateTime = DateTime.Now.ToShortDateString(); order.UpdateTime = DateTime.Now.ToShortDateString(); order.Assessment_ID = 0; order.OTM_ID = matching_BLL.getOTM_IDByAddress(order.MatchingAddress).ToString(); if (order.OTM_ID == "0") { order.Status = "新订单"; response.Data = "暂无外线员"; if (!string.IsNullOrEmpty(order.MatchingAddress)) { if (matching_BLL.isAddressNotExist(order.MatchingAddress)) { FIX_MatchingModel matching = new FIX_MatchingModel(); matching.CreateTime = DateTime.Now.ToShortDateString(); matching.UpdateTime = DateTime.Now.ToShortDateString(); matching.CreatePerson = "System"; matching.Address = order.MatchingAddress; matching.OTM = "0"; matching_BLL.m_Rep.Create(matching); } } } else { order.Status = "待接单"; response.Code = 1; Dictionary <string, object> dic = new Dictionary <string, object>(); SysUser user = user_BLL.m_Rep.Find(Convert.ToInt32(order.OTM_ID)); dic.Add("OutsideTroubleMan_ID", user.Id); dic.Add("Name", user.TrueName); dic.Add("Phone", user.MobileNumber); dic.Add("EmployeeNo", user.EmployeeNo); dic.Add("WorkYear", user.WorkYear); dic.Add("Business", user.Business); dic.Add("ResponsibleAreaBrief", user.ResponsibleAreaBrief); response.Data = dic; } order_BLL.m_Rep.Create(order); FIX_OrderHistoryModel orderHistory = new FIX_OrderHistoryModel(); orderHistory.CreatePerson = "System"; orderHistory.CreateTime = DateTime.Now.ToShortDateString(); orderHistory.Order_ID = order.Id; orderHistory.Status = order.Status; orderHistory.UpdateTime = DateTime.Now.ToShortDateString(); orderHistory_BLL.m_Rep.Create(orderHistory); return(toJson(response)); }