|
|
@@ -0,0 +1,83 @@
|
|
|
+/*
|
|
|
+ * +----------------------------------------------------------------------
|
|
|
+ * | Copyright (c) 奇特物联 2021-2022 All rights reserved.
|
|
|
+ * +----------------------------------------------------------------------
|
|
|
+ * | Licensed 未经许可不能去掉「奇特物联」相关版权
|
|
|
+ * +----------------------------------------------------------------------
|
|
|
+ * | Author: xw2sy@163.com
|
|
|
+ * +----------------------------------------------------------------------
|
|
|
+ */
|
|
|
+package cc.iotkit.manager.controller;
|
|
|
+
|
|
|
+import cc.iotkit.common.api.PageRequest;
|
|
|
+import cc.iotkit.common.api.Paging;
|
|
|
+import cc.iotkit.common.api.Request;
|
|
|
+import cc.iotkit.common.log.annotation.Log;
|
|
|
+import cc.iotkit.common.log.enums.BusinessType;
|
|
|
+import cc.iotkit.common.validate.AddGroup;
|
|
|
+import cc.iotkit.common.validate.EditGroup;
|
|
|
+import cc.iotkit.manager.dto.bo.category.CategoryBo;
|
|
|
+import cc.iotkit.manager.dto.bo.product.ProductBo;
|
|
|
+import cc.iotkit.manager.dto.bo.productmodel.ProductModelBo;
|
|
|
+import cc.iotkit.manager.dto.bo.thingmodel.ThingModelBo;
|
|
|
+import cc.iotkit.manager.dto.vo.category.CategoryVo;
|
|
|
+import cc.iotkit.manager.dto.vo.product.ProductVo;
|
|
|
+import cc.iotkit.manager.dto.vo.productmodel.ProductModelVo;
|
|
|
+import cc.iotkit.manager.dto.vo.thingmodel.ThingModelVo;
|
|
|
+import cc.iotkit.manager.service.IProductService;
|
|
|
+import cc.iotkit.model.product.Category;
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Api(tags = {""})
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/home")
|
|
|
+public class HomeController {
|
|
|
+ @Autowired
|
|
|
+ private IProductService productService;
|
|
|
+ @ApiOperation("简介")
|
|
|
+ @PostMapping("/data")
|
|
|
+ public Map data() {
|
|
|
+ Map<String,Object> dataMap = new HashMap<>();
|
|
|
+ List<CategoryVo> categoryVos = productService.selectCategoryList();
|
|
|
+ Date todayZero = todayZeroTime();
|
|
|
+ Map<String,String> categoryMap = new HashMap<>();
|
|
|
+ if(CollectionUtil.isNotEmpty(categoryVos)){
|
|
|
+ dataMap.put("categoryAllNum",categoryVos.size());
|
|
|
+ Integer categoryTodayNum = categoryVos.stream().map(item->new Date(item.getCreateAt()).compareTo(todayZero)>0)
|
|
|
+ .collect(Collectors.toList()).size();
|
|
|
+ dataMap.put("categoryTodayNum",categoryTodayNum);
|
|
|
+ categoryMap = categoryVos.stream().collect(Collectors.toMap(CategoryVo::getId,CategoryVo::getName));
|
|
|
+ }
|
|
|
+ List<ProductVo> productVos = productService.selectProductList();
|
|
|
+ if(CollectionUtil.isNotEmpty(productVos)){
|
|
|
+ dataMap.put("productAllNum",productVos.size());
|
|
|
+ Integer productTodayNum = categoryVos.stream().map(item->new Date(item.getCreateAt()).compareTo(todayZero)>0)
|
|
|
+ .collect(Collectors.toList()).size();
|
|
|
+ dataMap.put("productTodayNum",productTodayNum);
|
|
|
+ }
|
|
|
+ return dataMap;
|
|
|
+ }
|
|
|
+ private Date todayZeroTime(){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY,0);
|
|
|
+ calendar.set(Calendar.MINUTE,0);
|
|
|
+ calendar.set(Calendar.HOUR,0);
|
|
|
+ calendar.set(Calendar.MILLISECOND,0);
|
|
|
+ return calendar.getTime();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|