Browse Source

添加手淘数据导入接口

songyh 4 years ago
parent
commit
49d3aeb2f8

+ 4 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceCustomerDdTbtjDataController.java

@@ -23,8 +23,10 @@ import lombok.extern.slf4j.Slf4j;
 
 import org.jeecg.modules.ctop.entity.BytedanceCustomerDdTbtjData;
 import org.jeecg.modules.ctop.service.IBytedanceCustomerDdTbtjDataService;
+import org.jeecg.modules.excelutil.BytedanceCustomTbtjDataExcelListener;
 import org.jeecg.modules.excelutil.ExcelUtils;
 import org.jeecg.modules.excelutil.JhsBakendDataExcelListener;
+import org.jeecg.modules.excelutil.entity.BytedanceCustomTbtjDataEntity;
 import org.jeecg.modules.excelutil.entity.JhsBakendDataEntity;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -194,9 +196,8 @@ public class BytedanceCustomerDdTbtjDataController {
 		  try {
 			  MultipartFile file = entity.getValue();
 			  fis = (FileInputStream) file.getInputStream();
-			  //TODO ---需要创建监听类+实体类
-			  AnalysisEventListener listener = new JhsBakendDataExcelListener();
-			  Boolean flag = ExcelUtils.readExcel(fis, JhsBakendDataEntity.class, listener);
+			  AnalysisEventListener listener = new BytedanceCustomTbtjDataExcelListener();
+			  Boolean flag = ExcelUtils.readExcel(fis, BytedanceCustomTbtjDataEntity.class, listener);
 			  System.out.println("导入是否成功:" + flag);
 		  } catch (Exception e) {
 			  e.printStackTrace();

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/BytedanceCustomerDdTbtjData.java

@@ -21,7 +21,7 @@ public class BytedanceCustomerDdTbtjData {
 	@TableId(type = IdType.AUTO)
 	private Long id;
 	/**adId*/
-	private Integer adId;
+	private Long adId;
 	/**stateDate*/
 	private String stateDate;
 	/**loginCnt*/

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/BytedanceCustomerDdTbtjDataMapper.xml

@@ -14,7 +14,7 @@
         <foreach collection="datas" item="data" separator=",">
             (
             #{data.adId},
-            #{data.stateDate},
+            #{data.dateString},
             #{data.loginCnt},
             #{data.buyerCnt},
             #{data.nextDayStay}

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/BytedanceCustomTbtjDataExcelListener.java

@@ -3,10 +3,12 @@ package org.jeecg.modules.excelutil;
 import cn.com.ctop.common.module.utils.SpringUtils;
 import com.alibaba.excel.context.AnalysisContext;
 import com.alibaba.excel.event.AnalysisEventListener;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.impl.BytedanceCustomerDdTbtjDataServiceImpl;
 import org.jeecg.modules.excelutil.entity.BytedanceCustomTbtjDataEntity;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 public class BytedanceCustomTbtjDataExcelListener extends AnalysisEventListener<BytedanceCustomTbtjDataEntity> {
@@ -18,6 +20,8 @@ public class BytedanceCustomTbtjDataExcelListener extends AnalysisEventListener<
     @Override
     public void invoke(BytedanceCustomTbtjDataEntity object, AnalysisContext context) {
         //数据存储到list,供批量处理,或后续自己业务逻辑处理。
+        Date date = object.getStateDate();
+        object.setDateString(DateUtils.formatDate(date,"yyyy-MM-dd HH:mm:ss"));
         datas.add(object);
         if(null!=datas&&datas.size()>=BATCH_COUNT){
             saveDate();

+ 20 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/BytedanceCustomTbtjDataEntity.java

@@ -3,27 +3,31 @@ package org.jeecg.modules.excelutil.entity;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.metadata.BaseRowModel;
 
+import java.util.Date;
+
 public class BytedanceCustomTbtjDataEntity extends BaseRowModel {
     /**日期*/
-    @ExcelProperty(value = "日期", index = 1)
-    private String stateDate;
+    @ExcelProperty(value = "日期", index = 0)
+    private Date stateDate;
     /**计划id*/
-    @ExcelProperty(value = "计划id", index = 2)
+    @ExcelProperty(value = "计划id", index = 1)
     private Long adId;
-    @ExcelProperty(value = "登录人数", index = 3)
+    @ExcelProperty(value = "登录人数", index = 2)
     private Integer loginCnt;
     /**bugerCnt*/
-    @ExcelProperty(value = "首购人数", index = 4)
+    @ExcelProperty(value = "首购人数", index = 3)
     private Integer buyerCnt;
     /**nextDayStay*/
-    @ExcelProperty(value = "次留数", index = 5)
+    @ExcelProperty(value = "次留数", index = 4)
     private Integer nextDayStay;
+    
+    private String dateString;
 
-    public String getStateDate() {
+    public Date getStateDate() {
         return stateDate;
     }
 
-    public void setStateDate(String stateDate) {
+    public void setStateDate(Date stateDate) {
         this.stateDate = stateDate;
     }
 
@@ -58,4 +62,12 @@ public class BytedanceCustomTbtjDataEntity extends BaseRowModel {
     public void setNextDayStay(Integer nextDayStay) {
         this.nextDayStay = nextDayStay;
     }
+
+    public String getDateString() {
+        return dateString;
+    }
+
+    public void setDateString(String dateString) {
+        this.dateString = dateString;
+    }
 }