lyhzzz 2 år sedan
förälder
incheckning
f8da9dae09

+ 4 - 0
src/main/java/com/fdkankan/manage/service/IDownloadOrderService.java

@@ -1,9 +1,11 @@
 package com.fdkankan.manage.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.manage.common.PageInfo;
 import com.fdkankan.manage.entity.DownloadOrder;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.manage.vo.request.OrderParam;
+import com.fdkankan.manage.vo.response.DownOrderVo;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -21,4 +23,6 @@ public interface IDownloadOrderService extends IService<DownloadOrder> {
     PageInfo pageList(OrderParam param);
 
     void export(HttpServletRequest req, HttpServletResponse resp);
+
+    Page<DownOrderVo> pageListByParam(OrderParam orderParam);
 }

+ 3 - 0
src/main/java/com/fdkankan/manage/service/ISceneProService.java

@@ -8,6 +8,7 @@ import com.fdkankan.manage.vo.request.SceneParam;
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -42,4 +43,6 @@ public interface ISceneProService extends IService<ScenePro> {
     Long getKkCount(List<String> asList, String startTime);
     Long getSsCount(List<String> asList, String startTime);
     Long getSsObjCount(List<String> asList, String startTime);
+
+    HashMap<String, String> getSnCodeByNumList(Set<String> numList);
 }

+ 20 - 3
src/main/java/com/fdkankan/manage/service/impl/DownloadOrderServiceImpl.java

@@ -20,6 +20,9 @@ import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -45,7 +48,7 @@ public class DownloadOrderServiceImpl extends ServiceImpl<IDownloadOrderMapper,
     @Override
     public PageInfo pageList(OrderParam param) {
         CacheUtil.orderParam = param;
-        Page<DownOrderVo> page = this.getBaseMapper().pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);
+        Page<DownOrderVo> page = this.pageListByParam(param);
         for (DownOrderVo record : page.getRecords()) {
             record.setCreateTime(record.getTradeTime());
             if(StringUtils.isNotBlank(record.getSceneNum())){
@@ -72,11 +75,25 @@ public class DownloadOrderServiceImpl extends ServiceImpl<IDownloadOrderMapper,
     }
 
     @Override
+    public Page<DownOrderVo> pageListByParam(OrderParam orderParam) {
+        Page<DownOrderVo> page = this.getBaseMapper().pageList(new Page<>(orderParam.getPageNum(), orderParam.getPageSize()), orderParam);
+        Set<String> numList = page.getRecords().stream().map(DownOrderVo::getSceneNum).collect(Collectors.toSet());
+        HashMap<String,String> snCodeMap = sceneProService.getSnCodeByNumList(numList);
+
+        for (DownOrderVo record : page.getRecords()) {
+            if(StringUtils.isNotBlank(record.getSceneNum())){
+                record.setSnCode(snCodeMap.get(record.getSceneNum()));
+            }
+        }
+        return page;
+    }
+
+    @Override
     public void export(HttpServletRequest req, HttpServletResponse resp) {
         OrderParam orderParam = CacheUtil.orderParam;
         orderParam.setPageNum(1);
         orderParam.setPageSize(5000);
-        Page<DownOrderVo> page = this.getBaseMapper().pageList(new Page<>(orderParam.getPageNum(),orderParam.getPageSize()),orderParam);
+        Page<DownOrderVo> page = this.pageListByParam(orderParam);
 
         ExcelWriter excelWriter = null;
         try {
@@ -84,7 +101,7 @@ public class DownloadOrderServiceImpl extends ServiceImpl<IDownloadOrderMapper,
             excelService.commonExport(req,resp,"下载订单",page.getRecords(),excelWriter);
             while (page.hasNext()){
                 orderParam.setPageNum(orderParam.getPageNum()+1);
-                page = this.getBaseMapper().pageList(new Page<>(orderParam.getPageNum(),orderParam.getPageSize()),orderParam);
+                page = this.pageListByParam(orderParam);
                 if(page.getRecords().size() >0){
                     excelService.commonExport(req,resp,"下载订单",page.getRecords(),excelWriter);
                 }

+ 42 - 0
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -503,4 +503,46 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         }
         return this.count(wrapper) + count;
     }
+
+    @Override
+    public HashMap<String, String> getSnCodeByNumList(Set<String> numList) {
+        HashMap<String, Long> sceneMap = new HashMap<>();
+        HashMap<Long, String> cameraMap = new HashMap<>();
+        HashMap<String, String> snCodeMap = new HashMap<>();
+
+        LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(ScenePro::getIsUpgrade,0);
+        wrapper.in(ScenePro::getNum,numList);
+        List<ScenePro> list = this.list(wrapper);
+        if(list.size() >0){
+            list.forEach(entity -> sceneMap.put(entity.getNum(),entity.getCameraId()));
+        }
+
+        LambdaQueryWrapper<ScenePlus> wrapper2 = new LambdaQueryWrapper<>();
+        wrapper2.in(ScenePlus::getNum,numList);
+        List<ScenePlus> list2 = scenePlusService.list(wrapper2);
+        if(list2.size() >0){
+            list2.forEach(entity -> sceneMap.put(entity.getNum(),entity.getCameraId()));
+        }
+        if(sceneMap.size() <=0){
+            return snCodeMap;
+        }
+        Set<Long> cameraIds = list.stream().map(ScenePro::getCameraId).collect(Collectors.toSet());
+        Set<Long> cameraIds2 = list2.stream().map(ScenePlus::getCameraId).collect(Collectors.toSet());
+
+        cameraIds.addAll(cameraIds2);
+
+        if(cameraIds.size() >0){
+            List<Camera> cameraList = cameraService.listByIds(cameraIds);
+            cameraList.forEach(entity -> cameraMap.put(entity.getId(),entity.getSnCode()));
+            for (String num : numList) {
+                Long cameraId = sceneMap.get(num);
+                if(cameraId != null){
+                    snCodeMap.put(num,cameraMap.get(cameraId));
+                }
+            }
+        }
+
+        return snCodeMap;
+    }
 }

+ 3 - 1
src/main/java/com/fdkankan/manage/vo/response/DownOrderVo.java

@@ -1,5 +1,6 @@
 package com.fdkankan.manage.vo.response;
 
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
 import lombok.Data;
 
@@ -8,9 +9,10 @@ import java.math.BigDecimal;
 @Data
 public class DownOrderVo {
 
-    @ExcelProperty("ID")
+    @ExcelIgnore
     private Long id;
 
+    @ExcelIgnore
     private String createTime;               //下单时间
 
     @ExcelProperty("下单时间")

+ 3 - 1
src/main/java/com/fdkankan/manage/vo/response/OrderVo.java

@@ -1,5 +1,6 @@
 package com.fdkankan.manage.vo.response;
 
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
 import lombok.Data;
 
@@ -8,7 +9,7 @@ import java.math.BigDecimal;
 @Data
 public class OrderVo {
 
-    @ExcelProperty("ID")
+    @ExcelIgnore
     private Long id;
 
     @ExcelProperty("下单时间")
@@ -35,6 +36,7 @@ public class OrderVo {
     @ExcelProperty("订单状态")
     private String paymentStatus;           //付款状态(未付款unpaid、已付款paid、已取消cancel, 部分支付partPayment, 部分退款partRefund, 全额退款refunded)
 
+    @ExcelIgnore
     private String shipAreaPath;
 
     @ExcelProperty("地址")