Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
NTMApp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhang_u
NTMApp
Commits
00519999
Commit
00519999
authored
Jan 02, 2025
by
zhang_u
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
单机取号
parent
0e672d81
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
371 additions
and
155 deletions
+371
-155
AIOItemAdapter.java
...m/example/numbertakingmachine/adapter/AIOItemAdapter.java
+9
-2
MSGItemAdapter.java
...m/example/numbertakingmachine/adapter/MSGItemAdapter.java
+14
-13
BasicBean.java
.../java/com/example/numbertakingmachine/bean/BasicBean.java
+29
-1
ConfigListBean.java
.../com/example/numbertakingmachine/bean/ConfigListBean.java
+9
-0
PATBean.java
...in/java/com/example/numbertakingmachine/bean/PATBean.java
+11
-0
Http.java
.../main/java/com/example/numbertakingmachine/http/Http.java
+64
-58
HttpRequest.java
...ava/com/example/numbertakingmachine/http/HttpRequest.java
+46
-1
MyServer.java
...java/com/example/numbertakingmachine/server/MyServer.java
+2
-4
NTMRecordHelper.java
.../com/example/numbertakingmachine/sql/NTMRecordHelper.java
+3
-4
MainActivity.java
...java/com/example/numbertakingmachine/ui/MainActivity.java
+98
-61
SplashActivity.java
...va/com/example/numbertakingmachine/ui/SplashActivity.java
+5
-5
MyApplication.java
.../com/example/numbertakingmachine/utils/MyApplication.java
+8
-0
SystemUtils.java
...va/com/example/numbertakingmachine/utils/SystemUtils.java
+60
-0
HTTPSession.java
...c/main/java/org/nanohttpd/protocols/http/HTTPSession.java
+3
-2
dialog_print_tips.xml
app/src/main/res/layout/dialog_print_tips.xml
+1
-0
msg_item.xml
app/src/main/res/layout/msg_item.xml
+9
-4
No files found.
app/src/main/java/com/example/numbertakingmachine/adapter/AIOItemAdapter.java
View file @
00519999
...
...
@@ -34,13 +34,20 @@ public class AIOItemAdapter extends RecyclerView.Adapter<AIOItemAdapter.ViewHold
private
int
width
=
-
1
;
private
Context
context
;
public
AIOItemAdapter
(
Context
context
,
ArrayList
<
ConfigDevsBean
.
DevsBean
>
data
,
int
height
,
int
width
)
{
public
AIOItemAdapter
(
Context
context
,
int
height
,
int
width
)
{
this
.
context
=
context
;
this
.
data
=
data
;
this
.
height
=
height
;
this
.
width
=
width
;
}
public
void
setData
(
ArrayList
<
ConfigDevsBean
.
DevsBean
>
data
)
{
this
.
data
=
data
;
}
public
void
notifyAdapter
()
{
notifyDataSetChanged
();
}
public
void
setAiOiItemOnClick
(
AIOitemInterface
aiOitemInterface
)
{
this
.
aiOitemInterface
=
aiOitemInterface
;
}
...
...
app/src/main/java/com/example/numbertakingmachine/adapter/MSGItemAdapter.java
View file @
00519999
...
...
@@ -64,9 +64,6 @@ public class MSGItemAdapter extends RecyclerView.Adapter<MSGItemAdapter.ViewHold
@Override
public
void
onBindViewHolder
(
ViewHolder
holder
,
int
position
)
{
// 从数据列表中获取数据并绑定到视图
if
(
position
>=
data
.
size
())
{
holder
.
layout
.
setVisibility
(
View
.
INVISIBLE
);
}
initView
(
holder
,
position
);
}
...
...
@@ -86,17 +83,21 @@ public class MSGItemAdapter extends RecyclerView.Adapter<MSGItemAdapter.ViewHold
}
holder
.
itemView
.
setLayoutParams
(
params
);
if
(
position
<
data
.
size
())
{
String
queueID
=
data
.
get
(
position
).
get
(
"queueID"
);
if
(
queueID
!=
null
&&
!
queueID
.
isEmpty
())
{
List
<
Map
<
String
,
String
>>
maps
=
recordHelper
.
searchNTMQueueTable
(
BaseUtils
.
NTMRecordTable
.
queueID
,
queueID
);
if
(
maps
.
size
()
>=
1
)
{
Map
<
String
,
String
>
map
=
maps
.
get
(
0
);
holder
.
layout
.
setVisibility
(
View
.
VISIBLE
);
holder
.
num
.
setText
(
map
.
get
(
BaseUtils
.
NTMQueueTable
.
prefix
)
+
data
.
get
(
position
).
get
(
BaseUtils
.
NTMRecordTable
.
current
));
holder
.
num2
.
setText
(
map
.
get
(
BaseUtils
.
NTMQueueTable
.
title
));
if
(
data
.
get
(
position
).
get
(
BaseUtils
.
NTMRecordTable
.
current
).
equals
(
"0"
))
holder
.
layout
.
setVisibility
(
View
.
INVISIBLE
);
else
{
String
queueID
=
data
.
get
(
position
).
get
(
"queueID"
);
if
(
queueID
!=
null
&&
!
queueID
.
isEmpty
())
{
List
<
Map
<
String
,
String
>>
maps
=
recordHelper
.
searchNTMQueueTable
(
BaseUtils
.
NTMRecordTable
.
queueID
,
queueID
);
if
(
maps
.
size
()
>=
1
)
{
Map
<
String
,
String
>
map
=
maps
.
get
(
0
);
holder
.
layout
.
setVisibility
(
View
.
VISIBLE
);
holder
.
num
.
setText
(
map
.
get
(
BaseUtils
.
NTMQueueTable
.
prefix
)
+
data
.
get
(
position
).
get
(
BaseUtils
.
NTMRecordTable
.
current
));
holder
.
num2
.
setText
(
map
.
get
(
BaseUtils
.
NTMQueueTable
.
title
));
}
}
}
else
holder
.
layout
.
setVisibility
(
View
.
INVISIBLE
);
}
}
}
else
holder
.
layout
.
setVisibility
(
View
.
INVISIBLE
);
}
@Override
...
...
app/src/main/java/com/example/numbertakingmachine/bean/BasicBean.java
View file @
00519999
...
...
@@ -18,7 +18,12 @@ public class BasicBean implements Serializable {
private
ModuleBean
module
;
private
TerminalBean
terminal
;
public
BasicBean
(
String
hosCode
,
String
hosName
,
ModuleBean
module
,
TerminalBean
terminal
)
{
this
.
hosCode
=
hosCode
;
this
.
hosName
=
hosName
;
this
.
module
=
module
;
this
.
terminal
=
terminal
;
}
public
String
getHosCode
()
{
return
hosCode
;
...
...
@@ -65,6 +70,13 @@ public class BasicBean implements Serializable {
private
String
level
;
private
List
<
ListBean
>
list
;
public
ModuleBean
(
String
moduleCode
,
String
moduleName
,
String
level
,
List
<
ListBean
>
list
)
{
this
.
moduleCode
=
moduleCode
;
this
.
moduleName
=
moduleName
;
this
.
level
=
level
;
this
.
list
=
list
;
}
public
String
getModuleCode
()
{
return
moduleCode
;
}
...
...
@@ -108,6 +120,12 @@ public class BasicBean implements Serializable {
private
String
moduleName
;
private
String
level
;
public
ListBean
(
String
moduleCode
,
String
moduleName
,
String
level
)
{
this
.
moduleCode
=
moduleCode
;
this
.
moduleName
=
moduleName
;
this
.
level
=
level
;
}
public
String
getModuleCode
()
{
return
moduleCode
;
}
...
...
@@ -153,6 +171,16 @@ public class BasicBean implements Serializable {
private
String
opSys
;
private
String
version
;
public
TerminalBean
(
String
terminalCode
,
String
terminalName
,
String
ip
,
String
mac
,
String
resolution
,
String
opSys
,
String
version
)
{
this
.
terminalCode
=
terminalCode
;
this
.
terminalName
=
terminalName
;
this
.
ip
=
ip
;
this
.
mac
=
mac
;
this
.
resolution
=
resolution
;
this
.
opSys
=
opSys
;
this
.
version
=
version
;
}
public
String
getTerminalCode
()
{
return
terminalCode
;
}
...
...
app/src/main/java/com/example/numbertakingmachine/bean/ConfigListBean.java
View file @
00519999
...
...
@@ -34,6 +34,15 @@ public class ConfigListBean implements Serializable {
private
String
level
;
private
String
type
;
private
List
<
TimesBean
>
times
;
private
String
tempID
;
public
String
getTempID
()
{
return
tempID
;
}
public
void
setTempID
(
String
tempID
)
{
this
.
tempID
=
tempID
;
}
public
String
getTitle
()
{
return
title
;
...
...
app/src/main/java/com/example/numbertakingmachine/bean/PATBean.java
View file @
00519999
...
...
@@ -35,6 +35,17 @@ public class PATBean implements Serializable {
private
String
patName
;
private
String
cardCode
;
public
PATBean
(
String
hosCode
,
String
terminalCode
,
String
regId
,
String
moduleCode
,
String
moduleName
,
String
regNo
,
String
takeTime
,
String
status
)
{
this
.
hosCode
=
hosCode
;
this
.
terminalCode
=
terminalCode
;
this
.
regId
=
regId
;
this
.
moduleCode
=
moduleCode
;
this
.
moduleName
=
moduleName
;
this
.
regNo
=
regNo
;
this
.
takeTime
=
takeTime
;
this
.
status
=
status
;
}
public
String
getHosCode
()
{
return
hosCode
;
}
...
...
app/src/main/java/com/example/numbertakingmachine/http/Http.java
View file @
00519999
...
...
@@ -3,6 +3,7 @@ package com.example.numbertakingmachine.http;
import
android.content.Context
;
import
android.content.res.AssetManager
;
import
android.graphics.Bitmap
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.util.Log
;
...
...
@@ -10,6 +11,8 @@ import android.widget.Toast;
import
androidx.test.espresso.core.internal.deps.guava.base.MoreObjects
;
import
com.example.numbertakingmachine.BuildConfig
;
import
com.example.numbertakingmachine.bean.BasicBean
;
import
com.example.numbertakingmachine.bean.CallBean
;
import
com.example.numbertakingmachine.bean.ConfigBean
;
import
com.example.numbertakingmachine.bean.ConfigDevsBean
;
...
...
@@ -21,9 +24,11 @@ import com.example.numbertakingmachine.bean.ConfigVPlayBean;
import
com.example.numbertakingmachine.bean.DataBean
;
import
com.example.numbertakingmachine.bean.HttpResultBean
;
import
com.example.numbertakingmachine.bean.ImageChangeBean
;
import
com.example.numbertakingmachine.bean.PATBean
;
import
com.example.numbertakingmachine.sql.BaseUtils
;
import
com.example.numbertakingmachine.sql.NTMRecordHelper
;
import
com.example.numbertakingmachine.utils.FileUtils
;
import
com.example.numbertakingmachine.utils.MyApplication
;
import
com.example.numbertakingmachine.utils.SpeechUtils
;
import
com.example.numbertakingmachine.utils.SystemUtils
;
...
...
@@ -51,12 +56,16 @@ import retrofit2.Callback;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
AIO
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
horizontal
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
ip
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
logo
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
mActivityMessenger
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
mac
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
recordHelper
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
all
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
screenReal
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
speechUtils
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
vertical
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
gson
;
import
static
org
.
nanohttpd
.
protocols
.
http
.
response
.
Response
.
newFixedLengthResponse
;
public
class
Http
extends
NanoHTTPD
{
...
...
@@ -67,7 +76,6 @@ public class Http extends NanoHTTPD {
private
static
final
String
value_null
=
"{\"code\":2,\"msg\":\"null\"}"
;
private
Context
context
;
private
Handler
handler
=
null
;
private
Gson
gson
=
new
Gson
();
private
AssetManager
asset
=
null
;
public
Http
(
Context
context
,
int
port
,
Handler
handler
)
{
...
...
@@ -185,36 +193,55 @@ public class Http extends NanoHTTPD {
recordHelper
.
updateNTMConfig
(
config
.
get
(
"color"
),
config
.
get
(
"devType"
),
config
.
get
(
"tips"
),
config
.
get
(
"comTitle"
),
config
.
get
(
"QR"
));
}
ConfigListBean
list
=
null
;
recordHelper
.
deleteTableData
(
BaseUtils
.
NTMRecordTable
.
NAME
);
if
(
config
.
containsKey
(
"list"
))
{
ConfigListBean
list
=
gson
.
fromJson
(
config
.
get
(
"list"
),
ConfigListBean
.
class
);
list
=
gson
.
fromJson
(
config
.
get
(
"list"
),
ConfigListBean
.
class
);
if
(
list
.
getList
().
size
()
!=
0
)
{
recordHelper
.
deleteTableData
(
BaseUtils
.
NTMQueueTable
.
NAME
);
recordHelper
.
deleteTableData
(
BaseUtils
.
NTMTimesTable
.
NAME
);
}
for
(
int
i
=
0
;
i
<
list
.
getList
().
size
();
i
++)
{
ConfigListBean
.
ListBean
listBean
=
list
.
getList
().
get
(
i
);
recordHelper
.
insertNTMQueue
(
listBean
.
get
Queue
ID
(),
""
+
i
,
listBean
.
getTitle
(),
recordHelper
.
insertNTMQueue
(
listBean
.
get
Temp
ID
(),
""
+
i
,
listBean
.
getTitle
(),
listBean
.
getInitial
(),
listBean
.
getPrefix
(),
listBean
.
getLevel
(),
listBean
.
getType
());
for
(
int
j
=
0
;
j
<
listBean
.
getTimes
().
size
();
j
++)
{
ConfigListBean
.
ListBean
.
TimesBean
timesBean
=
listBean
.
getTimes
().
get
(
j
);
recordHelper
.
insertNTMTimes
(
timesBean
.
getName
(),
listBean
.
get
Queue
ID
(),
timesBean
.
getNum
(),
timesBean
.
getStart
(),
recordHelper
.
insertNTMTimes
(
timesBean
.
getName
(),
listBean
.
get
Temp
ID
(),
timesBean
.
getNum
(),
timesBean
.
getStart
(),
timesBean
.
getEnd
(),
timesBean
.
getIsReset
());
}
}
}
BasicBean
.
ModuleBean
moduleBean
=
null
;
if
(
config
.
containsKey
(
"devs"
))
{
ConfigDevsBean
devs
=
gson
.
fromJson
(
config
.
get
(
"devs"
),
ConfigDevsBean
.
class
);
if
(
devs
.
getDevs
().
size
()
!=
0
)
{
recordHelper
.
deleteTableData
(
BaseUtils
.
NTMDevsTable
.
NAME
);
}
for
(
ConfigDevsBean
.
DevsBean
dev
:
devs
.
getDevs
())
{
List
<
BasicBean
.
ModuleBean
.
ListBean
>
bmlist
=
new
ArrayList
<>();
if
(
dev
.
getQueueID
().
contains
(
","
))
{
String
[]
split
=
dev
.
getQueueID
().
split
(
","
);
for
(
int
i
=
0
;
i
<
split
.
length
;
i
++)
{
recordHelper
.
insertNTMDevs
(
dev
.
getCodeID
(),
dev
.
getTitle
(),
split
[
i
],
dev
.
getType
(),
dev
.
getPlayType
());
String
title
=
""
;
for
(
int
j
=
0
;
j
<
list
.
getList
().
size
();
j
++)
{
if
(
list
.
getList
().
get
(
j
).
getTempID
().
equals
(
dev
.
getQueueID
()))
{
bmlist
.
add
(
new
BasicBean
.
ModuleBean
.
ListBean
(
"BM2"
+
dev
.
getQueueID
(),
list
.
getList
().
get
(
j
).
getTitle
(),
"2"
));
}
}
}
}
else
}
else
{
recordHelper
.
insertNTMDevs
(
dev
.
getCodeID
(),
dev
.
getTitle
(),
dev
.
getQueueID
(),
dev
.
getType
(),
dev
.
getPlayType
());
String
title
=
""
;
for
(
int
i
=
0
;
i
<
list
.
getList
().
size
();
i
++)
{
if
(
list
.
getList
().
get
(
i
).
getTempID
().
equals
(
dev
.
getQueueID
()))
{
BasicBean
.
ModuleBean
.
ListBean
bean
=
new
BasicBean
.
ModuleBean
.
ListBean
(
"BM2"
+
dev
.
getQueueID
(),
list
.
getList
().
get
(
i
).
getTitle
(),
"2"
);
bmlist
.
add
(
bean
);
}
}
}
moduleBean
=
new
BasicBean
.
ModuleBean
(
"BM"
+
dev
.
getCodeID
(),
dev
.
getTitle
(),
"1"
,
bmlist
);
}
}
if
(
config
.
containsKey
(
"vPlay"
))
{
...
...
@@ -229,7 +256,9 @@ public class Http extends NanoHTTPD {
recordHelper
.
updateNTMDevsSPlay
(
play
.
getCodeID
(),
play
.
getIp
(),
play
.
getColor
());
}
}
BasicBean
.
TerminalBean
terminalBean
=
new
BasicBean
.
TerminalBean
(
"ST001"
,
config
.
get
(
"comTitle"
),
ip
,
mac
,
screenReal
[
0
]
+
"*"
+
screenReal
[
1
],
Build
.
MODEL
,
BuildConfig
.
VERSION_NAME
);
HttpRequest
.
UpdateData
(
gson
,
new
BasicBean
(
"hos001"
,
"一体机"
,
moduleBean
,
terminalBean
));
//保存完成后发送至activity进行页面刷新
Message
message
=
Message
.
obtain
();
message
.
what
=
0x16
;
...
...
@@ -299,11 +328,12 @@ public class Http extends NanoHTTPD {
CallBean
callBean
=
gson
.
fromJson
(
json
,
CallBean
.
class
);
String
codeID
=
callBean
.
getCodeID
();
//呼叫码值下所有列
String
queueID
=
callBean
.
getQueueID
();
//呼叫单独列
if
(
queueID
.
equals
(
""
))
{
//呼叫列出现空时,按照码值呼叫
if
(
queueID
.
equals
(
""
)
||
!
queueID
.
contains
(
","
)
)
{
//呼叫列出现空时,按照码值呼叫
all
=
recordHelper
.
searchNTMRecordTableRow
(
BaseUtils
.
NTMRecordTable
.
codeID
+
" = ? "
,
new
String
[]{
codeID
});
if
(
all
!=
null
)
{
for
(
int
i
=
0
;
i
<
all
.
size
();
i
++)
{
callUpdateSql
(
all
.
get
(
i
),
BaseUtils
.
NTMRecordTable
.
codeID
,
codeID
);
if
(
i
==
all
.
size
()
-
1
)
callUpdateSql
(
all
.
get
(
i
),
BaseUtils
.
NTMRecordTable
.
codeID
,
codeID
);
}
}
}
else
{
//呼叫列非空时,虚拟叫号下,按照呼叫列依次呼叫
...
...
@@ -325,37 +355,13 @@ public class Http extends NanoHTTPD {
String
queueRepeatID
=
repeatBean
.
getQueueID
();
//呼叫单独列
if
(
queueRepeatID
.
equals
(
""
))
{
//呼叫列出现空时,按照码值呼叫
all
=
recordHelper
.
searchNTMRecordTableRow
(
BaseUtils
.
NTMRecordTable
.
codeID
+
" = ? "
,
new
String
[]{
codeRepeatID
});
if
(
all
!=
null
)
{
for
(
Map
<
String
,
String
>
map
:
all
)
{
String
tips
=
"请"
+
map
.
get
(
BaseUtils
.
NTMRecordTable
.
last
)
+
"前往窗口"
;
//创建消息
Message
message
=
Message
.
obtain
();
message
.
what
=
0x10
;
message
.
obj
=
tips
;
message
.
replyTo
=
mActivityMessenger
;
handler
.
sendMessage
(
message
);
speechUtils
.
playText
(
tips
);
Log
.
d
(
"sss_重呼成功"
,
tips
);
}
}
repeatUpdateSql
(
all
);
}
else
{
//呼叫列非空时,虚拟叫号下,按照呼叫列依次呼叫
String
[]
split
=
queueRepeatID
.
split
(
","
);
for
(
String
queue_RepeatID
:
split
)
{
all
=
recordHelper
.
searchNTMRecordTableRow
(
BaseUtils
.
NTMRecordTable
.
codeID
+
" = ? and "
+
BaseUtils
.
NTMRecordTable
.
queueID
+
" = ?"
,
new
String
[]{
codeRepeatID
,
queue_RepeatID
});
if
(
all
!=
null
)
{
for
(
Map
<
String
,
String
>
map
:
all
)
{
String
tips
=
"请"
+
map
.
get
(
BaseUtils
.
NTMRecordTable
.
last
)
+
"前往窗口"
;
//创建消息
Message
message
=
Message
.
obtain
();
message
.
what
=
0x10
;
message
.
obj
=
tips
;
message
.
replyTo
=
mActivityMessenger
;
handler
.
sendMessage
(
message
);
speechUtils
.
playText
(
tips
);
Log
.
d
(
"sss_重呼成功"
,
tips
);
}
}
repeatUpdateSql
(
all
);
}
}
s
.
append
(
success
);
...
...
@@ -405,20 +411,23 @@ public class Http extends NanoHTTPD {
private
void
callUpdateSql
(
Map
<
String
,
String
>
map
,
String
key
,
String
value
)
{
String
tips
=
""
;
if
(
Integer
.
parseInt
(
map
.
get
(
BaseUtils
.
NTMRecordTable
.
current
))
<
Integer
.
parseInt
(
map
.
get
(
BaseUtils
.
NTMRecordTable
.
all
)))
{
recordHelper
.
updateNTMRecord
(
SystemUtils
.
getIpAddressString
(),
Log
.
d
(
"sss map"
,
map
.
toString
());
if
(
Integer
.
parseInt
(
map
.
get
(
BaseUtils
.
NTMRecordTable
.
current
))
==
0
)
{
tips
=
"当前无取号信息"
;
}
else
if
(
Integer
.
parseInt
(
map
.
get
(
BaseUtils
.
NTMRecordTable
.
current
))
<
Integer
.
parseInt
(
map
.
get
(
BaseUtils
.
NTMRecordTable
.
all
)))
{
recordHelper
.
insertNTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
map
.
get
(
BaseUtils
.
NTMRecordTable
.
all
),
String
.
valueOf
(
Integer
.
parseInt
(
map
.
get
(
BaseUtils
.
NTMRecordTable
.
current
))
+
1
),
String
.
valueOf
(
Integer
.
parseInt
(
map
.
get
(
BaseUtils
.
NTMRecordTable
.
current
))
+
1
),
map
.
get
(
BaseUtils
.
NTMRecordTable
.
codeID
),
map
.
get
(
BaseUtils
.
NTMRecordTable
.
queueID
),
map
.
get
(
BaseUtils
.
NTMRecordTable
.
total
),
key
,
value
);
map
.
get
(
BaseUtils
.
NTMRecordTable
.
total
));
tips
=
"请"
+
map
.
get
(
BaseUtils
.
NTMRecordTable
.
current
)
+
"前往窗口"
;
}
else
{
tips
=
"请"
+
map
.
get
(
BaseUtils
.
NTMRecordTable
.
current
)
+
"前往窗口"
;
}
HttpRequest
.
patData
(
gson
,
new
PATBean
(
"hos001"
,
"ST001"
,
"hos001BM2"
+
map
.
get
(
BaseUtils
.
NTMRecordTable
.
queueID
)
+
map
.
get
(
BaseUtils
.
NTMRecordTable
.
current
),
"BM2"
+
map
.
get
(
BaseUtils
.
NTMRecordTable
.
queueID
),
"心电图"
,
map
.
get
(
BaseUtils
.
NTMRecordTable
.
current
),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd HH:mm:ss"
),
"1"
));
//创建消息
Message
message
=
Message
.
obtain
();
message
.
what
=
0x11
;
...
...
@@ -430,6 +439,23 @@ public class Http extends NanoHTTPD {
Log
.
d
(
"sss_叫号成功"
,
tips
);
}
private
void
repeatUpdateSql
(
List
<
Map
<
String
,
String
>>
all
)
{
if
(
MyApplication
.
all
!=
null
)
{
for
(
Map
<
String
,
String
>
map
:
MyApplication
.
all
)
{
// 新加:数据库添加业务编号字段以及业务名称
String
tips
=
"请"
+
map
.
get
(
BaseUtils
.
NTMRecordTable
.
last
)
+
"前往窗口"
;
HttpRequest
.
patData
(
gson
,
new
PATBean
(
"hos001"
,
"ST001"
,
"1"
,
"BM2"
+
map
.
get
(
BaseUtils
.
NTMRecordTable
.
queueID
),
"心电图"
,
map
.
get
(
BaseUtils
.
NTMRecordTable
.
last
),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd HH:mm:ss"
),
"1"
));
//创建消息
Message
message
=
Message
.
obtain
();
message
.
what
=
0x10
;
message
.
obj
=
tips
;
message
.
replyTo
=
mActivityMessenger
;
handler
.
sendMessage
(
message
);
speechUtils
.
playText
(
tips
);
Log
.
d
(
"sss_重呼成功"
,
tips
);
}
}
}
private
void
initPlay
(
String
str
)
{
Log
.
i
(
TAG
,
"play: "
+
str
);
SpeechUtils
tts
=
SpeechUtils
.
getInstance
(
context
);
...
...
@@ -493,23 +519,4 @@ public class Http extends NanoHTTPD {
return
resp
;
}
//立即生效时 判断是否存在网络交互 有时上传http
private
void
updateData
(){
String
json
=
""
;
HttpRequest
.
getRetrofit
(
gson
)
.
create
(
API
.
class
)
.
pat
(
HttpRequest
.
getBody
(
json
))
.
enqueue
(
new
Callback
<
HttpResultBean
>()
{
@Override
public
void
onResponse
(
Call
<
HttpResultBean
>
call
,
retrofit2
.
Response
<
HttpResultBean
>
response
)
{
}
@Override
public
void
onFailure
(
Call
<
HttpResultBean
>
call
,
Throwable
t
)
{
}
});
}
}
\ No newline at end of file
app/src/main/java/com/example/numbertakingmachine/http/HttpRequest.java
View file @
00519999
package
com
.
example
.
numbertakingmachine
.
http
;
import
android.util.Log
;
import
com.example.numbertakingmachine.bean.BasicBean
;
import
com.example.numbertakingmachine.bean.HttpResultBean
;
import
com.example.numbertakingmachine.bean.PATBean
;
import
com.google.gson.Gson
;
import
okhttp3.OkHttpClient
;
import
okhttp3.RequestBody
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Retrofit
;
import
retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
;
import
retrofit2.converter.gson.GsonConverterFactory
;
...
...
@@ -11,7 +18,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public
class
HttpRequest
{
private
static
OkHttpClient
okHttpClient
=
null
;
private
static
String
URL
=
"http
://www.develop
.com/single_server/public/"
;
private
static
String
URL
=
"http
s://bj-jkb.rwjiankang
.com/single_server/public/"
;
public
static
Retrofit
getRetrofit
(
Gson
gson
)
{
Retrofit
retrofit
=
new
Retrofit
.
Builder
()
...
...
@@ -44,4 +51,42 @@ public class HttpRequest {
return
body
;
}
public
static
void
UpdateData
(
Gson
gson
,
BasicBean
basicBean
){
String
json
=
gson
.
toJson
(
basicBean
);
Log
.
d
(
"sssss"
,
json
);
HttpRequest
.
getRetrofit
(
gson
)
.
create
(
API
.
class
)
.
basic
(
HttpRequest
.
getBody
(
json
))
.
enqueue
(
new
Callback
<
HttpResultBean
>()
{
@Override
public
void
onResponse
(
Call
<
HttpResultBean
>
call
,
retrofit2
.
Response
<
HttpResultBean
>
response
)
{
Log
.
d
(
"sss_success"
,
""
+
response
.
message
());
}
@Override
public
void
onFailure
(
Call
<
HttpResultBean
>
call
,
Throwable
t
)
{
Log
.
d
(
"sss_fail"
,
""
+
t
.
getMessage
());
}
});
}
public
static
void
patData
(
Gson
gson
,
PATBean
batBean
){
String
json
=
gson
.
toJson
(
batBean
);
Log
.
d
(
"sssss"
,
json
);
HttpRequest
.
getRetrofit
(
gson
)
.
create
(
API
.
class
)
.
pat
(
HttpRequest
.
getBody
(
json
))
.
enqueue
(
new
Callback
<
HttpResultBean
>()
{
@Override
public
void
onResponse
(
Call
<
HttpResultBean
>
call
,
retrofit2
.
Response
<
HttpResultBean
>
response
)
{
Log
.
d
(
"sss_success"
,
""
+
response
.
message
());
}
@Override
public
void
onFailure
(
Call
<
HttpResultBean
>
call
,
Throwable
t
)
{
Log
.
d
(
"sss_fail"
,
""
+
t
.
getMessage
());
}
});
}
}
app/src/main/java/com/example/numbertakingmachine/server/MyServer.java
View file @
00519999
...
...
@@ -111,13 +111,11 @@ public class MyServer extends Service {
mServiceMessenger
=
new
Messenger
(
handler
);
// 创建对象,端口我这里设置为8080
if
(
myServer
==
null
)
myServer
=
new
Http
(
getApplicationContext
(),
8080
,
handler
);
myServer
=
new
Http
(
getApplicationContext
(),
8080
,
handler
);
try
{
// 开启HTTP服务
Log
.
d
(
"ssss"
,
"开启http服务"
);
if
(!
myServer
.
isAlive
())
myServer
.
start
();
myServer
.
start
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
app/src/main/java/com/example/numbertakingmachine/sql/NTMRecordHelper.java
View file @
00519999
...
...
@@ -135,8 +135,7 @@ public class NTMRecordHelper extends SQLiteOpenHelper {
List
<
DataBean
>
array
=
new
ArrayList
<>();
SQLiteDatabase
database
=
helper
.
getWritableDatabase
();
try
{
Cursor
query
=
database
.
query
(
true
,
BaseUtils
.
NTMRecordTable
.
NAME
,
null
,
key
+
" = ?"
,
new
String
[]{
value
},
null
,
null
,
null
,
null
);
Cursor
query
=
database
.
rawQuery
(
"select * from "
+
BaseUtils
.
NTMRecordTable
.
NAME
+
" WHERE "
+
key
+
" = ?"
,
new
String
[]{
value
});
query
.
moveToFirst
();
for
(
int
i
=
0
;
i
<
query
.
getCount
();
i
++)
{
array
.
add
(
new
DataBean
(
query
.
getString
(
query
.
getColumnIndex
(
BaseUtils
.
NTMRecordTable
.
id
)),
...
...
@@ -163,8 +162,7 @@ public class NTMRecordHelper extends SQLiteOpenHelper {
List
<
DataBean
>
array
=
new
ArrayList
<>();
SQLiteDatabase
database
=
helper
.
getWritableDatabase
();
try
{
Cursor
query
=
database
.
query
(
true
,
BaseUtils
.
NTMTimesTable
.
NAME
,
null
,
key
+
" = ?"
,
new
String
[]{
value
},
null
,
null
,
null
,
null
);
Cursor
query
=
database
.
rawQuery
(
"select * from "
+
BaseUtils
.
NTMTimesTable
.
NAME
+
" WHERE "
+
key
+
" = ?"
,
new
String
[]{
value
});
query
.
moveToFirst
();
for
(
int
i
=
0
;
i
<
query
.
getCount
();
i
++)
{
array
.
add
(
new
DataBean
(
query
.
getString
(
query
.
getColumnIndex
(
BaseUtils
.
NTMTimesTable
.
id
)),
...
...
@@ -199,6 +197,7 @@ public class NTMRecordHelper extends SQLiteOpenHelper {
map
.
put
(
BaseUtils
.
NTMRecordTable
.
all
,
query
.
getString
(
query
.
getColumnIndex
(
BaseUtils
.
NTMRecordTable
.
all
)));
map
.
put
(
BaseUtils
.
NTMRecordTable
.
last
,
query
.
getString
(
query
.
getColumnIndex
(
BaseUtils
.
NTMRecordTable
.
last
)));
map
.
put
(
BaseUtils
.
NTMRecordTable
.
current
,
query
.
getString
(
query
.
getColumnIndex
(
BaseUtils
.
NTMRecordTable
.
current
)));
map
.
put
(
BaseUtils
.
NTMRecordTable
.
queueID
,
query
.
getString
(
query
.
getColumnIndex
(
BaseUtils
.
NTMRecordTable
.
queueID
)));
array
.
add
(
map
);
query
.
moveToNext
();
}
...
...
app/src/main/java/com/example/numbertakingmachine/ui/MainActivity.java
View file @
00519999
...
...
@@ -38,6 +38,8 @@ import com.example.numbertakingmachine.adapter.MSGItemAdapter;
import
com.example.numbertakingmachine.bean.Argument
;
import
com.example.numbertakingmachine.bean.ConfigDevsBean
;
import
com.example.numbertakingmachine.bean.DataBean
;
import
com.example.numbertakingmachine.bean.PATBean
;
import
com.example.numbertakingmachine.http.HttpRequest
;
import
com.example.numbertakingmachine.server.MyServer
;
import
com.example.numbertakingmachine.sql.BaseUtils
;
import
com.example.numbertakingmachine.sql.NTMRecordHelper
;
...
...
@@ -57,6 +59,7 @@ import java.util.concurrent.Executors;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
AIO
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
devType
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
gson
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
horizontal
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
logo
;
import
static
com
.
example
.
numbertakingmachine
.
utils
.
MyApplication
.
myServer
;
...
...
@@ -96,9 +99,11 @@ public class MainActivity extends AppCompatActivity {
case
0x12
:
Log
.
d
(
"sss"
,
"Service发送过来的结果是..."
+
msg
.
obj
);
textStr
+=
"\n叫号:"
+
String
.
valueOf
(
msg
.
obj
);
if
(
msg
.
obj
.
equals
(
"当前无取号信息"
))
return
;
if
(
devType
.
equals
(
"0"
))
{
if
(
msgItemAdapter
!=
null
)
{
Collections
.
reverse
(
all
);
msgItemAdapter
.
setData
(
all
);
msgItemAdapter
.
refresh
();
}
...
...
@@ -113,7 +118,7 @@ public class MainActivity extends AppCompatActivity {
text
.
setText
(
textStr
);
break
;
case
0x16
:
initSQL
();
initSQL
(
1
);
break
;
case
0x18
:
//更改图片
...
...
@@ -150,6 +155,7 @@ public class MainActivity extends AppCompatActivity {
private
DataBean
dataBean
=
null
;
private
MSGItemAdapter
msgItemAdapter
;
private
TextView
dialogTime
;
private
AIOItemAdapter
aioItemAdapter
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -175,7 +181,7 @@ public class MainActivity extends AppCompatActivity {
}
initView
();
initServer
();
initSQL
();
initSQL
(
0
);
Log
.
d
(
"sss"
,
FileUtils
.
settingPath
);
}
...
...
@@ -196,56 +202,57 @@ public class MainActivity extends AppCompatActivity {
recycle
=
findViewById
(
R
.
id
.
recycle
);
}
private
void
initSQL
()
{
private
void
initSQL
(
int
type
)
{
List
<
Map
<
String
,
String
>>
maps
=
recordHelper
.
searchNTMConfigTableAll
();
if
(
maps
==
null
||
maps
.
size
()
==
0
)
{
//程序首次进入,创建默认数据
recordHelper
.
insertNTMConfig
(
"1"
,
"0"
,
"0"
,
"温馨提示"
,
"融威众邦"
,
"123456"
,
""
,
"1"
);
recordHelper
.
insertNTMQueue
(
"
1
"
,
"1"
,
"默认"
,
"0"
,
"A"
,
"0"
,
"0"
);
recordHelper
.
insertNTMTimes
(
"全天"
,
"
1
"
,
"100"
,
"8:00"
,
"16:00"
,
"0"
);
recordHelper
.
insertNTMDevs
(
"01"
,
"窗口一"
,
"
1
"
,
"0"
,
"0"
);
recordHelper
.
insertNTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
"1"
,
"1"
,
"1"
,
"01"
,
"
1
"
,
"100"
);
recordHelper
.
insertNTMQueue
(
"
A
"
,
"1"
,
"默认"
,
"0"
,
"A"
,
"0"
,
"0"
);
recordHelper
.
insertNTMTimes
(
"全天"
,
"
A
"
,
"100"
,
"8:00"
,
"16:00"
,
"0"
);
recordHelper
.
insertNTMDevs
(
"01"
,
"窗口一"
,
"
A
"
,
"0"
,
"0"
);
recordHelper
.
insertNTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
"1"
,
"1"
,
"1"
,
"01"
,
"
A
"
,
"100"
);
}
all
=
recordHelper
.
searchNTMRecordTableAll
();
if
(
all
!=
null
&&
all
.
size
()
>
=
0
)
{
if
(
all
!=
null
&&
all
.
size
()
>
0
)
{
if
(!
all
.
get
(
0
).
get
(
BaseUtils
.
NTMRecordTable
.
ntimes
).
equals
(
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
)))
{
recordHelper
.
updateNTMRecord
(
SystemUtils
.
getIpAddressString
(),
recordHelper
.
deleteTableData
(
BaseUtils
.
NTMRecordTable
.
NAME
);
recordHelper
.
insertNTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
"1"
,
"1"
,
"1"
,
""
,
""
,
""
,
all
.
get
(
0
).
get
(
BaseUtils
.
NTMRecordTable
.
id
),
""
);
"1"
,
"1"
,
"0"
,
"01"
,
"A"
,
"100"
);
}
}
showMsgList
();
showList
();
showMsgList
(
type
);
showList
(
type
);
}
private
void
showMsgList
()
{
//横竖屏一体机呼叫展示
private
void
showMsgList
(
int
type
)
{
//横竖屏一体机呼叫展示
if
(
devType
.
equals
(
"0"
))
{
int
size
=
0
;
if
(
orientation
==
0
)
{
size
=
4
;
showMsgRecycle
.
setLayoutManager
(
new
StaggeredGridLayoutManager
(
1
,
StaggeredGridLayoutManager
.
VERTICAL
));
}
else
{
size
=
5
;
showMsgRecycle
.
setLayoutManager
(
new
StaggeredGridLayoutManager
(
2
,
StaggeredGridLayoutManager
.
VERTICAL
));
}
showMsgView
(
siz
e
);
showMsgView
(
typ
e
);
}
else
if
(
devType
.
equals
(
"3"
))
{
showMsgRecycle
.
setLayoutManager
(
new
StaggeredGridLayoutManager
(
1
,
StaggeredGridLayoutManager
.
VERTICAL
));
showMsgView
(
4
);
showMsgView
(
type
);
}
}
private
void
showMsgView
(
int
siz
e
)
{
private
void
showMsgView
(
int
typ
e
)
{
showMsgRecycle
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
int
width
=
showMsgRecycle
.
getWidth
();
int
height
=
showMsgRecycle
.
getHeight
();
//Collections.reverse(all);
msgItemAdapter
=
new
MSGItemAdapter
(
getApplicationContext
(),
width
,
height
);
Collections
.
reverse
(
all
);
Log
.
d
(
"sss size "
,
all
.
size
()
+
" "
);
if
(
type
==
0
)
{
msgItemAdapter
=
new
MSGItemAdapter
(
getApplicationContext
(),
width
,
height
);
showMsgRecycle
.
setAdapter
(
msgItemAdapter
);
}
else
msgItemAdapter
.
refresh
();
msgItemAdapter
.
setData
(
all
);
showMsgRecycle
.
setAdapter
(
msgItemAdapter
);
}
});
}
...
...
@@ -253,15 +260,10 @@ public class MainActivity extends AppCompatActivity {
/**
* 展示取号列
*/
private
void
showList
()
{
private
void
showList
(
int
type
)
{
ArrayList
<
ConfigDevsBean
.
DevsBean
>
devs
=
recordHelper
.
searchNTMDevsTableAll
();
switch
(
devType
)
{
case
"0"
:
// devs.add(new ConfigDevsBean.DevsBean());
// devs.add(new ConfigDevsBean.DevsBean());
// devs.add(new ConfigDevsBean.DevsBean());
// devs.add(new ConfigDevsBean.DevsBean());
// devs.add(new ConfigDevsBean.DevsBean());
if
(
orientation
==
0
)
{
//竖屏一体机
if
(
devs
.
size
()
==
3
||
devs
.
size
()
==
4
)
recycle
.
setLayoutManager
(
new
StaggeredGridLayoutManager
(
2
,
StaggeredGridLayoutManager
.
VERTICAL
));
...
...
@@ -305,17 +307,20 @@ public class MainActivity extends AppCompatActivity {
int
width
=
recycle
.
getWidth
();
int
height
=
recycle
.
getHeight
();
Log
.
i
(
"cchh"
,
"TextView Height is "
+
height
+
", Width is "
+
width
);
AIOItemAdapter
aioItemAdapter
=
new
AIOItemAdapter
(
getApplicationContext
(),
devs
,
height
,
width
);
recycle
.
setAdapter
(
aioItemAdapter
);
if
(
type
==
0
)
{
aioItemAdapter
=
new
AIOItemAdapter
(
getApplicationContext
(),
height
,
width
);
recycle
.
setAdapter
(
aioItemAdapter
);
}
else
aioItemAdapter
.
notifyAdapter
();
aioItemAdapter
.
setData
(
devs
);
aioItemAdapter
.
setAiOiItemOnClick
(
new
AIOitemInterface
()
{
@Override
public
void
onItemClick
(
View
view
,
int
position
)
{
String
queueID
=
devs
.
get
(
position
).
getQueueID
();
if
(
queueID
!=
null
&&
!
queueID
.
isEmpty
())
{
List
<
DataBean
>
dataBeans
=
recordHelper
.
searchNTMRecordTable
(
BaseUtils
.
NTMDevsTable
.
queueID
,
queueID
);
List
<
DataBean
>
timesBeans
=
recordHelper
.
searchNTMTimesTable
(
BaseUtils
.
NTMDevsTable
.
queueID
,
queueID
);
printNTM
(
dataBeans
,
timesBeans
);
showDialog
(
devs
.
get
(
position
).
getTitle
()
);
List
<
DataBean
>
dataBeans
=
recordHelper
.
searchNTMRecordTable
(
BaseUtils
.
NTMDevsTable
.
queueID
,
queueID
);
printNTM
(
devs
.
get
(
position
).
getTitle
(),
dataBeans
,
timesBeans
);
}
}
});
...
...
@@ -345,7 +350,7 @@ public class MainActivity extends AppCompatActivity {
bindService
(
intentHttp
,
conn
,
BIND_AUTO_CREATE
);
}
private
void
showDialog
(
String
name
)
{
private
void
showDialog
(
int
type
,
String
name
)
{
View
view
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
dialog_print_tips
,
null
,
true
);
if
(
dialog
==
null
)
dialog
=
new
AlertDialog
.
Builder
(
this
).
setView
(
view
).
create
();
...
...
@@ -355,15 +360,18 @@ public class MainActivity extends AppCompatActivity {
dialog
.
setCancelable
(
false
);
dialog
.
setCanceledOnTouchOutside
(
false
);
dialogTime
=
view
.
findViewById
(
R
.
id
.
time
);
TextView
tips
=
view
.
findViewById
(
R
.
id
.
tips
);
TextView
title
=
view
.
findViewById
(
R
.
id
.
title
);
dialogTime
.
setText
(
dialogDismiss
+
"s"
);
title
.
setText
(
name
);
if
(
type
==
0
)
tips
.
setText
(
"取号成功"
);
else
tips
.
setText
(
"不在取号时间"
);
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
while
(
dialogDismiss
>=
0
)
{
Log
.
d
(
"ssss"
,
""
+
dialogDismiss
);
Thread
.
currentThread
().
sleep
(
1000
);
dialogDismiss
-=
1
;
handler
.
sendEmptyMessage
(
DIALOGTIMES
);
...
...
@@ -387,7 +395,7 @@ public class MainActivity extends AppCompatActivity {
NavigationBarUtil
.
clearFocusNotAle
(
dialog
.
getWindow
());
}
private
void
printNTM
(
List
<
DataBean
>
dataBeans
,
List
<
DataBean
>
timesBeans
)
{
private
void
printNTM
(
String
title
,
List
<
DataBean
>
dataBeans
,
List
<
DataBean
>
timesBeans
)
{
//打印
new
Thread
(
new
Runnable
()
{
@Override
...
...
@@ -401,39 +409,60 @@ public class MainActivity extends AppCompatActivity {
if
(
System
.
currentTimeMillis
()
>=
SystemUtils
.
dateTimeStamp
(
SystemUtils
.
formatTurnSecond
(
timesBeans
.
get
(
i
).
getStart
()))
&&
System
.
currentTimeMillis
()
<=
SystemUtils
.
dateTimeStamp
(
SystemUtils
.
formatTurnSecond
(
timesBeans
.
get
(
i
).
getEnd
())))
{
isPrint
=
true
;
dataBean
=
dataBeans
.
get
(
0
);
dataBean
.
setNum
(
timesBeans
.
get
(
i
).
getNum
());
if
(
dataBeans
!=
null
&&
dataBeans
.
size
()
>
0
)
{
dataBean
=
dataBeans
.
get
(
0
);
dataBean
.
setNum
(
timesBeans
.
get
(
i
).
getNum
());
}
else
{
dataBean
=
new
DataBean
();
dataBean
.
setNum
(
timesBeans
.
get
(
i
).
getNum
());
dataBean
.
setQueueID
(
timesBeans
.
get
(
i
).
getQueueID
());
dataBean
.
setTotal
(
timesBeans
.
get
(
i
).
getNum
());
ArrayList
<
ConfigDevsBean
.
DevsBean
>
devsBeans
=
recordHelper
.
searchNTMDevsTable
(
BaseUtils
.
NTMDevsTable
.
queueID
+
" = ? "
,
new
String
[]{
timesBeans
.
get
(
i
).
getQueueID
()});
dataBean
.
setCodeID
(
devsBeans
.
get
(
0
).
getCodeID
());
dataBean
.
setAll
(
"0"
);
dataBean
.
setLast
(
"0"
);
dataBean
.
setCurrent
(
"0"
);
}
break
;
}
}
if
(!
isPrint
)
if
(!
isPrint
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
showDialog
(
1
,
title
);
}
});
return
;
}
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
showDialog
(
0
,
title
);
}
});
if
(
dataBeans
==
null
||
dataBeans
.
size
()
<=
0
)
{
//insert
recordHelper
.
insertNTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
"1"
,
"1"
,
"1"
,
dataBean
.
getCodeID
(),
dataBean
.
getQueueID
(),
dataBean
.
getTotal
());
recordHelper
.
insertNTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
"1"
,
"1"
,
"1"
,
dataBean
.
getCodeID
(),
dataBean
.
getQueueID
(),
dataBean
.
getTotal
());
}
else
{
if
(!
dataBean
.
getTimes
().
equals
(
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
)))
{
recordHelper
.
update
NTMRecord
(
SystemUtils
.
getIpAddressString
(),
recordHelper
.
insert
NTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
"1"
,
"1"
,
"1"
,
dataBean
.
getCodeID
(),
dataBean
.
getQueueID
(),
dataBean
.
getTotal
(),
BaseUtils
.
NTMRecordTable
.
queueID
,
dataBean
.
getQueueID
());
dataBean
.
getCodeID
(),
dataBean
.
getQueueID
(),
dataBean
.
getTotal
());
}
else
{
//update
if
(
Integer
.
parseInt
(
dataBean
.
getAll
())
<=
Integer
.
parseInt
(
dataBean
.
getNum
()))
{
recordHelper
.
updateNTMRecord
(
SystemUtils
.
getIpAddressString
(),
String
current
=
""
;
if
(
dataBean
.
getCurrent
().
equals
(
"0"
))
current
=
"1"
;
else
current
=
dataBean
.
getCurrent
();
recordHelper
.
insertNTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
String
.
valueOf
(
Integer
.
parseInt
(
dataBean
.
getAll
())
+
1
),
dataBean
.
getLast
(),
dataBean
.
getCurrent
(),
dataBean
.
getCodeID
(),
dataBean
.
getQueueID
(),
dataBean
.
getNum
(),
BaseUtils
.
NTMRecordTable
.
queueID
,
dataBean
.
getQueueID
());
String
.
valueOf
(
Integer
.
parseInt
(
dataBean
.
getAll
())
+
1
),
dataBean
.
getLast
(),
current
,
dataBean
.
getCodeID
(),
dataBean
.
getQueueID
(),
dataBean
.
getNum
());
}
else
{
isPrint
=
false
;
}
...
...
@@ -441,10 +470,14 @@ public class MainActivity extends AppCompatActivity {
}
if
(
isPrint
)
{
List
<
DataBean
>
beans
=
recordHelper
.
searchNTMRecordTable
(
BaseUtils
.
NTMDevsTable
.
queueID
,
dataBean
.
getQueueID
());
DataBean
bean
=
null
;
if
(
beans
.
size
()
>
0
)
{
bean
=
beans
.
get
(
beans
.
size
()
-
1
);
}
String
xmlStr
=
"<printInvoke name=\"GENERAL_PRINT\" ><arguments>\n"
+
"<printString id=\"LINE1\" size=\"1\" bold=\"1\" pos=\"center\" >取号机</printString>\n"
+
"<printString id=\"LINE3\" size=\"3\" bold=\"1\" pos=\"center\" >"
+
beans
.
get
(
0
).
getAll
(
)
+
"</printString>\n"
+
"<printString id=\"LINE4\" size=\"2\" bold=\"0\" pos=\"center\" >排队:"
+
String
.
valueOf
(
Integer
.
parseInt
(
beans
.
get
(
0
).
getAll
())
-
Integer
.
parseInt
(
beans
.
get
(
0
)
.
getCurrent
()))
+
"</printString>\n"
+
"<printString id=\"LINE3\" size=\"3\" bold=\"1\" pos=\"center\" >"
+
(
Integer
.
parseInt
(
bean
.
getAll
())
)
+
"</printString>\n"
+
"<printString id=\"LINE4\" size=\"2\" bold=\"0\" pos=\"center\" >排队:"
+
(
Integer
.
parseInt
(
bean
.
getAll
())
-
Integer
.
parseInt
(
bean
.
getCurrent
()))
+
"</printString>\n"
+
"<printString id=\"LINE5\" size=\"1\" bold=\"0\" pos=\"center\" >"
+
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd HH:mm:ss"
)
+
"</printString>\n"
+
"<printString id=\"LINE6\" size=\"1\" bold=\"0\" pos=\"center\" >-------------------------</printString>\n"
+
"<printString id=\"QR\" size=\"1\" bold=\"0\" pos=\"center\" >这是一个二维码示例</printString> \t\t\n"
+
...
...
@@ -460,18 +493,22 @@ public class MainActivity extends AppCompatActivity {
}
retargs
=
printerF37C
.
Print_Title
(
"GENERAL_PRINT.xml"
,
arguments
,
pullService
.
custom
);
}
if
(
devType
.
equals
(
0
))
if
(
devType
.
equals
(
"0"
))
{
DataBean
finalBean
=
bean
;
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
HttpRequest
.
patData
(
gson
,
new
PATBean
(
"hos001"
,
"ST001"
,
"hos001BM2"
+
finalBean
.
getQueueID
()
+
finalBean
.
getCurrent
(),
"BM2"
+
finalBean
.
getQueueID
(),
"心电图"
,
finalBean
.
getCurrent
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd HH:mm:ss"
),
"0"
));
textStr
+=
"\n当前取号总数为"
+
dataBean
.
getAll
();
textStr
+=
"\n当前呼叫:"
+
dataBean
.
getCurrent
();
textStr
+=
"\n排队:"
+
String
.
valueOf
(
Integer
.
parseInt
(
dataBean
.
getAll
())
-
Integer
.
parseInt
(
dataBean
.
getCurrent
()));
textStr
+=
"\n当前时间:"
+
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd HH:mm:ss"
);
textStr
+=
"\n打印成功"
;
text
.
setText
(
textStr
);
Log
.
d
(
"Sss"
,
textStr
);
// text.setText(textStr);
}
});
}
}
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
...
...
app/src/main/java/com/example/numbertakingmachine/ui/SplashActivity.java
View file @
00519999
...
...
@@ -118,7 +118,7 @@ public class SplashActivity extends AppCompatActivity {
recordHelper
.
insertNTMQueue
(
"1"
,
"1"
,
"默认"
,
"0"
,
"A"
,
"0"
,
"0"
);
recordHelper
.
insertNTMTimes
(
"全天"
,
"1"
,
"100"
,
"8:00"
,
"16:00"
,
"0"
);
recordHelper
.
insertNTMDevs
(
"01"
,
"窗口一"
,
"1"
,
"0"
,
"0"
);
recordHelper
.
insertNTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
"1"
,
"1"
,
"
1
"
,
"01"
,
"1"
,
"100"
);
recordHelper
.
insertNTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
"1"
,
"1"
,
"
0
"
,
"01"
,
"1"
,
"100"
);
colorBac
=
"0"
;
devType
=
"0"
;
}
else
{
...
...
@@ -127,12 +127,12 @@ public class SplashActivity extends AppCompatActivity {
devType
=
"0"
;
}
all
=
recordHelper
.
searchNTMRecordTableAll
();
if
(
all
!=
null
&&
all
.
size
()
>
=
0
)
{
if
(
all
!=
null
&&
all
.
size
()
>
0
)
{
if
(!
all
.
get
(
0
).
get
(
BaseUtils
.
NTMRecordTable
.
ntimes
).
equals
(
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
)))
{
recordHelper
.
updateNTMRecord
(
SystemUtils
.
getIpAddressString
(),
recordHelper
.
deleteTableData
(
BaseUtils
.
NTMRecordTable
.
NAME
);
recordHelper
.
insertNTMRecord
(
SystemUtils
.
getIpAddressString
(),
SystemUtils
.
getDateToString
(
System
.
currentTimeMillis
(),
0
,
"yyyy-MM-dd"
),
"1"
,
"1"
,
"1"
,
"01"
,
"1"
,
"100"
,
all
.
get
(
0
).
get
(
BaseUtils
.
NTMRecordTable
.
id
),
""
);
"1"
,
"1"
,
"0"
,
"01"
,
"A"
,
"100"
);
}
}
}
...
...
app/src/main/java/com/example/numbertakingmachine/utils/MyApplication.java
View file @
00519999
...
...
@@ -6,6 +6,7 @@ import android.os.Messenger;
import
com.example.numbertakingmachine.http.Http
;
import
com.example.numbertakingmachine.sql.NTMRecordHelper
;
import
com.google.gson.Gson
;
import
java.io.File
;
import
java.util.List
;
...
...
@@ -30,6 +31,10 @@ public class MyApplication extends Application {
public
static
String
colorBac
=
"0"
;
public
static
String
devType
=
"0"
;
public
static
int
orientation
=
0
;
public
static
String
mac
=
""
;
public
static
String
ip
=
""
;
public
static
int
[]
screenReal
;
public
static
Gson
gson
=
new
Gson
();
@Override
public
void
onCreate
()
{
...
...
@@ -41,6 +46,9 @@ public class MyApplication extends Application {
if
(!
f
.
exists
())
{
UtilsCopyFile
.
copyAssetsFiles
(
this
,
"RWconfig"
,
storagePath
);
}
mac
=
SystemUtils
.
getMacFromHardware
();
ip
=
SystemUtils
.
getIpAddressString
();
screenReal
=
SystemUtils
.
getScreenReal
(
application
.
getApplicationContext
());
}
//初始化数据
...
...
app/src/main/java/com/example/numbertakingmachine/utils/SystemUtils.java
View file @
00519999
...
...
@@ -5,9 +5,13 @@ import android.content.BroadcastReceiver;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.graphics.Point
;
import
android.hardware.usb.UsbDevice
;
import
android.hardware.usb.UsbManager
;
import
android.os.Build
;
import
android.util.Log
;
import
android.view.Display
;
import
android.view.WindowManager
;
import
java.net.Inet4Address
;
import
java.net.InetAddress
;
...
...
@@ -161,4 +165,60 @@ public class SystemUtils {
}
}
/**
* Android 7.0之后获取Mac地址
* 遍历循环所有的网络接口,找到接口是 wlan0
* 必须的权限 <uses-permission android:name="android.permission.INTERNET"></uses-permission>
*
* @return
*/
public
static
String
getMacFromHardware
()
{
/*获取mac地址有一点需要注意的就是android 6.0版本后,以下注释方法不再适用,不管任何手机都会返回"02:00:00:00:00:00"这个默认的mac地址,这是googel官方为了加强权限管理而禁用了getSYstemService(Context.WIFI_SERVICE)方法来获得mac地址。*/
String
macAddress
=
null
;
StringBuffer
buf
=
new
StringBuffer
();
NetworkInterface
networkInterface
=
null
;
try
{
networkInterface
=
NetworkInterface
.
getByName
(
"eth0"
);
if
(
networkInterface
==
null
)
{
networkInterface
=
NetworkInterface
.
getByName
(
"wlan0"
);
}
if
(
networkInterface
==
null
)
{
return
"02:00:00:00:00:02"
;
}
byte
[]
addr
=
networkInterface
.
getHardwareAddress
();
if
(
addr
!=
null
)
for
(
byte
b
:
addr
)
{
buf
.
append
(
String
.
format
(
"%02X:"
,
b
));
}
if
(
buf
.
length
()
>
0
)
{
buf
.
deleteCharAt
(
buf
.
length
()
-
1
);
}
macAddress
=
buf
.
toString
();
}
catch
(
SocketException
|
NullPointerException
e
)
{
e
.
printStackTrace
();
return
"02:00:00:00:00:02"
;
}
return
macAddress
;
}
/**
* 获得屏幕真实宽高高度(包含底部导航栏)
*/
public
static
int
[]
getScreenReal
(
Context
context
)
{
int
[]
screen
=
new
int
[
2
];
WindowManager
windowManager
=
(
WindowManager
)
context
.
getSystemService
(
Context
.
WINDOW_SERVICE
);
final
Display
display
=
windowManager
.
getDefaultDisplay
();
Point
outPoint
=
new
Point
();
if
(
Build
.
VERSION
.
SDK_INT
>=
19
)
{
// 可能有虚拟按键的情况
display
.
getRealSize
(
outPoint
);
}
else
{
// 不可能有虚拟按键
display
.
getSize
(
outPoint
);
}
screen
[
0
]
=
outPoint
.
x
;
//手机屏幕真实宽度
screen
[
1
]
=
outPoint
.
y
;
//手机屏幕真实高度
return
screen
;
}
}
app/src/main/java/org/nanohttpd/protocols/http/HTTPSession.java
View file @
00519999
...
...
@@ -36,6 +36,7 @@ package org.nanohttpd.protocols.http;
import
android.util.Log
;
import
com.example.numbertakingmachine.utils.MyApplication
;
import
com.example.numbertakingmachine.utils.SystemUtils
;
import
java.io.BufferedInputStream
;
...
...
@@ -132,10 +133,10 @@ public class HTTPSession implements IHTTPSession {
this
.
tempFileManager
=
tempFileManager
;
this
.
inputStream
=
new
BufferedInputStream
(
inputStream
,
HTTPSession
.
BUFSIZE
);
this
.
outputStream
=
outputStream
;
// this.remoteIp = SystemUtils.getIpAddressString()
;
this
.
remoteIp
=
MyApplication
.
ip
;
// this.remoteIp = "localhost";
this
.
remoteHostname
=
"localhost"
;
this
.
remoteIp
=
inetAddress
.
isLoopbackAddress
()
||
inetAddress
.
isAnyLocalAddress
()
?
"127.0.0.1"
:
localhostIP
;
//
this.remoteIp = inetAddress.isLoopbackAddress() || inetAddress.isAnyLocalAddress() ? "127.0.0.1" : localhostIP;
Log
.
d
(
"ssss获取到的ip"
,
remoteIp
);
//this.remoteHostname = inetAddress.isLoopbackAddress() || inetAddress.isAnyLocalAddress() ? "localhost" : inetAddress.getHostName().toString();
this
.
headers
=
new
HashMap
<
String
,
String
>();
...
...
app/src/main/res/layout/dialog_print_tips.xml
View file @
00519999
...
...
@@ -46,6 +46,7 @@
android:src=
"@drawable/sueecss"
/>
<TextView
android:id=
"@+id/tips"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
...
...
app/src/main/res/layout/msg_item.xml
View file @
00519999
...
...
@@ -21,7 +21,8 @@
android:gravity=
"center"
android:text=
"请"
android:textColor=
"@color/grey_333"
android:textSize=
"50px"
android:textSize=
"45px"
android:singleLine=
"true"
android:textStyle=
"bold"
/>
<TextView
...
...
@@ -34,6 +35,7 @@
android:layout_marginRight=
"20px"
android:textColor=
"@color/blue_0183FF"
android:textSize=
"70px"
android:singleLine=
"true"
android:textStyle=
"bold"
/>
<TextView
...
...
@@ -43,7 +45,8 @@
android:gravity=
"center"
android:text=
"号患者到"
android:textColor=
"@color/grey_333"
android:textSize=
"50px"
android:textSize=
"45px"
android:singleLine=
"true"
android:textStyle=
"bold"
/>
<TextView
...
...
@@ -56,6 +59,7 @@
android:layout_marginRight=
"20px"
android:textColor=
"@color/blue_0183FF"
android:textSize=
"70px"
android:singleLine=
"true"
android:textStyle=
"bold"
/>
<TextView
...
...
@@ -63,9 +67,10 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:text=
"
号
窗口办理"
android:text=
"窗口办理"
android:textColor=
"@color/grey_333"
android:textSize=
"50px"
android:textSize=
"45px"
android:singleLine=
"true"
android:textStyle=
"bold"
/>
</LinearLayout>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment