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
8cfa25ef
Commit
8cfa25ef
authored
Dec 02, 2020
by
李德才
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持中文
parent
60798c9e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
48 deletions
+20
-48
SnController.java
...ain/java/com/archser/aserver/controller/SnController.java
+0
-1
SnService.java
src/main/java/com/archser/aserver/service/SnService.java
+0
-23
PropertyUtil.java
src/main/java/com/archser/aserver/util/PropertyUtil.java
+17
-22
SN.properties
src/main/webapp/SN.properties
+3
-2
No files found.
src/main/java/com/archser/aserver/controller/SnController.java
View file @
8cfa25ef
...
...
@@ -5,7 +5,6 @@ import com.jfinal.aop.Clear;
import
com.jfinal.aop.Inject
;
import
com.jfinal.core.Controller
;
import
com.jfinal.kit.Ret
;
import
com.jfinal.kit.StrKit
;
public
class
SnController
extends
Controller
{
...
...
src/main/java/com/archser/aserver/service/SnService.java
View file @
8cfa25ef
...
...
@@ -4,7 +4,6 @@ package com.archser.aserver.service;
import
com.archser.aserver.util.PropertyUtil
;
import
com.jfinal.kit.PathKit
;
import
com.jfinal.kit.PropKit
;
import
com.jfinal.kit.StrKit
;
import
com.jfinal.plugin.redis.Redis
;
import
java.io.File
;
...
...
@@ -37,26 +36,4 @@ public class SnService {
}
/**
* 向 Properties 写入
*
* @param cupCode
* @param snCode
*/
public
void
setProperty
(
String
cupCode
,
String
snCode
)
{
PropertyUtil
.
setProperty
(
cupCode
,
snCode
,
FILE_PATH
);
}
/**
* 将序列号信息写入Redis
*
* @param cpuCode
* @param snCode
* @return
*/
public
String
saveSnToRedis
(
String
cpuCode
,
String
snCode
)
{
return
Redis
.
use
().
set
(
cpuCode
,
snCode
);
}
}
src/main/java/com/archser/aserver/util/PropertyUtil.java
View file @
8cfa25ef
package
com
.
archser
.
aserver
.
util
;
import
com.jfinal.kit.PropKit
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.io.OutputStreamWriter
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Objects
;
import
java.util.Properties
;
...
...
@@ -20,31 +21,16 @@ import java.util.Properties;
*/
public
class
PropertyUtil
{
static
final
String
filePath
=
"D:\\workspace\\PublicSource\\aserver\\src\\main\\webapp\\SN.properties"
;
static
final
String
copyFilePath
=
"D:\\workspace\\PublicSource\\aserver\\src\\main\\webapp\\SN2.properties"
;
public
static
Properties
loadResource
(
String
propFile
)
throws
IOException
{
Properties
properties
=
new
Properties
();
InputStreamReader
reader
=
new
InputStreamReader
(
PropertyUtil
.
class
.
getResourceAsStream
(
propFile
));
InputStreamReader
reader
=
new
InputStreamReader
(
PropertyUtil
.
class
.
getResourceAsStream
(
propFile
));
properties
.
load
(
reader
);
return
properties
;
}
public
static
String
get
(
String
filePath
,
String
key
)
{
Properties
prop
=
null
;
try
{
prop
=
loadResource
(
filePath
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
String
title
=
null
;
try
{
assert
prop
!=
null
;
title
=
new
String
(
prop
.
getOrDefault
(
key
,
null
).
toString
().
getBytes
(),
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
ignored
)
{
}
return
title
;
}
/**
* 读取配置文件中的值
*
...
...
@@ -59,7 +45,7 @@ public class PropertyUtil {
input
=
new
FileInputStream
(
filePath
);
BufferedReader
bf
=
new
BufferedReader
(
new
InputStreamReader
(
input
));
props
.
load
(
bf
);
value
=
new
String
(
props
.
getProperty
(
key
).
getBytes
(
StandardCharsets
.
ISO_8859_1
),
StandardCharsets
.
UTF_8
);
value
=
props
.
getProperty
(
key
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
...
...
@@ -84,12 +70,14 @@ public class PropertyUtil {
Properties
props
=
new
Properties
();
OutputStream
out
=
null
;
InputStream
input
=
null
;
FileOutputStream
oFile
=
null
;
try
{
input
=
new
FileInputStream
(
filePath
);
oFile
=
new
FileOutputStream
(
new
File
(
filePath
),
true
);
//true表示追加打开,false每次都是清空再重写
props
.
load
(
input
);
props
.
setProperty
(
key
,
value
);
out
=
new
FileOutputStream
(
filePath
);
props
.
store
(
out
,
null
);
props
.
store
(
new
OutputStreamWriter
(
oFile
,
StandardCharsets
.
UTF_8
),
"III"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
...
...
@@ -106,4 +94,11 @@ public class PropertyUtil {
}
}
public
static
void
main
(
String
[]
args
)
{
String
key
=
"AAA"
;
String
value
=
"数字档案室3,cdcsdcdscd"
;
setProperty
(
key
,
value
,
filePath
);
// System.err.println(PropKit.use(new File(filePath)).get(key));
}
}
src/main/webapp/SN.properties
View file @
8cfa25ef
cfc84f0ff5395302517acc5ded7e7101f415cb953d535833296b292fa0f9c5ae
=
huayiwendang,04c5c8a0db17ff09e046e64099dbe532fc2c79e0f8898a4351234d96049055964448a10b4d1459e598532c33069a1b1293d2d6aeb66ca28448a622a364fdeec28e781180b7cbf8738b654860ac18dd2592d055ee3d1a1104b747c7f43070ae0e1102287bd0a6f84113a629e4eb9a4f5f7c4628c691416ab536201bccfd8f5d3fe44e7bb737760dd21edff98347200a0d258b5097fc252b3c41401f2bb26683f2aa56e220c85fb83ae653e1a26a11adf14564383578e7d202d9c83f7130b4c912e8295f8c9fa93deb20dbbe18e1fcc2cbd7e281d5acfe5b01ad61477542c335012b8753a27a52f164990743194b1314885a
\ No newline at end of file
#III
#Wed Dec 02 15:35:36 CST 2020
AAA
=
数字档案室3,cdcsdcdscd
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