소스 검색

热点导入

lyhzzz 1 년 전
부모
커밋
0102db38ac
43개의 변경된 파일1215개의 추가작업 그리고 66개의 파일을 삭제
  1. 12 4
      src/main/java/com/cdf/CdfApplication.java
  2. 9 0
      src/main/java/com/cdf/common/CacheUtil.java
  3. 2 0
      src/main/java/com/cdf/common/ResultCode.java
  4. 21 0
      src/main/java/com/cdf/controller/api/BrandApiController.java
  5. 41 0
      src/main/java/com/cdf/controller/back/BrandController.java
  6. 55 0
      src/main/java/com/cdf/controller/back/ExcelController.java
  7. 55 0
      src/main/java/com/cdf/controller/back/HotOutlineController.java
  8. 80 0
      src/main/java/com/cdf/entity/Brand.java
  9. 56 0
      src/main/java/com/cdf/entity/HotOutline.java
  10. 3 0
      src/main/java/com/cdf/entity/HotRelation.java
  11. 1 18
      src/main/java/com/cdf/generate/AutoGenerate.java
  12. 1 0
      src/main/java/com/cdf/httpClient/request/FdkkHotData.java
  13. 67 0
      src/main/java/com/cdf/httpClient/util/CdfOpenApiUtil.java
  14. 42 0
      src/main/java/com/cdf/httpClient/util/MD5Util.java
  15. 15 0
      src/main/java/com/cdf/httpClient/vo/CdfBrand.java
  16. 14 0
      src/main/java/com/cdf/httpClient/vo/CdfBrandParam.java
  17. 11 0
      src/main/java/com/cdf/httpClient/vo/CdfBrandResult.java
  18. 11 0
      src/main/java/com/cdf/httpClient/vo/CdfResp.java
  19. 18 0
      src/main/java/com/cdf/mapper/IBrandMapper.java
  20. 18 0
      src/main/java/com/cdf/mapper/IHotOutlineMapper.java
  21. 9 0
      src/main/java/com/cdf/request/BrandApiParam.java
  22. 14 0
      src/main/java/com/cdf/request/UploadHotsParam.java
  23. 17 0
      src/main/java/com/cdf/response/BrandApiVo.java
  24. 15 0
      src/main/java/com/cdf/response/HotExcelVo.java
  25. 24 0
      src/main/java/com/cdf/response/HotUploadTemplate.java
  26. 15 0
      src/main/java/com/cdf/response/OutlineUploadTemplate.java
  27. 35 0
      src/main/java/com/cdf/response/ProductUploadTemplate.java
  28. 14 4
      src/main/java/com/cdf/schedule/ScheduleTask.java
  29. 26 0
      src/main/java/com/cdf/service/IBrandService.java
  30. 20 0
      src/main/java/com/cdf/service/IHotOutlineService.java
  31. 170 0
      src/main/java/com/cdf/service/impl/BrandServiceImpl.java
  32. 171 0
      src/main/java/com/cdf/service/impl/ExcelService.java
  33. 12 8
      src/main/java/com/cdf/service/impl/FdkkSceneEditService.java
  34. 33 0
      src/main/java/com/cdf/service/impl/HotOutlineServiceImpl.java
  35. 3 0
      src/main/java/com/cdf/util/DateUtil.java
  36. 81 30
      src/main/java/com/cdf/util/ExcelUtil.java
  37. 3 0
      src/main/resources/application-eurpord.yaml
  38. 1 1
      src/main/resources/application-local.yaml
  39. 3 0
      src/main/resources/application-test.yaml
  40. 5 1
      src/main/resources/application.yaml
  41. 2 0
      src/main/resources/logback-spring.xml
  42. 5 0
      src/main/resources/mapper/BrandMapper.xml
  43. 5 0
      src/main/resources/mapper/HotOutlineMapper.xml

+ 12 - 4
src/main/java/com/cdf/CdfApplication.java

@@ -1,11 +1,14 @@
 package com.cdf;
 
 import com.alibaba.fastjson.JSONObject;
+import com.cdf.common.CacheUtil;
 import com.cdf.httpClient.client.FdkkClient;
 import com.cdf.httpClient.request.FdkkLoginRequest;
 import com.cdf.httpClient.response.FdkkResponse;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.CommandLineRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.ApplicationContext;
@@ -17,17 +20,22 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @MapperScan("com.cdf.**.mapper")
 @ComponentScan(basePackages = {"com.cdf.*","com.fdkankan.*"})
 @EnableScheduling
