|
@@ -0,0 +1,833 @@
|
|
|
+package com.cloudcross.ssp.web.back.main.ap;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.PrintWriter;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.apache.commons.lang.ArrayUtils;
|
|
|
+import org.apache.log4j.Logger;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
+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.base.utils.freemarker.FreemarkerTemplateProcessor;
|
|
|
+import com.cloudcross.ssp.base.web.SimpleController;
|
|
|
+import com.cloudcross.ssp.common.consts.Status;
|
|
|
+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.model.Account;
|
|
|
+import com.cloudcross.ssp.model.Location;
|
|
|
+import com.cloudcross.ssp.model.Log;
|
|
|
+import com.cloudcross.ssp.model.PlaceOperator;
|
|
|
+import com.cloudcross.ssp.model.Wifi;
|
|
|
+import com.cloudcross.ssp.service.ILocationService;
|
|
|
+import com.cloudcross.ssp.service.ILogService;
|
|
|
+import com.cloudcross.ssp.service.IOperatorService;
|
|
|
+import com.cloudcross.ssp.service.IPlaceOperatorService;
|
|
|
+import com.cloudcross.ssp.service.IPlaceService;
|
|
|
+import com.cloudcross.ssp.service.IWifiService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 热点管理相关控制器
|
|
|
+ * @author chenyou
|
|
|
+ *
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping("/main/ap/apmac")
|
|
|
+public class ApmacController extends SimpleController {
|
|
|
+ private static final Logger LOG = Logger.getLogger(ApmacController.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IWifiService wifiService;
|
|
|
+ @Autowired
|
|
|
+ private ILogService logService;
|
|
|
+ @Autowired
|
|
|
+ private ILocationService locationService;
|
|
|
+ @Autowired
|
|
|
+ private IPlaceOperatorService placeOperatorService;
|
|
|
+ @Autowired
|
|
|
+ private FreemarkerTemplateProcessor templateProcessor;
|
|
|
+ @Autowired
|
|
|
+ private IPlaceService placeService;
|
|
|
+ @Autowired
|
|
|
+ private IOperatorService operatorService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 热点详情的列表页
|
|
|
+ * 前端要传递几个参数,分别所选媒体的媒体Id(变量名为selectedOperatorId),省(变量名为cn),市(变量名为cnCity),场景(变量名为place,这个是运营商定义的场景名称,传过来传个场景名称就行),
|
|
|
+ * 数聚场景id(变量名为placeId)
|
|
|
+ * 还有一个搜索参数,按mac地址搜索
|
|
|
+ * 注:如果传过来的参数是空值或者空字符串或者没传,则按默认值进行搜索,默认的为全部
|
|
|
+ * @param model
|
|
|
+ * @param paramMap
|
|
|
+ * @param page
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/list")
|
|
|
+ public String list(Model model, @RequestParam HashMap<String, Object> paramMap,
|
|
|
+ @RequestParam(defaultValue = "1") int page) {
|
|
|
+
|
|
|
+ Long operatorId = null;
|
|
|
+ String operatorName = null;
|
|
|
+ String cn = null;
|
|
|
+ String cnCity = null;
|
|
|
+ String place = null;
|
|
|
+ Long placeId = null;
|
|
|
+ String placeName = null;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下面对传递过来的几个参数进行处理
|
|
|
+ */
|
|
|
+ if(null != paramMap.get("selectedOperatorId") && !"".equals(paramMap.get("selectedOperatorId"))) {
|
|
|
+ operatorId = Long.parseLong(String.valueOf(paramMap.get("selectedOperatorId")));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null != paramMap.get("cn") && !"".equals(paramMap.get("cn"))) {
|
|
|
+ cn = String.valueOf(paramMap.get("cn"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null != paramMap.get("cnCity") && !"".equals(paramMap.get("cnCity"))) {
|
|
|
+ cnCity = String.valueOf(paramMap.get("cnCity"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null != paramMap.get("placeId") && !"".equals(paramMap.get("placeId"))) {
|
|
|
+ placeId = Long.parseLong(String.valueOf(paramMap.get("placeId")));
|
|
|
+ }
|
|
|
+
|
|
|
+ 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("placeId", placeId);
|
|
|
+ paramMap.put("place", place);
|
|
|
+
|
|
|
+ //按热点名称和详细地址搜索
|
|
|
+ if(null != paramMap.get("searchValue") && !"".equals(paramMap.get("searchValue"))) {
|
|
|
+ String name = (String) paramMap.get("searchValue");
|
|
|
+ paramMap.put("searchValue", SqlHelper.doLike(name.trim()));
|
|
|
+ } else {
|
|
|
+ paramMap.put("searchValue", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ int totalRow = 0;
|
|
|
+ Pager pager = null;
|
|
|
+ pager = new Pager();
|
|
|
+ //查询符合条件的总的条数
|
|
|
+ totalRow = wifiService.countByParamsBack(paramMap);
|
|
|
+ pager.setPage(page);
|
|
|
+ pager.setTotalRow(totalRow);
|
|
|
+
|
|
|
+ List<Wifi> wifiList = wifiService.findByParamsBack(paramMap, pager);
|
|
|
+
|
|
|
+ //如果下拉框传的是默认值,则回传一个对应的值给前端
|
|
|
+ if(null == operatorId) {
|
|
|
+ operatorName = "全部媒体";
|
|
|
+ } else {
|
|
|
+ operatorName = operatorService.findById(operatorId).getCompanyName();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null == cn) {
|
|
|
+ cn = "省";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null == cnCity) {
|
|
|
+ cnCity = "市";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null == place) {
|
|
|
+ place = "场景";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null == placeId) {
|
|
|
+ placeName = "数聚场景";
|
|
|
+ } else {
|
|
|
+ placeName = placeService.findById(placeId).getName();
|
|
|
+ }
|
|
|
+
|
|
|
+ paramMap.put("operatorName", operatorName);
|
|
|
+ paramMap.put("cn", cn);
|
|
|
+ paramMap.put("cnCity", cnCity);
|
|
|
+ paramMap.put("place", place);
|
|
|
+ paramMap.put("placeName", placeName);
|
|
|
+ model.addAttribute("pager",pager);
|
|
|
+ model.addAllAttributes(paramMap);
|
|
|
+ model.addAttribute("wifiList", wifiList);
|
|
|
+
|
|
|
+ return page("list");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 前端传递一个媒体的id(变量名为selectedOperatorId),默认为全部
|
|
|
+ * 需要传递一个搜索的参数,可以按场景(name)搜索和数据场景(placeName)搜索
|
|
|
+ * @param model
|
|
|
+ * @param page
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/relationship")
|
|
|
+ public String relationship(Model model, @RequestParam HashMap<String, Object> paramMap,
|
|
|
+ @RequestParam(defaultValue = "1") int page) {
|
|
|
+ Long operatorId = null;
|
|
|
+ String operatorName = null;
|
|
|
+ /**
|
|
|
+ * 对传入的搜索参数做处理,如果传递的是空值或者空字符串的话就设为空
|
|
|
+ */
|
|
|
+ if(null == paramMap.get("selectedOperatorId") || "".equals(paramMap.get("selectedOperatorId"))) {
|
|
|
+ operatorName = "全部";
|
|
|
+ } else {
|
|
|
+ operatorId = Long.parseLong(String.valueOf(paramMap.get("selectedOperatorId")));
|
|
|
+ operatorName = operatorService.findById(operatorId).getCompanyName();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 按热点场景和数聚场景搜索
|
|
|
+ if (null != paramMap.get("searchValue")
|
|
|
+ && !"".equals(paramMap.get("searchValue"))) {
|
|
|
+ String searchValue = (String) paramMap.get("searchValue");
|
|
|
+ paramMap.put("searchValue", SqlHelper.doLike(searchValue.trim()));
|
|
|
+ } else {
|
|
|
+ paramMap.put("searchValue", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ paramMap.put("operatorId", operatorId);
|
|
|
+ paramMap.put("operatorName", operatorName);
|
|
|
+ int totalRow = 0;
|
|
|
+ Pager pager = null;
|
|
|
+ pager = new Pager();
|
|
|
+ //查询符合条件的总的条数
|
|
|
+ totalRow = placeOperatorService.countByParams(paramMap);
|
|
|
+ pager.setPage(page);
|
|
|
+ pager.setTotalRow(totalRow);
|
|
|
+ List<PlaceOperator> placeOperatorList = placeOperatorService.findByParams(paramMap, pager);
|
|
|
+ model.addAttribute("placeOperatorList", placeOperatorList);
|
|
|
+ return page("relationship");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找所有的省
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/cn")
|
|
|
+ public @ResponseBody
|
|
|
+ Map<String, List<String>> findAllProvince() {
|
|
|
+ List<String> provinceList = locationService.findAllProvince();
|
|
|
+ Map<String, List<String>> map = new HashMap<String, List<String>>();
|
|
|
+ map.put("province", provinceList);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找该省下的所有城市
|
|
|
+ * @param province
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/city")
|
|
|
+ public @ResponseBody
|
|
|
+ Map<String, List<String>> findCityByProvince(@RequestParam String province) {
|
|
|
+ //这里如果传递过来的参数是空值或者空字符串则返回一个空值
|
|
|
+ if(null == province || "".equals(province)) {
|
|
|
+ System.out.println("传递的参数出错");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> cityList = locationService.findCityByProvince(province);
|
|
|
+ Map<String, List<String>> map = new HashMap<String, List<String>>();
|
|
|
+ map.put("city", cityList);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找所有的场景
|
|
|
+ * 这里必须传递一个运营商id,因为是搜索某一个运营商下的场景
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/place")
|
|
|
+ public @ResponseBody
|
|
|
+ Map<String, List<String>> findPlaceDefinedByOperator(@RequestParam Long operatorId) {
|
|
|
+ if(null == operatorId) {
|
|
|
+ System.out.println("传递的参数为空");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> placeList = placeOperatorService.findPlaceByOperator(operatorId);
|
|
|
+ Map<String, List<String>> map = new HashMap<String, List<String>>();
|
|
|
+ map.put("place", placeList);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找所有与该运营商下的所有的场景对应的云联定义的数聚场景
|
|
|
+ * 这里必须传递一个运营商id,因为是搜索某一个运营商下的场景
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/placeName")
|
|
|
+ public @ResponseBody
|
|
|
+ List<Map<Long, String>> placeName(@RequestParam Long operatorId) {
|
|
|
+ if(null == operatorId) {
|
|
|
+ System.out.println("传递的参数为空");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<Long, String>> placeNameList = placeOperatorService.findPlace(operatorId);
|
|
|
+ return placeNameList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量开启热点
|
|
|
+ * @param request
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/enable")
|
|
|
+ public @ResponseBody
|
|
|
+ String enable(HttpServletRequest request,Long[] id) {
|
|
|
+ if (ArrayUtils.isNotEmpty(id)) {
|
|
|
+ //循环得到热点名称
|
|
|
+ List<String> wifiNameList = new ArrayList<String>();
|
|
|
+
|
|
|
+ for(int i = 0; i < id.length; i++) {
|
|
|
+ Wifi wifi = wifiService.findById(id[i]);
|
|
|
+ wifiNameList.add(wifi.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果开启成功,则增加对应的修改记录
|
|
|
+ if(wifiService.updateStatus(LangUtil.array2List(id),
|
|
|
+ Status.enable.value)) {
|
|
|
+ for(int i = 0; i < id.length; i++) {
|
|
|
+ Log log = new Log();
|
|
|
+ //对应模块,这里应该是热点模块
|
|
|
+ log.setModule("Ap");
|
|
|
+ //对应的表名,这里是t_wifi
|
|
|
+ log.setTableName("t_wifi");
|
|
|
+ //对应的热点的id
|
|
|
+ log.setRecordId(id[i]);
|
|
|
+ //对应的操作类型
|
|
|
+ log.setActionType("开启");
|
|
|
+ //得到该热点的媒体公司名称
|
|
|
+ String operatorName = operatorService.findById(wifiService.findById(id[i]).getOperatorId()).getCompanyName();
|
|
|
+ //变更详情
|
|
|
+ log.setAction("开启了" + operatorName + "中的热点:" + wifiNameList.get(i));
|
|
|
+ log.setActionTime("100");
|
|
|
+ log.setAccountId(new Long(getLoginUser().getId()));
|
|
|
+ log.setUserIp(Common.toIpAddr(request));
|
|
|
+ log.setAccountName(getLoginUser().getAccountName());
|
|
|
+ logService.add(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量暂停热点
|
|
|
+ * @param request
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/disable")
|
|
|
+ public @ResponseBody
|
|
|
+ String disable(HttpServletRequest request,Long[] id) {
|
|
|
+ if (ArrayUtils.isNotEmpty(id)) {
|
|
|
+ //循环得到热点名称
|
|
|
+ List<String> wifiNameList = new ArrayList<String>();
|
|
|
+
|
|
|
+ for(int i = 0; i < id.length; i++) {
|
|
|
+ Wifi wifi = wifiService.findById(id[i]);
|
|
|
+ wifiNameList.add(wifi.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果开启成功,则增加对应的修改记录
|
|
|
+ if(wifiService.updateStatus(LangUtil.array2List(id),
|
|
|
+ Status.disable.value)) {
|
|
|
+ for(int i = 0; i < id.length; i++) {
|
|
|
+ Log log = new Log();
|
|
|
+ //对应模块,这里应该是热点模块
|
|
|
+ log.setModule("Ap");
|
|
|
+ //对应的表名,这里是t_wifi
|
|
|
+ log.setTableName("t_wifi");
|
|
|
+ //对应的热点的id
|
|
|
+ log.setRecordId(id[i]);
|
|
|
+ //对应的操作类型
|
|
|
+ log.setActionType("暂停");
|
|
|
+ //得到该热点的媒体公司名称
|
|
|
+ String operatorName = operatorService.findById(wifiService.findById(id[i]).getOperatorId()).getCompanyName();
|
|
|
+ //变更详情
|
|
|
+ log.setAction("暂停了" + operatorName + "中的热点:" + wifiNameList.get(i));
|
|
|
+ log.setActionTime("100");
|
|
|
+ log.setAccountId(new Long(getLoginUser().getId()));
|
|
|
+ log.setUserIp(Common.toIpAddr(request));
|
|
|
+ log.setAccountName(getLoginUser().getAccountName());
|
|
|
+ logService.add(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除时只是把这些选中的行的状态改为-1,并没有把它从表里面删掉
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/delete")
|
|
|
+ public @ResponseBody
|
|
|
+ String delete(HttpServletRequest request, Long[] id) {
|
|
|
+ if (ArrayUtils.isNotEmpty(id)) {
|
|
|
+ //循环得到热点名称
|
|
|
+ List<String> wifiNameList = new ArrayList<String>();
|
|
|
+
|
|
|
+ for(int i = 0; i < id.length; i++) {
|
|
|
+ Wifi wifi = wifiService.findById(id[i]);
|
|
|
+ wifiNameList.add(wifi.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果开启成功,则增加对应的修改记录
|
|
|
+ if(wifiService.updateStatus(LangUtil.array2List(id),
|
|
|
+ Status.delete.value)) {
|
|
|
+ for(int i = 0; i < id.length; i++) {
|
|
|
+ Log log = new Log();
|
|
|
+ //对应模块,这里应该是热点模块
|
|
|
+ log.setModule("Ap");
|
|
|
+ //对应的表名,这里是t_wifi
|
|
|
+ log.setTableName("t_wifi");
|
|
|
+ //对应的热点的id
|
|
|
+ log.setRecordId(id[i]);
|
|
|
+ //对应的操作类型
|
|
|
+ log.setActionType("删除");
|
|
|
+ //得到该热点的媒体公司名称
|
|
|
+ String operatorName = operatorService.findById(wifiService.findById(id[i]).getOperatorId()).getCompanyName();
|
|
|
+ //变更详情
|
|
|
+ log.setAction("删除了" + operatorName + "中的热点:" + wifiNameList.get(i));
|
|
|
+ log.setActionTime("100");
|
|
|
+ log.setAccountId(new Long(getLoginUser().getId()));
|
|
|
+ log.setUserIp(Common.toIpAddr(request));
|
|
|
+ log.setAccountName(getLoginUser().getAccountName());
|
|
|
+ logService.add(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 跳转到编辑的页面
|
|
|
+ * @param model
|
|
|
+ * @param paramMap
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/edit")
|
|
|
+ public String edit(Model model, @RequestParam Long id) {
|
|
|
+ Wifi wifi = wifiService.findById(id);
|
|
|
+ model.addAttribute("wifi", wifi);
|
|
|
+ return page("edit");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 跳转到创建热点页面
|
|
|
+ * @param model
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/create")
|
|
|
+ public String edit(Model model) {
|
|
|
+ return page("create");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping("/save")
|
|
|
+ public String save(HttpServletRequest request,@ModelAttribute("form") Wifi wifi) {
|
|
|
+ if(null == wifi.getId()) {
|
|
|
+ //创建时保存数据
|
|
|
+ //通过得到的省和市的名称得到对应的location
|
|
|
+ Map<String, String> paramMap = new HashMap<String, String>();
|
|
|
+ paramMap.put("cn", wifi.getCn().trim());
|
|
|
+ paramMap.put("cnCity", wifi.getCnCity().trim());
|
|
|
+ Location location = locationService.findByCnAndCnCity(paramMap);
|
|
|
+ wifi.setLocation(location.getLocation());
|
|
|
+ //根据运营商命名的场景名称和运营商id得到云联定义的场景名称对应的id
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("name", wifi.getPlace());
|
|
|
+ map.put("operatorId", wifi.getOperatorId());
|
|
|
+ Long placeId = placeOperatorService.findByNameAndOperatorId(map);
|
|
|
+ wifi.setPlaceId(placeId);
|
|
|
+ wifi.setUpdated(new Date());
|
|
|
+
|
|
|
+ wifiService.add(wifi);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建成功后增加创建的日志
|
|
|
+ */
|
|
|
+ Log log = new Log();
|
|
|
+ //对应模块,这里应该是热点模块
|
|
|
+ log.setModule("Ap");
|
|
|
+ //对应的表名,这里是t_wifi
|
|
|
+ log.setTableName("t_wifi");
|
|
|
+ //对应的热点的id
|
|
|
+ log.setRecordId(wifi.getId());
|
|
|
+ //对应的操作类型
|
|
|
+ log.setActionType("创建");
|
|
|
+ log.setActionTime("100");
|
|
|
+ log.setAccountId(new Long(getLoginUser().getId()));
|
|
|
+ log.setUserIp(Common.toIpAddr(request));
|
|
|
+ log.setAccountName(getLoginUser().getAccountName());
|
|
|
+ //创建详情
|
|
|
+ log.setAction("在媒体" + operatorService.findById(wifi.getOperatorId()).getCompanyName() + "中创建了一个热点,热点名称为" + wifi.getName());
|
|
|
+ logService.add(log);
|
|
|
+
|
|
|
+ return redirect(page("list"));
|
|
|
+ } else {
|
|
|
+ //编辑后保存数据
|
|
|
+ //先得到编辑前的数据
|
|
|
+ Wifi formerWifi = wifiService.findById(wifi.getId());
|
|
|
+
|
|
|
+ //通过得到的省和市的名称得到对应的location
|
|
|
+ Map<String, String> paramMap = new HashMap<String, String>();
|
|
|
+ paramMap.put("cn", wifi.getCn().trim());
|
|
|
+ paramMap.put("cnCity", wifi.getCnCity().trim());
|
|
|
+ Location location = locationService.findByCnAndCnCity(paramMap);
|
|
|
+ wifi.setLocation(location.getLocation());
|
|
|
+
|
|
|
+ wifi.setPlace(wifi.getPlace().trim());
|
|
|
+ //根据运营商命名的场景名称和运营商id得到云联定义的场景名称对应的id
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("name", wifi.getPlace());
|
|
|
+ map.put("operatorId", wifi.getOperatorId());
|
|
|
+ Long placeId = placeOperatorService.findByNameAndOperatorId(map);
|
|
|
+ wifi.setPlaceId(placeId);
|
|
|
+
|
|
|
+ wifiService.edit(wifi);
|
|
|
+
|
|
|
+ //得到编辑后的热点对象
|
|
|
+ Wifi presentWifi = wifiService.findById(wifi.getId());
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑成功后,对比编辑前后的数据,如果发生了改变,则增加修改日志
|
|
|
+ */
|
|
|
+ Log log = new Log();
|
|
|
+ //对应模块,这里应该是热点模块
|
|
|
+ log.setModule("Ap");
|
|
|
+ //对应的表名,这里是t_wifi
|
|
|
+ log.setTableName("t_wifi");
|
|
|
+ //对应的热点的id
|
|
|
+ log.setRecordId(wifi.getId());
|
|
|
+ //对应的操作类型
|
|
|
+ log.setActionType("编辑");
|
|
|
+ log.setActionTime("100");
|
|
|
+ log.setAccountId(new Long(getLoginUser().getId()));
|
|
|
+ log.setUserIp(Common.toIpAddr(request));
|
|
|
+ log.setAccountName(getLoginUser().getAccountName());
|
|
|
+
|
|
|
+ //记录变更详情
|
|
|
+ String action = "对"+ operatorService.findById(formerWifi.getOperatorId()).getCompanyName() +"中的热点" + formerWifi.getName() + "进行了修改: ";
|
|
|
+ //变更标志,默认为false表示没有进行修改
|
|
|
+ boolean updatedMark = false;
|
|
|
+
|
|
|
+ //热点名称的比较
|
|
|
+ if(!(formerWifi.getName().equals(presentWifi.getName()))) {
|
|
|
+ action = "对热点的名称做了修改,将" + formerWifi.getName() + " ---> " + presentWifi.getName();
|
|
|
+ updatedMark = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ //省、市的比较
|
|
|
+ if(!(formerWifi.getLocation().equals(presentWifi.getLocation()))) {
|
|
|
+ action = "对热点的省、市进行了修改,将" + formerWifi.getCn() + " 和 " + formerWifi.getCnCity() + "--->"
|
|
|
+ + presentWifi.getCn() + " 和 " + presentWifi.getCnCity();
|
|
|
+ updatedMark = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ //详细地址的比较
|
|
|
+ if(!(formerWifi.getAddress().equals(presentWifi.getAddress()))) {
|
|
|
+ action = "对热点的详细地址进行了修改,将" + formerWifi.getAddress() + "--->"
|
|
|
+ + presentWifi.getAddress();
|
|
|
+ updatedMark = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ //经纬度的比较
|
|
|
+ if(!(formerWifi.getLongitude().equals(presentWifi.getLongitude())) || !(formerWifi.getLatitude().equals(presentWifi.getLatitude()))) {
|
|
|
+ action = "对热点的经纬度进行了修改,将经度" + formerWifi.getLongitude() + " 和纬度 " + formerWifi.getLatitude() + "--->"
|
|
|
+ + presentWifi.getLongitude() + " 和 " + presentWifi.getLatitude();
|
|
|
+ updatedMark = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ //场景的比较
|
|
|
+ if(!(formerWifi.getPlace().equals(presentWifi.getPlace()))) {
|
|
|
+ action = "对热点的场景名称进行了修改,将" + formerWifi.getPlace() + "--->"
|
|
|
+ + presentWifi.getPlace();
|
|
|
+ updatedMark = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ log.setAction(action);
|
|
|
+
|
|
|
+ if(updatedMark) {
|
|
|
+ logService.add(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return redirect(page("list"));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日志的列表显示的,需要传递一个热点id,变量名为id
|
|
|
+ * @param model
|
|
|
+ * @param paramMap
|
|
|
+ * @param page
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/update")
|
|
|
+ public String update(Model model,
|
|
|
+ @RequestParam Long id,
|
|
|
+ @RequestParam(defaultValue = "1") int page) {
|
|
|
+ Map<String, Object> paramMap = new HashMap<String, Object>();
|
|
|
+ // 查询总行数
|
|
|
+ paramMap.put("tableName", "t_wifi");
|
|
|
+ paramMap.put("recordId", id);
|
|
|
+ int totalRow = logService.countByParamsBack(paramMap);
|
|
|
+
|
|
|
+ Pager pager = new Pager();
|
|
|
+ pager.setPage(page);
|
|
|
+ pager.setTotalRow(totalRow);
|
|
|
+ List<Log> logList = logService.findByParamsBack(paramMap, pager);
|
|
|
+ model.addAllAttributes(paramMap);
|
|
|
+ model.addAttribute("pager", pager);
|
|
|
+ model.addAttribute("logList", logList);
|
|
|
+ model.addAttribute("id", id);
|
|
|
+ return page("update");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出日志的excel,需要传递一个参数就是导出那个热点的的日志记录
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ @RequestMapping("/exportLogExcel")
|
|
|
+ public void exportLogExcel(HttpServletRequest request,
|
|
|
+ HttpServletResponse response,
|
|
|
+ @RequestParam Long id) {
|
|
|
+ HashMap<String, Object> paramMap = new HashMap<String, Object>();
|
|
|
+ Account account = getLoginUser();
|
|
|
+ paramMap.put("operatorName", operatorService.findById(account.getOperatorId()).getCompanyName());
|
|
|
+ paramMap.put("tableName", "t_wifi");
|
|
|
+ paramMap.put("recordId", id);
|
|
|
+ List<Log> logList = logService.findByParamsBack(paramMap);
|
|
|
+ paramMap.put("dataList", logList);
|
|
|
+ response.reset();
|
|
|
+ // Content-Type:application/vnd.ms-excel;charset=utf8或者text/xml;charset=utf8
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf8");
|
|
|
+ // 设置excel文件名称
|
|
|
+ SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ String fileName = "report" + df2.format(new Date());
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename="
|
|
|
+ + fileName + ".xls");
|
|
|
+ // 需要对excel的列的总数进行指定
|
|
|
+ int column = 5;
|
|
|
+ paramMap.put("dataSize", logList.size());
|
|
|
+ paramMap.put("column", column);
|
|
|
+
|
|
|
+ String excelTemplate = templateProcessor.processTemplate(
|
|
|
+ "excel/logReport.ftl", paramMap);
|
|
|
+ try {
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ out.write(excelTemplate);
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出场景对应关系excel
|
|
|
+ * 需要传递一个搜索的参数,可以按场景(name)搜索和数据场景(placeName)搜索
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ @RequestMapping("/exportRelationshipExcel")
|
|
|
+ public void exportRelationShipExcel(HttpServletRequest request,
|
|
|
+ HttpServletResponse response,
|
|
|
+ @RequestParam HashMap<String, Object> paramMap) {
|
|
|
+
|
|
|
+ Long operatorId = null;
|
|
|
+ String operatorName = null;
|
|
|
+ /**
|
|
|
+ * 对传入的搜索参数做处理,如果传递的是空值或者空字符串的话就设为空
|
|
|
+ */
|
|
|
+ if(null == paramMap.get("selectedOperatorId") || "".equals(paramMap.get("selectedOperatorId"))) {
|
|
|
+ operatorName = "全部";
|
|
|
+ } else {
|
|
|
+ operatorId = Long.parseLong(String.valueOf(paramMap.get("selectedOperatorId")));
|
|
|
+ operatorName = operatorService.findById(operatorId).getCompanyName();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 按热点场景和数聚场景搜索
|
|
|
+ if (null != paramMap.get("searchValue")
|
|
|
+ && !"".equals(paramMap.get("searchValue"))) {
|
|
|
+ String searchValue = (String) paramMap.get("searchValue");
|
|
|
+ paramMap.put("searchValue", SqlHelper.doLike(searchValue.trim()));
|
|
|
+ } else {
|
|
|
+ paramMap.put("searchValue", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ paramMap.put("operatorId", operatorId);
|
|
|
+ paramMap.put("operatorName", operatorName);
|
|
|
+
|
|
|
+ List<PlaceOperator> placeOperatorList = placeOperatorService.findByParamsBack(paramMap);
|
|
|
+ paramMap.put("dataList", placeOperatorList);
|
|
|
+ response.reset();
|
|
|
+ // Content-Type:application/vnd.ms-excel;charset=utf8或者text/xml;charset=utf8
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf8");
|
|
|
+ // 设置excel文件名称
|
|
|
+ SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ String fileName = "report" + df2.format(new Date());
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename="
|
|
|
+ + fileName + ".xls");
|
|
|
+ // 需要对excel的列的总数进行指定
|
|
|
+ int column = 2;
|
|
|
+ paramMap.put("dataSize", placeOperatorList.size());
|
|
|
+ paramMap.put("column", column);
|
|
|
+
|
|
|
+ String excelTemplate = templateProcessor.processTemplate(
|
|
|
+ "excel/relationship.ftl", paramMap);
|
|
|
+ try {
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ out.write(excelTemplate);
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出热点详情列表页的excel
|
|
|
+ * 前端要传递几个参数,分别所选媒体的媒体Id(变量名为selectedOperatorId),省(变量名为cn),市(变量名为cnCity),场景(变量名为place,这个是运营商定义的场景名称,传过来传个场景名称就行),
|
|
|
+ * 数聚场景id(变量名为placeId)
|
|
|
+ * 还有一个搜索参数,按mac地址搜索
|
|
|
+ * 注:如果传过来的参数是空值或者空字符串或者没传,则按默认值进行搜索,默认的为全部
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ @RequestMapping("/exportApListExcel")
|
|
|
+ public void exportApListExcel(HttpServletRequest request,
|
|
|
+ HttpServletResponse response,
|
|
|
+ @RequestParam HashMap<String, Object> paramMap) {
|
|
|
+ Long operatorId = null;
|
|
|
+ String operatorName = null;
|
|
|
+ String cn = null;
|
|
|
+ String cnCity = null;
|
|
|
+ String place = null;
|
|
|
+ Long placeId = null;
|
|
|
+ String placeName = null;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下面对传递过来的几个参数进行处理
|
|
|
+ */
|
|
|
+ try{
|
|
|
+ if(null != paramMap.get("selectedOperatorId") && !"".equals(paramMap.get("selectedOperatorId"))) {
|
|
|
+ operatorId = Long.parseLong(String.valueOf(paramMap.get("selectedOperatorId")));
|
|
|
+ operatorName = operatorService.findById(operatorId).getCompanyName();
|
|
|
+ } else {
|
|
|
+ operatorName = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != paramMap.get("cn") && !"".equals(paramMap.get("cn"))) {
|
|
|
+ cn = new String(String.valueOf(paramMap.get("cn")).getBytes("ISO-8859-1"),"UTF-8");
|
|
|
+ paramMap.put("cnName", cn);
|
|
|
+ } else {
|
|
|
+ paramMap.put("cnName", "全部");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != paramMap.get("cnCity")
|
|
|
+ && !"".equals(paramMap.get("cnCity"))) {
|
|
|
+ cnCity = new String(String.valueOf(paramMap.get("cnCity")).getBytes("ISO-8859-1"),"UTF-8");
|
|
|
+ paramMap.put("cnCityName", cnCity);
|
|
|
+ } else {
|
|
|
+ paramMap.put("cnCityName", "全部");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != paramMap.get("placeId")
|
|
|
+ && !"".equals(paramMap.get("placeId"))) {
|
|
|
+ placeId = Long.parseLong(String.valueOf(paramMap.get("placeId")));
|
|
|
+ placeName = placeService.findById(placeId).getName();
|
|
|
+ }
|
|
|
+
|
|
|
+ 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("operatorId", operatorId);
|
|
|
+ paramMap.put("cn", cn);
|
|
|
+ paramMap.put("cnCity", cnCity);
|
|
|
+ paramMap.put("placeId", placeId);
|
|
|
+ paramMap.put("place", place);
|
|
|
+ paramMap.put("placeName", placeName);
|
|
|
+ paramMap.put("operatorName", operatorName);
|
|
|
+
|
|
|
+ //按mac地址搜索
|
|
|
+ if (null != paramMap.get("searchValue")
|
|
|
+ && !"".equals(paramMap.get("searchValue"))) {
|
|
|
+ String name = new String(((String) paramMap.get("searchValue")).getBytes("ISO-8859-1"),"UTF-8");
|
|
|
+ paramMap.put("searchValue", SqlHelper.doLike(name.trim()));
|
|
|
+ } else {
|
|
|
+ paramMap.put("searchValue", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch(Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ List<Wifi> wifiList = wifiService.findByParamsBack(paramMap);
|
|
|
+
|
|
|
+ paramMap.put("dataList", wifiList);
|
|
|
+ response.reset();
|
|
|
+ // Content-Type:application/vnd.ms-excel;charset=utf8或者text/xml;charset=utf8
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf8");
|
|
|
+ // 设置excel文件名称
|
|
|
+ SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ String fileName = "report" + df2.format(new Date());
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename="
|
|
|
+ + fileName + ".xls");
|
|
|
+ // 需要对excel的列的总数进行指定
|
|
|
+ int column = 14;
|
|
|
+ paramMap.put("dataSize", wifiList.size());
|
|
|
+ paramMap.put("column", column);
|
|
|
+
|
|
|
+ String excelTemplate = templateProcessor.processTemplate(
|
|
|
+ "excel/apList.ftl", paramMap);
|
|
|
+ try {
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ out.write(excelTemplate);
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|