Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gs1-office-web-sit
Overview
Overview
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
吴迪
gs1-office-web-sit
Commits
c3ee0fa6
Commit
c3ee0fa6
authored
Dec 13, 2021
by
ZhangYunfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改条码生成逻辑
parent
caf6edcd
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
5 deletions
+57
-5
BarcodeGenerationController.java
...odules/manage/controller/BarcodeGenerationController.java
+6
-2
QRcodeDao.java
src/main/java/io/office/modules/manage/dao/QRcodeDao.java
+2
-0
GS1CodeListEntity.java
...va/io/office/modules/manage/entity/GS1CodeListEntity.java
+1
-0
BarcodeGenerationService.java
...fice/modules/manage/service/BarcodeGenerationService.java
+1
-1
BarcodeGenerationServiceImpl.java
...les/manage/service/impl/BarcodeGenerationServiceImpl.java
+39
-1
CheckAICodeUtil.java
.../java/io/office/modules/manage/utils/CheckAICodeUtil.java
+1
-1
QRcodeDao.xml
src/main/resources/mapper/manage/QRcodeDao.xml
+7
-0
No files found.
src/main/java/io/office/modules/manage/controller/BarcodeGenerationController.java
View file @
c3ee0fa6
...
...
@@ -34,8 +34,11 @@ public class BarcodeGenerationController {
*/
@Login
@PostMapping
(
"/api/createQRcode"
)
public
R
createQRcode
(
@RequestBody
Map
<
String
,
String
>
param
)
{
String
url
=
this
.
barcodeGenerationService
.
createPicture
(
param
.
get
(
"content"
));
public
R
createQRcode
(
@RequestBody
String
[]
param
)
{
if
(
param
.
length
==
0
){
return
R
.
error
(
"参数有误"
);
}
String
url
=
this
.
barcodeGenerationService
.
createPicture
(
param
);
return
R
.
ok
().
put
(
"pictureUrl"
,
url
);
}
@Login
...
...
@@ -59,4 +62,5 @@ public class BarcodeGenerationController {
String
result
=
CheckAICodeUtil
.
ckeckCode
(
body
.
getCode
(),
body
.
getContent
());
return
R
.
ok
().
put
(
"result"
,
result
);
}
}
src/main/java/io/office/modules/manage/dao/QRcodeDao.java
View file @
c3ee0fa6
...
...
@@ -10,4 +10,6 @@ public interface QRcodeDao extends BaseMapper<GS1CodeListEntity> {
List
<
GS1CodeListEntity
>
getGS1CodeList
();
GS1CodeListEntity
getGS1ByMark
();
GS1CodeListEntity
getFixedLengthResult
(
String
aiCode
);
}
src/main/java/io/office/modules/manage/entity/GS1CodeListEntity.java
View file @
c3ee0fa6
...
...
@@ -12,6 +12,7 @@ import lombok.Setter;
@Getter
@ApiModel
(
value
=
"GS1CodeList"
)
public
class
GS1CodeListEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"标识符ID"
)
public
String
id
;
...
...
src/main/java/io/office/modules/manage/service/BarcodeGenerationService.java
View file @
c3ee0fa6
...
...
@@ -13,7 +13,7 @@ import java.util.List;
*/
@Service
public
interface
BarcodeGenerationService
{
String
createPicture
(
String
content
);
String
createPicture
(
String
[]
param
);
List
<
GS1CodeListEntity
>
getGS1CodeListSSCC
();
...
...
src/main/java/io/office/modules/manage/service/impl/BarcodeGenerationServiceImpl.java
View file @
c3ee0fa6
package
io
.
office
.
modules
.
manage
.
service
.
impl
;
import
com.sun.javaws.jnl.RContentDesc
;
import
io.office.common.exception.RRException
;
import
io.office.modules.manage.dao.QRcodeDao
;
import
io.office.modules.manage.entity.GS1CodeListEntity
;
import
io.office.modules.manage.service.BarcodeGenerationService
;
import
io.office.modules.manage.utils.CheckAICodeUtil
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -17,11 +19,47 @@ public class BarcodeGenerationServiceImpl implements BarcodeGenerationService {
private
QRcodeDao
qRcodeDao
;
private
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
public
static
final
String
SEPERATOR
=
"ñ"
;
public
static
final
String
prefix_host
=
"http://localhost:9091/office/"
;
public
static
final
String
prefix_url
=
"barcodegeneration/api/gensvg?type="
;
@Override
public
String
createPicture
(
String
content
)
{
public
String
createPicture
(
String
[]
param
)
{
String
content
=
""
;
//遍历参数数组
for
(
int
i
=
0
;
i
<
param
.
length
;
i
++)
{
//获取ai标识符
String
[]
split
=
param
[
i
].
split
(
","
);
String
aiCode
=
split
[
0
];
//根据ai标识符查ai详情
GS1CodeListEntity
fixedLengthResult
=
qRcodeDao
.
getFixedLengthResult
(
aiCode
);
//不定长处理
if
(
fixedLengthResult
.
getIsVariable
()==
1
){
if
(
split
[
1
].
trim
().
length
()<=
fixedLengthResult
.
getMaxLength
()
&&
split
[
1
].
trim
().
length
()>=
fixedLengthResult
.
getMinLength
()){
content
=
content
+
split
[
0
]+
split
[
1
]+
SEPERATOR
;
}
else
{
throw
new
RRException
(
"AI为"
+
aiCode
+
" 的信息需要填充"
+
fixedLengthResult
.
getMaxLength
()+
"位数字"
);
}
//定长处理
}
else
if
(
fixedLengthResult
.
getIsVariable
()==
0
){
if
(
split
[
1
].
trim
().
length
()==
fixedLengthResult
.
getMinLength
()){
//是否需要校验码
if
(
fixedLengthResult
.
getIsCheck
()==
1
){
content
=
content
+
split
[
0
]+
split
[
1
]+
CheckAICodeUtil
.
antoFixCheckCode
(
split
[
1
]);
}
else
{
content
=
content
+
split
[
0
]+
split
[
1
];
}
}
else
{
throw
new
RRException
(
"AI为"
+
aiCode
+
" 的信息需要填充"
+
fixedLengthResult
.
getMaxLength
()+
"位数字"
);
}
}
}
if
(
content
.
lastIndexOf
(
"ñ"
)==
content
.
length
()-
1
){
content
=
content
.
substring
(
0
,
content
.
length
()-
1
);
}
else
if
(
content
.
length
()>
48
){
throw
new
RRException
(
"总长度不能超过48位"
);
}
String
url
=
""
;
if
(
content
.
length
()
>
50
)
{
throw
new
RRException
(
"最大50位!"
);
...
...
src/main/java/io/office/modules/manage/utils/CheckAICodeUtil.java
View file @
c3ee0fa6
...
...
@@ -29,7 +29,7 @@ public class CheckAICodeUtil {
}
//00 01
//返回一位校验码
p
rivate
static
String
antoFixCheckCode
(
String
gtinNo
){
p
ublic
static
String
antoFixCheckCode
(
String
gtinNo
){
//gtinNo = "0690123456789";
int
sum
=
0
;
char
[]
charArray
=
gtinNo
.
toCharArray
();
...
...
src/main/resources/mapper/manage/QRcodeDao.xml
View file @
c3ee0fa6
...
...
@@ -14,4 +14,10 @@
is_decimal isDecimal,is_check isCheck, is_num isNum, format, is_fnc1 isFnc1, data_name dataName ,is_date isDate, prompt
FROM gs1_standard where mark='8003'
</select>
<select
id=
"getFixedLengthResult"
resultType=
"io.office.modules.manage.entity.GS1CodeListEntity"
>
SELECT id, CONCAT(mark,'(',meaning,')') as codeName,mark codeValue, is_variable isVariable, min_length minLength, enable_max_length maxLength,
is_decimal isDecimal,is_check isCheck, is_num isNum, format, is_fnc1 isFnc1, data_name dataName ,is_date isDate, prompt
FROM gs1_standard where mark=#{aiCode};
</select>
</mapper>
\ No newline at end of file
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