/// <summary> /// 检查楼层 /// </summary> /// <param name="sumFloor">总楼层</param> /// <param name="nowFloor">当前楼层</param> /// <returns></returns> public static bool CheckHouseFloor(string sumFloor, string nowFloor) { sumFloor = StringHelp.TrimBlank(sumFloor); if (string.IsNullOrEmpty(sumFloor)) { return(true); } nowFloor = StringHelp.TrimBlank(nowFloor); if (string.IsNullOrEmpty(nowFloor)) { return(true); } if (!StringHelp.IsInteger(sumFloor)) { return(false); } if (!StringHelp.IsInteger(nowFloor)) { return(false); } int _nowFloor = Convert.ToInt32(nowFloor); int _sumFloor = Convert.ToInt32(sumFloor); if (_nowFloor > _sumFloor) { return(false); } return(true); }
/// <summary> /// 整理各列字符串格式 /// </summary> /// <param name="newHouse"></param> /// <returns></returns> public static NewHouse ToColumnStr(this NewHouse newHouse) { //整理数据字符串 newHouse.Lpm = StringHelp.TrimBlank(newHouse.Lpm).ToRemoveSpe(); newHouse.Xzq = StringHelp.TrimBlank(newHouse.Xzq.Trim().ToRemoveSpe()); newHouse.Jg = string.IsNullOrEmpty(StringHelp.TrimBlank(newHouse.Jg)) ? "平面" : StringHelp.TrimBlank(newHouse.Jg); newHouse.Zj = StringHelp.TrimBlank(newHouse.Zj); newHouse.Cx = StringHelp.TrimBlank(newHouse.Cx).ToRemoveSpe(); newHouse.Phone = StringHelp.TrimBlank(newHouse.Phone).ToRemoveSpe(); newHouse.Mj = Regex.Replace(newHouse.Mj, @"\..*", "", RegexOptions.IgnoreCase); newHouse.Dj = Regex.Replace(newHouse.Dj, @"\..*", "", RegexOptions.IgnoreCase); newHouse.Hymj = Regex.Replace(newHouse.Hymj, @"\..*", "", RegexOptions.IgnoreCase); newHouse.Dxsmj = Regex.Replace(newHouse.Dxsmj, @"\..*", "", RegexOptions.IgnoreCase); //计算数据 newHouse.Jzlx = SpiderHelp.GetBuildingType(newHouse.Zlc); //获取计算建筑类型 newHouse.Yt = SpiderHelp.GetHousePurposes(newHouse.Mj, newHouse.Jzlx); //获取计算用途 newHouse.Hx = SpiderHelp.GetHouseType(newHouse.Hx).ToRemoveSpe(); newHouse.Alsj = newHouse.Alsj != null?newHouse.Alsj.Trim() : newHouse.Alsj; if (!StringHelp.CheckStrIsDate(newHouse.Alsj)) { newHouse.Alsj = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } else { newHouse.Alsj = Convert.ToDateTime(newHouse.Alsj).ToString("yyyy-MM-dd HH:mm:ss"); } return(newHouse); }
/// <summary> /// 获取计算户型 /// </summary> /// <param name="houseType"></param> /// <returns></returns> public static string GetHouseType(string houseType) { if (houseType == null) { return(""); } houseType = StringHelp.TrimBlank(houseType); if (string.IsNullOrEmpty(houseType)) { return(""); } Dictionary <string, RegexInfo> regDic = new Dictionary <string, RegexInfo>(); string _houseType = StringHelp.ChineseConvertToNumber(houseType); regDic.Add("房", new RegexInfo("(.+)房", "$1")); regDic.Add("厅", new RegexInfo("(\\d+)厅", "$1")); Dictionary <string, List <string> > regDicResult = GetStrByRegex(_houseType, regDic); string _f = regDicResult["房"].Count < 1 ? "" : regDicResult["房"][0]; string _t = regDicResult["厅"].Count < 1 ? "" : regDicResult["厅"][0]; if (!StringHelp.IsInteger(_f) || !StringHelp.IsInteger(_t)) { return(""); } int f = Convert.ToInt32(_f); //房 int t = Convert.ToInt32(_t); //厅 //房>2 if (f > 2) { //厅>=房&&房<5 if (t >= f && f < 5) { t = f - 1; } } else { //厅>房 if (t > f) { t = f; } } if (f >= 7) { return("七房及以上"); } if (f > 4 && f < 7) { return(StringHelp.NumberConvertToChinese(f.ToString()) + "房"); } if (t < 1) { return("单身公寓"); } _houseType = string.Format("{0}房{1}厅", f.ToString(), t.ToString()); return(StringHelp.NumberConvertToChinese(_houseType)); }
/// <summary> /// 检查单价范围(100000>unitPrice>3000) /// </summary> /// <param name="unitPrice"></param> /// <returns></returns> public static bool CheckHouseUnitPrice(string unitPrice) { if (string.IsNullOrEmpty(unitPrice)) { return(false); } unitPrice = StringHelp.TrimBlank(unitPrice); if (!StringHelp.IsInteger(unitPrice)) { return(false); } int _unitPrice = Convert.ToInt32(unitPrice); if (_unitPrice > 3000 && _unitPrice < 100000) { return(true); } return(false); }
/// <summary> /// 检查房屋面积(1000>area>15) /// </summary> /// <param name="area"></param> /// <returns></returns> public static bool CheckHouseArea(string area) { if (string.IsNullOrEmpty(area)) { return(false); } area = StringHelp.TrimBlank(area); if (!StringHelp.IsInteger(area)) { return(false); } int _area = Convert.ToInt32(area); if (_area > 15 && _area < 1000) { return(true); } return(false); }
/// <summary> /// 获取计算住宅用途 /// </summary> /// <param name="area">建筑面积</param> /// <param name="houseType">建筑类型</param> /// <returns></returns> public static string GetHousePurposes(string area, string buildingType) { area = StringHelp.TrimBlank(area); if (!StringHelp.IsInteger(area)) { return(""); } int _area = Convert.ToInt32(area); if (_area > 299 && buildingType.Equals(buildingType4)) { return(housePurposes1);//独立别墅 } if (_area > 199 && buildingType.Equals(buildingType4)) { return(housePurposes2);//联排别墅 } if (_area > 144) { return(housePurposes3); //非普通住宅 } return(housePurposes4); //普通住宅 }
/// <summary> /// 获取建筑类型 /// </summary> /// <param name="sumL">总楼层</param> /// <returns></returns> public static string GetBuildingType(string sumL) { sumL = StringHelp.TrimBlank(sumL); if (!StringHelp.IsInteger(sumL)) { return(""); } int _sumL = Convert.ToInt32(sumL);; if (_sumL > 17) { return(buildingType1);//高层 } if (_sumL > 9) { return(buildingType2);//小高层 } if (_sumL > 3) { return(buildingType3); //多层 } return(buildingType4); //低层 }