pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/boying/controller/OutParkController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/boying/controller/car/PlateServlet2.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/boying/controller/phone/FFPayController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
pom.xml
@@ -25,6 +25,10 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>mysql</groupId> src/main/java/com/boying/controller/OutParkController.java
@@ -12,6 +12,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -26,6 +27,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.TimeUnit; import static com.boying.common.util.DateUtil.getMinute; @@ -46,6 +48,10 @@ @Autowired private CostRuleService costRuleService; @Autowired private ParkService parkService; @Autowired private StringRedisTemplate redisTemplate; @PostMapping("findPage") public Object findPage(int page,int pageSize) { @@ -188,7 +194,20 @@ Barrier barrier1 = findBarrier(code2); barrierId = barrier1.getId(); parkId = barrier1.getParkId(); 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 "null"; } }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()); @@ -212,6 +231,9 @@ // 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); @@ -233,6 +255,7 @@ outPark.setCode(System.currentTimeMillis()+""); EnterPark enterPark = enterParkService.findByCarNo(carNo).get(0); if(enterPark==null){ s += "未发现入场车辆:"+carNo+"\n"; writeTxt(s); @@ -241,6 +264,7 @@ s += "发现入场车辆: "+enterPark.getCarNo()+",道闸id为:"+enterPark.getBarrierId()+",停车场id:"+enterPark.getParkId()+",违章标识:"+enterPark.getStatus()+"\n"; outPark.setEnterTime(enterPark.getCreateTime()); } String redis = redisTemplate.opsForValue().get("car_park_" + parkId); long l = outPark.getCreateTime().getTime() - enterPark.getCreateTime().getTime(); s+= "场内时长为:"+l+"毫秒,合计为: "+l/(1000*60)+"秒\n"; outPark.setTime(l/(1000*60)); @@ -255,6 +279,13 @@ //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); src/main/java/com/boying/controller/car/PlateServlet2.java
@@ -5,10 +5,7 @@ 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; @@ -16,6 +13,7 @@ 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; @@ -33,6 +31,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.TimeUnit; import static com.boying.common.util.DateUtil.getMinute; @@ -45,6 +44,10 @@ private static final long serialVersionUID = 1L; @Autowired private SystemConfigProperties systemConfigProperties; @Autowired private StringRedisTemplate redisTemplate; @Autowired private ParkService parkService; /** * 回复开闸 @@ -112,6 +115,7 @@ @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 = ""; @@ -162,7 +166,8 @@ } 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){ @@ -170,11 +175,11 @@ }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); @@ -182,14 +187,20 @@ } 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); } } @@ -225,7 +236,20 @@ 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()); @@ -249,6 +273,9 @@ 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); @@ -269,6 +296,7 @@ }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; @@ -281,6 +309,13 @@ 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); src/main/java/com/boying/controller/phone/FFPayController.java
@@ -20,8 +20,11 @@ import javax.persistence.criteria.Root; import javax.servlet.http.HttpServletRequest; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.UnsupportedEncodingException; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -190,16 +193,21 @@ @PostMapping("result") public String result(HttpServletRequest request,String payKey,String payerTypeCode,String payerNum,String payCode,Double amt,String status,String errorInfo,String sign,String signType) throws Exception{ System.out.println(payCode+"-------"+status); String s = "payCode===="+payCode+",\n"; try { s += "开始走回调接口------>"; writeTxt(s); updateOrderRecord(payCode,status); }catch (Exception e){ s += "更新订单记录出异常------>"; writeTxt(s); } return "success"; } //更新订单记录 public void updateOrderRecord(String payCode,String status){ String s = "更新订单记录:payCode===="+payCode+",status==="+status+",\n"; Specification<OrderRecord> specification = new Specification<OrderRecord>() { @Override public Predicate toPredicate(Root<OrderRecord> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { @@ -211,8 +219,10 @@ } }; List<OrderRecord> all = orderRecordService.findAll(specification); s += "查询到订单记录为:"+all.size()+"条,\n"; if(all.size()==1){ OrderRecord orderRecord = all.get(0); s += "查询到订单为:"+orderRecord.getId()+",\n"; if(status.equals("01")){ orderRecord.setStatus(0); } @@ -226,9 +236,12 @@ if(orderRecord.getType()==0){ updateTicket(orderRecord.getQueryId(),status); }else{ s += "修改出场表:"+orderRecord.getQueryId()+",status==="+status+",\n"; writeTxt(s); updateOutPark(orderRecord.getQueryId(),status); } } writeTxt(s); } //更新罚单的状态 @@ -306,13 +319,22 @@ // } public void updateOutPark(Long outParkId,String status){ String s = "开始修改出场表-----》,\n"; s+= "outparkId==="+outParkId+",status==="+status+",\n"; writeTxt(s); OutPark outPark = (OutPark) outParkService.findById(outParkId); if(outPark!=null){ s += "找到出场数据:"+outPark.getId()+",\n"; writeTxt(s); if(status.equals("03")){ s += "出场数据修改----》"; writeTxt(s); outPark.setStatus(1); outParkService.save(outPark); } } s += "未找到出场数据-----》"; writeTxt(s); } //删除进停车场的数据 @@ -336,9 +358,13 @@ //生成电子缴款码 @PostMapping("park") public Object park(Long id){ String logs = "开始缴费流程------》"; logs += "出场id为:"+id+",\n"; OutPark outPark = (OutPark) outParkService.findById(id); if(outPark.getPrice()==0){ updateOutPark(outPark.getId(),"03"); logs += "支付金额为0,\n"; writeTxt(logs); return error("本次停车无需支付费用"); } @@ -356,13 +382,17 @@ List<WhiteList> all = whiteListService.findAll(specification); for(WhiteList w : all){ if(w.getType()==0){ logs+=outPark.getCarNo()+"在白名单,\n"; updateOutPark(outPark.getId(),"03"); writeTxt(logs); return error("本次停车无需支付费用!"); }else{ if(w.getParkId()!=null){ if(w.getEndTime()!=null){ if(w.getParkId()==outPark.getParkId()&&new Date().getTime()<w.getEndTime().getTime()){ logs+=outPark.getCarNo()+"在特殊规则白名单,\n"; updateOutPark(outPark.getId(),"03"); writeTxt(logs); return error("本次停车无需支付费用!"); } } @@ -396,6 +426,8 @@ sbf.append("&signType=MD5"); String s1 = httpsRequest(ip+"/pay/inpay","POST",sbf.toString()); if(s1.equals("error")){ logs += "生成执法电子缴款码失败,请联系管理员,\n"; writeTxt(logs); return error("生成执法电子缴款码失败,请联系管理员"); } JSONObject jsonObject = JSON.parseObject(s1); @@ -404,15 +436,20 @@ if(eInfo.equals("此订单已过期")){ outPark.setCode(System.currentTimeMillis()+""); outParkService.save(outPark); logs += "此订单已过期,\n"; writeTxt(logs); return park(id); }else{ logs += "此订单有异常错误,\n"; writeTxt(logs); return error(eInfo); } }else{ String payCode = jsonObject.get("payCode").toString(); logs += "payCode: "+payCode+",\n"; outPark.setPayCode(payCode); outParkService.save(outPark); writeTxt(logs); addOrderRecord(outPark); return success("生成停车电子缴款码","https://hbfs.govpay.ccb.com/online/fssm?fee=130000000001&PyfScnCgycd=01&pyfTpcd=3&BNo="+payCode); } @@ -446,4 +483,25 @@ orderRecordService.save(orderRecord); } 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("打印错误"); } } }