-public class CdfApplication implements ApplicationContextAware {
+public class CdfApplication implements CommandLineRunner {
 
 
-    static ApplicationContext applicationContext;
+    @Value("${spring.profiles.active:test}")
+    private String activeYaml;
+    @Value("${local.file.path:/home/test}")
+    private String localFilePath;
 
     public static void main(String[] args) {
         SpringApplication.run(CdfApplication.class, args);
     }
 
     @Override
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
-        this.applicationContext = applicationContext;
+    public void run(String... args) throws Exception {
+        CacheUtil.activeYaml = activeYaml;
+        CacheUtil.localFilePath = localFilePath;
+
     }
 }

+ 9 - 0
src/main/java/com/cdf/common/CacheUtil.java

@@ -0,0 +1,9 @@
+package com.cdf.common;
+
+public class CacheUtil {
+
+    public static String activeYaml;
+
+    public static String localFilePath ;
+
+}

+ 2 - 0
src/main/java/com/cdf/common/ResultCode.java

@@ -34,6 +34,8 @@ public enum ResultCode {
 
     PRODUCT_SOURCE_NOT_EXIST(9001,"对接系统店铺不存在"),
     PRODUCT_SOURCE_NOT_DEL(9003,"店铺存在关联数据,不能删除。"),
+
+    DOWN_TEMPLATE_ERROR(10001,"下载模版出错"),
     ;
 
     public int code;

+ 21 - 0
src/main/java/com/cdf/controller/api/BrandApiController.java

@@ -0,0 +1,21 @@
+package com.cdf.controller.api;
+
+import com.cdf.common.ResultData;
+import com.cdf.request.BrandApiParam;
+import com.cdf.service.IBrandService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/api/brand")
+public class BrandApiController {
+
+    @Autowired
+    IBrandService brandService;
+
+
+    @PostMapping("/list")
+    public ResultData list(@RequestBody BrandApiParam param){
+        return ResultData.ok(brandService.pageList(param));
+    }
+}

+ 41 - 0
src/main/java/com/cdf/controller/back/BrandController.java

@@ -0,0 +1,41 @@
+package com.cdf.controller.back;
+
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.cdf.common.PageInfo;
+import com.cdf.common.ResultData;
+import com.cdf.entity.Brand;
+import com.cdf.request.BaseRequest;
+import com.cdf.service.IBrandService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+@RestController
+@RequestMapping("/back/brand")
+public class BrandController {
+
+    @Autowired
+    IBrandService brandService;
+
+
+    @PostMapping("/list")
+    public ResultData list(@RequestBody BaseRequest param){
+        Page<Brand> page = brandService.page(new Page<>(param.getPageNum(), param.getPageSize()));
+        return ResultData.ok(PageInfo.PageInfo(page));
+    }
+
+    @GetMapping("updateBrandInfo")
+    public ResultData updateBrandInfo() throws Exception {
+        brandService.updateBrandInfo();
+        return ResultData.ok();
+    }
+}
+

+ 55 - 0
src/main/java/com/cdf/controller/back/ExcelController.java

@@ -0,0 +1,55 @@
+package com.cdf.controller.back;
+
+
+import com.cdf.common.ResultData;
+import com.cdf.request.UploadHotsParam;
+import com.cdf.service.impl.ExcelService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+@RestController
+@RequestMapping("/back/excel")
+public class ExcelController extends BaseLogController{
+
+    @Autowired
+    ExcelService hotsService;
+
+    /**
+     * 下载导入模版
+     * type  0 外框设置 ,1 瀑布流, 2,精选推荐设置 ,3 品牌推荐设置
+     */
+    @GetMapping("/downTemplate")
+    public ResultData downInTemplate(@RequestParam(required = false,defaultValue = "0") Integer type,
+                                     @RequestParam(required = false) String sceneNum,
+                                     HttpServletRequest req,HttpServletResponse resp)  {
+        hotsService.downTemplate(type,sceneNum,req,resp);
+        return ResultData.ok();
+    }
+
+    @PostMapping("/checkFile")
+    public ResultData checkFile(@RequestBody UploadHotsParam param){
+        param.setToken(getToken());
+        hotsService.checkFile(param);
+        return ResultData.ok();
+    }
+
+    @PostMapping("/uploadExcel")
+    public ResultData uploadExcel(@RequestBody UploadHotsParam param){
+        param.setToken(getToken());
+        hotsService.uploadExcel(param);
+        return ResultData.ok();
+    }
+
+}
+

+ 55 - 0
src/main/java/com/cdf/controller/back/HotOutlineController.java

@@ -0,0 +1,55 @@
+package com.cdf.controller.back;
+
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.cdf.common.PageInfo;
+import com.cdf.common.ResultCode;
+import com.cdf.common.ResultData;
+import com.cdf.entity.HotOutline;
+import com.cdf.exception.BusinessException;
+import com.cdf.request.BaseRequest;
+import com.cdf.service.IHotOutlineService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+@RestController
+@RequestMapping("/back/hotOutline")
+public class HotOutlineController {
+
+    @Autowired
+    IHotOutlineService hotOutlineService;
+
+    @PostMapping("/list")
+    public ResultData list(@RequestBody BaseRequest param){
+        Page<HotOutline> page = hotOutlineService.page(new Page<>(param.getPageNum(), param.getPageSize()));
+        return ResultData.ok(PageInfo.PageInfo(page));
+    }
+
+    @PostMapping("/add")
+    public ResultData add(@RequestBody HotOutline hotOutline){
+        hotOutlineService.save(hotOutline);
+        return ResultData.ok();
+    }
+
+    @PostMapping("/del")
+    public ResultData del(@RequestBody HotOutline hotOutline){
+        if(hotOutline.getId() == null){
+            throw new BusinessException(ResultCode.PARAM_MISS);
+        }
+        hotOutlineService.removeById(hotOutline.getId());
+        return ResultData.ok();
+    }
+}
+

+ 80 - 0
src/main/java/com/cdf/entity/Brand.java

@@ -0,0 +1,80 @@
+package com.cdf.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+@Getter
+@Setter
+@TableName("t_brand")
+public class Brand implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 第三方品牌Id
+     */
+    @TableField("cdf_brand_id")
+    private String cdfBrandId;
+
+    /**
+     * 中文名称
+     */
+    @TableField("zh_name")
+    private String zhName;
+
+    /**
+     * 繁体名称
+     */
+    @TableField("ft_name")
+    private String ftName;
+
+    /**
+     * 英文名称
+     */
+    @TableField("en_name")
+    private String enName;
+
+    /**
+     * 品牌logo
+     */
+    @TableField("brand_logo")
+    private String brandLogo;
+
+    /**
+     * 外框Id
+     */
+    @TableField("outline_id")
+    private Integer outlineId;
+
+    @TableField("tb_status")
+    @TableLogic
+    private Integer tbStatus;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+
+}

+ 56 - 0
src/main/java/com/cdf/entity/HotOutline.java

@@ -0,0 +1,56 @@
+package com.cdf.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+@Getter
+@Setter
+@TableName("t_hot_outline")
+public class HotOutline implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 外框名称
+     */
+    @TableField("outline_name")
+    private String outlineName;
+
+    /**
+     * 外框图片
+     */
+    @TableField("outline_image")
+    private String outlineImage;
+
+    @TableField("tb_status")
+    @TableLogic
+    private Integer tbStatus;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+
+}

+ 3 - 0
src/main/java/com/cdf/entity/HotRelation.java

