|
@@ -1,6 +1,5 @@
|
|
package com.ruixuan.isc.controller;
|
|
package com.ruixuan.isc.controller;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.ruixuan.common.core.controller.BaseController;
|
|
import com.ruixuan.common.core.controller.BaseController;
|
|
import com.ruixuan.common.core.page.TableDataInfo;
|
|
import com.ruixuan.common.core.page.TableDataInfo;
|
|
@@ -10,18 +9,16 @@ import com.ruixuan.data.utils.ExportExcelUtils;
|
|
import com.ruixuan.isc.service.ISupplyChainService;
|
|
import com.ruixuan.isc.service.ISupplyChainService;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
+import lombok.SneakyThrows;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
-
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/isv/supply_chain")
|
|
@RequestMapping("/isv/supply_chain")
|
|
@@ -778,5 +775,301 @@ public class SupplyChainController extends BaseController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取供应链人员列表
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getSupplyChainUserList")
|
|
|
|
+ @ApiOperation(value = "获取供应链成员列表")
|
|
|
|
+ public TableDataInfo getSupplyChainUserList() {
|
|
|
|
+ List<JSONObject> list = supplyChainService.getSupplyChainUserList();
|
|
|
|
+ return getDataTable(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取商品绑定人员列表
|
|
|
|
+ *
|
|
|
|
+ * @param status
|
|
|
|
+ * @param userId
|
|
|
|
+ * @param itemId
|
|
|
|
+ * @param itemTitle
|
|
|
|
+ * @param activityId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/bindUserItemList")
|
|
|
|
+ @ApiOperation(value = "商品认领列表")
|
|
|
|
+ public TableDataInfo bindUserItemList(
|
|
|
|
+ @ApiParam("状态") @RequestParam(value = "status", required = false) Integer status,
|
|
|
|
+ @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
|
|
|
|
+ @ApiParam("商品id") @RequestParam(value = "itemId", required = false) Long itemId,
|
|
|
|
+ @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
|
|
|
|
+ @ApiParam("活动ID") @RequestParam(value = "activityId", required = false) Long activityId
|
|
|
|
+ ) {
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
+ if (!Check.isNull(status)) {
|
|
|
|
+ requestMap.put("status", status);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(userId)) {
|
|
|
|
+ requestMap.put("userId", userId);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(itemId)) {
|
|
|
|
+ requestMap.put("itemId", itemId);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(itemTitle)) {
|
|
|
|
+ requestMap.put("itemTitle", itemTitle);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(activityId)) {
|
|
|
|
+ requestMap.put("activityId", activityId);
|
|
|
|
+ }
|
|
|
|
+ startPage();
|
|
|
|
+ List<JSONObject> list = supplyChainService.bindUserItemList(requestMap);
|
|
|
|
+ return getDataTable(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 商品解绑
|
|
|
|
+ *
|
|
|
|
+ * @param itemId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/unbindUser")
|
|
|
|
+ @ApiOperation(value = "商品解绑")
|
|
|
|
+ public JSONObject unbindUser(
|
|
|
|
+ @ApiParam("商品id") @RequestParam(value = "itemId", required = false) Long itemId) {
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+ if (Check.isNull(itemId)) {
|
|
|
|
+ returnJson.put("code", -1);
|
|
|
|
+ returnJson.put("message", "请传入商品ID");
|
|
|
|
+ return returnJson;
|
|
|
|
+ }
|
|
|
|
+ boolean isTrueOrFalse = supplyChainService.unbindUser(itemId);
|
|
|
|
+ if (isTrueOrFalse) {
|
|
|
|
+ returnJson.put("code", 0);
|
|
|
|
+ returnJson.put("message", "解绑成功");
|
|
|
|
+ return returnJson;
|
|
|
|
+ } else {
|
|
|
|
+ returnJson.put("code", -1);
|
|
|
|
+ returnJson.put("message", "解绑失败");
|
|
|
|
+ return returnJson;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 绑定商品
|
|
|
|
+ *
|
|
|
|
+ * @param itemId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/bindUser")
|
|
|
|
+ @ApiOperation(value = "绑定商品")
|
|
|
|
+ public JSONObject bindUser(
|
|
|
|
+ @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId,
|
|
|
|
+ @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId,
|
|
|
|
+ @ApiParam("用户名称") @RequestParam(value = "nikeName", required = false) String nikeName) {
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+ if (Check.isNull(itemId)) {
|
|
|
|
+ returnJson.put("code", -1);
|
|
|
|
+ returnJson.put("message", "请传入商品ID");
|
|
|
|
+ return returnJson;
|
|
|
|
+ }
|
|
|
|
+ if (Check.isNull("userId")) {
|
|
|
|
+ returnJson.put("code", -1);
|
|
|
|
+ returnJson.put("message", "请传入用户ID");
|
|
|
|
+ return returnJson;
|
|
|
|
+ }
|
|
|
|
+ if (Check.isNull("nikeName")) {
|
|
|
|
+ returnJson.put("code", -1);
|
|
|
|
+ returnJson.put("message", "请传入用户名称");
|
|
|
|
+ return returnJson;
|
|
|
|
+ }
|
|
|
|
+ boolean isTrueOrFalse = supplyChainService.bindUser(itemId, userId, nikeName);
|
|
|
|
+ if (isTrueOrFalse) {
|
|
|
|
+ returnJson.put("code", 0);
|
|
|
|
+ returnJson.put("message", "认领成功");
|
|
|
|
+ return returnJson;
|
|
|
|
+ } else {
|
|
|
|
+ returnJson.put("code", -1);
|
|
|
|
+ returnJson.put("message", "认领失败");
|
|
|
|
+ return returnJson;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 供应链管理员统计列表
|
|
|
|
+ *
|
|
|
|
+ * @param orderStartDate
|
|
|
|
+ * @param orderEndDate
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/adminReportList")
|
|
|
|
+ @ApiOperation(value = "供应链管理员统计列表")
|
|
|
|
+ public TableDataInfo adminReportList(
|
|
|
|
+ @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
|
|
|
|
+ @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
+ if (!Check.isNull(orderStartDate)) {
|
|
|
|
+ Long start = DateUtils.getStartLongTime(orderStartDate);
|
|
|
|
+ requestMap.put("start", start);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(orderEndDate)) {
|
|
|
|
+ Long end = DateUtils.getEndLongTime(orderEndDate);
|
|
|
|
+ requestMap.put("end", end);
|
|
|
|
+ }
|
|
|
|
+ TableDataInfo dataInfo = new TableDataInfo();
|
|
|
|
+ if (Check.isNullMap(requestMap)) {
|
|
|
|
+ dataInfo.setCode(-1);
|
|
|
|
+ dataInfo.setMsg("入参不能为空");
|
|
|
|
+ return dataInfo;
|
|
|
|
+ }
|
|
|
|
+ startPage();
|
|
|
|
+ List<JSONObject> list = supplyChainService.adminReportList(requestMap);
|
|
|
|
+ return getDataTable(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 认领商品列表
|
|
|
|
+ *
|
|
|
|
+ * @param userId
|
|
|
|
+ * @param orderStartDate
|
|
|
|
+ * @param orderEndDate
|
|
|
|
+ * @param itemId
|
|
|
|
+ * @param itemTitle
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/userItemDetail")
|
|
|
|
+ @ApiOperation(value = "认领商品列表")
|
|
|
|
+ public TableDataInfo userItemDetail(
|
|
|
|
+ @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
|
|
|
|
+ @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
|
|
|
|
+ @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
|
|
|
|
+ @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
|
|
|
|
+ @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) Long itemTitle) {
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
+ if (!Check.isNull(userId)) {
|
|
|
|
+ requestMap.put("userId", userId);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(orderStartDate)) {
|
|
|
|
+ Long start = DateUtils.getStartLongTime(orderStartDate);
|
|
|
|
+ requestMap.put("start", start);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(orderEndDate)) {
|
|
|
|
+ Long end = DateUtils.getEndLongTime(orderEndDate);
|
|
|
|
+ requestMap.put("end", end);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(itemId)) {
|
|
|
|
+ requestMap.put("itemId", itemId);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(itemTitle)) {
|
|
|
|
+ requestMap.put("itemTitle", itemTitle);
|
|
|
|
+ }
|
|
|
|
+ TableDataInfo dataInfo = new TableDataInfo();
|
|
|
|
+ if (Check.isNullMap(requestMap)) {
|
|
|
|
+ dataInfo.setCode(-1);
|
|
|
|
+ dataInfo.setMsg("入参不能为空");
|
|
|
|
+ return dataInfo;
|
|
|
|
+ }
|
|
|
|
+ startPage();
|
|
|
|
+ List<JSONObject> list = supplyChainService.userItemDetail(requestMap);
|
|
|
|
+ return getDataTable(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 首页-时段对比
|
|
|
|
+ *
|
|
|
|
+ * @param orderStartDate
|
|
|
|
+ * @param orderEndDate
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ @GetMapping("/indexTimeIntervalRatio")
|
|
|
|
+ @ApiOperation(value = "首页-时段对比")
|
|
|
|
+ public JSONObject indexTimeIntervalRatio(
|
|
|
|
+ @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
|
|
|
|
+ @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
+ String nowDate = DateUtils.getNowDateStr();
|
|
|
|
+ String thisCycleEnd = null; // 当前时段结束日期
|
|
|
|
+ String thisCycleStart = null; // 当前时段开始日期
|
|
|
|
+ String lastCycleEnd = null; // 上一时段结束日期
|
|
|
|
+ String lastCycleStart = null; // 上一时段开始日期
|
|
|
|
+ if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) {
|
|
|
|
+ thisCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
|
|
|
|
+ thisCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleEnd, -6);
|
|
|
|
+ lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleStart, -1);
|
|
|
|
+ lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -6);
|
|
|
|
+ } else {
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(orderStartDate), simpleDateFormat.parse(orderEndDate));
|
|
|
|
+ thisCycleEnd = orderEndDate;
|
|
|
|
+ thisCycleStart = orderStartDate;
|
|
|
|
+ lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1);
|
|
|
|
+ lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -differDay);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(thisCycleStart)) {
|
|
|
|
+ Long thisCycleStartTemp = DateUtils.getStartLongTime(thisCycleStart);
|
|
|
|
+ requestMap.put("thisCycleStartTemp", thisCycleStartTemp);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(thisCycleEnd)) {
|
|
|
|
+ Long thisCycleEndTemp = DateUtils.getEndLongTime(thisCycleEnd);
|
|
|
|
+ requestMap.put("thisCycleEndTemp", thisCycleEndTemp);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(lastCycleStart)) {
|
|
|
|
+ Long lastCycleStartTemp = DateUtils.getStartLongTime(lastCycleStart);
|
|
|
|
+ requestMap.put("lastCycleStartTemp", lastCycleStartTemp);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(lastCycleEnd)) {
|
|
|
|
+ Long lastCycleEndTemp = DateUtils.getEndLongTime(lastCycleEnd);
|
|
|
|
+ requestMap.put("lastCycleEndTemp", lastCycleEndTemp);
|
|
|
|
+ }
|
|
|
|
+ JSONObject timeIntervalRatioJson = supplyChainService.getTimeIntervalRatio(requestMap);
|
|
|
|
+ return timeIntervalRatioJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 首页-统计图
|
|
|
|
+ *
|
|
|
|
+ * @param orderStartDate
|
|
|
|
+ * @param orderEndDate
|
|
|
|
+ * @param type
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/indexStatistics")
|
|
|
|
+ @ApiOperation(value = "首页-统计图")
|
|
|
|
+ public List<JSONObject> indexStatistics(
|
|
|
|
+ @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
|
|
|
|
+ @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
|
|
|
|
+ @ApiParam("类型") @RequestParam(value = "type", required = false) String type) {
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
+ String nowDate = DateUtils.getNowDateStr();
|
|
|
|
+ String start = null;
|
|
|
|
+ String end = null;
|
|
|
|
+ if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) {
|
|
|
|
+ end = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
|
|
|
|
+ start = DateUtils.getAnotherDay("yyyy-MM-dd", end, -6);
|
|
|
|
+ } else {
|
|
|
|
+ start = orderStartDate;
|
|
|
|
+ end = orderEndDate;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(start)) {
|
|
|
|
+ Long startTemp = DateUtils.getStartLongTime(start);
|
|
|
|
+ requestMap.put("startTemp", startTemp);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(end)) {
|
|
|
|
+ Long endTemp = DateUtils.getEndLongTime(end);
|
|
|
|
+ requestMap.put("endTemp", endTemp);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(type)) {
|
|
|
|
+ requestMap.put("type", type);
|
|
|
|
+ }
|
|
|
|
+ List<JSONObject> list = supplyChainService.indexStatistics(requestMap);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
}
|
|
}
|