Browse Source

CSV格式文件导入,与回调

zhaoxian 1 year ago
parent
commit
bd33efea92

+ 51 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/material/controller/FirstDeliveryValidController.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.material.controller;
 package cn.com.ctop.toutiao.modules.material.controller;
 
 
+import cn.com.ctop.common.module.service.ISendMessageService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
@@ -10,6 +11,8 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.common.util.RedisUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -39,6 +42,11 @@ public class FirstDeliveryValidController {
     @Value("${zip.local.download-path}")
     @Value("${zip.local.download-path}")
     private String downloadPath;
     private String downloadPath;
 
 
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @Autowired
+    private ISendMessageService sendMessageService;
 
 
     /**
     /**
      * 导入EXCEL批量创建
      * 导入EXCEL批量创建
@@ -48,13 +56,52 @@ public class FirstDeliveryValidController {
     @PostMapping(value = "/importExcelMaterials")
     @PostMapping(value = "/importExcelMaterials")
     @ResponseBody
     @ResponseBody
     public Result<Object> importExcelMaterials(HttpServletResponse response, @RequestParam("file") MultipartFile file) throws Exception {
     public Result<Object> importExcelMaterials(HttpServletResponse response, @RequestParam("file") MultipartFile file) throws Exception {
-        StringBuffer path = new StringBuffer();
-        path.append(downloadPath).append("excel").append("/").append(DateUtils.formatDate()).append("/");
-        String newFileUrl = FileUtil.approvalFile(file, path.toString());
-        HttpUtils.fileUpload("http://ruixuan.api.tjyourong.com.cn/itemCollectSamples/importExcelMaterials", newFileUrl, null);
+        String nowDate = DateUtils.date2Str();
+        String key = nowDate + "_importExcelMaterials";
+        Object creative = redisUtil.get(key);
+        if (Check.isNull(creative)) {
+            StringBuffer path = new StringBuffer();
+            path.append(downloadPath).append("excel").append("/").append(DateUtils.formatDate()).append("/");
+            String newFileUrl = FileUtil.approvalFile(file, path.toString());
+            //宇鹏本地服务
+//            HttpUtils.fileUpload("http://192.168.1.149:8765/webhook/get_file", newFileUrl, null);
+            //宇鹏外网服务
+            HttpUtils.fileUpload("http://111.204.208.194:9998/webhook/get_file", newFileUrl, null);
+            redisUtil.set(key, "NO");
+        } else {
+            Result.successMsg("文件上传中...", null);
+        }
         return Result.successMsg("ok", null);
         return Result.successMsg("ok", null);
     }
     }
 
 
+
+    @GetMapping(value = "/excelCallBack")
+    public void excelCallBack(String msg) {
+        String nowDate = DateUtils.date2Str();
+        String key = nowDate + "_importExcelMaterials";
+        redisUtil.removeAll(key);
+        List<String> userIds = new ArrayList<>();
+        //秦可心  于蒙
+        userIds.add("c6dcc96ef9ed413aa224f10ec652fb88");
+        userIds.add("113dee46c7df464da78c07a985e92cd1");
+        StringBuilder text = new StringBuilder();
+        if ("error".equals(msg)) {
+//            赵西安
+            userIds.add("1b3deb8258e84df994f1371a51cfc14a");
+            text.append("上传首投有效素材失败通知:").append("<br/>")
+                    .append("您好,您上传的EXCEL文件录入失败").append("<br/>")
+                    .append("请联系管理员!");
+            for (String userId : userIds) {
+                sendMessageService.sendMessage(userId, text.toString());
+            }
+        } else {
+            text.append("上传首投有效素材成功通知:").append("<br/>")
+                    .append("您好,您上传的EXCEL文件已录入成功");
+            for (String userId : userIds) {
+                sendMessageService.sendMessage(userId, text.toString());
+            }
+        }
+    }
     /**
     /**
      * 导入EXCEL批量创建
      * 导入EXCEL批量创建
      * 返点-首投有效素材明细
      * 返点-首投有效素材明细