Browse Source

Changes 修改站点绑定业务

cyan 3 months ago
parent
commit
fa03353160

+ 30 - 3
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/okki/site/controller/ShopApiController.java

@@ -20,8 +20,14 @@ import org.jeecg.modules.okki.wechatgroup.service.IOkkiShopWechatGroupMsgService
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 /**
  * @Description: 站点
@@ -212,14 +218,35 @@ public class ShopApiController {
      * @param authorization
      * @return
      */
-    @PostMapping(value = "/deal/site/info")
-    public Result<?> dealOkkiSiteInfo(@RequestHeader(HttpHeaders.AUTHORIZATION) String authorization) {
+    @PostMapping(value = "/upload/site/info")
+    public Result<?> dealUploadSiteInfo(@RequestParam("files") MultipartFile files, @RequestHeader(HttpHeaders.AUTHORIZATION) String authorization) throws IOException {
+        Map<String, Object> map = new HashMap<>();
         log.info("请求参数 authorization:{}", authorization);
         String Authorization = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImRlYW4iLCJleHAiOjE3MTQ0NjU5Njl9.QdCBYR8mioXcKGi1n5RdMQ5RbJHCSGbE8dkdwYuOXh4";
         if (!authorization.equals(Authorization)) {
             return Result.error("sign 验证不通过");
         }
-        boolean result = okkiSiteService.dealSiteInfoByJsonData(fileJsonPath);
+
+        //获取原始文件名
+        String originalFilename = files.getOriginalFilename();
+        log.info("originalFilename:{}", originalFilename);
+
+        //获取文件文件扩展名
+        String extname = originalFilename.substring(originalFilename.lastIndexOf("."));
+        log.info("extname:{}", extname);
+        if (!extname.contains("json")) {
+            map.put("status", 502);
+            return Result.error("文件格式不正确");
+        }
+
+        //随机名+文件扩展名
+        String newFileName = UUID.randomUUID() + extname;
+        log.info("newFileName:{}", newFileName);
+
+        String pathDir = fileJsonPath + "/" + newFileName;
+        files.transferTo(new File(pathDir));
+
+        boolean result = okkiSiteService.dealSiteInfoByJsonData(pathDir);
         if (result) {
             return Result.ok("同步站点信息成功");
         }

+ 9 - 4
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/okki/site/service/impl/OkkiSiteServiceImpl.java

@@ -644,14 +644,19 @@ public class OkkiSiteServiceImpl extends ServiceImpl<OkkiSiteMapper, OkkiSite> i
             String siteIdStr = String.valueOf(item.get("网站ID"));
             String[] parts = siteIdStr.split("\\.");
             String siteId = parts[0];
-            log.info("siteId:{}", siteId);
+//            log.info("siteId:{}", siteId);
             if (xiaoManSiteDtoMap.containsKey(siteId)) {
-                dealUpdateCustomerInfo(item, xiaoManSiteDtoMap.get(siteId));
+                ThreadPoolUtil.execute(new Runnable() {
+                    @Override
+                    public void run() {
+                        dealUpdateCustomerInfo(item, xiaoManSiteDtoMap.get(siteId));
+                    }
+                });
             }
         }
 
         // 发送消息
-        feiShuMsgService.syncXiaoManDashboardData();
+//        feiShuMsgService.syncXiaoManDashboardData();
         return true;
     }
 
@@ -659,7 +664,7 @@ public class OkkiSiteServiceImpl extends ServiceImpl<OkkiSiteMapper, OkkiSite> i
      * 处理客服团队信息的更新逻辑
      */
     private void dealUpdateCustomerInfo(Map<String, Object> customerInfo, XiaoManSiteDto xiaoManSiteDto) {
-        log.info("customerInfo:{},xiaoManSiteDto:{}", FastJsonUtil.toJSONString(customerInfo), FastJsonUtil.toJSONString(xiaoManSiteDto));
+//        log.info("customerInfo:{},xiaoManSiteDto:{}", FastJsonUtil.toJSONString(customerInfo), FastJsonUtil.toJSONString(xiaoManSiteDto));
         // 初始化飞书更新 DTO
         String recordId = (String) customerInfo.get("record_id");
         FeiShuRecordSheetDto recordSheetDto = new FeiShuRecordSheetDto();

+ 1 - 1
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml

@@ -323,4 +323,4 @@ aws:
   service : lambda
 
 file:
-  jsonPath: /home/ubuntu/okki-oms/files/xiaoman_dashboard.json
+  jsonPath: /home/ubuntu/okki-oms/files