@@ -43,6 +43,9 @@ public class HotRelation implements Serializable {
     @TableField("product_source_id")
     private Integer productSourceId;
 
+    @TableField("brand_id")
+    private Integer brandId;
+
     @TableField("tb_status")
     private Boolean tbStatus;
 

+ 1 - 18
src/main/java/com/cdf/generate/AutoGenerate.java

@@ -20,26 +20,9 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir") ;
 
         generate(path,"", getTables(new String[]{
-                "t_scene_source_data"
+                "t_brand","t_hot_outline"
         }));
 
-//        generate(path,"goods", getTables(new String[]{
-//                        "t_camera","t_camera_detail","t_camera_out","t_camera_space","t_camera_version",
-//                        "t_company","t_goods","t_goods_sku","t_cart","t_goods_spec",
-//                        "t_goods_spec_value","t_goods_spu_spec","t_sn_code"
-//        }));
-
-//        generate(path,"order", getTables(new String[]{
-//                        "t_increment_order","t_invoice","t_order","t_order_item",
-//                        "t_pre_sale","t_space_sdk","t_trade_log","t_commerce_order","t_download_order","t_expansion_order"
-//        }));
-//        generate(path,"order", getTables(new String[]{
-//                        "t_virtual_order"
-//        }));
-
-//        generate(path,"user", getTables(new String[]{
-//                        "t_user","t_user_increment","t_manager","t_province","t_increment_type","t_intercom_message","t_receiver_info"
-//        }));
     }
 
     public static List<String> getTables(String [] tableNames){

+ 1 - 0
src/main/java/com/cdf/httpClient/request/FdkkHotData.java

@@ -15,4 +15,5 @@ public class FdkkHotData {
     private String hotContent;
 
     private Integer productSourceId;
+    private Integer brandId;
 }

+ 67 - 0
src/main/java/com/cdf/httpClient/util/CdfOpenApiUtil.java

@@ -0,0 +1,67 @@
+package com.cdf.httpClient.util;
+
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.cdf.common.PageInfo;
+import com.cdf.httpClient.vo.*;
+import com.cdf.util.DateUtil;
+
+import java.util.*;
+
+public class CdfOpenApiUtil {
+
+    public static final String CDF_APPID= "A0Dbor9KPFOqvLGnTM";
+    public static final String CDF_AUTH_CODE= "JxRUrnlnnU4fNyMJlsdMTvtnOBqBuAo5";
+    public static final String CDF_APP_SECRET= "sbYX7hQwaB0GlR1BO0jxDvJVs687VUlI";
+
+    public static String createSign( SortedMap<Object,Object> parameters, String key){
+        StringBuilder sb = new StringBuilder();
+        Set<Map.Entry<Object, Object>> es = parameters.entrySet();  //所有参与传参的参数按照accsii排序(升序)
+        Iterator<Map.Entry<Object, Object>> it = es.iterator();
+        while(it.hasNext()) {
+            Map.Entry entry = (Map.Entry)it.next();
+            String k = (String)entry.getKey();
+            Object v = entry.getValue();
+            //空值不传递,不参与签名组串
+            if(null != v && !"".equals(v)) {
+                sb.append(k).append("=").append(v).append("&");
+            }
+        }
+        //System.out.println("字符串:"+sb.toString());
+        sb.append("app_secret=").append(key);
+        //MD5加密,结果转换为大写字符
+        System.out.println(sb.toString());
+        return MD5Util.MD5Encode(sb.toString(), "UTF-8").toUpperCase();
+    }
+
+    public static PageInfo<List<CdfBrand>> getBrandList(Long pageNum, Long pageSize){
+        SortedMap<Object,Object> map = new TreeMap<>();
+        map.put("app_id",CDF_APPID);
+        map.put("auth_code",CDF_AUTH_CODE);
+        map.put("method","sq.brand.list.get");
+        map.put("sign_method","MD5");
+        map.put("nonce_str","3g3jJVfI9CWwKMr45x9SkB0gbi9kAn28");
+        CdfBrandParam cdfBrandParam = new CdfBrandParam(pageNum,pageSize,null);
+        map.put("biz_content",JSONObject.toJSONString(cdfBrandParam));
+        map.put("timestamp", DateUtil.getDateStr(new Date()));
+        String sign = createSign(map, CDF_APP_SECRET);
+        map.put("sign",sign);
+        String jsonString = JSONObject.toJSONString(map);
+        System.out.println(jsonString);
+        String post = HttpUtil.post("https://open.cdfmembers.com/apigateway/v1?app_id="+CDF_APPID+"&method=sq.brand.list.get", jsonString);
+        System.out.println(post);
+        CdfResp resp = JSONObject.parseObject(post, CdfResp.class);
+        if(resp.getCode() == 0000){
+            JSONObject content = resp.getContent();
+            CdfBrandResult brandResult = content.toJavaObject(CdfBrandResult.class);
+            Long totalCount = brandResult.getTotal_count();
+            List<CdfBrand> brands1 =  brandResult.getBrand_list();
+            return PageInfo.PageInfo(pageNum, pageSize, totalCount, brands1);
+        }
+        return null;
+
+    }
+
+
+
+}

+ 42 - 0
src/main/java/com/cdf/httpClient/util/MD5Util.java

@@ -0,0 +1,42 @@
+package com.cdf.httpClient.util;
+
+import java.security.MessageDigest;
+
+public class MD5Util {
+
+    private static String byteArrayToHexString(byte b[]) {
+        StringBuffer resultSb = new StringBuffer();
+        for (int i = 0; i < b.length; i++)
+            resultSb.append(byteToHexString(b[i]));
+
+        return resultSb.toString();
+    }
+
+    private static String byteToHexString(byte b) {
+        int n = b;
+        if (n < 0)
+            n += 256;
+        int d1 = n / 16;
+        int d2 = n % 16;
+        return hexDigits[d1] + hexDigits[d2];
+    }
+
+    public static String MD5Encode(String origin, String charsetname) {
+        String resultString = null;
+        try {
+            resultString = new String(origin);
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            if (charsetname == null || "".equals(charsetname))
+                resultString = byteArrayToHexString(md.digest(resultString
+                        .getBytes()));
+            else
+                resultString = byteArrayToHexString(md.digest(resultString
+                        .getBytes(charsetname)));
+        } catch (Exception exception) {
+        }
+        return resultString;
+    }
+
+    private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5",
+            "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
+}

+ 15 - 0
src/main/java/com/cdf/httpClient/vo/CdfBrand.java

@@ -0,0 +1,15 @@
+package com.cdf.httpClient.vo;
+
+import lombok.Data;
+
+@Data
+public class CdfBrand {
+
+    private String brand_tc_name;
+    private String brand_en_name;
+    private String brand_name;
+    private String logo;
+
+    private String brand_id;
+
+}

+ 14 - 0
src/main/java/com/cdf/httpClient/vo/CdfBrandParam.java

@@ -0,0 +1,14 @@
+package com.cdf.httpClient.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@AllArgsConstructor
+public class CdfBrandParam {
+    private Long page_no;
+    private Long page_rows;
+    private List<Integer> brand_ids ;
+}

+ 11 - 0
src/main/java/com/cdf/httpClient/vo/CdfBrandResult.java

@@ -0,0 +1,11 @@
+package com.cdf.httpClient.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class CdfBrandResult {
+    private Long total_count;
+    private List<CdfBrand> brand_list;
+}

+ 11 - 0
src/main/java/com/cdf/httpClient/vo/CdfResp.java

@@ -0,0 +1,11 @@
+package com.cdf.httpClient.vo;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
+
+@Data
+public class CdfResp {
+    private Integer code;
+    private String message;
+    private JSONObject content;
+}

+ 18 - 0
src/main/java/com/cdf/mapper/IBrandMapper.java

@@ -0,0 +1,18 @@
+package com.cdf.mapper;
+
+import com.cdf.entity.Brand;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+@Mapper
+public interface IBrandMapper extends BaseMapper<Brand> {
+
+}

+ 18 - 0
src/main/java/com/cdf/mapper/IHotOutlineMapper.java

@@ -0,0 +1,18 @@
+package com.cdf.mapper;
+
+import com.cdf.entity.HotOutline;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+@Mapper
+public interface IHotOutlineMapper extends BaseMapper<HotOutline> {
+
+}

+ 9 - 0
src/main/java/com/cdf/request/BrandApiParam.java

@@ -0,0 +1,9 @@
+package com.cdf.request;
+
+import com.cdf.request.BaseRequest;
+import lombok.Data;
+
+@Data
+public class BrandApiParam extends BaseRequest {
+    private String keyWord;
+}

+ 14 - 0
src/main/java/com/cdf/request/UploadHotsParam.java

@@ -0,0 +1,14 @@
+package com.cdf.request;
+
+import lombok.Data;
+
+@Data
+public class UploadHotsParam {
+    private String filePath;
+    /**
+     * 0瀑布流导入,1精选推荐导入,2品牌推荐导入
+     */
+    private Integer type;
+
+    private String token;
+}

+ 17 - 0
src/main/java/com/cdf/response/BrandApiVo.java

@@ -0,0 +1,17 @@
+package com.cdf.response;
+
+import lombok.Data;
+
+@Data
+public class BrandApiVo {
+    private Integer id ;
+    private String cdfBrandId;
+    private String zhName;
+    private String ftName;
+    private String enName;
+    private String brandLogo;
+    private Integer outlineId;
+    private String outlineName;
+    private String outlineImage;
+
+}

+ 15 - 0
src/main/java/com/cdf/response/HotExcelVo.java

@@ -0,0 +1,15 @@
+package com.cdf.response;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class HotExcelVo {
+
+    @ExcelProperty("热点Id")
+    private String sid;
+    @ExcelProperty("热点名称")
+    private String title;
+}

+ 24 - 0
src/main/java/com/cdf/response/HotUploadTemplate.java

@@ -0,0 +1,24 @@
+package com.cdf.response;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+public class HotUploadTemplate {
+
+    @ExcelProperty("场景码")
+    private String sceneNum;
+
+    @ExcelProperty("热点ID")
+    private String sid;
+
+    @ExcelProperty("热点标题")
+    private String hotTitle;
+
+    public HotUploadTemplate(String sceneNum, String sid, String hotTitle) {
+        this.sceneNum = sceneNum;
+        this.sid = sid;
+        this.hotTitle = hotTitle;
+    }
+}

+ 15 - 0
src/main/java/com/cdf/response/OutlineUploadTemplate.java

@@ -0,0 +1,15 @@
+package com.cdf.response;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class OutlineUploadTemplate {
+
+    @ExcelProperty("外框ID")
+    private String outlineId;
+    @ExcelProperty("品牌ID")
+    private String brandId;
+}

+ 35 - 0
src/main/java/com/cdf/response/ProductUploadTemplate.java

@@ -0,0 +1,35 @@
+package com.cdf.response;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+public class ProductUploadTemplate extends HotUploadTemplate{
+
+    @ExcelProperty("店铺ID")
+    private String shopId;
+
+    @ExcelProperty("商品P码")
+    private String productId;
+
+
+    public ProductUploadTemplate(String sceneNum, String sid, String hotTitle) {
+        super(sceneNum, sid, hotTitle);
+    }
+
+    public String getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(String shopId) {
+        this.shopId = shopId;
+    }
+
+    public String getProductId() {
+        return productId;
+    }
+
+    public void setProductId(String productId) {
+        this.productId = productId;
+    }
+}

+ 14 - 4
src/main/java/com/cdf/schedule/ScheduleTask.java

@@ -1,22 +1,23 @@
 package com.cdf.schedule;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.cdf.common.PageInfo;
+import com.cdf.entity.Brand;
 import com.cdf.entity.PageData;
-import com.cdf.entity.SceneSource;
 import com.cdf.entity.SceneSourceData;
 import com.cdf.entity.TotalData;
+import com.cdf.httpClient.util.CdfOpenApiUtil;
+import com.cdf.httpClient.vo.CdfBrand;
+import com.cdf.service.IBrandService;
 import com.cdf.service.IPageDataService;
 import com.cdf.service.ISceneSourceDataService;
-import com.cdf.service.ISceneSourceService;
 import com.cdf.service.ITotalDataService;
 import com.cdf.util.DateUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import javax.naming.ldap.PagedResultsControl;
 import java.math.BigDecimal;
 import java.util.*;
 
@@ -134,4 +135,13 @@ public class ScheduleTask {
         totalDataService.save(totalData);
     }
 
+
+    @Autowired
+    IBrandService brandService;
+
+    @Scheduled(fixedDelay = 24*60*60*1000, initialDelay = 10*1000)
+    public void updateBrand() throws Exception {
+        brandService.updateBrandInfo();
+    }
+
 }

