Browse Source

热点管理首页的更新,将地域表,数聚场景,数聚子场景,数聚场景和数聚子场景的对应关系在项目一启动就加载进项目

Signed-off-by: you.chen <you.chen@cloudcross.com>
you.chen 9 years ago
parent
commit
237de69db4

+ 81 - 0
src/main/java/com/cloudcross/ssp/listener/InitData.java

@@ -0,0 +1,81 @@
+package com.cloudcross.ssp.listener;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 初始化一些数据,让项目一启动就加载进内存
+ * @author chenyou
+ *
+ */
+public class InitData {
+	private static InitData instance;
+	
+	//用来存储地域的location,cn,cn_city进内存,这里以location为key,value是"cn,cn_city"
+	public static Map<String, String> locationMap = new HashMap<String, String>();
+	//这里存储数聚子场景
+	public static Map<Integer, String> placeMap = new HashMap<Integer, String>();
+	//这里存储数聚场景
+	public static Map<Integer, String> placeClassInfoMap = new HashMap<Integer, String>();
+	//这里存储数聚子场景和数聚场景的对应关系
+	public static Map<Integer, List<Long>> placeClassMap = new HashMap<Integer, List<Long>>();
+	
+	private InitData() {
+		
+	}
+	
+	public InitData getInitDataInstance() {
+		if(null == instance) {
+			instance = new InitData();
+		}
+		
+		return instance;
+	}
+	
+	/**
+	 * 根据省得到location,没有则返回空值
+	 * @param cn
+	 * @return
+	 */
+	public static String getLocation(String cn) {
+		for(Map.Entry<String, String> map : locationMap.entrySet()) {
+			if(map.getValue().equals(cn)) {
+				return map.getKey();
+			}
+		}
+		
+		return null;
+	}
+	
+	
+	/**
+	 * 根据省和市得到location,没有则返回空值
+	 * @param cn
+	 * @return
+	 */
+	public static String getLocation(String cn, String cnCity) {
+		for(Map.Entry<String, String> map : locationMap.entrySet()) {
+			if(map.getValue().equals(cn + "+" + cnCity)) {
+				return map.getKey();
+			}
+		}
+		
+		return null;
+	}
+	
+	/**
+	 * 根据数聚子场景id得到它的数聚场景的名称
+	 * @param placeId
+	 * @return
+	 */
+	public static String getPlaceClassName(Long placeId) {
+		for(Map.Entry<Integer, List<Long>> map : placeClassMap.entrySet()) {
+			if(map.getValue().contains(placeId)) {
+				return InitData.placeClassInfoMap.get(map.getKey());
+			}
+		}
+		
+		return null;
+	}
+}

+ 109 - 0
src/main/java/com/cloudcross/ssp/listener/InitDataListener.java

@@ -0,0 +1,109 @@
+package com.cloudcross.ssp.listener;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.stereotype.Service;
+
+import com.cloudcross.ssp.model.Place;
+import com.cloudcross.ssp.model.PlaceClass;
+import com.cloudcross.ssp.model.PlaceClassInformation;
+import com.cloudcross.ssp.service.IPlaceClassInformationService;
+import com.cloudcross.ssp.service.IPlaceClassService;
+import com.cloudcross.ssp.service.impl.LocationService;
+import com.cloudcross.ssp.service.impl.PlaceService;
+
+/**
+ * 让项目一启动就加载地域,数聚场景和场景的信息,放进内存里
+ * 
+ * @author chenyou
+ *
+ */
+@Service
+public class InitDataListener implements
+		ApplicationListener<ContextRefreshedEvent> {
+	// private static final Logger LOGGER =
+	// Logger.getLogger(PointRateListener.class);
+
+	@Autowired
+	LocationService locationService;
+	@Autowired
+	PlaceService placeService;
+	@Autowired
+	IPlaceClassInformationService placeClassInformationService;
+	@Autowired
+	IPlaceClassService placeClassService;
+
+	/**
+	 * 启动加载执行
+	 */
+	@Override
+	public void onApplicationEvent(ContextRefreshedEvent event) {
+		// 这个防止被加载两次
+		if (event.getApplicationContext().getParent() == null) {
+			// 加载地域信息 ,其中value的值为"cn,cn_city",key的值为location
+			//注:当location字符串的后两位以00结尾时这时的value值只有cn,因为以00结尾的要么是cn和cnCity一样要么是其他
+			List<Map<String, String>> locationList = locationService
+					.findAllLocationAndCnAndCnCity();
+			for (Map<String, String> map : locationList) {
+				if(map.get("location").endsWith("00")) {
+					InitData.locationMap.put(
+							map.get("location"),
+							map.get("cn"));
+				} else {
+				InitData.locationMap.put(
+						map.get("location"),
+						map.get("cn") + "," + map.get("cnCity"));
+				}
+			}
+
+			// 加载数聚子场景信息,key值为数聚子场景的id,value值为数聚子场景名称
+			List<Place> placeList = placeService.findAll();
+			for (int i = 0; i < placeList.size(); i++) {
+				InitData.placeMap.put(placeList.get(i).getId().intValue(),
+						placeList.get(i).getName());
+			}
+
+			// 加载数聚场景信息,key值为数聚场景id,value值为数聚场景名称
+			List<PlaceClassInformation> placeClassInformationList = placeClassInformationService
+					.findAll();
+			for (int i = 0; i < placeClassInformationList.size(); i++) {
+				InitData.placeClassInfoMap
+						.put(placeClassInformationList.get(i).getId()
+								.intValue(), placeClassInformationList.get(i)
+								.getName());
+			}
+
+			// 加载数聚场景和数聚子场景的对应关系key值为数聚场景的id,value值为该数聚场景下的数聚子场景的id的list,如果该数聚场景下的数聚子场景没有则这个list的大小为0
+			List<PlaceClass> placeClassList = placeClassService.findAll();
+			List<Long> list = null;
+			for (int i = 0; i < placeClassList.size(); i++) {
+				if (null == InitData.placeClassMap.get(placeClassList.get(i)
+						.getClassId().intValue())) {
+					list = new ArrayList<Long>();
+					InitData.placeClassMap.put(placeClassList.get(i)
+							.getClassId().intValue(), list);
+				} else {
+					list = InitData.placeClassMap.get(placeClassList.get(i)
+							.getClassId().intValue());
+				}
+
+				list.add(placeClassList.get(i).getPlaceId());
+			}
+
+			for (int i = 1; i <= 31; i++) {
+				System.out.println("include how many:"
+						+ InitData.placeClassMap.get(i).size());
+				for (Long l : InitData.placeClassMap.get(i)) {
+					System.out.print(l + ",");
+				}
+				System.out.println();
+			}
+		}
+	}
+
+}

