diff --git a/crm-admin/src/main/java/com/yb/lb/webapp/view/ViewMeetingApi.java b/crm-admin/src/main/java/com/yb/lb/webapp/view/ViewMeetingApi.java index 3ecb2c0..2266409 100644 --- a/crm-admin/src/main/java/com/yb/lb/webapp/view/ViewMeetingApi.java +++ b/crm-admin/src/main/java/com/yb/lb/webapp/view/ViewMeetingApi.java @@ -2,27 +2,25 @@ package com.yb.lb.webapp.view; import cn.hutool.core.util.IdUtil; import com.github.pagehelper.PageInfo; +import com.yb.lb.common.core.AjaxResult; +import com.yb.lb.common.core.BaseController; import com.yb.lb.common.utils.DateUtil; import com.yb.lb.common.utils.ErrorUtils; import com.yb.lb.common.utils.FINALCMD; import com.yb.lb.common.utils.ParameterUtils; import com.yb.lb.webapp.archives.distributor.service.DistributorService; import com.yb.lb.webapp.archives.marketingArea.service.MarketingAreaService; -import com.yb.lb.webapp.audit.service.AuditService; import com.yb.lb.webapp.random.service.RandomService; import com.yb.lb.webapp.redis.service.RedisService; import com.yb.lb.webapp.system.authority.service.AccessService; import com.yb.lb.webapp.system.logger.utils.BusinessType; import com.yb.lb.webapp.system.logger.utils.Log; import com.yb.lb.webapp.system.logger.utils.OperatorType; -import com.yb.lb.webapp.thread.quote.ViewMeetingThread; import com.yb.lb.webapp.utils.RoleDateUtils; import com.yb.lb.webapp.view.view.sevice.ViewMeetingService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; @@ -32,9 +30,10 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; -import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; /** * @author TanChao @@ -44,11 +43,7 @@ import java.util.concurrent.Executors; @Controller @RequestMapping("/api/meeting") @Api(tags = "app:市场活动") -public class ViewMeetingApi { - /** - * 日志 - */ - private final Logger logger = LoggerFactory.getLogger(this.getClass()); +public class ViewMeetingApi extends BaseController { @Autowired ViewMeetingService viewMeetingService; @@ -57,8 +52,6 @@ public class ViewMeetingApi { @Autowired AccessService accessService; @Autowired - AuditService auditService; - @Autowired RandomService randomService; @Autowired DistributorService distributorService; @@ -97,58 +90,25 @@ public class ViewMeetingApi { HttpServletRequest request) { Map result = new HashMap<>(); Map params = new HashMap(); - try { - String token = request.getHeader("token"); - if (redisService.exists(token)) { - Map tokenMap = redisService.hmget(token); - params = ParameterUtils.reqMapSeria(request.getParameterMap()); - params.put("id", IdUtil.simpleUUID()); - params.put("createTime", DateUtil.getTime()); - params.put("companyId", tokenMap.get("companyId") + ""); - params.put("createUser", tokenMap.get("id") + ""); - params.put("staffId", tokenMap.get("archivesId") + ""); - params.put("staffName", tokenMap.get("realName") + ""); - params.put("semId", tokenMap.get("areaId") + ""); - params.put("ancestors", tokenMap.get("ancestors") + ""); - // 编码 - params.put("viewNo", randomService.randomUtils1(FINALCMD.VIEW_NO, tokenMap.get("companyId") + "")); - // 状态:0待审核1审核通过2审核未通过3.审核中4.自由态 - params.put("status", "4"); - boolean flag = viewMeetingService.addView(params, ".addView"); - if (flag) { - result.put("data", true); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - /*if (("1").equals(auditType)) { - result = new HashMap(); - result = auditService.commitAudit(token, AuditTypeUtil.AUDITMEETING, params.get("id") + "", "市场活动", params.get("tranNo") + "", menuCode); - result.put("data", true); - }*/ - //创建线程池 设置线程数量为1个 - ExecutorService pool = Executors.newFixedThreadPool(1); - ViewMeetingThread viewMeetingThread = new ViewMeetingThread(params, marketingAreaService, distributorService); - //提交线程池执行 - pool.submit(viewMeetingThread); - //结束线程 - pool.shutdown(); - } else { - result.put("data", false); - result.put("code", ErrorUtils.ERROR); - result.put("msg", "操作失败"); - } - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("市场活动app-提交" + "操作异常:" + e.getMessage()); + String token = request.getHeader("token"); + if (!redisService.exists(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); } - return result; + Map tokenMap = redisService.hmget(token); + params = ParameterUtils.reqMapSeria(request.getParameterMap()); + params.put("id", IdUtil.simpleUUID()); + params.put("createTime", DateUtil.getTime()); + params.put("companyId", tokenMap.get("companyId") + ""); + params.put("createUser", tokenMap.get("id") + ""); + params.put("staffId", tokenMap.get("archivesId") + ""); + params.put("staffName", tokenMap.get("realName") + ""); + params.put("semId", tokenMap.get("areaId") + ""); + params.put("ancestors", tokenMap.get("ancestors") + ""); + // 编码 + params.put("viewNo", randomService.randomUtils1(FINALCMD.VIEW_NO, tokenMap.get("companyId") + "")); + // 状态:0待审核1审核通过2审核未通过3.审核中4.自由态 + params.put("status", "4"); + return toAjax(viewMeetingService.addView(params, ".addView")); } /** @@ -179,50 +139,17 @@ public class ViewMeetingApi { @ApiParam(required = false, value = "菜单编码(提交审核使用)") @RequestParam(required = false) String menuCode, HttpServletRequest request) { Map result = new HashMap<>(); - try { - String token = request.getHeader("token"); - if (redisService.exists(token)) { - Map params = ParameterUtils.reqMapSeria(request.getParameterMap()); - Map tokenMap = redisService.hmget(token); - params.put("staffId", tokenMap.get("archivesId") + ""); - params.put("staffName", tokenMap.get("realName") + ""); - params.put("semId", tokenMap.get("areaId") + ""); - params.put("ancestors", tokenMap.get("ancestors") + ""); - boolean flag = viewMeetingService.updateView(params, ".updateView"); - if (flag) { - result.put("data", true); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - /*if (("1").equals(auditType)) { - result = new HashMap(); - result = auditService.commitAudit(token, AuditTypeUtil.AUDITMEETING, params.get("id") + "", "市场活动", params.get("tranNo") + "", menuCode); - result.put("data", true); - }*/ - //创建线程池 设置线程数量为1个 - ExecutorService pool = Executors.newFixedThreadPool(1); - ViewMeetingThread viewMeetingThread = new ViewMeetingThread(params, marketingAreaService, distributorService); - //提交线程池执行 - pool.submit(viewMeetingThread); - //结束线程 - pool.shutdown(); - } else { - result.put("data", false); - result.put("code", ErrorUtils.ERROR); - result.put("msg", "操作失败"); - } - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("市场活动app-修改" + "操作异常:" + e.getMessage()); + String token = request.getHeader("token"); + if (!redisService.exists(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); } - return result; + Map params = ParameterUtils.reqMapSeria(request.getParameterMap()); + Map tokenMap = redisService.hmget(token); + params.put("staffId", tokenMap.get("archivesId") + ""); + params.put("staffName", tokenMap.get("realName") + ""); + params.put("semId", tokenMap.get("areaId") + ""); + params.put("ancestors", tokenMap.get("ancestors") + ""); + return toAjax(viewMeetingService.updateView(params, ".updateView")); } /** @@ -250,59 +177,30 @@ public class ViewMeetingApi { @ApiParam(required = true, value = "页码", defaultValue = "1") @RequestParam(required = true) String page, @ApiParam(required = true, value = "显示数量", defaultValue = "10") @RequestParam(required = true) String pageSize, HttpServletRequest request) { + String token = request.getHeader("token"); + if (!redisService.exists(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); + } Map result = new HashMap<>(); Map paramsMap = new HashMap<>(); - try { - String token = request.getHeader("token"); - if (redisService.exists(token)) { - paramsMap = roleDateUtils.roleUtiles(token, marketingAreaId, region, code); - if ("0".equals(paramsMap.get("code"))) { - result.put("data", ""); - result.put("msg", "无权查看"); - result.put("code", ErrorUtils.USERNAME_POWER_ERROR); - } else { - paramsMap.put("typeName", typeName); - paramsMap.put("typeId", typeId); - paramsMap.put("activityContent", activityContent); - paramsMap.put("startDate", startDate); - paramsMap.put("endDate", endDate); - paramsMap.put("createStartDate", createStartDate); - paramsMap.put("createEndDate", createEndDate); - paramsMap.put("dealersId", dealersId); - paramsMap.put("distributorName", distributorName); - paramsMap.put("clientType", clientType); - paramsMap.put("staffId", staffId); - paramsMap.put("page", page); - paramsMap.put("pageSize", pageSize); - PageInfo pageInfo = viewMeetingService.pageList(paramsMap, ".pageList"); - if (pageInfo != null) { - List list = pageInfo.getList(); - result.put("data", list); - result.put("total", pageInfo.getTotal()); - result.put("pageNum", pageInfo.getPageNum()); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } else { - result.put("data", null); - result.put("pageNum", 0); - result.put("total", 0); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } - } - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("市场活动app-市场活动列表" + "操作异常:" + e.getMessage()); + paramsMap = roleDateUtils.roleUtiles(token, marketingAreaId, region, code); + if ("0".equals(paramsMap.get("code"))) { + return AjaxResult.error(ErrorUtils.USERNAME_POWER_ERROR, "无权查看"); } - return result; + paramsMap.put("typeName", typeName); + paramsMap.put("typeId", typeId); + paramsMap.put("activityContent", activityContent); + paramsMap.put("startDate", startDate); + paramsMap.put("endDate", endDate); + paramsMap.put("createStartDate", createStartDate); + paramsMap.put("createEndDate", createEndDate); + paramsMap.put("dealersId", dealersId); + paramsMap.put("distributorName", distributorName); + paramsMap.put("clientType", clientType); + paramsMap.put("staffId", staffId); + paramsMap.put("page", page); + paramsMap.put("pageSize", pageSize); + return toPage(viewMeetingService.pageList(paramsMap, ".pageList")); } /** @@ -318,28 +216,13 @@ public class ViewMeetingApi { HttpServletRequest request) { Map params = new HashMap<>(); Map result = new HashMap<>(); - try { - String token = request.getHeader("token"); - if (redisService.exists(token)) { - params.put("id", id); - params.put("typeId", typeId); - Map map = viewMeetingService.oneView(params, ".pageList"); - result.put("data", map); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("市场活动app-市场活动详情" + "操作异常:" + e.getMessage()); + String token = request.getHeader("token"); + if (!redisService.exists(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); } - return result; + params.put("id", id); + params.put("typeId", typeId); + return AjaxResult.success(viewMeetingService.oneView(params, ".pageList")); } /** @@ -357,68 +240,54 @@ public class ViewMeetingApi { HttpServletRequest request) { Map params = new HashMap<>(); Map result = new HashMap<>(); - try { - String token = request.getHeader("token"); - if (redisService.exists(token)) { - params = roleDateUtils.roleUtiles(token, marketingAreaId, region, code); - if ("0".equals(params.get("code"))) { - result.put("data", ""); - result.put("msg", "无权查看"); - result.put("code", ErrorUtils.USERNAME_POWER_ERROR); - return result; - } - Map map = new HashMap(); - // 本年度累计场数 - // 获取当前年份 - String year = DateUtil.getYear(); - params.put("year", year); - Integer yearNum = viewMeetingService.countAll(params, ".countActivity"); - Integer participantsNum = viewMeetingService.countAll(params, ".viewNumPersion"); - map.put("yearNum", yearNum != null ? yearNum : 0); - // (年)累计参与人数 - map.put("participantsNum", participantsNum != null ? participantsNum : 0); - - // 本季度新增场数 - // 获取当前季度 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - int quarter = calendar.get(Calendar.MONTH) / 3 + 1; - params.remove("year"); - - if (quarter == 1) { - // 第一季度:1月-3月 - params.put("laststart", year + "-01"); - params.put("lastend", year + "-03"); - } else if (quarter == 2) { - // 第二季度:4月-6月 - params.put("laststart", year + "-04"); - params.put("lastend", year + "-06"); - } else if (quarter == 3) { - // 第三季度:7月-9月 - params.put("laststart", year + "-07"); - params.put("lastend", year + "-09"); - } else if (quarter == 4) { - // 第四季度:10月-12月 - params.put("laststart", year + "-10"); - params.put("lastend", year + "-12"); - } - Integer quarterly = viewMeetingService.countAll(params, ".countActivity"); - map.put("quarterly", quarterly != null ? quarterly : 0); - result.put("data", map); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("市场活动数据统计" + "操作异常:" + e.getMessage()); + String token = request.getHeader("token"); + if (!redisService.exists(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); } + params = roleDateUtils.roleUtiles(token, marketingAreaId, region, code); + if ("0".equals(params.get("code"))) { + return AjaxResult.error(ErrorUtils.USERNAME_POWER_ERROR, "无权查看"); + } + Map map = new HashMap(); + // 本年度累计场数 + // 获取当前年份 + String year = DateUtil.getYear(); + params.put("year", year); + Integer yearNum = viewMeetingService.countAll(params, ".countActivity"); + Integer participantsNum = viewMeetingService.countAll(params, ".viewNumPersion"); + map.put("yearNum", yearNum != null ? yearNum : 0); + // (年)累计参与人数 + map.put("participantsNum", participantsNum != null ? participantsNum : 0); + + // 本季度新增场数 + // 获取当前季度 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + int quarter = calendar.get(Calendar.MONTH) / 3 + 1; + params.remove("year"); + + if (quarter == 1) { + // 第一季度:1月-3月 + params.put("laststart", year + "-01"); + params.put("lastend", year + "-03"); + } else if (quarter == 2) { + // 第二季度:4月-6月 + params.put("laststart", year + "-04"); + params.put("lastend", year + "-06"); + } else if (quarter == 3) { + // 第三季度:7月-9月 + params.put("laststart", year + "-07"); + params.put("lastend", year + "-09"); + } else if (quarter == 4) { + // 第四季度:10月-12月 + params.put("laststart", year + "-10"); + params.put("lastend", year + "-12"); + } + Integer quarterly = viewMeetingService.countAll(params, ".countActivity"); + map.put("quarterly", quarterly != null ? quarterly : 0); + result.put("data", map); + result.put("code", ErrorUtils.SUCCESS); + result.put("msg", "操作成功"); return result; } @@ -442,51 +311,37 @@ public class ViewMeetingApi { HttpServletRequest request) { Map result = new HashMap<>(); Map params = new HashMap<>(); - try { - String token = request.getHeader("token"); - if (redisService.exists(token)) { - params = roleDateUtils.roleUtiles(token, marketingAreaId, "", code); - if ("0".equals(params.get("code"))) { - result.put("data", ""); - result.put("msg", "无权查看"); - result.put("code", ErrorUtils.USERNAME_POWER_ERROR); - return result; - } - params.put("startDate", startDate); - params.put("endDate", endDate); - params.put("createStartDate", createStartDate); - params.put("createEndDate", createEndDate); - params.put("page", page); - params.put("pageSize", pageSize); - PageInfo pageInfo = viewMeetingService.pageList(params, ".countActivityNum"); - if (pageInfo != null) { - result.put("data", viewMeetingService.countActivityNum(pageInfo.getList())); - // 合计数量 - // result.put("totalData", viewMeetingService.listAll(params, ".countActivityTotalNum")); - result.put("totalData", viewMeetingService.getActivityTotalNum(params)); - result.put("total", pageInfo.getTotal()); - result.put("pageNum", pageInfo.getPageNum()); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } else { - result.put("data", null); - result.put("totalData", null); - result.put("pageNum", 0); - result.put("total", 0); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "无数据"); - } - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("市场活动报表-按照区域分组" + "操作异常:" + e.getMessage()); + String token = request.getHeader("token"); + if (!redisService.exists(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); + } + params = roleDateUtils.roleUtiles(token, marketingAreaId, "", code); + if ("0".equals(params.get("code"))) { + return AjaxResult.error(ErrorUtils.USERNAME_POWER_ERROR, "无权查看"); + } + params.put("startDate", startDate); + params.put("endDate", endDate); + params.put("createStartDate", createStartDate); + params.put("createEndDate", createEndDate); + params.put("page", page); + params.put("pageSize", pageSize); + PageInfo pageInfo = viewMeetingService.pageList(params, ".countActivityNum"); + if (pageInfo != null) { + result.put("data", viewMeetingService.countActivityNum(pageInfo.getList())); + // 合计数量 + // result.put("totalData", viewMeetingService.listAll(params, ".countActivityTotalNum")); + result.put("totalData", viewMeetingService.getActivityTotalNum(params)); + result.put("total", pageInfo.getTotal()); + result.put("pageNum", pageInfo.getPageNum()); + result.put("code", ErrorUtils.SUCCESS); + result.put("msg", "操作成功"); + } else { + result.put("data", null); + result.put("totalData", null); + result.put("pageNum", 0); + result.put("total", 0); + result.put("code", ErrorUtils.SUCCESS); + result.put("msg", "无数据"); } return result; } @@ -512,51 +367,37 @@ public class ViewMeetingApi { HttpServletRequest request) { Map result = new HashMap<>(); Map params = new HashMap<>(); - try { - String token = request.getHeader("token"); - if (redisService.exists(token)) { - params = roleDateUtils.roleUtiles(token, marketingAreaId, "", code); - if ("0".equals(params.get("code"))) { - result.put("data", ""); - result.put("msg", "无权查看"); - result.put("code", ErrorUtils.USERNAME_POWER_ERROR); - return result; - } - params.put("startDate", startDate); - params.put("endDate", endDate); - params.put("createStartDate", createStartDate); - params.put("createEndDate", createEndDate); - params.put("staffId", staffId); - params.put("page", page); - params.put("pageSize", pageSize); - PageInfo pageInfo = viewMeetingService.pageList(params, ".countActivityNumByStaff"); - if (pageInfo != null) { - result.put("data", viewMeetingService.countActivityNum(pageInfo.getList())); - // 合计数量 - result.put("totalData", viewMeetingService.getActivityTotalNum(params)); - result.put("total", pageInfo.getTotal()); - result.put("pageNum", pageInfo.getPageNum()); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } else { - result.put("data", null); - result.put("totalData", null); - result.put("pageNum", 0); - result.put("total", 0); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "无数据"); - } - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("市场活动报表-按照业务员分组" + "操作异常:" + e.getMessage()); + String token = request.getHeader("token"); + if (!redisService.exists(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); + } + params = roleDateUtils.roleUtiles(token, marketingAreaId, "", code); + if ("0".equals(params.get("code"))) { + return AjaxResult.error(ErrorUtils.USERNAME_POWER_ERROR, "无权查看"); + } + params.put("startDate", startDate); + params.put("endDate", endDate); + params.put("createStartDate", createStartDate); + params.put("createEndDate", createEndDate); + params.put("staffId", staffId); + params.put("page", page); + params.put("pageSize", pageSize); + PageInfo pageInfo = viewMeetingService.pageList(params, ".countActivityNumByStaff"); + if (pageInfo != null) { + result.put("data", viewMeetingService.countActivityNum(pageInfo.getList())); + // 合计数量 + result.put("totalData", viewMeetingService.getActivityTotalNum(params)); + result.put("total", pageInfo.getTotal()); + result.put("pageNum", pageInfo.getPageNum()); + result.put("code", ErrorUtils.SUCCESS); + result.put("msg", "操作成功"); + } else { + result.put("data", null); + result.put("totalData", null); + result.put("pageNum", 0); + result.put("total", 0); + result.put("code", ErrorUtils.SUCCESS); + result.put("msg", "无数据"); } return result; } diff --git a/crm-admin/src/main/java/com/yb/lb/webapp/view/ViewMeetingController.java b/crm-admin/src/main/java/com/yb/lb/webapp/view/ViewMeetingController.java index fd25358..8a5f4ed 100644 --- a/crm-admin/src/main/java/com/yb/lb/webapp/view/ViewMeetingController.java +++ b/crm-admin/src/main/java/com/yb/lb/webapp/view/ViewMeetingController.java @@ -1,18 +1,15 @@ package com.yb.lb.webapp.view; import com.github.pagehelper.PageInfo; +import com.yb.lb.common.core.AjaxResult; +import com.yb.lb.common.core.BaseController; import com.yb.lb.common.utils.ErrorUtils; -import com.yb.lb.webapp.archives.dictionary.service.DictionaryiesService; -import com.yb.lb.webapp.random.service.RandomService; import com.yb.lb.webapp.redis.service.RedisService; -import com.yb.lb.webapp.system.authority.service.AccessService; import com.yb.lb.webapp.utils.RoleDateUtils; import com.yb.lb.webapp.view.view.sevice.ViewMeetingService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; @@ -23,7 +20,6 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -34,22 +30,12 @@ import java.util.Map; @Controller @RequestMapping("/adminx/meeting") @Api(tags = "pc:市场活动") -public class ViewMeetingController { - /** - * 日志 - */ - private final Logger logger = LoggerFactory.getLogger(ViewMeetingController.class); +public class ViewMeetingController extends BaseController { @Autowired ViewMeetingService viewMeetingService; @Autowired - RandomService randomService; - @Autowired RedisService redisService; @Autowired - DictionaryiesService dictionaryiesService; - @Autowired - AccessService accessService; - @Autowired RoleDateUtils roleDateUtils; /** @@ -79,57 +65,28 @@ public class ViewMeetingController { HttpServletRequest request) { Map result = new HashMap<>(); Map paramsMap = new HashMap<>(); - try { - String token = request.getHeader("token"); - if (redisService.isKey(token)) { - paramsMap = roleDateUtils.roleUtiles(token, marketingAreaId, region, code); - if ("0".equals(paramsMap.get("code"))) { - result.put("data", ""); - result.put("msg", "无权查看"); - result.put("code", ErrorUtils.USERNAME_POWER_ERROR); - } else { - paramsMap.put("typeName", typeName); - paramsMap.put("typeId", typeId); - paramsMap.put("activityContent", activityContent); - paramsMap.put("startDate", startDate); - paramsMap.put("createEndDate", createEndDate); - paramsMap.put("createStartDate", createStartDate); - paramsMap.put("endDate", endDate); - paramsMap.put("dealersId", dealersId); - paramsMap.put("distributorName", distributorName); - paramsMap.put("clientType", clientType); - paramsMap.put("staffId", staffId); - paramsMap.put("page", page); - paramsMap.put("pageSize", pageSize); - PageInfo pageInfo = viewMeetingService.pageList(paramsMap, ".pageList"); - if (pageInfo != null) { - List list = pageInfo.getList(); - result.put("data", list); - result.put("total", pageInfo.getTotal()); - result.put("pageNum", pageInfo.getPageNum()); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } else { - result.put("data", null); - result.put("pageNum", 0); - result.put("total", 0); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } - } - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("pc市场活动" + "操作异常:" + e.getMessage()); + String token = request.getHeader("token"); + if (!redisService.isKey(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); } - return result; + paramsMap = roleDateUtils.roleUtiles(token, marketingAreaId, region, code); + if ("0".equals(paramsMap.get("code"))) { + return AjaxResult.error(ErrorUtils.USERNAME_POWER_ERROR, "无权查看"); + } + paramsMap.put("typeName", typeName); + paramsMap.put("typeId", typeId); + paramsMap.put("activityContent", activityContent); + paramsMap.put("startDate", startDate); + paramsMap.put("createEndDate", createEndDate); + paramsMap.put("createStartDate", createStartDate); + paramsMap.put("endDate", endDate); + paramsMap.put("dealersId", dealersId); + paramsMap.put("distributorName", distributorName); + paramsMap.put("clientType", clientType); + paramsMap.put("staffId", staffId); + paramsMap.put("page", page); + paramsMap.put("pageSize", pageSize); + return toPage(viewMeetingService.pageList(paramsMap, ".pageList")); } /** @@ -145,28 +102,13 @@ public class ViewMeetingController { HttpServletRequest request) { Map params = new HashMap<>(); Map result = new HashMap<>(); - try { - String token = request.getHeader("token"); - if (redisService.isKey(token)) { - params.put("id", id); - params.put("typeId", typeId); - Map map = viewMeetingService.oneView(params, ".pageList"); - result.put("data", map); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("pc市场活动-市场活动详情" + "操作异常:" + e.getMessage()); + String token = request.getHeader("token"); + if (!redisService.isKey(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); } - return result; + params.put("id", id); + params.put("typeId", typeId); + return AjaxResult.success(viewMeetingService.oneView(params, ".pageList")); } /** @@ -189,50 +131,36 @@ public class ViewMeetingController { HttpServletRequest request) { Map result = new HashMap<>(); Map params = new HashMap<>(); - try { - String token = request.getHeader("token"); - if (redisService.exists(token)) { - params = roleDateUtils.roleUtiles(token, marketingAreaId, "", code); - if ("0".equals(params.get("code"))) { - result.put("data", ""); - result.put("msg", "无权查看"); - result.put("code", ErrorUtils.USERNAME_POWER_ERROR); - return result; - } - params.put("startDate", startDate); - params.put("endDate", endDate); - params.put("createStartDate", createStartDate); - params.put("createEndDate", createEndDate); - params.put("page", page); - params.put("pageSize", pageSize); - PageInfo pageInfo = viewMeetingService.pageList(params, ".countActivityNum"); - if (pageInfo != null) { - result.put("data", viewMeetingService.countActivityNum(pageInfo.getList())); - // 合计数量 - result.put("totalData", viewMeetingService.getActivityTotalNum(params)); - result.put("total", pageInfo.getTotal()); - result.put("pageNum", pageInfo.getPageNum()); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } else { - result.put("data", null); - result.put("totalData", null); - result.put("pageNum", 0); - result.put("total", 0); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "无数据"); - } - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("市场活动报表-按照区域分组" + "操作异常:" + e.getMessage()); + String token = request.getHeader("token"); + if (!redisService.isKey(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); + } + params = roleDateUtils.roleUtiles(token, marketingAreaId, "", code); + if ("0".equals(params.get("code"))) { + return AjaxResult.error(ErrorUtils.USERNAME_POWER_ERROR, "无权查看"); + } + params.put("startDate", startDate); + params.put("endDate", endDate); + params.put("createStartDate", createStartDate); + params.put("createEndDate", createEndDate); + params.put("page", page); + params.put("pageSize", pageSize); + PageInfo pageInfo = viewMeetingService.pageList(params, ".countActivityNum"); + if (pageInfo != null) { + result.put("data", viewMeetingService.countActivityNum(pageInfo.getList())); + // 合计数量 + result.put("totalData", viewMeetingService.getActivityTotalNum(params)); + result.put("total", pageInfo.getTotal()); + result.put("pageNum", pageInfo.getPageNum()); + result.put("code", ErrorUtils.SUCCESS); + result.put("msg", "操作成功"); + } else { + result.put("data", null); + result.put("totalData", null); + result.put("pageNum", 0); + result.put("total", 0); + result.put("code", ErrorUtils.SUCCESS); + result.put("msg", "无数据"); } return result; } @@ -258,51 +186,37 @@ public class ViewMeetingController { HttpServletRequest request) { Map result = new HashMap<>(); Map params = new HashMap<>(); - try { - String token = request.getHeader("token"); - if (redisService.exists(token)) { - params = roleDateUtils.roleUtiles(token, marketingAreaId, "", code); - if ("0".equals(params.get("code"))) { - result.put("data", ""); - result.put("msg", "无权查看"); - result.put("code", ErrorUtils.USERNAME_POWER_ERROR); - return result; - } - params.put("startDate", startDate); - params.put("endDate", endDate); - params.put("createStartDate", createStartDate); - params.put("createEndDate", createEndDate); - params.put("staffId", staffId); - params.put("page", page); - params.put("pageSize", pageSize); - PageInfo pageInfo = viewMeetingService.pageList(params, ".countActivityNumByStaff"); - if (pageInfo != null) { - result.put("data", viewMeetingService.countActivityNum(pageInfo.getList())); - // 合计数量 - result.put("totalData", viewMeetingService.getActivityTotalNum(params)); - result.put("total", pageInfo.getTotal()); - result.put("pageNum", pageInfo.getPageNum()); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "操作成功"); - } else { - result.put("data", null); - result.put("totalData", null); - result.put("pageNum", 0); - result.put("total", 0); - result.put("code", ErrorUtils.SUCCESS); - result.put("msg", "无数据"); - } - } else { - result.put("data", false); - result.put("code", ErrorUtils.IS_NOT_LOGIN_ERROR); - result.put("msg", "用户未登录"); - } - } catch (Exception e) { - e.printStackTrace(); - result.put("data", false); - result.put("code", ErrorUtils.DEBUG); - result.put("msg", "操作异常"); - logger.debug("市场活动报表-按照业务员分组" + "操作异常:" + e.getMessage()); + String token = request.getHeader("token"); + if (!redisService.isKey(token)) { + return AjaxResult.error(ErrorUtils.IS_NOT_LOGIN_ERROR, "用户未登录"); + } + params = roleDateUtils.roleUtiles(token, marketingAreaId, "", code); + if ("0".equals(params.get("code"))) { + return AjaxResult.error(ErrorUtils.USERNAME_POWER_ERROR, "无权查看"); + } + params.put("startDate", startDate); + params.put("endDate", endDate); + params.put("createStartDate", createStartDate); + params.put("createEndDate", createEndDate); + params.put("staffId", staffId); + params.put("page", page); + params.put("pageSize", pageSize); + PageInfo pageInfo = viewMeetingService.pageList(params, ".countActivityNumByStaff"); + if (pageInfo != null) { + result.put("data", viewMeetingService.countActivityNum(pageInfo.getList())); + // 合计数量 + result.put("totalData", viewMeetingService.getActivityTotalNum(params)); + result.put("total", pageInfo.getTotal()); + result.put("pageNum", pageInfo.getPageNum()); + result.put("code", ErrorUtils.SUCCESS); + result.put("msg", "操作成功"); + } else { + result.put("data", null); + result.put("totalData", null); + result.put("pageNum", 0); + result.put("total", 0); + result.put("code", ErrorUtils.SUCCESS); + result.put("msg", "无数据"); } return result; }