Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
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
208f9517
Commit
208f9517
authored
4 years ago
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
二维码导出
parent
c5bd5c0e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
991 additions
and
875 deletions
+991
-875
pom.xml
wisenergy-common/pom.xml
+15
-15
ExcelUtils.java
...n/src/main/java/cn/wisenergy/common/utils/ExcelUtils.java
+276
-276
ExcelView.java
.../cn/wisenergy/common/utils/exportView/view/ExcelView.java
+562
-563
AntiFakeMapper.xml
...nergy-mapper/src/main/resources/mapper/AntiFakeMapper.xml
+6
-5
AntiFake.java
...-model/src/main/java/cn/wisenergy/model/app/AntiFake.java
+2
-0
AntiFakeService.java
...c/main/java/cn/wisenergy/service/app/AntiFakeService.java
+2
-0
AntiFakeServiceImpl.java
...va/cn/wisenergy/service/app/impl/AntiFakeServiceImpl.java
+35
-11
UserLevelTaskServiceImpl.java
.../wisenergy/service/app/impl/UserLevelTaskServiceImpl.java
+0
-3
ExcelUtils.java
...e/src/main/java/cn/wisenergy/service/util/ExcelUtils.java
+79
-0
AntiFakeController.java
...isenergy/web/admin/controller/app/AntiFakeController.java
+14
-2
No files found.
wisenergy-common/pom.xml
View file @
208f9517
...
@@ -140,21 +140,21 @@
...
@@ -140,21 +140,21 @@
<artifactId>
shiro-spring
</artifactId>
<artifactId>
shiro-spring
</artifactId>
</dependency>
</dependency>
<!-- POI -->
<!-- POI -->
<dependency
>
<!-- <dependency>--
>
<groupId>
org.apache.poi
</groupId
>
<!-- <groupId>org.apache.poi</groupId>--
>
<artifactId>
poi
</artifactId
>
<!-- <artifactId>poi</artifactId>--
>
<version>
3.9
</version
>
<!-- <version>3.9</version>--
>
</dependency
>
<!-- </dependency>--
>
<dependency
>
<!-- <dependency>--
>
<groupId>
org.apache.poi
</groupId
>
<!-- <groupId>org.apache.poi</groupId>--
>
<artifactId>
poi-ooxml
</artifactId
>
<!-- <artifactId>poi-ooxml</artifactId>--
>
<version>
3.9
</version
>
<!-- <version>3.9</version>--
>
</dependency
>
<!-- </dependency>--
>
<dependency
>
<!-- <dependency>--
>
<groupId>
org.apache.poi
</groupId
>
<!-- <groupId>org.apache.poi</groupId>--
>
<artifactId>
poi-ooxml-schemas
</artifactId
>
<!-- <artifactId>poi-ooxml-schemas</artifactId>--
>
<version>
3.9
</version
>
<!-- <version>3.9</version>--
>
</dependency
>
<!-- </dependency>--
>
<dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<artifactId>
hutool-all
</artifactId>
...
...
This diff is collapsed.
Click to expand it.
wisenergy-common/src/main/java/cn/wisenergy/common/utils/ExcelUtils.java
View file @
208f9517
This diff is collapsed.
Click to expand it.
wisenergy-common/src/main/java/cn/wisenergy/common/utils/exportView/view/ExcelView.java
View file @
208f9517
This diff is collapsed.
Click to expand it.
wisenergy-mapper/src/main/resources/mapper/AntiFakeMapper.xml
View file @
208f9517
...
@@ -118,7 +118,7 @@
...
@@ -118,7 +118,7 @@
</foreach>
</foreach>
</insert>
</insert>
<select
id=
"getByProductNo"
result
Type=
"cn.wisenergy.model.app.AntiFake
"
>
<select
id=
"getByProductNo"
result
Map=
"antiMap
"
>
select
select
<include
refid=
"cols_all"
/>
<include
refid=
"cols_all"
/>
from
from
...
@@ -137,7 +137,7 @@
...
@@ -137,7 +137,7 @@
</where>
</where>
</select>
</select>
<select
id=
"getList"
result
Type=
"cn.wisenergy.model.app.AntiFake
"
>
<select
id=
"getList"
result
Map=
"antiMap
"
>
select
select
<include
refid=
"cols_all"
/>
<include
refid=
"cols_all"
/>
from
from
...
@@ -149,8 +149,9 @@
...
@@ -149,8 +149,9 @@
</where>
</where>
</select>
</select>
<select
id=
"getProductNos"
resultType=
"cn.wisenergy.model.app.AntiFake"
>
<select
id=
"getProductNos"
resultMap=
"antiMap"
>
select product_no
select
<include
refid=
"cols_all"
/>
from
from
<include
refid=
"table"
/>
<include
refid=
"table"
/>
<where>
<where>
...
@@ -162,7 +163,7 @@
...
@@ -162,7 +163,7 @@
</where>
</where>
</select>
</select>
<select
id=
"getByShaValue"
result
Type=
"cn.wisenergy.model.app.AntiFake
"
>
<select
id=
"getByShaValue"
result
Map=
"antiMap
"
>
select
select
<include
refid=
"cols_all"
/>
<include
refid=
"cols_all"
/>
from
from
...
...
This diff is collapsed.
Click to expand it.
wisenergy-model/src/main/java/cn/wisenergy/model/app/AntiFake.java
View file @
208f9517
package
cn
.
wisenergy
.
model
.
app
;
package
cn
.
wisenergy
.
model
.
app
;
import
com.alibaba.excel.annotation.ExcelIgnoreUnannotated
;
import
com.alibaba.excel.annotation.ExcelIgnoreUnannotated
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
...
@@ -50,6 +51,7 @@ public class AntiFake implements Serializable {
...
@@ -50,6 +51,7 @@ public class AntiFake implements Serializable {
* 防伪码
* 防伪码
*/
*/
@ApiModelProperty
(
value
=
"防伪码"
,
name
=
"shaValue"
)
@ApiModelProperty
(
value
=
"防伪码"
,
name
=
"shaValue"
)
@ExcelProperty
(
value
=
"防伪码"
)
private
String
shaValue
;
private
String
shaValue
;
/**
/**
...
...
This diff is collapsed.
Click to expand it.
wisenergy-service/src/main/java/cn/wisenergy/service/app/AntiFakeService.java
View file @
208f9517
...
@@ -63,4 +63,6 @@ public interface AntiFakeService {
...
@@ -63,4 +63,6 @@ public interface AntiFakeService {
* @return
* @return
*/
*/
R
<
Boolean
>
report
(
String
str
,
HttpServletResponse
response
);
R
<
Boolean
>
report
(
String
str
,
HttpServletResponse
response
);
void
exportReceivable
(
String
str
,
HttpServletResponse
response
);
}
}
This diff is collapsed.
Click to expand it.
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AntiFakeServiceImpl.java
View file @
208f9517
...
@@ -13,6 +13,7 @@ import cn.wisenergy.model.vo.ReportCodeVo;
...
@@ -13,6 +13,7 @@ import cn.wisenergy.model.vo.ReportCodeVo;
import
cn.wisenergy.service.Manager.AntiFakeManger
;
import
cn.wisenergy.service.Manager.AntiFakeManger
;
import
cn.wisenergy.service.app.AntiFakeService
;
import
cn.wisenergy.service.app.AntiFakeService
;
import
cn.wisenergy.service.util.CodeUtils
;
import
cn.wisenergy.service.util.CodeUtils
;
import
cn.wisenergy.service.util.ExcelUtils
;
import
cn.wisenergy.service.util.QRCodeUtils
;
import
cn.wisenergy.service.util.QRCodeUtils
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcel
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
...
@@ -203,15 +204,18 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
...
@@ -203,15 +204,18 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
return
R
.
ok
(
false
);
return
R
.
ok
(
false
);
}
}
//获取防伪
二维码生产
码
//获取防伪码
List
<
AntiFake
>
result
=
antiFakeMapper
.
getProductNos
(
array
);
List
<
AntiFake
>
result
=
antiFakeMapper
.
getProductNos
(
array
);
if
(
CollectionUtils
.
isEmpty
(
result
))
{
if
(
CollectionUtils
.
isEmpty
(
result
))
{
return
R
.
ok
(
0
,
true
);
return
R
.
ok
(
0
,
true
);
}
}
List
<
ReportCodeVo
>
resultBo
=
new
ArrayList
<>();
for
(
AntiFake
anti
:
result
)
{
for
(
AntiFake
anti
:
result
)
{
String
url
=
REQUEST_URL
+
anti
.
getShaValue
();
String
url
=
REQUEST_URL
+
anti
.
getShaValue
();
anti
.
setShaValue
(
url
);
ReportCodeVo
reportCodeVo
=
new
ReportCodeVo
();
reportCodeVo
.
setShaValue
(
url
);
resultBo
.
add
(
reportCodeVo
);
}
}
//生成Excel
//生成Excel
...
@@ -220,21 +224,13 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
...
@@ -220,21 +224,13 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setContentType
(
"application/vnd.ms-excel"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
// 使用java8新特性的stream流去处理数据,把空的数据过滤掉
List
<
ReportCodeVo
>
resultBo
=
new
ArrayList
<>();
for
(
AntiFake
antiFake
:
result
)
{
ReportCodeVo
reportCodeVo
=
new
ReportCodeVo
();
reportCodeVo
.
setShaValue
(
antiFake
.
getShaValue
());
resultBo
.
add
(
reportCodeVo
);
}
//创建文件名称
//创建文件名称
long
lon
=
System
.
currentTimeMillis
();
long
lon
=
System
.
currentTimeMillis
();
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
lon
+
".xlsx"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
lon
+
".xlsx"
);
// sheet名称
// sheet名称
EasyExcel
.
write
(
response
.
getOutputStream
(),
ReportCodeVo
.
class
).
sheet
(
Long
.
toString
(
lon
)).
doWrite
(
resultBo
);
EasyExcel
.
write
(
response
.
getOutputStream
(),
AntiFake
.
class
).
sheet
(
Long
.
toString
(
lon
)).
doWrite
(
resultBo
);
//修改二维码使用状态
//修改二维码使用状态
boolean
bool
=
antiFakeManger
.
updateAntiFake
(
array
);
boolean
bool
=
antiFakeManger
.
updateAntiFake
(
array
);
if
(!
bool
)
{
if
(!
bool
)
{
...
@@ -246,6 +242,34 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
...
@@ -246,6 +242,34 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
}
}
}
}
@Override
public
void
exportReceivable
(
String
str
,
HttpServletResponse
response
)
{
if
(
StringUtils
.
isBlank
(
str
)){
return
;
}
//把字符转化为数字
List
<
Long
>
array
=
StringUtil
.
strToLongArray
(
str
);
if
(
CollectionUtils
.
isEmpty
(
array
))
{
return
;
}
//获取防伪码
List
<
AntiFake
>
result
=
antiFakeMapper
.
getProductNos
(
array
);
if
(
CollectionUtils
.
isEmpty
(
result
))
{
return
;
}
List
<
ReportCodeVo
>
resultBo
=
new
ArrayList
<>();
for
(
AntiFake
anti
:
result
)
{
String
url
=
REQUEST_URL
+
anti
.
getShaValue
();
ReportCodeVo
reportCodeVo
=
new
ReportCodeVo
();
reportCodeVo
.
setShaValue
(
url
);
resultBo
.
add
(
reportCodeVo
);
}
ExcelUtils
.
export
(
response
,
resultBo
,
"aadfgh"
,
ReportCodeVo
.
class
);
}
/**
/**
* 分页处理方法
* 分页处理方法
*
*
...
...
This diff is collapsed.
Click to expand it.
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UserLevelTaskServiceImpl.java
View file @
208f9517
...
@@ -6,14 +6,11 @@ import cn.wisenergy.service.app.LastMonthUserInfoService;
...
@@ -6,14 +6,11 @@ import cn.wisenergy.service.app.LastMonthUserInfoService;
import
cn.wisenergy.service.app.MonthUserLevelService
;
import
cn.wisenergy.service.app.MonthUserLevelService
;
import
cn.wisenergy.service.app.UserLevelService
;
import
cn.wisenergy.service.app.UserLevelService
;
import
cn.wisenergy.service.app.UserLevelTaskService
;
import
cn.wisenergy.service.app.UserLevelTaskService
;
import
com.sun.org.apache.bcel.internal.generic.ARRAYLENGTH
;
import
com.xxl.job.core.handler.annotation.XxlJob
;
import
com.xxl.job.core.handler.annotation.XxlJob
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.xssf.model.IndexedUDFFinder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
@Service
@Service
...
...
This diff is collapsed.
Click to expand it.
wisenergy-service/src/main/java/cn/wisenergy/service/util/ExcelUtils.java
0 → 100644
View file @
208f9517
package
cn
.
wisenergy
.
service
.
util
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.write.metadata.style.WriteCellStyle
;
import
com.alibaba.excel.write.metadata.style.WriteFont
;
import
com.alibaba.excel.write.style.HorizontalCellStyleStrategy
;
import
com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy
;
import
io.undertow.util.Headers
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.springframework.http.MediaType
;
import
javax.servlet.http.HttpServletResponse
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.List
;
/**
* Excel工具类
*
* @author: ZHY
* @date: 2020-08-24 17:31
* @version:
**/
public
class
ExcelUtils
{
private
final
static
HorizontalCellStyleStrategy
HORIZONTAL_CELL_STYLE_STRATEGY
;
static
{
// 头的策略
WriteCellStyle
headWriteCellStyle
=
new
WriteCellStyle
();
WriteFont
headWriteFont
=
new
WriteFont
();
headWriteFont
.
setFontHeightInPoints
((
short
)
12
);
headWriteCellStyle
.
setWriteFont
(
headWriteFont
);
// 内容的策略
WriteCellStyle
contentWriteCellStyle
=
new
WriteCellStyle
();
contentWriteCellStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
contentWriteCellStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
contentWriteCellStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
contentWriteCellStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
contentWriteCellStyle
.
setHorizontalAlignment
(
HorizontalAlignment
.
CENTER
);
contentWriteCellStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
// 内容字体
WriteFont
contentWriteFont
=
new
WriteFont
();
// 字体大小
contentWriteFont
.
setFontHeightInPoints
((
short
)
11
);
contentWriteCellStyle
.
setWriteFont
(
contentWriteFont
);
// 这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现
HORIZONTAL_CELL_STYLE_STRATEGY
=
new
HorizontalCellStyleStrategy
(
headWriteCellStyle
,
contentWriteCellStyle
);
}
/**
* 导出
*
* @param response
* @param data 数据
* @param fileName 文件名
* @param t 导出对象
**/
public
static
<
T
>
void
export
(
HttpServletResponse
response
,
List
<
T
>
data
,
String
fileName
,
Class
<
T
>
t
)
{
try
{
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
response
.
setCharacterEncoding
(
StandardCharsets
.
UTF_8
.
name
());
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
response
.
setHeader
(
Headers
.
CONTENT_DISPOSITION_STRING
,
"attachment;filename="
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
)
+
".xlsx"
);
EasyExcel
.
write
(
response
.
getOutputStream
(),
t
)
.
registerWriteHandler
(
HORIZONTAL_CELL_STYLE_STRATEGY
)
.
registerWriteHandler
(
new
LongestMatchColumnWidthStyleStrategy
())
.
sheet
(
fileName
).
doWrite
(
data
);
}
catch
(
Exception
e
)
{
// 重置response
response
.
reset
();
throw
new
RuntimeException
(
"下载失败"
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/AntiFakeController.java
View file @
208f9517
...
@@ -36,13 +36,13 @@ public class AntiFakeController {
...
@@ -36,13 +36,13 @@ public class AntiFakeController {
return
antiFakeService
.
createCode
(
codeVo
);
return
antiFakeService
.
createCode
(
codeVo
);
}
}
@ApiOperation
(
value
=
"扫描防伪二维码"
,
notes
=
"扫描防伪二维码"
,
httpMethod
=
"
POS
T"
)
@ApiOperation
(
value
=
"扫描防伪二维码"
,
notes
=
"扫描防伪二维码"
,
httpMethod
=
"
GE
T"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"shaValue"
,
value
=
"防伪码"
,
dataType
=
"String"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"shaValue"
,
value
=
"防伪码"
,
dataType
=
"String"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"securityCode"
,
value
=
"安全码"
,
dataType
=
"String"
,
required
=
true
)
@ApiImplicitParam
(
name
=
"securityCode"
,
value
=
"安全码"
,
dataType
=
"String"
,
required
=
true
)
})
})
@ApiImplicitParam
(
name
=
"shaValue"
,
value
=
"防伪码"
,
dataType
=
"String"
)
@ApiImplicitParam
(
name
=
"shaValue"
,
value
=
"防伪码"
,
dataType
=
"String"
)
@
Pos
tMapping
(
"/admin/scanCode"
)
@
Ge
tMapping
(
"/admin/scanCode"
)
public
R
<
String
>
scanCode
(
String
shaValue
,
String
securityCode
)
{
public
R
<
String
>
scanCode
(
String
shaValue
,
String
securityCode
)
{
log
.
info
(
"shop-mall[]AntiFakeController[]scanCode[]input.param.shaValue:"
+
shaValue
,
securityCode
);
log
.
info
(
"shop-mall[]AntiFakeController[]scanCode[]input.param.shaValue:"
+
shaValue
,
securityCode
);
if
(
StringUtils
.
isBlank
(
shaValue
))
{
if
(
StringUtils
.
isBlank
(
shaValue
))
{
...
@@ -77,4 +77,16 @@ public class AntiFakeController {
...
@@ -77,4 +77,16 @@ public class AntiFakeController {
return
antiFakeService
.
report
(
ids
,
response
);
return
antiFakeService
.
report
(
ids
,
response
);
}
}
// @ApiOperation(value = "导出二维码", notes = "获取防伪二维码分页列表", httpMethod = "GET")
// @ApiImplicitParam(name = "ids", value = " 二维码主键id :\"1,2,3,4,5,6,7,8,9,\"", dataType = "String")
// @GetMapping("admin/antiFakeService")
// public void antiFakeService(String ids, HttpServletResponse response) {
// log.info("shop-mall[]AntiFakeController[]antiFakeService[]input.param.ids:" + ids);
// if (StringUtils.isBlank(ids)) {
// return ;
// }
//
// antiFakeService.exportReceivable(ids, response);
// }
}
}
This diff is collapsed.
Click to expand it.
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