Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
erp-service
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
ximai
erp-service
Commits
6760822f
Commit
6760822f
authored
Dec 06, 2024
by
李驰骋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
工艺文档添加
打印接口调整 登录接口调用MES
parent
593d2ee7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
2170 additions
and
103 deletions
+2170
-103
pom.xml
pom.xml
+17
-0
Application.java
.../java/com/topsunit/scanservice/ximai/app/Application.java
+4
-0
AppConfig.java
...java/com/topsunit/scanservice/ximai/common/AppConfig.java
+15
-12
Constants.java
...java/com/topsunit/scanservice/ximai/common/Constants.java
+251
-0
DateUtil.java
.../java/com/topsunit/scanservice/ximai/common/DateUtil.java
+15
-0
FileSystem.java
...ava/com/topsunit/scanservice/ximai/common/FileSystem.java
+216
-0
FileSystemException.java
...opsunit/scanservice/ximai/common/FileSystemException.java
+35
-0
FileView.java
.../java/com/topsunit/scanservice/ximai/common/FileView.java
+183
-0
IOUtils.java
...n/java/com/topsunit/scanservice/ximai/common/IOUtils.java
+256
-0
MatchFile.java
...java/com/topsunit/scanservice/ximai/common/MatchFile.java
+16
-0
Path.java
...main/java/com/topsunit/scanservice/ximai/common/Path.java
+399
-0
PrintConfig.java
...va/com/topsunit/scanservice/ximai/common/PrintConfig.java
+27
-0
PrintConfigUrl.java
...com/topsunit/scanservice/ximai/common/PrintConfigUrl.java
+33
-0
SmbFileSystem.java
.../com/topsunit/scanservice/ximai/common/SmbFileSystem.java
+202
-0
CmsmvController.java
...opsunit/scanservice/ximai/controller/CmsmvController.java
+3
-1
MoctaController.java
...opsunit/scanservice/ximai/controller/MoctaController.java
+31
-1
MoctaDocCriteria.java
.../com/topsunit/scanservice/ximai/dto/MoctaDocCriteria.java
+19
-0
MoctaDocDto.java
.../java/com/topsunit/scanservice/ximai/dto/MoctaDocDto.java
+9
-30
PurccDto.java
...ain/java/com/topsunit/scanservice/ximai/dto/PurccDto.java
+2
-0
PurccPrintParams.java
.../com/topsunit/scanservice/ximai/dto/PurccPrintParams.java
+4
-0
Purcc.java
...ain/java/com/topsunit/scanservice/ximai/entity/Purcc.java
+20
-0
Purcd.java
...ain/java/com/topsunit/scanservice/ximai/entity/Purcd.java
+20
-0
TokenService.java
...com/topsunit/scanservice/ximai/security/TokenService.java
+136
-0
CmsmvService.java
.../com/topsunit/scanservice/ximai/service/CmsmvService.java
+18
-0
MocthService.java
.../com/topsunit/scanservice/ximai/service/MocthService.java
+12
-11
PurccService.java
.../com/topsunit/scanservice/ximai/service/PurccService.java
+42
-18
MesLoginService.java
...om/topsunit/scanservice/ximai/webapi/MesLoginService.java
+19
-0
PrintApi.java
.../java/com/topsunit/scanservice/ximai/webapi/PrintApi.java
+6
-3
LoginParams.java
...om/topsunit/scanservice/ximai/webapi/dto/LoginParams.java
+9
-0
LoginResult.java
...om/topsunit/scanservice/ximai/webapi/dto/LoginResult.java
+10
-0
PrintField.java
...com/topsunit/scanservice/ximai/webapi/dto/PrintField.java
+40
-0
PrintParam.java
...com/topsunit/scanservice/ximai/webapi/dto/PrintParam.java
+4
-25
application-demo.yml
src/main/resources/application-demo.yml
+24
-1
application-dev.yml
src/main/resources/application-dev.yml
+4
-1
application-test-co.yml
src/main/resources/application-test-co.yml
+23
-0
application-thximai.yml
src/main/resources/application-thximai.yml
+23
-0
application-ximai.yml
src/main/resources/application-ximai.yml
+23
-0
No files found.
pom.xml
View file @
6760822f
...
...
@@ -24,6 +24,8 @@
<lombok>
1.18.8
</lombok>
<knife4j>
3.0.3
</knife4j>
<hutool>
5.8.0.M3
</hutool>
<openfeign.version>
3.0.8
</openfeign.version>
<jwt.version>
0.9.1
</jwt.version>
</properties>
<dependencyManagement>
...
...
@@ -168,6 +170,21 @@
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
</dependency>
<dependency>
<groupId>
org.samba.jcifs
</groupId>
<artifactId>
jcifs
</artifactId>
<version>
1.3.3
</version>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
<version>
${openfeign.version}
</version>
</dependency>
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
<artifactId>
jjwt
</artifactId>
<version>
${jwt.version}
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/topsunit/scanservice/ximai/app/Application.java
View file @
6760822f
...
...
@@ -6,8 +6,10 @@ import com.topsunit.scanservice.ximai.common.Version;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.domain.EntityScan
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.data.jpa.repository.config.EnableJpaRepositories
;
import
springfox.documentation.oas.annotations.EnableOpenApi
;
/**
* <p>Title: Application</p>
...
...
@@ -21,7 +23,9 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@ComponentScan
(
basePackages
=
{
"com.topsunit"
})
@EntityScan
(
"com.topsunit"
)
@EnableJpaRepositories
(
"com.topsunit"
)
@EnableFeignClients
(
basePackages
=
{
"com.topsunit"
})
@EnableKnife4j
@EnableOpenApi
public
class
Application
{
public
static
void
main
(
String
[]
args
)
{
Version
.
INSTANCE
.
setVersion
(
"4.0.0.1"
);
...
...
src/main/java/com/topsunit/scanservice/ximai/common/AppConfig.java
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
common
;
import
lombok.Data
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -11,10 +12,13 @@ import org.springframework.context.annotation.Configuration;
* @version V1.0
* @date 2021/10/26
*/
@Data
@Configuration
public
class
AppConfig
{
@Value
(
"${topsunit.token-expires-hour}"
)
private
Long
tokenExpiresHour
;
@Value
(
"${topsunit.token-secret}"
)
private
String
tokenSecret
;
public
Long
getTokenExpires
()
{
if
(
tokenExpiresHour
==
null
)
{
...
...
@@ -39,19 +43,18 @@ public class AppConfig {
@Value
(
"${topsunit.print-api-url}"
)
private
String
printApiUrl
;
public
String
getPrintApiUrl
(){
return
printApiUrl
;
}
@Value
(
"${topsunit.default-password}"
)
private
String
defaultPassword
;
public
String
getDefaultPassword
(){
return
defaultPassword
;
}
public
String
getDbName
()
{
return
dbName
;
}
/**
* 共享文件地址
*/
@Value
(
"${topsunit.share-url}"
)
private
String
shareUrl
;
/**
* MES接口地址
*/
@Value
(
"${topsunit.mes-url}"
)
private
String
mesUrl
;
}
src/main/java/com/topsunit/scanservice/ximai/common/Constants.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
common
;
import
io.jsonwebtoken.Claims
;
/**
* 通用常量信息
*/
public
class
Constants
{
/**
* UTF-8 字符集
*/
public
static
final
String
UTF8
=
"UTF-8"
;
/**
* GBK 字符集
*/
public
static
final
String
GBK
=
"GBK"
;
/**
* http请求
*/
public
static
final
String
HTTP
=
"http://"
;
/**
* https请求
*/
public
static
final
String
HTTPS
=
"https://"
;
/**
* 通用成功标识
*/
public
static
final
String
SUCCESS
=
"0"
;
/**
* 通用失败标识
*/
public
static
final
String
FAIL
=
"1"
;
/**
* 登录成功
*/
public
static
final
String
LOGIN_SUCCESS
=
"Success"
;
/**
* 注销
*/
public
static
final
String
LOGOUT
=
"Logout"
;
/**
* 注册
*/
public
static
final
String
REGISTER
=
"Register"
;
/**
* 登录失败
*/
public
static
final
String
LOGIN_FAIL
=
"Error"
;
/**
* 验证码 redis key
*/
public
static
final
String
CAPTCHA_CODE_KEY
=
"captcha_codes:"
;
/**
* 登录用户 redis key
*/
public
static
final
String
LOGIN_TOKEN_KEY
=
"login_tokens:"
;
/**
* 防重提交 redis key
*/
public
static
final
String
REPEAT_SUBMIT_KEY
=
"repeat_submit:"
;
/**
* 限流 redis key
*/
public
static
final
String
RATE_LIMIT_KEY
=
"rate_limit:"
;
/**
* 验证码有效期(分钟)
*/
public
static
final
Integer
CAPTCHA_EXPIRATION
=
2
;
/**
* 令牌
*/
public
static
final
String
TOKEN
=
"token"
;
/**
* 令牌前缀
*/
public
static
final
String
TOKEN_PREFIX
=
"Bearer "
;
/**
* 令牌前缀
*/
public
static
final
String
LOGIN_USER_KEY
=
"login_user_key"
;
/**
* 用户ID
*/
public
static
final
String
JWT_USERID
=
"userid"
;
/**
* 用户名称
*/
public
static
final
String
JWT_USERNAME
=
Claims
.
SUBJECT
;
/**
* 用户头像
*/
public
static
final
String
JWT_AVATAR
=
"avatar"
;
/**
* 创建时间
*/
public
static
final
String
JWT_CREATED
=
"created"
;
/**
* 用户权限
*/
public
static
final
String
JWT_AUTHORITIES
=
"authorities"
;
/**
* 参数管理 cache key
*/
public
static
final
String
SYS_CONFIG_KEY
=
"sys_config:"
;
/**
* 字典管理 cache key
*/
public
static
final
String
SYS_DICT_KEY
=
"sys_dict:"
;
/**
* 资源映射路径 前缀
*/
public
static
final
String
RESOURCE_PREFIX
=
"/profile"
;
/**
* RMI 远程方法调用
*/
public
static
final
String
LOOKUP_RMI
=
"rmi:"
;
/**
* LDAP 远程方法调用
*/
public
static
final
String
LOOKUP_LDAP
=
"ldap:"
;
/**
* LDAPS 远程方法调用
*/
public
static
final
String
LOOKUP_LDAPS
=
"ldaps:"
;
/**
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
*/
public
static
final
String
[]
JOB_WHITELIST_STR
=
{
"com.ruoyi"
};
/**
* 定时任务违规的字符
*/
public
static
final
String
[]
JOB_ERROR_STR
=
{
"java.net.URL"
,
"javax.naming.InitialContext"
,
"org.yaml.snakeyaml"
,
"org.springframework"
,
"org.apache"
,
"com.ruoyi.common.utils.file"
};
public
static
final
String
METHOD_INSERT_TYPE
=
"insert"
;
public
static
final
String
METHOD_UPDATE_TYPE
=
"update"
;
public
static
final
String
METHOD_DELETE_TYPE
=
"delete"
;
public
static
class
DateConstant
{
public
static
String
YYYY
=
"yyyy"
;
public
static
String
YYYY_MM
=
"yyyy-MM"
;
public
static
String
YYYY_MM_DD
=
"yyyy-MM-dd"
;
public
static
String
YYYYMMDDHHMMSS
=
"yyyyMMddHHmmss"
;
public
static
String
YYYY_MM_DD_HH_MM_SS
=
"yyyy-MM-dd HH:mm:ss"
;
/**
* 星期日;
*/
public
static
final
String
SUNDAY
=
"星期日"
;
/**
* 星期一;
*/
public
static
final
String
MONDAY
=
"星期一"
;
/**
* 星期二;
*/
public
static
final
String
TUESDAY
=
"星期二"
;
/**
* 星期三;
*/
public
static
final
String
WEDNESDAY
=
"星期三"
;
/**
* 星期四;
*/
public
static
final
String
THURSDAY
=
"星期四"
;
/**
* 星期五;
*/
public
static
final
String
FRIDAY
=
"星期五"
;
/**
* 星期六;
*/
public
static
final
String
SATURDAY
=
"星期六"
;
/**
* 显示年月日时分秒,例如 2015-08-11 09:51:53.
*/
public
static
final
String
DATETIME_PATTERN
=
"yyyy-MM-dd HH:mm:ss"
;
/**
* 显示年月日时分,例如 2015-08-11 09:51.
*/
public
static
final
String
NO_SECOND_DATETIME_PATTERN
=
"yyyy-MM-dd HH:mm"
;
/**
* 仅显示年月日,例如 2015-08-11.
*/
public
static
final
String
DATE_PATTERN
=
"yyyy-MM-dd"
;
/**
* 仅显示时分秒,例如 09:51:53.
*/
public
static
final
String
TIME_PATTERN
=
"HH:mm:ss"
;
/**
* 显示年月日时分秒(由/分割),例如 2015/08/11 09:51:53.
*/
public
static
final
String
DATETIME_PATTERN_WITH_SLASH
=
"yyyy/MM/dd HH:mm:ss"
;
/**
* 显示年月日(由/分割),例如 2015/08/11.
*/
public
static
final
String
DATE_PATTERN_WITH_SLASH
=
"yyyy/MM/dd"
;
/**
* 仅显示年(无符号),例如 2015.
*/
public
static
final
String
YEAR_PATTERN
=
"yyyy"
;
/**
* 仅显示年月,例如 2015-08.
*/
public
static
final
String
MONTH_PATTERN
=
"yyyy-MM"
;
}
}
src/main/java/com/topsunit/scanservice/ximai/common/DateUtil.java
View file @
6760822f
...
...
@@ -14,16 +14,31 @@ import java.time.format.DateTimeFormatter;
*/
public
class
DateUtil
{
public
static
final
DateTimeFormatter
defaultDateFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
);
public
static
final
DateTimeFormatter
standardDateFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
public
static
final
DateTimeFormatter
defaultDateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmssSSS"
);
public
static
final
DateTimeFormatter
shortDateFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyMMdd"
);
public
static
String
localDateToString
(
LocalDate
date
){
return
date
.
format
(
defaultDateFormatter
);
}
public
static
LocalDate
stringToLocalDate
(
String
s
){
return
LocalDate
.
parse
(
s
,
defaultDateFormatter
);
}
public
static
String
localDateToStandardString
(
LocalDate
date
){
return
date
.
format
(
standardDateFormatter
);
}
public
static
String
currentDateString
(){
return
LocalDate
.
now
().
format
(
defaultDateFormatter
);
}
public
static
String
currentShortDateString
(){
return
LocalDate
.
now
().
format
(
shortDateFormatter
);
}
public
static
String
localDateTimeToString
(
LocalDateTime
dateTime
){
return
dateTime
.
format
(
defaultDateTimeFormatter
);
}
...
...
src/main/java/com/topsunit/scanservice/ximai/common/FileSystem.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
common
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
/**
* 文件系统
* <p/>
* 该接口定义一个与具体实现无关的文件系统接口
*
* @author vacoor
*/
public
abstract
class
FileSystem
{
/**
* 给定路径是否存在
*
* @param path 文件系统路径
* @throws FileSystemException
*/
public
abstract
boolean
exists
(
String
path
)
throws
FileSystemException
;
/**
* 获取路径的文件状态
*
* @param path 文件系统路径
* @return 返回文件状态, 如果文件不存在返回 null
* @throws FileSystemException
*/
public
abstract
FileView
stat
(
String
path
)
throws
FileSystemException
;
/**
* 获取路径的文件状态
*
* @param path 文件或目录路径
* @return 文件或目录的状态, 如果目录下没有文件或文件不存在返回空数组
* @throws FileSystemException
*/
public
abstract
FileView
[]
ls
(
String
path
)
throws
FileSystemException
;
/**
* 创建给定路径的目录, 如果目录已经创建成功或已经存在返回 true, 创建失败返回 false
* 如果已经存在但不是一个目录则抛出异常
*
* @param path 目录路径
* @throws FileSystemException
*/
public
abstract
boolean
mkdirs
(
String
path
)
throws
FileSystemException
;
/**
* 打开给定路径的文件, 如果给定路径不存在返回null, 如果不是文件将抛出异常
* <p/>
* 注: 关闭输入流时才会关闭相关资源, 因此读取完毕后务必关闭输入流
*
* @param file 文件路径
* @return 文件输入流或null
* @throws FileSystemException
*/
public
abstract
InputStream
open
(
String
file
)
throws
FileSystemException
;
/**
* 获取一个创建文件的输出流并自动创建相关目录, 当 override = false, 如果文件已经存在则抛出异常
*
* @param file 要创建的文件路径
* @param override 如果文件已经存在是否覆盖
* @return 新建文件的输出流
* @throws FileSystemException
*/
public
abstract
OutputStream
create
(
String
file
,
boolean
override
)
throws
FileSystemException
;
/**
* 获取一个创建文件的输出流并自动创建相关目录, 当 override = false, 如果文件已经存在则抛出异常
*
* @param file 要创建的文件路径
* @param contentType MIME 类型, 某些文件系统会记录该值, 例如 OSS 在返回时使用
* @param override 如果文件已经存在是否覆盖
* @return 新建文件的输出流
* @throws FileSystemException
*/
public
abstract
OutputStream
create
(
String
file
,
String
contentType
,
boolean
override
)
throws
FileSystemException
;
/**
* 删除给定路径
*
* @param path 文件或目录路径
* @param force 如果文件夹中存在文件是否强制删除
* @param recursive 如果文件夹中存在目录是否递归删除
* @throws FileSystemException
*/
public
abstract
void
rm
(
String
path
,
boolean
force
,
boolean
recursive
)
throws
FileSystemException
;
/**
* 重命名路径
*
* @param oldPath 源路径
* @param newPath 目标路径
* @throws FileSystemException
*/
public
abstract
void
rename
(
String
oldPath
,
String
newPath
)
throws
FileSystemException
;
/**
* 关闭连接通道
* @throws FileSystemException
*/
public
abstract
void
disconnect
()
throws
FileSystemException
;
/**
* 搜索指定名称文件
* @param path 路径
* @param name 支持正则
* @param recursive 是否搜索所有层级目录,false:只在当前目录查找
*/
public
List
<
FileView
>
searchFiles
(
String
path
,
String
name
,
boolean
recursive
)
{
List
<
FileView
>
rst
=
new
ArrayList
<
FileView
>();
FileView
[]
fileViews
=
this
.
ls
(
path
);
for
(
FileView
fileView
:
fileViews
){
if
(
fileView
.
isDirectory
()){
if
(
recursive
)
rst
.
addAll
(
this
.
searchFiles
(
fileView
.
getPath
(),
name
,
recursive
));
}
else
if
(
fileView
.
getName
().
matches
(
name
)){
rst
.
add
(
fileView
);
}
}
return
rst
;
}
/**
* 搜索指定名称文件
* @param path 路径
* @param matchFile 文件区配接口
* @param recursive 是否搜索所有层级目录,false:只在当前目录查找
*/
public
List
<
FileView
>
searchFiles
(
String
path
,
MatchFile
matchFile
,
boolean
recursive
)
{
List
<
FileView
>
rst
=
new
ArrayList
<
FileView
>();
FileView
[]
fileViews
=
this
.
ls
(
path
);
for
(
FileView
fileView
:
fileViews
){
if
(
fileView
.
isDirectory
()){
if
(
recursive
)
rst
.
addAll
(
this
.
searchFiles
(
fileView
.
getPath
(),
matchFile
,
recursive
));
}
else
if
(
matchFile
.
isMatch
(
fileView
.
getName
(),
fileView
.
getPath
())){
rst
.
add
(
fileView
);
}
}
return
rst
;
}
public
void
zip
(
String
archive
,
String
...
files
)
throws
IOException
{
File
archivePath
=
new
File
(
archive
);
File
parent
=
archivePath
.
getParentFile
();
if
(!
parent
.
exists
()
&&
!
parent
.
mkdirs
())
{
throw
new
IOException
(
"cannot mkdirs: "
+
parent
);
}
zip
(
new
FileOutputStream
(
archivePath
),
files
);
}
public
void
zip
(
OutputStream
out
,
String
...
files
)
throws
IOException
{
Path
[]
paths
=
new
Path
[
files
.
length
];
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
paths
[
i
]
=
Path
.
get
(
files
[
i
]);
}
compressTo
(
out
,
paths
);
}
public
void
compressTo
(
OutputStream
out
,
Path
[]
files
)
throws
IOException
{
// ZipOutputStream zipOut = new ZipOutputStream(out, Charsets.UTF_8);
ZipOutputStream
zipOut
=
new
ZipOutputStream
(
out
);
try
{
for
(
Path
f
:
files
)
{
doCompressEntry
(
zipOut
,
f
,
f
.
getParent
());
}
}
finally
{
zipOut
.
flush
();
zipOut
.
close
();
}
}
private
void
doCompressEntry
(
ZipOutputStream
zipOut
,
Path
file
,
Path
baseDir
)
throws
IOException
{
FileView
view
=
this
.
stat
(
file
.
getPath
());
if
(
null
==
view
)
{
// not exists
return
;
}
String
relativePath
=
file
.
relativize
(
baseDir
).
getPath
();
// 如果要添加一个目录,注意使用符号"/"作为添加项名字结尾符
relativePath
=
view
.
isDirectory
()
&&
!
relativePath
.
endsWith
(
"/"
)
?
relativePath
+
"/"
:
relativePath
;
relativePath
=
relativePath
.
startsWith
(
"/"
)
||
relativePath
.
startsWith
(
"\\"
)
?
relativePath
.
substring
(
1
)
:
relativePath
;
// 添加一个 entry
zipOut
.
putNextEntry
(
new
ZipEntry
(
relativePath
));
if
(!
view
.
isDirectory
())
{
// 如果是文件, 写入文件内容
InputStream
in
=
this
.
open
(
file
.
getPath
());
if
(
null
!=
in
)
{
IOUtils
.
flow
(
in
,
zipOut
,
true
,
false
);
}
}
zipOut
.
closeEntry
();
// 如果是真实目录(非符号链接)遍历其下所有文件
if
(
view
.
isDirectory
()
&&
!
view
.
isSymlink
())
{
FileView
[]
views
=
this
.
ls
(
file
.
getPath
());
for
(
FileView
f
:
views
)
{
String
path
=
f
.
getPath
();
path
=
!
path
.
startsWith
(
"/"
)
?
"/"
+
path
:
path
;
doCompressEntry
(
zipOut
,
Path
.
get
(
path
),
baseDir
);
}
}
}
}
src/main/java/com/topsunit/scanservice/ximai/common/FileSystemException.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
common
;
/**
* 文件系统异常
*
* @author vacoor
*/
public
class
FileSystemException
extends
RuntimeException
{
public
FileSystemException
()
{
}
public
FileSystemException
(
String
message
)
{
super
(
message
);
}
public
FileSystemException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
public
FileSystemException
(
Throwable
cause
)
{
super
(
cause
);
}
public
static
<
R
>
R
rethrowFileSystemException
(
Throwable
exception
)
{
if
(
exception
instanceof
Error
)
{
throw
(
Error
)
exception
;
}
exception
.
printStackTrace
();
if
(
exception
instanceof
FileSystemException
)
{
throw
(
FileSystemException
)
exception
;
}
throw
new
FileSystemException
(
exception
);
}
}
src/main/java/com/topsunit/scanservice/ximai/common/FileView.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
common
;
import
java.util.Date
;
/**
* 文件视图
* <p/>
* 文件视图定义了文件的基本信息, 包含路径, 大小, 类型, 修改时间, 权限, 拥有者, 所属组等信息
*
* @author vacoor
* @see <a href="https://www.ibm.com/developerworks/community/blogs/IBMzOS/entry/20140704?lang=en">USS</a>
*/
public
class
FileView
{
public
static
final
int
SUID
=
04000
;
// set user ID on execution
public
static
final
int
SGID
=
02000
;
// set group ID on execution
public
static
final
int
STICKY
=
01000
;
// sticky bit ****** NOT DOCUMENTED *****
public
static
final
int
OWNER_READ
=
00400
;
// read by owner
public
static
final
int
OWNER_WRITE
=
00200
;
// write by owner
public
static
final
int
OWNER_EXECUTE
=
00100
;
// execute/search by owner
public
static
final
int
GROUP_READ
=
00040
;
// read by group
public
static
final
int
GROUP_WRITE
=
00020
;
// write by group
public
static
final
int
GROUP_EXECUTE
=
00010
;
// execute/search by group
public
static
final
int
OTHER_READ
=
00004
;
// read by others
public
static
final
int
OTHER_WRITE
=
00002
;
// write by others
public
static
final
int
OTHER_EXECUTE
=
00001
;
// execute/search by others
private
String
name
;
private
String
path
;
private
long
length
;
private
boolean
isDirectory
;
private
long
lastModifiedTime
;
// 修改时间, 距离 1970.01.01 00:00:00 毫秒
private
long
lastAccessTime
;
// 访问时间
private
int
permissions
;
// set UID + set GID + Sticky + File Permissions
private
String
owner
;
// 文件所有者
private
String
group
;
// 文件所有组
private
String
symlink
;
// 链接真实路径
/**
* 构建一个文件视图
*
* @param path 文件路径
* @param length 文件大小
* @param isDirectory 是否是目录
* @param lastModifiedTime 最后修改时间
* @param lastAccessTime 最后访问时间
* @param permissions 权限掩码
* @param owner 拥有者
* @param group 所属组
* @param symlink 符号链接对应的真实路径
*/
public
FileView
(
String
path
,
long
length
,
boolean
isDirectory
,
long
lastModifiedTime
,
long
lastAccessTime
,
int
permissions
,
String
owner
,
String
group
,
String
symlink
)
{
this
.
path
=
path
;
this
.
length
=
length
;
this
.
isDirectory
=
isDirectory
;
this
.
lastModifiedTime
=
lastModifiedTime
;
this
.
lastAccessTime
=
lastAccessTime
;
this
.
permissions
=
permissions
;
this
.
owner
=
owner
;
this
.
group
=
group
;
this
.
symlink
=
symlink
;
}
/**
* 当前视图是否是目录
*
* @return 如果当前视图是目录则返回true, 否则返回false
*/
public
boolean
isDirectory
()
{
return
isDirectory
;
}
/**
* 获取当前视图对应的文件路径
*/
public
String
getPath
()
{
return
path
;
}
/**
* 获取当前文件的大小
*/
public
long
getLength
()
{
return
length
;
}
/**
* 获取当前文件的最后修改时间
*/
public
long
getLastModifiedTime
()
{
return
lastModifiedTime
;
}
/**
* 获取当前文件的最后昂文时间
*/
public
long
getLastAccessTime
()
{
return
lastAccessTime
;
}
/**
* 获取当前文件的权限掩码
*/
public
int
getPermissions
()
{
return
permissions
;
}
/**
* 获取当前文件的拥有者
*/
public
String
getOwner
()
{
return
owner
;
}
/**
* 获取当前文件的所属组
*/
public
String
getGroup
()
{
return
group
;
}
/**
* 获取当前文件的符号链接
*/
public
String
getSymlink
()
{
return
symlink
;
}
/**
* 当前文件视图是否是一个符号链接
*
* @return 如果是符号链接返回 true, 否则返回 false
*/
public
boolean
isSymlink
()
{
return
null
!=
getSymlink
();
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
/**
* 获取权限掩码字符串形式, eg: drwxrw---
*/
public
String
getPermissionsString
()
{
StringBuffer
buf
=
new
StringBuffer
(
10
);
int
m
=
permissions
;
buf
.
append
(
isDirectory
()
?
'd'
:
(
isSymlink
()
?
'l'
:
'-'
));
buf
.
append
((
m
&
OWNER_READ
)
!=
0
?
'r'
:
'-'
);
buf
.
append
((
m
&
OWNER_WRITE
)
!=
0
?
'w'
:
'-'
);
buf
.
append
((
m
&
SUID
)
!=
0
?
's'
:
((
m
&
OWNER_EXECUTE
)
!=
0
?
'x'
:
'-'
));
buf
.
append
((
m
&
GROUP_READ
)
!=
0
?
'r'
:
'-'
);
buf
.
append
((
m
&
GROUP_WRITE
)
!=
0
?
'w'
:
'-'
);
buf
.
append
((
m
&
SGID
)
!=
0
?
's'
:
((
m
&
GROUP_EXECUTE
)
!=
0
?
'x'
:
'-'
));
buf
.
append
((
m
&
OTHER_READ
)
!=
0
?
'r'
:
'-'
);
buf
.
append
((
m
&
OTHER_WRITE
)
!=
0
?
'w'
:
'-'
);
buf
.
append
((
m
&
OTHER_EXECUTE
)
!=
0
?
'x'
:
'-'
);
return
buf
.
toString
();
}
/**
* 获取最后修改时间的字符串形式, 注: 字符串形式取决于操作系统
*/
public
String
getAtimeString
()
{
return
new
Date
(
lastAccessTime
).
toString
();
}
/**
* 获取最后修改时间的字符串形式, 注: 字符串形式取决于操作系统
*/
public
String
getMtimeString
()
{
return
new
Date
(
lastModifiedTime
).
toString
();
}
public
String
toString
()
{
return
(
getPermissionsString
()
+
" "
+
getOwner
()
+
" "
+
getGroup
()
+
" "
+
getLength
()
+
" "
+
getMtimeString
()
+
" "
+
path
+
(
isSymlink
()
?
" -> "
+
getSymlink
()
:
""
));
}
}
src/main/java/com/topsunit/scanservice/ximai/common/IOUtils.java
0 → 100644
View file @
6760822f
/*
* Copyright (c) 2005, 2014 vacoor
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
package
com
.
topsunit
.
scanservice
.
ximai
.
common
;
import
java.io.*
;
import
java.nio.ByteBuffer
;
import
java.nio.channels.ReadableByteChannel
;
import
java.nio.channels.WritableByteChannel
;
import
java.nio.charset.Charset
;
/**
* IO 操作工具类
*
* @author vacoor
*/
public
abstract
class
IOUtils
{
protected
static
final
int
DEFAULT_BYTE_BUFFER_SIZE
=
8192
;
protected
static
final
int
DEFUALT_CHAR_BUFFER_SIZE
=
100
;
/**
* {@link #flow(InputStream, OutputStream, byte[], boolean, boolean)}
*/
public
static
void
flow
(
InputStream
is
,
OutputStream
os
,
boolean
closeIn
,
boolean
closeOut
)
throws
IOException
{
byte
[]
buffer
=
new
byte
[
DEFAULT_BYTE_BUFFER_SIZE
];
flow
(
is
,
os
,
buffer
,
closeIn
,
closeOut
);
}
/**
* 该方法不关闭流
*
* @param is 输入流
* @param os 输出流
* @param buffer
* @throws IOException
*/
public
static
void
flow
(
InputStream
is
,
OutputStream
os
,
byte
[]
buffer
,
boolean
closeIn
,
boolean
closeOut
)
throws
IOException
{
try
{
int
readed
;
while
(-
1
<
(
readed
=
is
.
read
(
buffer
)))
{
os
.
write
(
buffer
,
0
,
readed
);
}
os
.
flush
();
}
finally
{
if
(
closeIn
)
{
close
(
is
);
}
if
(
closeOut
)
{
close
(
os
);
}
}
}
/**
* {@link #flow(Reader, Writer, char[], boolean, boolean)}
*/
public
static
void
flow
(
Reader
reader
,
Writer
writer
,
boolean
closeIn
,
boolean
closeOut
)
throws
IOException
{
char
[]
buffer
=
new
char
[
DEFUALT_CHAR_BUFFER_SIZE
];
flow
(
reader
,
writer
,
buffer
,
closeIn
,
closeOut
);
}
/**
* 该方法不关闭流
*
* @param reader
* @param writer
* @param buffer
* @throws IOException
*/
public
static
void
flow
(
Reader
reader
,
Writer
writer
,
char
[]
buffer
,
boolean
closeIn
,
boolean
closeOut
)
throws
IOException
{
try
{
int
readed
;
while
(-
1
<
(
readed
=
reader
.
read
(
buffer
)))
{
writer
.
write
(
buffer
,
0
,
readed
);
}
writer
.
flush
();
}
finally
{
if
(
closeIn
)
{
close
(
reader
);
}
if
(
closeOut
)
{
close
(
writer
);
}
}
}
/**
* {@link #flow(ReadableByteChannel, WritableByteChannel, ByteBuffer, boolean, boolean)}
*/
public
static
void
flow
(
ReadableByteChannel
rbc
,
WritableByteChannel
wbc
,
boolean
closeIn
,
boolean
closeOut
)
throws
IOException
{
flow
(
rbc
,
wbc
,
null
,
closeIn
,
closeOut
);
}
/**
* {@link FileInputStream#getChannel()}
* {@link java.io.FileOutputStream#getChannel()}
* {@link java.nio.channels.Channels#newChannel(InputStream)}
* {@link java.nio.channels.Channels#newChannel(OutputStream)}
* {@link ReadableByteChannel}
* {@link WritableByteChannel}
*
* @param rbc
* @param wbc
* @param buffer
* @throws IOException
*/
public
static
void
flow
(
ReadableByteChannel
rbc
,
WritableByteChannel
wbc
,
ByteBuffer
buffer
,
boolean
closeIn
,
boolean
closeOut
)
throws
IOException
{
if
(
buffer
==
null
||
buffer
.
capacity
()
<
1
)
{
buffer
=
ByteBuffer
.
allocate
(
DEFAULT_BYTE_BUFFER_SIZE
);
}
try
{
while
(-
1
<
rbc
.
read
(
buffer
))
{
buffer
.
flip
();
wbc
.
write
(
buffer
);
buffer
.
clear
();
}
}
finally
{
if
(
closeIn
)
{
close
(
rbc
);
}
if
(
closeOut
)
{
close
(
wbc
);
}
}
}
/**
* 从输入流中读入数据将缓冲区填满
*
* @param is
* @param buff
* @param closeIn
* @throws IOException
*/
public
static
void
readFully
(
InputStream
is
,
byte
[]
buff
,
boolean
closeIn
)
throws
IOException
{
readFully
(
is
,
buff
,
0
,
closeIn
);
}
/**
* 从输入流中读入数据将缓冲区填满
*
* @param is
* @param buff
* @param offset
* @param closeIn
* @throws IOException
*/
public
static
void
readFully
(
InputStream
is
,
byte
[]
buff
,
int
offset
,
boolean
closeIn
)
throws
IOException
{
int
length
=
buff
.
length
-
offset
;
int
actual
=
read
(
is
,
buff
,
offset
,
length
,
closeIn
);
if
(
actual
!=
length
)
{
throw
new
EOFException
(
"Length to read: "
+
length
+
" actual: "
+
actual
);
}
}
/**
* 读取给定长度字节到缓冲区,返回读取的字节数
*
* @param is
* @param buff
* @param offset
* @param length
* @param closeIn
* @return
* @throws IOException
*/
public
static
int
read
(
InputStream
is
,
byte
[]
buff
,
int
offset
,
final
int
length
,
boolean
closeIn
)
throws
IOException
{
if
(
length
<
0
)
{
throw
new
IllegalArgumentException
(
"length must be greater than or equal 0"
);
}
int
remaining
=
length
;
while
(
remaining
>
0
)
{
int
location
=
length
-
remaining
;
int
readed
=
is
.
read
(
buff
,
offset
+
location
,
remaining
);
if
(-
1
==
readed
)
{
break
;
}
remaining
-=
readed
;
}
if
(
closeIn
)
{
close
(
is
);
}
return
length
-
remaining
;
}
public
static
byte
[]
readBytes
(
InputStream
is
,
boolean
closeIn
)
throws
IOException
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
(
1024
);
flow
(
is
,
baos
,
closeIn
,
true
);
return
baos
.
toByteArray
();
}
public
static
String
toString
(
InputStream
is
,
Charset
charset
,
boolean
closeIn
)
throws
IOException
{
Reader
reader
=
charset
==
null
?
new
InputStreamReader
(
is
)
:
new
InputStreamReader
(
is
,
charset
);
return
toString
(
reader
,
closeIn
);
}
public
static
String
toString
(
Reader
reader
,
boolean
closeIn
)
throws
IOException
{
StringWriter
writer
=
new
StringWriter
();
flow
(
reader
,
writer
,
closeIn
,
true
);
return
writer
.
toString
();
}
public
static
String
toString
(
File
file
)
throws
IOException
{
return
toString
(
file
,
Charset
.
defaultCharset
());
}
public
static
String
toString
(
File
file
,
Charset
charset
)
throws
IOException
{
return
toString
(
new
FileInputStream
(
file
),
charset
,
true
);
}
public
static
void
write
(
CharSequence
charseq
,
OutputStream
os
,
Charset
charset
,
boolean
closeOut
)
throws
IOException
{
Writer
writer
=
charset
==
null
?
new
OutputStreamWriter
(
os
)
:
new
OutputStreamWriter
(
os
,
charset
);
write
(
charseq
,
writer
,
closeOut
);
}
public
static
void
write
(
CharSequence
charseq
,
Writer
writer
,
boolean
closeOut
)
throws
IOException
{
try
{
writer
.
write
(
charseq
.
toString
());
writer
.
flush
();
}
finally
{
if
(
closeOut
)
{
close
(
writer
);
}
}
}
public
static
BufferedInputStream
toBuffered
(
InputStream
is
)
{
return
null
==
is
||
is
instanceof
BufferedInputStream
?
(
BufferedInputStream
)
is
:
new
BufferedInputStream
(
is
);
}
public
static
BufferedReader
toBuffered
(
Reader
reader
)
{
return
null
==
reader
||
reader
instanceof
BufferedReader
?
(
BufferedReader
)
reader
:
new
BufferedReader
(
reader
);
}
public
static
void
close
(
Closeable
closeable
)
{
if
(
closeable
!=
null
)
{
try
{
closeable
.
close
();
}
catch
(
IOException
ignore
)
{
}
}
}
private
IOUtils
()
{
}
}
\ No newline at end of file
src/main/java/com/topsunit/scanservice/ximai/common/MatchFile.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
common
;
/**
* 文件匹配接口
* @ Author: chicheng.li
* @ Date : 2022/1/11
*/
public
interface
MatchFile
{
/**
* 是否匹配文件
* @param fileName 文件名
* @param path 文件路径
* @return
*/
public
boolean
isMatch
(
String
fileName
,
String
path
);
}
src/main/java/com/topsunit/scanservice/ximai/common/Path.java
0 → 100644
View file @
6760822f
This diff is collapsed.
Click to expand it.
src/main/java/com/topsunit/scanservice/ximai/common/PrintConfig.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
common
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.List
;
/**
* <p>Title: PrintConfig</p>
* <p>Description: 打印设置</p>
*
* @author xi.feng
* @version V1.0
*/
@Configuration
@ConfigurationProperties
(
prefix
=
"topsunit.print"
)
public
class
PrintConfig
{
private
List
<
PrintConfigUrl
>
urls
;
public
List
<
PrintConfigUrl
>
getUrls
()
{
return
urls
;
}
public
void
setUrls
(
List
<
PrintConfigUrl
>
urls
)
{
this
.
urls
=
urls
;
}
}
src/main/java/com/topsunit/scanservice/ximai/common/PrintConfigUrl.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
common
;
import
java.io.Serializable
;
/**
* <p>Title: PrintConfigUrl</p>
* <p>Description: PrintConfigUrl</p>
*
* @author xi.feng
* @version V1.0
*/
public
class
PrintConfigUrl
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
code
;
private
String
url
;
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
}
src/main/java/com/topsunit/scanservice/ximai/common/SmbFileSystem.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
common
;
import
jcifs.smb.SmbFile
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
static
com
.
topsunit
.
scanservice
.
ximai
.
common
.
FileSystemException
.
rethrowFileSystemException
;
/**
* 共享文件传输协议
* @ Author: chicheng.li
* @ Date : 2022/1/6
*/
public
class
SmbFileSystem
extends
FileSystem
{
String
uri
;
@Override
public
boolean
exists
(
String
path
)
throws
FileSystemException
{
try
{
SmbFile
smbFile
=
new
SmbFile
(
uri
+
path
);
return
smbFile
.
exists
();
}
catch
(
Throwable
ex
){
return
rethrowFileSystemException
(
ex
);
}
}
@Override
public
FileView
stat
(
String
path
)
throws
FileSystemException
{
if
(!
path
.
startsWith
(
Path
.
SEPARATOR
)){
path
=
Path
.
SEPARATOR
+
path
;
}
try
{
SmbFile
smbFile
=
new
SmbFile
(
uri
+
path
);
FileView
fv
=
new
FileView
(
smbFile
.
getPath
().
replace
(
uri
,
""
),
smbFile
.
getContentLength
(),
smbFile
.
isDirectory
(),
smbFile
.
getLastModified
(),
smbFile
.
getDate
(),
smbFile
.
getType
(),
null
,
null
,
null
);
fv
.
setName
(
smbFile
.
getName
());
return
fv
;
}
catch
(
Throwable
ex
){
return
rethrowFileSystemException
(
ex
);
}
}
@Override
public
FileView
[]
ls
(
String
path
)
throws
FileSystemException
{
if
(!
path
.
startsWith
(
Path
.
SEPARATOR
)){
path
=
Path
.
SEPARATOR
+
path
;
}
try
{
//smb文件夹必须以/结尾
if
(!
path
.
endsWith
(
"/"
)){
path
=
path
+
"/"
;
}
SmbFile
smbFile
=
new
SmbFile
(
uri
+
path
);
if
(!
smbFile
.
isDirectory
())
{
throw
new
FileSystemException
(
String
.
format
(
"[%s]不是文件夹"
));
}
SmbFile
[]
files
=
smbFile
.
listFiles
();
FileView
[]
rst
=
new
FileView
[
files
.
length
];
int
i
=
0
;
for
(
SmbFile
nextSmbFile
:
smbFile
.
listFiles
()){
FileView
fv
=
new
FileView
(
nextSmbFile
.
getPath
().
replace
(
uri
,
""
),
nextSmbFile
.
getContentLength
(),
nextSmbFile
.
isDirectory
(),
nextSmbFile
.
getLastModified
(),
nextSmbFile
.
getDate
(),
nextSmbFile
.
getType
(),
null
,
null
,
null
);
fv
.
setName
(
nextSmbFile
.
getName
());
rst
[
i
]
=
fv
;
i
++;
}
return
rst
;
}
catch
(
Throwable
ex
){
return
rethrowFileSystemException
(
ex
);
}
}
@Override
public
boolean
mkdirs
(
String
path
)
throws
FileSystemException
{
if
(!
path
.
startsWith
(
Path
.
SEPARATOR
)){
path
=
Path
.
SEPARATOR
+
path
;
}
try
{
SmbFile
smbFile
=
new
SmbFile
(
uri
+
path
);
if
(!
smbFile
.
exists
()){
smbFile
.
mkdirs
();
}
return
true
;
}
catch
(
Throwable
ex
){
return
rethrowFileSystemException
(
ex
);
}
}
@Override
public
InputStream
open
(
String
file
)
throws
FileSystemException
{
if
(!
file
.
startsWith
(
Path
.
SEPARATOR
)){
file
=
Path
.
SEPARATOR
+
file
;
}
try
{
SmbFile
smbFile
=
new
SmbFile
(
uri
+
file
);
return
smbFile
.
getInputStream
();
}
catch
(
Throwable
ex
){
return
rethrowFileSystemException
(
ex
);
}
}
@Override
public
OutputStream
create
(
String
file
,
boolean
override
)
throws
FileSystemException
{
if
(!
file
.
startsWith
(
Path
.
SEPARATOR
)){
file
=
Path
.
SEPARATOR
+
file
;
}
try
{
return
this
.
create
(
file
,
null
,
override
);
}
catch
(
Throwable
ex
){
return
rethrowFileSystemException
(
ex
);
}
}
@Override
public
OutputStream
create
(
String
file
,
String
contentType
,
boolean
override
)
throws
FileSystemException
{
try
{
SmbFile
smbFile
=
new
SmbFile
(
uri
+
file
);
if
(
override
&&
smbFile
.
exists
()){
smbFile
.
delete
();
return
smbFile
.
getOutputStream
();
}
else
{
return
smbFile
.
getOutputStream
();
}
}
catch
(
Throwable
ex
){
return
rethrowFileSystemException
(
ex
);
}
}
@Override
public
void
rm
(
String
path
,
boolean
force
,
boolean
recursive
)
throws
FileSystemException
{
try
{
SmbFile
smbFile
=
new
SmbFile
(
uri
+
path
);
this
.
rmExe
(
smbFile
,
force
,
recursive
);
}
catch
(
Throwable
ex
){
rethrowFileSystemException
(
ex
);
}
}
/**
* 删除给定路径
*
* @param file 共享文件对象
* @param force 如果文件夹中存在文件是否强制删除
* @param recursive 如果文件夹中存在目录是否递归删除
* @throws FileSystemException
*/
@SuppressWarnings
(
"unchecked"
)
protected
void
rmExe
(
SmbFile
file
,
boolean
force
,
boolean
recursive
)
throws
IOException
{
try
{
if
(
file
.
isDirectory
())
{
SmbFile
[]
files
=
file
.
listFiles
();
if
(!
force
&&
0
<
files
.
length
)
{
throw
new
IOException
(
"You cannot delete non-empty directory, use force=true to overide"
);
}
for
(
SmbFile
f
:
files
)
{
if
(!
recursive
&&
f
.
isDirectory
())
{
throw
new
IOException
(
"Directory has contents, cannot delete without recurse=true"
);
}
if
(
f
.
isDirectory
()){
this
.
rmExe
(
f
,
force
,
recursive
);
}
else
{
f
.
delete
();
}
}
file
.
delete
();
}
else
{
file
.
delete
();
}
}
catch
(
Exception
e
)
{
throw
new
IOException
(
e
);
}
}
@Override
public
void
rename
(
String
oldPath
,
String
newPath
)
throws
FileSystemException
{
try
{
SmbFile
sf
=
new
SmbFile
(
uri
+
oldPath
);
sf
.
renameTo
(
new
SmbFile
(
uri
+
newPath
));
}
catch
(
Throwable
ex
){
rethrowFileSystemException
(
ex
);
}
}
@Override
public
void
disconnect
()
throws
FileSystemException
{
}
public
String
getUri
()
{
return
uri
;
}
public
void
setUri
(
String
uri
)
{
this
.
uri
=
uri
;
}
}
src/main/java/com/topsunit/scanservice/ximai/controller/CmsmvController.java
View file @
6760822f
...
...
@@ -7,8 +7,10 @@ import com.topsunit.scanservice.ximai.dto.LoginResult;
import
com.topsunit.scanservice.ximai.dto.SetPasswordParams
;
import
com.topsunit.scanservice.ximai.security.PassToken
;
import
com.topsunit.scanservice.ximai.service.CmsmvService
;
import
com.topsunit.scanservice.ximai.webapi.MesLoginService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -35,7 +37,7 @@ public class CmsmvController {
@PassToken
@PostMapping
(
"/login"
)
public
LoginResult
login
(
@RequestBody
LoginParams
loginParams
)
{
return
cmsmvService
.
login
(
loginParams
);
return
cmsmvService
.
login
ByMes
(
loginParams
);
}
@PassToken
...
...
src/main/java/com/topsunit/scanservice/ximai/controller/MoctaController.java
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
controller
;
import
com.topsunit.scanservice.ximai.common.AppConfig
;
import
com.topsunit.scanservice.ximai.common.FileView
;
import
com.topsunit.scanservice.ximai.common.IOUtils
;
import
com.topsunit.scanservice.ximai.common.SmbFileSystem
;
import
com.topsunit.scanservice.ximai.dto.*
;
import
com.topsunit.scanservice.ximai.service.MoctaService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.Optional
;
...
...
@@ -22,16 +30,38 @@ import java.util.Optional;
public
class
MoctaController
{
private
final
MoctaService
moctaService
;
private
AppConfig
appConfig
;
public
MoctaController
(
MoctaService
moctaService
)
{
this
.
moctaService
=
moctaService
;
}
@PostMapping
(
"/mocta/
getfordoc"
)
@PostMapping
(
"/mocta/getfordoc"
)
Optional
<
MoctaDocDto
>
getForDoc
(
@RequestBody
MoctaIdCriteria
criteria
){
return
moctaService
.
getForDoc
(
criteria
);
}
@ApiOperation
(
"获取文件列表"
)
@PostMapping
(
"/mocta/getfordocList"
)
MoctaDocDto
getfordocList
(
@RequestBody
MoctaIdCriteria
criteria
){
MoctaDocDto
rst
=
new
MoctaDocDto
();
SmbFileSystem
fileSystem
=
new
SmbFileSystem
();
fileSystem
.
setUri
(
appConfig
.
getShareUrl
());
List
<
FileView
>
list
=
fileSystem
.
searchFiles
(
"/"
,
".*"
,
false
);
list
.
forEach
(
s
->{
rst
.
getFiles
().
add
(
s
.
getName
());
});
return
rst
;
}
@ApiOperation
(
"下载文件"
)
@PostMapping
(
"/mocta/getfordocFile"
)
void
getfordocFile
(
@RequestBody
MoctaDocCriteria
criteria
,
HttpServletResponse
response
)
throws
IOException
{
SmbFileSystem
fileSystem
=
new
SmbFileSystem
();
fileSystem
.
setUri
(
appConfig
.
getShareUrl
());
InputStream
in
=
fileSystem
.
open
(
criteria
.
getFileName
());
IOUtils
.
flow
(
in
,
response
.
getOutputStream
(),
true
,
true
);
}
@ApiOperation
(
"工单查询"
)
@PostMapping
(
"/mocta/getMoctaList"
)
List
<
MoctaDto
>
getMoctaList
(
@RequestBody
MoctaCriteria
criteria
){
...
...
src/main/java/com/topsunit/scanservice/ximai/dto/MoctaDocCriteria.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* <p>Title: MoctaDocDto</p>
* <p>Description: 订单查询 - 查询工艺文档</p>
*
* @author xi.feng
* @version V1.0
* @date 2021/11/16
*/
@Data
public
class
MoctaDocCriteria
{
/*文件名*/
@ApiModelProperty
(
"文件名"
)
private
String
fileName
;
}
src/main/java/com/topsunit/scanservice/ximai/dto/MoctaDocDto.java
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
dto
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* <p>Title: MoctaDocDto</p>
* <p>Description: 订单查询 - 查询工艺文档</p>
...
...
@@ -8,6 +13,7 @@ package com.topsunit.scanservice.ximai.dto;
* @version V1.0
* @date 2021/11/16
*/
@Data
public
class
MoctaDocDto
{
/*工单单别*/
private
String
ta001
;
...
...
@@ -17,36 +23,9 @@ public class MoctaDocDto {
private
String
ta006
;
/*产品图号*/
private
String
mb029
;
/*内部图号*/
private
String
udf08
;
public
String
getTa001
()
{
return
ta001
;
}
public
void
setTa001
(
String
ta001
)
{
this
.
ta001
=
ta001
;
}
public
String
getTa002
()
{
return
ta002
;
}
public
void
setTa002
(
String
ta002
)
{
this
.
ta002
=
ta002
;
}
public
String
getTa006
()
{
return
ta006
;
}
public
void
setTa006
(
String
ta006
)
{
this
.
ta006
=
ta006
;
}
public
String
getMb029
()
{
return
mb029
;
}
private
List
<
String
>
files
=
new
ArrayList
<>();
public
void
setMb029
(
String
mb029
)
{
this
.
mb029
=
mb029
;
}
}
src/main/java/com/topsunit/scanservice/ximai/dto/PurccDto.java
View file @
6760822f
...
...
@@ -33,6 +33,8 @@ public class PurccDto {
private
String
cc012
;
@ApiModelProperty
(
""
)
private
String
cc026
;
@ApiModelProperty
(
"库房标识"
)
private
String
udf01
;
private
List
<
PurcdDto
>
purcds
;
...
...
src/main/java/com/topsunit/scanservice/ximai/dto/PurccPrintParams.java
View file @
6760822f
...
...
@@ -16,6 +16,10 @@ import java.util.List;
*/
@Data
public
class
PurccPrintParams
{
@ApiModelProperty
(
"打印标识"
)
private
String
udf01
;
@ApiModelProperty
(
"打印数据"
)
List
<
PurcdPrintParams
>
purcdPrintParamsList
;
}
src/main/java/com/topsunit/scanservice/ximai/entity/Purcc.java
View file @
6760822f
...
...
@@ -28,9 +28,13 @@ public class Purcc extends EntityBase {
@Column
private
String
cc009
;
@Column
private
String
cc010
;
@Column
private
String
cc012
;
@Column
private
String
cc026
;
@Column
private
String
udf01
;
public
String
getCc001
()
{
return
cc001
;
...
...
@@ -88,6 +92,14 @@ public class Purcc extends EntityBase {
this
.
cc009
=
cc009
;
}
public
String
getCc010
()
{
return
cc010
;
}
public
void
setCc010
(
String
cc010
)
{
this
.
cc010
=
cc010
;
}
public
String
getCc012
()
{
return
cc012
;
}
...
...
@@ -103,4 +115,12 @@ public class Purcc extends EntityBase {
public
void
setCc026
(
String
cc026
)
{
this
.
cc026
=
cc026
;
}
public
String
getUdf01
()
{
return
udf01
;
}
public
void
setUdf01
(
String
udf01
)
{
this
.
udf01
=
udf01
;
}
}
src/main/java/com/topsunit/scanservice/ximai/entity/Purcd.java
View file @
6760822f
...
...
@@ -57,6 +57,10 @@ public class Purcd extends EntityBase {
private
BigDecimal
cd029
;
@Column
private
String
cd034
;
@Column
private
String
udf01
;
@Column
private
String
udf02
;
public
String
getCd001
()
{
return
cd001
;
...
...
@@ -217,4 +221,20 @@ public class Purcd extends EntityBase {
public
void
setCd034
(
String
cd034
)
{
this
.
cd034
=
cd034
;
}
public
String
getUdf01
()
{
return
udf01
;
}
public
void
setUdf01
(
String
udf01
)
{
this
.
udf01
=
udf01
;
}
public
String
getUdf02
()
{
return
udf02
;
}
public
void
setUdf02
(
String
udf02
)
{
this
.
udf02
=
udf02
;
}
}
src/main/java/com/topsunit/scanservice/ximai/security/TokenService.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
security
;
import
com.topsunit.scanservice.ximai.common.AppConfig
;
import
com.topsunit.scanservice.ximai.common.Constants
;
import
com.topsunit.scanservice.ximai.dto.LoginResult
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
/**
* token验证处理
*
*/
@Component
public
class
TokenService
{
@Autowired
AppConfig
appConfig
;
/**
* 获取用户身份信息
*
* @return 用户信息
*/
public
LoginResult
getLoginUser
(
HttpServletRequest
request
)
{
LoginResult
rst
=
new
LoginResult
();
// 获取请求携带的令牌
String
token
=
getToken
(
request
);
if
(
StringUtils
.
isNotEmpty
(
token
))
{
try
{
Claims
claims
=
parseToken
(
token
);
// 解析对应的权限以及用户信息
String
uuid
=
(
String
)
claims
.
get
(
Constants
.
LOGIN_USER_KEY
);
String
userName
=
(
String
)
claims
.
get
(
Constants
.
JWT_USERNAME
);
String
userKey
=
getTokenKey
(
uuid
);
rst
.
setMv001
(
userName
);
rst
.
setMv002
(
userName
);
rst
.
setToken
(
token
);
return
rst
;
}
catch
(
Exception
e
)
{
}
}
return
null
;
}
/**
* 从令牌中获取数据声明
*
* @param token 令牌
* @return 数据声明
*/
private
Claims
parseToken
(
String
token
)
{
return
Jwts
.
parser
()
.
setSigningKey
(
appConfig
.
getTokenSecret
())
.
parseClaimsJws
(
token
)
.
getBody
();
}
/**
* 从令牌中获取用户名
*
* @param token 令牌
* @return 用户名
*/
public
String
getUsernameFromToken
(
String
token
)
{
Claims
claims
=
parseToken
(
token
);
return
claims
.
getSubject
();
}
/**
* 获取请求token
*
* @param request
* @return token
*/
private
String
getToken
(
HttpServletRequest
request
)
{
String
token
=
request
.
getHeader
(
"Authorization"
);
if
(
StringUtils
.
isNotEmpty
(
token
)
&&
token
.
startsWith
(
Constants
.
TOKEN_PREFIX
))
{
token
=
token
.
replace
(
Constants
.
TOKEN_PREFIX
,
""
);
}
return
token
;
}
private
String
getTokenKey
(
String
uuid
)
{
return
Constants
.
LOGIN_TOKEN_KEY
+
uuid
;
}
/**
* 根据Token获取对应的用户
* @param token
* @return
*/
public
LoginResult
getUserByToken
(
String
token
){
LoginResult
rst
=
new
LoginResult
();
if
(
StringUtils
.
isNotEmpty
(
token
))
{
try
{
Claims
claims
=
parseToken
(
token
);
// 解析对应的权限以及用户信息
String
uuid
=
(
String
)
claims
.
get
(
Constants
.
LOGIN_USER_KEY
);
String
userName
=
(
String
)
claims
.
get
(
Constants
.
JWT_USERNAME
);
String
userKey
=
getTokenKey
(
uuid
);
rst
.
setMv001
(
userName
);
rst
.
setMv002
(
userName
);
rst
.
setToken
(
token
);
return
rst
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
null
;
}
}
src/main/java/com/topsunit/scanservice/ximai/service/CmsmvService.java
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
service
;
import
cn.hutool.core.bean.BeanUtil
;
import
com.topsunit.scanservice.ximai.common.AppConfig
;
import
com.topsunit.scanservice.ximai.common.StringUtil
;
import
com.topsunit.scanservice.ximai.common.TopsunitException
;
...
...
@@ -13,6 +14,9 @@ import com.topsunit.scanservice.ximai.entity.Cmsmv;
import
com.topsunit.scanservice.ximai.security.CurrentActor
;
import
com.topsunit.scanservice.ximai.security.Encryptor
;
import
com.topsunit.scanservice.ximai.security.TokenManger
;
import
com.topsunit.scanservice.ximai.security.TokenService
;
import
com.topsunit.scanservice.ximai.webapi.MesLoginService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -27,12 +31,17 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public
class
CmsmvService
{
@Autowired
MesLoginService
mesLoginService
;
private
final
CmsmvDao
cmsmvDao
;
private
final
LoginMapper
loginMapper
;
private
final
TokenManger
tokenManger
;
private
final
CurrentActor
currentActor
;
private
final
Encryptor
encryptor
;
private
final
AppConfig
appConfig
;
@Autowired
private
TokenService
tokenService
;
public
CmsmvService
(
CmsmvDao
cmsmvDao
,
LoginMapper
loginMapper
,
TokenManger
tokenManger
,
CurrentActor
currentActor
,
Encryptor
encryptor
,
AppConfig
appConfig
)
{
this
.
cmsmvDao
=
cmsmvDao
;
...
...
@@ -63,6 +72,15 @@ public class CmsmvService {
.
orElseThrow
(()
->
new
TopsunitException
(
"用户名或密码错误。"
));
}
public
LoginResult
loginByMes
(
LoginParams
loginParams
)
{
com
.
topsunit
.
scanservice
.
ximai
.
webapi
.
dto
.
LoginParams
loginParams2
=
BeanUtil
.
copyProperties
(
loginParams
,
com
.
topsunit
.
scanservice
.
ximai
.
webapi
.
dto
.
LoginParams
.
class
);
com
.
topsunit
.
scanservice
.
ximai
.
webapi
.
dto
.
LoginResult
loginResult2
=
mesLoginService
.
login
(
loginParams2
);
if
(
loginResult2
.
getCode
()==
500
){
throw
new
TopsunitException
(
loginResult2
.
getMsg
());
}
return
tokenService
.
getUserByToken
(
loginResult2
.
getToken
());
}
@Transactional
public
void
setPassword
(
SetPasswordParams
params
)
{
Cmsmv
cmsmv
=
cmsmvDao
.
findById
(
params
.
getMv001
()).
orElseThrow
(()
->
new
TopsunitException
(
"用户不存在"
));
...
...
src/main/java/com/topsunit/scanservice/ximai/service/MocthService.java
View file @
6760822f
...
...
@@ -13,6 +13,7 @@ import com.topsunit.scanservice.ximai.entity.Mocth;
import
com.topsunit.scanservice.ximai.entity.Mocti
;
import
com.topsunit.scanservice.ximai.security.CurrentActor
;
import
com.topsunit.scanservice.ximai.webapi.PrintApi
;
import
com.topsunit.scanservice.ximai.webapi.dto.PrintField
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -114,22 +115,22 @@ public class MocthService {
return
;
}
List
<
Map
<
String
,
Object
>>
codeList
=
new
ArrayList
<>();
List
<
List
<
PrintField
>>
codeList
=
new
ArrayList
<>();
moctis
.
stream
().
forEach
(
i
->
{
moctiDao
.
findByTi001AndTi002
(
printParams
.
getTh001
(),
printParams
.
getTh002
()).
stream
().
findFirst
().
ifPresent
(
j
->
{
Map
<
String
,
Object
>
objectMap
=
new
LinkedHashMap
<>();
objectMap
.
put
(
"WWJH_Type"
,
j
.
getTi001
().
trim
(
));
objectMap
.
put
(
"WWJH_No"
,
j
.
getTi002
().
trim
(
));
objectMap
.
put
(
"GD_No"
,
j
.
getTi014
().
trim
(
));
objectMap
.
put
(
"P_No"
,
j
.
getTi004
().
trim
(
));
objectMap
.
put
(
"P_Name"
,
j
.
getTi005
().
trim
(
));
objectMap
.
put
(
"P_Spec"
,
j
.
getTi006
().
trim
(
));
objectMap
.
put
(
"LotNo"
,
j
.
getTi010
().
trim
(
));
objectMap
.
put
(
"WWJH_KW"
,
j
.
getTi060
().
trim
(
));
List
<
PrintField
>
objectMap
=
new
ArrayList
<>();
objectMap
.
add
(
PrintField
.
of
(
"WWJH_Type"
,
j
.
getTi001
().
trim
()
));
objectMap
.
add
(
PrintField
.
of
(
"WWJH_No"
,
j
.
getTi002
().
trim
()
));
objectMap
.
add
(
PrintField
.
of
(
"GD_No"
,
j
.
getTi014
().
trim
()
));
objectMap
.
add
(
PrintField
.
of
(
"P_No"
,
j
.
getTi004
().
trim
()
));
objectMap
.
add
(
PrintField
.
of
(
"P_Name"
,
j
.
getTi005
().
trim
()
));
objectMap
.
add
(
PrintField
.
of
(
"P_Spec"
,
j
.
getTi006
().
trim
()
));
objectMap
.
add
(
PrintField
.
of
(
"LotNo"
,
j
.
getTi010
().
trim
()
));
objectMap
.
add
(
PrintField
.
of
(
"WWJH_KW"
,
j
.
getTi060
().
trim
()
));
// 品号-批号-单别-单号-序号
String
qrCode
=
String
.
format
(
"%s-%s-%s-%s-%s"
,
j
.
getTi004
().
trim
(),
j
.
getTi010
().
trim
(),
j
.
getTi001
().
trim
(),
j
.
getTi002
().
trim
(),
j
.
getTi003
().
trim
());
objectMap
.
put
(
"QRCode"
,
"QRCode"
);
objectMap
.
add
(
PrintField
.
of
(
"QRCode"
,
qrCode
)
);
codeList
.
add
(
objectMap
);
...
...
src/main/java/com/topsunit/scanservice/ximai/service/PurccService.java
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
service
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.topsunit.scanservice.ximai.common.DateUtil
;
import
com.topsunit.scanservice.ximai.common.StringUtil
;
import
com.topsunit.scanservice.ximai.common.TopsunitException
;
import
com.topsunit.scanservice.ximai.common.*
;
import
com.topsunit.scanservice.ximai.dao.InvmcDao
;
import
com.topsunit.scanservice.ximai.dao.PurccDao
;
import
com.topsunit.scanservice.ximai.dao.PurcdDao
;
...
...
@@ -13,6 +11,8 @@ import com.topsunit.scanservice.ximai.dto.mapper.PurccMapper;
import
com.topsunit.scanservice.ximai.entity.*
;
import
com.topsunit.scanservice.ximai.security.CurrentActor
;
import
com.topsunit.scanservice.ximai.webapi.PrintApi
;
import
com.topsunit.scanservice.ximai.webapi.dto.PrintField
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -37,6 +37,8 @@ public class PurccService {
private
final
CurrentActor
currentActor
;
private
final
PrintApi
printApi
;
private
final
InvmcDao
invmcDao
;
@Autowired
private
PrintConfig
printConfig
;
public
PurccService
(
PurccDao
purccDao
,
PurcdDao
purcdDao
,
PurtdDao
purtdDao
,
PurccMapper
purccMapper
,
CurrentActor
currentActor
,
PrintApi
printApi
,
InvmcDao
invmcDao
)
{
this
.
purccDao
=
purccDao
;
...
...
@@ -132,33 +134,55 @@ public class PurccService {
return
;
}
purcdPrintParamsList
=
printParams
.
getPurcdPrintParamsList
().
stream
().
filter
(
i
->
i
.
getCount
()
>
0
).
collect
(
Collectors
.
toList
());
if
(
purcdPrintParamsList
.
isEmpty
())
{
if
(
purcdPrintParamsList
.
isEmpty
())
{
return
;
}
String
printCode
=
Optional
.
ofNullable
(
printParams
.
getUdf01
())
.
filter
(
i
->
i
.
length
()
>
1
)
.
map
(
i
->
i
.
substring
(
0
,
1
))
.
orElse
(
""
);
String
url
=
printConfig
.
getUrls
()
.
stream
()
.
filter
(
i
->
i
.
getCode
().
equals
(
printCode
))
.
map
(
PrintConfigUrl:
:
getUrl
)
.
findFirst
()
.
orElseThrow
(()->
new
TopsunitException
(
"未配置打印机"
));
List
<
Map
<
String
,
Object
>>
codeList
=
new
ArrayList
<>();
List
<
List
<
PrintField
>>
codeList
=
new
ArrayList
<>();
purcdPrintParamsList
.
forEach
(
i
->
{
purcdDao
.
findById
(
new
PurcdId
(
i
.
getCd001
(),
i
.
getCd002
(),
i
.
getCd003
())).
ifPresent
(
j
->
{
Map
<
String
,
Object
>
objectMap
=
new
LinkedHashMap
<>();
objectMap
.
put
(
"DH_Type"
,
j
.
getCd001
().
trim
());
objectMap
.
put
(
"DH_No"
,
j
.
getCd002
().
trim
());
objectMap
.
put
(
"CG_No"
,
j
.
getCd011
().
trim
());
objectMap
.
put
(
"P_No"
,
j
.
getCd004
().
trim
());
objectMap
.
put
(
"P_Name"
,
j
.
getCd005
().
trim
());
objectMap
.
put
(
"P_Spec"
,
j
.
getCd006
().
trim
());
objectMap
.
put
(
"DH_QTY"
,
j
.
getCd008
().
toString
().
trim
());
Optional
<
Purcc
>
optionalPurcc
=
purccDao
.
findById
(
new
PurccId
(
i
.
getCd001
(),
i
.
getCd002
()));
List
<
PrintField
>
objectMap
=
new
ArrayList
<>();
objectMap
.
add
(
PrintField
.
of
(
"DH_Type"
,
j
.
getCd001
().
trim
()));
objectMap
.
add
(
PrintField
.
of
(
"DH_No"
,
j
.
getCd002
().
trim
()));
objectMap
.
add
(
PrintField
.
of
(
"CG_No"
,
j
.
getCd011
().
trim
()));
objectMap
.
add
(
PrintField
.
of
(
"P_No"
,
j
.
getCd004
().
trim
()));
objectMap
.
add
(
PrintField
.
of
(
"P_Name"
,
j
.
getCd005
().
trim
()));
objectMap
.
add
(
PrintField
.
of
(
"P_Spec"
,
j
.
getCd006
().
trim
()));
objectMap
.
add
(
PrintField
.
of
(
"DH_QTY"
,
j
.
getCd008
().
toString
().
trim
()));
// 获取默认库位
Optional
<
Invmc
>
invmcOptional
=
getDefaultInvmc
(
j
.
getCd004
());
if
(
invmcOptional
.
isPresent
())
{
objectMap
.
put
(
"DH_KW"
,
invmcOptional
.
get
().
getMc015
().
trim
(
));
objectMap
.
add
(
PrintField
.
of
(
"DH_KW"
,
invmcOptional
.
get
().
getMc015
().
trim
()
));
}
else
{
objectMap
.
put
(
"DH_KW"
,
""
);
objectMap
.
add
(
PrintField
.
of
(
"DH_KW"
,
""
)
);
}
// 品号-(空)-单别-单号-序号
String
qrCode
=
String
.
format
(
"%s-%s-%s-%s-%s"
,
j
.
getCd004
().
trim
(),
""
,
j
.
getCd001
().
trim
(),
j
.
getCd002
().
trim
(),
j
.
getCd003
().
trim
());
objectMap
.
put
(
"QRCode"
,
qrCode
);
// String qrCode = String.format("%s-%s-%s-%s-%s", j.getCd004().trim(), "", j.getCd001().trim(), j.getCd002().trim(), j.getCd003().trim());
String
qrCode
=
j
.
getCd004
();
objectMap
.
add
(
PrintField
.
of
(
"QRCode"
,
qrCode
));
objectMap
.
add
(
PrintField
.
of
(
"CD006"
,
j
.
getCd006
().
trim
()));
objectMap
.
add
(
PrintField
.
of
(
"UDF01"
,
j
.
getUdf01
().
trim
()));
objectMap
.
add
(
PrintField
.
of
(
"UDF02"
,
j
.
getUdf02
().
trim
()));
objectMap
.
add
(
PrintField
.
of
(
"CC010"
,
optionalPurcc
.
map
(
Purcc:
:
getCc010
)
.
map
(
DateUtil:
:
stringToLocalDate
)
.
map
(
DateUtil:
:
localDateToStandardString
)
.
orElse
(
""
)));
codeList
.
add
(
objectMap
);
...
...
@@ -170,7 +194,7 @@ public class PurccService {
});
try
{
printApi
.
print
(
"DH"
,
1
,
codeList
);
printApi
.
print
(
url
,
"DH"
,
1
,
codeList
);
}
catch
(
JsonProcessingException
e
)
{
throw
new
TopsunitException
(
e
.
getMessage
());
}
...
...
src/main/java/com/topsunit/scanservice/ximai/webapi/MesLoginService.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
webapi
;
import
com.topsunit.scanservice.ximai.webapi.dto.LoginParams
;
import
com.topsunit.scanservice.ximai.webapi.dto.LoginResult
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
@FeignClient
(
name
=
"MES"
,
url
=
"${topsunit.mes-url}"
)
public
interface
MesLoginService
{
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
POST
)
LoginResult
login
(
@RequestBody
LoginParams
loginParams
);
}
src/main/java/com/topsunit/scanservice/ximai/webapi/PrintApi.java
View file @
6760822f
...
...
@@ -3,6 +3,7 @@ package com.topsunit.scanservice.ximai.webapi;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.topsunit.scanservice.ximai.common.AppConfig
;
import
com.topsunit.scanservice.ximai.webapi.dto.PrintField
;
import
com.topsunit.scanservice.ximai.webapi.dto.PrintParam
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -46,9 +47,7 @@ public class PrintApi {
return
restTemplate
;
}
public
void
print
(
String
templateKey
,
Integer
printNumber
,
List
<
Map
<
String
,
Object
>>
codeList
)
throws
JsonProcessingException
{
String
url
=
appConfig
.
getPrintApiUrl
();
public
void
print
(
String
url
,
String
templateKey
,
Integer
printNumber
,
List
<
List
<
PrintField
>>
codeList
)
throws
JsonProcessingException
{
HttpHeaders
requestHeader
=
new
HttpHeaders
();
requestHeader
.
add
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
...
...
@@ -65,4 +64,8 @@ public class PrintApi {
String
resultRemote
=
exchange
.
getBody
();
//得到返回的值
}
public
void
print
(
String
templateKey
,
Integer
printNumber
,
List
<
List
<
PrintField
>>
codeList
)
throws
JsonProcessingException
{
print
(
appConfig
.
getPrintApiUrl
(),
templateKey
,
printNumber
,
codeList
);
}
}
src/main/java/com/topsunit/scanservice/ximai/webapi/dto/LoginParams.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
webapi
.
dto
;
import
lombok.Data
;
@Data
public
class
LoginParams
{
String
username
;
String
password
;
}
src/main/java/com/topsunit/scanservice/ximai/webapi/dto/LoginResult.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
webapi
.
dto
;
import
lombok.Data
;
@Data
public
class
LoginResult
{
String
msg
;
int
code
=
0
;
String
token
;
}
src/main/java/com/topsunit/scanservice/ximai/webapi/dto/PrintField.java
0 → 100644
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
webapi
.
dto
;
/**
* description: PrintField <br>
* date: 2022/11/8 17:03 <br>
* author: xi.feng <br>
* version: 1.0 <br>
*/
public
class
PrintField
{
public
static
PrintField
of
(
String
code
,
String
value
){
return
new
PrintField
(
code
,
value
);
}
public
PrintField
()
{
}
public
PrintField
(
String
code
,
String
value
)
{
this
.
code
=
code
;
this
.
value
=
value
;
}
private
String
code
;
private
String
value
;
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
}
src/main/java/com/topsunit/scanservice/ximai/webapi/dto/PrintParam.java
View file @
6760822f
package
com
.
topsunit
.
scanservice
.
ximai
.
webapi
.
dto
;
import
lombok.Data
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -8,32 +10,9 @@ import java.util.Map;
* Date: 2021/11/03 17:29
* Description: 打印参数
*/
@Data
public
class
PrintParam
{
private
String
templateKey
;
private
Integer
printNumber
;
private
List
<
Map
<
String
,
Object
>>
codeList
;
public
String
getTemplateKey
()
{
return
templateKey
;
}
public
void
setTemplateKey
(
String
templateKey
)
{
this
.
templateKey
=
templateKey
;
}
public
Integer
getPrintNumber
()
{
return
printNumber
;
}
public
void
setPrintNumber
(
Integer
printNumber
)
{
this
.
printNumber
=
printNumber
;
}
public
List
<
Map
<
String
,
Object
>>
getCodeList
()
{
return
codeList
;
}
public
void
setCodeList
(
List
<
Map
<
String
,
Object
>>
codeList
)
{
this
.
codeList
=
codeList
;
}
private
List
<
List
<
PrintField
>>
codeList
;
}
src/main/resources/application-demo.yml
View file @
6760822f
topsunit
:
token-expires-hour
:
8760
authentication-enabled
:
false
token-secret
:
q8w3Cx9Lr4fT2y6uV5sZ8aE1mN0kP7gH
authentication-enabled
:
true
print-api-url
:
http://192.168.1.107:8085/ximaiprintservice/print/PrintLabelByBarTender
share-url
:
smb://127.0.0.1/share
mes-url
:
http://localhost:8088
default-password
:
123456
db-name
:
demo
print
:
urls
:
-
code
:
1
url
:
http://192.168.1.24:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
2
url
:
http://192.168.4.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
3
url
:
http://192.168.2.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
4
url
:
http://192.168.3.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
5
url
:
http://192.168.1.25:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
6
url
:
http://192.168.1.26:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
7
url
:
http://192.168.2.197:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
8
url
:
http://192.168.3.197:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
9
url
:
http://192.168.4.197:8085/ximaiprintservice/print/PrintLabelByBarTender
server
:
port
:
20091
servlet
:
...
...
src/main/resources/application-dev.yml
View file @
6760822f
topsunit
:
token-expires-hour
:
8760
token-secret
:
q8w3Cx9Lr4fT2y6uV5sZ8aE1mN0kP7gH
authentication-enabled
:
false
print-api-url
:
http://127.0.0.1:8085/ximaiprintservice/print/PrintLabelByBarTender
share-url
:
smb://127.0.0.1/share
mes-url
:
http://localhost:8088
default-password
:
123456
db-name
:
TEST
server
:
...
...
@@ -31,7 +34,7 @@ spring:
name
:
DEMO
username
:
sa
password
:
123qweQWE
url
:
jdbc:sqlserver://localhost:1433;DatabaseName=
XIMAI
url
:
jdbc:sqlserver://localhost:1433;DatabaseName=
leader
type
:
com.alibaba.druid.pool.DruidDataSource
druid
:
filters
:
stat
...
...
src/main/resources/application-test-co.yml
View file @
6760822f
topsunit
:
token-expires-hour
:
8760
token-secret
:
q8w3Cx9Lr4fT2y6uV5sZ8aE1mN0kP7gH
authentication-enabled
:
false
print-api-url
:
http://127.0.0.1:8085/ximaiprintservice/print/PrintLabelByBarTender
share-url
:
smb://127.0.0.1/share
mes-url
:
http://localhost:8088
default-password
:
123456
db-name
:
TEST
print
:
urls
:
-
code
:
1
url
:
http://192.168.1.24:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
2
url
:
http://192.168.4.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
3
url
:
http://192.168.2.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
4
url
:
http://192.168.3.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
5
url
:
http://192.168.1.25:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
6
url
:
http://192.168.1.26:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
7
url
:
http://192.168.2.197:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
8
url
:
http://192.168.3.197:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
9
url
:
http://192.168.4.197:8085/ximaiprintservice/print/PrintLabelByBarTender
server
:
port
:
9094
servlet
:
...
...
src/main/resources/application-thximai.yml
View file @
6760822f
topsunit
:
token-expires-hour
:
8760
token-secret
:
q8w3Cx9Lr4fT2y6uV5sZ8aE1mN0kP7gH
authentication-enabled
:
false
print-api-url
:
http://192.168.1.107:8085/ximaiprintservice/print/PrintLabelByBarTender
share-url
:
smb://127.0.0.1/share
mes-url
:
http://localhost:8088
default-password
:
123456
db-name
:
Leader
print
:
urls
:
-
code
:
1
url
:
http://192.168.1.24:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
2
url
:
http://192.168.4.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
3
url
:
http://192.168.2.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
4
url
:
http://192.168.3.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
5
url
:
http://192.168.1.25:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
6
url
:
http://192.168.1.26:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
7
url
:
http://192.168.2.197:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
8
url
:
http://192.168.3.197:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
9
url
:
http://192.168.4.197:8085/ximaiprintservice/print/PrintLabelByBarTender
server
:
port
:
20091
servlet
:
...
...
src/main/resources/application-ximai.yml
View file @
6760822f
topsunit
:
token-expires-hour
:
8760
token-secret
:
q8w3Cx9Lr4fT2y6uV5sZ8aE1mN0kP7gH
authentication-enabled
:
false
print-api-url
:
http://192.168.1.107:8085/ximaiprintservice/print/PrintLabelByBarTender
share-url
:
smb://127.0.0.1/share
mes-url
:
http://localhost:8088
default-password
:
123456
db-name
:
XIMAI
print
:
urls
:
-
code
:
1
url
:
http://192.168.1.24:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
2
url
:
http://192.168.4.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
3
url
:
http://192.168.2.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
4
url
:
http://192.168.3.198:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
5
url
:
http://192.168.1.25:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
6
url
:
http://192.168.1.26:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
7
url
:
http://192.168.2.197:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
8
url
:
http://192.168.3.197:8085/ximaiprintservice/print/PrintLabelByBarTender
-
code
:
9
url
:
http://192.168.4.197:8085/ximaiprintservice/print/PrintLabelByBarTender
server
:
port
:
20091
servlet
:
...
...
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