/// <summary> /// 写字楼详情 /// </summary> /// <returns></returns> public ActionResult GetFormJson(int?keyValue) { string returnUrl = Request.Url.ToString(); Ku_LocationEntity entity = locationBll.GetEntity(keyValue); return(Content(entity.ToJson())); }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(int?keyValue, Ku_CompanyEntity entity) { IRepository db = new RepositoryFactory().BaseRepository().BeginTrans(); if (keyValue != null) { Ku_CompanyEntity oldEntity = db.FindEntity <Ku_CompanyEntity>(t => t.Id == keyValue); //真实地址修正注册地址 if (oldEntity.CompanyAddress != entity.RealAddress && !string.IsNullOrEmpty(entity.RealAddress) && oldEntity.RealAddress != entity.RealAddress) { //重新运算地址 Ku_LocationEntity locationData = locationService.AddressToLocation(entity.RealAddress); entity = GetCompany(entity, locationData); //减去原坐标数 Ku_LocationEntity oldLoactionEntity = db.FindEntity <Ku_LocationEntity>(t => t.Id == oldEntity.LocationId); oldLoactionEntity.Count = oldLoactionEntity.Count - 1; db.Update <Ku_LocationEntity>(oldLoactionEntity); } entity.Modify(keyValue); this.BaseRepository().Update(entity); } else { var company_Data = db.FindEntity <Ku_CompanyEntity>(t => t.CompanyName == entity.CompanyName);//公司重复判断 if (company_Data != null) { throw new Exception(entity.CompanyName + " 重复!"); } //地址为空判断 if (string.IsNullOrEmpty(entity.CompanyAddress)) { throw new Exception(entity.CompanyName + " 地址为空!"); } //如果存在坐标id,直接从当前坐标添加公司,如果不存在坐标点,则需要从地址转换坐标 if (entity.LocationId == null) { //1.根据地址获得坐标信息 Ku_LocationEntity locationData = locationService.AddressToLocation(entity.CompanyAddress); entity = GetCompany(entity, locationData); } else { //现有坐标 Ku_LocationEntity locationData = db.FindEntity <Ku_LocationEntity>(t => t.Id == entity.LocationId); locationData.Count = locationData.Count + 1; db.Update(locationData); entity = GetCompany(entity, locationData); } entity.Create(); this.BaseRepository().Insert(entity); } }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(int?keyValue, Ku_LocationEntity entity) { try { service.SaveForm(keyValue, entity); } catch (Exception) { throw; } }
/// <summary> /// 根据参数获取热点 /// </summary> /// <returns></returns> public ActionResult GetLocationJson(int?locationId, string address) { Ku_LocationEntity location = null; //获取位置坐标点 if (locationId != null) { location = locationBll.GetEntity(locationId); } else { if (!string.IsNullOrEmpty(address)) { //根据地址获取热点 location = locationBll.AddressToLocation(address); } } return(Content(location.ToJson())); }
/// <summary> /// 补全公司数据中的1.楼层房间,2.坐标关联信息 /// </summary> /// <param name="entity">公司实体</param> /// <param name="locationData">坐标点实体</param> /// <returns></returns> public Ku_CompanyEntity GetCompany(Ku_CompanyEntity entity, Ku_LocationEntity locationData) { //通过地址获取楼层和房间 if (entity.Floor == 0 && entity.Room == 0 && !string.IsNullOrEmpty(entity.RealAddress)) { string building; int floor, room; getFloorRoom(entity.RealAddress, out building, out floor, out room); entity.Building = building; entity.Floor = floor; entity.Room = room; } //添加客户信息表,将插入的位置id和商圈名称,返回给公司 entity.Province = locationData.Province; entity.City = locationData.City; entity.District = locationData.District; entity.LocationId = locationData.Id; entity.RegeoId = locationData.RegeoId; entity.RegeoName = locationData.RegeoName; return(entity); }
public ActionResult NearbyForm(int?keyValue, Ku_LocationEntity entity) { //double Lon = (double)entity.wxLon; //double Lat = (double)entity.wxLat; //double bdLat, bdLon; //MapConverter.GCJ02ToBD09(Lat, Lon, out bdLat, out bdLon); //entity.bdLat = (decimal)bdLat; //entity.bdLon = (decimal)bdLon; ////根据坐标获取省市县信息 //string url = @"http://restapi.amap.com/v3/geocode/regeo?location="+ Lon + "," + Lat + "&key=cf3dd05a8192fd1839628b39e589c89e&radius=1000&extensions=all";//output=XML& //string responseJson = HttpClientHelper.Get(url); //RestLocation restLocation = JsonConvert.DeserializeObject<RestLocation>(responseJson.Replace("[]", "\"\"")); //entity.Province = restLocation.regeocode.addressComponent.province; //entity.City = restLocation.regeocode.addressComponent.city; //entity.CityCode = restLocation.regeocode.addressComponent.citycode; //entity.District = restLocation.regeocode.addressComponent.district; //插入热点表 locationBll.SaveForm(keyValue, entity); return(Content("true")); }
public ActionResult SaveForm(int?keyValue, Ku_LocationEntity entity) { ku_locationbll.SaveForm(keyValue, entity); return(Success("操作成功。")); }