Init EZParkingGPRS project into Coding.net
This commit is contained in:
9
.classpath
Normal file
9
.classpath
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.0"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
36
.project
Normal file
36
.project
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>EZParkingGPRS</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
12
.settings/.jsdtscope
Normal file
12
.settings/.jsdtscope
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="WebContent"/>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
|
||||
<attributes>
|
||||
<attribute name="hide" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
|
||||
<classpathentry kind="output" path=""/>
|
||||
</classpath>
|
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/src=UTF-8
|
11
.settings/org.eclipse.jdt.core.prefs
Normal file
11
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
8
.settings/org.eclipse.wst.common.component
Normal file
8
.settings/org.eclipse.wst.common.component
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="EZParkingGPRS">
|
||||
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
|
||||
<property name="context-root" value="EZParkingGPRS"/>
|
||||
<property name="java-output-path" value="/EZParkingGPRS/bin"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
7
.settings/org.eclipse.wst.common.project.facet.core.xml
Normal file
7
.settings/org.eclipse.wst.common.project.facet.core.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<fixed facet="wst.jsdt.web"/>
|
||||
<installed facet="java" version="1.7"/>
|
||||
<installed facet="jst.web" version="2.5"/>
|
||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||
</faceted-project>
|
1
.settings/org.eclipse.wst.jsdt.ui.superType.container
Normal file
1
.settings/org.eclipse.wst.jsdt.ui.superType.container
Normal file
@ -0,0 +1 @@
|
||||
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
|
1
.settings/org.eclipse.wst.jsdt.ui.superType.name
Normal file
1
.settings/org.eclipse.wst.jsdt.ui.superType.name
Normal file
@ -0,0 +1 @@
|
||||
Window
|
3
WebContent/META-INF/MANIFEST.MF
Normal file
3
WebContent/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
BIN
WebContent/WEB-INF/lib/comm.jar
Normal file
BIN
WebContent/WEB-INF/lib/comm.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/commons-lang-2.6.jar
Normal file
BIN
WebContent/WEB-INF/lib/commons-lang-2.6.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/commons-logging-1.0.3.jar
Normal file
BIN
WebContent/WEB-INF/lib/commons-logging-1.0.3.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/javassist-3.11.0.GA.jar
Normal file
BIN
WebContent/WEB-INF/lib/javassist-3.11.0.GA.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/javassist-3.7.ga.jar
Normal file
BIN
WebContent/WEB-INF/lib/javassist-3.7.ga.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/jcl-over-slf4j-1.6.6.jar
Normal file
BIN
WebContent/WEB-INF/lib/jcl-over-slf4j-1.6.6.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/jzlib-1.1.1.jar
Normal file
BIN
WebContent/WEB-INF/lib/jzlib-1.1.1.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/log4j-1.2.11.jar
Normal file
BIN
WebContent/WEB-INF/lib/log4j-1.2.11.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/mina-core-2.0.7.jar
Normal file
BIN
WebContent/WEB-INF/lib/mina-core-2.0.7.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/ognl-3.0.5.jar
Normal file
BIN
WebContent/WEB-INF/lib/ognl-3.0.5.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/postgresql-9.1-901.jdbc4.jar
Normal file
BIN
WebContent/WEB-INF/lib/postgresql-9.1-901.jdbc4.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/slf4j-api-1.6.6.jar
Normal file
BIN
WebContent/WEB-INF/lib/slf4j-api-1.6.6.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/smslib-3.3.0b2.jar
Normal file
BIN
WebContent/WEB-INF/lib/smslib-3.3.0b2.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/spring-2.5.6.SEC03.jar
Normal file
BIN
WebContent/WEB-INF/lib/spring-2.5.6.SEC03.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/tomcat-apr-5.5.23.jar
Normal file
BIN
WebContent/WEB-INF/lib/tomcat-apr-5.5.23.jar
Normal file
Binary file not shown.
BIN
WebContent/WEB-INF/lib/xbean-spring-3.11.1.jar
Normal file
BIN
WebContent/WEB-INF/lib/xbean-spring-3.11.1.jar
Normal file
Binary file not shown.
122
WebContent/WEB-INF/pages/parking.html
Normal file
122
WebContent/WEB-INF/pages/parking.html
Normal file
@ -0,0 +1,122 @@
|
||||
<HTML>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
||||
<title>EZParking</title>
|
||||
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
var searchReq = createAjaxObj();
|
||||
function createAjaxObj()
|
||||
{
|
||||
var httprequest = false;
|
||||
if (window.XMLHttpRequest)
|
||||
{
|
||||
httprequest = new XMLHttpRequest()
|
||||
if (httprequest.overrideMimeType)
|
||||
httprequest.overrideMimeType('text/xml')
|
||||
}
|
||||
else if (window.ActiveXObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
httprequest = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
try
|
||||
{
|
||||
httprequest = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return httprequest
|
||||
}
|
||||
|
||||
function searchSuggest()
|
||||
{
|
||||
searchReq.open("POST", 'jqueryEZParkingStatus', true);
|
||||
searchReq.onreadystatechange = handleEZParkingStatus;
|
||||
searchReq.send(null);
|
||||
}
|
||||
|
||||
function handleEZParkingStatus()
|
||||
{
|
||||
if (searchReq.readyState == 4)
|
||||
{
|
||||
var str = searchReq.responseText.split(",");
|
||||
|
||||
for (var i = 0; i <= str.length - 1; i++)
|
||||
{
|
||||
alert(str[i])
|
||||
var parkingIdStatus = str[i].split("_");
|
||||
|
||||
if(parkingIdStatus[1] == "1")
|
||||
{
|
||||
document.getElementById("position"+parkingIdStatus[0]).style.background = "#FF0000";
|
||||
}
|
||||
|
||||
if(parkingIdStatus[1] == "0")
|
||||
{
|
||||
document.getElementById("position"+parkingIdStatus[0]).style.background = "#00FF40";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setInterval("searchSuggest()",60000);
|
||||
</script>
|
||||
</head>
|
||||
<Body>
|
||||
<p>东园小区停车位地图</p>
|
||||
<div style="width:9px;height:20px;">
|
||||
<div id="position226" style="background:#00FF40;width:9px;height:20px;position:relative;left:310px;top:171px"></div>
|
||||
<div id="position227" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-21px;left:310px;top:194px"></div>
|
||||
<div id="position228" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-21px;left:310px;top:217px"></div>
|
||||
<div id="position229" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-21px;left:310px;top:271px"></div>
|
||||
<div id="position230" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-21px;left:310px;top:304px"></div>
|
||||
<div id="position231" style="background:#00FF40;width:9px;height:19px;position:relative;margin-top:-21px;left:310px;top:338px"></div>
|
||||
<div id="position232" style="background:#00FF40;width:19px;height:9px;position:relative;margin-top:-10px;left:299px;top:357px"></div>
|
||||
<div id="position233" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-21px;left:310px;top:389px"></div>
|
||||
<div id="position234" style="background:#00FF40;width:9px;height:19px;position:relative;margin-top:-21px;left:310px;top:412px"></div>
|
||||
<div id="position235" style="background:#00FF40;width:19px;height:9px;position:relative;margin-top:-10px;left:290px;top:424px"></div>
|
||||
<div id="position236" style="background:#00FF40;width:19px;height:9px;position:relative;margin-top:-10px;left:290px;top:434px"></div>
|
||||
<div id="position237" style="background:#00FF40;width:19px;height:9px;position:relative;margin-top:-10px;left:290px;top:444px"></div>
|
||||
<div id="position238" style="background:#00FF40;width:19px;height:9px;position:relative;margin-top:-10px;left:290px;top:454px"></div>
|
||||
<div id="position239" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-21px;left:310px;top:483px"></div>
|
||||
<div id="position240" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-21px;left:310px;top:505px"></div>
|
||||
<div id="position241" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-21px;left:310px;top:528px"></div>
|
||||
<div id="position242" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:336px;top:159px"></div>
|
||||
<div id="position243" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:336px;top:181px"></div>
|
||||
<div id="position244" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:336px;top:203px"></div>
|
||||
<div id="position245" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:336px;top:225px"></div>
|
||||
<div id="position246" style="background:#00FF40;width:19px;height:9px;position:relative;margin-top:-10px;left:347px;top:238px"></div>
|
||||
<div id="position247" style="background:#00FF40;width:19px;height:9px;position:relative;margin-top:-10px;left:377px;top:239px"></div>
|
||||
<div id="position248" style="background:#00FF40;width:20px;height:9px;position:relative;margin-top:-10px;left:399px;top:240px"></div>
|
||||
<div id="position249" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:337px;top:283px"></div>
|
||||
<div id="position250" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:337px;top:305px"></div>
|
||||
<div id="position251" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:337px;top:339px"></div>
|
||||
<div id="position252" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:337px;top:361px"></div>
|
||||
<div id="position253" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:337px;top:428px"></div>
|
||||
<div id="position254" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:337px;top:450px"></div>
|
||||
<div id="position255" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:337px;top:482px"></div>
|
||||
<div id="position256" style="background:#00FF40;width:9px;height:20px;position:relative;margin-top:-20px;left:337px;top:504px"></div>
|
||||
<div id="position257" style="background:#00FF40;width:20px;height:9px;position:relative;margin-top:-10px;left:412px;top:318px"></div>
|
||||
<div id="position258" style="background:#00FF40;width:20px;height:9px;position:relative;margin-top:-10px;left:434px;top:319px"></div>
|
||||
<div id="position259" style="background:#00FF40;width:20px;height:9px;position:relative;margin-top:-10px;left:456px;top:320px"></div>
|
||||
<div id="position260" style="background:#00FF40;width:20px;height:9px;position:relative;margin-top:-10px;left:478px;top:321px"></div>
|
||||
<div id="position261" style="background:#00FF40;width:20px;height:9px;position:relative;margin-top:-10px;left:501px;top:322px"></div>
|
||||
<div id="position262" style="background:#00FF40;width:20px;height:9px;position:relative;margin-top:-10px;left:524px;top:323px"></div>
|
||||
<div id="position263" style="background:#00FF40;width:19px;height:9px;position:relative;margin-top:-10px;left:438px;top:404px"></div>
|
||||
<div id="position264" style="background:#00FF40;width:20px;height:9px;position:relative;margin-top:-10px;left:458px;top:405px"></div>
|
||||
<div id="position265" style="background:#00FF40;width:20px;height:9px;position:relative;margin-top:-10px;left:480px;top:406px"></div>
|
||||
<div id="position266" style="background:#00FF40;width:20px;height:9px;position:relative;margin-top:-10px;left:503px;top:407px"></div>
|
||||
</div>
|
||||
|
||||
<div class="div">
|
||||
<img src="dongyuan.bmp" border="0" usemap="#planetmap" alt="Parking" />
|
||||
<map name="planetmap" id="planetmap"></map>
|
||||
</div>
|
||||
</Body>
|
||||
</HTML>
|
88
WebContent/WEB-INF/pages/update.html
Normal file
88
WebContent/WEB-INF/pages/update.html
Normal file
@ -0,0 +1,88 @@
|
||||
<HTML>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
||||
<title>EZParking Update Position</title>
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
var searchReq = createAjaxObj();
|
||||
function createAjaxObj()
|
||||
{
|
||||
var httprequest = false;
|
||||
if (window.XMLHttpRequest)
|
||||
{
|
||||
httprequest = new XMLHttpRequest()
|
||||
if (httprequest.overrideMimeType)
|
||||
httprequest.overrideMimeType('text/xml')
|
||||
}
|
||||
else if (window.ActiveXObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
httprequest = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
try
|
||||
{
|
||||
httprequest = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return httprequest
|
||||
}
|
||||
|
||||
function createQueryString()
|
||||
{
|
||||
var moduleID=document.getElementById("moduleID").value;
|
||||
|
||||
var statusAry = document.getElementsByName("statusId");
|
||||
for(var i=0; i<statusAry.length; i++)
|
||||
{
|
||||
if(statusAry[i].checked)
|
||||
{
|
||||
var status=statusAry[i].value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var queryString="moduleID=" + moduleID + "&status=" + status;
|
||||
return queryString;
|
||||
}
|
||||
|
||||
function updateStatus()
|
||||
{
|
||||
var queryString=createQueryString();
|
||||
|
||||
searchReq.open("POST", 'jqueryUpdateStatus', true);
|
||||
searchReq.onreadystatechange = handleEZParkingStatus;
|
||||
searchReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
|
||||
searchReq.send(queryString);
|
||||
}
|
||||
|
||||
function handleEZParkingStatus()
|
||||
{
|
||||
if (searchReq.readyState == 4)
|
||||
{
|
||||
alert("Update Successfully");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<Body>
|
||||
<div class="div">
|
||||
ModuleID:<input type="text" id="moduleID">
|
||||
<br/>
|
||||
Have Car:<input id="statusRadio" name="statusId" type="radio" value="1" />
|
||||
|
||||
No Car:<input id="statusRadio" name="statusId" type="radio" value="0" />
|
||||
<br/>
|
||||
<button type="button" onClick="updateStatus()">Update</button>
|
||||
<br/><br/>
|
||||
<img src="position.jpg" width="600" height="700" />
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
65
WebContent/WEB-INF/web.xml
Normal file
65
WebContent/WEB-INF/web.xml
Normal file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE web-app
|
||||
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
||||
|
||||
<web-app>
|
||||
<servlet>
|
||||
<servlet-name>parking</servlet-name>
|
||||
<servlet-class>com.ezparking.gprs.EZParkingMap</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>updatePage</servlet-name>
|
||||
<servlet-class>com.ezparking.gprs.EZParkingUpdatePage</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>ezparkingList</servlet-name>
|
||||
<servlet-class>com.ezparking.gprs.EZParkingList</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>ezparkingServlet</servlet-name>
|
||||
<servlet-class>com.ezparking.gprs.EZParkingServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>send</servlet-name>
|
||||
<servlet-class>com.ezparking.gprs.EZParkingSend</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>jqueryEZParkingStatus</servlet-name>
|
||||
<servlet-class>com.ezparking.gprs.EZParkingStatusServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>jqueryUpdateStatus</servlet-name>
|
||||
<servlet-class>com.ezparking.gprs.EZParkingUpdateServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>parking</servlet-name>
|
||||
<url-pattern>/parking</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>updatePage</servlet-name>
|
||||
<url-pattern>/updatePage</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>ezparkingList</servlet-name>
|
||||
<url-pattern>/ezparkingList</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>ezparkingServlet</servlet-name>
|
||||
<url-pattern>/ezparking</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>send</servlet-name>
|
||||
<url-pattern>/send</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>jqueryEZParkingStatus</servlet-name>
|
||||
<url-pattern>/jqueryEZParkingStatus</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>jqueryUpdateStatus</servlet-name>
|
||||
<url-pattern>/jqueryUpdateStatus</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
BIN
WebContent/dongyuan.bmp
Normal file
BIN
WebContent/dongyuan.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 MiB |
BIN
WebContent/position.jpg
Normal file
BIN
WebContent/position.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 494 KiB |
95
src/com/ezparking/gprs/EZParkingList.java
Normal file
95
src/com/ezparking/gprs/EZParkingList.java
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class EZParkingList extends HttpServlet
|
||||
{
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
|
||||
IOException
|
||||
{
|
||||
GPRSService service = new GPRSService();
|
||||
List<GPRSModel> modelList = service.listModel();
|
||||
|
||||
resp.setContentType("text/html;charset=UTF-8");
|
||||
resp.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = resp.getWriter();
|
||||
out.write("<table>");
|
||||
|
||||
out.write("<tr>");
|
||||
out.write("<td>同步头</td>");
|
||||
out.write("<td>所在地市</td>");
|
||||
out.write("<td>所在地区/县</td>");
|
||||
out.write("<td>所在地街道/乡</td>");
|
||||
out.write("<td>所在地路网/停车场</td>");
|
||||
out.write("<td>所在地附近建筑物</td>");
|
||||
out.write("<td>所在地附近建筑物属性</td>");
|
||||
out.write("<td>所在地门牌号</td>");
|
||||
out.write("<td>出入口属性</td>");
|
||||
out.write("<td>产品类型</td>");
|
||||
out.write("<td>备用部分</td>");
|
||||
out.write("<td>接收机模块ID码</td>");
|
||||
out.write("<td>地磁感应模块ID码</td>");
|
||||
out.write("<td>状态位</td>");
|
||||
out.write("<td>水平变化量</td>");
|
||||
out.write("<td>垂直变化量</td>");
|
||||
out.write("<td>车位时间的“时”</td>");
|
||||
out.write("<td>车位时间的“分”</td>");
|
||||
out.write("<td>车位时间的“秒”</td>");
|
||||
out.write("<td>GPRS信号强度</td>");
|
||||
out.write("<td>数据帧尾</td>");
|
||||
out.write("<td>更新时间</td>");
|
||||
out.write("</tr>");
|
||||
for (GPRSModel model : modelList)
|
||||
{
|
||||
out.write("<tr>");
|
||||
|
||||
out.write("<td>55AA</td>");
|
||||
out.write("<td>" + model.getCityID() + "</td>");
|
||||
out.write("<td>" + model.getCountyID() + "</td>");
|
||||
out.write("<td>" + model.getCommitteeID() + "</td>");
|
||||
out.write("<td>" + model.getParkID() + "</td>");
|
||||
out.write("<td>" + model.getBuildingID() + "</td>");
|
||||
out.write("<td>" + model.getBuildingAttrID() + "</td>");
|
||||
out.write("<td>" + model.getBuildingNO() + "</td>");
|
||||
out.write("<td>" + model.getModuleEntranceType() + "</td>");
|
||||
out.write("<td>" + model.getModuleType() + "</td>");
|
||||
out.write("<td>" + model.getMemo() + "</td>");
|
||||
out.write("<td>" + model.getRouterID() + "</td>");
|
||||
out.write("<td>" + model.getModuleID() + "</td>");
|
||||
out.write("<td>" + model.getStatus() + "</td>");
|
||||
out.write("<td>" + model.getHorizonValue() + "</td>");
|
||||
out.write("<td>" + model.getVerticalValue() + "</td>");
|
||||
out.write("<td>" + model.getHour() + "</td>");
|
||||
out.write("<td>" + model.getMinute() + "</td>");
|
||||
out.write("<td>" + model.getSecond() + "</td>");
|
||||
out.write("<td>" + model.getGPRSSignal() + "</td>");
|
||||
out.write("<td>78</td>");
|
||||
out.write("<td>" + model.getUDT() + "</td>");
|
||||
|
||||
out.write("</tr>");
|
||||
}
|
||||
out.write("</table>");
|
||||
out.flush();
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
doGet(req, resp);
|
||||
}
|
||||
}
|
46
src/com/ezparking/gprs/EZParkingMap.java
Normal file
46
src/com/ezparking/gprs/EZParkingMap.java
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class EZParkingMap extends HttpServlet
|
||||
{
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
|
||||
IOException
|
||||
{
|
||||
// resp.setContentType("text/html;charset=UTF-8");
|
||||
// resp.setCharacterEncoding("UTF-8");
|
||||
// PrintWriter out = resp.getWriter();
|
||||
// out.write("<Body>");
|
||||
//
|
||||
// out.write("<p>东园小区停车位地图</p>");
|
||||
// out.write("<img src='images/dongyuan.bmp' border='0' usemap='#planetmap' alt='Planets'/>");
|
||||
// out.write("<map name='planetmap' id='planetmap'>");
|
||||
// out.write("</map>");
|
||||
//
|
||||
// out.write("</Body>");
|
||||
// out.flush();
|
||||
|
||||
doPost(req,resp);
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String path=req.getContextPath();
|
||||
req.getRequestDispatcher("WEB-INF/pages/parking.html").forward(req, resp);
|
||||
}
|
||||
}
|
93
src/com/ezparking/gprs/EZParkingSend.java
Normal file
93
src/com/ezparking/gprs/EZParkingSend.java
Normal file
@ -0,0 +1,93 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.mina.core.future.ConnectFuture;
|
||||
import org.apache.mina.core.service.IoConnector;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.apache.mina.transport.socket.nio.NioSocketConnector;
|
||||
import org.smslib.Message.MessageEncodings;
|
||||
import org.smslib.OutboundMessage;
|
||||
import org.smslib.Service;
|
||||
import org.smslib.modem.SerialModemGateway;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class EZParkingSend extends HttpServlet
|
||||
{
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
|
||||
IOException
|
||||
{
|
||||
doPost(req, resp);
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String sendStr = req.getParameter("sendStr");
|
||||
String mobilePhones = req.getParameter("mobilePhones");
|
||||
// String ipPort = req.getParameter("ipPort");
|
||||
|
||||
Service srv = new Service();
|
||||
OutboundMessage msg;
|
||||
OutboundNotification outboundNotification = new OutboundNotification();
|
||||
SerialModemGateway gateway = new SerialModemGateway("modem.com3", "COM3", 9600, "wavecom",
|
||||
"");
|
||||
gateway.setInbound(true);
|
||||
gateway.setOutbound(true);
|
||||
gateway.setSimPin("0000");
|
||||
gateway.setOutboundNotification(outboundNotification);
|
||||
srv.addGateway(gateway);
|
||||
|
||||
System.out.println("Init Success, Ready to start service");
|
||||
|
||||
try
|
||||
{
|
||||
srv.startService();
|
||||
System.out.println("start service successfully");
|
||||
String[] phones = mobilePhones.split(",");
|
||||
for (String phone : phones)
|
||||
{
|
||||
msg = new OutboundMessage(phone, sendStr);
|
||||
msg.setEncoding(MessageEncodings.ENCUCS2);
|
||||
srv.sendMessage(msg);
|
||||
}
|
||||
srv.stopService();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// IoConnector connector = new NioSocketConnector();
|
||||
// connector.getSessionConfig().setReadBufferSize(2048);
|
||||
//
|
||||
// connector.setHandler(new SendGPRSHandler(sendStr));
|
||||
// ConnectFuture future = connector.connect(new InetSocketAddress(
|
||||
// ipConfig, Integer.valueOf(ipPort).intValue()));
|
||||
// future.awaitUninterruptibly();
|
||||
//
|
||||
// if (!future.isConnected()) {
|
||||
// return;
|
||||
// }
|
||||
// IoSession session = future.getSession();
|
||||
// session.getConfig().setUseReadOperation(true);
|
||||
// session.getCloseFuture().awaitUninterruptibly();
|
||||
// System.out.println(session.read().getMessage());
|
||||
//
|
||||
// System.out.println("After Writing");
|
||||
// connector.dispose();
|
||||
}
|
||||
}
|
60
src/com/ezparking/gprs/EZParkingServlet.java
Normal file
60
src/com/ezparking/gprs/EZParkingServlet.java
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class EZParkingServlet extends HttpServlet
|
||||
{
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
|
||||
IOException
|
||||
{
|
||||
resp.setContentType("text/html;charset=UTF-8");
|
||||
resp.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = resp.getWriter();
|
||||
out.write("<form method='post' action='./send'>");
|
||||
out.write("<table>");
|
||||
|
||||
out.write("<tr>");
|
||||
|
||||
// IPConfigService service = new IPConfigService();
|
||||
out.write("<td>Content: <input type='text' name='sendStr' /></td>");
|
||||
|
||||
// List<IPConfigModel> ipList = service.listModel();
|
||||
// out.write("<td>IP Address: <select name='ipConfig' id='ipConfig'>");
|
||||
// for(IPConfigModel model : ipList)
|
||||
// {
|
||||
// out.write("<option value="+model.getId()+">"+model.getAddress());
|
||||
// out.write("</option>");
|
||||
// }
|
||||
// out.write("</select></td>");
|
||||
out.write("<td>Mobile Phones: <input type='text' name='mobilePhones' /></td>");
|
||||
// out.write("<td>Port: <input type='text' name='ipPort' /></td>");
|
||||
|
||||
out.write("<td><input type='button' value='Send' onClick='this.form.submit()'></td>");
|
||||
out.write("</tr>");
|
||||
|
||||
out.write("</table>");
|
||||
out.write("</form>");
|
||||
out.flush();
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
doGet(req, resp);
|
||||
}
|
||||
}
|
52
src/com/ezparking/gprs/EZParkingStatusServlet.java
Normal file
52
src/com/ezparking/gprs/EZParkingStatusServlet.java
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class EZParkingStatusServlet extends HttpServlet
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
|
||||
IOException
|
||||
{
|
||||
this.doPost(req, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
GPRSService service = new GPRSService();
|
||||
List<TblModule> tblList = new ArrayList<TblModule>();
|
||||
|
||||
StringBuffer tblIds = new StringBuffer();
|
||||
tblList = service.listTblModule();
|
||||
for(TblModule tbl : tblList)
|
||||
{
|
||||
tblIds.append(tbl.getId()+"_"+tbl.getStatus()+",");
|
||||
}
|
||||
String result = tblIds.toString();
|
||||
|
||||
result = result.substring(0, result.length() - 1);
|
||||
|
||||
PrintWriter out = resp.getWriter();
|
||||
out.print(result);
|
||||
}
|
||||
|
||||
}
|
33
src/com/ezparking/gprs/EZParkingUpdatePage.java
Normal file
33
src/com/ezparking/gprs/EZParkingUpdatePage.java
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class EZParkingUpdatePage extends HttpServlet
|
||||
{
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
doPost(req, resp);
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
String path = req.getContextPath();
|
||||
req.getRequestDispatcher("WEB-INF/pages/update.html").forward(req,
|
||||
resp);
|
||||
}
|
||||
}
|
38
src/com/ezparking/gprs/EZParkingUpdateServlet.java
Normal file
38
src/com/ezparking/gprs/EZParkingUpdateServlet.java
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class EZParkingUpdateServlet extends HttpServlet
|
||||
{
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
|
||||
IOException
|
||||
{
|
||||
this.doPost(req, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
GPRSService service = new GPRSService();
|
||||
String moduleID = req.getParameter("moduleID").toString();
|
||||
Integer status = Integer.valueOf(req.getParameter("status").toString());
|
||||
service.updateTblModuleByModuleID(moduleID, status);
|
||||
|
||||
}
|
||||
}
|
154
src/com/ezparking/gprs/GPRSDBUtil.java
Normal file
154
src/com/ezparking/gprs/GPRSDBUtil.java
Normal file
@ -0,0 +1,154 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
public class GPRSDBUtil
|
||||
{
|
||||
private static Connection conn;
|
||||
|
||||
public static Connection getConn()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (conn == null || conn.isClosed())
|
||||
{
|
||||
|
||||
Class.forName("org.postgresql.Driver");
|
||||
String url = "jdbc:postgresql://121.41.88.171:5432/ParkDevice";
|
||||
conn = DriverManager.getConnection(url, "postgres", "Abcd1234");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
public static Statement getStatement(Connection conn)
|
||||
{
|
||||
Statement stmt = null;
|
||||
try
|
||||
{
|
||||
stmt = conn.createStatement();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public static PreparedStatement getPreparedStatement(Connection conn, String sql)
|
||||
{
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = conn.prepareStatement(sql);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return pstmt;
|
||||
}
|
||||
|
||||
public static ResultSet getResultSet(PreparedStatement pstmt)
|
||||
{
|
||||
ResultSet res = null;
|
||||
try
|
||||
{
|
||||
res = pstmt.executeQuery();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static ResultSet getResultSet(Statement stmt, String sql)
|
||||
{
|
||||
ResultSet res = null;
|
||||
try
|
||||
{
|
||||
res = stmt.executeQuery(sql);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void close(Connection conn, Statement stmt, ResultSet res)
|
||||
{
|
||||
close(res);
|
||||
close(stmt);
|
||||
close(conn);
|
||||
}
|
||||
|
||||
private static void close(Statement stmt)
|
||||
{
|
||||
if (stmt != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
stmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
stmt = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void close(ResultSet res)
|
||||
{
|
||||
if (res != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
res.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
res = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void close(Connection conn)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((conn != null) && (!conn.isClosed()))
|
||||
{
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn = null;
|
||||
}
|
||||
}
|
||||
}
|
343
src/com/ezparking/gprs/GPRSModel.java
Normal file
343
src/com/ezparking/gprs/GPRSModel.java
Normal file
@ -0,0 +1,343 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class GPRSModel implements Serializable
|
||||
{
|
||||
private String originalData_HEX;
|
||||
private String cityID_HEX;
|
||||
private String countyID_HEX;
|
||||
private String committeeID_HEX;
|
||||
private String parkID_HEX;
|
||||
private String buildingID_HEX;
|
||||
private String buildingAttrID_HEX;
|
||||
private String buildingNO_HEX;
|
||||
private String moduleEntranceType_HEX;
|
||||
private String moduleType_HEX;
|
||||
private String memo_HEX;
|
||||
private String routerID_HEX;
|
||||
private String moduleID_HEX;
|
||||
private String status_HEX;
|
||||
private String horizonValue_HEX;
|
||||
private String verticalValue_HEX;
|
||||
private String hour_HEX;
|
||||
private String minute_HEX;
|
||||
private String second_HEX;
|
||||
private String gPRSSignal_HEX;
|
||||
private String UDT;
|
||||
|
||||
public String getOriginalData_HEX()
|
||||
{
|
||||
return originalData_HEX;
|
||||
}
|
||||
|
||||
public void setOriginalData_HEX(String originalData_HEX)
|
||||
{
|
||||
this.originalData_HEX = originalData_HEX;
|
||||
}
|
||||
|
||||
public String getCityID_HEX()
|
||||
{
|
||||
return cityID_HEX;
|
||||
}
|
||||
|
||||
public void setCityID_HEX(String cityID_HEX)
|
||||
{
|
||||
this.cityID_HEX = cityID_HEX;
|
||||
}
|
||||
|
||||
public String getCountyID_HEX()
|
||||
{
|
||||
return countyID_HEX;
|
||||
}
|
||||
|
||||
public void setCountyID_HEX(String countyID_HEX)
|
||||
{
|
||||
this.countyID_HEX = countyID_HEX;
|
||||
}
|
||||
|
||||
public String getCommitteeID_HEX()
|
||||
{
|
||||
return committeeID_HEX;
|
||||
}
|
||||
|
||||
public void setCommitteeID_HEX(String committeeID_HEX)
|
||||
{
|
||||
this.committeeID_HEX = committeeID_HEX;
|
||||
}
|
||||
|
||||
public String getParkID_HEX()
|
||||
{
|
||||
return parkID_HEX;
|
||||
}
|
||||
|
||||
public void setParkID_HEX(String parkID_HEX)
|
||||
{
|
||||
this.parkID_HEX = parkID_HEX;
|
||||
}
|
||||
|
||||
public String getBuildingID_HEX()
|
||||
{
|
||||
return buildingID_HEX;
|
||||
}
|
||||
|
||||
public void setBuildingID_HEX(String buildingID_HEX)
|
||||
{
|
||||
this.buildingID_HEX = buildingID_HEX;
|
||||
}
|
||||
|
||||
public String getBuildingAttrID_HEX()
|
||||
{
|
||||
return buildingAttrID_HEX;
|
||||
}
|
||||
|
||||
public void setBuildingAttrID_HEX(String buildingAttrID_HEX)
|
||||
{
|
||||
this.buildingAttrID_HEX = buildingAttrID_HEX;
|
||||
}
|
||||
|
||||
public String getBuildingNO_HEX()
|
||||
{
|
||||
return buildingNO_HEX;
|
||||
}
|
||||
|
||||
public void setBuildingNO_HEX(String buildingNO_HEX)
|
||||
{
|
||||
this.buildingNO_HEX = buildingNO_HEX;
|
||||
}
|
||||
|
||||
public String getModuleEntranceType_HEX()
|
||||
{
|
||||
return moduleEntranceType_HEX;
|
||||
}
|
||||
|
||||
public void setModuleEntranceType_HEX(String moduleEntranceType_HEX)
|
||||
{
|
||||
this.moduleEntranceType_HEX = moduleEntranceType_HEX;
|
||||
}
|
||||
|
||||
public String getModuleType_HEX()
|
||||
{
|
||||
return moduleType_HEX;
|
||||
}
|
||||
|
||||
public void setModuleType_HEX(String moduleType_HEX)
|
||||
{
|
||||
this.moduleType_HEX = moduleType_HEX;
|
||||
}
|
||||
|
||||
public String getMemo_HEX()
|
||||
{
|
||||
return memo_HEX;
|
||||
}
|
||||
|
||||
public void setMemo_HEX(String memo_HEX)
|
||||
{
|
||||
this.memo_HEX = memo_HEX;
|
||||
}
|
||||
|
||||
public String getRouterID_HEX()
|
||||
{
|
||||
return routerID_HEX;
|
||||
}
|
||||
|
||||
public void setRouterID_HEX(String routerID_HEX)
|
||||
{
|
||||
this.routerID_HEX = routerID_HEX;
|
||||
}
|
||||
|
||||
public String getModuleID_HEX()
|
||||
{
|
||||
return moduleID_HEX;
|
||||
}
|
||||
|
||||
public void setModuleID_HEX(String moduleID_HEX)
|
||||
{
|
||||
this.moduleID_HEX = moduleID_HEX;
|
||||
}
|
||||
|
||||
public String getStatus_HEX()
|
||||
{
|
||||
return status_HEX;
|
||||
}
|
||||
|
||||
public void setStatus_HEX(String status_HEX)
|
||||
{
|
||||
this.status_HEX = status_HEX;
|
||||
}
|
||||
|
||||
public String getHorizonValue_HEX()
|
||||
{
|
||||
return horizonValue_HEX;
|
||||
}
|
||||
|
||||
public void setHorizonValue_HEX(String horizonValue_HEX)
|
||||
{
|
||||
this.horizonValue_HEX = horizonValue_HEX;
|
||||
}
|
||||
|
||||
public String getVerticalValue_HEX()
|
||||
{
|
||||
return verticalValue_HEX;
|
||||
}
|
||||
|
||||
public void setVerticalValue_HEX(String verticalValue_HEX)
|
||||
{
|
||||
this.verticalValue_HEX = verticalValue_HEX;
|
||||
}
|
||||
|
||||
public String getHour_HEX()
|
||||
{
|
||||
return hour_HEX;
|
||||
}
|
||||
|
||||
public void setHour_HEX(String hour_HEX)
|
||||
{
|
||||
this.hour_HEX = hour_HEX;
|
||||
}
|
||||
|
||||
public String getMinute_HEX()
|
||||
{
|
||||
return minute_HEX;
|
||||
}
|
||||
|
||||
public void setMinute_HEX(String minute_HEX)
|
||||
{
|
||||
this.minute_HEX = minute_HEX;
|
||||
}
|
||||
|
||||
public String getSecond_HEX()
|
||||
{
|
||||
return second_HEX;
|
||||
}
|
||||
|
||||
public void setSecond_HEX(String second_HEX)
|
||||
{
|
||||
this.second_HEX = second_HEX;
|
||||
}
|
||||
|
||||
public String getgPRSSignal_HEX()
|
||||
{
|
||||
return gPRSSignal_HEX;
|
||||
}
|
||||
|
||||
public void setgPRSSignal_HEX(String gPRSSignal_HEX)
|
||||
{
|
||||
this.gPRSSignal_HEX = gPRSSignal_HEX;
|
||||
}
|
||||
|
||||
|
||||
public String getCityID()
|
||||
{
|
||||
return Long.parseLong(this.getCityID_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getCountyID()
|
||||
{
|
||||
return Long.parseLong(this.getCountyID_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getCommitteeID()
|
||||
{
|
||||
return Long.parseLong(this.getCommitteeID_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getParkID()
|
||||
{
|
||||
return Long.parseLong(this.getParkID_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getBuildingID()
|
||||
{
|
||||
return Long.parseLong(this.getBuildingID_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getBuildingAttrID()
|
||||
{
|
||||
return Long.parseLong(this.getBuildingAttrID_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getBuildingNO()
|
||||
{
|
||||
return Long.parseLong(this.getBuildingNO_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getModuleEntranceType()
|
||||
{
|
||||
return Long.parseLong(this.getModuleEntranceType_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getModuleType()
|
||||
{
|
||||
return Long.parseLong(this.getModuleType_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getMemo()
|
||||
{
|
||||
return Long.parseLong(this.getMemo_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getRouterID()
|
||||
{
|
||||
return Long.parseLong(this.getRouterID_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getModuleID()
|
||||
{
|
||||
return Long.parseLong(this.getModuleID_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return Long.parseLong(this.getStatus_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getHorizonValue()
|
||||
{
|
||||
return (this.getStatus_HEX().equals("20")) ? "0" : Long.parseLong(this.getHorizonValue_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getVerticalValue()
|
||||
{
|
||||
return (this.getStatus_HEX().equals("20")) ? "0" : Long.parseLong(this.getVerticalValue_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getHour()
|
||||
{
|
||||
return (this.getStatus_HEX().equals("20")) ? "0" : Long.parseLong(this.getHour_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getMinute()
|
||||
{
|
||||
return (this.getStatus_HEX().equals("20")) ? "0" : Long.parseLong(this.getMinute_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getSecond()
|
||||
{
|
||||
return (this.getStatus_HEX().equals("20")) ? "0" : Long.parseLong(this.getSecond_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getGPRSSignal()
|
||||
{
|
||||
return (this.getStatus_HEX().equals("20")) ? "0" : Long.parseLong(this.getgPRSSignal_HEX(), 16) + "";
|
||||
}
|
||||
|
||||
public String getUDT()
|
||||
{
|
||||
return UDT;
|
||||
}
|
||||
|
||||
public void setUDT(String uDT)
|
||||
{
|
||||
UDT = uDT;
|
||||
}
|
||||
|
||||
}
|
247
src/com/ezparking/gprs/GPRSService.java
Normal file
247
src/com/ezparking/gprs/GPRSService.java
Normal file
@ -0,0 +1,247 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
public class GPRSService
|
||||
{
|
||||
public Boolean insertGPRS(GPRSModel model)
|
||||
{
|
||||
Integer row = Integer.valueOf(0);
|
||||
|
||||
Connection conn = GPRSDBUtil.getConn();
|
||||
|
||||
StringBuffer sqlBuffer = new StringBuffer("INSERT INTO \"tbl_ModuleData\" (");
|
||||
sqlBuffer.append("\"OriginalData_HEX\", \"CityID_HEX\", \"CountyID_HEX\", \"CommitteeID_HEX\", \"ParkID_HEX\", \"BuildingID_HEX\", \"BuildingAttrID_HEX\", \"BuildingNO_HEX\", ");
|
||||
sqlBuffer.append("\"ModuleEntranceType_HEX\", \"ModuleType_HEX\", \"Memo_HEX\", \"RouterID_HEX\", \"ModuleID_HEX\", \"Status_HEX\", \"HorizonValue_HEX\", \"VerticalValue_HEX\", ");
|
||||
sqlBuffer.append("\"Hour_HEX\", \"Minute_HEX\", \"Second_HEX\", \"GPRSSignal_HEX\", \"CityID\", \"CountyID\", \"CommitteeID\", \"ParkID\", \"BuildingID\", \"BuildingAttrID\", \"BuildingNO\", ");
|
||||
sqlBuffer.append("\"ModuleEntranceType\", \"ModuleType\", \"Memo\", \"RouterID\", \"ModuleID\", \"Status\", \"HorizonValue\", \"VerticalValue\", \"Hour\", \"Minute\", \"Second\", \"GPRSSignal\", \"UDT\")");
|
||||
sqlBuffer.append("VALUES (?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,to_char(now(),'YYYY-MM-dd HH24:MI:SS'))");
|
||||
|
||||
PreparedStatement pstmt = GPRSDBUtil.getPreparedStatement(conn, sqlBuffer.toString());
|
||||
try
|
||||
{
|
||||
pstmt.setString(1, model.getOriginalData_HEX());
|
||||
pstmt.setString(2, model.getCityID_HEX());
|
||||
pstmt.setString(3, model.getCountyID_HEX());
|
||||
pstmt.setString(4, model.getCommitteeID_HEX());
|
||||
pstmt.setString(5, model.getParkID_HEX());
|
||||
pstmt.setString(6, model.getBuildingID_HEX());
|
||||
pstmt.setString(7, model.getBuildingAttrID_HEX());
|
||||
pstmt.setString(8, model.getBuildingNO_HEX());
|
||||
pstmt.setString(9, model.getModuleEntranceType_HEX());
|
||||
pstmt.setString(10, model.getModuleType_HEX());
|
||||
pstmt.setString(11, model.getMemo_HEX());
|
||||
pstmt.setString(12, model.getRouterID_HEX());
|
||||
pstmt.setString(13, model.getModuleID_HEX());
|
||||
pstmt.setString(14, model.getStatus_HEX());
|
||||
pstmt.setString(15, model.getHorizonValue_HEX());
|
||||
pstmt.setString(16, model.getVerticalValue_HEX());
|
||||
pstmt.setString(17, model.getHour_HEX());
|
||||
pstmt.setString(18, model.getMinute_HEX());
|
||||
pstmt.setString(19, model.getSecond_HEX());
|
||||
pstmt.setString(20, model.getgPRSSignal_HEX());
|
||||
pstmt.setString(21, model.getCityID());
|
||||
pstmt.setString(22, model.getCountyID());
|
||||
pstmt.setString(23, model.getCommitteeID());
|
||||
pstmt.setString(24, model.getParkID());
|
||||
pstmt.setString(25, model.getBuildingID());
|
||||
pstmt.setString(26, model.getBuildingAttrID());
|
||||
pstmt.setString(27, model.getBuildingNO());
|
||||
pstmt.setString(28, model.getModuleEntranceType());
|
||||
pstmt.setString(29, model.getModuleType());
|
||||
pstmt.setString(30, model.getMemo());
|
||||
pstmt.setString(31, model.getRouterID());
|
||||
pstmt.setString(32, model.getModuleID());
|
||||
pstmt.setString(33, model.getStatus());
|
||||
pstmt.setString(34, model.getHorizonValue());
|
||||
pstmt.setString(35, model.getVerticalValue());
|
||||
pstmt.setString(36, model.getHour());
|
||||
pstmt.setString(37, model.getMinute());
|
||||
pstmt.setString(38, model.getSecond());
|
||||
pstmt.setString(39, model.getGPRSSignal());
|
||||
|
||||
row = Integer.valueOf(pstmt.executeUpdate());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GPRSDBUtil.close(conn, pstmt, null);
|
||||
}
|
||||
return Boolean.valueOf(row.intValue() > 0);
|
||||
}
|
||||
|
||||
public List<GPRSModel> listModel()
|
||||
{
|
||||
Connection conn = GPRSDBUtil.getConn();
|
||||
StringBuffer sqlBuffer = new StringBuffer(
|
||||
"SELECT * FROM \"tbl_ModuleData\" ORDER BY \"UDT\" desc");
|
||||
|
||||
List<GPRSModel> modelList = new ArrayList<GPRSModel>();
|
||||
PreparedStatement pstmt = GPRSDBUtil.getPreparedStatement(conn, sqlBuffer.toString());
|
||||
try
|
||||
{
|
||||
ResultSet result = pstmt.executeQuery();
|
||||
while (result.next())
|
||||
{
|
||||
GPRSModel model = new GPRSModel();
|
||||
model.setOriginalData_HEX(result.getString("OriginalData_HEX"));
|
||||
model.setCityID_HEX(result.getString("CityID_HEX"));
|
||||
model.setCountyID_HEX(result.getString("CountyID_HEX"));
|
||||
model.setCommitteeID_HEX(result.getString("CommitteeID_HEX"));
|
||||
model.setParkID_HEX(result.getString("ParkID_HEX"));
|
||||
model.setBuildingID_HEX(result.getString("BuildingID_HEX"));
|
||||
model.setBuildingAttrID_HEX(result.getString("BuildingAttrID_HEX"));
|
||||
model.setBuildingNO_HEX(result.getString("BuildingNO_HEX"));
|
||||
model.setModuleEntranceType_HEX(result.getString("ModuleEntranceType_HEX"));
|
||||
model.setModuleType_HEX(result.getString("ModuleType_HEX"));
|
||||
model.setMemo_HEX(result.getString("Memo_HEX"));
|
||||
model.setRouterID_HEX(result.getString("RouterID_HEX"));
|
||||
model.setModuleID_HEX(result.getString("ModuleID_HEX"));
|
||||
model.setStatus_HEX(result.getString("Status_HEX"));
|
||||
model.setHorizonValue_HEX(result.getString("HorizonValue_HEX"));
|
||||
model.setVerticalValue_HEX(result.getString("VerticalValue_HEX"));
|
||||
model.setHour_HEX(result.getString("Hour_HEX"));
|
||||
model.setMinute_HEX(result.getString("Minute_HEX"));
|
||||
model.setSecond_HEX(result.getString("Second_HEX"));
|
||||
model.setgPRSSignal_HEX(result.getString("GPRSSignal_HEX"));
|
||||
model.setUDT(result.getString("UDT"));
|
||||
modelList.add(model);
|
||||
}
|
||||
return modelList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GPRSDBUtil.close(conn, pstmt, null);
|
||||
}
|
||||
return modelList;
|
||||
}
|
||||
|
||||
public List<TblModule> listTblModule()
|
||||
{
|
||||
Connection conn = GPRSDBUtil.getConn();
|
||||
|
||||
StringBuffer sqlBuffer = new StringBuffer(
|
||||
"SELECT * FROM \"tbl_Module\" ORDER BY \"UDT\" desc");
|
||||
|
||||
List<TblModule> moduleList = new ArrayList<TblModule>();
|
||||
PreparedStatement pstmt = GPRSDBUtil.getPreparedStatement(conn, sqlBuffer.toString());
|
||||
try
|
||||
{
|
||||
ResultSet result = pstmt.executeQuery();
|
||||
while (result.next())
|
||||
{
|
||||
TblModule model = new TblModule();
|
||||
model.setId(result.getInt("ID"));
|
||||
model.setCityID(result.getString("CityID"));
|
||||
model.setCountyID(result.getString("CountyID"));
|
||||
model.setCommitteeID(result.getString("CommitteeID"));
|
||||
model.setParkID("ParkID");
|
||||
model.setBuildingID("BuildingID");
|
||||
model.setBuildingAttrID("BuildingAttrID");
|
||||
model.setBuildingNO("BuildingNO");
|
||||
model.setModuleEntranceType("ModuleEntranceType");
|
||||
model.setModuleType("ModuleType");
|
||||
model.setMemo("Memo");
|
||||
model.setRouterID("RouterID");
|
||||
model.setModuleID("ModuleID");
|
||||
model.setRemark("Remark");
|
||||
model.setStatus(result.getInt("Status"));
|
||||
model.setUdt(result.getString("UDT"));
|
||||
|
||||
moduleList.add(model);
|
||||
}
|
||||
return moduleList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GPRSDBUtil.close(conn, pstmt, null);
|
||||
}
|
||||
return moduleList;
|
||||
}
|
||||
|
||||
public Boolean updateTblModuleByModuleID(String moduleID, Integer status)
|
||||
{
|
||||
Integer row = Integer.valueOf(0);
|
||||
Connection conn = GPRSDBUtil.getConn();
|
||||
StringBuffer sqlBuffer = new StringBuffer("UPDATE \"tbl_Module\" SET \"Status\"=?,\"UDT\"=now() WHERE \"ModuleID\"=?");
|
||||
PreparedStatement pstmt = GPRSDBUtil.getPreparedStatement(conn, sqlBuffer.toString());
|
||||
try
|
||||
{
|
||||
pstmt.setInt(1, status);
|
||||
pstmt.setString(2, moduleID);
|
||||
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GPRSDBUtil.close(conn, pstmt, null);
|
||||
}
|
||||
return Boolean.valueOf(row.intValue() > 0);
|
||||
}
|
||||
|
||||
public Boolean updateTblModule(GPRSModel model)
|
||||
{
|
||||
Integer row = Integer.valueOf(0);
|
||||
|
||||
Connection conn = GPRSDBUtil.getConn();
|
||||
|
||||
StringBuffer sqlBuffer = new StringBuffer("UPDATE \"tbl_Module\" SET \"Status\"=?, \"UDT\"=now() ");
|
||||
sqlBuffer.append("WHERE \"CityID\"=? AND \"CountyID\"=? AND \"CommitteeID\"=? AND \"ParkID\"=? AND \"BuildingID\"=? AND \"BuildingAttrID\"=? AND \"BuildingNO\"=? AND \"ModuleEntranceType\"=? ");
|
||||
sqlBuffer.append("AND \"ModuleType\"=? AND \"Memo\"=? AND \"RouterID\"=? AND \"ModuleID\"=?");
|
||||
|
||||
PreparedStatement pstmt = GPRSDBUtil.getPreparedStatement(conn, sqlBuffer.toString());
|
||||
try
|
||||
{
|
||||
pstmt.setInt(1, Integer.valueOf(model.getStatus()));
|
||||
pstmt.setString(2, model.getCityID());
|
||||
pstmt.setString(3, model.getCountyID());
|
||||
pstmt.setString(4, model.getCommitteeID());
|
||||
pstmt.setString(5, model.getParkID());
|
||||
pstmt.setString(6, model.getBuildingID());
|
||||
pstmt.setString(7, model.getBuildingAttrID());
|
||||
pstmt.setString(8, model.getBuildingNO());
|
||||
pstmt.setString(9, model.getModuleEntranceType());
|
||||
pstmt.setString(10, model.getModuleType());
|
||||
pstmt.setString(11, model.getMemo());
|
||||
pstmt.setString(12, model.getRouterID());
|
||||
pstmt.setString(13, model.getModuleID());
|
||||
|
||||
row = Integer.valueOf(pstmt.executeUpdate());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GPRSDBUtil.close(conn, pstmt, null);
|
||||
}
|
||||
return Boolean.valueOf(row.intValue() > 0);
|
||||
}
|
||||
}
|
63
src/com/ezparking/gprs/GPRSServlet.java
Normal file
63
src/com/ezparking/gprs/GPRSServlet.java
Normal file
@ -0,0 +1,63 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
public class GPRSServlet
|
||||
{
|
||||
public GPRSModel receiveGPRS(String str)
|
||||
{
|
||||
GPRSModel model = new GPRSModel();
|
||||
|
||||
if ((str == null) || (str.length() == 0))
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
model.setOriginalData_HEX("55AA"+str+"78");
|
||||
model.setCityID_HEX(str.substring(0, 4));
|
||||
model.setCountyID_HEX(str.substring(4, 8));
|
||||
model.setCommitteeID_HEX(str.substring(8, 12));
|
||||
model.setParkID_HEX(str.substring(12, 16));
|
||||
model.setBuildingID_HEX(str.substring(16, 20));
|
||||
model.setBuildingAttrID_HEX(str.substring(20, 24));
|
||||
model.setBuildingNO_HEX(str.substring(24, 28));
|
||||
model.setModuleEntranceType_HEX(str.substring(28, 30));
|
||||
model.setModuleType_HEX(str.substring(30, 32));
|
||||
model.setMemo_HEX(str.substring(32, 38));
|
||||
model.setRouterID_HEX(str.substring(38, 44));
|
||||
model.setModuleID_HEX(str.substring(44, 50));
|
||||
model.setStatus_HEX(str.substring(50, 52));
|
||||
model.setHorizonValue_HEX(str.substring(52, 56));
|
||||
model.setVerticalValue_HEX(str.substring(56, 60));
|
||||
model.setHour_HEX(str.substring(60, 62));
|
||||
model.setMinute_HEX(str.substring(62, 64));
|
||||
model.setSecond_HEX(str.substring(64, 66));
|
||||
model.setgPRSSignal_HEX(str.substring(66, 68));
|
||||
|
||||
|
||||
GPRSService service = new GPRSService();
|
||||
service.insertGPRS(model);
|
||||
|
||||
updateTblModule(model);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public void updateTblModule(GPRSModel model)
|
||||
{
|
||||
GPRSService service = new GPRSService();
|
||||
service.updateTblModule(model);
|
||||
}
|
||||
|
||||
public String toStringHex(String s)
|
||||
{
|
||||
String result = Integer.toString(Integer.parseInt(s, 16));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
48
src/com/ezparking/gprs/IPConfigModel.java
Normal file
48
src/com/ezparking/gprs/IPConfigModel.java
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class IPConfigModel implements Serializable
|
||||
{
|
||||
private String id;
|
||||
private String address;
|
||||
private String port;
|
||||
|
||||
public String getPort()
|
||||
{
|
||||
return this.port;
|
||||
}
|
||||
|
||||
public void setPort(String port)
|
||||
{
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAddress()
|
||||
{
|
||||
return this.address;
|
||||
}
|
||||
|
||||
public void setAddress(String address)
|
||||
{
|
||||
this.address = address;
|
||||
}
|
||||
}
|
139
src/com/ezparking/gprs/IPConfigService.java
Normal file
139
src/com/ezparking/gprs/IPConfigService.java
Normal file
@ -0,0 +1,139 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
public class IPConfigService
|
||||
{
|
||||
public Boolean insertIPConfig(IPConfigModel model)
|
||||
{
|
||||
Integer row = Integer.valueOf(0);
|
||||
|
||||
Connection conn = GPRSDBUtil.getConn();
|
||||
|
||||
StringBuffer sqlBuffer = new StringBuffer("INSERT INTO ipconfigModel (id, address, port)");
|
||||
sqlBuffer.append("VALUES (?,?, ?)");
|
||||
|
||||
PreparedStatement pstmt = GPRSDBUtil.getPreparedStatement(conn, sqlBuffer.toString());
|
||||
try
|
||||
{
|
||||
pstmt.setString(1, model.getId());
|
||||
pstmt.setString(2, model.getAddress());
|
||||
pstmt.setString(3, model.getPort());
|
||||
row = Integer.valueOf(pstmt.executeUpdate());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GPRSDBUtil.close(conn, pstmt, null);
|
||||
}
|
||||
return Boolean.valueOf(row.intValue() > 0);
|
||||
}
|
||||
|
||||
public Integer findIPConfig(IPConfigModel model)
|
||||
{
|
||||
Integer row = Integer.valueOf(0);
|
||||
|
||||
Connection conn = GPRSDBUtil.getConn();
|
||||
|
||||
StringBuffer sqlBuffer = new StringBuffer(
|
||||
"SELECT count(*) as totalNumber FROM ipconfigModel WHERE address='"
|
||||
+ model.getAddress() + "' and port='" + model.getPort() + "'");
|
||||
|
||||
PreparedStatement pstmt = GPRSDBUtil.getPreparedStatement(conn, sqlBuffer.toString());
|
||||
try
|
||||
{
|
||||
ResultSet result = pstmt.executeQuery();
|
||||
while (result.next())
|
||||
{
|
||||
row = Integer.valueOf(result.getInt("totalNumber"));
|
||||
}
|
||||
return row;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GPRSDBUtil.close(conn, pstmt, null);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
public IPConfigModel getIPConfigById(String id)
|
||||
{
|
||||
IPConfigModel model = new IPConfigModel();
|
||||
|
||||
Connection conn = GPRSDBUtil.getConn();
|
||||
|
||||
StringBuffer sqlBuffer = new StringBuffer("SELECT * FROM ipconfigModel WHERE id='" + id
|
||||
+ "'");
|
||||
|
||||
PreparedStatement pstmt = GPRSDBUtil.getPreparedStatement(conn, sqlBuffer.toString());
|
||||
try
|
||||
{
|
||||
ResultSet result = pstmt.executeQuery();
|
||||
while (result.next())
|
||||
{
|
||||
model.setId(result.getString("id"));
|
||||
model.setAddress(result.getString("address"));
|
||||
model.setPort(result.getString("port"));
|
||||
}
|
||||
return model;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GPRSDBUtil.close(conn, pstmt, null);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public List<IPConfigModel> listModel()
|
||||
{
|
||||
Connection conn = GPRSDBUtil.getConn();
|
||||
StringBuffer sqlBuffer = new StringBuffer("SELECT * FROM ipconfigModel");
|
||||
|
||||
List<IPConfigModel> modelList = new ArrayList<IPConfigModel>();
|
||||
PreparedStatement pstmt = GPRSDBUtil.getPreparedStatement(conn, sqlBuffer.toString());
|
||||
try
|
||||
{
|
||||
ResultSet result = pstmt.executeQuery();
|
||||
while (result.next())
|
||||
{
|
||||
IPConfigModel model = new IPConfigModel();
|
||||
model.setId(result.getString("id"));
|
||||
model.setAddress(result.getString("address"));
|
||||
model.setPort(result.getString("port"));
|
||||
modelList.add(model);
|
||||
}
|
||||
return modelList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
GPRSDBUtil.close(conn, pstmt, null);
|
||||
}
|
||||
return modelList;
|
||||
}
|
||||
}
|
27
src/com/ezparking/gprs/IPConfigServlet.java
Normal file
27
src/com/ezparking/gprs/IPConfigServlet.java
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
public class IPConfigServlet
|
||||
{
|
||||
public void receiveIPConfig(String id, String address, String port)
|
||||
{
|
||||
IPConfigModel model = new IPConfigModel();
|
||||
|
||||
model.setId(id);
|
||||
model.setAddress(address);
|
||||
model.setPort(port);
|
||||
|
||||
IPConfigService service = new IPConfigService();
|
||||
Integer totalrow = service.findIPConfig(model);
|
||||
if (totalrow.intValue() == 0)
|
||||
{
|
||||
service.insertIPConfig(model);
|
||||
}
|
||||
}
|
||||
}
|
30
src/com/ezparking/gprs/MinaTimeServer.java
Normal file
30
src/com/ezparking/gprs/MinaTimeServer.java
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import org.apache.mina.core.service.IoAcceptor;
|
||||
import org.apache.mina.core.session.IdleStatus;
|
||||
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
public class MinaTimeServer
|
||||
{
|
||||
// private static final int PORT = 1001;
|
||||
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
IoAcceptor acceptor = new NioSocketAcceptor();
|
||||
|
||||
acceptor.setHandler(new TimeServerHandler());
|
||||
acceptor.getSessionConfig().setReadBufferSize(2048);
|
||||
acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10);
|
||||
acceptor.bind(new InetSocketAddress(1001));
|
||||
}
|
||||
}
|
29
src/com/ezparking/gprs/OutboundNotification.java
Normal file
29
src/com/ezparking/gprs/OutboundNotification.java
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import org.smslib.IOutboundMessageNotification;
|
||||
import org.smslib.OutboundMessage;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
public class OutboundNotification implements IOutboundMessageNotification
|
||||
{
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.smslib.IOutboundMessageNotification#process(java.lang.String,
|
||||
* org.smslib.OutboundMessage)
|
||||
*/
|
||||
@Override
|
||||
public void process(String gatewayId, OutboundMessage msg)
|
||||
{
|
||||
System.out.println("Outbound handler called from Gateway: " + gatewayId);
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
}
|
64
src/com/ezparking/gprs/SendGPRSHandler.java
Normal file
64
src/com/ezparking/gprs/SendGPRSHandler.java
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.service.IoHandlerAdapter;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
|
||||
import com.sun.xml.internal.fastinfoset.Encoder;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
public class SendGPRSHandler extends IoHandlerAdapter
|
||||
{
|
||||
private String value;
|
||||
|
||||
public SendGPRSHandler(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void messageSent(IoSession session, Object message) throws Exception
|
||||
{
|
||||
// super.messageSent(session, this.value);
|
||||
System.out.println("message sent done");
|
||||
session.close(false);
|
||||
}
|
||||
|
||||
public void messageReceived(IoSession session, Object message) throws Exception
|
||||
{
|
||||
super.messageReceived(session, message);
|
||||
System.out.println("server received message is:"+message.toString());
|
||||
session.write("success");
|
||||
}
|
||||
|
||||
public void sessionOpened(IoSession session) throws Exception
|
||||
{
|
||||
IoBuffer buffer = IoBuffer.wrap(str2HexStr(value));
|
||||
session.write(buffer);
|
||||
}
|
||||
|
||||
public byte[] str2HexStr(String str)
|
||||
{
|
||||
int len = (str.length() / 2);
|
||||
byte[] result = new byte[len];
|
||||
char[] achar = str.toCharArray();
|
||||
for (int i = 0; i < len; i++) {
|
||||
int pos = i * 2;
|
||||
result[i] = (byte) (toByte(achar[pos]) << 4 | toByte(achar[pos + 1]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private byte toByte(char c)
|
||||
{
|
||||
byte b = (byte) "0123456789ABCDEF".indexOf(c);
|
||||
return b;
|
||||
}
|
||||
}
|
192
src/com/ezparking/gprs/TblModule.java
Normal file
192
src/com/ezparking/gprs/TblModule.java
Normal file
@ -0,0 +1,192 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TblModule implements Serializable
|
||||
{
|
||||
private Integer id;
|
||||
private String cityID;
|
||||
private String countyID;
|
||||
private String committeeID;
|
||||
private String parkID;
|
||||
private String buildingID;
|
||||
private String buildingAttrID;
|
||||
private String buildingNO;
|
||||
private String moduleEntranceType;
|
||||
private String moduleType;
|
||||
private String memo;
|
||||
private String routerID;
|
||||
private String moduleID;
|
||||
private String remark;
|
||||
private Integer status;
|
||||
private String udt;
|
||||
|
||||
public Integer getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCityID()
|
||||
{
|
||||
return cityID;
|
||||
}
|
||||
|
||||
public void setCityID(String cityID)
|
||||
{
|
||||
this.cityID = cityID;
|
||||
}
|
||||
|
||||
public String getCountyID()
|
||||
{
|
||||
return countyID;
|
||||
}
|
||||
|
||||
public void setCountyID(String countyID)
|
||||
{
|
||||
this.countyID = countyID;
|
||||
}
|
||||
|
||||
public String getCommitteeID()
|
||||
{
|
||||
return committeeID;
|
||||
}
|
||||
|
||||
public void setCommitteeID(String committeeID)
|
||||
{
|
||||
this.committeeID = committeeID;
|
||||
}
|
||||
|
||||
public String getParkID()
|
||||
{
|
||||
return parkID;
|
||||
}
|
||||
|
||||
public void setParkID(String parkID)
|
||||
{
|
||||
this.parkID = parkID;
|
||||
}
|
||||
|
||||
public String getBuildingID()
|
||||
{
|
||||
return buildingID;
|
||||
}
|
||||
|
||||
public void setBuildingID(String buildingID)
|
||||
{
|
||||
this.buildingID = buildingID;
|
||||
}
|
||||
|
||||
public String getBuildingAttrID()
|
||||
{
|
||||
return buildingAttrID;
|
||||
}
|
||||
|
||||
public void setBuildingAttrID(String buildingAttrID)
|
||||
{
|
||||
this.buildingAttrID = buildingAttrID;
|
||||
}
|
||||
|
||||
public String getBuildingNO()
|
||||
{
|
||||
return buildingNO;
|
||||
}
|
||||
|
||||
public void setBuildingNO(String buildingNO)
|
||||
{
|
||||
this.buildingNO = buildingNO;
|
||||
}
|
||||
|
||||
public String getModuleEntranceType()
|
||||
{
|
||||
return moduleEntranceType;
|
||||
}
|
||||
|
||||
public void setModuleEntranceType(String moduleEntranceType)
|
||||
{
|
||||
this.moduleEntranceType = moduleEntranceType;
|
||||
}
|
||||
|
||||
public String getModuleType()
|
||||
{
|
||||
return moduleType;
|
||||
}
|
||||
|
||||
public void setModuleType(String moduleType)
|
||||
{
|
||||
this.moduleType = moduleType;
|
||||
}
|
||||
|
||||
public String getMemo()
|
||||
{
|
||||
return memo;
|
||||
}
|
||||
|
||||
public void setMemo(String memo)
|
||||
{
|
||||
this.memo = memo;
|
||||
}
|
||||
|
||||
public String getRouterID()
|
||||
{
|
||||
return routerID;
|
||||
}
|
||||
|
||||
public void setRouterID(String routerID)
|
||||
{
|
||||
this.routerID = routerID;
|
||||
}
|
||||
|
||||
public String getModuleID()
|
||||
{
|
||||
return moduleID;
|
||||
}
|
||||
|
||||
public void setModuleID(String moduleID)
|
||||
{
|
||||
this.moduleID = moduleID;
|
||||
}
|
||||
|
||||
public String getRemark()
|
||||
{
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark)
|
||||
{
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Integer getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getUdt()
|
||||
{
|
||||
return udt;
|
||||
}
|
||||
|
||||
public void setUdt(String udt)
|
||||
{
|
||||
this.udt = udt;
|
||||
}
|
||||
|
||||
}
|
22
src/com/ezparking/gprs/Test.java
Normal file
22
src/com/ezparking/gprs/Test.java
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
public class Test
|
||||
{
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
GPRSServlet servlet = new GPRSServlet();
|
||||
|
||||
servlet.receiveGPRS("00010002000300040005000600070001000000000001000001000000000015292C52");
|
||||
}
|
||||
|
||||
}
|
55
src/com/ezparking/gprs/TimeServerHandler.java
Normal file
55
src/com/ezparking/gprs/TimeServerHandler.java
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.ezparking.gprs;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.service.IoHandlerAdapter;
|
||||
import org.apache.mina.core.session.IdleStatus;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
|
||||
/**
|
||||
* @author qwsun
|
||||
*
|
||||
*/
|
||||
public class TimeServerHandler extends IoHandlerAdapter
|
||||
{
|
||||
public void exceptionCaught(IoSession session, Throwable cause) throws Exception
|
||||
{
|
||||
cause.printStackTrace();
|
||||
}
|
||||
|
||||
public void messageReceived(IoSession session, Object message) throws Exception
|
||||
{
|
||||
IoBuffer ioBuffer = (IoBuffer) message;
|
||||
String bufferStr = ioBuffer.getHexDump();
|
||||
bufferStr = bufferStr.trim().replace(" ", "");
|
||||
|
||||
String[] bufferAry = bufferStr.split("55AA");
|
||||
for (String buffer : bufferAry)
|
||||
{
|
||||
GPRSServlet servlet = new GPRSServlet();
|
||||
servlet.receiveGPRS(buffer);
|
||||
|
||||
// InetSocketAddress clientIP = (InetSocketAddress) session.getRemoteAddress();
|
||||
// String ipAddress = clientIP.getAddress().getHostAddress();
|
||||
// String ipPort = clientIP.getPort() + "";
|
||||
//
|
||||
// Date now = new Date();
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// String id = sdf.format(now);
|
||||
//
|
||||
// IPConfigServlet ipServlet = new IPConfigServlet();
|
||||
// ipServlet.receiveIPConfig(id, ipAddress, ipPort);
|
||||
}
|
||||
}
|
||||
|
||||
public void sessionIdle(IoSession session, IdleStatus status) throws Exception
|
||||
{
|
||||
System.out.println("IDLE " + session.getIdleCount(status));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user