From f53c26884de8f3fd5b15a5a36c5743225d8b5628 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期五, 06 十二月 2024 16:45:22 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java
index f980197..8d71d90 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java
@@ -5,6 +5,8 @@
 import cn.afterturn.easypoi.excel.entity.ExportParams;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.chargingPile.api.dto.GetSiteListDTO;
+import com.ruoyi.chargingPile.api.feignClient.SiteClient;
 import com.ruoyi.chargingPile.api.model.TParkingLot;
 import com.ruoyi.chargingPile.api.model.TParkingRecord;
 import com.ruoyi.chargingPile.api.query.ParkingRecordQuery;
@@ -22,6 +24,7 @@
 import com.ruoyi.common.log.annotation.Log;
 import com.ruoyi.common.log.enums.BusinessType;
 import com.ruoyi.common.log.enums.OperatorType;
+import com.ruoyi.common.security.service.TokenService;
 import com.ruoyi.order.api.query.TOrderInvoiceQuery;
 import com.ruoyi.order.api.vo.TCharingUserEquimentVO;
 import com.ruoyi.order.api.vo.TOrderInvoiceVO;
@@ -37,6 +40,7 @@
 import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -59,14 +63,41 @@
     private TParkingRecordService parkingRecordService;
     @Resource
     private TParkingLotService parkingLotService;
+    @Resource
+    private SiteClient siteClient;
+    @Resource
+    private TokenService tokenService;
 
     @ApiOperation(tags = {"后台-订单管理-停车记录"},value = "列表")
     @PostMapping(value = "/page")
     public R<Page<TParkingRecord>> page(@RequestBody ParkingRecordPageQuery query) {
+        Long userid = tokenService.getLoginUser().getUserid();
+        List<Integer> siteIds = new ArrayList<>();
+
+            List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userid).getData();
+            for (GetSiteListDTO datum : data) {
+                siteIds.add(datum.getId());
+            }
+        List<TParkingLot> list = parkingLotService.lambdaQuery().in(!siteIds.isEmpty(), TParkingLot::getSiteId, siteIds).list();
+        List<Integer> ids = new ArrayList<>();
+        for (TParkingLot tParkingLot : list) {
+            ids.add(tParkingLot.getId());
+        }
+
+        String s1 = "";
+        String s2 = "";
+        if (query.getTimePeriod()!=null){
+             s1 = query.getTimePeriod().split(" - ")[0];
+             s2 = query.getTimePeriod().split(" - ")[1];
+        }
         Page<TParkingRecord> page = parkingRecordService.lambdaQuery()
                 .like(query.getLicensePlate() != null, TParkingRecord::getLicensePlate, query.getLicensePlate())
                 .eq(query.getStatus() != null, TParkingRecord::getStatus, query.getStatus())
                 .eq(query.getOutParkingType() != null, TParkingRecord::getOutParkingType, query.getOutParkingType())
+                .between(query.getTimePeriod()!=null,TParkingRecord::getInParkingTime,s1,s2)
+                .or()
+                .between(query.getTimePeriod()!=null,TParkingRecord::getOutParkingTime,s1,s2)
+                .orderByDesc(TParkingRecord::getCreateTime)
                 .page(Page.of(query.getPageCurr(), query.getPageSize()));
 
         for (TParkingRecord record : page.getRecords()) {
@@ -141,6 +172,7 @@
     public R out(Long id) {
         TParkingRecord byId = parkingRecordService.getById(id);
         byId.setStatus(2);
+        byId.setOutParkingTime(LocalDateTime.now());
         parkingRecordService.updateById(byId);
         return R.ok();
 
@@ -296,7 +328,7 @@
     @PostMapping(value = "/parking/work")
     @ApiOperation(value = "停车订单统计", tags = {"管理后台-工作台"})
     public R<TParkLotRecordCountVo> work(@RequestBody ParkingRecordQueryDto parkingRecordQueryDto){
-        List<TParkingRecord> list = parkingRecordService.lambdaQuery().eq(parkingRecordQueryDto.getParkingLotId() != null, TParkingRecord::getParkingLotId, parkingRecordQueryDto.getParkingLotId())
+        List<TParkingRecord> list = parkingRecordService.lambdaQuery().isNotNull(TParkingRecord::getOutParkingType).eq(parkingRecordQueryDto.getParkingLotId() != null, TParkingRecord::getParkingLotId, parkingRecordQueryDto.getParkingLotId())
                 .ge(parkingRecordQueryDto.getStartTime()!=null,TParkingRecord::getCreateTime, parkingRecordQueryDto.getStartTime())
                 .le(parkingRecordQueryDto.getEndTime()!=null,TParkingRecord::getCreateTime, parkingRecordQueryDto.getEndTime().plusDays(1)).list();
         int count1 = list.size();
@@ -325,7 +357,7 @@
     @PostMapping(value = "/parking/work1")
     @ApiOperation(value = "停车订单统计", tags = {"管理后台-工作台"})
     public R<TParkLotRecordCountVo> work1(@RequestBody ParkingRecordQueryDto parkingRecordQueryDto){
-        List<TParkingRecord> list = parkingRecordService.lambdaQuery().eq(parkingRecordQueryDto.getParkingLotId() != null, TParkingRecord::getParkingLotId, parkingRecordQueryDto.getParkingLotId()).list();
+        List<TParkingRecord> list = parkingRecordService.lambdaQuery().isNotNull(TParkingRecord::getOutParkingType).eq(parkingRecordQueryDto.getParkingLotId() != null, TParkingRecord::getParkingLotId, parkingRecordQueryDto.getParkingLotId()).list();
         int count1 = list.size();
         //统计出list中chargingOrderId为null的数据个数
         int count2 = list.stream().filter(item -> item.getChargingOrderId() != null).collect(Collectors.toList()).size();

--
Gitblit v1.7.1