+ 26 - 0
src/main/java/com/cdf/service/IBrandService.java

@@ -0,0 +1,26 @@
+package com.cdf.service;
+
+import com.cdf.entity.Brand;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.cdf.request.BrandApiParam;
+import com.cdf.response.BrandApiVo;
+
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+public interface IBrandService extends IService<Brand> {
+
+    void updateBrandInfo() throws Exception;
+
+    Object pageList(BrandApiParam param);
+
+    HashMap<Integer, BrandApiVo> getMapByIds(Set<Integer> brandIds);
+}

+ 20 - 0
src/main/java/com/cdf/service/IHotOutlineService.java

@@ -0,0 +1,20 @@
+package com.cdf.service;
+
+import com.cdf.entity.HotOutline;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+public interface IHotOutlineService extends IService<HotOutline> {
+
+    HashMap<Integer, HotOutline> getMapByIds(List<Integer> outLineIds);
+}

+ 170 - 0
src/main/java/com/cdf/service/impl/BrandServiceImpl.java

@@ -0,0 +1,170 @@
+package com.cdf.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.cdf.common.PageInfo;
+import com.cdf.entity.Brand;
+import com.cdf.entity.HotOutline;
+import com.cdf.httpClient.util.CdfOpenApiUtil;
+import com.cdf.httpClient.vo.CdfBrand;
+import com.cdf.mapper.IBrandMapper;
+import com.cdf.request.BrandApiParam;
+import com.cdf.response.BrandApiVo;
+import com.cdf.service.IBrandService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cdf.service.IHotOutlineService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+@Service
+@Slf4j
+public class BrandServiceImpl extends ServiceImpl<IBrandMapper, Brand> implements IBrandService {
+
+    @Autowired
+    IHotOutlineService hotOutlineService;
+    @Override
+    public void updateBrandInfo() throws Exception {
+        Long pageNum = 1L;
+        Long pageSize = 100L;
+        List<CdfBrand> allBrand = new ArrayList<>();
+        PageInfo<List<CdfBrand>> pageInfo = CdfOpenApiUtil.getBrandList(pageNum,pageSize);
+        if(pageInfo == null){
+            return;
+        }
+        Long size = 0L;
+        if(pageInfo.getTotal() % pageSize == 0){
+            size = pageInfo.getTotal() /pageSize;
+        }else {
+            size = pageInfo.getTotal() / pageSize +1;
+        }
+        log.info("cdf品牌总数为{},一共为{}页",pageInfo.getTotal(),size);
+        for (long i = 1 ; i<= size;i++){
+            Thread.sleep(500L);
+            allBrand.addAll(pageInfo.getList());
+            pageInfo = CdfOpenApiUtil.getBrandList(i,pageSize);
+        }
+        List<Brand> list = this.list();
+        HashMap<String,Brand> brandHashMap = new HashMap<>();
+        for (Brand brand : list) {
+            brandHashMap.put(brand.getCdfBrandId(),brand);
+        }
+        List<Brand> saveList = new ArrayList<>();
+        for (CdfBrand cdfBrand : allBrand) {
+            Brand brand = brandHashMap.get(cdfBrand.getBrand_id());
+            if(brand == null){
+                brand = new Brand();
+                brand.setCdfBrandId(cdfBrand.getBrand_id());
+            }
+            brand.setZhName(cdfBrand.getBrand_name());
+            brand.setFtName(cdfBrand.getBrand_tc_name());
+            brand.setEnName(cdfBrand.getBrand_en_name());
+            brand.setBrandLogo(cdfBrand.getLogo());
+            saveList.add(brand);
+        }
+        this.saveOrUpdateBatch(saveList);
+
+        List<String> delList = new ArrayList<>();
+        Set<String> cdfBrandIds = saveList.stream().map(Brand::getCdfBrandId).collect(Collectors.toSet());
+        Set<String> dbBrandIds = list.stream().map(Brand::getCdfBrandId).collect(Collectors.toSet());
+        for (String dbBrandId : dbBrandIds) {
+            if(!cdfBrandIds.contains(dbBrandId)){
+                delList.add(dbBrandId);
+            }
+        }
+        if(delList.size() >0){
+            LambdaQueryWrapper<Brand> wrapper = new LambdaQueryWrapper<>();
+            wrapper.in(Brand::getCdfBrandId,delList);
+            this.remove(wrapper);
+        }
+    }
+
+    @Override
+    public Object pageList(BrandApiParam param) {
+        LambdaQueryWrapper<Brand> wrapper = new LambdaQueryWrapper<>();
+        if(StringUtils.isNotBlank(param.getKeyWord())){
+            wrapper.like(Brand::getEnName,param.getKeyWord())
+                    .or()
+                    .like(Brand::getFtName,param.getKeyWord())
+                    .or()
+                    .like(Brand::getZhName,param.getKeyWord());
+        }
+        wrapper.orderByDesc(Brand::getCreateTime);
+        Page<Brand> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
+        List<Integer> outLineIds = page.getRecords().stream().map(Brand::getOutlineId).filter(Objects::nonNull).collect(Collectors.toList());
+        HashMap<Integer, HotOutline> map = hotOutlineService.getMapByIds(outLineIds);
+
+        Page<BrandApiVo> pageVo = new Page<>(param.getPageNum(), param.getPageSize());
+        List<BrandApiVo> listVo = new ArrayList<>();
+        for (Brand record : page.getRecords()) {
+            BrandApiVo vo = new BrandApiVo();
+            BeanUtil.copyProperties(record,vo);
+            HotOutline hotOutline = map.get(record.getOutlineId());
+            if(hotOutline != null){
+                vo.setOutlineName(hotOutline.getOutlineName());
+                vo.setOutlineImage(hotOutline.getOutlineImage());
+            }
+            listVo.add(vo);
+        }
+        pageVo.setTotal(page.getTotal());
+        pageVo.setRecords(listVo);
+
+        return PageInfo.PageInfo(pageVo);
+    }
+
+    @Override
+    public HashMap<Integer, BrandApiVo> getMapByIds(Set<Integer> brandIds) {
+        HashMap<Integer, BrandApiVo> map = new HashMap<>();
+        if(!brandIds.isEmpty()){
+            List<Brand> brands = this.listByIds(brandIds);
+            List<Integer> outLineIds = brands.stream().map(Brand::getOutlineId).filter(Objects::nonNull).collect(Collectors.toList());
+            HashMap<Integer, HotOutline> hotOutlineHashMap = hotOutlineService.getMapByIds(outLineIds);
+            for (Brand brand : brands) {
+                BrandApiVo vo = new BrandApiVo();
+                BeanUtil.copyProperties(brand,vo);
+                HotOutline hotOutline = hotOutlineHashMap.get(brand.getOutlineId());
+                if(hotOutline != null){
+                    vo.setOutlineName(hotOutline.getOutlineName());
+                    vo.setOutlineImage(hotOutline.getOutlineImage());
+                }
+                map.put(vo.getId(),vo);
+            }
+        }
+        return map;
+    }
+
+    public static void main(String[] args) {
+        Long pageNum = 1L;
+        Long pageSize = 100L;
+        List<CdfBrand> allBrand = new ArrayList<>();
+        PageInfo<List<CdfBrand>> pageInfo =CdfOpenApiUtil.getBrandList(pageNum,pageSize);
+        if(pageInfo == null){
+            return;
+        }
+        Long size = 0L;
+        if(pageInfo.getTotal() % pageSize == 0){
+            size = pageInfo.getTotal() /pageSize;
+        }else {
+            size = pageInfo.getTotal() / pageSize +1;
+        }
+        log.info("cdf品牌总数为{},一共为{}页",pageInfo.getTotal(),size);
+        for (long i = 1 ; i<= size;i++){
+            allBrand.addAll(pageInfo.getList());
+            pageInfo = CdfOpenApiUtil.getBrandList(i,pageSize);
+        }
+        System.out.println(allBrand.size());
+    }
+}

