| | |
| | | package com.boying.controller.car; |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.boying.common.SystemConfigProperties; |
| | | import com.boying.entity.*; |
| | | import com.boying.service.*; |
| | | import com.boying.util.DateUtilOther; |
| | | import com.boying.util.StringUtil; |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.JsonParser; |
| | | import ledshow.CodeUtil; |
| | | import ledshow.LedBean; |
| | | import ledshow.ResultData; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServlet; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.util.Base64; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * Servlet implementation class PlateServlet |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/car") |
| | | @RequiredArgsConstructor |
| | | public class PlateServlet3 extends HttpServlet { |
| | | private static final long serialVersionUID = 1L; |
| | | private final SystemConfigProperties systemConfigProperties; |
| | | private final StringRedisTemplate redisTemplate; |
| | | private final ParkService parkService; |
| | | private final OutParkService outParkService; |
| | | private final EnterParkService enterParkService; |
| | | private final BarrierService barrierService; |
| | | private final TicketService ticketService; |
| | | private final CostRuleService costRuleService; |
| | | private final WhiteListService whiteListService; |
| | | private final String LEDURL = "http://192.168.31.212:9988/LedShow/IGetResultDataAllLine"; |
| | | |
| | | /** |
| | | * 回复开闸 |
| | | */ |
| | | protected void open(HttpServletRequest request, HttpServletResponse response,String data) throws ServletException, IOException { |
| | | response.setContentType("text/json"); |
| | | PrintWriter out = response.getWriter(); |
| | | String aa = "{" + |
| | | "\"Response_AlarmInfoPlate\": {" + |
| | | "\"info\":\"ok\"," + |
| | | "\"is_pay\":\"true\"," + |
| | | "\"serialData\" :[" + |
| | | "{" + |
| | | "\"serialChannel\":0," + |
| | | "\"data\" : \"" + data + "\"," + |
| | | "\"dataLen\" :" + data.length() + |
| | | "}" + |
| | | "]" + |
| | | "}" + |
| | | "}"; |
| | | out.println(aa); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | |
| | | //转码 |
| | | public static String deCode(String str) { |
| | | try { |
| | | byte[] b = str.getBytes("UTF-8");//���� |
| | | String sa = new String(b);//����:��ʲô�ַ����������ʲô�ַ������� |
| | | //String sa = new String(str.getBytes()); |
| | | |
| | | return sa; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | protected void noOpen(HttpServletRequest request, HttpServletResponse response,String data) throws IOException { |
| | | response.setContentType("text/json"); |
| | | PrintWriter out = response.getWriter(); |
| | | String aa = "{" + |
| | | "\"Response_AlarmInfoPlate\": {" + |
| | | "\"serialData\" :[" + |
| | | "{" + |
| | | "\"serialChannel\":0," + |
| | | "\"data\" : \"" + data + "\"," + |
| | | "\"dataLen\" :" + data.length() + |
| | | "}" + |
| | | "]" + |
| | | "}" + |
| | | "}"; |
| | | out.println(aa); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | protected void easyOpen(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | response.setContentType("text/json"); |
| | | PrintWriter out = response.getWriter(); |
| | | out.println("{\"Response_AlarmInfoPlate\":{\"info\":\"ok\",\"content\":\"...\",\"is_pay\":\"true\"}}"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | protected void easyNoOpen(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | response.setContentType("text/json"); |
| | | PrintWriter out = response.getWriter(); |
| | | out.println("{\"Response_AlarmInfoPlate\":{\"info\":\"error\",\"content\":\"...\",\"is_pay\":\"false\"}}"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | |
| | | @PostMapping("/status") |
| | | public void heart(String serialno,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { |
| | | Barrier barrier = barrierService.findByCode(serialno); |
| | | Park park = parkService.getById(barrier.getParkId()); |
| | | String redis = redisTemplate.opsForValue().get("park_up_" + park.getId()); |
| | | String redisnum = redisTemplate.opsForValue().get("car_park_" + park.getId()); |
| | | if(barrier!=null){ |
| | | if(barrier.getType2()==1){ |
| | | //待开闸 |
| | | if(barrier.getType() == 1){ |
| | | int i = Integer.parseInt(redisnum); |
| | | i++; |
| | | redisTemplate.opsForValue().set("car_park_" + park.getId(),Integer.toString(i),30, TimeUnit.DAYS); |
| | | }else if(barrier.getType() == 0){ |
| | | 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); |
| | | } |
| | | |
| | | } |
| | | barrier.setType2(0); |
| | | barrier.setUpdateTime(LocalDateTime.now()); |
| | | barrier.setStatus(0); |
| | | barrier.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(barrier); |
| | | easyOpen(request,response); |
| | | }else { |
| | | //不需开闸 |
| | | barrier.setStatus(0); |
| | | barrier.setUpdateTime(LocalDateTime.now()); |
| | | barrierService.saveOrUpdate(barrier); |
| | | OutPark outPark = outParkService.count4(barrier.getId()); |
| | | if(outPark!=null){ |
| | | if(barrier.getType() == 0){ |
| | | 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); |
| | | } |
| | | } |
| | | outPark.setStatus2(1); |
| | | outParkService.saveOrUpdate(outPark); |
| | | easyOpen(request,response); |
| | | } |
| | | if(barrier.getType() == 1){ |
| | | boolean in = barrierService.getDateDifIn(barrier.getId()); |
| | | if(in){ |
| | | inLedShowDefault(park.getId(),request,response); |
| | | } |
| | | }else if(barrier.getType() == 0){ |
| | | boolean out = barrierService.getDateDifOut(barrier.getId()); |
| | | if(out){ |
| | | outLedShowDefault(request,response); |
| | | } |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | easyNoOpen(request,response); |
| | | } |
| | | } |
| | | /** |
| | | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) |
| | | */ |
| | | @PostMapping("/PlateServlet") |
| | | protected void info(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| | | String s= ""; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream(),"UTF-8")); |
| | | String str = ""; |
| | | String lineStr = ""; |
| | | while((str = reader.readLine()) != null){ |
| | | lineStr += str; |
| | | } |
| | | 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 code = alarmInfoPlate.get("serialno").toString(); |
| | | |
| | | try { |
| | | JsonParser parser=new JsonParser(); |
| | | do { |
| | | JsonObject jsonObject=(JsonObject) parser.parse(lineStr); |
| | | if( jsonObject == null || jsonObject.isJsonNull() ) { |
| | | break; |
| | | } |
| | | |
| | | JsonObject jsonInfoPlate = jsonObject.get("AlarmInfoPlate").getAsJsonObject(); |
| | | if( jsonInfoPlate == null || jsonInfoPlate.isJsonNull() ) { |
| | | break; |
| | | } |
| | | |
| | | JsonObject jsonResult = jsonInfoPlate.get("result").getAsJsonObject(); |
| | | if( jsonResult == null || jsonResult.isJsonNull() ) { |
| | | break; |
| | | } |
| | | |
| | | JsonObject jsonPlateResult = jsonResult.get("PlateResult").getAsJsonObject(); |
| | | if( jsonPlateResult == null || jsonPlateResult.isJsonNull() ) { |
| | | break; |
| | | } |
| | | |
| | | String license = jsonPlateResult.get("license").getAsString();//车牌号 |
| | | if( license == null || license == "") { |
| | | break; |
| | | } |
| | | |
| | | String serialno = jsonInfoPlate.get("serialno").getAsString();//摄像机序列号 |
| | | if( serialno == null || serialno == "" ) { |
| | | break; |
| | | } |
| | | |
| | | System.out.println("编号:"+serialno+"设备识别到了:"+license); |
| | | String format = sdf.format(new Date()); |
| | | s+= format+",车牌号为:"+license+",serialno为:"+code+" "; |
| | | |
| | | Barrier barrier = barrierService.findByCode(code); |
| | | System.out.println("查询到道闸为:"+barrier); |
| | | if(barrier==null){ |
| | | s+="查询道闸为空\n"; |
| | | easyNoOpen(request,response); |
| | | }else{ |
| | | if(barrier.getType()==0){ |
| | | outPark(license, barrier.getId(), barrier.getParkId(),request,response); |
| | | s+=license+"-保存出场记录\n"; |
| | | }else{ |
| | | 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() ){ |
| | | //led显示 |
| | | inLedFullShow(code, license,barrier.getParkId(),request,response); |
| | | }else { |
| | | //led显示 |
| | | inLedShow(code, license,barrier.getParkId(),request,response); |
| | | enterPark(license,barrier.getId(),barrier.getParkId()); |
| | | s+=license+"-保存入场记录\n"; |
| | | } |
| | | } |
| | | } |
| | | writeTxt(s); |
| | | }while(false); |
| | | } |
| | | catch (Exception e) { |
| | | System.out.println("无入场记录"); |
| | | s+=" ,查询场内记录异常"; |
| | | writeTxt(s); |
| | | easyNoOpen(request,response); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void writeTxt( String txt) |
| | | { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
| | | try |
| | | { |
| | | FileWriter f = new FileWriter(systemConfigProperties.getLogPath()+sdf.format(new Date())+".txt",true); |
| | | BufferedWriter bw=new BufferedWriter(f); |
| | | bw.write(txt); |
| | | bw.newLine(); |
| | | bw.close(); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.out.println("打印错误"); |
| | | } |
| | | } |
| | | |
| | | 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) { |
| | | Park park = parkService.getById(parkId); |
| | | // int num = 0; |
| | | // String s = redisTemplate.opsForValue().get("car_park_" + parkId); |
| | | // if(park != null){ |
| | | // num = park.getNum(); |
| | | // if(s !=null){ |
| | | // if(Integer.parseInt(s) >= num){ |
| | | // redisTemplate.opsForValue().set("park_up_" + parkId,"false",30, TimeUnit.DAYS); |
| | | // return; |
| | | //package com.boying.controller.car; |
| | | // |
| | | //import cn.hutool.http.HttpRequest; |
| | | //import com.alibaba.fastjson.JSON; |
| | | //import com.alibaba.fastjson.JSONObject; |
| | | //import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | //import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | //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.RedisJsonUtil; |
| | | //import com.boying.util.StringUtil; |
| | | //import com.google.gson.JsonObject; |
| | | //import com.google.gson.JsonParser; |
| | | //import ledshow.CodeUtil; |
| | | //import ledshow.LedBean; |
| | | //import ledshow.ResultData; |
| | | //import lombok.RequiredArgsConstructor; |
| | | //import org.springframework.beans.factory.annotation.Autowired; |
| | | //import org.springframework.data.redis.core.StringRedisTemplate; |
| | | //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; |
| | | //import javax.servlet.http.HttpServletRequest; |
| | | //import javax.servlet.http.HttpServletResponse; |
| | | //import java.io.*; |
| | | //import java.text.ParseException; |
| | | //import java.text.SimpleDateFormat; |
| | | //import java.time.Duration; |
| | | //import java.time.LocalDateTime; |
| | | //import java.time.ZoneOffset; |
| | | //import java.util.Base64; |
| | | //import java.util.Date; |
| | | //import java.util.List; |
| | | //import java.util.concurrent.TimeUnit; |
| | | // |
| | | // |
| | | ///** |
| | | // * Servlet implementation class PlateServlet |
| | | // */ |
| | | //@Controller |
| | | //@RequestMapping("/ffzf/car") |
| | | //@RequiredArgsConstructor |
| | | //public class PlateServlet3 extends HttpServlet { |
| | | // private static final long serialVersionUID = 1L; |
| | | // private final SystemConfigProperties systemConfigProperties; |
| | | // private final StringRedisTemplate redisTemplate; |
| | | // private final ParkService parkService; |
| | | // private final OutParkService outParkService; |
| | | // private final EnterParkService enterParkService; |
| | | // private final BarrierService barrierService; |
| | | // private final TicketService ticketService; |
| | | // private final CostRuleService costRuleService; |
| | | // private final WhiteListService whiteListService; |
| | | // private final FileInfoService fileInfoService; |
| | | // private final TicketBlackService ticketBlackService; |
| | | // private final OutParkLogService outParkLogService; |
| | | // // private final RedisJsonUtil redisJsonUtil; |
| | | // private final String LEDURL = "http://192.168.31.212:9988/LedShow/IGetResultDataAllLine"; |
| | | // |
| | | // /** |
| | | // * 回复开闸 |
| | | // */ |
| | | // protected void open(HttpServletRequest request, HttpServletResponse response,String data) throws ServletException, IOException { |
| | | // response.setContentType("text/json"); |
| | | // PrintWriter out = response.getWriter(); |
| | | // String aa = "{" + |
| | | // "\"Response_AlarmInfoPlate\": {" + |
| | | // "\"info\":\"ok\"," + |
| | | // "\"is_pay\":\"true\"," + |
| | | // "\"serialData\" :[" + |
| | | // "{" + |
| | | // "\"serialChannel\":0," + |
| | | // "\"data\" : \"" + data + "\"," + |
| | | // "\"dataLen\" :" + data.length() + |
| | | // "}" + |
| | | // "]" + |
| | | // "}" + |
| | | // "}"; |
| | | // out.println(aa); |
| | | // out.flush(); |
| | | // out.close(); |
| | | // } |
| | | // |
| | | // |
| | | // //转码 |
| | | // public static String deCode(String str) { |
| | | // try { |
| | | // byte[] b = str.getBytes("UTF-8");//���� |
| | | // String sa = new String(b);//����:��ʲô�ַ����������ʲô�ַ������� |
| | | // //String sa = new String(str.getBytes()); |
| | | // |
| | | // return sa; |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // return ""; |
| | | // } |
| | | // } |
| | | // |
| | | // protected void noOpen(HttpServletRequest request, HttpServletResponse response,String data) throws IOException { |
| | | // response.setContentType("text/json"); |
| | | // PrintWriter out = response.getWriter(); |
| | | // String aa = "{" + |
| | | // "\"Response_AlarmInfoPlate\": {" + |
| | | // "\"serialData\" :[" + |
| | | // "{" + |
| | | // "\"serialChannel\":0," + |
| | | // "\"data\" : \"" + data + "\"," + |
| | | // "\"dataLen\" :" + data.length() + |
| | | // "}" + |
| | | // "]" + |
| | | // "}" + |
| | | // "}"; |
| | | // out.println(aa); |
| | | // out.flush(); |
| | | // out.close(); |
| | | // } |
| | | // |
| | | // protected void easyOpen(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | // response.setContentType("text/json"); |
| | | // PrintWriter out = response.getWriter(); |
| | | // out.println("{\"Response_AlarmInfoPlate\":{\"info\":\"ok\",\"content\":\"...\",\"is_pay\":\"true\"}}"); |
| | | // out.flush(); |
| | | // out.close(); |
| | | // } |
| | | // |
| | | // protected void easyOpen2(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | // response.setContentType("text/json"); |
| | | // PrintWriter out = response.getWriter(); |
| | | // out.println("{\"Response_AlarmInfoPlate\":{\"ivs_ioctrl\":{\"delay\":1000,\"io\":0,\"value\":2}}}"); |
| | | // out.flush(); |
| | | // out.close(); |
| | | // } |
| | | // |
| | | // protected void easyNoOpen(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | // response.setContentType("text/json"); |
| | | // PrintWriter out = response.getWriter(); |
| | | // out.println("{\"Response_AlarmInfoPlate\":{\"info\":\"error\",\"content\":\"...\",\"is_pay\":\"false\"}}"); |
| | | // out.flush(); |
| | | // out.close(); |
| | | // } |
| | | // |
| | | // @PostMapping("/status") |
| | | // public void heart(String serialno,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { |
| | | // Barrier barrier = barrierService.findByCode(serialno); |
| | | // Park park = parkService.getOneById(barrier.getParkId()); |
| | | // // Park park = parkService.getById(barrier.getParkId()); |
| | | // // String redis = redisTemplate.opsForValue().get("park_up_" + park.getId()); |
| | | // String redisnum = redisTemplate.opsForValue().get("car_park_" + park.getId()); |
| | | // if(StringUtils.isBlank(redisnum)){ |
| | | // redisnum = "0"; |
| | | // } |
| | | // if(barrier!=null){ |
| | | // if(barrier.getType2()==1){ |
| | | // //待开闸 |
| | | // if(barrier.getType() == 1){ |
| | | // int i = Integer.parseInt(redisnum); |
| | | // i++; |
| | | // redisTemplate.opsForValue().set("car_park_" + park.getId(),Integer.toString(i),30, TimeUnit.DAYS); |
| | | // }else if(barrier.getType() == 0){ |
| | | // 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); |
| | | // } |
| | | // |
| | | // } |
| | | // barrier.setType2(0); |
| | | // barrier.setUpdateTime(LocalDateTime.now()); |
| | | // barrier.setStatus(0); |
| | | // barrier.setUpdateTime(LocalDateTime.now()); |
| | | // barrierService.saveOrUpdate(barrier); |
| | | // |
| | | // String jsonValue = JSON.toJSONString(barrier); |
| | | // redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue); |
| | | // easyOpen(request,response); |
| | | // }else { |
| | | // s= "0"; |
| | | // redisTemplate.opsForValue().set("car_park_" + parkId,s,30, TimeUnit.DAYS); |
| | | // redisTemplate.opsForValue().set("park_up_" + parkId,"true",30, TimeUnit.DAYS); |
| | | // //不需开闸 |
| | | // LocalDateTime now = LocalDateTime.now(); |
| | | // LocalDateTime updateTime = barrier.getUpdateTime(); |
| | | // Duration duration = Duration.between(updateTime,now); |
| | | // long minutes = duration.toMinutes(); |
| | | // if(minutes>=2){ |
| | | // barrier.setStatus(0); |
| | | // barrier.setUpdateTime(LocalDateTime.now()); |
| | | // barrierService.saveOrUpdate(barrier); |
| | | // } |
| | | // |
| | | // String jsonValue = JSON.toJSONString(barrier); |
| | | // redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue); |
| | | // if(barrier.getType() == 0){ |
| | | // OutPark outPark = outParkService.count4(barrier.getId()); |
| | | // if(outPark!=null){ |
| | | // if(barrier.getType() == 0){ |
| | | // 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); |
| | | // } |
| | | // } |
| | | // outPark.setStatus2(1); |
| | | // outParkService.saveOrUpdate(outPark); |
| | | // easyOpen(request,response); |
| | | // OutParkLog byOutPark = outParkLogService.getByOutPark(outPark.getCarNo(), outPark.getId()); |
| | | // byOutPark.setOpenTime(LocalDateTime.now()); |
| | | // outParkLogService.saveOrUpdate(byOutPark); |
| | | // enterParkService.deleteByCarNo(outPark.getCarNo(), barrier.getParkId()); |
| | | // redisTemplate.delete("outPark-"+outPark.getBarrierId()); |
| | | // } |
| | | // } |
| | | // if(barrier.getType() == 1){ |
| | | // boolean in = barrierService.getDateDifIn(park.getId()); |
| | | // if(in){ |
| | | // inLedShowDefault(park.getId(),request,response); |
| | | // } |
| | | // }else if(barrier.getType() == 0){ |
| | | // boolean out = barrierService.getDateDifOut(barrier.getId()); |
| | | // if(out){ |
| | | // outLedShowDefault(request,response); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // }else { |
| | | // easyNoOpen(request,response); |
| | | // } |
| | | // } |
| | | // /** |
| | | // * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) |
| | | // */ |
| | | // @PostMapping("/PlateServlet") |
| | | // protected void info(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| | | // String s= ""; |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); |
| | | // 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); |
| | | // |
| | | // 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 { |
| | | // JsonParser parser=new JsonParser(); |
| | | // do { |
| | | // JsonObject jsonObject=(JsonObject) parser.parse(lineStr); |
| | | // if( jsonObject == null || jsonObject.isJsonNull() ) { |
| | | // break; |
| | | // } |
| | | // |
| | | // JsonObject jsonInfoPlate = jsonObject.get("AlarmInfoPlate").getAsJsonObject(); |
| | | // if( jsonInfoPlate == null || jsonInfoPlate.isJsonNull() ) { |
| | | // break; |
| | | // } |
| | | // |
| | | // JsonObject jsonResult = jsonInfoPlate.get("result").getAsJsonObject(); |
| | | // if( jsonResult == null || jsonResult.isJsonNull() ) { |
| | | // break; |
| | | // } |
| | | // |
| | | // JsonObject jsonPlateResult = jsonResult.get("PlateResult").getAsJsonObject(); |
| | | // if( jsonPlateResult == null || jsonPlateResult.isJsonNull() ) { |
| | | // break; |
| | | // } |
| | | // |
| | | // String license = jsonPlateResult.get("license").getAsString();//车牌号 |
| | | // if( license == null || license == "") { |
| | | // break; |
| | | // } |
| | | // |
| | | // String serialno = jsonInfoPlate.get("serialno").getAsString();//摄像机序列号 |
| | | // if( serialno == null || serialno == "" ) { |
| | | // break; |
| | | // } |
| | | // |
| | | // |
| | | // 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+" "; |
| | | // |
| | | // Barrier barrier = barrierService.findByCode(code); |
| | | // System.out.println("查询到道闸为:"+barrier); |
| | | // if(barrier==null){ |
| | | // s+="查询道闸为空\n"; |
| | | // easyNoOpen(request,response); |
| | | // }else{ |
| | | // if(barrier.getType()==0){ |
| | | // outPark(license, barrier.getId(), barrier.getParkId(),request,response,fileInfo); |
| | | // s+=license+"-保存出场记录\n"; |
| | | // }else{ |
| | | // 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() ){ |
| | | // //led显示 |
| | | // inLedFullShow(code, license,barrier.getParkId(),request,response); |
| | | // }else { |
| | | // //led显示 |
| | | // enterPark(license,barrier.getId(),barrier.getParkId(),fileInfo); |
| | | // inLedShow(code, license,barrier.getParkId(),request,response); |
| | | // s+=license+"-保存入场记录\n"; |
| | | // } |
| | | // } |
| | | // } |
| | | // writeTxt(s); |
| | | // }while(false); |
| | | // } |
| | | // catch (Exception e) { |
| | | // System.out.println("无入场记录"); |
| | | // 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 { |
| | | // QueryWrapper<EnterPark> wrapper2 = new QueryWrapper<>(); |
| | | // wrapper2.lambda() |
| | | // .eq(EnterPark::getBarrierId,barrier.getId()) |
| | | // .orderByDesc(EnterPark::getCreateTime) |
| | | // .last(" limit 1"); |
| | | // EnterPark one = enterParkService.getOne(wrapper2); |
| | | // if(one == null){ |
| | | // return R.failed("未查询到车辆存在"); |
| | | // }else { |
| | | // if(one.getCarNo().equals("无牌车")){ |
| | | // 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);//发现有违章 |
| | | // } |
| | | // enterPark.setIsPay(0); |
| | | // enterPark.setPrice(0); |
| | | // enterParkService.deleteByCarNo(enterPark.getCarNo(),enterPark.getParkId()); |
| | | // enterParkService.save(enterPark); |
| | | // barrier.setType2(1); |
| | | // barrierService.updateById(barrier); |
| | | // return R.ok(); |
| | | // }else { |
| | | // return R.failed("非法操作"); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | enterParkService.deleteByCarNo(carNo,parkId); |
| | | EnterPark enterPark = new EnterPark(); |
| | | enterPark.setCarNo(carNo); |
| | | enterPark.setBarrierId(barrierId); |
| | | enterPark.setParkId(parkId); |
| | | |
| | | 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.saveOrUpdate(enterPark); |
| | | |
| | | // Barrier barrier = barrierService.getById(barrierId); |
| | | // barrier.setType2(1); |
| | | // 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); |
| | | // |
| | | // //入场记录保存一下 |
| | | // if(one.getIsPay()==1){ |
| | | // money = money - one.getPrice(); |
| | | // }else { |
| | | // one.setPrice(money); |
| | | // one.setIsPay(0); |
| | | // enterParkService.updateById(one); |
| | | // } |
| | | // } 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) |
| | | // { |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
| | | // try |
| | | // { |
| | | // FileWriter f = new FileWriter(systemConfigProperties.getLogPath()+sdf.format(new Date())+".txt",true); |
| | | // BufferedWriter bw=new BufferedWriter(f); |
| | | // bw.write(txt); |
| | | // bw.newLine(); |
| | | // bw.close(); |
| | | // } |
| | | // catch(Exception e) |
| | | // { |
| | | // System.out.println("打印错误"); |
| | | // } |
| | | // } |
| | | // |
| | | // 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,FileInfo fileInfo) { |
| | | // TicketBlack black = ticketBlackService.getByCarNo(carNo, 1); |
| | | // if(black != null){ |
| | | // System.out.println("黑名单车辆"+carNo); |
| | | // }else { |
| | | // enterParkService.deleteByCarNo(carNo,parkId); |
| | | // EnterPark enterPark = new EnterPark(); |
| | | // enterPark.setIsPay(0); |
| | | // enterPark.setPrice(0); |
| | | // enterPark.setCarNo(carNo); |
| | | // enterPark.setBarrierId(barrierId); |
| | | // enterPark.setParkId(parkId); |
| | | // |
| | | // 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);//发现有违章 |
| | | // } |
| | | // if(fileInfo != null){ |
| | | // enterPark.setImgId(fileInfo.getId()); |
| | | // } |
| | | // enterParkService.saveOrUpdate(enterPark); |
| | | // String jsonValue = JSON.toJSONString(enterPark); |
| | | // redisTemplate.opsForValue().set("enterPark_dif_"+ parkId, jsonValue); |
| | | // |
| | | // } |
| | | // } |
| | | // |
| | | // 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; |
| | | // OutPark outPark = new OutPark(); |
| | | // outPark.setCarNo(carNo); |
| | | // outPark.setParkId(parkId); |
| | | // outPark.setBarrierId(barrierId); |
| | | // outPark.setCreateTime(LocalDateTime.now()); |
| | | // outPark.setCode(System.currentTimeMillis()+""); |
| | | // List<EnterPark> byCarNo = enterParkService.findByCarNo(carNo,parkId); |
| | | // |
| | | // if(byCarNo.size() == 0){ |
| | | // System.out.println(carNo+"未发现场内车辆"); |
| | | // }else{ |
| | | // enterPark = byCarNo.get(0); |
| | | // System.out.println("入场记录:"+enterPark); |
| | | // outPark.setEnterTime(enterPark.getCreateTime()); |
| | | // try { |
| | | // long l = outPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli() - enterPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(); |
| | | // outPark.setTime(l/(1000*60)); |
| | | // toDayHrMinSec = DateUtilOther.millisToDayHrMinSec(l/(1000*60)); |
| | | // money = costRuleService.getMoney(parkId, outPark.getEnterTime(), outPark.getCreateTime(), 1); |
| | | // |
| | | // //入场记录保存一下 |
| | | // if(enterPark.getIsPay() != null && enterPark.getIsPay()==1){ |
| | | // money = money - enterPark.getPrice(); |
| | | // }else { |
| | | // enterPark.setPrice(money); |
| | | // enterPark.setIsPay(0); |
| | | // enterParkService.updateById(enterPark); |
| | | // } |
| | | // } catch (ParseException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // |
| | | // } |
| | | // //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); |
| | | // //led展示 |
| | | // if(toDayHrMinSec == null){ |
| | | // toDayHrMinSec = "入场记录异常,请联系管理员"; |
| | | // } |
| | | // //判断是否在白名单 |
| | | // QueryWrapper<WhiteList> wrapper = new QueryWrapper<>(); |
| | | // wrapper.lambda() |
| | | // .eq(WhiteList::getCarNo,carNo); |
| | | // List<WhiteList> all = whiteListService.list(wrapper); |
| | | // if(all.size() >0){ |
| | | // for(WhiteList w : all){ |
| | | // if(w.getType()==0){ |
| | | // outLedShowYueZu(barrier.getCarNo(),"月租车",parkId,request,response,0); |
| | | // OutPark byCarNoAndBarrierId = outParkService.findByCarNoAndBarrierId(carNo, barrierId); |
| | | // byCarNoAndBarrierId.setStatus(2); |
| | | // byCarNoAndBarrierId.setStatus2(1); |
| | | // outParkService.saveOrUpdate(byCarNoAndBarrierId); |
| | | // barrierService.saveOrUpdate(barrier); |
| | | // String jsonValue2 = JSON.toJSONString(barrier); |
| | | // redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue2); |
| | | // String jsonValue = JSON.toJSONString(byCarNoAndBarrierId); |
| | | // redisTemplate.opsForValue().set("outPark_dif_"+ barrierId, jsonValue); |
| | | // return 0.0; |
| | | // }else{ |
| | | // if(StringUtils.isNotBlank(w.getParkIds())){ |
| | | // if(w.getEndTime()!=null){ |
| | | // String parkIds = w.getParkIds(); |
| | | // String[] split = parkIds.split(","); |
| | | // for (String s : split) { |
| | | // int pid = Integer.parseInt(s); |
| | | // if(pid == outPark.getParkId() && System.currentTimeMillis()<w.getEndTime().getTime()){ |
| | | // outLedShowYueZu(barrier.getCarNo(),"月租车",parkId,request,response,0); |
| | | // OutPark byCarNoAndBarrierId = outParkService.findByCarNoAndBarrierId(carNo, barrierId); |
| | | // byCarNoAndBarrierId.setStatus(2); |
| | | // byCarNoAndBarrierId.setStatus2(1); |
| | | // outParkService.saveOrUpdate(byCarNoAndBarrierId); |
| | | // barrierService.saveOrUpdate(barrier); |
| | | // String jsonValue2 = JSON.toJSONString(barrier); |
| | | // redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue2); |
| | | // String jsonValue = JSON.toJSONString(byCarNoAndBarrierId); |
| | | // redisTemplate.opsForValue().set("outPark_dif_"+ barrierId, jsonValue); |
| | | // return 0.0; |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // barrierService.saveOrUpdate(barrier); |
| | | } |
| | | |
| | | public double outPark(String carNo,Integer barrierId,Integer parkId,HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| | | double money = 0.0; |
| | | EnterPark enterPark = null; |
| | | String toDayHrMinSec = null; |
| | | OutPark outPark = new OutPark(); |
| | | outPark.setCarNo(carNo); |
| | | outPark.setParkId(parkId); |
| | | outPark.setBarrierId(barrierId); |
| | | outPark.setCreateTime(LocalDateTime.now()); |
| | | outPark.setCode(System.currentTimeMillis()+""); |
| | | List<EnterPark> byCarNo = enterParkService.findByCarNo(carNo,parkId); |
| | | |
| | | if(byCarNo.size() == 0){ |
| | | System.out.println(carNo+"未发现场内车辆"); |
| | | }else{ |
| | | enterPark = byCarNo.get(0); |
| | | System.out.println("入场记录:"+enterPark); |
| | | outPark.setEnterTime(enterPark.getCreateTime()); |
| | | try { |
| | | long l = outPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli() - enterPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(); |
| | | outPark.setTime(l/(1000*60)); |
| | | toDayHrMinSec = DateUtilOther.millisToDayHrMinSec(l/(1000*60)); |
| | | money = costRuleService.getMoney(parkId, outPark.getEnterTime(), outPark.getCreateTime(), 1); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | //outPark.setPrice(Double.valueOf(String.format("%.1f", money))); |
| | | outPark.setPrice(money); |
| | | outPark.setStatus3(findTicket(carNo)); |
| | | outParkService.saveOrUpdate(outPark); |
| | | Barrier barrier =barrierService.getById(barrierId); |
| | | barrier.setCarNo(carNo); |
| | | //led展示 |
| | | if(toDayHrMinSec == null){ |
| | | toDayHrMinSec = "不足两小时"; |
| | | } |
| | | //判断是否在白名单 |
| | | QueryWrapper<WhiteList> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(WhiteList::getCarNo,carNo); |
| | | List<WhiteList> all = whiteListService.list(wrapper); |
| | | if(all.size() >0){ |
| | | for(WhiteList w : all){ |
| | | if(w.getType()==0){ |
| | | outLedShowYueZu(barrier.getCarNo(),"月租车",parkId,request,response,0); |
| | | OutPark byCarNoAndBarrierId = outParkService.findByCarNoAndBarrierId(carNo, barrierId); |
| | | byCarNoAndBarrierId.setStatus(1); |
| | | byCarNoAndBarrierId.setStatus2(1); |
| | | outParkService.saveOrUpdate(byCarNoAndBarrierId); |
| | | return 0.0; |
| | | }else{ |
| | | if(w.getParkIds()!=null){ |
| | | if(w.getEndTime()!=null){ |
| | | String parkIds = w.getParkIds(); |
| | | String[] split = parkIds.split(","); |
| | | for (String s : split) { |
| | | int pid = Integer.parseInt(s); |
| | | if(pid == outPark.getParkId() && System.currentTimeMillis()<w.getEndTime().getTime()){ |
| | | outLedShowYueZu(barrier.getCarNo(),"月租车",parkId,request,response,0); |
| | | OutPark byCarNoAndBarrierId = outParkService.findByCarNoAndBarrierId(carNo, barrierId); |
| | | byCarNoAndBarrierId.setStatus(1); |
| | | byCarNoAndBarrierId.setStatus2(1); |
| | | outParkService.saveOrUpdate(byCarNoAndBarrierId); |
| | | return 0.0; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | 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); |
| | | return money; |
| | | } |
| | | |
| | | public int findTicket(String carNo){ |
| | | QueryWrapper<Ticket> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Ticket::getCarNo,carNo) |
| | | .eq(Ticket::getPayStatus,1); |
| | | List<Ticket> tickets = ticketService.list(wrapper); |
| | | if(tickets.size()>0){ |
| | | return 1; |
| | | }else{ |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | |
| | | public void inLedShow(String ledId,String carNo,Integer parkId,HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| | | String num = redisTemplate.opsForValue().get("car_park_" + parkId); |
| | | if(num == null){ |
| | | num = "0"; |
| | | } |
| | | Park byId = parkService.getById(parkId); |
| | | int n = Integer.parseInt(num)+1; |
| | | redisTemplate.opsForValue().set("car_park_" + parkId,Integer.toString(n),30, TimeUnit.DAYS); |
| | | int i = byId.getNum() - Integer.parseInt(num); |
| | | if(i<0){ |
| | | i = 0; |
| | | } |
| | | String carType = ""; |
| | | String carDay = ""; |
| | | Barrier barrier = barrierService.findByCode(ledId); |
| | | WhiteList byCarNo = whiteListService.getByCarNo(carNo); |
| | | if(byCarNo == null){ |
| | | carType = "临时车"; |
| | | }else { |
| | | if (byCarNo.getType() == 0){ |
| | | //白名单永久车辆 |
| | | carType = "月租车"; |
| | | }else { |
| | | //白名单固定停车场车辆 |
| | | if(byCarNo.getParkId().equals(barrier.getParkId())){ |
| | | carType = "月租车"; |
| | | long l = (byCarNo.getEndTime().getTime() - byCarNo.getStartTime().getTime()) / (24 * 3600 * 1000); |
| | | carDay = "有效期还有"+l+"天"; |
| | | } |
| | | } |
| | | } |
| | | if(StringUtils.isBlank(carDay)){ |
| | | carDay = "欢迎光临"; |
| | | } |
| | | |
| | | LedBean ledBean = new LedBean(); |
| | | ledBean.setcolor1(0); |
| | | ledBean.setcolor2(0); |
| | | ledBean.setcolor3(0); |
| | | ledBean.setcolor4(0); |
| | | ledBean.setcontent1(carNo); |
| | | ledBean.setcontent2(carType); |
| | | ledBean.setcontent3(carDay); |
| | | ledBean.setcontent4("余位:"+i); |
| | | ledBean.setdisMode1(0); |
| | | ledBean.setdisMode2(0); |
| | | ledBean.setdisMode3(0); |
| | | ledBean.setdisMode4(0); |
| | | ledBean.setvoiceContent(carType+","+carNo+","+carDay); |
| | | ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | byte[] dataX = new byte[resultData.getlenth()]; |
| | | System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | data1 = data1.replaceAll("\r\n", ""); |
| | | |
| | | open(request,response,data1);//入场开闸 |
| | | } |
| | | |
| | | public void inLedFullShow(String ledId, String carNo, Integer parkId,HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | String carType = ""; |
| | | String carDay = ""; |
| | | Barrier barrier = barrierService.findByCode(ledId); |
| | | WhiteList byCarNo = whiteListService.getByCarNo(carNo); |
| | | if(byCarNo == null){ |
| | | carType = "临时车"; |
| | | }else { |
| | | if (byCarNo.getType() == 0){ |
| | | //白名单永久车辆 |
| | | carType = "月租车"; |
| | | }else { |
| | | //白名单固定停车场车辆 |
| | | if(byCarNo.getParkId().equals(barrier.getParkId())){ |
| | | carType = "月租车"; |
| | | long l = (byCarNo.getEndTime().getTime() - byCarNo.getStartTime().getTime()) / (24 * 3600 * 1000); |
| | | carDay = "有效期还有"+l+"天"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | LedBean ledBean = new LedBean(); |
| | | ledBean.setcolor1(0); |
| | | ledBean.setcolor2(0); |
| | | ledBean.setcolor3(0); |
| | | ledBean.setcolor4(0); |
| | | ledBean.setcontent1(carNo); |
| | | ledBean.setcontent2(carType); |
| | | ledBean.setcontent3("车位已满"); |
| | | ledBean.setcontent4("请驶离"); |
| | | ledBean.setdisMode1(0); |
| | | ledBean.setdisMode2(0); |
| | | ledBean.setdisMode3(0); |
| | | ledBean.setdisMode4(0); |
| | | ledBean.setvoiceContent("车位已满,请驶离"); |
| | | ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | byte[] dataX = new byte[resultData.getlenth()]; |
| | | System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | data1 = data1.replaceAll("\r\n", ""); |
| | | |
| | | noOpen(request,response,data1);//入场开闸 |
| | | } |
| | | |
| | | public void outLedShow(String ledId,String carNo,Double price,String timeStamp,Integer parkId,HttpServletRequest request, HttpServletResponse response,int type) throws ServletException, IOException { |
| | | String redisnum = redisTemplate.opsForValue().get("car_park_" + parkId); |
| | | Park park = parkService.getById(parkId); |
| | | LedBean ledBean = new LedBean(); |
| | | ledBean.setcolor1(0); |
| | | ledBean.setcolor2(0); |
| | | ledBean.setcolor3(0); |
| | | ledBean.setcolor4(0); |
| | | ledBean.setcontent1(carNo); |
| | | ledBean.setcontent2("停车"+timeStamp); |
| | | ledBean.setcontent3("交费"+price+"元"); |
| | | ledBean.setcontent4("禁止闯杆"); |
| | | ledBean.setdisMode1(0); |
| | | ledBean.setdisMode2(1); |
| | | ledBean.setdisMode3(1); |
| | | ledBean.setdisMode4(0); |
| | | ledBean.setvoiceContent(carNo+"停车"+timeStamp+"交费"+price+"元"); |
| | | ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | byte[] dataX = new byte[resultData.getlenth()]; |
| | | System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | data1 = data1.replaceAll("\r\n", ""); |
| | | if(type == 0){ |
| | | //开闸 |
| | | open(request,response,data1); |
| | | redisTemplate.opsForValue().set("park_change_in_"+parkId,"true",1, TimeUnit.DAYS); |
| | | 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); |
| | | } |
| | | }else { |
| | | noOpen(request,response,data1); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void outLedShowYueZu(String carNo,String text,Integer parkId,HttpServletRequest request, HttpServletResponse response,int type) throws ServletException, IOException{ |
| | | String redisnum = redisTemplate.opsForValue().get("car_park_" + parkId); |
| | | LedBean ledBean = new LedBean(); |
| | | ledBean.setcolor1(0); |
| | | ledBean.setcolor2(0); |
| | | ledBean.setcolor3(0); |
| | | ledBean.setcolor4(0); |
| | | ledBean.setcontent1(carNo); |
| | | ledBean.setcontent2(text); |
| | | ledBean.setcontent3("减速慢行"); |
| | | ledBean.setcontent4("欢迎下次光临"); |
| | | ledBean.setdisMode1(0); |
| | | ledBean.setdisMode2(0); |
| | | ledBean.setdisMode3(0); |
| | | ledBean.setdisMode4(1); |
| | | ledBean.setvoiceContent(text+carNo+"欢迎下次光临"); |
| | | ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | byte[] dataX = new byte[resultData.getlenth()]; |
| | | System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | data1 = data1.replaceAll("\r\n", ""); |
| | | if(type == 0){ |
| | | //开闸 |
| | | open(request,response,data1); |
| | | redisTemplate.opsForValue().set("park_change_in_"+parkId,"true",1, TimeUnit.DAYS); |
| | | 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); |
| | | } |
| | | }else { |
| | | noOpen(request,response,data1); |
| | | } |
| | | } |
| | | |
| | | public void outLedShowDefault(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ |
| | | LedBean ledBean = new LedBean(); |
| | | ledBean.setcolor1(0); |
| | | ledBean.setcolor2(0); |
| | | ledBean.setcolor3(0); |
| | | ledBean.setcolor4(0); |
| | | ledBean.setcontent1("一车一杆"); |
| | | ledBean.setcontent2("减速慢行"); |
| | | ledBean.setcontent3("无需取卡"); |
| | | ledBean.setcontent4("扫码缴费"); |
| | | ledBean.setdisMode1(0); |
| | | ledBean.setdisMode2(0); |
| | | ledBean.setdisMode3(0); |
| | | ledBean.setdisMode4(0); |
| | | ledBean.setvoiceContent(""); |
| | | ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | byte[] dataX = new byte[resultData.getlenth()]; |
| | | System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | data1 = data1.replaceAll("\r\n", ""); |
| | | noOpen(request,response,data1); |
| | | } |
| | | |
| | | public void inLedShowDefault(Integer parkId,HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ |
| | | String num = redisTemplate.opsForValue().get("car_park_" + parkId); |
| | | String con3 = ""; |
| | | String con4 = ""; |
| | | if(num == null){ |
| | | num = "0"; |
| | | } |
| | | Park byId = parkService.getById(parkId); |
| | | int i = byId.getNum() - Integer.parseInt(num); |
| | | if(i<=0){ |
| | | i = 0; |
| | | con3 = "车位已满"; |
| | | con4 = "请驶离"; |
| | | }else { |
| | | con3 = "排队等候"; |
| | | con4 = "余位:"+i; |
| | | } |
| | | LedBean ledBean = new LedBean(); |
| | | ledBean.setcolor1(0); |
| | | ledBean.setcolor2(0); |
| | | ledBean.setcolor3(0); |
| | | ledBean.setcolor4(0); |
| | | ledBean.setcontent1("一车一杆"); |
| | | ledBean.setcontent2("减速慢行"); |
| | | ledBean.setcontent3(con3); |
| | | ledBean.setcontent4(con4); |
| | | ledBean.setdisMode1(0); |
| | | ledBean.setdisMode2(0); |
| | | ledBean.setdisMode3(0); |
| | | ledBean.setdisMode4(0); |
| | | ledBean.setvoiceContent(""); |
| | | ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | byte[] dataX = new byte[resultData.getlenth()]; |
| | | System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | data1 = data1.replaceAll("\r\n", ""); |
| | | noOpen(request,response,data1); |
| | | } |
| | | |
| | | |
| | | } |
| | | // String jsonValue2 = JSON.toJSONString(barrier); |
| | | // redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue2); |
| | | // if(outPark.getPrice()==0&&outPark.getStatus3()==0){ |
| | | // System.out.println(outPark.getCarNo()+"该车不需要缴费"); |
| | | // String s= "1."+barrier.getCarNo()+"该车不需要缴费\n"; |
| | | // writeTxt2(s); |
| | | // String jsonValue = JSON.toJSONString(outPark); |
| | | // redisTemplate.opsForValue().set("outPark_dif_"+ barrierId, jsonValue); |
| | | // outLedShow(outPark,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); |
| | | // OutParkLog byOutPark = outParkLogService.getByOutPark(outPark.getCarNo(), outPark.getId()); |
| | | // byOutPark.setOutTime(outPark.getCreateTime()); |
| | | // byOutPark.setParkId(outPark.getParkId()); |
| | | // outParkLogService.saveOrUpdate(byOutPark); |
| | | // String jsonValue = JSON.toJSONString(outPark); |
| | | // redisTemplate.opsForValue().set("outPark_dif_"+ barrierId, jsonValue); |
| | | // outLedShow(outPark,barrier.getCode(),barrier.getCarNo(),outPark.getPrice(),toDayHrMinSec,barrier.getParkId(),request,response,1); |
| | | // } |
| | | // return money; |
| | | // } |
| | | // |
| | | // public int findTicket(String carNo){ |
| | | // QueryWrapper<Ticket> wrapper = new QueryWrapper<>(); |
| | | // wrapper.lambda() |
| | | // .eq(Ticket::getCarNo,carNo) |
| | | // .eq(Ticket::getPayStatus,1); |
| | | // List<Ticket> tickets = ticketService.list(wrapper); |
| | | // if(tickets.size()>0){ |
| | | // return 1; |
| | | // }else{ |
| | | // return 0; |
| | | // } |
| | | // } |
| | | // |
| | | // |
| | | // public void inLedShow(String ledId,String carNo,Integer parkId,HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| | | // TicketBlack black = ticketBlackService.getByCarNo(carNo, 1); |
| | | // if(black != null){ |
| | | // LedBean ledBean = new LedBean(); |
| | | // ledBean.setcolor1(0); |
| | | // ledBean.setcolor2(0); |
| | | // ledBean.setcolor3(0); |
| | | // ledBean.setcolor4(0); |
| | | // ledBean.setcontent1(carNo); |
| | | // ledBean.setcontent2("黑名单车辆"); |
| | | // ledBean.setcontent3("禁止驶入"); |
| | | // ledBean.setcontent4("联系管理员"); |
| | | // ledBean.setdisMode1(0); |
| | | // ledBean.setdisMode2(0); |
| | | // ledBean.setdisMode3(0); |
| | | // ledBean.setdisMode4(0); |
| | | // ledBean.setvoiceContent("黑名单车辆"+carNo+",禁止驶入"); |
| | | // ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | // byte[] dataX = new byte[resultData.getlenth()]; |
| | | // System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | // String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | // data1 = data1.replaceAll("\r\n", ""); |
| | | // noOpen(request,response,data1); |
| | | // }else { |
| | | // String num = redisTemplate.opsForValue().get("car_park_" + parkId); |
| | | // if(num == null){ |
| | | // num = "0"; |
| | | // } |
| | | // Park byId = parkService.getById(parkId); |
| | | // int n = Integer.parseInt(num)+1; |
| | | // redisTemplate.opsForValue().set("car_park_" + parkId,Integer.toString(n),30, TimeUnit.DAYS); |
| | | // int i = byId.getNum() - Integer.parseInt(num); |
| | | // if(i<0){ |
| | | // i = 0; |
| | | // } |
| | | // String carType = ""; |
| | | // String carDay = ""; |
| | | // Barrier barrier = barrierService.findByCode(ledId); |
| | | // WhiteList byCarNo = whiteListService.getByCarNo(carNo); |
| | | // if(byCarNo == null){ |
| | | // carType = "临时车"; |
| | | // }else { |
| | | // if (byCarNo.getType() == 0){ |
| | | // //白名单永久车辆 |
| | | // carType = "月租车"; |
| | | // }else { |
| | | // //白名单固定停车场车辆 |
| | | // 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 = "临时车"; |
| | | // } |
| | | // } |
| | | // } |
| | | // if(StringUtils.isBlank(carDay) && !carNo.equals("无牌车")){ |
| | | // carDay = "欢迎光临"; |
| | | // }else if(StringUtils.isBlank(carDay) && carNo.equals("无牌车")){ |
| | | // carDay = "拒绝驶入"; |
| | | // } |
| | | // |
| | | // LedBean ledBean = new LedBean(); |
| | | // ledBean.setcolor1(0); |
| | | // ledBean.setcolor2(0); |
| | | // ledBean.setcolor3(0); |
| | | // ledBean.setcolor4(0); |
| | | // ledBean.setcontent1(carNo); |
| | | // ledBean.setcontent2(carType); |
| | | // ledBean.setcontent3(carDay); |
| | | // ledBean.setcontent4("余位:"+i); |
| | | // ledBean.setdisMode1(0); |
| | | // ledBean.setdisMode2(0); |
| | | // ledBean.setdisMode3(0); |
| | | // ledBean.setdisMode4(0); |
| | | // ledBean.setvoiceContent(carType+","+carNo+","+carDay); |
| | | // ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | // byte[] dataX = new byte[resultData.getlenth()]; |
| | | // System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | // String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | // data1 = data1.replaceAll("\r\n", ""); |
| | | // |
| | | // if(!carNo.equals("无牌车")){ |
| | | // open(request,response,data1);//入场开闸 |
| | | // }else { |
| | | // noOpen(request,response,data1); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // public void inLedFullShow(String ledId, String carNo, Integer parkId,HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | // String carType = ""; |
| | | // String carDay = ""; |
| | | // Barrier barrier = barrierService.findByCode(ledId); |
| | | // WhiteList byCarNo = whiteListService.getByCarNo(carNo); |
| | | // if(byCarNo == null){ |
| | | // carType = "临时车"; |
| | | // }else { |
| | | // if (byCarNo.getType() == 0){ |
| | | // //白名单永久车辆 |
| | | // carType = "月租车"; |
| | | // }else { |
| | | // //白名单固定停车场车辆 |
| | | // if(StringUtils.isNotBlank(byCarNo.getParkIds()) && byCarNo.getParkIds().contains(barrier.getParkId()+"")){ |
| | | // carType = "月租车"; |
| | | // }else { |
| | | // carType = "临时车"; |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // LedBean ledBean = new LedBean(); |
| | | // ledBean.setcolor1(0); |
| | | // ledBean.setcolor2(0); |
| | | // ledBean.setcolor3(0); |
| | | // ledBean.setcolor4(0); |
| | | // ledBean.setcontent1(carNo); |
| | | // ledBean.setcontent2(carType); |
| | | // ledBean.setcontent3("车位已满"); |
| | | // ledBean.setcontent4("请驶离"); |
| | | // ledBean.setdisMode1(0); |
| | | // ledBean.setdisMode2(0); |
| | | // ledBean.setdisMode3(0); |
| | | // ledBean.setdisMode4(0); |
| | | // ledBean.setvoiceContent("车位已满,请驶离"); |
| | | // ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | // byte[] dataX = new byte[resultData.getlenth()]; |
| | | // System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | // String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | // data1 = data1.replaceAll("\r\n", ""); |
| | | // |
| | | // noOpen(request,response,data1);//入场开闸 |
| | | // } |
| | | // |
| | | // public void outLedShow(OutPark outPark,String ledId,String carNo,Double price,String timeStamp,Integer parkId,HttpServletRequest request, HttpServletResponse response,int type) throws ServletException, IOException { |
| | | // String redisnum = redisTemplate.opsForValue().get("car_park_" + parkId); |
| | | // Park park = parkService.getById(parkId); |
| | | // LedBean ledBean = new LedBean(); |
| | | // ledBean.setcolor1(0); |
| | | // ledBean.setcolor2(0); |
| | | // ledBean.setcolor3(0); |
| | | // ledBean.setcolor4(0); |
| | | // ledBean.setcontent1(carNo); |
| | | // ledBean.setcontent2("停车"+timeStamp); |
| | | // ledBean.setcontent3("交费"+price+"元"); |
| | | // ledBean.setcontent4("禁止闯杆"); |
| | | // ledBean.setdisMode1(0); |
| | | // ledBean.setdisMode2(1); |
| | | // ledBean.setdisMode3(1); |
| | | // ledBean.setdisMode4(0); |
| | | // ledBean.setvoiceContent(carNo+"停车"+timeStamp+"交费"+price+"元"); |
| | | // ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | // byte[] dataX = new byte[resultData.getlenth()]; |
| | | // System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | // String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | // data1 = data1.replaceAll("\r\n", ""); |
| | | // if(type == 0){ |
| | | // if(carNo.equals("无牌车")){ |
| | | // noOpen(request,response,data1); |
| | | // }else { |
| | | // if(timeStamp.contains("记录异常")){ |
| | | // OutPark by5min = outParkService.findBy5min(carNo, parkId, LocalDateTime.now()); |
| | | // if(by5min != null){ |
| | | // //开闸 |
| | | // open(request,response,data1); |
| | | // enterParkService.deleteByCarNo(carNo, parkId); |
| | | // redisTemplate.opsForValue().set("park_change_in_"+parkId,"true",1, TimeUnit.DAYS); |
| | | // 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); |
| | | // } |
| | | // }else { |
| | | // noOpen(request,response,data1); |
| | | // } |
| | | // }else { |
| | | // //开闸 |
| | | // open(request,response,data1); |
| | | // |
| | | // //缓存在redis里,心跳接口去抬杆 |
| | | // String jsonValue = JSON.toJSONString(outPark); |
| | | // redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue); |
| | | // |
| | | // enterParkService.deleteByCarNo(carNo, parkId); |
| | | // redisTemplate.opsForValue().set("park_change_in_"+parkId,"true",1, TimeUnit.DAYS); |
| | | // 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); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | // }else { |
| | | // noOpen(request,response,data1); |
| | | // } |
| | | // |
| | | // } |
| | | // |
| | | // public void outLedShowYueZu(String carNo,String text,Integer parkId,HttpServletRequest request, HttpServletResponse response,int type) throws ServletException, IOException{ |
| | | // String redisnum = redisTemplate.opsForValue().get("car_park_" + parkId); |
| | | // LedBean ledBean = new LedBean(); |
| | | // ledBean.setcolor1(0); |
| | | // ledBean.setcolor2(0); |
| | | // ledBean.setcolor3(0); |
| | | // ledBean.setcolor4(0); |
| | | // ledBean.setcontent1(carNo); |
| | | // ledBean.setcontent2(text); |
| | | // ledBean.setcontent3("减速慢行"); |
| | | // ledBean.setcontent4("欢迎下次光临"); |
| | | // ledBean.setdisMode1(0); |
| | | // ledBean.setdisMode2(0); |
| | | // ledBean.setdisMode3(0); |
| | | // ledBean.setdisMode4(1); |
| | | // ledBean.setvoiceContent(text+carNo+"欢迎下次光临"); |
| | | // ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | // byte[] dataX = new byte[resultData.getlenth()]; |
| | | // System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | // String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | // data1 = data1.replaceAll("\r\n", ""); |
| | | // if(type == 0){ |
| | | // //开闸 |
| | | // open(request,response,data1); |
| | | // enterParkService.deleteByCarNo(carNo,parkId); |
| | | // redisTemplate.opsForValue().set("park_change_in_"+parkId,"true",1, TimeUnit.DAYS); |
| | | // 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); |
| | | // } |
| | | // }else { |
| | | // noOpen(request,response,data1); |
| | | // } |
| | | // } |
| | | // |
| | | // public void outLedShowDefault(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ |
| | | // LedBean ledBean = new LedBean(); |
| | | // ledBean.setcolor1(0); |
| | | // ledBean.setcolor2(0); |
| | | // ledBean.setcolor3(0); |
| | | // ledBean.setcolor4(0); |
| | | // ledBean.setcontent1("一车一杆"); |
| | | // ledBean.setcontent2("减速慢行"); |
| | | // ledBean.setcontent3("无需取卡"); |
| | | // ledBean.setcontent4("扫码缴费"); |
| | | // ledBean.setdisMode1(0); |
| | | // ledBean.setdisMode2(0); |
| | | // ledBean.setdisMode3(0); |
| | | // ledBean.setdisMode4(0); |
| | | // ledBean.setvoiceContent(""); |
| | | // ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | // byte[] dataX = new byte[resultData.getlenth()]; |
| | | // System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | // String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | // data1 = data1.replaceAll("\r\n", ""); |
| | | // noOpen(request,response,data1); |
| | | // } |
| | | // |
| | | // public void inLedShowDefault(Integer parkId,HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ |
| | | // String num = redisTemplate.opsForValue().get("car_park_" + parkId); |
| | | // String con3 = ""; |
| | | // String con4 = ""; |
| | | // if(num == null){ |
| | | // num = "0"; |
| | | // } |
| | | // Park byId = parkService.getById(parkId); |
| | | // int i = byId.getNum() - Integer.parseInt(num); |
| | | // if(i<=0){ |
| | | // i = 0; |
| | | // con3 = "车位已满"; |
| | | // con4 = "请驶离"; |
| | | // }else { |
| | | // con3 = "排队等候"; |
| | | // con4 = "余位:"+i; |
| | | // } |
| | | // LedBean ledBean = new LedBean(); |
| | | // ledBean.setcolor1(0); |
| | | // ledBean.setcolor2(0); |
| | | // ledBean.setcolor3(0); |
| | | // ledBean.setcolor4(0); |
| | | // ledBean.setcontent1("一车一杆"); |
| | | // ledBean.setcontent2("减速慢行"); |
| | | // ledBean.setcontent3(con3); |
| | | // ledBean.setcontent4(con4); |
| | | // ledBean.setdisMode1(0); |
| | | // ledBean.setdisMode2(0); |
| | | // ledBean.setdisMode3(0); |
| | | // ledBean.setdisMode4(0); |
| | | // ledBean.setvoiceContent(""); |
| | | // ResultData resultData = CodeUtil.GetResultDataAllLine(ledBean); |
| | | // byte[] dataX = new byte[resultData.getlenth()]; |
| | | // System.arraycopy(resultData.getdatas(),0,dataX,0,resultData.getlenth()); |
| | | // String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "="; |
| | | // data1 = data1.replaceAll("\r\n", ""); |
| | | // noOpen(request,response,data1); |
| | | // } |
| | | // |
| | | // |
| | | //} |