| | |
| | | import com.boying.common.SystemConfigProperties; |
| | | import com.boying.common.util.DateUtil; |
| | | import com.boying.common.util.StringUtil; |
| | | import com.boying.entity.Barrier; |
| | | import com.boying.entity.EnterPark; |
| | | import com.boying.entity.OutPark; |
| | | import com.boying.entity.Ticket; |
| | | import com.boying.entity.*; |
| | | import com.boying.service.*; |
| | | import com.google.gson.JsonIOException; |
| | | import com.google.gson.JsonObject; |
| | |
| | | import com.google.gson.JsonSyntaxException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.jpa.domain.Specification; |
| | | 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 java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import static com.boying.common.util.DateUtil.getMinute; |
| | | |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | @Autowired |
| | | private SystemConfigProperties systemConfigProperties; |
| | | @Autowired |
| | | private StringRedisTemplate redisTemplate; |
| | | @Autowired |
| | | private ParkService parkService; |
| | | |
| | | /** |
| | | * 回复开闸 |
| | |
| | | @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 = ""; |
| | |
| | | } |
| | | |
| | | System.out.println("编号:"+serialno+"设备识别到了:"+license); |
| | | s+="车牌号为:"+license+",serialno为:"+code+"\n"; |
| | | String format = sdf.format(new Date()); |
| | | s+= format+",车牌号为:"+license+",serialno为:"+code+"。 "; |
| | | |
| | | Barrier barrier = barrierService.findByCode(code); |
| | | if(barrier==null){ |
| | |
| | | }else{ |
| | | if(barrier.getType()==0){ |
| | | outPark(license, barrier.getId(), barrier.getParkId()); |
| | | s+=license+"保存出场记录\n"; |
| | | s+=license+"-保存出场记录\n"; |
| | | }else{ |
| | | open(request, response);//抬杆 |
| | | enterPark(license,barrier.getId(),barrier.getParkId()); |
| | | s+=license+"保存入场记录\n"; |
| | | s+=license+"-保存入场记录\n"; |
| | | } |
| | | } |
| | | writeTxt(s); |
| | |
| | | } |
| | | |
| | | catch (JsonIOException e) { |
| | | System.out.println("无入场记录"); |
| | | s+=" ,查询场内记录异常"; |
| | | e.printStackTrace(); |
| | | writeTxt(s); |
| | | } |
| | | catch (JsonSyntaxException e) { |
| | | System.out.println("无入场记录"); |
| | | s+=" ,查询场内记录异常"; |
| | | e.printStackTrace(); |
| | | writeTxt(s); |
| | | } |
| | | catch (Exception e) { |
| | | System.out.println("无入场记录"); |
| | | s+=" ,查询场内记录异常"; |
| | | writeTxt(s); |
| | | } |
| | | } |
| | |
| | | private CostRuleService costRuleService; |
| | | |
| | | public void enterPark(String carNo,Long barrierId,Long parkId) { |
| | | |
| | | Park park = (Park)parkService.findById(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){ |
| | | return; |
| | | } |
| | | }else { |
| | | s= "0"; |
| | | redisTemplate.opsForValue().set("car_park_" + parkId,s,30, TimeUnit.DAYS); |
| | | } |
| | | } |
| | | enterParkService.deleteByCarNo(carNo,parkId); |
| | | EnterPark enterPark = new EnterPark(); |
| | | enterPark.setCreateTime(new Date()); |
| | |
| | | enterPark.setStatus(1);//发现有违章 |
| | | } |
| | | enterParkService.save(enterPark); |
| | | int i = Integer.parseInt(s); |
| | | i++; |
| | | redisTemplate.opsForValue().set("car_park_" + parkId,Integer.toString(i),30, TimeUnit.DAYS); |
| | | |
| | | Barrier barrier = (Barrier) barrierService.findById(barrierId); |
| | | barrier.setType2(1); |
| | |
| | | }else{ |
| | | outPark.setEnterTime(enterPark.getCreateTime()); |
| | | } |
| | | String redis = redisTemplate.opsForValue().get("car_park_" + parkId); |
| | | long l = outPark.getCreateTime().getTime() - enterPark.getCreateTime().getTime(); |
| | | outPark.setTime(l/(1000*60)); |
| | | double money = 0; |
| | |
| | | |
| | | outPark.setStatus3(findTicket(carNo)); |
| | | outParkService.save(outPark); |
| | | int i = Integer.parseInt(redis); |
| | | i--; |
| | | if(i<0){ |
| | | redisTemplate.opsForValue().set("car_park_" + parkId,"0",30, TimeUnit.DAYS); |
| | | }else { |
| | | redisTemplate.opsForValue().set("car_park_" + parkId,Integer.toString(i),30, TimeUnit.DAYS); |
| | | } |
| | | |
| | | Barrier barrier = (Barrier) barrierService.findById(barrierId); |
| | | barrier.setCarNo(carNo); |