Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
shop-Mall
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
shop-Mall
Commits
c5bd5c0e
Commit
c5bd5c0e
authored
Apr 27, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
二维码实现优化 2
parent
3272c8d8
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
339 additions
and
195 deletions
+339
-195
ProductMapper.java
...pper/src/main/java/cn/wisenergy/mapper/ProductMapper.java
+32
-0
AntiFakeMapper.xml
...nergy-mapper/src/main/resources/mapper/AntiFakeMapper.xml
+7
-42
ProductMapper.xml
wisenergy-mapper/src/main/resources/mapper/ProductMapper.xml
+112
-0
AntiFake.java
...-model/src/main/java/cn/wisenergy/model/app/AntiFake.java
+5
-67
ProductInfo.java
...del/src/main/java/cn/wisenergy/model/app/ProductInfo.java
+100
-0
AntiFakeManger.java
...ain/java/cn/wisenergy/service/Manager/AntiFakeManger.java
+30
-1
AntiFakeService.java
...c/main/java/cn/wisenergy/service/app/AntiFakeService.java
+2
-1
RedisService.java
.../src/main/java/cn/wisenergy/service/app/RedisService.java
+0
-52
AntiFakeServiceImpl.java
...va/cn/wisenergy/service/app/impl/AntiFakeServiceImpl.java
+43
-29
AntiFakeController.java
...isenergy/web/admin/controller/app/AntiFakeController.java
+8
-3
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/ProductMapper.java
0 → 100644
View file @
c5bd5c0e
package
cn
.
wisenergy
.
mapper
;
import
cn.wisenergy.model.app.ProductInfo
;
import
org.apache.ibatis.annotations.Param
;
/**
* @author 86187
*/
public
interface
ProductMapper
{
/**
* 添加产品认证信息
*
* @param productInfo 产品认证信息
* @return 1
*/
int
add
(
ProductInfo
productInfo
);
/**
* 编辑产品认证信息
*
* @param productInfo 产品认证信息
* @return 1
*/
int
edit
(
ProductInfo
productInfo
);
/**
* 根据批次号获取产品认证信息
* @param batchNumber 批次号
* @return 产品认证信息
*/
ProductInfo
getByBatchNumber
(
@Param
(
"batchNumber"
)
String
batchNumber
);
}
wisenergy-mapper/src/main/resources/mapper/AntiFakeMapper.xml
View file @
c5bd5c0e
...
...
@@ -4,6 +4,7 @@
<resultMap
id=
"antiMap"
type=
"cn.wisenergy.model.app.AntiFake"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"product_no"
property=
"productNo"
/>
<result
column=
"security_code"
property=
"securityCode"
/>
<result
column=
"batch_number"
property=
"batchNumber"
/>
<result
column=
"sha_value"
property=
"shaValue"
/>
<result
column=
"produce_time"
property=
"produceTime"
/>
...
...
@@ -11,17 +12,6 @@
<result
column=
"status"
property=
"status"
/>
<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"
/>
<result
column=
"company_address"
property=
"companyAddress"
/>
<result
column=
"company_url"
property=
"companyUrl"
/>
<result
column=
"tracking_number"
property=
"trackingNumber"
/>
<result
column=
"logistics_url"
property=
"logisticsUrl"
/>
<result
column=
"record_number"
property=
"recordNumber"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
</resultMap>
...
...
@@ -36,25 +26,21 @@
</sql>
<sql
id=
"cols_exclude_id"
>
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
product_no,security_code,batch_number,sha_value,produce_time,scan_time,status,use_status,scan_number,create_time,update_time
</sql>
<sql
id=
"vals"
>
#{productNo},#{batchNumber},#{shaValue},#{produceTime},#{scanTime},#{status},#{useStatus},#{scanNumber},#{brand},
#{specification},#{brandName},#{productCountry}, #{validTime},#{companyName},#{companyAddress},#{companyUrl},#{trackingNumber},#{logisticsUrl},
#{recordNumber},now(),now()
#{productNo},#{securityCode},#{batchNumber},#{shaValue},#{produceTime},#{scanTime},#{status},#{useStatus},#{scanNumber},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.specification},#{i.brandName},#{i.productCountry}, #{i.validTime},#{i.companyName},
#{i.companyAddress}, #{i.companyUrl},#{i.trackingNumber},#{i.logisticsUrl}, #{i.recordNumber},now(),now()
#{i.productNo},#{i.securityCode},#{i.batchNumber},#{i.shaValue},#{i.produceTime},#{i.scanTime},#{i.status},#{i.useStatus},
#{i.scanNumber},now(),now()
</sql>
<sql
id=
"updateCondition"
>
<if
test=
"productNo != null"
>
product_no = #{productNo},
</if>
<if
test=
"securityCode != null"
>
security_code = #{securityCode},
</if>
<if
test=
"batchNumber != null"
>
batch_number = #{batchNumber},
</if>
<if
test=
"shaValue != null"
>
sha_value = #{shaValue},
</if>
<if
test=
"produceTime != null"
>
produce_time = #{produceTime},
</if>
...
...
@@ -62,23 +48,13 @@
<if
test=
"status != null"
>
status = #{status},
</if>
<if
test=
"useStatus != null"
>
use_status = #{useStatus},
</if>
<if
test=
"scanNumber != null"
>
scan_number = #{scanNumber},
</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>
<if
test=
"companyAddress != null"
>
company_address = #{companyAddress},
</if>
<if
test=
"companyUrl != null"
>
company_url = #{companyUrl},
</if>
<if
test=
"trackingNumber != null"
>
tracking_number = #{trackingNumber},
</if>
<if
test=
"logisticsUrl != null"
>
logistics_url = #{logisticsUrl},
</if>
<if
test=
"recordNumber != null"
>
record_number = #{recordNumber},
</if>
update_time =now()
</sql>
<sql
id=
"criteria"
>
<if
test=
"id != null"
>
id = #{id}
</if>
<if
test=
"productNo != null"
>
and product_no = #{productNo}
</if>
<if
test=
"securityCode != null"
>
and security_code = #{securityCode}
</if>
<if
test=
"batchNumber != null"
>
and batch_number = #{batchNumber}
</if>
<if
test=
"shaValue != null"
>
and sha_value = #{shaValue}
</if>
<if
test=
"produceTime != null"
>
and produce_time = #{produceTime}
</if>
...
...
@@ -86,17 +62,6 @@
<if
test=
"status != null"
>
and status = #{status}
</if>
<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>
<if
test=
"companyAddress != null"
>
and company_address = #{companyAddress}
</if>
<if
test=
"companyUrl != null"
>
and company_url = #{companyUrl}
</if>
<if
test=
"trackingNumber != null"
>
and tracking_number = #{trackingNumber}
</if>
<if
test=
"logisticsUrl != null"
>
and logistics_url = #{logisticsUrl}
</if>
<if
test=
"recordNumber != null"
>
and record_number = #{recordNumber}
</if>
<if
test=
"createTime != null"
>
and create_time
>
= #{createTime}
</if>
<if
test=
"updateTime != null"
>
and #{updateTime}
>
= update_time
</if>
</sql>
...
...
wisenergy-mapper/src/main/resources/mapper/ProductMapper.xml
0 → 100644
View file @
c5bd5c0e
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.wisenergy.mapper.ProductMapper"
>
<resultMap
id=
"productMap"
type=
"cn.wisenergy.model.app.ProductInfo"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"batch_number"
property=
"batchNumber"
/>
<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"
/>
<result
column=
"company_address"
property=
"companyAddress"
/>
<result
column=
"company_url"
property=
"companyUrl"
/>
<result
column=
"tracking_number"
property=
"trackingNumber"
/>
<result
column=
"logistics_url"
property=
"logisticsUrl"
/>
<result
column=
"record_number"
property=
"recordNumber"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
</resultMap>
<sql
id=
"table"
>
product_info
</sql>
<sql
id=
"cols_all"
>
id,
<include
refid=
"cols_exclude_id"
/>
</sql>
<sql
id=
"cols_exclude_id"
>
batch_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"
>
#{batchNumber},#{brand}, #{specification},#{brandName},#{productCountry}, #{validTime},#{companyName},
#{companyAddress},#{companyUrl},#{trackingNumber},#{logisticsUrl}, #{recordNumber},now(),now()
</sql>
<sql
id=
"createsVal"
>
#{i.batchNumber},#{i.brand},#{i.specification},#{i.brandName},#{i.productCountry},
#{i.validTime},#{i.companyName},
#{i.companyAddress}, #{i.companyUrl},#{i.trackingNumber},#{i.logisticsUrl}, #{i.recordNumber},now(),now()
</sql>
<sql
id=
"updateCondition"
>
<if
test=
"batchNumber != null"
>
batch_number = #{batchNumber},
</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>
<if
test=
"companyAddress != null"
>
company_address = #{companyAddress},
</if>
<if
test=
"companyUrl != null"
>
company_url = #{companyUrl},
</if>
<if
test=
"trackingNumber != null"
>
tracking_number = #{trackingNumber},
</if>
<if
test=
"logisticsUrl != null"
>
logistics_url = #{logisticsUrl},
</if>
<if
test=
"recordNumber != null"
>
record_number = #{recordNumber},
</if>
update_time =now()
</sql>
<sql
id=
"criteria"
>
<if
test=
"id != null"
>
id = #{id}
</if>
<if
test=
"batchNumber != null"
>
and batch_number = #{batchNumber}
</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>
<if
test=
"companyAddress != null"
>
and company_address = #{companyAddress}
</if>
<if
test=
"companyUrl != null"
>
and company_url = #{companyUrl}
</if>
<if
test=
"trackingNumber != null"
>
and tracking_number = #{trackingNumber}
</if>
<if
test=
"logisticsUrl != null"
>
and logistics_url = #{logisticsUrl}
</if>
<if
test=
"recordNumber != null"
>
and record_number = #{recordNumber}
</if>
<if
test=
"createTime != null"
>
and create_time
>
= #{createTime}
</if>
<if
test=
"updateTime != null"
>
and #{updateTime}
>
= update_time
</if>
</sql>
<insert
id=
"add"
parameterType=
"cn.wisenergy.model.app.ProductInfo"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
insert into
<include
refid=
"table"
/>
(
<include
refid=
"cols_exclude_id"
/>
)
value(
<include
refid=
"vals"
/>
)
</insert>
<update
id=
"edit"
parameterType=
"cn.wisenergy.model.app.ProductInfo"
>
UPDATE
<include
refid=
"table"
/>
<set>
<include
refid=
"updateCondition"
/>
</set>
<where>
id = #{id}
</where>
</update>
<select
id=
"getByBatchNumber"
resultMap=
"productMap"
>
select
<include
refid=
"cols_all"
/>
from
<include
refid=
"table"
/>
<where>
batch_number=#{batchNumber}
</where>
</select>
</mapper>
\ No newline at end of file
wisenergy-model/src/main/java/cn/wisenergy/model/app/AntiFake.java
View file @
c5bd5c0e
...
...
@@ -35,7 +35,11 @@ public class AntiFake implements Serializable {
@ApiModelProperty
(
value
=
"产品编号"
,
name
=
"productNo"
)
private
String
productNo
;
/**
* 安全码
*/
@ApiModelProperty
(
value
=
"安全码"
,
name
=
"securityCode"
)
private
String
securityCode
;
/**
* 批次号
*/
...
...
@@ -75,72 +79,6 @@ public class AntiFake implements Serializable {
@ApiModelProperty
(
value
=
"扫描次数"
,
name
=
"scanNumber"
)
private
Integer
scanNumber
;
/**
* 品牌
*/
@ApiModelProperty
(
value
=
"品牌"
,
name
=
"brand"
)
private
String
brand
;
/**
* 规格
*/
@ApiModelProperty
(
value
=
"规格"
,
name
=
"specification"
)
private
String
specification
;
/**
* 品牌名
*/
@ApiModelProperty
(
value
=
"品牌名"
,
name
=
"brandName"
)
private
String
brandName
;
/**
* 原产国
*/
@ApiModelProperty
(
value
=
"原产国"
,
name
=
"productCountry"
)
private
String
productCountry
;
/**
* 有效时间
*/
@ApiModelProperty
(
value
=
"有效时间"
,
name
=
"validTime"
)
private
Date
validTime
;
/**
* 企业名称
*/
@ApiModelProperty
(
value
=
"企业名称"
,
name
=
"companyName"
)
private
String
companyName
;
/**
* 企业地址
*/
@ApiModelProperty
(
value
=
"企业地址"
,
name
=
"companyAddress"
)
private
String
companyAddress
;
/**
* 企业网址
*/
@ApiModelProperty
(
value
=
"企业网址"
,
name
=
"companyUrl"
)
private
String
companyUrl
;
/**
* 货运单号
*/
@ApiModelProperty
(
value
=
"货运单号"
,
name
=
"trackingNumber"
)
private
String
trackingNumber
;
/**
* 物流轨迹查询平台
*/
@ApiModelProperty
(
value
=
"物流轨迹查询平台"
,
name
=
"logisticsUrl"
)
private
String
logisticsUrl
;
/**
* 海关进境货物备案编号
*/
@ApiModelProperty
(
value
=
"海关进境货物备案编号"
,
name
=
"recordNumber"
)
private
String
recordNumber
;
private
Date
createTime
;
private
Date
updateTime
;
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/app/ProductInfo.java
0 → 100644
View file @
c5bd5c0e
package
cn
.
wisenergy
.
model
.
app
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* @ Description: 产品认证信息实体类
* @ Author : 86187
* @ Date : 2021/4/27 10:03
* @author 86187
*/
@Data
@ApiModel
(
"ProductInfo"
)
public
class
ProductInfo
{
/**
* 主键id
*/
@ApiModelProperty
(
value
=
"主键id"
,
name
=
"id"
)
private
Integer
id
;
/**
* 批次号
*/
@ApiModelProperty
(
value
=
"批次号"
,
name
=
"batchNumber"
)
private
String
batchNumber
;
/**
* 品牌
*/
@ApiModelProperty
(
value
=
"品牌"
,
name
=
"brand"
)
private
String
brand
;
/**
* 规格
*/
@ApiModelProperty
(
value
=
"规格"
,
name
=
"specification"
)
private
String
specification
;
/**
* 品牌名
*/
@ApiModelProperty
(
value
=
"品牌名"
,
name
=
"brandName"
)
private
String
brandName
;
/**
* 原产国
*/
@ApiModelProperty
(
value
=
"原产国"
,
name
=
"productCountry"
)
private
String
productCountry
;
/**
* 有效时间
*/
@ApiModelProperty
(
value
=
"有效时间"
,
name
=
"validTime"
)
private
Date
validTime
;
/**
* 企业名称
*/
@ApiModelProperty
(
value
=
"企业名称"
,
name
=
"companyName"
)
private
String
companyName
;
/**
* 企业地址
*/
@ApiModelProperty
(
value
=
"企业地址"
,
name
=
"companyAddress"
)
private
String
companyAddress
;
/**
* 企业网址
*/
@ApiModelProperty
(
value
=
"企业网址"
,
name
=
"companyUrl"
)
private
String
companyUrl
;
/**
* 货运单号
*/
@ApiModelProperty
(
value
=
"货运单号"
,
name
=
"trackingNumber"
)
private
String
trackingNumber
;
/**
* 物流轨迹查询平台
*/
@ApiModelProperty
(
value
=
"物流轨迹查询平台"
,
name
=
"logisticsUrl"
)
private
String
logisticsUrl
;
/**
* 海关进境货物备案编号
*/
@ApiModelProperty
(
value
=
"海关进境货物备案编号"
,
name
=
"recordNumber"
)
private
String
recordNumber
;
private
Date
createTime
;
private
Date
updateTime
;
}
wisenergy-service/src/main/java/cn/wisenergy/service/Manager/AntiFakeManger.java
View file @
c5bd5c0e
package
cn
.
wisenergy
.
service
.
Manager
;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.mapper.AntiFakeMapper
;
import
cn.wisenergy.mapper.ProductMapper
;
import
cn.wisenergy.model.app.AntiFake
;
import
cn.wisenergy.model.app.ProductInfo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.util.List
;
...
...
@@ -16,10 +19,36 @@ public class AntiFakeManger {
@Autowired
private
AntiFakeMapper
antiFakeMapper
;
@Autowired
private
ProductMapper
productMapper
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
updateAntiFake
(
List
<
Long
>
array
)
{
//修改二维码使用状态
int
updateUseStatus
=
antiFakeMapper
.
updateUseStatus
(
array
);
return
updateUseStatus
==
array
.
size
();
}
/**
* 保存二维码信息和产品认证信息
*
* @param list 二维码信息
* @param productInfo 产品认证信息
* @return true of false
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
addAntiFakeAndProductInfo
(
List
<
AntiFake
>
list
,
ProductInfo
productInfo
)
{
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
int
count
=
antiFakeMapper
.
creates
(
list
);
if
(
count
!=
list
.
size
())
{
return
false
;
}
}
if
(
null
!=
productInfo
)
{
int
count
=
productMapper
.
add
(
productInfo
);
return
count
!=
0
;
}
return
true
;
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/AntiFakeService.java
View file @
c5bd5c0e
...
...
@@ -41,9 +41,10 @@ public interface AntiFakeService {
* 扫描防伪二维码
*
* @param produceNo 产品编号
* @param securityCode 安全码
* @return 扫描结果
*/
R
<
String
>
scanCode
(
String
produceNo
);
R
<
String
>
scanCode
(
String
produceNo
,
String
securityCode
);
/**
* 获取防伪二维码列表
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/RedisService.java
deleted
100644 → 0
View file @
3272c8d8
//package cn.wisenergy.service.app;
//
///**
// * Created by m1991 on 2021/3/12 16:57
// */
//public interface RedisService {
// /**
// * 点赞。状态为1
// * @param likedUserId
// * @param likedPostId
// */
// void saveLiked2Redis(String likedUserId, String likedPostId);
//
// /**
// * 取消点赞。将状态改变为0
// * @param likedUserId
// * @param likedPostId
// */
// void unlikeFromRedis(String likedUserId, String likedPostId);
//
// /**
// * 从Redis中删除一条点赞数据
// * @param likedUserId
// * @param likedPostId
// */
// void deleteLikedFromRedis(String likedUserId, String likedPostId);
//
// /**
// * 该用户的点赞数加1
// * @param likedUserId
// */
// void incrementLikedCount(String likedUserId);
//
// /**
// * 该用户的点赞数减1
// * @param likedUserId
// */
// void decrementLikedCount(String likedUserId);
//
// /**
// * 获取Redis中存储的所有点赞数据
// * @return
// */
// List<UserLike> getLikedDataFromRedis();
//
// /**
// * 获取Redis中存储的所有点赞数量
// * @return
// */
// List<LikedCountDTO> getLikedCountFromRedis();
//
//}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AntiFakeServiceImpl.java
View file @
c5bd5c0e
...
...
@@ -6,13 +6,13 @@ import cn.wisenergy.common.utils.R;
import
cn.wisenergy.common.utils.StringUtil
;
import
cn.wisenergy.mapper.AntiFakeMapper
;
import
cn.wisenergy.model.app.AntiFake
;
import
cn.wisenergy.model.app.ProductInfo
;
import
cn.wisenergy.model.dto.AntiFakeQuery
;
import
cn.wisenergy.model.dto.CreateCodeVo
;
import
cn.wisenergy.model.vo.ReportCodeVo
;
import
cn.wisenergy.service.Manager.AntiFakeManger
;
import
cn.wisenergy.service.app.AntiFakeService
;
import
cn.wisenergy.service.util.CodeUtils
;
import
cn.wisenergy.service.util.FileUtils
;
import
cn.wisenergy.service.util.QRCodeUtils
;
import
com.alibaba.excel.EasyExcel
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
...
...
@@ -23,13 +23,10 @@ import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
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
;
/**
* @author 86187
...
...
@@ -87,28 +84,37 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
antiFake
.
setStatus
(
0
);
antiFake
.
setUseStatus
(
0
);
//生成防伪码
String
sha
=
DigestUtils
.
sha1Hex
(
productNo
).
substring
(
0
,
16
);
antiFake
.
setShaValue
(
sha
);
//生成六位随机数作为安全码
int
code
=
(
int
)
((
Math
.
random
()
*
9
+
1
)
*
100000
);
antiFake
.
setSecurityCode
(
String
.
valueOf
(
code
));
antiFake
.
setScanNumber
(
0
);
antiFake
.
setProduceTime
(
codeVo
.
getProduceTime
());
antiFake
.
setCompanyAddress
(
"東京都千代田区東神田2丁目6番7号608"
);
antiFake
.
setCompanyName
(
"日本西田森製薬株式会社"
);
antiFake
.
setCompanyUrl
(
"www.nishidamori.co.jp"
);
antiFake
.
setLogisticsUrl
(
"中国国际货运航空 https://www.airchinacargo.com/en/search_order.php"
);
antiFake
.
setBrand
(
"西田森"
);
antiFake
.
setProductCountry
(
codeVo
.
getProductCountry
());
antiFake
.
setRecordNumber
(
codeVo
.
getRecordNumber
());
antiFake
.
setTrackingNumber
(
codeVo
.
getTrackingNumber
());
antiFake
.
setValidTime
(
codeVo
.
getValidTime
());
antiFake
.
setSpecification
(
codeVo
.
getSpecification
());
antiFake
.
setBrandName
(
codeVo
.
getBrandName
());
list
.
add
(
antiFake
);
}
//批量添加二维码
int
count
=
antiFakeMapper
.
creates
(
list
);
if
(
count
!=
list
.
size
())
{
return
R
.
error
(
"生成防伪二维码失败!"
);
//初始化产品认证信息
ProductInfo
productInfo
=
new
ProductInfo
();
productInfo
.
setBatchNumber
(
batchNumber
);
productInfo
.
setCompanyAddress
(
"東京都千代田区東神田2丁目6番7号608"
);
productInfo
.
setCompanyName
(
"日本西田森製薬株式会社"
);
productInfo
.
setCompanyUrl
(
"www.nishidamori.co.jp"
);
productInfo
.
setLogisticsUrl
(
"中国国际货运航空 https://www.airchinacargo.com/en/search_order.php"
);
productInfo
.
setBrand
(
"西田森"
);
productInfo
.
setProductCountry
(
codeVo
.
getProductCountry
());
productInfo
.
setRecordNumber
(
codeVo
.
getRecordNumber
());
productInfo
.
setTrackingNumber
(
codeVo
.
getTrackingNumber
());
productInfo
.
setValidTime
(
codeVo
.
getValidTime
());
productInfo
.
setSpecification
(
codeVo
.
getSpecification
());
productInfo
.
setBrandName
(
codeVo
.
getBrandName
());
//批量添加二维码 和产品认证信息
boolean
bool
=
antiFakeManger
.
addAntiFakeAndProductInfo
(
list
,
productInfo
);
if
(!
bool
)
{
return
R
.
ok
(
1
,
false
);
}
return
R
.
ok
(
0
,
true
);
}
...
...
@@ -122,9 +128,9 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
}
@Override
public
R
<
String
>
scanCode
(
String
shaValue
)
{
public
R
<
String
>
scanCode
(
String
shaValue
,
String
securityCode
)
{
log
.
info
(
"AntiFakeServiceImpl[]scanCode[]input.param.shaValue:"
+
shaValue
);
if
(
StringUtils
.
isBlank
(
shaValue
))
{
if
(
StringUtils
.
isBlank
(
shaValue
)
||
StringUtils
.
isBlank
(
securityCode
)
)
{
return
R
.
error
(
"入参不能为空!"
);
}
...
...
@@ -134,6 +140,10 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
return
R
.
error
(
"无效二维码"
);
}
if
(!
securityCode
.
equals
(
antiFake
.
getSecurityCode
()))
{
return
R
.
error
(
"安全码不匹配!"
);
}
if
(
antiFake
.
getStatus
()
==
1
)
{
antiFake
.
setScanNumber
(
antiFake
.
getScanNumber
()
+
1
);
int
count
=
antiFakeMapper
.
edit
(
antiFake
);
...
...
@@ -142,7 +152,7 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
}
return
R
.
ok
(
"防伪码号"
+
antiFake
.
getShaValue
()
+
"的产品为非正品,"
+
"第一次扫描时间为:"
+
DateUtil
.
convertDateToStr
(
antiFake
.
getScanTime
(),
"yyyy-MM-dd HH:mm:ss"
)
+
",共扫描过"
+
antiFake
.
getScanNumber
()
+
"
池
码"
);
+
",共扫描过"
+
antiFake
.
getScanNumber
()
+
"
次
码"
);
}
antiFake
.
setStatus
(
1
);
...
...
@@ -154,7 +164,7 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
}
return
R
.
ok
(
"防伪码号"
+
antiFake
.
getShaValue
()
+
"的产品为正品,"
+
"第一次扫描时间为:"
+
DateUtil
.
convertDateToStr
(
antiFake
.
getScanTime
(),
"yyyy-MM-dd HH:mm:ss"
)
+
",共扫描过"
+
antiFake
.
getScanNumber
()
+
"
池
码"
);
+
",共扫描过"
+
antiFake
.
getScanNumber
()
+
"
次
码"
);
}
@Override
...
...
@@ -195,6 +205,10 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
//获取防伪二维码生产码
List
<
AntiFake
>
result
=
antiFakeMapper
.
getProductNos
(
array
);
if
(
CollectionUtils
.
isEmpty
(
result
))
{
return
R
.
ok
(
0
,
true
);
}
for
(
AntiFake
anti
:
result
)
{
String
url
=
REQUEST_URL
+
anti
.
getShaValue
();
anti
.
setShaValue
(
url
);
...
...
@@ -207,12 +221,12 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
response
.
setCharacterEncoding
(
"utf-8"
);
// 使用java8新特性的stream流去处理数据,把空的数据过滤掉
List
<
ReportCodeVo
>
resultBo
=
result
.
stream
().
filter
(
Objects:
:
nonNull
)
.
map
(
t
->
{
return
ReportCodeVo
.
builder
()
.
shaValue
(
t
.
getShaValue
())
.
build
(
);
}).
collect
(
Collectors
.
toList
());
List
<
ReportCodeVo
>
resultBo
=
new
ArrayList
<>();
for
(
AntiFake
antiFake
:
result
)
{
ReportCodeVo
reportCodeVo
=
new
ReportCodeVo
();
reportCodeVo
.
setShaValue
(
antiFake
.
getShaValue
());
resultBo
.
add
(
reportCodeVo
);
}
//创建文件名称
long
lon
=
System
.
currentTimeMillis
();
...
...
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/AntiFakeController.java
View file @
c5bd5c0e
...
...
@@ -8,6 +8,7 @@ import cn.wisenergy.service.app.AntiFakeService;
import
com.github.pagehelper.PageInfo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -36,15 +37,19 @@ public class AntiFakeController {
}
@ApiOperation
(
value
=
"扫描防伪二维码"
,
notes
=
"扫描防伪二维码"
,
httpMethod
=
"POST"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"shaValue"
,
value
=
"防伪码"
,
dataType
=
"String"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"securityCode"
,
value
=
"安全码"
,
dataType
=
"String"
,
required
=
true
)
})
@ApiImplicitParam
(
name
=
"shaValue"
,
value
=
"防伪码"
,
dataType
=
"String"
)
@PostMapping
(
"/admin/scanCode"
)
public
R
<
String
>
scanCode
(
String
shaValue
)
{
log
.
info
(
"shop-mall[]AntiFakeController[]scanCode[]input.param.shaValue:"
+
shaValue
);
public
R
<
String
>
scanCode
(
String
shaValue
,
String
securityCode
)
{
log
.
info
(
"shop-mall[]AntiFakeController[]scanCode[]input.param.shaValue:"
+
shaValue
,
securityCode
);
if
(
StringUtils
.
isBlank
(
shaValue
))
{
return
R
.
error
(
"入参为空!"
);
}
return
antiFakeService
.
scanCode
(
shaValue
);
return
antiFakeService
.
scanCode
(
shaValue
,
securityCode
);
}
...
...
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