+ 10 - 0
src/main/java/com/cloudcross/ssp/model/mapper/location.sql.xml

@@ -49,4 +49,14 @@
 	<select id="findAllProvince" resultType="String">
 		select cn from t_location where location1='CN' group by cn order by location2 asc
 	</select>
+	
+	<select id="findAllLocationAndCnAndCnCity" resultType="map">
+		select location, cn, cn_city as cnCity from t_location
+	</select>
+	
+	<select id="findByLocation" parameterType="String" resultType="com.cloudcross.ssp.model.Location">
+		select
+		<include refid="base_column" />
+		from t_location where location = #{location}
+	</select>
 </mapper>

+ 4 - 0
src/main/java/com/cloudcross/ssp/model/mapper/place-class.sql.xml

@@ -15,4 +15,8 @@
 	<select id="selectPlaceIdByClassId" parameterType="java.lang.Long" resultType="java.lang.Long">
 		select place_id as placeId from t_place_class where class_id = #{classId} 
 	</select>
+	
+	<select id="findAll" resultType="PlaceClass">
+		select class_id as classId, place_id as placeId from t_place_class
+	</select>
 </mapper>

+ 135 - 95
src/main/java/com/cloudcross/ssp/model/mapper/wifi.sql.xml

@@ -29,16 +29,13 @@
 		SELECT
 		count(tw.id)
 		FROM
-			t_wifi tw LEFT JOIN t_location tl on tl.location = tw.location
-			LEFT JOIN t_place tp on  tp.id = tw.place_id
-			LEFT JOIN t_place_class tpc on tp.id = tpc.place_id
-			LEFT JOIN t_place_class_info tpci on tpci.id = tpc.class_id
+			t_wifi tw 
 		where tw.status != -1 
-		<if test="cn != null">
-			and tl.cn = #{cn}
-		</if>
+		<if test="location != null">
 		<if test="cnCity != null">
-			and tl.cn_city = #{cnCity}
+			and tw.location = #{location}
+			</if>
+			and tw.location like #{location}
 		</if>
 		<if test="place != null">
 			and tw.place = #{place}
@@ -46,8 +43,12 @@
 		<if test="operatorId != null">
 			and tw.operator_id = #{operatorId}
 		</if>
-		<if test="placeClassId != null">
-			and tpci.id = #{placeClassId}
+		<if test="placeIdList != null">
+		and tw.place_id in
+			<foreach item="id" collection="placeIdList" open="(" separator=","
+			close=")">
+			#{id}
+		</foreach>
 		</if>
 		<if test="mac != null">
 			and tw.apmac like #{mac}
@@ -59,29 +60,24 @@
 			tw.id id,
 			tw.NAME name,
 			tw.SSID SSID,
-			tl.cn cn,
-			tl.cn_city cnCity,
+			tw.location,
 			tw.address address,
 			tw.longitude longitude,
 			tw.latitude latitude,
 			tw.apmac apmac,
 			tw.place place,
-			tp.name placeName,
-			tpci.name as placeClassName,
+			tw.place_id placeId,
 			tw.updated updated,
 			tw.status status,
 			tw.operator_id operatorId
 		FROM
