src/main/java/com/boying/common/SystemConfigProperties.java | ●●●●● 补丁 | 查看 | 原始文档 | 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/dao/EnterParkDao.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/boying/service/EnterParkService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/systemconfig.properties | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/boying/common/SystemConfigProperties.java
@@ -29,6 +29,9 @@ @Value("${server.ip3}") private String ip3; @Value("${server.logPath}") private String logPath; public String getUploadImgPath() { return uploadImgPath; } @@ -60,4 +63,6 @@ public String getIp3() { return ip3; } public String getLogPath(){return logPath;} } src/main/java/com/boying/controller/OutParkController.java
@@ -1,6 +1,7 @@ package com.boying.controller; import com.boying.common.BaseController; import com.boying.common.SystemConfigProperties; import com.boying.common.util.DateUtil; import com.boying.common.util.StringUtil; import com.boying.entity.*; @@ -20,7 +21,10 @@ import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import java.beans.Transient; import java.io.BufferedWriter; import java.io.FileWriter; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import static com.boying.common.util.DateUtil.getMinute; @@ -37,6 +41,8 @@ private BarrierService barrierService; @Autowired private TicketService ticketService; @Autowired private SystemConfigProperties systemConfigProperties; @Autowired private CostRuleService costRuleService; @@ -215,8 +221,7 @@ @PostMapping("outPark2") public Object outPark(String carNo,Long barrierId,Long parkId,String code2) { String s = "开始执行出场接口------>"; System.out.println(s); String s = "开始执行出场接口------>\n"; Barrier barrier1 = findBarrier(code2); barrierId = barrier1.getId(); parkId = barrier1.getParkId(); @@ -226,24 +231,23 @@ outPark.setBarrierId(barrierId); outPark.setCreateTime(new Date()); outPark.setCode(System.currentTimeMillis()+""); EnterPark enterPark = enterParkService.findByCarNo(carNo); EnterPark enterPark = enterParkService.findByCarNo(carNo).get(0); if(enterPark==null){ String s1 = "未发现入场车辆:"+carNo; System.out.println(s1); s += "未发现入场车辆:"+carNo+"\n"; writeTxt(s); return error("无进场记录或手机号进出输入不一致",null); }else{ String s1 = "发现入场车辆: "+enterPark.getCarNo()+",道闸id为:"+enterPark.getBarrierId()+",停车场id:"+enterPark.getParkId()+",违章标识:"+enterPark.getStatus(); System.out.println(s1); s += "发现入场车辆: "+enterPark.getCarNo()+",道闸id为:"+enterPark.getBarrierId()+",停车场id:"+enterPark.getParkId()+",违章标识:"+enterPark.getStatus()+"\n"; outPark.setEnterTime(enterPark.getCreateTime()); } long l = outPark.getCreateTime().getTime() - enterPark.getCreateTime().getTime(); System.out.println("场内时长为:"+l+"毫秒,合计为: "+l/(1000*60)+"秒"); s+= "场内时长为:"+l+"毫秒,合计为: "+l/(1000*60)+"秒\n"; outPark.setTime(l/(1000*60)); double money = 0; try { money = costRuleService.getMoney(parkId, enterPark.getCreateTime(), outPark.getCreateTime(), 1); System.out.println("金额为:"+money); s+="金额为:"+money+"\n"; } catch (ParseException e) { e.printStackTrace(); } @@ -256,8 +260,12 @@ barrier.setCarNo(carNo); if(outPark.getPrice()==0&&outPark.getStatus3()==0){ barrier.setType2(1); }else { barrier.setType2(0); } barrierService.save(barrier); s += "\n"; writeTxt(s); return success("请求成功",outPark); } @@ -305,4 +313,21 @@ // } // return success("保存成功"); // } 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("打印错误"); } } } src/main/java/com/boying/controller/car/PlateServlet2.java
@@ -2,6 +2,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.boying.common.SystemConfigProperties; import com.boying.common.util.DateUtil; import com.boying.common.util.StringUtil; import com.boying.entity.Barrier; @@ -30,6 +31,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.*; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import static com.boying.common.util.DateUtil.getMinute; @@ -41,6 +43,8 @@ @RequestMapping("/car") public class PlateServlet2 extends HttpServlet { private static final long serialVersionUID = 1L; @Autowired private SystemConfigProperties systemConfigProperties; /** * 回复开闸 @@ -107,7 +111,7 @@ */ @PostMapping("/PlateServlet") protected void info(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String s= ""; BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream(),"UTF-8")); String str = ""; String lineStr = ""; @@ -153,50 +157,61 @@ } String serialno = jsonInfoPlate.get("serialno").getAsString();//摄像机序列号 if( license == null || license == "" ) { if( serialno == null || serialno == "" ) { break; } System.out.println("编号:"+serialno+"设备识别到了:"+license); s+="车牌号为:"+license+",serialno为:"+code+"\n"; Barrier barrier = barrierService.findByCode(code); if(barrier==null){ s+="查询道闸为空\n"; }else{ if(barrier.getType()==0){ outPark(license, barrier.getId(), barrier.getParkId()); s+=license+"保存出场记录\n"; }else{ open(request, response);//抬杆 enterPark(license,barrier.getId(),barrier.getParkId()); s+=license+"保存入场记录\n"; } } writeTxt(s); }while(false); } catch (JsonIOException e) { e.printStackTrace(); writeTxt(s); } catch (JsonSyntaxException e) { e.printStackTrace(); writeTxt(s); } catch (Exception e) { writeTxt(s); } } protected void WriteTxt( String path, String txt) private void writeTxt( String txt) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); try { FileWriter f = new FileWriter(path); BufferedWriter bw=new BufferedWriter(f); bw.write(txt); bw.close(); 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) { } catch(Exception e) { System.out.println("打印错误"); } } @Autowired private OutParkService outParkService; @@ -247,10 +262,10 @@ outPark.setBarrierId(barrierId); outPark.setCreateTime(new Date()); outPark.setCode(System.currentTimeMillis()+""); EnterPark enterPark = enterParkService.findByCarNo(carNo); EnterPark enterPark = enterParkService.findByCarNo(carNo).get(0); if(enterPark==null){ String s1 = "未发现入场车辆:"+carNo; }else{ outPark.setEnterTime(enterPark.getCreateTime()); } src/main/java/com/boying/dao/EnterParkDao.java
@@ -7,6 +7,7 @@ import org.springframework.stereotype.Repository; import java.util.Date; import java.util.List; @Repository("enterParkDao") public interface EnterParkDao extends BaseDao<EnterPark, Long>{ @@ -14,8 +15,8 @@ @Query(value = "select count(id) from EnterPark where createTime>:startTime and createTime<:endTime") long count1(Date startTime, Date endTime); @Query(value = "from EnterPark where carNo=:carNo and id = (select max(id) from EnterPark)") EnterPark findByCarNo(String carNo); @Query(value = "from EnterPark where carNo=:carNo order by createTime desc") List<EnterPark> findByCarNo(String carNo); @Modifying @Query(value = "delete from EnterPark where carNo=:carNo and parkId=:parkId") src/main/java/com/boying/service/EnterParkService.java
@@ -34,7 +34,7 @@ return (int)a; } public EnterPark findByCarNo(String carNo) { public List<EnterPark> findByCarNo(String carNo) { return enterParkDao.findByCarNo(carNo); } src/main/resources/systemconfig.properties
@@ -8,4 +8,6 @@ server.ip2=http://192.168.0.146:8081/ #http://ffkq.hesuancj.cn:38080 #抬杆接口ip server.ip3=http://endu.hbshengcai.com:9092/ws_dingzhi/ws_dingzhi_lizheng/ws_open.ashx server.ip3=http://endu.hbshengcai.com:9092/ws_dingzhi/ws_dingzhi_lizheng/ws_open.ashx #输出日志打印目录 server.logPath=/Users/kongdeqiang/Desktop/