‘linchangsheng’ 4 mesi fa
parent
commit
915e08d0d3

+ 48 - 2
mall-server-api/src/main/java/com/gree/mall/manager/logic/comlist/ComListLogic.java

@@ -38,6 +38,7 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import javax.servlet.http.HttpServletRequest;
@@ -143,7 +144,7 @@ public class ComListLogic {
 
         //上传主文件到oss,并记录
         //CommonFile commonFile = commonLogic.uploadFile(file);
-
+/*
         InputStream inputStream = commonLogic.getFileInputStreamByUrl(file);
         List<Object> objects = ExcelUtils.importExcel(inputStream);
         //拆分excel并上传oss
@@ -172,7 +173,7 @@ public class ComListLogic {
             comDetails.add(comDetail);
             //}
         }
-        comDetailService.saveBatch(comDetails);
+        comDetailService.saveBatch(comDetails);*/
     }
 
     public void download(String id, String downloadPwd, HttpServletRequest request, HttpServletResponse response) throws IOException {
@@ -588,4 +589,49 @@ public class ComListLogic {
         }
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    public void upFile() {
+        List<ComList> comListList = comListService.lambdaQuery()
+                .eq(ComList::getType, "CENTER")
+                .eq(ComList::getCenterUp, 0).list();
+
+        if (!CollectionUtil.isEmpty(comListList)){
+            for (ComList comList : comListList) {
+                List<ComDetail> list = comDetailService.lambdaQuery()
+                        .eq(ComDetail::getComListId, comList.getId()).list();
+                ComDetail comDetail1 = list.get(0);
+
+                InputStream inputStream = commonLogic.getFileInputStreamByUrl(comDetail1.getFileUrl());
+                List<Object> objects = ExcelUtils.importExcel(inputStream);
+                //拆分excel并上传oss
+                List<Map<String, Object>> fileUrls = this.createExcel(objects);
+                if (fileUrls == null) {
+                    throw new RemoteServiceException("拆分失败");
+                }
+                List<ComDetail> comDetails = new ArrayList<>();
+                for (Map<String, Object> fileUrl : fileUrls) {
+                    String websitNumber = (String) fileUrl.get("websitNumber");
+                    String filePath = (String) fileUrl.get("filePath");
+                    //新增拆分的附件明细表
+                    //for(Belongcompany belongcompany : list) {
+                    ComDetail comDetail = new ComDetail();
+                    comDetail.setCompanyWechatId(comDetail1.getCompanyWechatId());
+                    comDetail.setCompanyName(comDetail1.getCompanyName());
+                    comDetail.setTitle(comDetail1.getTitle());
+                    comDetail.setComListId(comDetail1.getComListId());
+                    comDetail.setFileName(comDetail1.getTitle());
+                    comDetail.setWebsitId(websitNumber);
+                    comDetail.setFileUrl(filePath);
+                    comDetail.setIsDownload(false);
+                    comDetail.setCreateTime(new Date());
+                    comDetail.setIsNotice(comList.getIsNotice());
+                    //comDetail.insert();
+                    comDetails.add(comDetail);
+                    //}
+                }
+                comDetailService.saveBatch(comDetails);
+            }
+
+        }
+    }
 }

+ 51 - 0
mall-server-api/src/main/java/com/gree/mall/manager/schedule/ComListSchedule.java

@@ -0,0 +1,51 @@
+package com.gree.mall.manager.schedule;
+
+import cn.hutool.core.date.DateUtil;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.gree.mall.manager.enums.workorder.OrderBaseStatusEnum;
+import com.gree.mall.manager.logic.comlist.ComListLogic;
+import com.gree.mall.manager.logic.common.WechatLogic;
+import com.gree.mall.manager.logic.websit.SettlementOrderLogic;
+import com.gree.mall.manager.logic.workorder.OrderBaseLogic;
+import com.gree.mall.manager.plus.entity.PgOrderBase;
+import com.gree.mall.manager.plus.entity.SettlementOrder;
+import com.gree.mall.manager.plus.service.PgOrderBaseService;
+import com.gree.mall.manager.plus.service.SettlementOrderService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 中心文件上传
+ * @author :lijh
+ * @description:TODO
+ * @date :2024/4/26 14:12
+ */
+@ConditionalOnProperty(name = "schedule.enable", havingValue = "true", matchIfMissing = true)
+@Component
+@Slf4j
+public class ComListSchedule {
+
+    @Autowired
+    ComListLogic comListLogic;
+
+
+    /**
+     * 生成抢单通知
+     */
+    @Transactional
+    @Scheduled(fixedDelay = 5*60 * 1000)
+    public void task() {
+        comListLogic.upFile();
+    }
+
+
+}