-			t_wifi tw LEFT JOIN t_location tl on tl.location = tw.location
-			LEFT JOIN t_place tp on  tp.id = tw.place_id
-			LEFT JOIN t_place_class tpc on tp.id = tpc.place_id
-			LEFT JOIN t_place_class_info tpci on tpci.id = tpc.class_id
+			t_wifi tw 
 		where tw.status != -1 
-		<if test="cn != null">
-			and tl.cn = #{cn}
-		</if>
-		<if test="cnCity != null">
-			and tl.cn_city = #{cnCity}
+		<if test="location != null">
+			<if test="cnCity != null">
+			and tw.location = #{location}
+			</if>
+			and tw.location like #{location}
 		</if>
 		<if test="place != null">
 			and tw.place = #{place}
@@ -89,8 +85,12 @@
 		<if test="operatorId != null">
 			and tw.operator_id = #{operatorId}
 		</if>
-		<if test="placeClassId != null">
-			and tpci.id = #{placeClassId}
+		<if test="placeIdList != null">
+		and tw.place_id in
+			<foreach item="id" collection="placeIdList" open="(" separator=","
+			close=")">
+			#{id}
+		</foreach>
 		</if>
 		<if test="mac != null">
 			and tw.apmac like #{mac}
@@ -104,29 +104,24 @@
 			tw.id id,
 			tw.NAME name,
 			tw.SSID SSID,
-			tl.cn cn,
-			tl.cn_city cnCity,
+			tw.location,
 			tw.address address,
 			tw.longitude longitude,
 			tw.latitude latitude,
 			tw.apmac apmac,
 			tw.place place,
-			tp.name placeName,
-			tpci.name as placeClassName,
+			tw.place_id placeId,
 			tw.updated updated,
 			tw.status status,
 			tw.operator_id operatorId
 		FROM
-			t_wifi tw LEFT JOIN t_location tl on tl.location = tw.location
-			LEFT JOIN t_place tp on  tp.id = tw.place_id
-			LEFT JOIN t_place_class tpc on tp.id = tpc.place_id
-			LEFT JOIN t_place_class_info tpci on tpci.id = tpc.class_id
+			t_wifi tw 
 		where tw.status != -1 
-		<if test="cn != null">
-			and tl.cn = #{cn}
-		</if>
-		<if test="cnCity != null">
-			and tl.cn_city = #{cnCity}
+		<if test="location != null">
+			<if test="cnCity != null">
+			and tw.location = #{location}
+			</if>
+			and tw.location like #{location}
 		</if>
 		<if test="place != null">
 			and tw.place = #{place}
@@ -134,8 +129,12 @@
 		<if test="operatorId != null">
 			and tw.operator_id = #{operatorId}
 		</if>
-		<if test="placeClassId != null">
-			and tpci.id = #{placeClassId}
+		<if test="placeIdList != null">
+		and tw.place_id in
+			<foreach item="id" collection="placeIdList" open="(" separator=","
+			close=")">
+			#{id}
+		</foreach>
 		</if>
 		<if test="mac != null">
 			and tw.apmac like #{mac}
@@ -144,76 +143,117 @@
 	</select>
 	
 	<select id="countByParamsOperator" parameterType="map" resultType="int">
-		select count(w.id) from t_wifi w, t_location l
-		<where>
-			w.location = l.location and w.status != -1 and w.operator_id = #{operatorId}
-			<if test="cn != null">
-				and l.cn = #{cn}
-			</if> 
+		SELECT
+		count(tw.id)
+		FROM
+			t_wifi tw 
+		where tw.status != -1 and tw.operator_id = #{operatorId}
+		<if test="location != null">
 			<if test="cnCity != null">
-				and l.cn_city = #{cnCity}
-			</if>
-			<if test="placeId != null">
-				and w.place_id = #{placeId}
-			</if>
-			<if test="place != null">
-				and w.place = #{place}
+			and tw.location = #{location}
 			</if>
