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 | 189 ++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 177 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/boying/controller/car/PlateServlet3.java b/src/main/java/com/boying/controller/car/PlateServlet3.java index 5115a1e..f99bd8a 100644 --- a/src/main/java/com/boying/controller/car/PlateServlet3.java +++ b/src/main/java/com/boying/controller/car/PlateServlet3.java @@ -5,10 +5,12 @@ 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.*; import com.boying.util.DateUtilOther; +import com.boying.util.FileUtil; import com.boying.util.StringUtil; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -20,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; @@ -35,11 +38,12 @@ import java.util.List; import java.util.concurrent.TimeUnit; + /** * Servlet implementation class PlateServlet */ @Controller -@RequestMapping("/car") +@RequestMapping("/ffzf/car") @RequiredArgsConstructor public class PlateServlet3 extends HttpServlet { private static final long serialVersionUID = 1L; @@ -52,6 +56,7 @@ private final TicketService ticketService; private final CostRuleService costRuleService; private final WhiteListService whiteListService; + private final FileInfoService fileInfoService; private final String LEDURL = "http://192.168.31.212:9988/LedShow/IGetResultDataAllLine"; /** @@ -145,9 +150,13 @@ int i = Integer.parseInt(redisnum); i--; if(i<0){ + String s= "2."+barrier.getCarNo()+"闂告満鎵嬪姩鍚姩锛屽満鍐呭仠杞︽暟涓�"+i+"\n"; + writeTxt2(s); redisTemplate.opsForValue().set("car_park_" + park.getId(),"0",30, TimeUnit.DAYS); redisTemplate.opsForValue().set("park_up_" + park.getId(),"true",30, TimeUnit.DAYS); }else { + String s= "2."+barrier.getCarNo()+"闂告満鎵嬪姩鍚姩锛屽満鍐呭仠杞︽暟涓�"+i+"\n"; + writeTxt2(s); redisTemplate.opsForValue().set("car_park_" + park.getId(),Integer.toString(i),30, TimeUnit.DAYS); redisTemplate.opsForValue().set("park_up_" + park.getId(),"true",30, TimeUnit.DAYS); } @@ -170,9 +179,13 @@ int i = Integer.parseInt(redisnum); i--; if(i<0){ + String s= "2."+outPark.getCarNo()+"缂磋垂瀹屾垚锛屽満鍐呭仠杞︽暟涓�"+i+"\n"; + writeTxt2(s); redisTemplate.opsForValue().set("car_park_" + park.getId(),"0",30, TimeUnit.DAYS); redisTemplate.opsForValue().set("park_up_" + park.getId(),"true",30, TimeUnit.DAYS); }else { + String s= "2."+outPark.getCarNo()+"缂磋垂瀹屾垚锛屽満鍐呭仠杞︽暟涓�"+i+"\n"; + writeTxt2(s); redisTemplate.opsForValue().set("car_park_" + park.getId(),Integer.toString(i),30, TimeUnit.DAYS); redisTemplate.opsForValue().set("park_up_" + park.getId(),"true",30, TimeUnit.DAYS); } @@ -208,16 +221,18 @@ BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream(),"UTF-8")); String str = ""; String lineStr = ""; + FileInfo fileInfo = null; 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"); JSONObject result = alarmInfoPlate.getJSONObject("result"); JSONObject plateResult = result.getJSONObject("PlateResult"); String carNo = plateResult.get("license").toString(); + String image = plateResult.get("imageFile").toString(); String code = alarmInfoPlate.get("serialno").toString(); try { @@ -253,7 +268,14 @@ break; } - System.out.println("缂栧彿锛�"+serialno+"璁惧璇嗗埆鍒颁簡锛�"+license); + + if(StringUtils.isNotBlank(image)){ + fileInfo = FileUtil.generateBase64StringToFile(image, 1,1); + fileInfoService.save(fileInfo); + } + + + System.out.println("缂栧彿锛�"+serialno+" 璁惧璇嗗埆鍒颁簡锛�"+license); String format = sdf.format(new Date()); s+= format+",杞︾墝鍙蜂负锛�"+license+",serialno涓猴細"+code+" "; @@ -264,7 +286,7 @@ easyNoOpen(request,response); }else{ if(barrier.getType()==0){ - outPark(license, barrier.getId(), barrier.getParkId(),request,response); + outPark(license, barrier.getId(), barrier.getParkId(),request,response,fileInfo); s+=license+"-淇濆瓨鍑哄満璁板綍\n"; }else{ String num = redisTemplate.opsForValue().get("car_park_" + barrier.getParkId()); @@ -280,7 +302,7 @@ }else { //led鏄剧ず inLedShow(code, license,barrier.getParkId(),request,response); - enterPark(license,barrier.getId(),barrier.getParkId()); + enterPark(license,barrier.getId(),barrier.getParkId(),fileInfo); s+=license+"-淇濆瓨鍏ュ満璁板綍\n"; } } @@ -293,6 +315,111 @@ s+=" ,鏌ヨ鍦哄唴璁板綍寮傚父"; writeTxt(s); easyNoOpen(request,response); + } + } + + /** + * 鎵嬫満鍙峰叆鍦� + * @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("鏈煡璇㈠埌鍏ュ満璁板綍"); } } @@ -314,10 +441,27 @@ } } + private void writeTxt2( String txt) + { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + try + { + FileWriter f = new FileWriter(systemConfigProperties.getLogPath()+sdf.format(new Date())+"LED.txt",true); + BufferedWriter bw=new BufferedWriter(f); + bw.write(txt); + bw.newLine(); + bw.close(); + } + catch(Exception e) + { + System.out.println("鎵撳嵃閿欒"); + } + } - public void enterPark(String carNo,Integer barrierId,Integer parkId) { + + public void enterPark(String carNo,Integer barrierId,Integer parkId,FileInfo fileInfo) { Park park = parkService.getById(parkId); // int num = 0; // String s = redisTemplate.opsForValue().get("car_park_" + parkId); @@ -348,6 +492,9 @@ if(tickets.size()>0){ enterPark.setStatus(1);//鍙戠幇鏈夎繚绔� } + if(fileInfo != null){ + enterPark.setImgId(fileInfo.getId()); + } enterParkService.saveOrUpdate(enterPark); // Barrier barrier = barrierService.getById(barrierId); @@ -355,7 +502,7 @@ // barrierService.saveOrUpdate(barrier); } - public double outPark(String carNo,Integer barrierId,Integer parkId,HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + public double outPark(String carNo,Integer barrierId,Integer parkId,HttpServletRequest request, HttpServletResponse response,FileInfo fileInfo) throws ServletException, IOException { double money = 0.0; EnterPark enterPark = null; String toDayHrMinSec = null; @@ -386,6 +533,9 @@ //outPark.setPrice(Double.valueOf(String.format("%.1f", money))); outPark.setPrice(money); outPark.setStatus3(findTicket(carNo)); + if(fileInfo != null){ + outPark.setImgId(fileInfo.getId()); + } outParkService.saveOrUpdate(outPark); Barrier barrier =barrierService.getById(barrierId); barrier.setCarNo(carNo); @@ -408,7 +558,7 @@ outParkService.saveOrUpdate(byCarNoAndBarrierId); return 0.0; }else{ - if(w.getParkIds()!=null){ + if(StringUtils.isNotBlank(w.getParkIds())){ if(w.getEndTime()!=null){ String parkIds = w.getParkIds(); String[] split = parkIds.split(","); @@ -430,10 +580,14 @@ } if(outPark.getPrice()==0&&outPark.getStatus3()==0){ System.out.println(outPark.getCarNo()+"璇ヨ溅涓嶉渶瑕佺即璐�"); + String s= "1."+barrier.getCarNo()+"璇ヨ溅涓嶉渶瑕佺即璐筡n"; + writeTxt2(s); outLedShow(barrier.getCode(),barrier.getCarNo(),outPark.getPrice(),toDayHrMinSec,barrier.getParkId(),request,response,0); }else { //闇�瑕佺即璐规垨鑰呮湁杩濈珷 System.out.println(outPark.getCarNo()+"璇ヨ溅闇�瑕佺即璐�"+outPark.getPrice()); + String s= "1."+barrier.getCarNo()+"璇ヨ溅闇�瑕佺即璐筡n"; + writeTxt2(s); outLedShow(barrier.getCode(),barrier.getCarNo(),outPark.getPrice(),toDayHrMinSec,barrier.getParkId(),request,response,1); } barrierService.saveOrUpdate(barrier); @@ -478,10 +632,12 @@ carType = "鏈堢杞�"; }else { //鐧藉悕鍗曞浐瀹氬仠杞﹀満杞﹁締 - if(byCarNo.getParkId().equals(barrier.getParkId())){ + if(StringUtils.isNotBlank(byCarNo.getParkIds()) && byCarNo.getParkIds().contains(barrier.getParkId()+"")){ carType = "鏈堢杞�"; long l = (byCarNo.getEndTime().getTime() - byCarNo.getStartTime().getTime()) / (24 * 3600 * 1000); carDay = "鏈夋晥鏈熻繕鏈�"+l+"澶�"; + }else { + carType = "涓存椂杞�"; } } } @@ -525,10 +681,10 @@ carType = "鏈堢杞�"; }else { //鐧藉悕鍗曞浐瀹氬仠杞﹀満杞﹁締 - if(byCarNo.getParkId().equals(barrier.getParkId())){ + if(StringUtils.isNotBlank(byCarNo.getParkIds()) && byCarNo.getParkIds().contains(barrier.getParkId()+"")){ carType = "鏈堢杞�"; - long l = (byCarNo.getEndTime().getTime() - byCarNo.getStartTime().getTime()) / (24 * 3600 * 1000); - carDay = "鏈夋晥鏈熻繕鏈�"+l+"澶�"; + }else { + carType = "涓存椂杞�"; } } } @@ -585,9 +741,13 @@ int i = Integer.parseInt(redisnum); i--; if(i<0){ + String s= "2."+carNo+"锛屽満鍐呭仠杞︽暟涓�0\n"; + writeTxt2(s); redisTemplate.opsForValue().set("car_park_" + parkId,"0",30, TimeUnit.DAYS); redisTemplate.opsForValue().set("park_up_" + parkId,"true",30, TimeUnit.DAYS); }else { + String s= "2."+carNo+"锛屽満鍐呭仠杞︽暟涓�"+i+"\n"; + writeTxt2(s); redisTemplate.opsForValue().set("car_park_" + parkId,Integer.toString(i),30, TimeUnit.DAYS); redisTemplate.opsForValue().set("park_up_" + parkId,"true",30, TimeUnit.DAYS); } @@ -625,9 +785,13 @@ int i = Integer.parseInt(redisnum); i--; if(i<0){ + String s= "2."+carNo+"锛屽満鍐呭仠杞︽暟涓�0\n"; + writeTxt2(s); redisTemplate.opsForValue().set("car_park_" + parkId,"0",30, TimeUnit.DAYS); redisTemplate.opsForValue().set("park_up_" + parkId,"true",30, TimeUnit.DAYS); }else { + String s= "2."+carNo+"锛屽満鍐呭仠杞︽暟涓�"+i+"\n"; + writeTxt2(s); redisTemplate.opsForValue().set("car_park_" + parkId,Integer.toString(i),30, TimeUnit.DAYS); redisTemplate.opsForValue().set("park_up_" + parkId,"true",30, TimeUnit.DAYS); } @@ -698,4 +862,5 @@ noOpen(request,response,data1); } + } -- Gitblit v1.9.1