Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
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
licc
data-server
Commits
be3afcf0
Commit
be3afcf0
authored
Apr 26, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
二维码实现2
parent
d6ba22fa
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
36 deletions
+50
-36
AntiFakeMapper.xml
...nergy-mapper/src/main/resources/mapper/AntiFakeMapper.xml
+13
-7
AntiFake.java
...-model/src/main/java/cn/wisenergy/model/app/AntiFake.java
+12
-0
CreateCodeVo.java
...el/src/main/java/cn/wisenergy/model/dto/CreateCodeVo.java
+9
-15
AntiFakeService.java
...c/main/java/cn/wisenergy/service/app/AntiFakeService.java
+2
-1
AntiFakeServiceImpl.java
...va/cn/wisenergy/service/app/impl/AntiFakeServiceImpl.java
+4
-7
CodeUtils.java
...ce/src/main/java/cn/wisenergy/service/util/CodeUtils.java
+8
-3
AntiFakeController.java
...isenergy/web/admin/controller/app/AntiFakeController.java
+2
-3
No files found.
wisenergy-mapper/src/main/resources/mapper/AntiFakeMapper.xml
View file @
be3afcf0
...
...
@@ -12,6 +12,8 @@
<result
column=
"use_status"
property=
"useStatus"
/>
<result
column=
"scan_number"
property=
"scanNumber"
/>
<result
column=
"brand"
property=
"brand"
/>
<result
column=
"specification"
property=
"specification"
/>
<result
column=
"brand_name"
property=
"brandName"
/>
<result
column=
"product_country"
property=
"productCountry"
/>
<result
column=
"valid_time"
property=
"validTime"
/>
<result
column=
"company_name"
property=
"companyName"
/>
...
...
@@ -34,21 +36,21 @@
</sql>
<sql
id=
"cols_exclude_id"
>
product_no,batch_number,sha_value,produce_time,scan_time,status,use_status,scan_number,brand,
product_country
,
valid_time, company_name,company_address,company_url,tracking_number,logistics_url,record
_number,
create_time,update_time
product_no,batch_number,sha_value,produce_time,scan_time,status,use_status,scan_number,brand,
specification
,
brand_name,product_country, valid_time, company_name,company_address,company_url,tracking
_number,
logistics_url,record_number,
create_time,update_time
</sql>
<sql
id=
"vals"
>
#{productNo},#{batchNumber},#{shaValue},#{produceTime},#{scanTime},#{status},#{useStatus},#{scanNumber},#{brand},
#{productCountry}, #{validTime},#{companyName},#{companyAddress},#{companyUrl},#{trackingNumber},#{logisticsUrl},
#{
specification},#{brandName},#{
productCountry}, #{validTime},#{companyName},#{companyAddress},#{companyUrl},#{trackingNumber},#{logisticsUrl},
#{recordNumber},now(),now()
</sql>
<sql
id=
"createsVal"
>
#{i.productNo},#{i.batchNumber},#{i.shaValue},#{i.produceTime},#{i.scanTime},#{i.status},#{i.useStatus},
#{i.scanNumber},#{i.brand},#{i.
productCountry}, #{i.validTime},#{i.companyName},#{i.companyAddress
},
#{i.companyUrl},#{i.trackingNumber},#{i.logisticsUrl}, #{i.recordNumber},now(),now()
#{i.scanNumber},#{i.brand},#{i.
specification},#{i.brandName},#{i.productCountry}, #{i.validTime},#{i.companyName
},
#{i.company
Address}, #{i.company
Url},#{i.trackingNumber},#{i.logisticsUrl}, #{i.recordNumber},now(),now()
</sql>
<sql
id=
"updateCondition"
>
...
...
@@ -59,8 +61,10 @@
<if
test=
"scanTime != null"
>
scan_time = #{scanTime},
</if>
<if
test=
"status != null"
>
status = #{status},
</if>
<if
test=
"useStatus != null"
>
use_status = #{useStatus},
</if>
<if
test=
"sca
Number != null"
>
sca_number = #{sca
Number},
</if>
<if
test=
"sca
nNumber != null"
>
scan_number = #{scan
Number},
</if>
<if
test=
"brand != null"
>
brand = #{brand},
</if>
<if
test=
"specification != null"
>
specification = #{specification},
</if>
<if
test=
"brandName != null"
>
brand_name = #{brandName},
</if>
<if
test=
"productCountry != null"
>
product_country = #{productCountry},
</if>
<if
test=
"validTime != null"
>
valid_time = #{validTime},
</if>
<if
test=
"companyName != null"
>
company_name = #{companyName},
</if>
...
...
@@ -83,6 +87,8 @@
<if
test=
"useStatus != null"
>
and use_status = #{useStatus}
</if>
<if
test=
"scaNumber != null"
>
and sca_number = #{scaNumber}
</if>
<if
test=
"brand != null"
>
and brand = #{brand}
</if>
<if
test=
"specification != null"
>
and specification = #{specification}
</if>
<if
test=
"brandName != null"
>
and brand_name = #{brandName}
</if>
<if
test=
"productCountry != null"
>
and product_country = #{productCountry}
</if>
<if
test=
"validTime != null"
>
and valid_time = #{validTime}
</if>
<if
test=
"companyName != null"
>
and company_name = #{companyName}
</if>
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/app/AntiFake.java
View file @
be3afcf0
...
...
@@ -81,6 +81,18 @@ public class AntiFake implements Serializable {
@ApiModelProperty
(
value
=
"品牌"
,
name
=
"brand"
)
private
String
brand
;
/**
* 规格
*/
@ApiModelProperty
(
value
=
"规格"
,
name
=
"specification"
)
private
String
specification
;
/**
* 品牌名
*/
@ApiModelProperty
(
value
=
"品牌名"
,
name
=
"brandName"
)
private
String
brandName
;
/**
* 原产国
*/
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/dto/CreateCodeVo.java
View file @
be3afcf0
...
...
@@ -20,22 +20,22 @@ public class CreateCodeVo {
private
Integer
number
;
/**
*
产品编号
*
生产日期 yyyy-MM-dd
*/
@ApiModelProperty
(
value
=
"
产品编号"
,
name
=
"productNo"
)
private
String
produc
tNo
;
@ApiModelProperty
(
value
=
"
生产日期 yyyy-MM-dd"
,
name
=
"produceTime"
,
required
=
true
)
private
String
produc
eTime
;
/**
*
防伪码
*
规格
*/
@ApiModelProperty
(
value
=
"
防伪码"
,
name
=
"shaValue
"
)
private
String
s
haValue
;
@ApiModelProperty
(
value
=
"
规格"
,
name
=
"specification
"
)
private
String
s
pecification
;
/**
*
生产日期 yyyy-MM-dd
*
品牌名
*/
@ApiModelProperty
(
value
=
"
生产日期 yyyy-MM-dd"
,
name
=
"produceTime"
,
required
=
true
)
private
String
produceTi
me
;
@ApiModelProperty
(
value
=
"
品牌名"
,
name
=
"brandName"
)
private
String
brandNa
me
;
/**
* 原产国
...
...
@@ -55,12 +55,6 @@ public class CreateCodeVo {
@ApiModelProperty
(
value
=
"货运单号"
,
name
=
"trackingNumber"
)
private
String
trackingNumber
;
/**
* 物流轨迹查询平台
*/
@ApiModelProperty
(
value
=
"物流轨迹查询平台"
,
name
=
"logisticsUrl"
)
private
String
logisticsUrl
;
/**
* 海关进境货物备案编号
*/
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/AntiFakeService.java
View file @
be3afcf0
...
...
@@ -8,6 +8,7 @@ import com.github.pagehelper.PageInfo;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.ParseException
;
import
java.util.List
;
...
...
@@ -25,7 +26,7 @@ public interface AntiFakeService {
* @param codeVo 二维码信息
* @return true or false
*/
R
<
Boolean
>
createCode
(
CreateCodeVo
codeVo
);
R
<
Boolean
>
createCode
(
CreateCodeVo
codeVo
)
throws
ParseException
;
/**
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AntiFakeServiceImpl.java
View file @
be3afcf0
...
...
@@ -27,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -47,7 +48,7 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
private
AntiFakeManger
antiFakeManger
;
@Override
public
R
<
Boolean
>
createCode
(
CreateCodeVo
codeVo
)
{
public
R
<
Boolean
>
createCode
(
CreateCodeVo
codeVo
)
throws
ParseException
{
log
.
info
(
"AntiFakeServiceImpl[]createCode[]input.param.codeVo:"
+
codeVo
);
if
(
null
==
codeVo
||
StringUtils
.
isBlank
(
codeVo
.
getProduceTime
()))
{
return
R
.
error
(
"入参不能为空!"
);
...
...
@@ -99,6 +100,8 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
antiFake
.
setRecordNumber
(
codeVo
.
getRecordNumber
());
antiFake
.
setTrackingNumber
(
codeVo
.
getTrackingNumber
());
antiFake
.
setValidTime
(
codeVo
.
getValidTime
());
antiFake
.
setSpecification
(
codeVo
.
getSpecification
());
antiFake
.
setBrandName
(
codeVo
.
getBrandName
());
list
.
add
(
antiFake
);
}
...
...
@@ -248,10 +251,4 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
schemeVo
.
setPageNo
(
pageNum
);
schemeVo
.
setPageSize
(
pageSize
);
}
public
static
void
main
(
String
[]
args
)
{
String
str
=
"nishidamori2021042210000001100000091vfpsyib7"
;
String
result
=
DigestUtils
.
sha1Hex
(
str
);
System
.
out
.
println
(
result
);
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/util/CodeUtils.java
View file @
be3afcf0
...
...
@@ -3,6 +3,8 @@ package cn.wisenergy.service.util;
import
cn.wisenergy.common.utils.DateUtil
;
import
org.apache.commons.lang.RandomStringUtils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
...
...
@@ -14,11 +16,14 @@ public class CodeUtils {
private
static
final
String
VALUE
=
"nishidamori"
;
public
static
String
createProductNo
(
String
batchNumber
,
String
batchNo
,
String
produceTime
)
{
public
static
String
createProductNo
(
String
batchNumber
,
String
batchNo
,
String
produceTime
)
throws
ParseException
{
//产品编号 =固定值+生产时间+生产批次+编号+随机数+校验规则
String
random
=
getRandom
();
String
ruleNumber
=
getVerifyNumber
(
batchNumber
,
batchNo
,
produceTime
,
random
);
return
VALUE
+
produceTime
+
batchNumber
+
batchNo
+
random
+
ruleNumber
;
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
Date
date
=
format
.
parse
(
produceTime
);
String
time
=
format
.
format
(
date
);
String
ruleNumber
=
getVerifyNumber
(
batchNumber
,
batchNo
,
time
,
random
);
return
VALUE
+
time
+
batchNumber
+
batchNo
+
random
+
ruleNumber
;
}
/**
...
...
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/AntiFakeController.java
View file @
be3afcf0
...
...
@@ -13,10 +13,9 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.ParseException
;
/**
* @author 86187
...
...
@@ -32,7 +31,7 @@ public class AntiFakeController {
@ApiOperation
(
value
=
"创建二维码"
,
notes
=
"创建二维码"
,
httpMethod
=
"POST"
)
@ApiImplicitParam
(
name
=
"codeVo"
,
value
=
"二维码信息"
,
dataType
=
"CreateCodeVo"
)
@PostMapping
(
value
=
"/admin/create/code"
)
public
R
<
Boolean
>
create
(
@RequestBody
CreateCodeVo
codeVo
)
{
public
R
<
Boolean
>
create
(
@RequestBody
CreateCodeVo
codeVo
)
throws
ParseException
{
return
antiFakeService
.
createCode
(
codeVo
);
}
...
...
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