Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
aserver
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
15所TongWeb
aserver
Commits
0ed72236
Commit
0ed72236
authored
Dec 01, 2020
by
李德才
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
查找并写入CPU唯一值
parent
4da62551
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
140 additions
and
0 deletions
+140
-0
SnController.java
...ain/java/com/archser/aserver/controller/SnController.java
+21
-0
SnService.java
src/main/java/com/archser/aserver/service/SnService.java
+38
-0
PropertyUtil.java
src/main/java/com/archser/aserver/util/PropertyUtil.java
+79
-0
SN.properties
src/main/webapp/SN.properties
+2
-0
No files found.
src/main/java/com/archser/aserver/controller/SnController.java
View file @
0ed72236
package
com
.
archser
.
aserver
.
controller
;
package
com
.
archser
.
aserver
.
controller
;
import
com.archser.aserver.service.SnService
;
import
com.archser.aserver.service.SnService
;
import
com.jfinal.aop.Clear
;
import
com.jfinal.aop.Inject
;
import
com.jfinal.aop.Inject
;
import
com.jfinal.core.Controller
;
import
com.jfinal.core.Controller
;
import
com.jfinal.kit.Ret
;
import
com.jfinal.kit.StrKit
;
public
class
SnController
extends
Controller
{
public
class
SnController
extends
Controller
{
...
@@ -11,5 +14,23 @@ public class SnController extends Controller {
...
@@ -11,5 +14,23 @@ public class SnController extends Controller {
SnService
snService
;
SnService
snService
;
/**
* 获取序列号
*/
@Clear
public
void
getPropertiesValue
()
{
String
cupCode
=
getPara
(
"cupCode"
);
try
{
String
snCode
=
snService
.
getPropertiesValue
(
cupCode
);
if
(
StrKit
.
isBlank
(
snCode
))
{
snService
.
setProperty
(
cupCode
,
""
);
}
renderJson
(
Ret
.
ok
(
"snCode"
,
snCode
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
renderJson
(
Ret
.
fail
());
}
}
}
}
src/main/java/com/archser/aserver/service/SnService.java
View file @
0ed72236
package
com
.
archser
.
aserver
.
service
;
package
com
.
archser
.
aserver
.
service
;
import
com.archser.aserver.util.PropertyUtil
;
import
com.jfinal.kit.PathKit
;
import
com.jfinal.kit.PropKit
;
import
java.io.File
;
/**
* 读写 SN配置文件 20201201 lidecai
*/
public
class
SnService
{
public
class
SnService
{
private
static
String
FILE_PATH
;
static
{
FILE_PATH
=
PathKit
.
getWebRootPath
()
+
File
.
separator
+
"SN.properties"
;
}
/**
* 从 Properties 文件中获取指定对应的值
*
* @param cupCode
* @return
*/
public
String
getPropertiesValue
(
String
cupCode
)
{
return
PropKit
.
use
(
new
File
(
FILE_PATH
)).
get
(
cupCode
);
}
/**
* 向 Properties 写入
*
* @param cupCode
* @param snCode
*/
public
void
setProperty
(
String
cupCode
,
String
snCode
)
{
PropertyUtil
.
setProperty
(
cupCode
,
snCode
,
FILE_PATH
);
}
}
}
src/main/java/com/archser/aserver/util/PropertyUtil.java
0 → 100644
View file @
0ed72236
package
com
.
archser
.
aserver
.
util
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Objects
;
import
java.util.Properties
;
/**
* 20201201 lidecai 读写 Property 文件工具类
*/
public
class
PropertyUtil
{
/**
* 读取配置文件中的值
*
* @param key
* @return
*/
public
static
String
getProperty
(
String
key
,
String
filePath
)
{
String
value
=
""
;
Properties
props
=
new
Properties
();
InputStream
input
=
null
;
try
{
input
=
new
FileInputStream
(
filePath
);
props
.
load
(
input
);
value
=
props
.
getProperty
(
key
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
Objects
.
requireNonNull
(
input
).
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
value
;
}
/**
* 向配置文件中写值
* @param key
* @param value
* @param filePath
*/
public
static
void
setProperty
(
String
key
,
String
value
,
String
filePath
)
{
Properties
props
=
new
Properties
();
OutputStream
out
=
null
;
InputStream
input
=
null
;
try
{
input
=
new
FileInputStream
(
filePath
);
props
.
load
(
input
);
props
.
setProperty
(
key
,
value
);
out
=
new
FileOutputStream
(
filePath
);
props
.
store
(
out
,
null
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
Objects
.
requireNonNull
(
input
).
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
try
{
Objects
.
requireNonNull
(
out
).
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
src/main/webapp/SN.properties
0 → 100644
View file @
0ed72236
#Tue Dec 01 16:02:59 CST 2020
AAAAAAAAAAAAAAA
=
cdcdcdcdcdc
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