From ccaad1437444311e719668896d129867c900d34e Mon Sep 17 00:00:00 2001
From: kongdeqiang <kongdeqiang960204@163.com>
Date: 星期二, 06 六月 2023 00:08:09 +0800
Subject: [PATCH] 提交更新
---
src/main/java/com/boying/controller/car/PlateServlet3.java | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
src/main/java/com/boying/util/FileUtil.java | 2
2 files changed, 113 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/boying/controller/car/PlateServlet3.java b/src/main/java/com/boying/controller/car/PlateServlet3.java
index a087cd5..56584f7 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;
@@ -230,7 +232,7 @@
JSONObject result = alarmInfoPlate.getJSONObject("result");
JSONObject plateResult = result.getJSONObject("PlateResult");
String carNo = plateResult.get("license").toString();
- // String image = plateResult.get("imageFile").toString();
+ String image = plateResult.get("imageFile").toString();
String code = alarmInfoPlate.get("serialno").toString();
try {
@@ -267,10 +269,10 @@
}
-// if(StringUtils.isNotBlank(image)){
-// fileInfo = FileUtil.generateBase64StringToFile(image, 1,1);
-// fileInfoService.save(fileInfo);
-// }
+ if(StringUtils.isNotBlank(image)){
+ fileInfo = FileUtil.generateBase64StringToFile(image, 1,1);
+ fileInfoService.save(fileInfo);
+ }
System.out.println("缂栧彿锛�"+serialno+" 璁惧璇嗗埆鍒颁簡锛�"+license);
@@ -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)
{
diff --git a/src/main/java/com/boying/util/FileUtil.java b/src/main/java/com/boying/util/FileUtil.java
index ac2d787..4708cbd 100644
--- a/src/main/java/com/boying/util/FileUtil.java
+++ b/src/main/java/com/boying/util/FileUtil.java
@@ -80,7 +80,7 @@
}else {
lastname=".pdf";
}
- String filePath = "D:\\project\\file\\";
+ String filePath = "D:\\FFproject\\file\\";
if(fileString == null){
return null;
}else {
--
Gitblit v1.9.1