123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748 |
- package com.ruixuan.jiaoyang.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.ruixuan.common.core.controller.BaseController;
- import com.ruixuan.common.core.page.TableDataInfo;
- import com.ruixuan.common.utils.Check;
- import com.ruixuan.common.utils.DateUtils;
- import com.ruixuan.jiaoyang.service.IJiaoYangDingPanService;
- import com.ruixuan.system.service.ISysDeptService;
- import com.ruixuan.system.service.ISysRoleService;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import static com.ruixuan.common.utils.PageUtils.startPage;
- @RestController
- @RequestMapping("/jy/dingpan")
- public class JiaoYangDingPanController extends BaseController {
- @Autowired
- private IJiaoYangDingPanService jiaoYangDingPanService;
- @Autowired
- private ISysRoleService sysRoleService;
- @Autowired
- private ISysDeptService sysDeptService;
- @GetMapping("/getSumInfo")
- @ApiOperation(value = "切片盯盘-汇总数据")
- public JSONObject getSumInfo(Long userId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(userId)) {
- throw new Exception("请传入用户id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- String roleId = sysRoleService.getRoleBYUserId(userId);
- // 剪手经理,渠道经理 查询部门下所有成员数据
- List<Long> promoterIds = new ArrayList<>();
- if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
- List<Long> userIds = new ArrayList<>();
- if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
- Long deptId = sysDeptService.getDeptIdByUserId(userId);
- userIds = sysDeptService.getDeptUserListByDeptId(deptId);
- } else {
- userIds.add(userId);
- }
- promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
- } else if ("jy_expert_business".equals(roleId)) {
- promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
- }
- if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
- if (Check.isNull(promoterIds)) {
- throw new Exception("该用户下未查询到绑定达人");
- }
- }
- if (!Check.isNull(promoterIds)) {
- requestMap.put("promoterIds", promoterIds);
- }
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- requestMap.put("start", start);
- requestMap.put("end", end);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
- String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
- String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
- requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
- requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
- Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
- if (start.equals(nowDate) && end.equals(nowDate)) {
- Integer nowHour = DateUtils.getNowHour();
- requestMap.put("nowHour", nowHour);
- }
- JSONObject date = jiaoYangDingPanService.getSumInfo(requestMap);
- returnJson.put("code", 200);
- returnJson.put("data", date);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- @GetMapping("/getMonthInfo")
- @ApiOperation(value = "切片盯盘-当月数据数据")
- public JSONObject getMonthInfo(Long userId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(userId)) {
- throw new Exception("请传入用户id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- String monthEndDate = DateUtils.getNowDate("yyyy-MM-dd");
- String monthStartDay = DateUtils.getMonthStartDay(monthEndDate);
- String roleId = sysRoleService.getRoleBYUserId(userId);
- // 剪手经理,渠道经理 查询部门下所有成员数据
- List<Long> promoterIds = new ArrayList<>();
- if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
- List<Long> userIds = new ArrayList<>();
- if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
- Long deptId = sysDeptService.getDeptIdByUserId(userId);
- userIds = sysDeptService.getDeptUserListByDeptId(deptId);
- } else {
- userIds.add(userId);
- }
- promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
- } else if ("jy_expert_business".equals(roleId)) {
- promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
- }
- if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
- if (Check.isNull(promoterIds)) {
- throw new Exception("该用户下未查询到绑定达人");
- }
- }
- if (!Check.isNull(promoterIds)) {
- requestMap.put("promoterIds", promoterIds);
- }
- Long monthStart = DateUtils.strDateToInt(monthStartDay);
- Long monthEnd = DateUtils.strDateToInt(monthEndDate);
- requestMap.put("monthStart", monthStart);
- requestMap.put("monthEnd", monthEnd);
- String lastMonthFirstDate = DateUtils.getLastMonthFirstDayByDate(monthEndDate);// 上个月开始时间
- String lastMonthEndDate = DateUtils.getLastMonthNowDay(monthEndDate);// 上个月结束时间
- requestMap.put("lastMonthStart", DateUtils.strDateToInt(lastMonthFirstDate));
- requestMap.put("lastMonthEnd", DateUtils.strDateToInt(lastMonthEndDate));
- JSONObject monthDate = jiaoYangDingPanService.getMonthInfo(requestMap);
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
- if (start.equals(nowDate) && end.equals(nowDate)) { // 如果传入时间为当天,取当前月的数据
- requestMap.put("echartStart", monthStart);
- requestMap.put("echartEnd", monthEnd);
- } else {
- requestMap.put("echartStart", start);
- requestMap.put("echartEnd", end);
- }
- List<JSONObject> list = jiaoYangDingPanService.getEchartData(requestMap);
- monthDate.put("list", list);
- returnJson.put("code", 200);
- returnJson.put("data", monthDate);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- @GetMapping("/getGmvHours")
- @ApiOperation(value = "切片盯盘-当月数据数据")
- public JSONObject getGmvHours(Long userId) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(userId)) {
- throw new Exception("请传入用户id");
- }
- String roleId = sysRoleService.getRoleBYUserId(userId);
- // 剪手经理,渠道经理 查询部门下所有成员数据
- List<Long> promoterIds = new ArrayList<>();
- if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
- List<Long> userIds = new ArrayList<>();
- if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
- Long deptId = sysDeptService.getDeptIdByUserId(userId);
- userIds = sysDeptService.getDeptUserListByDeptId(deptId);
- } else {
- userIds.add(userId);
- }
- promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
- } else if ("jy_expert_business".equals(roleId)) {
- promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
- }
- if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
- if (Check.isNull(promoterIds)) {
- throw new Exception("该用户下未查询到绑定达人");
- }
- }
- if (!Check.isNull(promoterIds)) {
- requestMap.put("promoterIds", promoterIds);
- }
- String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
- requestMap.put("date", DateUtils.strDateToInt(nowDate));
- List<JSONObject> today = jiaoYangDingPanService.getGmvHours(requestMap);
- String lastDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); // 日期 -1
- requestMap.put("date", DateUtils.strDateToInt(lastDate));
- List<JSONObject> yesterday = jiaoYangDingPanService.getGmvHours(requestMap);
- JSONObject data = new JSONObject();
- data.put("today", today);
- data.put("yesterday", yesterday);
- returnJson.put("code", 200);
- returnJson.put("data", data);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- /**
- * 分团队数据
- *
- * @param userId
- * @param startDate
- * @param endDate
- * @return
- */
- @GetMapping("/getTeamList")
- @ApiOperation(value = "切片盯盘-分团队数据")
- public JSONObject getTeamList(Long userId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(userId)) {
- throw new Exception("请传入用户id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- String roleId = sysRoleService.getRoleBYUserId(userId);
- // 剪手经理,渠道经理 查询部门下所有成员数据
- List<Long> promoterIds = new ArrayList<>();
- if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
- List<Long> userIds = new ArrayList<>();
- if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
- Long deptId = sysDeptService.getDeptIdByUserId(userId);
- userIds = sysDeptService.getDeptUserListByDeptId(deptId);
- } else {
- userIds.add(userId);
- }
- promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
- } else if ("jy_expert_business".equals(roleId)) {
- promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
- }
- if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
- if (Check.isNull(promoterIds)) {
- throw new Exception("该用户下未查询到绑定达人");
- }
- }
- if (!Check.isNull(promoterIds)) {
- requestMap.put("promoterIds", promoterIds);
- }
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- requestMap.put("start", start);
- requestMap.put("end", end);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
- String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
- String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
- requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
- requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
- Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
- if (start.equals(nowDate) && end.equals(nowDate)) {
- Integer nowHour = DateUtils.getNowHour();
- requestMap.put("nowHour", nowHour);
- }
- List<JSONObject> data = jiaoYangDingPanService.getTeamList(requestMap);
- returnJson.put("code", 200);
- returnJson.put("data", data);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- /**
- * 新增商品
- *
- * @param deptId
- * @param startDate
- * @param endDate
- * @return
- */
- @GetMapping("/getAddItemList")
- @ApiOperation(value = "切片盯盘-新增商品")
- public JSONObject getAddItemList(Long deptId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(deptId)) {
- throw new Exception("请传入部门id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- requestMap.put("deptId", deptId);
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- requestMap.put("start", start);
- requestMap.put("end", end);
- List<JSONObject> data = jiaoYangDingPanService.getAddItemList(requestMap);
- returnJson.put("data", data);
- returnJson.put("code", 200);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("success", false);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- /**
- * 分成员数据
- *
- * @param userId
- * @param startDate
- * @param endDate
- * @return
- */
- @GetMapping("/getPeopleList")
- @ApiOperation(value = "切片盯盘-成员数据")
- public JSONObject getPeopleList(Long userId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(userId)) {
- throw new Exception("请传入用户id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- String roleId = sysRoleService.getRoleBYUserId(userId);
- // 剪手经理,渠道经理 查询部门下所有成员数据
- List<Long> promoterIds = new ArrayList<>();
- if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
- List<Long> userIds = new ArrayList<>();
- if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
- Long deptId = sysDeptService.getDeptIdByUserId(userId);
- userIds = sysDeptService.getDeptUserListByDeptId(deptId);
- } else {
- userIds.add(userId);
- }
- promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
- } else if ("jy_expert_business".equals(roleId)) {
- promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
- }
- if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
- if (Check.isNull(promoterIds)) {
- throw new Exception("该用户下未查询到绑定达人");
- }
- }
- if (!Check.isNull(promoterIds)) {
- requestMap.put("promoterIds", promoterIds);
- }
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- requestMap.put("start", start);
- requestMap.put("end", end);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
- String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
- String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
- requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
- requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
- Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
- if (start.equals(nowDate) && end.equals(nowDate)) {
- Integer nowHour = DateUtils.getNowHour();
- requestMap.put("nowHour", nowHour);
- }
- List<JSONObject> data = jiaoYangDingPanService.getPeopleList(requestMap);
- returnJson.put("code", 200);
- returnJson.put("data", data);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- @GetMapping("/getAddItemListByUserId")
- @ApiOperation(value = "切片盯盘-新增商品")
- public JSONObject getAddItemListByUserId(Long userId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(userId)) {
- throw new Exception("请传入用户id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- requestMap.put("userId", userId);
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- requestMap.put("start", start);
- requestMap.put("end", end);
- List<JSONObject> data = jiaoYangDingPanService.getAddItemListByUserId(requestMap);
- returnJson.put("data", data);
- returnJson.put("code", 200);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("success", false);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- // 分达人数据
- @GetMapping("/getPromoterList")
- @ApiOperation(value = "切片盯盘-成员数据")
- public JSONObject getPromoterList(Long userId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(userId)) {
- throw new Exception("请传入用户id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- String roleId = sysRoleService.getRoleBYUserId(userId);
- // 剪手经理,渠道经理 查询部门下所有成员数据
- List<Long> promoterIds = new ArrayList<>();
- if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
- List<Long> userIds = new ArrayList<>();
- if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
- Long deptId = sysDeptService.getDeptIdByUserId(userId);
- userIds = sysDeptService.getDeptUserListByDeptId(deptId);
- } else {
- userIds.add(userId);
- }
- promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
- } else if ("jy_expert_business".equals(roleId)) {
- promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
- }
- if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
- if (Check.isNull(promoterIds)) {
- throw new Exception("该用户下未查询到绑定达人");
- }
- }
- if (!Check.isNull(promoterIds)) {
- requestMap.put("promoterIds", promoterIds);
- }
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- requestMap.put("start", start);
- requestMap.put("end", end);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
- String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
- String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
- requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
- requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
- Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
- if (start.equals(nowDate) && end.equals(nowDate)) {
- Integer nowHour = DateUtils.getNowHour();
- requestMap.put("nowHour", nowHour);
- }
- List<JSONObject> data = jiaoYangDingPanService.getPromoterList(requestMap);
- returnJson.put("code", 200);
- returnJson.put("data", data);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- @GetMapping("/getDingPanItemList")
- @ApiOperation(value = "切片盯盘")
- public JSONObject getItemList(Long userId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(userId)) {
- throw new Exception("请传入用户id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- String roleId = sysRoleService.getRoleBYUserId(userId);
- // 剪手经理,渠道经理 查询部门下所有成员数据
- List<Long> promoterIds = new ArrayList<>();
- if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
- List<Long> userIds = new ArrayList<>();
- if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
- Long deptId = sysDeptService.getDeptIdByUserId(userId);
- userIds = sysDeptService.getDeptUserListByDeptId(deptId);
- } else {
- userIds.add(userId);
- }
- promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
- } else if ("jy_expert_business".equals(roleId)) {
- promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
- }
- if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
- if (Check.isNull(promoterIds)) {
- throw new Exception("该用户下未查询到绑定达人");
- }
- }
- if (!Check.isNull(promoterIds)) {
- requestMap.put("promoterIds", promoterIds);
- }
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- requestMap.put("start", start);
- requestMap.put("end", end);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
- String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
- String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
- requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
- requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
- Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
- if (start.equals(nowDate) && end.equals(nowDate)) {
- Integer nowHour = DateUtils.getNowHour();
- requestMap.put("nowHour", nowHour);
- }
- List<JSONObject> data = jiaoYangDingPanService.getItemList(requestMap);
- returnJson.put("code", 200);
- returnJson.put("data", data);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- @GetMapping("/getDingPanTuiGuangUserList")
- @ApiOperation(value = "切片盯盘")
- public JSONObject getDingPanTuiGuangUserList(Long userId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(userId)) {
- throw new Exception("请传入用户id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- String roleId = sysRoleService.getRoleBYUserId(userId);
- // 剪手经理,渠道经理 查询部门下所有成员数据
- List<Long> promoterIds = new ArrayList<>();
- if ("jy_bd".equals(roleId) || "jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_scissors".equals(roleId) || "jy_out_operation_manager".equals(roleId) || "jy_out_operation".equals(roleId)) {
- List<Long> userIds = new ArrayList<>();
- if ("jy_bd_manage".equals(roleId) || "jy_scissors_manage".equals(roleId) || "jy_out_operation_manager".equals(roleId)) {
- Long deptId = sysDeptService.getDeptIdByUserId(userId);
- userIds = sysDeptService.getDeptUserListByDeptId(deptId);
- } else {
- userIds.add(userId);
- }
- promoterIds = jiaoYangDingPanService.getPromoterIdsByUserIds(userIds);
- } else if ("jy_expert_business".equals(roleId)) {
- promoterIds = jiaoYangDingPanService.getPromoterIdsByBusinessId(userId);
- }
- if (!"admin".equals(roleId) && !"jy_admnin".equals(roleId) && !"jy_expert_mentor".equals(roleId)) {
- if (Check.isNull(promoterIds)) {
- throw new Exception("该用户下未查询到绑定达人");
- }
- }
- if (!Check.isNull(promoterIds)) {
- requestMap.put("promoterIds", promoterIds);
- }
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- requestMap.put("start", start);
- requestMap.put("end", end);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
- String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
- String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
- requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
- requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
- Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
- if (start.equals(nowDate) && end.equals(nowDate)) {
- Integer nowHour = DateUtils.getNowHour();
- requestMap.put("nowHour", nowHour);
- }
- List<JSONObject> data = jiaoYangDingPanService.getDingPanTuiGuangUserList(requestMap);
- returnJson.put("code", 200);
- returnJson.put("data", data);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- @GetMapping("/getDingPanMentorBusinessList")
- @ApiOperation(value = "切片盯盘")
- public JSONObject getDingPanMentorBusinessList(Long userId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(userId)) {
- throw new Exception("请传入用户id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- String roleId = sysRoleService.getRoleBYUserId(userId);
- // 剪手经理,渠道经理 查询部门下所有成员数据
- if (!roleId.equals("admin") && !roleId.equals("jy_admnin") && !roleId.equals("jy_expert_mentor")) {
- returnJson.put("code", 200);
- returnJson.put("data", null);
- return returnJson;
- }
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- requestMap.put("start", start);
- requestMap.put("end", end);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
- String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
- String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
- requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
- requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
- Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
- if (start.equals(nowDate) && end.equals(nowDate)) {
- Integer nowHour = DateUtils.getNowHour();
- requestMap.put("nowHour", nowHour);
- }
- List<JSONObject> data = jiaoYangDingPanService.getDingPanMentorBusinessList(requestMap);
- returnJson.put("code", 200);
- returnJson.put("data", data);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- @GetMapping("/getTeamDetail")
- @ApiOperation(value = "切片盯盘")
- public JSONObject getTeamDetail(Long deptId, String startDate, String endDate) {
- Map<String, Object> requestMap = new HashMap<>();
- JSONObject returnJson = new JSONObject();
- try {
- if (Check.isNull(deptId)) {
- throw new Exception("请传入部门id");
- }
- if (Check.isNull(startDate)) {
- throw new Exception("请传入开始日期");
- }
- if (Check.isNull(endDate)) {
- throw new Exception("请传入结束日期");
- }
- requestMap.put("deptId", deptId);
- Long start = DateUtils.strDateToInt(startDate);
- Long end = DateUtils.strDateToInt(endDate);
- requestMap.put("start", start);
- requestMap.put("end", end);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
- String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
- String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
- requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
- requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
- Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
- if (start.equals(nowDate) && end.equals(nowDate)) {
- Integer nowHour = DateUtils.getNowHour();
- requestMap.put("nowHour", nowHour);
- }
- List<JSONObject> data = jiaoYangDingPanService.getDingPanMentorBusinessList(requestMap);
- returnJson.put("code", 200);
- returnJson.put("data", data);
- returnJson.put("success", true);
- } catch (Exception e) {
- e.printStackTrace();
- returnJson.put("code", 500);
- returnJson.put("message", e.getMessage());
- }
- return returnJson;
- }
- }
|