-			<if test="searchValue != null">
-				and (w.address like #{searchValue} or w.name like #{searchValue})
+			and tw.location like #{location}
+		</if>
+		<if test="place != null">
+			and tw.place = #{place}
+		</if>
+		<if test="placeIdList != null">
+		and tw.place_id in
+			<foreach item="id" collection="placeIdList" open="(" separator=","
+			close=")">
+			#{id}
+		</foreach>
+		</if>
+		<if test="searchValue != null">
+				and (t_wifi.address like #{searchValue} or t_wifi.name like #{searchValue})
 			</if>
-		</where> 
 	</select>
 	
 	<select id="findByParams" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
-		select 
-		<include refid="base_column" />, t_location.cn as cn, t_location.cn_city as cnCity, t_place.name as placeName
-		from t_wifi, t_location, t_place
-		<where>
-			t_wifi.location = t_location.location and t_wifi.place_id = t_place.id
-			and t_wifi.status != -1 and t_wifi.operator_id = #{operatorId}
-			<if test="cn != null">
-				and t_location.cn = #{cn}
-			</if> 
-			<if test="cnCity != null">
-				and t_location.cn_city = #{cnCity}
-			</if>
-			<if test="placeId != null">
-				and t_wifi.place_id = #{placeId}
-			</if>
-			<if test="place != null">
-				and t_wifi.place = #{place}
+		SELECT
+			tw.id id,
+			tw.NAME name,
+			tw.SSID SSID,
+			tw.location,
+			tw.address address,
+			tw.longitude longitude,
+			tw.latitude latitude,
+			tw.apmac apmac,
+			tw.place place,
+			tw.place_id placeId,
+			tw.updated updated,
+			tw.status status,
+			tw.operator_id operatorId
+		FROM
+			t_wifi tw 
+		where tw.status != -1 
+		<if test="location != null">
+		<if test="cnCity != null">
+			and tw.location = #{location}
 			</if>
-			<if test="searchValue != null">
+			and tw.location like #{location}
+		</if>
+		<if test="place != null">
+			and tw.place = #{place}
+		</if>
+		<if test="operatorId != null">
+			and tw.operator_id = #{operatorId}
+		</if>
+		<if test="placeIdList != null">
+		and tw.place_id in
+			<foreach item="id" collection="placeIdList" open="(" separator=","
+			close=")">
+			#{id}
+		</foreach>
+		</if>
+		<if test="searchValue != null">
 				and (t_wifi.address like #{searchValue} or t_wifi.name like #{searchValue})
 			</if>
-		</where> 
-		limit #{pager.offset}, #{pager.limit}
+		 order by tw.id asc
+		 limit #{pager.offset}, #{pager.limit}
 	</select>
 	
 	<select id="findByParams1" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
-		select 
-		<include refid="base_column" />, t_location.cn as cn, t_location.cn_city as cnCity, t_place.name as placeName
-		from t_wifi, t_location, t_place
-		<where>
-			t_wifi.location = t_location.location and t_wifi.place_id = t_place.id
-			and t_wifi.status != -1 and t_wifi.operator_id = #{operatorId}
-			<if test="cn != null">
-				and t_location.cn = #{cn}
-			</if> 
-			<if test="cnCity != null">
-				and t_location.cn_city = #{cnCity}
-			</if>
-			<if test="placeId != null">
-				and t_wifi.place_id = #{placeId}
-			</if>
-			<if test="place != null">
-				and t_wifi.place = #{place}
+		SELECT
+			tw.id id,
+			tw.NAME name,
+			tw.SSID SSID,
+			tw.location,
+			tw.address address,
+			tw.longitude longitude,
+			tw.latitude latitude,
+			tw.apmac apmac,
+			tw.place place,
+			tw.place_id placeId,
+			tw.updated updated,
+			tw.status status,
+			tw.operator_id operatorId
+		FROM
+			t_wifi tw 
+		where tw.status != -1 
+		<if test="location != null">
+		<if test="cnCity != null">
+			and tw.location = #{location}
 			</if>
-			<if test="searchValue != null">
+			and tw.location like #{location}
+		</if>
+		<if test="place != null">
+			and tw.place = #{place}
+		</if>
+		<if test="operatorId != null">
+			and tw.operator_id = #{operatorId}
+		</if>
+		<if test="placeIdList != null">
+		and tw.place_id in
+			<foreach item="id" collection="placeIdList" open="(" separator=","
+			close=")">
+			#{id}
+		</foreach>
+		</if>
+		<if test="searchValue != null">
 				and (t_wifi.address like #{searchValue} or t_wifi.name like #{searchValue})
 			</if>
-		</where> 
+		 order by tw.id asc
 	</select>
 	
 	

+ 13 - 0
src/main/java/com/cloudcross/ssp/service/ILocationService.java

@@ -31,4 +31,17 @@ public interface ILocationService {
 	 * @return
 	 */
 	List<String> findAllProvince();
+	
+	/**
+	 * 找所有的location和省份和城市
+	 * @return
+	 */
+	List<Map<String, String>> findAllLocationAndCnAndCnCity();
+	
+	/**
+	 * 根据location查找
+	 * @param location
+	 * @return
+	 */
+	Location findByLocation(String location);
 }

+ 6 - 0
src/main/java/com/cloudcross/ssp/service/IPlaceClassService.java

@@ -18,4 +18,10 @@ public interface IPlaceClassService extends IGenericService<PlaceClass> {
 	 */
 	boolean deletePlaceClass(Long placeId);
 	public List<Long> queryPlaceIdByClassId(Long classId);
+	
+	/**
+	 * 找出所有的数聚场景和数聚子场景的对应关系
+	 * @return
+	 */
+	List<PlaceClass> findAll();
 }

+ 10 - 0
src/main/java/com/cloudcross/ssp/service/impl/LocationService.java

@@ -54,5 +54,15 @@ public class LocationService implements ILocationService{
 
 	public List<String> findAllProvince() {
 		return ibatisDao.getList("locationSqlMapper.findAllProvince");
+	}
+
+	@Override
+	public List<Map<String, String>> findAllLocationAndCnAndCnCity() {
+		return ibatisDao.getList("locationSqlMapper.findAllLocationAndCnAndCnCity");
+	}
+
+	@Override
+	public Location findByLocation(String location) {
+		return ibatisDao.get("locationSqlMapper.findByLocation", location);
 	}	
 }

+ 5 - 0
src/main/java/com/cloudcross/ssp/service/impl/PlaceClassService.java

@@ -62,4 +62,9 @@ public class PlaceClassService implements IPlaceClassService {
 	public List<Long> queryPlaceIdByClassId(Long classId){
 		return myBatisDao.getList("placeClassSqlMapper.selectPlaceIdByClassId", classId);
 	}
+
+	@Override
+	public List<PlaceClass> findAll() {
+		return myBatisDao.getList("placeClassSqlMapper.findAll");
+	}
 }

+ 88 - 8
src/main/java/com/cloudcross/ssp/web/back/main/ap/ApmacController.java

@@ -31,6 +31,7 @@ import com.cloudcross.ssp.common.utils.Common;
 import com.cloudcross.ssp.common.utils.LangUtil;
 import com.cloudcross.ssp.common.utils.Pager;
 import com.cloudcross.ssp.common.utils.SqlHelper;
+import com.cloudcross.ssp.listener.InitData;
 import com.cloudcross.ssp.model.Account;
 import com.cloudcross.ssp.model.Location;
 import com.cloudcross.ssp.model.Log;
@@ -97,6 +98,8 @@ public class ApmacController extends SimpleController {
 		String place = null;
 		Long placeClassId = null;
 		String placeClassName = null;
+		String location = null;
+		List<Long> placeIdList = null;
 		
 		/**
 		 * 下面对传递过来的几个参数进行处理
@@ -116,20 +119,38 @@ public class ApmacController extends SimpleController {
 			cnCity = String.valueOf(paramMap.get("cnCity"));
 		}
 		
+		//根据cn和cnCity得到它的location
+		if(null != cn || null != cnCity) {
+			if(null != cn && null != cnCity) {
+				location = InitData.getLocation(cn, cnCity);
+			}
+			
+			//如果cnCity等于空则表明是选择该省下的所有的市
+			if(null != cn) {
+				location = InitData.getLocation(cn);
+				location = location.substring(0, (location.length() - 2)) + "%";
+			}
+		}
+		
 		if(null != paramMap.get("placeId") && !"".equals(paramMap.get("placeId"))) {
 			placeClassId = Long.parseLong(String.valueOf(paramMap.get("placeId")));
 		} 
 		
+		//通过数聚场景id得到数聚子场景的id的集合
+		if(null != placeClassId) {
+			placeIdList = InitData.placeClassMap.get(placeClassId.intValue());
+		}
+		
 		if(null != paramMap.get("place") && !"".equals(paramMap.get("place"))) {
 			place = String.valueOf(paramMap.get("place")).trim();
 		}
 		
-		paramMap.put("operatorId", operatorId);
-		paramMap.put("cn", cn);
 		paramMap.put("cnCity", cnCity);
-		paramMap.put("placeClassId", placeClassId);
+		paramMap.put("operatorId", operatorId);
+		paramMap.put("location", location);
+		paramMap.put("placeIdList", placeIdList);
 		paramMap.put("place", place);
-		
+
 		int totalRow = 0;
 		Pager pager = null;
 		pager = new Pager();
@@ -140,6 +161,25 @@ public class ApmacController extends SimpleController {
 		
 		List<Wifi> wifiList = wifiService.findByParamsBack(paramMap, pager);
 		
+		for(Wifi w : wifiList) {
+			//根据location设置它的省和市
+			//注:这里因为如果location是以“00”结尾的话,那它的省份可以确认,但是市的话就不能够直接从内存加载的信息里取
+			if(w.getLocation().endsWith("00")) {
+				Location l = locationService.findByLocation(w.getLocation());
+				w.setCn(l.getCn());
+				w.setCnCity(l.getCnCity());
+			} else {
+				if(null != InitData.locationMap.get(w.getLocation())) {
+				w.setCn(InitData.locationMap.get(w.getLocation()).split(",")[0]);
+				w.setCnCity(InitData.locationMap.get(w.getLocation()).split(",")[1]);
+				}
+			}
+			
+			//根据数聚子场景的id设置数聚场景的名称和数聚子场景的名称
+			w.setPlaceName(InitData.placeMap.get(w.getPlaceId().intValue()));
+			w.setPlaceClassName(InitData.getPlaceClassName(w.getPlaceId()));
+		}
+		
 		//如果下拉框传的是默认值,则回传一个对应的值给前端
 		if(null == operatorId || -1 == operatorId) {
 			operatorName = "全部媒体";
@@ -726,6 +766,8 @@ public class ApmacController extends SimpleController {
 		String place = null;
 		Long placeClassId = null;
 		String placeClassName = null;
+		String location = null;
+		List<Long> placeIdList = null;
 		
 		/**
 		 * 下面对传递过来的几个参数进行处理
@@ -753,6 +795,19 @@ public class ApmacController extends SimpleController {
 			paramMap.put("cnCityName", "全部");
 		}
 
+			// 根据cn和cnCity得到它的location
+			if (null != cn || null != cnCity) {
+				if (null != cn && null != cnCity) {
+					location = InitData.getLocation(cn, cnCity);
+				}
+				
+				//如果cnCity等于空则表明是选择该省下的所有的市
+				if(null != cn) {
+					location = InitData.getLocation(cn);
+					location = location.substring(0, (location.length() - 2)) + "%";
+				}
+			}
+		
 		if (null != paramMap.get("placeClassId")
 				&& !"".equals(paramMap.get("placeClassId"))) {
 			placeClassId = Long.parseLong(String.valueOf(paramMap.get("placeClassId")));
@@ -760,7 +815,13 @@ public class ApmacController extends SimpleController {
 		} else {
 			placeClassName = "全部";
 		}
-
+		
+			// 通过数聚场景id得到数聚子场景的id的集合
+			if (null != placeClassId) {
+				placeIdList = InitData.placeClassMap.get(placeClassId
+						.intValue());
+			}
+		
 		if(null != paramMap.get("place") && !"".equals(paramMap.get("place"))) {
 			place = new String(String.valueOf(paramMap.get("place")).trim().getBytes("ISO-8859-1"),"UTF-8");
 			paramMap.put("placeNameDefinedByOperator", place);
@@ -768,10 +829,10 @@ public class ApmacController extends SimpleController {
 			paramMap.put("placeNameDefinedByOperator", "全部");
 		}
 
-		paramMap.put("operatorId", operatorId);
-		paramMap.put("cn", cn);
 		paramMap.put("cnCity", cnCity);
-		paramMap.put("placeId", placeClassId);
+		paramMap.put("operatorId", operatorId);
+		paramMap.put("location", location);
+		paramMap.put("placeIdList", placeIdList);
 		paramMap.put("place", place);
 		paramMap.put("placeName", placeClassName);
 		paramMap.put("operatorName", operatorName);
@@ -790,6 +851,25 @@ public class ApmacController extends SimpleController {
 		}
 		List<Wifi> wifiList = wifiService.findByParamsBack(paramMap);
 		
+		for(Wifi w : wifiList) {
+			//根据location设置它的省和市
+			//注:这里因为如果location是以“00”结尾的话,那它的省份可以确认,但是市的话就不能够直接从内存加载的信息里取
+			if(w.getLocation().endsWith("00")) {
+				Location l = locationService.findByLocation(w.getLocation());
+				w.setCn(l.getCn());
+				w.setCnCity(l.getCnCity());
+			} else {
+				if(null != InitData.locationMap.get(w.getLocation())) {
+					w.setCn(InitData.locationMap.get(w.getLocation()).split(",")[0]);
+					w.setCnCity(InitData.locationMap.get(w.getLocation()).split(",")[1]);
+					}
+			}
+			
+			//根据数聚子场景的id设置数聚场景的名称和数聚子场景的名称
+			w.setPlaceName(InitData.placeMap.get(w.getPlaceId().intValue()));
+			w.setPlaceClassName(InitData.getPlaceClassName(w.getPlaceId()));
+		}
+		
 		paramMap.put("dataList", wifiList);
 		response.reset();
 		// Content-Type:application/vnd.ms-excel;charset=utf8或者text/xml;charset=utf8

+ 96 - 15
src/main/java/com/cloudcross/ssp/web/operator/main/ap/ApmacController.java

@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import com.cloudcross.ssp.listener.InitData;
 import com.cloudcross.ssp.model.Account;
 import com.cloudcross.ssp.base.utils.freemarker.FreemarkerTemplateProcessor;
 import com.cloudcross.ssp.base.web.SimpleController;
@@ -39,6 +40,7 @@ import com.cloudcross.ssp.model.pojo.PlaceNamePojo;
 import com.cloudcross.ssp.service.ILocationService;
 import com.cloudcross.ssp.service.ILogService;
 import com.cloudcross.ssp.service.IOperatorService;
+import com.cloudcross.ssp.service.IPlaceClassInformationService;
 import com.cloudcross.ssp.service.IPlaceOperatorService;
 import com.cloudcross.ssp.service.IPlaceService;
 import com.cloudcross.ssp.service.IWifiService;
@@ -65,7 +67,7 @@ public class ApmacController extends SimpleController {
 	@Autowired
 	private FreemarkerTemplateProcessor templateProcessor;
 	@Autowired
-	private IPlaceService placeService;
+	private IPlaceClassInformationService placeClassInformationService;
 	@Autowired
 	private IOperatorService operatorService;
 	
@@ -90,9 +92,12 @@ public class ApmacController extends SimpleController {
 		String cn = null;
 		String cnCity = null;
 		String place = null;
-		Long placeId = null;
+		Long placeClassId = null;
 		String placeName = null;
 		String searchValue = null;
+		String location = null;
+		List<Long> placeIdList = null;
+		
 		/**
 		 * 下面对传递过来的几个参数进行处理
 		 */
@@ -104,17 +109,35 @@ public class ApmacController extends SimpleController {
 			cnCity = String.valueOf(paramMap.get("cnCity"));
 		}
 		
+		// 根据cn和cnCity得到它的location
+		if (null != cn || null != cnCity) {
+			if (null != cn && null != cnCity) {
+				location = InitData.getLocation(cn, cnCity);
+			}
+			
+			//如果cn不空,cnCity为空则表明应该是选该省下的所有的市
+			if (null != cn) {
+				location = InitData.getLocation(cn);
+				location = location.substring(0, (location.length() - 2)) + "%";
+			}
+		}
+		
 		if(null != paramMap.get("placeId") && !"".equals(paramMap.get("placeId"))) {
-			placeId = Long.parseLong(String.valueOf(paramMap.get("placeId")));
+			placeClassId = Long.parseLong(String.valueOf(paramMap.get("placeId")));
 		} 
 		
+		// 通过数聚场景id得到数聚子场景的id的集合
+		if (null != placeClassId) {
+			placeIdList = InitData.placeClassMap.get(placeClassId.intValue());
+		}
+		
 		if(null != paramMap.get("place") && !"".equals(paramMap.get("place"))) {
 			place = String.valueOf(paramMap.get("place")).trim();
 		}
 		
-		paramMap.put("cn", cn);
 		paramMap.put("cnCity", cnCity);
-		paramMap.put("placeId", placeId);
+		paramMap.put("location", location);
+		paramMap.put("placeIdList", placeIdList);
 		paramMap.put("place", place);
 		
 		//按热点名称和详细地址搜索
@@ -136,6 +159,25 @@ public class ApmacController extends SimpleController {
 		
 		List<Wifi> wifiList = wifiService.findByParamsOperator(paramMap, pager);
 		
+		for(Wifi w : wifiList) {
+			//根据location设置它的省和市
+			//注:这里因为如果location是以“00”结尾的话,那它的省份可以确认,但是市的话就不能够直接从内存加载的信息里取
+			if(w.getLocation().endsWith("00")) {
+				Location l = locationService.findByLocation(w.getLocation());
+				w.setCn(l.getCn());
+				w.setCnCity(l.getCnCity());
+			} else {
+				if(null != InitData.locationMap.get(w.getLocation())) {
+					w.setCn(InitData.locationMap.get(w.getLocation()).split(",")[0]);
+					w.setCnCity(InitData.locationMap.get(w.getLocation()).split(",")[1]);
+					}
+			}
+			
+			//根据数聚子场景的id设置数聚场景的名称和数聚子场景的名称
+			w.setPlaceName(InitData.placeMap.get(w.getPlaceId().intValue()));
+			w.setPlaceClassName(InitData.getPlaceClassName(w.getPlaceId()));
+		}
+		
 		//如果下拉框传的是默认值,则回传一个对应的值给前端
 		if(null == cn) {
 			cn = "省";
@@ -149,10 +191,10 @@ public class ApmacController extends SimpleController {
 			place = "场景";
 		}
 		
-		if(null == placeId) {
+		if(null == placeClassId) {
 			placeName = "数聚场景";
 		} else {
-			placeName = placeService.findById(placeId).getName();
+			placeName = placeClassInformationService.findById(placeClassId).getName();
 		}
 		
 		
@@ -711,8 +753,10 @@ public class ApmacController extends SimpleController {
 
 		String cn = null;
 		String cnCity = null;
-		Long placeId = null;
+		Long placeClassId = null;
 		String place = null;
+		String location = null;
+		List<Long> placeIdList = null;
 
 		/**
 		 * 下面对传递过来的几个参数进行处理
@@ -733,26 +777,44 @@ public class ApmacController extends SimpleController {
 				paramMap.put("cnCityName", "全部");
 			}
 	
+			// 根据cn和cnCity得到它的location
+			if (null != cn || null != cnCity) {
+				if (null != cn && null != cnCity) {
+					location = InitData.getLocation(cn, cnCity);
+				}
+				
+				//如果cn不空,cnCity为空则表明应该是选该省下的所有的市
+				if (null != cn) {
+					location = InitData.getLocation(cn);
+					location = location.substring(0, (location.length() - 2)) + "%";
+				}
+			}
+			
 			if (null != paramMap.get("placeId")
 					&& !"".equals(paramMap.get("placeId"))) {
-				placeId = Long.parseLong(String.valueOf(paramMap.get("placeId")));
+				placeClassId = Long.parseLong(String.valueOf(paramMap.get("placeId")));
 			}
 	
+			// 通过数聚场景id得到数聚子场景的id的集合
+			if (null != placeClassId) {
+				placeIdList = InitData.placeClassMap.get(placeClassId.intValue());
+			}
+			
 			if(null != paramMap.get("place") && !"".equals(paramMap.get("place"))) {
 				place = new String(String.valueOf(paramMap.get("place")).trim().getBytes("ISO-8859-1"),"UTF-8");
 				paramMap.put("placeNameDefinedByOperator", place);
 			} else {
 				paramMap.put("placeNameDefinedByOperator", "全部");
 			}
-	
-			paramMap.put("cn", cn);
+			
 			paramMap.put("cnCity", cnCity);
-			paramMap.put("placeId", placeId);
+			paramMap.put("location", location);
+			paramMap.put("placeClassId", placeClassId);
 			paramMap.put("place", place);
 			
 			//如果数聚场景id不为空则根据场景id找对应的名称
-			if(null != placeId) {
-				paramMap.put("placeName", placeService.findById(placeId).getName());
+			if(null != placeClassId) {
+				paramMap.put("placeName", placeClassInformationService.findById(placeClassId).getName());
 			} else {
 				paramMap.put("placeName", "全部");
 			}
@@ -771,6 +833,25 @@ public class ApmacController extends SimpleController {
 		}
 		List<Wifi> wifiList = wifiService.findByParams(paramMap);
 		
+		for(Wifi w : wifiList) {
+			//根据location设置它的省和市
+			//注:这里因为如果location是以“00”结尾的话,那它的省份可以确认,但是市的话就不能够直接从内存加载的信息里取
+			if(w.getLocation().endsWith("00")) {
+				Location l = locationService.findByLocation(w.getLocation());
+				w.setCn(l.getCn());
+				w.setCnCity(l.getCnCity());
+			} else {
+				if(null != InitData.locationMap.get(w.getLocation())) {
+					w.setCn(InitData.locationMap.get(w.getLocation()).split(",")[0]);
+					w.setCnCity(InitData.locationMap.get(w.getLocation()).split(",")[1]);
+					}
+			}
+			
+			//根据数聚子场景的id设置数聚场景的名称和数聚子场景的名称
+			w.setPlaceName(InitData.placeMap.get(w.getPlaceId().intValue()));
+			w.setPlaceClassName(InitData.getPlaceClassName(w.getPlaceId()));
+		}
+		
 		paramMap.put("dataList", wifiList);
 		response.reset();
 		// Content-Type:application/vnd.ms-excel;charset=utf8或者text/xml;charset=utf8
@@ -781,7 +862,7 @@ public class ApmacController extends SimpleController {
 		response.setHeader("Content-Disposition", "attachment;filename="
 				+ fileName + ".xls");
 		// 需要对excel的列的总数进行指定
-		int column = 13;
+		int column = 14;
 		paramMap.put("dataSize", (wifiList.size() + 100));
 		paramMap.put("column", column);
 

+ 3 - 33
src/main/resources/application.properties

@@ -5,8 +5,8 @@ global.encoding=UTF-8
 #database setting
 jdbc.driver=com.mysql.jdbc.Driver
 jdbc.username=ssp_test
-jdbc.password=1q2w3e4r
-jdbc.url=jdbc:mysql://test.dc.loc:3306/ssp?useUnicode=true&amp;characterEncoding=UTF-8
+jdbc.password=1234qwer
+jdbc.url=jdbc:mysql://122.144.134.135:3306/ssp?useUnicode=true&amp;characterEncoding=UTF-8
 
 #mail server setting
 mail.server=smtp.163.com
@@ -28,34 +28,4 @@ resource.upload.dir=upload
 code.address = http://120.131.84.229
 #code.address = http://adx.datacross.cn
 
-#to be used
-global.locale=zh_CN
-global.encoding=UTF-8
-
-#database setting
-jdbc.driver=com.mysql.jdbc.Driver
-jdbc.username=ssp_test
-jdbc.password=1q2w3e4r
-jdbc.url=jdbc:mysql://test.dc.loc:3306/ssp?useUnicode=true&amp;characterEncoding=UTF-8
-
-#mail server setting
-mail.server=smtp.163.com
-mail.server.user=a502817870@163.com
-mail.server.password=MyLove520
-mail.from=a502817870@163.com
-mail.from.name=\u6D4B\u8BD5\u90AE\u4EF6
-mail.template.folder=mail
-
-#freemarker template setting
-template.load.dir=classpath:/template
-
-#where are resource upload into, relative to classpath
-resource.upload.domain=ssp.datacross.cn
-resource.upload.port=8080
-resource.upload.dir=upload
-
-#code address
-code.address = http://120.131.84.229
-#code.address = http://adx.datacross.cn
-
-#
+#