From 80cacfd0dcee0174f2a8d9ae322a2fcf857cef63 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期三, 04 十二月 2024 15:31:35 +0800
Subject: [PATCH] fix : 新增修改出场接口

---
 src/main/java/com/boying/controller/OrderRecordController.java |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 103 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/boying/controller/OrderRecordController.java b/src/main/java/com/boying/controller/OrderRecordController.java
index f9b88e2..9108b08 100644
--- a/src/main/java/com/boying/controller/OrderRecordController.java
+++ b/src/main/java/com/boying/controller/OrderRecordController.java
@@ -8,27 +8,26 @@
 import com.boying.entity.OrderRecord;
 import com.boying.entity.OutPark;
 import com.boying.entity.Park;
-import com.boying.entity.User;
 import com.boying.entity.vo.OrderRecordVo;
+import com.boying.entity.vo.OutParkVo;
 import com.boying.service.OrderRecordService;
 import com.boying.service.OutParkService;
 import com.boying.service.ParkService;
 import com.boying.service.UserService;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.models.auth.In;
 
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.Month;
+import java.time.YearMonth;
 import java.util.*;
-import java.util.logging.Handler;
 import java.util.stream.Collectors;
 
 @RestController
@@ -136,5 +135,104 @@
         return R.ok(resultList);
     }
 
+    @PostMapping("/findCountPageByDay")
+    public Object findCountPageByDay(Integer parkId,String day) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        if(StringUtils.isBlank(day)){
+            return R.failed("璇烽�夋嫨鏃堕棿鏌ヨ");
+        }else {
+            List<Park> parkList= new ArrayList<>();
+            if(parkId==null){
+                parkList  = parkService.list();
+            }else {
+                Park byId = parkService.getById(parkId);
+                parkList.add(byId);
+            }
+            String[] split = day.split("-");
+            Integer year = Integer.parseInt(split[0]);
+            Integer month = Integer.parseInt(split[1]);
+            // 浣跨敤YearMonth.of()鍒涘缓YearMonth瀹炰緥
+            YearMonth yearMonth = YearMonth.of(year, month);
+            // 浣跨敤YearMonth瀹炰緥鐨刲engthOfMonth()鏂规硶鑾峰彇璇ユ湀鐨勬渶澶уぉ鏁�
+            int maxDay = yearMonth.lengthOfMonth();
+            String start = day+"-01";
+            String end = day+"-"+maxDay;
+            List<OutParkVo> list = outParkService.getVoList(parkId,start,end);
+            List<Map<String,Object>> resultMapList = new ArrayList<>();
+
+            List<String>str=new ArrayList<String>();
+            for (int i = 1; i <= maxDay; i++) {
+                if(i<10){
+                    String d=day+"-0"+i;
+                    str.add(d);
+                }else {
+                    String d=day+"-"+i;
+                    str.add(d);
+                }
+            }
+            for (String s : str) {
+                List<OutParkVo> resultList = new ArrayList<>();
+                List<OutParkVo> collect = list.stream().filter(item -> item.getTi().equals(s)).collect(Collectors.toList());
+                for (Park park : parkList) {
+                    List<OutParkVo> vos = collect.stream().filter(item -> item.getParkId().equals(park.getId())).collect(Collectors.toList());
+                    if(vos!=null && vos.size()>0){
+                        OutParkVo vo = vos.get(0);
+                        vo.setParkName(park.getName());
+                        if(vo.getNum()==null){
+                            vo.setNum(0);
+                        }
+                        resultList.add(vo);
+                    }else {
+                        OutParkVo outParkVo = new OutParkVo();
+                        outParkVo.setTi(s);
+                        outParkVo.setNum(0);
+                        outParkVo.setParkId(park.getId());
+                        outParkVo.setParkName(park.getName());
+                        outParkVo.setPrice(0.0d);
+                        resultList.add(outParkVo);
+                    }
+                }
+                Map<String ,Object>map = new HashMap<>();
+                map.put("day",s);
+                map.put("data",resultList);
+                resultMapList.add(map);
+            }
+            return  R.ok(resultMapList);
+        }
+    }
+
+    public static void main(String[] args) {
+        // 鑾峰彇褰撳墠鏃ユ湡
+        LocalDate currentDate = LocalDate.now();
+        // 鑾峰彇褰撳墠鏈堜唤
+        Month currentMonth = currentDate.getMonth();
+        int maxLength = currentMonth.maxLength();
+
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+        List<String>str=new ArrayList<String>();
+        //String monthStart=df.format(new Date()).substring(0,8)+"01";
+        for (int i = 1; i <= maxLength; i++) {
+            if(i<10){
+                String d=df.format(new Date()).substring(0,8)+"0"+i;
+                str.add(d);
+            }else {
+                String d=df.format(new Date()).substring(0,8)+i;
+                str.add(d);
+            }
+        }
+        for (String s : str) {
+            System.out.println(s);
+        }
+
+        // 鍋囪鎴戜滑瑕佽幏鍙�2023骞�3鏈堢殑鏈�澶ф棩鏈�
+        int year = 2023;
+        int month = 3;
+        // 浣跨敤YearMonth.of()鍒涘缓YearMonth瀹炰緥
+        YearMonth yearMonth = YearMonth.of(year, month);
+        // 浣跨敤YearMonth瀹炰緥鐨刲engthOfMonth()鏂规硶鑾峰彇璇ユ湀鐨勬渶澶уぉ鏁�
+        int maxDay = yearMonth.lengthOfMonth();
+        System.out.println(maxDay);
+    }
+
 
 }

--
Gitblit v1.9.1