+ 171 - 0
src/main/java/com/cdf/service/impl/ExcelService.java

@@ -0,0 +1,171 @@
+package com.cdf.service.impl;
+
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.cdf.common.CacheUtil;
+import com.cdf.common.ResultCode;
+import com.cdf.request.UploadHotsParam;
+import com.cdf.response.HotExcelVo;
+import com.cdf.exception.BusinessException;
+import com.cdf.response.HotUploadTemplate;
+import com.cdf.response.OutlineUploadTemplate;
+import com.cdf.response.ProductUploadTemplate;
+import com.cdf.util.ExcelUtil;
+import com.cdf.util.UploadToCdfOssUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class ExcelService {
+
+    @Resource
+    private UploadToCdfOssUtil uploadToCdfOssUtil;
+
+    @Value("${upload.file-path}")
+    private String filePath;
+    @Value("${upload.query-path}")
+    private String queryPath;
+
+    @Autowired
+    private FdkkSceneEditService fdkkSceneEditService;
+    // 0 外框设置 ,1 瀑布流, 2,精选推荐设置 ,3 品牌推荐设置
+    public void  downTemplate(Integer type,String sceneNum,HttpServletRequest req,HttpServletResponse response)  {
+        if(type == null || StringUtils.isBlank(sceneNum)){
+            throw new BusinessException(ResultCode.PARAM_MISS);
+        }
+        try {
+            List<HotUploadTemplate> list = getHotsList(sceneNum,req.getHeader("token"));
+
+            String fileName = "";
+            switch (type){
+                case 0 :
+                    fileName ="导入外框模版";
+                    this.commonExport(req,response,fileName,list, OutlineUploadTemplate.class);
+                    break;
+                case 1 :
+                    fileName ="导入商品瀑布流模版";
+                    this.commonExport(req,response,fileName,list, ProductUploadTemplate.class);
+                    break;
+                case 2 :
+                    fileName ="导入精选推荐模版";
+                    this.commonExport(req,response,fileName,list, HotUploadTemplate.class);
+                    break;
+                case 3 :
+                    fileName ="导入品牌推荐模版";
+                    this.commonExport(req,response,fileName,list, HotUploadTemplate.class);
+                    break;
+                default: throw new BusinessException(ResultCode.PARAM_MISS);
+            }
+
+        }catch (Exception e){
+            log.info("导出热点列表出错",e);
+        }
+
+    }
+
+    public void commonExport(HttpServletRequest request, HttpServletResponse response,String name,List<?> result,Class<?> clz) throws Exception {
+        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), clz).build();
+        response.setContentType("application/vnd.ms-excel");
+        response.setCharacterEncoding("utf-8");
+        String fileName = name  + ".xlsx";
+        fileName = URLEncoder.encode(fileName, "UTF-8");
+        response.setHeader("Content-disposition", "attachment;filename=" + fileName);
+        WriteSheet writeSheet = EasyExcel.writerSheet(name).build();
+        excelWriter.write(result, writeSheet);
+    }
+
+    public void checkFile(UploadHotsParam param) {
+        if(StringUtils.isBlank(param.getFilePath()) || param.getType() == null){
+            throw new BusinessException(ResultCode.PARAM_MISS);
+        }
+        String awsKey = param.getFilePath().replace(queryPath, "");
+        if(!uploadToCdfOssUtil.existKey(awsKey)){
+            throw new BusinessException(ResultCode.UPLOAD_FILE_NO_EXIST);
+        }
+        String localPath = String.format(CacheUtil.localFilePath, CacheUtil.activeYaml);
+        String localFile = localPath + awsKey;
+        File file = new File(localFile);
+        if (! file.getParentFile().exists()) {
+            file.getParentFile().mkdirs();
+        }
+        uploadToCdfOssUtil.download(awsKey,localFile);
+
+        List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
+        List<HotUploadTemplate> list = null;
+        List<Integer> errorList = new ArrayList<>();
+        Integer colum = 0;
+        List<String> pidList = new ArrayList<>();
+        for (HashMap<Integer, String> map : excelRowList) {
+            String pid = map.get(3);
+            if(StringUtils.isNotBlank(pid)){
+                pidList.add(pid);
+            }
+        }
+
+        for (HashMap<Integer, String> map : excelRowList) {
+            colum ++;
+            String sceneNum = map.get(0);
+            String sid = map.get(1);
+            String title = map.get(2);
+            String pid = map.get(3);
+            if(StringUtils.isBlank(sceneNum) || StringUtils.isBlank(sid) || StringUtils.isBlank(pid)){
+                errorList.add(colum);
+                continue;
+            }
+            if(list == null){
+                list  = getHotsList(sceneNum,param.getToken());
+            }
+            if(list .isEmpty()){
+                errorList.add(colum);
+                continue;
+            }
+            List<String> collect = list.stream().map(HotUploadTemplate::getSid).collect(Collectors.toList());
+            if(!collect.contains(sid)){
+                errorList.add(colum);
+                continue;
+            }
+
+
+
+
+
+        }
+
+    }
+
+    private  List<HotUploadTemplate> getHotsList(String sceneNum,String token){
+        JSONObject tagList = fdkkSceneEditService.getTagList(sceneNum, token, "eshop_cn");
+        JSONArray tags =tagList.getJSONArray("tags");
+        List<HotUploadTemplate> list = new ArrayList<>();
+        for (Object obj : tags) {
+            JSONObject tag = (JSONObject) obj;
+            String sid = tag.getString("sid");
+            String title = tag.getString("title");
+            HotUploadTemplate hotExcelVo = new HotUploadTemplate(sceneNum,sid,title);
+            list.add(hotExcelVo);
+        }
+        return list;
+    }
+
+    public void uploadExcel(UploadHotsParam param) {
+    }
+}

