From 3fba1d84220268d871c3c28e0e25f6eab3526f46 Mon Sep 17 00:00:00 2001
From: kongdeqiang <kongdeqiang960204@163.com>
Date: 星期四, 08 六月 2023 10:13:37 +0800
Subject: [PATCH] 提交更新

---
 src/main/java/com/boying/controller/car/PlateServlet3.java |  111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 109 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/boying/controller/car/PlateServlet3.java b/src/main/java/com/boying/controller/car/PlateServlet3.java
index e00d4ee..f99bd8a 100644
--- a/src/main/java/com/boying/controller/car/PlateServlet3.java
+++ b/src/main/java/com/boying/controller/car/PlateServlet3.java
@@ -5,6 +5,7 @@
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.boying.common.R;
 import com.boying.common.SystemConfigProperties;
 import com.boying.entity.*;
 import com.boying.service.*;
@@ -21,6 +22,7 @@
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -41,7 +43,7 @@
  * Servlet implementation class PlateServlet
  */
 @Controller
-@RequestMapping("/car")
+@RequestMapping("/ffzf/car")
 @RequiredArgsConstructor
 public class PlateServlet3 extends HttpServlet {
     private static final long serialVersionUID = 1L;
@@ -223,7 +225,7 @@
         while((str = reader.readLine()) != null){
             lineStr += str;
         }
-        System.out.println("鑾峰彇鍒扮殑閬撻椄鎺ㄩ�佹暟鎹负锛�"+lineStr);
+       // System.out.println("鑾峰彇鍒扮殑閬撻椄鎺ㄩ�佹暟鎹负锛�"+lineStr);
 
         JSONObject jsonObject1 = JSON.parseObject(lineStr);
         JSONObject alarmInfoPlate = jsonObject1.getJSONObject("AlarmInfoPlate");
@@ -316,6 +318,111 @@
         }
     }
 
+    /**
+     * 鎵嬫満鍙峰叆鍦�
+     * @param
+     * @return
+     */
+    @PostMapping("/inParkByPhone" )
+    @ResponseBody
+    public Object inParkByPhone( EnterPark enterPark){
+        Barrier barrier = barrierService.getById(enterPark.getBarrierId());
+        if(barrier!=null){
+            String num = redisTemplate.opsForValue().get("car_park_" +  barrier.getParkId());
+            if(StringUtils.isBlank(num)){
+                num = "0";
+                redisTemplate.opsForValue().set("car_park_" + barrier.getParkId(),num,30, TimeUnit.DAYS);
+                redisTemplate.opsForValue().set("park_up_" + barrier.getParkId(),"true",30, TimeUnit.DAYS);
+            }
+            Park byId = parkService.getById(barrier.getParkId());
+            if(Integer.parseInt(num) >= byId.getNum() ){
+                return R.failed(null,"绂佹閫氳,杞︿綅宸叉弧");
+            }else {
+                enterPark.setCreateTime(LocalDateTime.now());
+                QueryWrapper<Ticket> wrapper = new QueryWrapper<>();
+                wrapper.lambda()
+                        .eq(Ticket::getCarNo,enterPark.getCarNo())
+                        .eq(Ticket::getPayStatus,1);
+                List<Ticket> tickets = ticketService.list(wrapper);
+                if(tickets.size()>0){
+                    enterPark.setStatus(1);//鍙戠幇鏈夎繚绔�
+                }
+                enterParkService.deleteByCarNo(enterPark.getCarNo(),enterPark.getParkId());
+                enterParkService.save(enterPark);
+                return R.ok();
+            }
+        }
+        return R.failed(null,"鏁版嵁寮傚父");
+    }
+
+    /**
+     * 鎵嬫満鍙峰嚭鍦�
+     * @param
+     * @return
+     */
+    @PostMapping("/outParkByPhone" )
+    @ResponseBody
+    public Object outParkByPhone(String code2,String carNo){
+        Barrier byCode2 = barrierService.findByCode2(code2);
+        QueryWrapper<EnterPark> wrapper =new QueryWrapper<>();
+        wrapper.lambda()
+                .eq(EnterPark::getParkId,byCode2.getParkId())
+                .eq(EnterPark::getCarNo,carNo);
+        EnterPark one = enterParkService.getOne(wrapper);
+        if(one != null){
+            double money = 0.0;
+            String toDayHrMinSec = null;
+            OutPark outPark = new OutPark();
+            outPark.setCarNo(carNo);
+            outPark.setParkId(one.getParkId());
+            outPark.setBarrierId(byCode2.getId());
+            outPark.setCreateTime(LocalDateTime.now());
+            outPark.setCode(System.currentTimeMillis()+"");
+            System.out.println("鍏ュ満璁板綍锛�"+one);
+            outPark.setEnterTime(one.getCreateTime());
+            outPark.setParkName(byCode2.getName());
+            if(outPark.getTime() > 0){
+                outPark.setTimeStr(DateUtilOther.millisToDayHrMinSec(new Double(outPark.getTime()).longValue()));
+            }else {
+                outPark.setTimeStr("涓嶈冻涓�鍒嗛挓");
+            }
+            try {
+                long l = outPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli() - one.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                outPark.setTime(l/(1000*60));
+                toDayHrMinSec = DateUtilOther.millisToDayHrMinSec(l/(1000*60));
+                money = costRuleService.getMoney(one.getParkId(), outPark.getEnterTime(), outPark.getCreateTime(), 1);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+            outPark.setPrice(money);
+            outPark.setStatus3(findTicket(carNo));
+            outParkService.saveOrUpdate(outPark);
+            byCode2.setCarNo(carNo);
+            //led灞曠ず
+            if(toDayHrMinSec == null){
+                return R.failed("寮傚父璁板綍");
+            }
+            if(outPark.getPrice()==0&&outPark.getStatus3()==0){
+                System.out.println(outPark.getCarNo()+"璇ヨ溅涓嶉渶瑕佺即璐�");
+                String s= "1."+byCode2.getCarNo()+"璇ヨ溅涓嶉渶瑕佺即璐筡n";
+                writeTxt2(s);
+                byCode2.setType2(1);
+                barrierService.updateById(byCode2);
+                return R.ok(outPark);
+            }else {
+                //闇�瑕佺即璐规垨鑰呮湁杩濈珷
+                System.out.println(outPark.getCarNo()+"璇ヨ溅闇�瑕佺即璐�"+outPark.getPrice());
+                String s= "1."+byCode2.getCarNo()+"璇ヨ溅闇�瑕佺即璐筡n";
+                writeTxt2(s);
+                barrierService.updateById(byCode2);
+                return R.ok(outPark);
+            }
+
+        }else {
+            return R.failed("鏈煡璇㈠埌鍏ュ満璁板綍");
+        }
+    }
+
 
     private void writeTxt( String txt)
     {

--
Gitblit v1.9.1