+ 12 - 8
src/main/java/com/cdf/service/impl/FdkkSceneEditService.java

@@ -5,10 +5,7 @@ import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.cdf.common.ResultCode;
-import com.cdf.entity.HotRelation;
-import com.cdf.entity.NumRegion;
-import com.cdf.entity.ProductHk;
-import com.cdf.entity.ProductSource;
+import com.cdf.entity.*;
 import com.cdf.exception.BusinessException;
 import com.cdf.httpClient.client.CdfClient;
 import com.cdf.httpClient.client.CdfHKClient;
@@ -19,10 +16,8 @@ import com.cdf.httpClient.request.FdkkUploadRequest;
 import com.cdf.httpClient.request.SceneRequest;
 import com.cdf.httpClient.response.FdkkResponse;
 import com.cdf.httpClient.response.cdf.*;
-import com.cdf.service.IFdkkUserService;
-import com.cdf.service.IHotRelationService;
-import com.cdf.service.IProductHkService;
-import com.cdf.service.IProductSourceService;
+import com.cdf.response.BrandApiVo;
+import com.cdf.service.*;
 import com.cdf.util.*;
 import com.google.zxing.client.j2se.MatrixToImageWriter;
 import com.google.zxing.common.BitMatrix;
@@ -75,6 +70,8 @@ public class FdkkSceneEditService {
     IFdkkUserService fdkkUserService;
     @Autowired
     IProductSourceService productSourceService;
+    @Autowired
+    IBrandService brandService;
 
 
     public JSONObject getAuth(String num, String token) {
@@ -125,6 +122,7 @@ public class FdkkSceneEditService {
             hotRelation.setNum(fdkkHotRequest.getNum());
             hotRelation.setContent(fdkkHotData.getHotContent());
             hotRelation.setProductSourceId(fdkkHotData.getProductSourceId());
+            hotRelation.setBrandId(fdkkHotData.getBrandId());
             if(update){
                 hotRelationService.updateById(hotRelation);
             }else {
@@ -287,6 +285,7 @@ public class FdkkSceneEditService {
         List<String> sidsList = new ArrayList<>();
         HashMap<String,HotRelation> hotRelationMap = new HashMap<>();
         HashMap<Integer,ProductSource> productSourceMap = new HashMap<>();
+        HashMap<Integer, BrandApiVo> brandMap = new HashMap<>();
         for (Object obj : tags) {
             JSONObject tag = (JSONObject) obj;
             String sid = tag.getString("sid");
@@ -306,6 +305,8 @@ public class FdkkSceneEditService {
                     productSourceMap.put(productSource.getId(),productSource);
                 }
             }
+            Set<Integer> brandIds = hotRelations.stream().map(HotRelation::getBrandId).filter(brandId -> brandId != null).collect(Collectors.toSet());
+            brandMap = brandService.getMapByIds(brandIds);
         }
 
         for (Object obj : tags) {
@@ -335,6 +336,9 @@ public class FdkkSceneEditService {
             if(hotRelation.getProductSourceId() != null){
                 tag.put("productSource",productSourceMap.get(hotRelation.getProductSourceId()));
             }
+            if(hotRelation.getBrandId() != null){
+                tag.put("brand",brandMap.get(hotRelation.getBrandId()));
+            }
             resultMap.put(sid,jsonArray);
             requestArray.addAll(jsonArray);
         }

+ 33 - 0
src/main/java/com/cdf/service/impl/HotOutlineServiceImpl.java

@@ -0,0 +1,33 @@
+package com.cdf.service.impl;
+
+import com.cdf.entity.HotOutline;
+import com.cdf.mapper.IHotOutlineMapper;
+import com.cdf.service.IHotOutlineService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.time.OffsetTime;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-12-06
+ */
+@Service
+public class HotOutlineServiceImpl extends ServiceImpl<IHotOutlineMapper, HotOutline> implements IHotOutlineService {
+
+    @Override
+    public HashMap<Integer, HotOutline> getMapByIds(List<Integer> outLineIds) {
+        HashMap<Integer, HotOutline> map = new HashMap<>();
+        if(!outLineIds.isEmpty()){
+            List<HotOutline> hotOutlines = this.listByIds(outLineIds);
+            hotOutlines.forEach(entity -> map.put(entity.getId(),entity));
+        }
+        return map;
+    }
+}

+ 3 - 0
src/main/java/com/cdf/util/DateUtil.java

@@ -102,4 +102,7 @@ public class DateUtil {
         }
     }
 
+    public static String getDateStr(Date date) {
+        return new SimpleDateFormat(TIME_FORMAT).format(date);
+    }
 }

+ 81 - 30
src/main/java/com/cdf/util/ExcelUtil.java

@@ -1,5 +1,6 @@
 package com.cdf.util;
 
+import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
@@ -8,54 +9,104 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
+@Slf4j
 public class ExcelUtil {
 
-
-    public static List<HashMap<Integer,String>> getExcelRowList(MultipartFile multipartFile) throws IOException {
+    public static List<HashMap<Integer,String>> getExcelRowList(File multipartFile)  {
         //行List,也是最终要返回的List
-        List<HashMap<Integer,String>> rowList=new ArrayList<>();
         Workbook workbook=getExcelWorkBook(multipartFile);
-        Sheet sheet = workbook.getSheetAt(0);
-        if (sheet == null) {
-            throw new IOException("创建Sheet失败!");
-        }
-        //开始遍历行
-        for (int i=1;i<= sheet.getLastRowNum();i++){
-            Row row = sheet.getRow(i);
-            //列List
-            HashMap<Integer,String> map = new HashMap<>();
-            //转换为List数组
-            for (int cellNum=0;cellNum<= row.getLastCellNum();cellNum++){
-                Cell cell = row.getCell(cellNum);
-                if(cell != null){
-                    map.put(cellNum,cell.toString());
+        return getExcelRowList(workbook);
+    }
+
+
+    public static List<HashMap<Integer,String>> getExcelRowList(Workbook workbook)  {
+        //行List,也是最终要返回的List
+        List<HashMap<Integer,String>> rowList = new ArrayList<>();
+        try {
+            Sheet sheet = workbook.getSheetAt(0);
+            if (sheet == null) {
+                throw new IOException("创建Sheet失败!");
+            }
+            //开始遍历行
+            for (int i=1;i<= sheet.getLastRowNum();i++){
+                Row row = sheet.getRow(i);
+                //列List
+                HashMap<Integer,String> map = new HashMap<>();
+                //转换为List数组
+                for (int cellNum=0;cellNum<= row.getLastCellNum();cellNum++){
+                    Cell cell = row.getCell(cellNum);
+                    if(cell != null){
+                        map.put(cellNum,cell.toString());
+                    }
                 }
+                rowList.add(map);
+            }
+
+        }catch (Exception e){
+            log.info("excel-to-list-error:",e);
+        }finally {
+            try {
+                workbook.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
             }
-            rowList.add(map);
         }
-        workbook.close();
+
         return rowList;
     }
+    public static List<HashMap<Integer,String>> getExcelRowList(MultipartFile multipartFile)  {
+        //行List,也是最终要返回的List
+        Workbook workbook=getExcelWorkBook(multipartFile);
+        return getExcelRowList(workbook);
+    }
+
+
 
 
     //获取WorkBook对象
-    private static Workbook getExcelWorkBook(MultipartFile multipartFile) throws IOException {
-        InputStream inputStream=multipartFile.getInputStream();
-        String originalFileName=multipartFile.getOriginalFilename();
-        assert originalFileName != null;
-        String fileType=originalFileName.substring(originalFileName.lastIndexOf(".")+1);
-        if (fileType.equalsIgnoreCase("xls")) {
-            //xls格式
-            return new HSSFWorkbook(inputStream);
-        } else {
-            //xlsx格式
-            return new XSSFWorkbook(inputStream);
+    private static Workbook getExcelWorkBook(MultipartFile multipartFile){
+        try {
+            InputStream inputStream=multipartFile.getInputStream();
+            String originalFileName=multipartFile.getOriginalFilename();
+            assert originalFileName != null;
+            String fileType=originalFileName.substring(originalFileName.lastIndexOf(".")+1);
+            if (fileType.equalsIgnoreCase("xls")) {
+                //xls格式
+                return new HSSFWorkbook(inputStream);
+            } else {
+                //xlsx格式
+                return new XSSFWorkbook(inputStream);
+            }
+        }catch (Exception e){
+            log.info("excel-to-list-error:",e);
+        }
+        return null;
+
+    }
+    private static Workbook getExcelWorkBook(File file)  {
+        try {
+            FileInputStream fileInputStream = new FileInputStream(file);
+            String fileName = file.getName();
+            String fileType=fileName.substring(fileName.lastIndexOf(".")+1);
+            if (fileType.equalsIgnoreCase("xls")) {
+                //xls格式
+                return new HSSFWorkbook(fileInputStream);
+            } else {
+                //xlsx格式
+                return new XSSFWorkbook(fileInputStream);
+            }
+
+        }catch (Exception e){
+            log.info("excel-to-list-error:",e);
         }
+        return null;
     }
 }

+ 3 - 0
src/main/resources/application-eurpord.yaml

@@ -32,6 +32,9 @@ spring:
       shutdown-timeout: 0ms
 logging:
   config: classpath:logback-spring.xml
+  file:
+    path: /home/prod/cdf/logs
+
 mybatis-plus:
   configuration:
     log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl #开启sql日志

+ 1 - 1
src/main/resources/application-local.yaml

@@ -10,7 +10,7 @@ spring:
     name: druidDataSource
     type: com.alibaba.druid.pool.DruidDataSource
     druid:
-      url: jdbc:mysql://18.156.200.112:3306/cdf_gm?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&allowMultiQueries=true
+      url: jdbc:mysql://18.156.200.112:3306/cdf_gm_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&allowMultiQueries=true
       username: root
       password: 4Dage@zhongmian#@168
   redis:

+ 3 - 0
src/main/resources/application-test.yaml

@@ -33,6 +33,9 @@ spring:
       shutdown-timeout: 0ms
 logging:
   config: classpath:logback-spring.xml
+  file:
+    path: /home/test/cdf/logs
+
 mybatis-plus:
   configuration:
     log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl #开启sql日志

+ 5 - 1
src/main/resources/application.yaml

@@ -27,4 +27,8 @@ forest:
   ## 请求超时时间,单位为毫秒, 默认值为3000
   timeout: 300000
   ## 连接超时时间,单位为毫秒, 默认值为2000
-  connect-timeout: 300000
+  connect-timeout: 300000
+
+local:
+  file:
+    path: /home/%s/cdf/file/

+ 2 - 0
src/main/resources/logback-spring.xml

@@ -4,9 +4,11 @@
 <!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
 <!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
 <configuration scan="true" scanPeriod="10 seconds">
+	<springProperty scope="context" name="LOG_PATH" source="logging.file.path"/>
 
 	<contextName>logback</contextName>
 	<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
+	<property name="log.path" value="${LOG_PATH}" />
 	<property name="log.path" value="/home/test/logs/cdf" />
 
 	<!-- 彩色日志 -->

+ 5 - 0
src/main/resources/mapper/BrandMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.cdf.mapper.IBrandMapper">
+
+</mapper>

+ 5 - 0
src/main/resources/mapper/HotOutlineMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.cdf.mapper.IHotOutlineMapper">
+
+</mapper>