Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
e4409308
Commit
e4409308
authored
Jul 08, 2019
by
周健威
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/base-modify' into base-modify
parents
d2082ec5
99da74fb
Changes
47
Hide whitespace changes
Inline
Side-by-side
Showing
47 changed files
with
3240 additions
and
63 deletions
+3240
-63
pom.xml
ace-common/pom.xml
+45
-0
ObjectRestResponse.java
...ithub/wxiaoqi/security/common/msg/ObjectRestResponse.java
+0
-3
UUIDUtils.java
...va/com/github/wxiaoqi/security/common/util/UUIDUtils.java
+19
-0
Excel2003Reader.java
...b/wxiaoqi/security/common/util/excel/Excel2003Reader.java
+275
-0
Excel2007Reader.java
...b/wxiaoqi/security/common/util/excel/Excel2007Reader.java
+667
-0
Excel2Html.java
...github/wxiaoqi/security/common/util/excel/Excel2Html.java
+426
-0
ExcelExport.java
...ithub/wxiaoqi/security/common/util/excel/ExcelExport.java
+610
-0
ExcelImport.java
...ithub/wxiaoqi/security/common/util/excel/ExcelImport.java
+152
-0
XssfDataType.java
...thub/wxiaoqi/security/common/util/excel/XssfDataType.java
+12
-0
systemconfig.properties
...mon/src/main/resources/properties/systemconfig.properties
+4
-4
AppUserDetail.java
...m/github/wxiaoqi/security/admin/entity/AppUserDetail.java
+20
-0
BaseUserRelation.java
...ithub/wxiaoqi/security/admin/entity/BaseUserRelation.java
+50
-0
UserFeign.java
...va/com/github/wxiaoqi/security/admin/feign/UserFeign.java
+3
-0
AppUserDTO.java
...m/github/wxiaoqi/security/admin/feign/dto/AppUserDTO.java
+35
-0
AppUserManageVo.java
...com/github/wxiaoqi/security/admin/vo/AppUserManageVo.java
+7
-6
AppUserVo.java
.../java/com/github/wxiaoqi/security/admin/vo/AppUserVo.java
+35
-0
AppUserDetailBiz.java
...m/github/wxiaoqi/security/admin/biz/AppUserDetailBiz.java
+1
-1
AppUserController.java
...github/wxiaoqi/security/admin/rest/AppUserController.java
+16
-7
AppPermissionService.java
...aoqi/security/admin/rpc/service/AppPermissionService.java
+6
-1
AppUserDetailMapper.xml
...e-admin/src/main/resources/mapper/AppUserDetailMapper.xml
+36
-26
IntegralRule.java
.../java/com/xxfc/platform/activity/entity/IntegralRule.java
+128
-0
IntegralSignRecord.java
...com/xxfc/platform/activity/entity/IntegralSignRecord.java
+47
-0
IntegralUserRecord.java
...com/xxfc/platform/activity/entity/IntegralUserRecord.java
+64
-0
IntegralUserTotal.java
.../com/xxfc/platform/activity/entity/IntegralUserTotal.java
+47
-0
ActivityFeign.java
.../java/com/xxfc/platform/activity/feign/ActivityFeign.java
+1
-1
UserInfoBiz.java
...ain/java/com/xxfc/platform/activity/user/UserInfoBiz.java
+29
-0
IntegralRuleBiz.java
.../java/com/xxfc/platform/activity/biz/IntegralRuleBiz.java
+77
-0
IntegralSignRecordBiz.java
...com/xxfc/platform/activity/biz/IntegralSignRecordBiz.java
+13
-0
IntegralUserRecordBiz.java
...com/xxfc/platform/activity/biz/IntegralUserRecordBiz.java
+62
-0
IntegralUserTotalBiz.java
.../com/xxfc/platform/activity/biz/IntegralUserTotalBiz.java
+100
-0
IntegralRuleMapper.java
...com/xxfc/platform/activity/mapper/IntegralRuleMapper.java
+10
-0
IntegralSignRecordMapper.java
...fc/platform/activity/mapper/IntegralSignRecordMapper.java
+7
-0
IntegralUserRecordMapper.java
...fc/platform/activity/mapper/IntegralUserRecordMapper.java
+7
-0
IntegralUserTotalMapper.java
...xfc/platform/activity/mapper/IntegralUserTotalMapper.java
+11
-0
IntegralRuleController.java
...m/xxfc/platform/activity/rest/IntegralRuleController.java
+48
-0
IntegralSignRecordController.java
.../platform/activity/rest/IntegralSignRecordController.java
+17
-0
IntegralUserRecordController.java
.../platform/activity/rest/IntegralUserRecordController.java
+17
-0
IntegralUserTotalController.java
...c/platform/activity/rest/IntegralUserTotalController.java
+11
-0
IntegralRuleMapper.xml
...y-server/src/main/resources/mapper/IntegralRuleMapper.xml
+45
-0
IntegralSignRecordMapper.xml
...er/src/main/resources/mapper/IntegralSignRecordMapper.xml
+14
-0
IntegralUserRecordMapper.xml
...er/src/main/resources/mapper/IntegralUserRecordMapper.xml
+18
-0
IntegralUserTotalMapper.xml
...ver/src/main/resources/mapper/IntegralUserTotalMapper.xml
+26
-0
AppVersionController.java
...java/com/xxfc/platform/app/rest/AppVersionController.java
+2
-2
BaseOrderController.java
...ava/com/xxfc/platform/order/rest/BaseOrderController.java
+1
-0
TourUserController.java
.../java/com/xxfc/platform/tour/rest/TourUserController.java
+12
-8
VehicleLicenseController.java
.../xxfc/platform/vehicle/rest/VehicleLicenseController.java
+3
-0
VehicleModelController.java
...om/xxfc/platform/vehicle/rest/VehicleModelController.java
+4
-4
No files found.
ace-common/pom.xml
View file @
e4409308
...
...
@@ -24,6 +24,7 @@
</build>
<properties>
<mapper.version>
3.4.0
</mapper.version>
<poi.version>
3.15
</poi.version>
</properties>
<dependencies>
...
...
@@ -125,6 +126,50 @@
<scope>
compile
</scope>
</dependency>
<!-- excel 组件 -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
${poi.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
${poi.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml-schemas
</artifactId>
<version>
${poi.version}
</version>
<exclusions>
<exclusion>
<artifactId>
stax-api
</artifactId>
<groupId>
stax
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
${poi.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.xmlbeans
</groupId>
<artifactId>
xmlbeans
</artifactId>
<version>
2.6.0
</version>
<exclusions>
<exclusion>
<artifactId>
stax-api
</artifactId>
<groupId>
stax
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<optional>
true
</optional>
</dependency>
</dependencies>
...
...
ace-common/src/main/java/com/github/wxiaoqi/security/common/msg/ObjectRestResponse.java
View file @
e4409308
...
...
@@ -16,9 +16,6 @@ public class ObjectRestResponse<T> extends BaseResponse {
private
static
final
Integer
WEB_CALL_RESULT_FAILED
=
ResultCode
.
FAILED_CODE
;
private
static
final
String
RESULT_SUCCESS_MSG
=
"操作成功"
;
private
static
final
String
RESULT_FAIL_MSG
=
"操作失败"
;
private
static
final
String
PARAM_IS_EMPTY
=
"参数为空"
;
public
boolean
isRel
()
{
return
rel
;
}
...
...
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/UUIDUtils.java
View file @
e4409308
...
...
@@ -14,6 +14,13 @@ public class UUIDUtils {
"W"
,
"X"
,
"Y"
,
"Z"
};
public
static
String
[]
chars1
=
new
String
[]
{
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
,
"h"
,
"i"
,
"j"
,
"k"
,
"l"
,
"m"
,
"n"
,
"p"
,
"q"
,
"r"
,
"s"
,
"t"
,
"u"
,
"v"
,
"w"
,
"x"
,
"y"
,
"z"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
,
"K"
,
"L"
,
"M"
,
"N"
,
"P"
,
"Q"
,
"R"
,
"S"
,
"T"
,
"U"
,
"V"
,
"W"
,
"X"
,
"Y"
,
"Z"
};
public
static
String
generateShortUuid
()
{
StringBuffer
shortBuffer
=
new
StringBuffer
();
String
uuid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
...
...
@@ -25,4 +32,16 @@ public class UUIDUtils {
return
shortBuffer
.
toString
();
}
public
static
String
genCodes
(
int
length
)
{
StringBuffer
shortBuffer
=
new
StringBuffer
();
String
uuid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
String
str
=
uuid
.
substring
(
i
*
4
,
i
*
4
+
4
);
int
x
=
Integer
.
parseInt
(
str
,
16
);
shortBuffer
.
append
(
chars1
[
x
%
0x3E
]);
}
return
shortBuffer
.
toString
();
}
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/excel/Excel2003Reader.java
0 → 100644
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
.
excel
;
import
org.apache.poi.hssf.eventusermodel.*
;
import
org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener
;
import
org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord
;
import
org.apache.poi.hssf.eventusermodel.dummyrecord.MissingCellDummyRecord
;
import
org.apache.poi.hssf.model.HSSFFormulaParser
;
import
org.apache.poi.hssf.record.*
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.poifs.filesystem.POIFSFileSystem
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* Excel2003格式解析
*
* @author lipengjun
* @email 939961241@qq.com
* @date 2017年10月28日 13:11:27
*/
public
class
Excel2003Reader
implements
HSSFListener
{
private
int
minColumns
=
-
1
;
private
POIFSFileSystem
fs
;
/**
* 最后一行行号
*/
private
int
lastRowNumber
;
/**
* 最后一列列号
*/
private
int
lastColumnNumber
;
/**
* Should we output the formula, or the value it has?
*/
private
boolean
outputFormulaValues
=
true
;
/**
* For parsing Formulas
*/
private
SheetRecordCollectingListener
workbookBuildingListener
;
// 工作薄
private
HSSFWorkbook
stubWorkbook
;
// Records we pick up as we process
private
SSTRecord
sstRecord
;
private
FormatTrackingHSSFListener
formatListener
;
// 表索引
private
int
sheetIndex
=
-
1
;
private
BoundSheetRecord
[]
orderedBSRs
;
@SuppressWarnings
(
"rawtypes"
)
private
ArrayList
boundSheetRecords
=
new
ArrayList
();
// For handling formulas with string results
private
int
nextRow
;
private
int
nextColumn
;
private
boolean
outputNextStringRecord
;
// 存储行记录的容器
private
List
<
String
>
rowlist
=
new
ArrayList
<
String
>();
;
// 单Sheet数据
private
List
<
String
[]>
sheetData
=
new
ArrayList
<
String
[]>();
// 多Sheet数据
private
Map
<
Integer
,
List
<
String
[]>>
workData
=
new
HashMap
<
Integer
,
List
<
String
[]>>();
/**
* 遍历excel下所有的sheet
*
* @param fileStream 处理文件流
* @throws IOException 抛出IO异常
*/
public
void
process
(
InputStream
fileStream
)
throws
IOException
{
this
.
fs
=
new
POIFSFileSystem
(
fileStream
);
MissingRecordAwareHSSFListener
listener
=
new
MissingRecordAwareHSSFListener
(
this
);
formatListener
=
new
FormatTrackingHSSFListener
(
listener
);
HSSFEventFactory
factory
=
new
HSSFEventFactory
();
HSSFRequest
request
=
new
HSSFRequest
();
if
(
outputFormulaValues
)
{
request
.
addListenerForAllRecords
(
formatListener
);
}
else
{
workbookBuildingListener
=
new
SheetRecordCollectingListener
(
formatListener
);
request
.
addListenerForAllRecords
(
workbookBuildingListener
);
}
factory
.
processWorkbookEvents
(
request
,
fs
);
}
/**
* HSSFListener 监听方法,处理 Record
*
* @param record 行记录
*/
@SuppressWarnings
(
"unchecked"
)
@Override
public
void
processRecord
(
Record
record
)
{
int
thisRow
=
-
1
;
int
thisColumn
=
-
1
;
String
thisStr
=
null
;
String
value
=
null
;
switch
(
record
.
getSid
())
{
case
BoundSheetRecord
.
sid
:
boundSheetRecords
.
add
(
record
);
break
;
case
BOFRecord
.
sid
:
BOFRecord
br
=
(
BOFRecord
)
record
;
if
(
br
.
getType
()
==
BOFRecord
.
TYPE_WORKSHEET
)
{
// 如果有需要,则建立子工作薄
if
(
workbookBuildingListener
!=
null
&&
stubWorkbook
==
null
)
{
stubWorkbook
=
workbookBuildingListener
.
getStubHSSFWorkbook
();
}
if
(
sheetIndex
>=
0
)
{
List
<
String
[]>
data
=
new
ArrayList
<
String
[]>();
data
.
addAll
(
sheetData
);
workData
.
put
(
sheetIndex
,
data
);
sheetData
.
clear
();
}
sheetIndex
++;
if
(
orderedBSRs
==
null
)
{
orderedBSRs
=
BoundSheetRecord
.
orderByBofPosition
(
boundSheetRecords
);
}
}
break
;
case
SSTRecord
.
sid
:
sstRecord
=
(
SSTRecord
)
record
;
break
;
case
BlankRecord
.
sid
:
BlankRecord
brec
=
(
BlankRecord
)
record
;
thisRow
=
brec
.
getRow
();
thisColumn
=
brec
.
getColumn
();
thisStr
=
""
;
rowlist
.
add
(
thisColumn
,
thisStr
);
break
;
case
BoolErrRecord
.
sid
:
// 单元格为布尔类型
BoolErrRecord
berec
=
(
BoolErrRecord
)
record
;
thisRow
=
berec
.
getRow
();
thisColumn
=
berec
.
getColumn
();
thisStr
=
berec
.
getBooleanValue
()
+
""
;
rowlist
.
add
(
thisColumn
,
thisStr
);
break
;
case
FormulaRecord
.
sid
:
// 单元格为公式类型
FormulaRecord
frec
=
(
FormulaRecord
)
record
;
thisRow
=
frec
.
getRow
();
thisColumn
=
frec
.
getColumn
();
if
(
outputFormulaValues
)
{
if
(
Double
.
isNaN
(
frec
.
getValue
()))
{
// Formula result is a string
// This is stored in the next record
outputNextStringRecord
=
true
;
nextRow
=
frec
.
getRow
();
nextColumn
=
frec
.
getColumn
();
}
else
{
thisStr
=
formatListener
.
formatNumberDateCell
(
frec
);
}
}
else
{
thisStr
=
'"'
+
HSSFFormulaParser
.
toFormulaString
(
stubWorkbook
,
frec
.
getParsedExpression
())
+
'"'
;
}
rowlist
.
add
(
thisColumn
,
thisStr
);
break
;
case
StringRecord
.
sid
:
// 单元格中公式的字符串
if
(
outputNextStringRecord
)
{
// String for formula
StringRecord
srec
=
(
StringRecord
)
record
;
thisStr
=
srec
.
getString
();
thisRow
=
nextRow
;
thisColumn
=
nextColumn
;
outputNextStringRecord
=
false
;
}
break
;
case
LabelRecord
.
sid
:
LabelRecord
lrec
=
(
LabelRecord
)
record
;
thisColumn
=
lrec
.
getColumn
();
value
=
lrec
.
getValue
().
trim
();
value
=
value
.
equals
(
""
)
?
" "
:
value
;
this
.
rowlist
.
add
(
thisColumn
,
value
);
break
;
case
LabelSSTRecord
.
sid
:
// 单元格为字符串类型
LabelSSTRecord
lsrec
=
(
LabelSSTRecord
)
record
;
thisColumn
=
lsrec
.
getColumn
();
if
(
sstRecord
==
null
)
{
rowlist
.
add
(
thisColumn
,
" "
);
}
else
{
value
=
sstRecord
.
getString
(
lsrec
.
getSSTIndex
()).
toString
().
trim
();
value
=
value
.
equals
(
""
)
?
" "
:
value
;
rowlist
.
add
(
thisColumn
,
value
);
}
break
;
case
NumberRecord
.
sid
:
// 单元格为数字类型
NumberRecord
numrec
=
(
NumberRecord
)
record
;
thisColumn
=
numrec
.
getColumn
();
value
=
formatListener
.
formatNumberDateCell
(
numrec
).
trim
();
value
=
value
.
equals
(
""
)
?
" "
:
value
;
// 向容器加入列值
rowlist
.
add
(
thisColumn
,
value
);
break
;
default
:
break
;
}
// 遇到新行的操作
if
(
thisRow
!=
-
1
&&
thisRow
!=
lastRowNumber
)
{
lastColumnNumber
=
-
1
;
}
// 空值的操作
if
(
record
instanceof
MissingCellDummyRecord
)
{
MissingCellDummyRecord
mc
=
(
MissingCellDummyRecord
)
record
;
thisColumn
=
mc
.
getColumn
();
rowlist
.
add
(
thisColumn
,
""
);
}
// 更新行和列的值
if
(
thisRow
>
-
1
)
{
lastRowNumber
=
thisRow
;
}
if
(
thisColumn
>
-
1
)
{
lastColumnNumber
=
thisColumn
;
}
// 行结束时的操作
if
(
record
instanceof
LastCellOfRowDummyRecord
)
{
if
(
minColumns
>
0
)
{
// 列值重新置空
if
(
lastColumnNumber
==
-
1
)
{
lastColumnNumber
=
0
;
}
}
lastColumnNumber
=
-
1
;
// 每行结束时, 数据写入集合
sheetData
.
add
(
rowlist
.
toArray
(
new
String
[]{}));
// 清空容器
rowlist
.
clear
();
}
}
/**
* 获取数据(单Sheet)
*
* @param sheetIndex sheet下标
* @return List<String[]> 数据
*/
public
List
<
String
[]>
getSheetData
(
Integer
sheetIndex
)
{
return
workData
.
get
(
sheetIndex
);
}
/**
* 获取数据(多Sheet)
*
* @return Map<Integer, List<String[]>> 多sheet的数据
*/
public
Map
<
Integer
,
List
<
String
[]>>
getSheetData
()
{
return
workData
;
}
}
\ No newline at end of file
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/excel/Excel2007Reader.java
0 → 100644
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
.
excel
;
import
org.apache.poi.hssf.usermodel.HSSFDateUtil
;
import
org.apache.poi.openxml4j.exceptions.InvalidFormatException
;
import
org.apache.poi.openxml4j.exceptions.OpenXML4JException
;
import
org.apache.poi.openxml4j.opc.OPCPackage
;
import
org.apache.poi.ss.usermodel.DataFormatter
;
import
org.apache.poi.xssf.eventusermodel.ReadOnlySharedStringsTable
;
import
org.apache.poi.xssf.eventusermodel.XSSFReader
;
import
org.apache.poi.xssf.model.StylesTable
;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle
;
import
org.apache.poi.xssf.usermodel.XSSFRichTextString
;
import
org.xml.sax.Attributes
;
import
org.xml.sax.InputSource
;
import
org.xml.sax.SAXException
;
import
org.xml.sax.XMLReader
;
import
org.xml.sax.helpers.DefaultHandler
;
import
javax.xml.parsers.ParserConfigurationException
;
import
javax.xml.parsers.SAXParser
;
import
javax.xml.parsers.SAXParserFactory
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* Excel2007解析器
*
* @author lipengjun
* @email 939961241@qq.com
* @date 2017年10月28日 13:11:27
*/
public
class
Excel2007Reader
extends
DefaultHandler
{
/**
* Table with unique strings
*/
private
ReadOnlySharedStringsTable
sharedStringsTable
;
/**
* 总共解析多少列
*/
private
final
int
minColumnCount
=
0
;
/**
* 判断是否值标签‘V’
*/
private
boolean
vIsOpen
;
/**
* 单元数据类型,startElement中确认赋值,endElement中使用判断
*/
private
XssfDataType
nextDataType
;
/**
* 当前解析列下标
*/
private
int
thisColumn
=
-
1
;
/**
* 已完成解析列最近下标
*/
private
int
lastColumnNumber
=
0
;
/**
* 单元格值内容临时存储
*/
private
StringBuffer
value
=
new
StringBuffer
();
/**
* 单行数据集合
*/
private
List
<
String
>
rowlist
=
new
ArrayList
<
String
>();
/**
* 当前sheet
*/
private
int
sheetIndex
=
-
1
;
/**
* 单Sheet数据
*/
private
List
<
String
[]>
sheetData
=
new
ArrayList
<
String
[]>();
/**
* 多Sheet数据
*/
private
Map
<
Integer
,
List
<
String
[]>>
workData
=
new
HashMap
<
Integer
,
List
<
String
[]>>();
private
DataFormatter
formatter
;
/**
* 格式索引暂时不用
*/
private
short
formatIndex
;
private
String
formatString
;
/**
* 样式表暂时不用
*/
private
StylesTable
stylesTable
;
/**
* 解析单Sheet内容
*
* @param strings 字符串
* @param sheetInputStream 输入流
* @throws IOException IO异常
* @throws ParserConfigurationException 解析异常
* @throws SAXException SAX异常
*/
private
void
processSheet
(
ReadOnlySharedStringsTable
strings
,
InputStream
sheetInputStream
)
throws
IOException
,
ParserConfigurationException
,
SAXException
{
sheetIndex
++;
this
.
sharedStringsTable
=
strings
;
InputSource
sheetSource
=
new
InputSource
(
sheetInputStream
);
SAXParserFactory
saxFactory
=
SAXParserFactory
.
newInstance
();
SAXParser
saxParser
=
saxFactory
.
newSAXParser
();
XMLReader
sheetParser
=
saxParser
.
getXMLReader
();
sheetParser
.
setContentHandler
(
this
);
sheetParser
.
parse
(
sheetSource
);
}
/**
* 解析多Sheet内容
* 异常处理暂时不完整
*
* @param fileStream 文件流
* @param isMuti 是否多个sheet
*/
public
void
process
(
InputStream
fileStream
,
boolean
isMuti
)
{
OPCPackage
xlsxPackage
;
try
{
xlsxPackage
=
OPCPackage
.
open
(
fileStream
);
ReadOnlySharedStringsTable
sharedStringsTable
=
new
ReadOnlySharedStringsTable
(
xlsxPackage
);
XSSFReader
xssfReader
=
new
XSSFReader
(
xlsxPackage
);
this
.
stylesTable
=
xssfReader
.
getStylesTable
();
this
.
formatter
=
new
DataFormatter
();
XSSFReader
.
SheetIterator
iter
=
(
XSSFReader
.
SheetIterator
)
xssfReader
.
getSheetsData
();
while
(
iter
.
hasNext
())
{
InputStream
stream
=
iter
.
next
();
processSheet
(
sharedStringsTable
,
stream
);
stream
.
close
();
List
<
String
[]>
data
=
new
ArrayList
<
String
[]>();
data
.
addAll
(
sheetData
);
workData
.
put
(
sheetIndex
,
data
);
sheetData
.
clear
();
if
(!
isMuti
)
{
// 如果只加载一个sheet内容,直接跳出循环
break
;
}
}
}
catch
(
InvalidFormatException
e
)
{
throw
new
RuntimeException
(
"解析EXCEL出错"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"解析EXCEL出错"
);
}
catch
(
SAXException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"解析EXCEL出错"
);
}
catch
(
OpenXML4JException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"解析EXCEL出错"
);
}
catch
(
ParserConfigurationException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"解析EXCEL出错"
);
}
}
/**
* Receive notification of the start of an element.
* <p>
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the start of
* each element (such as allocating a new tree node or writing
* output to a file).</p>
*
* @param uri The Namespace URI, or the empty string if the
* element has no Namespace URI or if Namespace
* processing is not being performed.
* @param localName The local name (without prefix), or the
* empty string if Namespace processing is not being
* performed.
* @param name The qualified name (with prefix), or the
* empty string if qualified names are not available.
* @param attributes The attributes attached to the element. If
* there are no attributes, it shall be an empty
* Attributes object.
* @throws SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.ContentHandler#startElement
*/
@Override
public
void
startElement
(
String
uri
,
String
localName
,
String
name
,
Attributes
attributes
)
throws
SAXException
{
if
(
"inlineStr"
.
equals
(
name
)
||
"v"
.
equals
(
name
))
{
// v=> value
vIsOpen
=
true
;
value
.
setLength
(
0
);
}
else
if
(
"c"
.
equals
(
name
))
{
// c => cell
vIsOpen
=
false
;
String
r
=
attributes
.
getValue
(
"r"
);
int
firstDigit
=
-
1
;
for
(
int
c
=
0
;
c
<
r
.
length
();
++
c
)
{
if
(
Character
.
isDigit
(
r
.
charAt
(
c
)))
{
firstDigit
=
c
;
break
;
}
}
thisColumn
=
nameToColumn
(
r
.
substring
(
0
,
firstDigit
));
this
.
nextDataType
=
XssfDataType
.
NUMBER
;
String
cellType
=
attributes
.
getValue
(
"t"
);
String
cellStyleStr
=
attributes
.
getValue
(
"s"
);
if
(
"b"
.
equals
(
cellType
))
{
nextDataType
=
XssfDataType
.
BOOL
;
}
else
if
(
"e"
.
equals
(
cellType
))
{
nextDataType
=
XssfDataType
.
ERROR
;
}
else
if
(
"inlineStr"
.
equals
(
cellType
))
{
nextDataType
=
XssfDataType
.
INLINESTR
;
}
else
if
(
"s"
.
equals
(
cellType
))
{
nextDataType
=
XssfDataType
.
SSTINDEX
;
}
else
if
(
"str"
.
equals
(
cellType
))
{
nextDataType
=
XssfDataType
.
FORMULA
;
}
else
if
(
cellStyleStr
!=
null
)
{
// if (cellStyleStr.equals("2")) {// 判断是否是日期
// nextDataType = XssfDataType.DATE;
// }
int
styleIndex
=
Integer
.
parseInt
(
cellStyleStr
);
XSSFCellStyle
style
=
stylesTable
.
getStyleAt
(
styleIndex
);
this
.
formatIndex
=
style
.
getDataFormat
();
this
.
formatString
=
style
.
getDataFormatString
();
if
(
formatIndex
==
14
||
formatIndex
==
15
||
formatIndex
==
16
||
formatIndex
==
17
)
{
nextDataType
=
XssfDataType
.
DATE
;
}
else
if
(
formatIndex
==
18
||
formatIndex
==
19
||
formatIndex
==
20
||
formatIndex
==
21
||
formatIndex
==
45
||
formatIndex
==
46
||
formatIndex
==
47
)
{
nextDataType
=
XssfDataType
.
TIME
;
}
else
if
(
formatIndex
==
22
)
{
nextDataType
=
XssfDataType
.
DATETIME
;
}
}
}
}
/**
* Receive notification of the end of an element.
* <p>
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the end of
* each element (such as finalising a tree node or writing
* output to a file).</p>
*
* @param uri The Namespace URI, or the empty string if the
* element has no Namespace URI or if Namespace
* processing is not being performed.
* @param localName The local name (without prefix), or the
* empty string if Namespace processing is not being
* performed.
* @param name The qualified name (with prefix), or the
* empty string if qualified names are not available.
* @throws SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.ContentHandler#endElement
*/
@Override
public
void
endElement
(
String
uri
,
String
localName
,
String
name
)
throws
SAXException
{
String
thisStr
=
null
;
// v标识单元格值标签
if
(
"v"
.
equals
(
name
))
{
// Process the value contents as required.
// Do now, as characters() may be called more than once
switch
(
nextDataType
)
{
case
BOOL:
char
first
=
value
.
charAt
(
0
);
thisStr
=
first
==
'0'
?
"FALSE"
:
"TRUE"
;
break
;
case
ERROR:
thisStr
=
"\"ERROR:"
+
value
.
toString
()
+
'"'
;
break
;
case
FORMULA:
// A formula could result in a string value,
// so always add double-quote characters.
thisStr
=
'"'
+
value
.
toString
()
+
'"'
;
break
;
case
INLINESTR:
// TODO: have seen an example of this, so it's untested.
XSSFRichTextString
rtsi
=
new
XSSFRichTextString
(
value
.
toString
());
thisStr
=
rtsi
.
toString
();
break
;
case
SSTINDEX:
String
sstIndex
=
value
.
toString
();
try
{
int
idx
=
Integer
.
parseInt
(
sstIndex
);
XSSFRichTextString
rtss
=
new
XSSFRichTextString
(
sharedStringsTable
.
getEntryAt
(
idx
));
thisStr
=
rtss
.
toString
();
}
catch
(
NumberFormatException
ex
)
{
// @TODO
}
break
;
case
NUMBER:
String
n
=
value
.
toString
();
BigDecimal
bd
=
new
BigDecimal
(
n
);
// 未移除最后的0,按默认string处理
thisStr
=
bd
.
toString
();
break
;
case
DATE:
Date
date
=
HSSFDateUtil
.
getJavaDate
(
Double
.
valueOf
(
value
.
toString
()));
thisStr
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
date
);
break
;
case
DATETIME:
Date
dateTime
=
HSSFDateUtil
.
getJavaDate
(
Double
.
valueOf
(
value
.
toString
()));
thisStr
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
dateTime
);
break
;
case
TIME:
Date
time
=
HSSFDateUtil
.
getJavaDate
(
Double
.
valueOf
(
value
.
toString
()));
thisStr
=
new
SimpleDateFormat
(
"HH:mm:ss"
).
format
(
time
);
break
;
default
:
thisStr
=
"(TODO: Unexpected type: "
+
nextDataType
+
")"
;
break
;
}
// 判定已解析列下标与当前下标差异,超过1则表示前面有空单元格,自动填入空串
for
(
int
i
=
lastColumnNumber
;
i
<
thisColumn
-
1
;
++
i
)
{
// 使用"" 作为空串
rowlist
.
add
(
""
);
}
rowlist
.
add
(
thisStr
);
// 更新已解析列下标
if
(
thisColumn
>
-
1
)
{
lastColumnNumber
=
thisColumn
;
}
}
else
if
(
"row"
.
equals
(
name
))
{
// 标识当前行结束,行数据写入结果
for
(
int
i
=
lastColumnNumber
;
i
<
(
this
.
minColumnCount
);
i
++)
{
rowlist
.
add
(
""
);
}
lastColumnNumber
=
-
1
;
sheetData
.
add
(
rowlist
.
toArray
(
new
String
[]{}));
rowlist
.
clear
();
}
}
/**
* 添加字符
*
* @param ch char[] 添加字符串
* @param start 开始位置
* @param length 长度
* @throws SAXException SAX异常
*/
@Override
public
void
characters
(
char
[]
ch
,
int
start
,
int
length
)
throws
SAXException
{
if
(
vIsOpen
)
{
value
.
append
(
ch
,
start
,
length
);
}
}
/**
* 获取当前列索引下标
*
* @param name 名字
* @return 整型
*/
private
int
nameToColumn
(
String
name
)
{
int
column
=
-
1
;
for
(
int
i
=
0
;
i
<
name
.
length
();
++
i
)
{
int
c
=
name
.
charAt
(
i
);
column
=
(
column
+
1
)
*
26
+
c
-
'A'
;
}
return
column
;
}
/**
* 获取数据(单Sheet)
*
* @param sheetIndex sheet下标
* @return List<String[]>
*/
public
List
<
String
[]>
getSheetData
(
Integer
sheetIndex
)
{
return
workData
.
get
(
sheetIndex
);
}
/**
* 获取数据(多Sheet)
*
* @return Map<Integer,List<String[]>> 对应列的Map
*/
public
Map
<
Integer
,
List
<
String
[]>>
getSheetData
()
{
return
workData
;
}
/**
* 取得sharedStringsTable的值
*
* @return sharedStringsTable值.
*/
public
ReadOnlySharedStringsTable
getSharedStringsTable
()
{
return
sharedStringsTable
;
}
/**
* 设定sharedStringsTable的值
*
* @param sharedStringsTable 设定值
*/
public
void
setSharedStringsTable
(
ReadOnlySharedStringsTable
sharedStringsTable
)
{
this
.
sharedStringsTable
=
sharedStringsTable
;
}
/**
* 取得vIsOpen的值
*
* @return vIsOpen值.
*/
public
boolean
isvIsOpen
()
{
return
vIsOpen
;
}
/**
* 设定vIsOpen的值
*
* @param vIsOpen 设定值
*/
public
void
setvIsOpen
(
boolean
vIsOpen
)
{
this
.
vIsOpen
=
vIsOpen
;
}
/**
* 取得nextDataType的值
*
* @return nextDataType值.
*/
public
XssfDataType
getNextDataType
()
{
return
nextDataType
;
}
/**
* 设定nextDataType的值
*
* @param nextDataType 设定值
*/
public
void
setNextDataType
(
XssfDataType
nextDataType
)
{
this
.
nextDataType
=
nextDataType
;
}
/**
* 取得thisColumn的值
*
* @return thisColumn值.
*/
public
int
getThisColumn
()
{
return
thisColumn
;
}
/**
* 设定thisColumn的值
*
* @param thisColumn 设定值
*/
public
void
setThisColumn
(
int
thisColumn
)
{
this
.
thisColumn
=
thisColumn
;
}
/**
* 取得lastColumnNumber的值
*
* @return lastColumnNumber值.
*/
public
int
getLastColumnNumber
()
{
return
lastColumnNumber
;
}
/**
* 设定lastColumnNumber的值
*
* @param lastColumnNumber 设定值
*/
public
void
setLastColumnNumber
(
int
lastColumnNumber
)
{
this
.
lastColumnNumber
=
lastColumnNumber
;
}
/**
* 取得value的值
*
* @return value值.
*/
public
StringBuffer
getValue
()
{
return
value
;
}
/**
* 设定value的值
*
* @param value 设定值
*/
public
void
setValue
(
StringBuffer
value
)
{
this
.
value
=
value
;
}
/**
* 取得rowlist的值
*
* @return rowlist值.
*/
public
List
<
String
>
getRowlist
()
{
return
rowlist
;
}
/**
* 设定rowlist的值
*
* @param rowlist 设定值
*/
public
void
setRowlist
(
List
<
String
>
rowlist
)
{
this
.
rowlist
=
rowlist
;
}
/**
* 取得sheetIndex的值
*
* @return sheetIndex值.
*/
public
int
getSheetIndex
()
{
return
sheetIndex
;
}
/**
* 设定sheetIndex的值
*
* @param sheetIndex 设定值
*/
public
void
setSheetIndex
(
int
sheetIndex
)
{
this
.
sheetIndex
=
sheetIndex
;
}
/**
* 取得workData的值
*
* @return workData值.
*/
public
Map
<
Integer
,
List
<
String
[]>>
getWorkData
()
{
return
workData
;
}
/**
* 设定workData的值
*
* @param workData 设定值
*/
public
void
setWorkData
(
Map
<
Integer
,
List
<
String
[]>>
workData
)
{
this
.
workData
=
workData
;
}
/**
* 取得formatter的值
*
* @return formatter值.
*/
public
DataFormatter
getFormatter
()
{
return
formatter
;
}
/**
* 设定formatter的值
*
* @param formatter 设定值
*/
public
void
setFormatter
(
DataFormatter
formatter
)
{
this
.
formatter
=
formatter
;
}
/**
* 取得formatIndex的值
*
* @return formatIndex值.
*/
public
short
getFormatIndex
()
{
return
formatIndex
;
}
/**
* 设定formatIndex的值
*
* @param formatIndex 设定值
*/
public
void
setFormatIndex
(
short
formatIndex
)
{
this
.
formatIndex
=
formatIndex
;
}
/**
* 取得formatString的值
*
* @return formatString值.
*/
public
String
getFormatString
()
{
return
formatString
;
}
/**
* 设定formatString的值
*
* @param formatString 设定值
*/
public
void
setFormatString
(
String
formatString
)
{
this
.
formatString
=
formatString
;
}
/**
* 取得stylesTable的值
*
* @return stylesTable值.
*/
public
StylesTable
getStylesTable
()
{
return
stylesTable
;
}
/**
* 设定stylesTable的值
*
* @param stylesTable 设定值
*/
public
void
setStylesTable
(
StylesTable
stylesTable
)
{
this
.
stylesTable
=
stylesTable
;
}
/**
* 取得minColumnCount的值
*
* @return minColumnCount值.
*/
public
int
getMinColumnCount
()
{
return
minColumnCount
;
}
/**
* 设定sheetData的值
*
* @param sheetData 设定值
*/
public
void
setSheetData
(
List
<
String
[]>
sheetData
)
{
this
.
sheetData
=
sheetData
;
}
}
\ No newline at end of file
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/excel/Excel2Html.java
0 → 100644
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
.
excel
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.hssf.util.HSSFColor
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.usermodel.*
;
import
java.io.*
;
import
java.math.BigDecimal
;
import
java.net.URLDecoder
;
import
java.text.DecimalFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 解析excel成html
*
* @author lipengjun
* @email 939961241@qq.com
* @date 2017年10月28日 13:11:27
*/
public
class
Excel2Html
{
public
static
void
main
(
String
[]
args
)
throws
UnsupportedEncodingException
{
// str = excelToHtml(realPath, "1.html");
String
path
=
Excel2Html
.
class
.
getResource
(
"."
).
getPath
();
String
realPath
=
URLDecoder
.
decode
(
path
,
"utf-8"
);
String
str
=
excelToHtml
(
realPath
+
"\\acctExport.xlsx"
);
System
.
out
.
println
(
str
);
}
public
static
String
excelToHtml
(
String
realPath
)
{
String
excelFile
=
realPath
;
//String htmlFile=realPath + "\\" + saveName + ".html";
InputStream
is
=
null
;
String
content
=
null
;
File
sourcefile
=
null
;
try
{
sourcefile
=
new
File
(
excelFile
);
is
=
new
FileInputStream
(
sourcefile
);
//此WorkbookFactory在POI-3.10版本中使用需要添加dom4j
Workbook
wb
=
WorkbookFactory
.
create
(
is
);
if
(
wb
instanceof
XSSFWorkbook
)
{
XSSFWorkbook
xWb
=
(
XSSFWorkbook
)
wb
;
eval
=
new
XSSFFormulaEvaluator
((
XSSFWorkbook
)
wb
);
content
=
getExcelInfo
(
xWb
,
true
);
}
else
if
(
wb
instanceof
HSSFWorkbook
)
{
HSSFWorkbook
hWb
=
(
HSSFWorkbook
)
wb
;
eval
=
new
HSSFFormulaEvaluator
((
HSSFWorkbook
)
wb
);
content
=
getExcelInfo
(
hWb
,
true
);
}
//writeFile(content, htmlFile);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
is
.
close
();
if
(
sourcefile
.
exists
())
{
//sourcefile.delete();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
content
;
}
private
static
FormulaEvaluator
eval
=
null
;
public
static
String
getExcelInfo
(
Workbook
wb
,
boolean
isWithStyle
)
{
StringBuffer
sb
=
new
StringBuffer
();
Sheet
sheet
=
wb
.
getSheetAt
(
0
);
//获取第一个Sheet的内容
int
lastRowNum
=
sheet
.
getLastRowNum
();
Map
<
String
,
String
>
map
[]
=
getRowSpanColSpanMap
(
sheet
);
sb
.
append
(
"<table style='border-collapse:collapse;' id='gv' width='100%'>"
);
Row
row
=
null
;
//兼容
Cell
cell
=
null
;
//兼容
for
(
int
rowNum
=
sheet
.
getFirstRowNum
();
rowNum
<=
lastRowNum
;
rowNum
++)
{
row
=
sheet
.
getRow
(
rowNum
);
if
(
row
==
null
)
{
sb
.
append
(
"<tr><td > </td></tr>"
);
continue
;
}
sb
.
append
(
"<tr>"
);
int
lastColNum
=
row
.
getLastCellNum
();
for
(
int
colNum
=
0
;
colNum
<
lastColNum
;
colNum
++)
{
cell
=
row
.
getCell
(
colNum
);
if
(
cell
==
null
)
{
//特殊情况 空白的单元格会返回null
sb
.
append
(
"<td> </td>"
);
continue
;
}
String
stringValue
=
getCellValueFormula
(
cell
,
eval
);
if
(
map
[
0
].
containsKey
(
rowNum
+
","
+
colNum
))
{
String
pointString
=
map
[
0
].
get
(
rowNum
+
","
+
colNum
);
map
[
0
].
remove
(
rowNum
+
","
+
colNum
);
int
bottomeRow
=
Integer
.
valueOf
(
pointString
.
split
(
","
)[
0
]);
int
bottomeCol
=
Integer
.
valueOf
(
pointString
.
split
(
","
)[
1
]);
int
rowSpan
=
bottomeRow
-
rowNum
+
1
;
int
colSpan
=
bottomeCol
-
colNum
+
1
;
sb
.
append
(
"<td rowspan= '"
+
rowSpan
+
"' colspan= '"
+
colSpan
+
"' "
);
}
else
if
(
map
[
1
].
containsKey
(
rowNum
+
","
+
colNum
))
{
map
[
1
].
remove
(
rowNum
+
","
+
colNum
);
continue
;
}
else
{
sb
.
append
(
"<td "
);
}
//判断是否需要样式
if
(
isWithStyle
)
{
dealExcelStyle
(
wb
,
sheet
,
cell
,
sb
);
//处理单元格样式
}
sb
.
append
(
">"
);
if
(
stringValue
==
null
||
""
.
equals
(
stringValue
.
trim
()))
{
sb
.
append
(
" "
);
}
else
{
// 将ascii码为160的空格转换为html下的空格( )
sb
.
append
(
stringValue
.
replace
(
String
.
valueOf
((
char
)
160
),
" "
));
}
sb
.
append
(
"</td>"
);
}
sb
.
append
(
"</tr>"
);
}
sb
.
append
(
"</table>"
);
return
sb
.
toString
();
}
private
static
Map
<
String
,
String
>[]
getRowSpanColSpanMap
(
Sheet
sheet
)
{
Map
<
String
,
String
>
map0
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
map1
=
new
HashMap
<
String
,
String
>();
int
mergedNum
=
sheet
.
getNumMergedRegions
();
CellRangeAddress
range
=
null
;
for
(
int
i
=
0
;
i
<
mergedNum
;
i
++)
{
range
=
sheet
.
getMergedRegion
(
i
);
int
topRow
=
range
.
getFirstRow
();
int
topCol
=
range
.
getFirstColumn
();
int
bottomRow
=
range
.
getLastRow
();
int
bottomCol
=
range
.
getLastColumn
();
map0
.
put
(
topRow
+
","
+
topCol
,
bottomRow
+
","
+
bottomCol
);
// System.out.println(topRow + "," + topCol + "," + bottomRow + "," + bottomCol);
int
tempRow
=
topRow
;
while
(
tempRow
<=
bottomRow
)
{
int
tempCol
=
topCol
;
while
(
tempCol
<=
bottomCol
)
{
map1
.
put
(
tempRow
+
","
+
tempCol
,
""
);
tempCol
++;
}
tempRow
++;
}
map1
.
remove
(
topRow
+
","
+
topCol
);
}
Map
[]
map
=
{
map0
,
map1
};
return
map
;
}
/**
* 获取表格单元格Cell内容
*
* @param cell
* @return
*/
private
static
String
getCellValue
(
Cell
cell
)
{
String
result
=
new
String
();
switch
(
cell
.
getCellType
())
{
// 数字类型
case
Cell
.
CELL_TYPE_NUMERIC
:
// 处理日期格式、时间格式
if
(
HSSFDateUtil
.
isCellDateFormatted
(
cell
))
{
SimpleDateFormat
sdf
=
null
;
if
(
cell
.
getCellStyle
().
getDataFormat
()
==
HSSFDataFormat
.
getBuiltinFormat
(
"h:mm"
))
{
sdf
=
new
SimpleDateFormat
(
"HH:mm"
);
}
else
{
// 日期
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
}
Date
date
=
cell
.
getDateCellValue
();
result
=
sdf
.
format
(
date
);
}
else
if
(
cell
.
getCellStyle
().
getDataFormat
()
==
58
)
{
// 处理自定义日期格式:m月d日(通过判断单元格的格式id解决,id的值是58)
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
double
value
=
cell
.
getNumericCellValue
();
Date
date
=
org
.
apache
.
poi
.
ss
.
usermodel
.
DateUtil
.
getJavaDate
(
value
);
result
=
sdf
.
format
(
date
);
}
else
if
(
cell
.
getCellStyle
().
getDataFormat
()
==
10
)
{
// 百分比格式的处理
cell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
String
value
=
cell
.
getStringCellValue
();
DecimalFormat
format
=
new
DecimalFormat
(
"#0.00%"
);
result
=
format
.
format
(
Double
.
parseDouble
(
value
));
}
else
if
(
cell
.
getCellStyle
().
getDataFormatString
().
equals
(
"0.0000%"
))
{
// 百分比格式的处理
cell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
String
value
=
cell
.
getStringCellValue
();
DecimalFormat
format
=
new
DecimalFormat
(
"#0.0000%"
);
result
=
format
.
format
(
Double
.
parseDouble
(
value
));
}
else
{
double
value
=
cell
.
getNumericCellValue
();
CellStyle
style
=
cell
.
getCellStyle
();
DecimalFormat
format
=
new
DecimalFormat
(
",##0.00########"
);
String
temp
=
style
.
getDataFormatString
();
// 单元格设置成常规
if
(
temp
.
equals
(
"General"
))
{
format
.
applyPattern
(
"#"
);
}
result
=
format
.
format
(
value
);
}
break
;
// String类型
case
Cell
.
CELL_TYPE_STRING
:
result
=
cell
.
getRichStringCellValue
().
toString
();
break
;
case
Cell
.
CELL_TYPE_BLANK
:
result
=
""
;
break
;
default
:
result
=
""
;
break
;
}
return
result
;
}
public
static
String
getCellValueFormula
(
Cell
cell
,
FormulaEvaluator
formulaEvaluator
)
{
if
(
cell
==
null
||
formulaEvaluator
==
null
)
{
return
null
;
}
if
(
cell
.
getCellType
()
==
Cell
.
CELL_TYPE_FORMULA
)
{
DecimalFormat
format
=
new
DecimalFormat
(
",##0.00########"
);
double
calcResult
=
formulaEvaluator
.
evaluate
(
cell
).
getNumberValue
();
return
format
.
format
(
new
BigDecimal
(
calcResult
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
));
}
return
getCellValue
(
cell
);
}
/**
* 处理表格样式
*
* @param wb
* @param sheet
* @param cell
* @param sb
*/
private
static
void
dealExcelStyle
(
Workbook
wb
,
Sheet
sheet
,
Cell
cell
,
StringBuffer
sb
)
{
CellStyle
cellStyle
=
cell
.
getCellStyle
();
if
(
cellStyle
!=
null
)
{
short
alignment
=
cellStyle
.
getAlignment
();
sb
.
append
(
"align='"
+
convertAlignToHtml
(
alignment
)
+
"' "
);
//单元格内容的水平对齐方式
short
verticalAlignment
=
cellStyle
.
getVerticalAlignment
();
sb
.
append
(
"valign='"
+
convertVerticalAlignToHtml
(
verticalAlignment
)
+
"' "
);
//单元格中内容的垂直排列方式
if
(
wb
instanceof
XSSFWorkbook
)
{
XSSFFont
xf
=
((
XSSFCellStyle
)
cellStyle
).
getFont
();
short
boldWeight
=
xf
.
getBoldweight
();
sb
.
append
(
"style='"
);
sb
.
append
(
"font-weight:"
+
boldWeight
+
";"
);
// 字体加粗
sb
.
append
(
"font-size: "
+
xf
.
getFontHeight
()
/
2
+
"%;"
);
// 字体大小
int
columnWidth
=
sheet
.
getColumnWidth
(
cell
.
getColumnIndex
());
sb
.
append
(
"width:"
+
columnWidth
+
"px;"
);
XSSFColor
xc
=
xf
.
getXSSFColor
();
if
(
xc
!=
null
&&
!
""
.
equals
(
xc
))
{
sb
.
append
(
"color:#"
+
xc
.
getARGBHex
().
substring
(
2
)
+
";"
);
// 字体颜色
}
XSSFColor
bgColor
=
(
XSSFColor
)
cellStyle
.
getFillForegroundColorColor
();
if
(
bgColor
!=
null
&&
!
""
.
equals
(
bgColor
))
{
sb
.
append
(
"background-color:#"
+
bgColor
.
getARGBHex
().
substring
(
2
)
+
";"
);
// 背景颜色
}
sb
.
append
(
getBorderStyle
(
0
,
cellStyle
.
getBorderTop
(),
((
XSSFCellStyle
)
cellStyle
).
getTopBorderXSSFColor
()));
sb
.
append
(
getBorderStyle
(
1
,
cellStyle
.
getBorderRight
(),
((
XSSFCellStyle
)
cellStyle
).
getRightBorderXSSFColor
()));
sb
.
append
(
getBorderStyle
(
2
,
cellStyle
.
getBorderBottom
(),
((
XSSFCellStyle
)
cellStyle
).
getBottomBorderXSSFColor
()));
sb
.
append
(
getBorderStyle
(
3
,
cellStyle
.
getBorderLeft
(),
((
XSSFCellStyle
)
cellStyle
).
getLeftBorderXSSFColor
()));
}
else
if
(
wb
instanceof
HSSFWorkbook
)
{
HSSFFont
hf
=
((
HSSFCellStyle
)
cellStyle
).
getFont
(
wb
);
short
boldWeight
=
hf
.
getBoldweight
();
short
fontColor
=
hf
.
getColor
();
sb
.
append
(
"style='"
);
HSSFPalette
palette
=
((
HSSFWorkbook
)
wb
).
getCustomPalette
();
// 类HSSFPalette用于求的颜色的国际标准形式
HSSFColor
hc
=
palette
.
getColor
(
fontColor
);
sb
.
append
(
"font-weight:"
+
boldWeight
+
";"
);
// 字体加粗
sb
.
append
(
"font-size: "
+
hf
.
getFontHeight
()
/
2
+
"%;"
);
// 字体大小
String
fontColorStr
=
convertToStardColor
(
hc
);
if
(
fontColorStr
!=
null
&&
!
""
.
equals
(
fontColorStr
.
trim
()))
{
sb
.
append
(
"color:"
+
fontColorStr
+
";"
);
// 字体颜色
}
int
columnWidth
=
sheet
.
getColumnWidth
(
cell
.
getColumnIndex
());
sb
.
append
(
"width:"
+
columnWidth
+
"px;"
);
short
bgColor
=
cellStyle
.
getFillForegroundColor
();
hc
=
palette
.
getColor
(
bgColor
);
String
bgColorStr
=
convertToStardColor
(
hc
);
if
(
bgColorStr
!=
null
&&
!
""
.
equals
(
bgColorStr
.
trim
()))
{
sb
.
append
(
"background-color:"
+
bgColorStr
+
";"
);
// 背景颜色
}
sb
.
append
(
getBorderStyle
(
palette
,
0
,
cellStyle
.
getBorderTop
(),
cellStyle
.
getTopBorderColor
()));
sb
.
append
(
getBorderStyle
(
palette
,
1
,
cellStyle
.
getBorderRight
(),
cellStyle
.
getRightBorderColor
()));
sb
.
append
(
getBorderStyle
(
palette
,
3
,
cellStyle
.
getBorderLeft
(),
cellStyle
.
getLeftBorderColor
()));
sb
.
append
(
getBorderStyle
(
palette
,
2
,
cellStyle
.
getBorderBottom
(),
cellStyle
.
getBottomBorderColor
()));
}
sb
.
append
(
"' "
);
}
}
/**
* 单元格内容的水平对齐方式
*
* @param alignment
* @return
*/
private
static
String
convertAlignToHtml
(
short
alignment
)
{
String
align
=
"left"
;
switch
(
alignment
)
{
case
CellStyle
.
ALIGN_LEFT
:
align
=
"left"
;
break
;
case
CellStyle
.
ALIGN_CENTER
:
align
=
"center"
;
break
;
case
CellStyle
.
ALIGN_RIGHT
:
align
=
"right"
;
break
;
default
:
break
;
}
return
align
;
}
/**
* 单元格中内容的垂直排列方式
*
* @param verticalAlignment
* @return
*/
private
static
String
convertVerticalAlignToHtml
(
short
verticalAlignment
)
{
String
valign
=
"middle"
;
switch
(
verticalAlignment
)
{
case
CellStyle
.
VERTICAL_BOTTOM
:
valign
=
"bottom"
;
break
;
case
CellStyle
.
VERTICAL_CENTER
:
valign
=
"center"
;
break
;
case
CellStyle
.
VERTICAL_TOP
:
valign
=
"top"
;
break
;
default
:
break
;
}
return
valign
;
}
private
static
String
convertToStardColor
(
HSSFColor
hc
)
{
StringBuffer
sb
=
new
StringBuffer
(
""
);
if
(
hc
!=
null
)
{
if
(
HSSFColor
.
AUTOMATIC
.
index
==
hc
.
getIndex
())
{
return
null
;
}
sb
.
append
(
"#"
);
for
(
int
i
=
0
;
i
<
hc
.
getTriplet
().
length
;
i
++)
{
sb
.
append
(
fillWithZero
(
Integer
.
toHexString
(
hc
.
getTriplet
()[
i
])));
}
}
return
sb
.
toString
();
}
private
static
String
fillWithZero
(
String
str
)
{
if
(
str
!=
null
&&
str
.
length
()
<
2
)
{
return
"0"
+
str
;
}
return
str
;
}
static
String
[]
bordesr
=
{
"border-top:"
,
"border-right:"
,
"border-bottom:"
,
"border-left:"
};
static
String
[]
borderStyles
=
{
"solid "
,
"solid "
,
"solid "
,
"solid "
,
"solid "
,
"solid "
,
"solid "
,
"solid "
,
"solid "
,
"solid"
,
"solid"
,
"solid"
,
"solid"
,
"solid"
};
private
static
String
getBorderStyle
(
HSSFPalette
palette
,
int
b
,
short
s
,
short
t
)
{
if
(
s
==
0
)
return
bordesr
[
b
]
+
borderStyles
[
s
]
+
"#d0d7e5 1px;"
;
;
String
borderColorStr
=
convertToStardColor
(
palette
.
getColor
(
t
));
borderColorStr
=
borderColorStr
==
null
||
borderColorStr
.
length
()
<
1
?
"#000000"
:
borderColorStr
;
return
bordesr
[
b
]
+
borderStyles
[
s
]
+
borderColorStr
+
" 1px;"
;
}
private
static
String
getBorderStyle
(
int
b
,
short
s
,
XSSFColor
xc
)
{
if
(
s
==
0
)
return
bordesr
[
b
]
+
borderStyles
[
s
]
+
"#d0d7e5 1px;"
;
;
if
(
xc
!=
null
&&
!
""
.
equals
(
xc
))
{
String
borderColorStr
=
xc
.
getARGBHex
();
//t.getARGBHex();
borderColorStr
=
borderColorStr
==
null
||
borderColorStr
.
length
()
<
1
?
"#000000"
:
borderColorStr
.
substring
(
2
);
return
bordesr
[
b
]
+
borderStyles
[
s
]
+
borderColorStr
+
" 1px;"
;
}
return
""
;
}
private
static
void
writeFile
(
String
content
,
String
path
)
{
OutputStream
os
=
null
;
BufferedWriter
bw
=
null
;
try
{
File
file
=
new
File
(
path
);
os
=
new
FileOutputStream
(
file
);
bw
=
new
BufferedWriter
(
new
OutputStreamWriter
(
os
));
bw
.
write
(
content
);
}
catch
(
FileNotFoundException
fnfe
)
{
fnfe
.
printStackTrace
();
}
catch
(
IOException
ioe
)
{
ioe
.
printStackTrace
();
}
finally
{
try
{
if
(
bw
!=
null
)
bw
.
close
();
if
(
os
!=
null
)
os
.
close
();
}
catch
(
IOException
ie
)
{
ie
.
printStackTrace
();
}
}
}
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/excel/ExcelExport.java
0 → 100644
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
.
excel
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.hssf.util.HSSFColor
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.math.BigDecimal
;
import
java.net.URLEncoder
;
import
java.sql.Timestamp
;
import
java.text.DecimalFormat
;
import
java.util.*
;
/**
* 导出EXCEL功能包主类
* 使用POI进行EXCEL导出的功能类。
* 目前简单处理,未设置内存优化。 数据量偏大,出现性能问题时再处理。
*
* @author lipengjun
* @email 939961241@qq.com
* @date 2017年10月28日 13:11:27
*/
public
class
ExcelExport
{
/**
* EXCEL 2003 扩展名
*/
public
static
final
String
EXCEL03_EXTENSION
=
".xls"
;
/**
* EXCEL 2007 扩展名
*/
public
static
final
String
EXCEL07_EXTENSION
=
".xlsx"
;
/**
* 工作表
*/
private
Workbook
workBook
;
/**
* 导出文件名
*/
private
String
exportFileName
;
/**
* 日志
*/
private
Log
logger
=
LogFactory
.
getLog
(
ExcelExport
.
class
);
/**
* 默认构造方法。
* 自动生成工作表。
*/
public
ExcelExport
()
{
this
(
"workbook.xlsx"
);
}
/**
* 指定导出文件名的构造方法
* 指定导出文件名。 同时根据指定文件名的扩展名确定导出格式是03或是07 。
* 不带扩展名默认为07格式。(POI 07格式支持内存优化)
*
* @param exportFileName 要导出的文件名(带扩展名。不带扩展名默认为07)
*/
public
ExcelExport
(
String
exportFileName
)
{
if
(
StringUtils
.
isBlank
(
exportFileName
))
{
exportFileName
=
"workbook.xlsx"
;
}
String
fileName
=
exportFileName
.
toLowerCase
();
// 根据文件名扩展名生成EXCEL格式。
if
(
fileName
.
endsWith
(
ExcelExport
.
EXCEL03_EXTENSION
))
{
workBook
=
new
HSSFWorkbook
();
}
else
if
(
exportFileName
.
endsWith
(
ExcelExport
.
EXCEL07_EXTENSION
))
{
workBook
=
new
XSSFWorkbook
();
}
else
{
workBook
=
new
XSSFWorkbook
();
fileName
+=
".xlsx"
;
// 按正则替换? 处理文件名最后一个字符为“.” 的问题
// fileName = fileName.replaceAll("..", ".");
}
// 最后按小写文件名输出
this
.
exportFileName
=
fileName
;
}
/**
* 主要功能: 导出EXCEL到response
* 注意事项:无
*
* @param response HttpServletResponse
*/
public
void
export
(
HttpServletResponse
response
)
{
// response.setHeader("Content-Disposition","attachment;filename=totalExcel.xls");
response
.
reset
();
response
.
setContentType
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"
);
// response.setContentType("text/html;charset=UTF-8");
// response.setContentType("APPLICATION/*");
String
fileName
=
null
;
// 处理编码
try
{
//modify by ld 2017年4月10日19:04:37 根据浏览器编码文件名
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
String
userAgent
=
request
.
getHeader
(
"User-Agent"
);
//针对IE或者以IE为内核的浏览器:
if
(
userAgent
.
contains
(
"MSIE"
)
||
userAgent
.
contains
(
"Trident"
))
{
fileName
=
URLEncoder
.
encode
(
exportFileName
,
"UTF-8"
);
}
else
{
//非IE浏览器的处理:
fileName
=
new
String
(
exportFileName
.
getBytes
(
"UTF-8"
),
"ISO-8859-1"
);
}
}
catch
(
UnsupportedEncodingException
e
)
{
fileName
=
"export.xls"
;
}
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
fileName
);
ServletOutputStream
output
;
try
{
output
=
response
.
getOutputStream
();
workBook
.
write
(
output
);
output
.
flush
();
output
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
"导出文件出错了"
,
e
);
throw
new
RuntimeException
(
"文件导出错误"
);
}
}
/**
* 主要功能:简单测试
* 注意事项:无
*
* @param args 参数
*/
public
static
void
main
(
String
[]
args
)
{
ExcelExport
ee1
=
new
ExcelExport
();
List
<
Object
[]>
list1
=
new
ArrayList
<
Object
[]>();
List
<
Object
>
obj
=
new
ArrayList
<
Object
>();
obj
.
add
(
"370681198002042214"
);
obj
.
add
(
new
Date
());
obj
.
add
(
new
Timestamp
(
System
.
currentTimeMillis
()));
obj
.
add
(
1
);
obj
.
add
(
11111111111111L
);
obj
.
add
(
123456.123456f
);
obj
.
add
(
123456789.12345678
);
obj
.
add
(
new
BigDecimal
(
"123456789123456789.1234"
));
obj
.
add
(
true
);
list1
.
add
(
obj
.
toArray
());
String
[]
header
=
new
String
[]{
"身份证号"
,
"日期"
,
"时间"
,
"整型"
,
"长整"
,
"浮点"
,
"双精度"
,
"大数"
,
"布尔"
};
ee1
.
addSheetByArray
(
"测试1"
,
list1
,
header
);
OutputStream
fis
;
try
{
fis
=
new
FileOutputStream
(
"D:\\test1.xlsx"
);
ee1
.
getWorkbook
().
write
(
fis
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
/**
* 主要功能: 在EXCEL中添加一个Sheet
* 注意事项:添加Sheet 并将List<Object[]> 中的数据填充
*
* @param sheetName 表单名字
* @param list 要填充的数据 以Object[] 表示单条记录
* @param colCaption 要生成的表头
*/
public
void
addSheetByArray
(
String
sheetName
,
List
<
Object
[]>
list
,
String
[]
colCaption
)
{
// 创建表单
Sheet
sheet
;
if
(
StringUtils
.
isBlank
(
sheetName
))
{
sheet
=
workBook
.
createSheet
();
}
else
{
sheet
=
workBook
.
createSheet
(
sheetName
);
}
// 生成标题行 (表头)
createCaptionRow
(
colCaption
,
sheet
);
// 记录列数
int
colNum
=
0
;
// 从第二行开始
int
startRow
=
1
;
for
(
Object
[]
obj
:
list
)
{
Row
row
=
sheet
.
createRow
(
startRow
++);
int
cols
=
createRowData
(
row
,
Arrays
.
asList
(
obj
));
row
.
setHeight
((
short
)
400
);
colNum
=
colNum
>
cols
?
colNum
:
cols
;
}
adjustCellWidth
(
colNum
,
startRow
,
sheet
);
}
/**
* 主要功能:在EXCEL中添加一个Sheet
* 注意事项:添加Sheet 并将List<Object[]> 中的数据填充
*
* @param sheetName 表单名字
* @param list 要填充的数据 以Map<String,Object> 表示单条记录
* @param colCaption 要生成的表头
*/
public
void
addSheetByMap
(
String
sheetName
,
List
<
Map
<
String
,
Object
>>
list
,
String
[]
colCaption
)
{
// 创建表单
Sheet
sheet
;
if
(
StringUtils
.
isBlank
(
sheetName
))
{
sheet
=
workBook
.
createSheet
();
}
else
{
sheet
=
workBook
.
createSheet
(
sheetName
);
}
// 生成标题行 (表头)
createCaptionRow
(
colCaption
,
sheet
);
int
colNum
=
0
;
// 转换数据
// 从第二行开始
int
startRow
=
1
;
for
(
Map
<
String
,
Object
>
map
:
list
)
{
Row
row
=
sheet
.
createRow
(
startRow
++);
int
cols
=
createRowData
(
row
,
map
.
values
());
row
.
setHeight
((
short
)
400
);
colNum
=
colNum
>
cols
?
colNum
:
cols
;
}
adjustCellWidth
(
colNum
,
startRow
,
sheet
);
// 处理宽度
}
/**
* 主要功能: 判断fiel
* 注意事项:无
*
* @param name 要判断的字符
* @param ignores 要忽略的数组
* @return 存在返回true
*/
private
boolean
isInIgnors
(
String
name
,
String
[]
ignores
)
{
for
(
String
ignore
:
ignores
)
{
if
(
name
.
equals
(
ignore
))
{
return
true
;
}
}
return
false
;
}
/**
* 主要功能: 生成每一行的数据
* 注意事项:无
*
* @param row 要处理的行
* @param coll 集合类型(List Map.values) 要处理的数据
* @return int 列数
*/
private
int
createRowData
(
Row
row
,
Collection
<
Object
>
coll
)
{
int
cellNum
=
0
;
for
(
Object
obj
:
coll
)
{
// 空值 按照 "" 字符串处理
if
(
obj
==
null
)
{
obj
=
""
;
}
// 转换一个字符串值, 以方便判断
String
strValue
=
obj
.
toString
();
// 创建单元格
Cell
cell
=
row
.
createCell
(
cellNum
);
// 根据单元格的类型设置值
// 公式型(普通BEAN和MAP中暂时并不存在)
if
(
strValue
.
startsWith
(
"FORMULA:"
))
{
}
else
{
// 处理宽度
// 设置单元格的值
setCellValue
(
cell
,
obj
);
}
// 处理下一个单元格
cellNum
++;
}
return
cellNum
;
}
/**
* 主要功能: 设置某单元格的值
* 注意事项: 同时根据值类型设置样式
* TODO: 对数字类型做进一步解析和判断。 对需要按%显示的进行处理。 %可以从表头中获取?
* 对于CellType 和CellValue 的设置还需要详细参考文档,避免产生不必要的错误转换
* 日期类型格式以通用格式。 待替换为全局变量
* 数字保留小数和显示百分比格式暂时未设置
*
* @param cell 单元格
* @param obj 原始值( null已转换为"" 空字符串)
*/
private
void
setCellValue
(
Cell
cell
,
Object
obj
)
{
CreationHelper
createHelper
=
workBook
.
getCreationHelper
();
String
strValue
=
obj
.
toString
();
// 时间戳类型 要先判断时间戳类型再判断时期类型
if
(
obj
instanceof
Timestamp
)
{
// 转换为Date后赋值
Date
dt
=
(
Timestamp
)
obj
;
// String value = DateUtil.format(dt, "yyyy-MM-dd HH:mm:ss");
CellStyle
cellStyle
=
workBook
.
createCellStyle
();
cellStyle
.
setDataFormat
(
createHelper
.
createDataFormat
().
getFormat
(
"yyyy-MM-dd HH:mm:ss"
));
cell
.
setCellValue
(
dt
);
cell
.
setCellStyle
(
cellStyle
);
}
// 日期型
else
if
(
obj
instanceof
Date
)
{
// String value = DateUtil.format((Date)obj, "yyyy-MM-dd");
// cell.setCellValue(value);
CellStyle
cellStyle
=
workBook
.
createCellStyle
();
cellStyle
.
setDataFormat
(
createHelper
.
createDataFormat
().
getFormat
(
"yyyy-MM-dd"
));
cell
.
setCellValue
((
Date
)
obj
);
cell
.
setCellStyle
(
cellStyle
);
}
/*
* 由于数字类型有int、long、double、BigDecimal 多种类型 输出格式可能要求数字、百分比、保留几位小数等多种格式. 目前仅按照数字格式输出
*/
else
if
(
obj
instanceof
Integer
)
{
cell
.
setCellType
(
CellType
.
NUMERIC
);
DecimalFormat
df
=
new
DecimalFormat
(
"0"
);
String
value
=
df
.
format
(
obj
);
cell
.
setCellValue
(
value
);
}
else
if
(
obj
instanceof
Long
)
{
cell
.
setCellType
(
CellType
.
NUMERIC
);
DecimalFormat
df
=
new
DecimalFormat
(
"0"
);
String
value
=
df
.
format
(
obj
);
cell
.
setCellValue
(
value
);
}
else
if
(
obj
instanceof
Float
)
{
cell
.
setCellType
(
CellType
.
NUMERIC
);
DecimalFormat
df
=
new
DecimalFormat
(
"0.0000"
);
String
value
=
df
.
format
(
obj
);
cell
.
setCellValue
(
value
);
}
else
if
(
obj
instanceof
Double
)
{
cell
.
setCellType
(
CellType
.
NUMERIC
);
DecimalFormat
df
=
new
DecimalFormat
(
"0.0000"
);
String
value
=
df
.
format
(
obj
);
cell
.
setCellValue
(
value
);
}
// BigDecimal
else
if
(
obj
instanceof
BigDecimal
)
{
cell
.
setCellType
(
CellType
.
STRING
);
cell
.
setCellValue
(
strValue
);
}
// 数字 //数字型要判断 对于百分比显示 、单位是万元等的显示细节要处理
// else if (StringUtil.isFloatNumeric(strValue)) {
// cell.setCellType(CellType.NUMERIC);
// 暂时未处理BigDecimal 类型的数据,如果有问题,只能使用String
// cell.setCellValue(Double.valueOf(strValue));
// modi by zhang @2016年11月14日14:13:11 处理浮点小数格式 暂时无法统一位数
// DecimalFormat df = new DecimalFormat("0.0000");
// String whatYourWant = df.format();
// 按String 方式输出数字
// BigDecimal bd = new BigDecimal(strValue);
// cell.setCellValue(bd.toPlainString());
// 主要处理小数的位数格式,暂时不好判断,输出原值
// cell.setCellValue(strValue);
// CellStyle style = workBook.createCellStyle();
// style.setDataFormat(workBook.createDataFormat().getFormat("0.00%"));
// }
// 字符串类型
else
if
(
obj
instanceof
String
)
{
// modi at 2016年11月14日14:27:51 by zhang
// 补充设置单元格类型,避免编码类被当作数字类型
cell
.
setCellType
(
CellType
.
STRING
);
// end modi
cell
.
setCellValue
(
strValue
);
}
else
{
cell
.
setCellType
(
CellType
.
STRING
);
cell
.
setCellValue
(
strValue
);
}
}
/**
* 主要功能: 生成EXCEL的第一行表头
* 注意事项: 默认按第一行生成表头。
*
* @param colCaption 表头字符数组
* @param sheet 表单
*/
private
void
createCaptionRow
(
String
[]
colCaption
,
Sheet
sheet
)
{
// 默认第一行
Row
row
=
sheet
.
createRow
(
0
);
row
.
setHeight
((
short
)
400
);
if
(
colCaption
==
null
)
{
return
;
}
// 按列生成表头
for
(
int
i
=
0
;
i
<
colCaption
.
length
;
i
++)
{
Cell
cell
=
row
.
createCell
(
i
);
cell
.
setCellStyle
(
getStyle
(
"title"
));
cell
.
setCellType
(
CellType
.
STRING
);
cell
.
setCellValue
(
colCaption
[
i
]);
}
}
/**
* 主要功能: 调整列宽
* 注意事项:无
*
* @param cols 列数
* @param rows 行数
* @param sheet sheet
*/
private
void
adjustCellWidth
(
int
cols
,
int
rows
,
Sheet
sheet
)
{
int
[]
cellWidth
=
new
int
[
cols
];
// 取列中最长的行
for
(
int
col
=
0
;
col
<
cols
;
col
++)
{
for
(
int
row
=
0
;
row
<
rows
;
row
++)
{
Cell
cell
=
sheet
.
getRow
(
row
).
getCell
(
col
);
String
value
=
getCellValue
(
cell
);
int
length
=
value
.
getBytes
().
length
;
if
(
length
>
cellWidth
[
col
])
{
cellWidth
[
col
]
=
length
;
}
}
}
for
(
int
j
=
0
;
j
<
cellWidth
.
length
;
j
++)
{
if
(
cellWidth
[
j
]
>
254
)
{
cellWidth
[
j
]
=
254
;
}
// 设置列宽度 单位为 1/256 个字符 设置加10%
sheet
.
setColumnWidth
(
j
,
cellWidth
[
j
]
*
12
>
255
?
(
255
*
256
/
10
)
:
(
cellWidth
[
j
]
*
12
*
256
/
10
));
}
}
/**
* 主要功能: 取单元格的值
* 注意事项:按数字和字符两种类型先处理。 BOOLEAN FORMULA 先不处理。 日期格式如何判断?
*
* @param cell 单元格
* @return 单元格的值
*/
@SuppressWarnings
(
"deprecation"
)
private
String
getCellValue
(
Cell
cell
)
{
String
value
=
""
;
try
{
// 按数字和字符两种类型先处理。 BOOLEAN FORMULA 先不处理。 日期格式如何判断?
switch
(
cell
.
getCellTypeEnum
())
{
case
NUMERIC:
value
=
cell
.
getNumericCellValue
()
+
"1111"
;
// 增加4位的长度
// 数字格式包含日期格式,但暂时无法判断日期格式
// 除非使用固定宽度。。。。。。。
break
;
case
STRING:
value
=
cell
.
getStringCellValue
();
break
;
default
:
break
;
}
}
catch
(
Exception
e
)
{
// 不对异常做处理。仅打印到控制台以供调试
// 占不打印
// e.printStackTrace();
}
return
value
;
}
/**
* 主要功能: 生成表头样式(默认样式)
* 注意事项:仅生成默认样式
*
* @param type 类型 title 或 data
* @return CellStyle
*/
private
CellStyle
getStyle
(
String
type
)
{
CellStyle
cs
=
workBook
.
createCellStyle
();
// 创建一个style
if
(
"title"
.
equals
(
type
))
{
// 表头样式
Font
font
=
workBook
.
createFont
();
// 创建一个字体
// font.setBoldweight(Font.BOLDWEIGHT_BOLD); // 粗体
font
.
setBold
(
true
);
// cs.setAlignment(CellStyle.ALIGN_CENTER);// 水平居中
cs
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
cs
.
setFillBackgroundColor
(
HSSFColor
.
SKY_BLUE
.
index
);
// 设置背景色
cs
.
setFont
(
font
);
}
return
cs
;
}
/**
* 取得wb的值
*
* @return wb值.
*/
public
Workbook
getWorkbook
()
{
return
workBook
;
}
/**
* 设定wb的值
*
* @param workBook 设定值
*/
public
void
setWorkbook
(
Workbook
workBook
)
{
this
.
workBook
=
workBook
;
}
/**
* 取得exportFileName的值
*
* @return exportFileName值.
*/
public
String
getExportFileName
()
{
return
exportFileName
;
}
/**
* 设定exportFileName的值
*
* @param exportFileName 设定值
*/
public
void
setExportFileName
(
String
exportFileName
)
{
this
.
exportFileName
=
exportFileName
;
}
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/excel/ExcelImport.java
0 → 100644
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
.
excel
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
/**
* Excel文件导入的基本功能类
* 可导入EXCEL2003 和 EXCEL2007格式。
*
* @author lipengjun
* @email 939961241@qq.com
* @date 2017年10月28日 13:11:27
*/
public
class
ExcelImport
{
/**
* excel2003扩展名
*/
public
static
final
String
EXCEL03_EXTENSION
=
".xls"
;
/**
* excel2007扩展名
*/
public
static
final
String
EXCEL07_EXTENSION
=
".xlsx"
;
private
ExcelImport
()
{
}
/**
* 解析EXCEL数据为 List<String[]>
*
* @param excelFile 要解析的上传EXCEL文件
* @return List<String[]) 行(列)
*/
public
static
List
<
String
[]>
getExcelData07
(
MultipartFile
excelFile
)
{
List
<
String
[]>
resultList
=
null
;
if
(
null
==
excelFile
||
excelFile
.
isEmpty
())
{
throw
new
RuntimeException
(
"文件内容为空!"
);
}
Excel2007Reader
excel07
=
new
Excel2007Reader
();
try
{
excel07
.
process
(
excelFile
.
getInputStream
(),
false
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"excel解析失败!"
);
}
resultList
=
excel07
.
getSheetData
(
0
);
return
resultList
;
}
/**
* 解析EXCEL数据为 List<String[]>
*
* @param excelFile 要解析的上传EXCEL文件
* @return List<String[]) 行(列)
*/
public
static
List
<
String
[]>
getExcelData03
(
MultipartFile
excelFile
)
{
List
<
String
[]>
resultList
=
null
;
if
(
null
==
excelFile
||
excelFile
.
isEmpty
())
{
throw
new
RuntimeException
(
"文件内容为空!"
);
}
Excel2003Reader
excel03
=
new
Excel2003Reader
();
// 实例化excel处理对象
try
{
excel03
.
process
(
excelFile
.
getInputStream
());
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"excel解析失败!"
);
}
resultList
=
excel03
.
getSheetData
(
0
);
return
resultList
;
}
/**
* 通过解析MultipartFile对象获取excel内容,并且将其拼装为List<String[]>对象返回
*
* @param excelFile
* @return
* @throws Exception
*/
public
static
List
<
String
[]>
getExcelData
(
MultipartFile
excelFile
)
throws
RuntimeException
{
List
<
String
[]>
resultList
=
null
;
if
(!
excelFile
.
isEmpty
())
{
// 上传的文件不能为空
String
excelFileName
=
excelFile
.
getOriginalFilename
();
// 文件名(带后缀)
if
(
excelFileName
.
toLowerCase
().
endsWith
(
EXCEL03_EXTENSION
))
{
// 如果文件是以.xls为后缀
Excel2003Reader
excel03
=
new
Excel2003Reader
();
// 实例化excel处理对象
try
{
excel03
.
process
(
excelFile
.
getInputStream
());
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"excel解析失败!"
);
}
resultList
=
excel03
.
getSheetData
(
0
);
}
else
if
(
excelFileName
.
toLowerCase
().
endsWith
(
EXCEL07_EXTENSION
))
{
// 如果文件是以.xlsx为后缀
Excel2007Reader
excel07
=
new
Excel2007Reader
();
try
{
excel07
.
process
(
excelFile
.
getInputStream
(),
false
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"excel解析失败!"
);
}
resultList
=
excel07
.
getSheetData
(
0
);
}
}
return
resultList
;
}
/**
* 通过解析MultipartFile对象获取excel内容,并且将其拼装为Map<Integer, List<String[]>>对象返回
*
* @param excelFile
* @return
* @throws Exception
*/
public
static
Map
<
Integer
,
List
<
String
[]>>
getExcelDataAll
(
MultipartFile
excelFile
)
throws
RuntimeException
{
Map
<
Integer
,
List
<
String
[]>>
result
=
null
;
if
(!
excelFile
.
isEmpty
())
{
// 上传的文件不能为空
String
excelFileName
=
excelFile
.
getOriginalFilename
();
// 文件名(带后缀)
if
(
excelFileName
.
toLowerCase
().
endsWith
(
EXCEL03_EXTENSION
))
{
// 如果文件是以.xls为后缀
Excel2003Reader
excel03
=
new
Excel2003Reader
();
// 实例化excel处理对象
try
{
excel03
.
process
(
excelFile
.
getInputStream
());
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"excel解析失败!"
);
}
result
=
excel03
.
getSheetData
();
}
else
if
(
excelFileName
.
toLowerCase
().
endsWith
(
EXCEL07_EXTENSION
))
{
// 如果文件是以.xlsx为后缀
Excel2007Reader
excel07
=
new
Excel2007Reader
();
try
{
excel07
.
process
(
excelFile
.
getInputStream
(),
true
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"excel解析失败!"
);
}
result
=
excel07
.
getSheetData
();
}
}
return
result
;
}
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/excel/XssfDataType.java
0 → 100644
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
.
excel
;
/**
* XSSFDataType
*
* @author lipengjun
* @email 939961241@qq.com
* @date 2017年10月28日 13:11:27
*/
public
enum
XssfDataType
{
BOOL
,
ERROR
,
FORMULA
,
INLINESTR
,
SSTINDEX
,
NUMBER
,
DATE
,
DATETIME
,
TIME
,
}
ace-common/src/main/resources/properties/systemconfig.properties
View file @
e4409308
...
...
@@ -13,10 +13,10 @@ USER_HEADER_URL_DEFAULT=https://xxtest.upyuns.com/image/app/default_%20avatar.pn
#默认昵称
USER_NIKENAME_DEFAULT
=
XX_
#短信机
ACCESSKEYID
=
LTAI
lXrgxOBAj2Ny
ACCESSKEYSECRET
=
zo8OkOCF4iygqOjYYoxRKfVRxDvgTI
TEMPLATECODE
=
SMS_1
66480010
SIGNNAME
=
升云
ACCESSKEYID
=
LTAI
nxMDwHQL8yg9
ACCESSKEYSECRET
=
OCKDEiwKGjePCZgPeWMEUFGwGbKYLA
TEMPLATECODE
=
SMS_1
70070101
SIGNNAME
=
滴房车
#微信支付配置
WINXIN_AppID
=
wxcc2c9b7c87439a6d
WINXIN_AppSecret
=
279796e8c2963c8a5ddc8270ef642b29
...
...
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/entity/AppUserDetail.java
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
entity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.persistence.Column
;
...
...
@@ -31,6 +32,7 @@ public class AppUserDetail {
private
Long
createtime
;
private
Long
updatetime
;
private
Integer
isdel
;
//渠道来源;1-app;2-小程序
private
Integer
channel
;
/**
* 省份编号
...
...
@@ -54,4 +56,22 @@ public class AppUserDetail {
*/
@Column
(
name
=
"upd_host"
)
private
String
updHost
;
@ApiModelProperty
(
value
=
"用户职位"
)
@Column
(
name
=
"position_id"
)
private
Integer
positionId
;
@ApiModelProperty
(
value
=
"用户来源:0-自来,1-用户邀请"
)
@Column
(
name
=
"source"
)
private
Integer
source
;
@ApiModelProperty
(
value
=
"邀请码"
)
@Column
(
name
=
"code"
)
private
String
code
;
@ApiModelProperty
(
value
=
"邀请人id:"
)
@Column
(
name
=
"inviter_account"
)
private
String
inviterAccount
;
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/entity/BaseUserRelation.java
→
ace-modules/ace-admin
-api
/src/main/java/com/github/wxiaoqi/security/admin/entity/BaseUserRelation.java
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
entity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.io.Serializable
;
import
javax.persistence.*
;
/**
...
...
@@ -11,6 +14,7 @@ import javax.persistence.*;
* @email 463540703@qq.com
* @date 2019-06-04 14:29:29
*/
@Data
@Table
(
name
=
"base_user_relation"
)
public
class
BaseUserRelation
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -42,90 +46,5 @@ public class BaseUserRelation implements Serializable {
//是否删除;0-正常;1-删除
@Column
(
name
=
"is_del"
)
private
Integer
isDel
;
/**
* 设置:主键id
*/
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
/**
* 获取:主键id
*/
public
Integer
getId
()
{
return
id
;
}
/**
* 设置:用户id
*/
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
/**
* 获取:用户id
*/
public
Integer
getUserId
()
{
return
userId
;
}
/**
* 设置:小程序用户id
*/
public
void
setToUid
(
Integer
toUid
)
{
this
.
toUid
=
toUid
;
}
/**
* 获取:小程序用户id
*/
public
Integer
getToUid
()
{
return
toUid
;
}
/**
* 设置:是否有效;0-有效;1-无效
*/
public
void
setStaus
(
Integer
staus
)
{
this
.
staus
=
staus
;
}
/**
* 获取:是否有效;0-有效;1-无效
*/
public
Integer
getStaus
()
{
return
staus
;
}
/**
* 设置:创建时间
*/
public
void
setCrtTime
(
Long
crtTime
)
{
this
.
crtTime
=
crtTime
;
}
/**
* 获取:创建时间
*/
public
Long
getCrtTime
()
{
return
crtTime
;
}
/**
* 设置:更新时间
*/
public
void
setUpdTime
(
Long
updTime
)
{
this
.
updTime
=
updTime
;
}
/**
* 获取:更新时间
*/
public
Long
getUpdTime
()
{
return
updTime
;
}
/**
* 设置:是否删除;0-正常;1-删除
*/
public
void
setIsDel
(
Integer
isDel
)
{
this
.
isDel
=
isDel
;
}
/**
* 获取:是否删除;0-正常;1-删除
*/
public
Integer
getIsDel
()
{
return
isDel
;
}
}
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/feign/UserFeign.java
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
feign
;
import
com.github.wxiaoqi.security.admin.dto.UserMemberDTO
;
import
com.github.wxiaoqi.security.admin.entity.AppUserLogin
;
import
com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel
;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
com.github.wxiaoqi.security.admin.feign.dto.UserDTO
;
...
...
@@ -99,5 +100,7 @@ public interface UserFeign {
@GetMapping
(
"/member/entityList"
)
public
ObjectRestResponse
<
List
<
BaseUserMemberLevel
>>
memberEntityList
(
@RequestParam
(
"entity"
)
Map
<
String
,
Object
>
entity
);
@GetMapping
(
"/app/user/one"
)
public
AppUserLogin
one
(
@RequestParam
(
value
=
"username"
)
String
username
);
}
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/feign/dto/AppUserDTO.java
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
feign
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
...
...
@@ -20,6 +21,40 @@ public class AppUserDTO {
private
String
birthday
;
private
String
personSign
;
private
String
remark
;
//渠道来源;1-app;2-小程序
private
Integer
channel
;
/**
* 省份编号
*/
private
Integer
provinceCode
;
/**
* 市编号
*/
private
Integer
cityCode
;
/**
* 创建ip
*/
private
String
crtHost
;
/**
* 更新ip
*/
private
String
updHost
;
@ApiModelProperty
(
value
=
"用户职位"
)
private
Integer
positionId
;
@ApiModelProperty
(
value
=
"用户来源:0-自来,1-用户邀请"
)
private
Integer
source
;
@ApiModelProperty
(
value
=
"邀请码"
)
private
String
code
;
@ApiModelProperty
(
value
=
"邀请人id:"
)
private
String
inviterAccount
;
private
Integer
imUserid
;
private
String
wxOpenid
;
private
String
unionid
;
...
...
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/vo/AppUserManageVo.java
View file @
e4409308
...
...
@@ -54,15 +54,16 @@ public class AppUserManageVo {
/**
* 邀请人id
*/
@Column
(
name
=
"Inviter_account"
)
private
Integer
InviterAccount
;
@Column
(
name
=
"inviter_account"
)
private
Integer
inviterAccount
;
/**
*
账号申请所在地
*
上
*/
@Column
(
name
=
"
address
"
)
private
String
address
;
@Column
(
name
=
"
province_code
"
)
private
String
provinceCode
;
@Column
(
name
=
"city_code"
)
private
String
cityCode
;
/**
* 用户性别
*/
...
...
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/vo/AppUserVo.java
View file @
e4409308
package
com
.
github
.
wxiaoqi
.
security
.
admin
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
...
...
@@ -46,5 +47,39 @@ public class AppUserVo {
private
String
personSign
;
//备注
private
String
remark
;
//渠道来源;1-app;2-小程序
private
Integer
channel
;
/**
* 省份编号
*/
private
Integer
provinceCode
;
/**
* 市编号
*/
private
Integer
cityCode
;
/**
* 创建ip
*/
private
String
crtHost
;
/**
* 更新ip
*/
private
String
updHost
;
@ApiModelProperty
(
value
=
"用户职位"
)
private
Integer
positionId
;
@ApiModelProperty
(
value
=
"用户来源:0-自来,1-用户邀请"
)
private
Integer
source
;
@ApiModelProperty
(
value
=
"邀请码"
)
private
String
code
;
@ApiModelProperty
(
value
=
"邀请人id:"
)
private
String
inviterAccount
;
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/AppUserDetailBiz.java
View file @
e4409308
...
...
@@ -68,7 +68,7 @@ public class AppUserDetailBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
BeanUtils
.
copyProperties
(
entity
,
userVo
);
if
(
entity
!=
null
){
entity
.
setUpdHost
(
AppPermissionService
.
getIp
());
entity
.
setUpdatetime
(
Instant
.
now
().
toEpochMilli
());
entity
.
setUpdatetime
(
Instant
.
now
().
toEpochMilli
()
/
1000L
);
super
.
updateSelectiveById
(
entity
);
}
}
catch
(
Exception
e
)
{
...
...
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rest/AppUserController.java
View file @
e4409308
...
...
@@ -3,14 +3,11 @@ package com.github.wxiaoqi.security.admin.rest;
import
com.ace.cache.annotation.Cache
;
import
com.github.wxiaoqi.security.admin.biz.AppUserBiz
;
import
com.github.wxiaoqi.security.admin.biz.AppUserDetailBiz
;
import
com.github.wxiaoqi.security.admin.biz.AppUserLoginBiz
;
import
com.github.wxiaoqi.security.admin.biz.BaseUserMemberBiz
;
import
com.github.wxiaoqi.security.admin.entity.AppUser
;
import
com.github.wxiaoqi.security.admin.entity.AppUserDetail
;
import
com.github.wxiaoqi.security.admin.entity.Group
;
import
com.github.wxiaoqi.security.admin.entity.User
;
import
com.github.wxiaoqi.security.admin.entity.*
;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
com.github.wxiaoqi.security.admin.vo.AppUserGroups
;
import
com.github.wxiaoqi.security.admin.vo.AppUserInfoVo
;
import
com.github.wxiaoqi.security.admin.vo.AppUserVo
;
import
com.github.wxiaoqi.security.admin.vo.UserMemberVo
;
import
com.github.wxiaoqi.security.auth.client.config.UserAuthConfig
;
...
...
@@ -24,8 +21,6 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -49,6 +44,9 @@ public class AppUserController extends CommonBaseController {
@Autowired
AppUserDetailBiz
userDetailBiz
;
@Autowired
AppUserLoginBiz
appUserLoginBiz
;
@Autowired
private
BaseUserMemberBiz
userMemberBiz
;
...
...
@@ -146,5 +144,16 @@ public class AppUserController extends CommonBaseController {
return
ObjectRestResponse
.
succ
();
}
/**
* 更新用户信息
* @param username
* @return
*/
@GetMapping
(
"/one"
)
public
AppUserLogin
one
(
@RequestParam
(
value
=
"username"
)
String
username
){
return
appUserLoginBiz
.
getUserByUsername
(
username
);
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/service/AppPermissionService.java
View file @
e4409308
...
...
@@ -15,11 +15,12 @@ import com.github.wxiaoqi.security.api.vo.user.AppUserInfo;
import
com.github.wxiaoqi.security.common.msg.BaseResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.EmojiFilter
;
import
com.github.wxiaoqi.security.common.util.UUIDUtils
;
import
com.github.wxiaoqi.security.common.util.VerificationUtils
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.github.wxiaoqi.security.common.util.process.SystemConfig
;
import
com.github.wxiaoqi.security.common.util.result.JsonResultUtil
;
import
com.xxfc.platform.activity.
F
eign.ActivityFeign
;
import
com.xxfc.platform.activity.
f
eign.ActivityFeign
;
import
com.xxfc.platform.im.feign.ImFeign
;
import
com.xxfc.platform.universal.dto.RegionDTO
;
import
com.xxfc.platform.universal.feign.RegionFeign
;
...
...
@@ -248,6 +249,8 @@ public class AppPermissionService {
rsUserDetail
.
setIsdel
(
0
);
rsUserDetail
.
setCrtHost
(
getIp
());
setCreateIPInfo
(
rsUserDetail
);
//生成邀请码
rsUserDetail
.
setCode
(
UUIDUtils
.
genCodes
(
6
));
appUserDetailBiz
.
insertSelective
(
rsUserDetail
);
log
.
error
(
"注册:新增用户详情: "
+
userid
);
//自动登录获取优惠卷
...
...
@@ -754,6 +757,8 @@ public class AppPermissionService {
rsUserDetail
.
setCreatetime
(
now
);
rsUserDetail
.
setUpdatetime
(
now
);
rsUserDetail
.
setIsdel
(
0
);
//生成邀请码
rsUserDetail
.
setCode
(
UUIDUtils
.
genCodes
(
6
));
//设置来源
rsUserDetail
.
setChannel
(
UserSourceEnum
.
APPLET
.
getCode
());
rsUserDetail
.
setCrtHost
(
getIp
());
...
...
ace-modules/ace-admin/src/main/resources/mapper/AppUserDetailMapper.xml
View file @
e4409308
<?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=
"com.github.wxiaoqi.security.admin.mapper.AppUserDetailMapper"
>
<resultMap
id=
"AppUserVoMap"
type=
"com.github.wxiaoqi.security.admin.vo.AppUserVo"
>
<result
column=
"id"
property=
"id"
/>
<result
column=
"userid"
property=
"userid"
/>
<result
column=
"im_userid"
property=
"imUserid"
/>
<result
column=
"username"
property=
"username"
/>
<result
column=
"wx_openid"
property=
"wxOpenid"
/>
<result
column=
"unionid"
property=
"unionid"
/>
<result
column=
"openid"
property=
"openid"
/>
<result
column=
"status"
property=
"status"
/>
<result
column=
"id_number"
property=
"idNumber"
/>
<result
column=
"certification_status"
property=
"certificationStatus"
/>
<result
column=
"is_member"
property=
"isMember"
/>
<result
column=
"nickname"
property=
"nickname"
/>
<result
column=
"realname"
property=
"realname"
/>
<result
column=
"headimgurl"
property=
"headimgurl"
/>
<result
column=
"birthday"
property=
"birthday"
/>
<result
column=
"email"
property=
"email"
/>
<result
column=
"sex"
property=
"sex"
/>
<result
column=
"person_sign"
property=
"personSign"
/>
<result
column=
"remark"
property=
"remark"
/>
</resultMap>
<resultMap
id=
"AppUserVoMap"
type=
"com.github.wxiaoqi.security.admin.vo.AppUserVo"
>
<result
column=
"id"
property=
"id"
/>
<result
column=
"userid"
property=
"userid"
/>
<result
column=
"im_userid"
property=
"imUserid"
/>
<result
column=
"username"
property=
"username"
/>
<result
column=
"wx_openid"
property=
"wxOpenid"
/>
<result
column=
"unionid"
property=
"unionid"
/>
<result
column=
"openid"
property=
"openid"
/>
<result
column=
"status"
property=
"status"
/>
<result
column=
"id_number"
property=
"idNumber"
/>
<result
column=
"certification_status"
property=
"certificationStatus"
/>
<result
column=
"is_member"
property=
"isMember"
/>
<result
column=
"nickname"
property=
"nickname"
/>
<result
column=
"realname"
property=
"realname"
/>
<result
column=
"headimgurl"
property=
"headimgurl"
/>
<result
column=
"birthday"
property=
"birthday"
/>
<result
column=
"email"
property=
"email"
/>
<result
column=
"sex"
property=
"sex"
/>
<result
column=
"person_sign"
property=
"personSign"
/>
<result
column=
"remark"
property=
"remark"
/>
<result
column=
"channel"
property=
"channel"
/>
<result
column=
"province_code"
property=
"provinceCode"
/>
<result
column=
"city_code"
property=
"cityCode"
/>
<result
column=
"crt_host"
property=
"crtHost"
/>
<result
column=
"upd_host"
property=
"updHost"
/>
<result
column=
"position_id"
property=
"positionId"
/>
<result
column=
"source"
property=
"source"
/>
<result
column=
"code"
property=
"code"
/>
<result
column=
"invitera_ccount"
property=
"inviterAccount"
/>
</resultMap>
<!-- 获取用户信息 -->
<select
id=
"getUserInfo"
resultMap=
"AppUserVoMap"
>
<!-- 获取用户信息 -->
<select
id=
"getUserInfo"
resultMap=
"AppUserVoMap"
>
select l.im_userid,l.username,l.wx_openid,l.unionid,l.openid,l.status,l.id_number,l.certification_status,d.* from app_user_login l
left join app_user_detail d
on d.userid = l.id
...
...
@@ -43,7 +52,8 @@
d.nickname,
d.source,
d.Inviter_account,
d.address,
d.province_code,
d.city_code,
d.sex,
d.email,
l.username,
...
...
@@ -75,7 +85,7 @@
base_user_member_level ml
on
ml.id = b.member_level
)
m
) m
on
l.id = m.user_id
where 1=1
...
...
@@ -97,7 +107,7 @@
</if>
</select>
</select>
</mapper>
\ No newline at end of file
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/entity/IntegralRule.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
entity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.math.BigDecimal
;
@Table
(
name
=
"integral_rule"
)
@Data
public
class
IntegralRule
{
/**
* 主键id
*/
@Id
private
Integer
id
;
/**
* 周期单位:0-天,1-周;3-月;4-季;5-年
*/
private
Integer
period
;
/**
* 次数
*/
private
Integer
number
;
/**
* 积分
*/
private
Integer
point
;
/**
* 积分兑换:金额/分
*/
private
BigDecimal
price
;
/**
* 是否连续:0-不连续;1-连续
*/
@Column
(
name
=
"is_continuity"
)
private
Boolean
isContinuity
;
/**
* 多少天后连续算
*/
@Column
(
name
=
"finish_day"
)
private
Integer
finishDay
;
/**
* n天获取的积分
*/
@Column
(
name
=
"finish_point"
)
private
Integer
finishPoint
;
/**
* 是否启用:1-启用;0-停用
*/
private
Boolean
status
;
/**
* 创建时间
*/
@Column
(
name
=
"crt_time"
)
private
Long
crtTime
;
/**
* 是否删除:0-正常;1-删除
*/
private
Boolean
isdel
;
/**
* 规则开始时间
*/
@Column
(
name
=
"start_time"
)
private
Long
startTime
;
/**
* 规则结束时间
*/
@Column
(
name
=
"end_time"
)
private
Long
endTime
;
/**
* 更新时间
*/
@Column
(
name
=
"upd_time"
)
private
Long
updTime
;
/**
* 备注
*/
private
String
remarks
;
/**
* 描述
*/
private
String
desc
;
/**
* 规则图片
*/
private
String
img
;
/**
* 排序
*/
@Column
(
name
=
"order_id"
)
private
Integer
orderId
;
/**
* 规则名称
*/
private
String
name
;
/**
* 获取积分规则
*/
private
String
regulation
;
/**
* json字符串 如:[{"day":4,"integeral":8},{"day":4,"integeral":8}]
*/
@Column
(
name
=
"other_rule"
)
private
String
otherRule
;
}
\ No newline at end of file
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/entity/IntegralSignRecord.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
entity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
@Table
(
name
=
"integral_sign_record"
)
@Data
public
class
IntegralSignRecord
{
/**
* 主键id
*/
@Id
private
Integer
id
;
/**
* 用户id
*/
@Column
(
name
=
"user_id"
)
private
Integer
userId
;
/**
* 连续签到天数
*/
@Column
(
name
=
"sign_days"
)
private
Integer
signDays
;
/**
* 开始时间
*/
@Column
(
name
=
"start_time"
)
private
Long
startTime
;
/**
* 最后签到时间
*/
@Column
(
name
=
"last_time"
)
private
Long
lastTime
;
/**
* 是否删除:0-正常;1-删除
*/
private
Boolean
isdel
;
}
\ No newline at end of file
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/entity/IntegralUserRecord.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
entity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
@Table
(
name
=
"integral_user_record"
)
@Data
public
class
IntegralUserRecord
{
/**
* 主键id
*/
@Id
private
Integer
id
;
/**
* 用户id
*/
@Column
(
name
=
"user_id"
)
private
Integer
userId
;
/**
* 0-获取积分;1-抵扣积分
*/
private
Boolean
type
;
/**
* 积分数
*/
private
Integer
point
;
/**
* 积分规则id
*/
@Column
(
name
=
"integral_rule_id"
)
private
Integer
integralRuleId
;
/**
* 积分时间
*/
@Column
(
name
=
"crt_time"
)
private
Long
crtTime
;
/**
* 是否有效:1-有效;0-失效
*/
@Column
(
name
=
"is_valid"
)
private
Boolean
isValid
;
/**
* 是否删除:0-正常;1-删除
*/
private
Boolean
isdel
;
/**
* 获取积分的途径id:如订单id,评论id,签到记录id
*/
@Column
(
name
=
"channel_id"
)
private
Integer
channelId
;
}
\ No newline at end of file
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/entity/IntegralUserTotal.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
entity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
@Table
(
name
=
"integral_user_total"
)
@Data
public
class
IntegralUserTotal
{
/**
* 主键id
*/
@Id
private
Integer
id
;
/**
* 用户id
*/
@Column
(
name
=
"user_id"
)
private
Integer
userId
;
/**
* 总收益积分
*/
@Column
(
name
=
"total_point"
)
private
Integer
totalPoint
;
/**
* 剩余收益积分
*/
@Column
(
name
=
"rest_point"
)
private
Integer
restPoint
;
@Column
(
name
=
"crt_time"
)
private
Long
crtTime
;
@Column
(
name
=
"upd_time"
)
private
Long
updTime
;
/**
* 是否删除:0-正常;1-删除
*/
private
Boolean
isdel
;
}
\ No newline at end of file
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/
F
eign/ActivityFeign.java
→
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/
f
eign/ActivityFeign.java
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
F
eign
;
package
com
.
xxfc
.
platform
.
activity
.
f
eign
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.activity.vo.UserCouponVo
;
...
...
xx-activity/xx-activity-api/src/main/java/com/xxfc/platform/activity/user/UserInfoBiz.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
user
;
import
com.github.wxiaoqi.security.admin.feign.UserFeign
;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
@Slf4j
@Component
public
class
UserInfoBiz
{
@Autowired
UserFeign
userFeign
;
public
AppUserDTO
getUserInfo
()
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
if
(
request
.
getHeader
(
"Authorization"
)
!=
null
)
{
return
userFeign
.
userDetailByToken
(
request
.
getHeader
(
"Authorization"
)).
getData
();
}
else
if
(
request
.
getHeader
(
"access_token"
)
!=
null
)
{
return
userFeign
.
userDetailByToken
(
request
.
getHeader
(
"access_token"
)).
getData
();
}
return
null
;
}
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/IntegralRuleBiz.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
biz
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.activity.entity.IntegralRule
;
import
com.xxfc.platform.activity.mapper.IntegralRuleMapper
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
@Service
@Transactional
public
class
IntegralRuleBiz
extends
BaseBiz
<
IntegralRuleMapper
,
IntegralRule
>
{
/**
* 添加、更新积分规则
* @param integralRule
* @return
*/
public
ObjectRestResponse
add
(
IntegralRule
integralRule
)
{
if
(
integralRule
==
null
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
}
if
(
integralRule
.
getId
()
!=
null
)
{
//已存在,更新
IntegralRule
oldValue
=
mapper
.
selectByPrimaryKey
(
integralRule
.
getId
());
if
(
oldValue
==
null
)
{
return
ObjectRestResponse
.
createDefaultFail
();
}
BeanUtil
.
copyProperties
(
integralRule
,
oldValue
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
).
setIgnoreError
(
true
));
mapper
.
updateByPrimaryKeySelective
(
oldValue
);
return
ObjectRestResponse
.
succ
();
}
mapper
.
insertSelective
(
integralRule
);
return
ObjectRestResponse
.
succ
();
}
/**
* 删除积分规则
* @param id
* @return
*/
public
ObjectRestResponse
deleteOne
(
Integer
id
)
{
if
(
id
==
null
||
id
<
0
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
}
IntegralRule
oldValue
=
mapper
.
selectByPrimaryKey
(
id
);
if
(
oldValue
==
null
)
{
return
ObjectRestResponse
.
createDefaultFail
();
}
oldValue
.
setIsdel
(
true
);
mapper
.
updateByPrimaryKeySelective
(
oldValue
);
return
ObjectRestResponse
.
succ
();
}
public
ObjectRestResponse
<
IntegralRule
>
getOne
(
IntegralRule
integralRule
)
{
if
(
integralRule
==
null
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
}
IntegralRule
oldValue
=
mapper
.
selectByPrimaryKey
(
integralRule
.
getId
());
if
(
oldValue
==
null
)
{
return
ObjectRestResponse
.
createDefaultFail
();
}
return
ObjectRestResponse
.
succ
(
oldValue
);
}
public
ObjectRestResponse
<
List
<
IntegralRule
>>
getAll
(
IntegralRule
integralRule
)
{
List
<
IntegralRule
>
integralRules
=
mapper
.
selectAllByParam
(
integralRule
);
return
ObjectRestResponse
.
succ
(
integralRules
);
}
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/IntegralSignRecordBiz.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
biz
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.xxfc.platform.activity.entity.IntegralSignRecord
;
import
com.xxfc.platform.activity.mapper.IntegralSignRecordMapper
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
@Transactional
public
class
IntegralSignRecordBiz
extends
BaseBiz
<
IntegralSignRecordMapper
,
IntegralSignRecord
>
{
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/IntegralUserRecordBiz.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
biz
;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.activity.entity.IntegralUserRecord
;
import
com.xxfc.platform.activity.mapper.IntegralUserRecordMapper
;
import
com.xxfc.platform.activity.user.UserInfoBiz
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
@Transactional
@Slf4j
public
class
IntegralUserRecordBiz
extends
BaseBiz
<
IntegralUserRecordMapper
,
IntegralUserRecord
>
{
@Autowired
UserInfoBiz
userInfoBiz
;
/**
* 添加用户积分记录
* @param integralUserRecord
* @return
*/
public
ObjectRestResponse
add
(
IntegralUserRecord
integralUserRecord
)
{
return
ObjectRestResponse
.
succ
();
}
/**
* 删除一个用户记录
* @param id
* @return
*/
public
ObjectRestResponse
deleteOne
(
Integer
id
)
{
if
(
id
==
null
||
id
<=
0
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
}
IntegralUserRecord
integralUserRecord
=
mapper
.
selectByPrimaryKey
(
id
);
if
(
integralUserRecord
==
null
)
{
log
.
info
(
"删除的用户记录不存在,要删除的id ={}"
,
id
);
return
ObjectRestResponse
.
createDefaultFail
();
}
integralUserRecord
.
setIsdel
(
true
);
mapper
.
updateByPrimaryKeySelective
(
integralUserRecord
);
return
ObjectRestResponse
.
succ
();
}
/**
* 根据获取某个用户的列表
* @return
*/
public
ObjectRestResponse
<
IntegralUserRecord
>
getUserList
()
{
AppUserDTO
appUserDTO
=
userInfoBiz
.
getUserInfo
();
if
(
appUserDTO
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
508
,
"token is null or invalid"
);
}
return
ObjectRestResponse
.
succ
();
}
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/IntegralUserTotalBiz.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
biz
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.activity.entity.IntegralUserTotal
;
import
com.xxfc.platform.activity.mapper.IntegralUserTotalMapper
;
import
com.xxfc.platform.activity.user.UserInfoBiz
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
@Service
@Transactional
public
class
IntegralUserTotalBiz
extends
BaseBiz
<
IntegralUserTotalMapper
,
IntegralUserTotal
>
{
@Autowired
UserInfoBiz
userInfoBiz
;
/**
* 添加用户总积分
* @param integralUserTotal
* @return
*/
public
ObjectRestResponse
add
(
IntegralUserTotal
integralUserTotal
)
{
AppUserDTO
appUserDTO
=
userInfoBiz
.
getUserInfo
();
if
(
appUserDTO
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
508
,
"token is null or invalid"
);
}
if
(
integralUserTotal
==
null
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
}
integralUserTotal
.
setUserId
(
appUserDTO
.
getUserid
());
if
(
integralUserTotal
.
getId
()
!=
null
)
{
IntegralUserTotal
oldValue
=
mapper
.
selectByPrimaryKey
(
integralUserTotal
.
getId
());
if
(
oldValue
==
null
)
{
return
ObjectRestResponse
.
createDefaultFail
();
}
BeanUtil
.
copyProperties
(
integralUserTotal
,
oldValue
,
CopyOptions
.
create
().
setIgnoreNullValue
(
true
).
setIgnoreError
(
true
));
mapper
.
updateByPrimaryKeySelective
(
oldValue
);
return
ObjectRestResponse
.
succ
();
}
mapper
.
insertSelective
(
integralUserTotal
);
return
ObjectRestResponse
.
succ
();
}
/**
* 删除信息
* @param id
* @return
*/
public
ObjectRestResponse
deleteOne
()
{
AppUserDTO
appUserDTO
=
userInfoBiz
.
getUserInfo
();
if
(
appUserDTO
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
508
,
"token is null or invalid"
);
}
IntegralUserTotal
integralUserTotal
=
new
IntegralUserTotal
();
integralUserTotal
.
setUserId
(
appUserDTO
.
getUserid
());
List
<
IntegralUserTotal
>
oldValue
=
mapper
.
selectAllByParam
(
integralUserTotal
);
if
(
oldValue
==
null
||
oldValue
.
size
()
<=
0
)
{
return
ObjectRestResponse
.
createDefaultFail
();
}
oldValue
.
get
(
0
).
setIsdel
(
true
);
mapper
.
updateByPrimaryKeySelective
(
oldValue
.
get
(
0
));
return
ObjectRestResponse
.
succ
();
}
/**
* 获取某个用户的积分信息
* @return
*/
public
ObjectRestResponse
<
IntegralUserTotal
>
getByUser
()
{
AppUserDTO
appUserDTO
=
userInfoBiz
.
getUserInfo
();
if
(
appUserDTO
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
508
,
"token is null or invalid"
);
}
IntegralUserTotal
integralUserTotal
=
new
IntegralUserTotal
();
integralUserTotal
.
setUserId
(
appUserDTO
.
getUserid
());
List
<
IntegralUserTotal
>
oldValue
=
mapper
.
selectAllByParam
(
integralUserTotal
);
if
(
oldValue
==
null
||
oldValue
.
size
()
<=
0
)
{
return
ObjectRestResponse
.
createDefaultFail
();
}
return
ObjectRestResponse
.
succ
(
oldValue
.
get
(
0
));
}
/**
* 获取所有的信息
* @param integralUserTotal
* @return
*/
public
ObjectRestResponse
<
List
<
IntegralUserTotal
>>
getAll
(
IntegralUserTotal
integralUserTotal
)
{
List
<
IntegralUserTotal
>
integralUserTotals
=
mapper
.
selectAllByParam
(
integralUserTotal
);
return
ObjectRestResponse
.
succ
(
integralUserTotals
);
}
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/mapper/IntegralRuleMapper.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
mapper
;
import
com.xxfc.platform.activity.entity.IntegralRule
;
import
tk.mybatis.mapper.common.Mapper
;
import
java.util.List
;
public
interface
IntegralRuleMapper
extends
Mapper
<
IntegralRule
>
{
public
List
<
IntegralRule
>
selectAllByParam
(
IntegralRule
integralRule
);
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/mapper/IntegralSignRecordMapper.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
mapper
;
import
com.xxfc.platform.activity.entity.IntegralSignRecord
;
import
tk.mybatis.mapper.common.Mapper
;
public
interface
IntegralSignRecordMapper
extends
Mapper
<
IntegralSignRecord
>
{
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/mapper/IntegralUserRecordMapper.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
mapper
;
import
com.xxfc.platform.activity.entity.IntegralUserRecord
;
import
tk.mybatis.mapper.common.Mapper
;
public
interface
IntegralUserRecordMapper
extends
Mapper
<
IntegralUserRecord
>
{
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/mapper/IntegralUserTotalMapper.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
mapper
;
import
com.xxfc.platform.activity.entity.IntegralUserTotal
;
import
tk.mybatis.mapper.common.Mapper
;
import
java.util.List
;
public
interface
IntegralUserTotalMapper
extends
Mapper
<
IntegralUserTotal
>
{
List
<
IntegralUserTotal
>
selectAllByParam
(
IntegralUserTotal
integralUserTotal
);
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/IntegralRuleController.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
rest
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.activity.biz.IntegralRuleBiz
;
import
com.xxfc.platform.activity.entity.IntegralRule
;
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.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@RestController
@RequestMapping
(
value
=
"integralRule"
)
@Api
(
value
=
"积分规则"
)
public
class
IntegralRuleController
{
@Autowired
IntegralRuleBiz
integralRuleBiz
;
@PostMapping
(
value
=
"/add"
)
@ApiOperation
(
value
=
"添加积分规则"
)
public
ObjectRestResponse
add
(
IntegralRule
integralRule
)
{
return
integralRuleBiz
.
add
(
integralRule
);
}
@PostMapping
(
value
=
"/delete"
)
@ApiOperation
(
value
=
"删除积分规则"
)
public
ObjectRestResponse
deleteOne
(
Integer
id
)
{
return
integralRuleBiz
.
deleteOne
(
id
);
}
@GetMapping
(
value
=
"/one"
)
@ApiOperation
(
value
=
"根据id获取制定规则"
)
public
ObjectRestResponse
<
IntegralRule
>
getOne
(
IntegralRule
integralRule
)
{
return
integralRuleBiz
.
getOne
(
integralRule
);
}
@GetMapping
(
value
=
"/list"
)
@ApiOperation
(
value
=
"获取所有的规则"
)
public
ObjectRestResponse
<
List
<
IntegralRule
>>
getList
(
IntegralRule
integralRule
)
{
return
integralRuleBiz
.
getAll
(
integralRule
);
}
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/IntegralSignRecordController.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
rest
;
import
com.xxfc.platform.activity.biz.IntegralSignRecordBiz
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
value
=
"integralSignRecord"
)
@Api
(
value
=
"用户签到记录"
)
public
class
IntegralSignRecordController
{
@Autowired
IntegralSignRecordBiz
integralSignRecordBiz
;
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/IntegralUserRecordController.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
rest
;
import
com.xxfc.platform.activity.biz.IntegralUserRecordBiz
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
value
=
"integralUserRecord"
)
@Api
(
value
=
"用户积分记录"
)
public
class
IntegralUserRecordController
{
@Autowired
IntegralUserRecordBiz
integralUserRecordBiz
;
}
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/rest/IntegralUserTotalController.java
0 → 100644
View file @
e4409308
package
com
.
xxfc
.
platform
.
activity
.
rest
;
import
io.swagger.annotations.Api
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
value
=
"integralUserTotal"
)
@Api
(
value
=
"用户总积分"
)
public
class
IntegralUserTotalController
{
}
xx-activity/xx-activity-server/src/main/resources/mapper/IntegralRuleMapper.xml
0 → 100644
View file @
e4409308
<?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=
"com.xxfc.platform.activity.mapper.IntegralRuleMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.xxfc.platform.activity.entity.IntegralRule"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"period"
property=
"period"
jdbcType=
"BIT"
/>
<result
column=
"number"
property=
"number"
jdbcType=
"INTEGER"
/>
<result
column=
"point"
property=
"point"
jdbcType=
"INTEGER"
/>
<result
column=
"price"
property=
"price"
jdbcType=
"DECIMAL"
/>
<result
column=
"is_continuity"
property=
"isContinuity"
jdbcType=
"BIT"
/>
<result
column=
"finish_day"
property=
"finishDay"
jdbcType=
"INTEGER"
/>
<result
column=
"finish_point"
property=
"finishPoint"
jdbcType=
"INTEGER"
/>
<result
column=
"status"
property=
"status"
jdbcType=
"BIT"
/>
<result
column=
"crt_time"
property=
"crtTime"
jdbcType=
"BIGINT"
/>
<result
column=
"isdel"
property=
"isdel"
jdbcType=
"BIT"
/>
<result
column=
"start_time"
property=
"startTime"
jdbcType=
"BIGINT"
/>
<result
column=
"end_time"
property=
"endTime"
jdbcType=
"BIGINT"
/>
<result
column=
"upd_time"
property=
"updTime"
jdbcType=
"BIGINT"
/>
<result
column=
"remarks"
property=
"remarks"
jdbcType=
"VARCHAR"
/>
<result
column=
"desc"
property=
"desc"
jdbcType=
"VARCHAR"
/>
<result
column=
"img"
property=
"img"
jdbcType=
"VARCHAR"
/>
<result
column=
"order_id"
property=
"orderId"
jdbcType=
"INTEGER"
/>
<result
column=
"name"
property=
"name"
jdbcType=
"VARCHAR"
/>
<result
column=
"regulation"
property=
"regulation"
jdbcType=
"LONGVARCHAR"
/>
<result
column=
"other_rule"
property=
"otherRule"
jdbcType=
"LONGVARCHAR"
/>
</resultMap>
<select
id=
"selectAllByParam"
resultType=
"com.xxfc.platform.activity.entity.IntegralRule"
parameterType=
"com.xxfc.platform.activity.entity.IntegralRule"
>
select * from integral_rule
<where>
<if
test=
"id != null"
>
and id = #{id}
</if>
<if
test=
"name != null"
>
and name like concat("%", #{name}, "%")
</if>
</where>
order by order_id DESC ,crt_time DESC
</select>
</mapper>
\ No newline at end of file
xx-activity/xx-activity-server/src/main/resources/mapper/IntegralSignRecordMapper.xml
0 → 100644
View file @
e4409308
<?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=
"com.xxfc.platform.activity.mapper.IntegralSignRecordMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.xxfc.platform.activity.entity.IntegralSignRecord"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"user_id"
property=
"userId"
jdbcType=
"INTEGER"
/>
<result
column=
"sign_days"
property=
"signDays"
jdbcType=
"INTEGER"
/>
<result
column=
"start_time"
property=
"startTime"
jdbcType=
"BIGINT"
/>
<result
column=
"last_time"
property=
"lastTime"
jdbcType=
"BIGINT"
/>
</resultMap>
</mapper>
\ No newline at end of file
xx-activity/xx-activity-server/src/main/resources/mapper/IntegralUserRecordMapper.xml
0 → 100644
View file @
e4409308
<?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=
"com.xxfc.platform.activity.mapper.IntegralUserRecordMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.xxfc.platform.activity.entity.IntegralUserRecord"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"user_id"
property=
"userId"
jdbcType=
"INTEGER"
/>
<result
column=
"type"
property=
"type"
jdbcType=
"BIT"
/>
<result
column=
"point"
property=
"point"
jdbcType=
"INTEGER"
/>
<result
column=
"integral_rule_id"
property=
"integralRuleId"
jdbcType=
"INTEGER"
/>
<result
column=
"crt_time"
property=
"crtTime"
jdbcType=
"BIGINT"
/>
<result
column=
"is_valid"
property=
"isValid"
jdbcType=
"BIT"
/>
<result
column=
"isdel"
property=
"isdel"
jdbcType=
"BIT"
/>
<result
column=
"channel_id"
property=
"channelId"
jdbcType=
"INTEGER"
/>
</resultMap>
</mapper>
\ No newline at end of file
xx-activity/xx-activity-server/src/main/resources/mapper/IntegralUserTotalMapper.xml
0 → 100644
View file @
e4409308
<?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=
"com.xxfc.platform.activity.mapper.IntegralUserTotalMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.xxfc.platform.activity.entity.IntegralUserTotal"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"user_id"
property=
"userId"
jdbcType=
"INTEGER"
/>
<result
column=
"total_point"
property=
"totalPoint"
jdbcType=
"INTEGER"
/>
<result
column=
"rest_point"
property=
"restPoint"
jdbcType=
"INTEGER"
/>
<result
column=
"crt_time"
property=
"crtTime"
jdbcType=
"BIGINT"
/>
<result
column=
"upd_time"
property=
"updTime"
jdbcType=
"BIGINT"
/>
</resultMap>
<select
id=
"selectAllByParam"
parameterType=
"com.xxfc.platform.activity.entity.IntegralUserTotal"
resultType=
"com.xxfc.platform.activity.entity.IntegralUserTotal"
>
select * from integral_user_total
<where>
<if
test=
"userId != null"
>
and user_id = #{userId}
</if>
</where>
order by upd_time DESC
</select>
</mapper>
\ No newline at end of file
xx-app/xx-app-server/src/main/java/com/xxfc/platform/app/rest/AppVersionController.java
View file @
e4409308
...
...
@@ -59,8 +59,8 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
@ApiOperation
(
"查询"
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
public
ObjectRestResponse
<
AppVersion
>
get
(
@PathVariable
Integer
id
){
@RequestMapping
(
value
=
"/
getAppVersion/
{id}"
,
method
=
RequestMethod
.
GET
)
public
ObjectRestResponse
<
AppVersion
>
get
AppVersion
(
@PathVariable
Integer
id
){
return
ObjectRestResponse
.
succ
(
baseBiz
.
get
(
id
));
}
...
...
xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/rest/BaseOrderController.java
View file @
e4409308
...
...
@@ -134,6 +134,7 @@ public class BaseOrderController extends CommonBaseController {
@ResponseBody
@ApiOperation
(
value
=
"获取后台订单列表"
)
@IgnoreClientToken
@CrossOrigin
public
ObjectRestResponse
<
PageDataVO
<
OrderPageVO
>>
selectByUser
(
QueryOrderList
dto
)
{
if
(
dto
.
getStartTime
()
!=
null
)
{
if
(
dto
.
getEndTime
()
==
null
)
{
...
...
xx-tour/xx-tour-server/src/main/java/com/xxfc/platform/tour/rest/TourUserController.java
View file @
e4409308
...
...
@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiOperation;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.web.bind.annotation.*
;
import
tk.mybatis.mapper.entity.Example
;
import
tk.mybatis.mapper.weekend.WeekendSqls
;
...
...
@@ -93,20 +94,19 @@ public class TourUserController extends TourBaseController<TourUserBiz> {
}
/**
*
添加和更新
* @param
id
*
删除
* @param
* @return
*/
@ApiOperation
(
"删除"
)
@PostMapping
(
value
=
"/app/del"
)
@Transactional
public
ObjectRestResponse
<
TourUser
>
del
(
@Request
Param
(
value
=
"id"
,
defaultValue
=
"0"
)
Integer
id
){
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ObjectRestResponse
<
TourUser
>
del
(
@Request
Body
TourUser
tourUser
){
try
{
TourUser
tourUser1
=
new
TourUser
();
tourUser1
.
setId
(
id
);
tourUser1
.
setIsdel
(
1
);
baseBiz
.
updateSelectiveById
(
tourUser1
);
tourUser
.
setIsdel
(
1
);
baseBiz
.
updateSelectiveById
(
tourUser
);
return
ObjectRestResponse
.
succ
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -149,4 +149,8 @@ public class TourUserController extends TourBaseController<TourUserBiz> {
}
}
\ No newline at end of file
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/rest/VehicleLicenseController.java
View file @
e4409308
...
...
@@ -2,6 +2,7 @@ package com.xxfc.platform.vehicle.rest;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.vehicle.biz.VehicleLicenseBiz
;
import
com.xxfc.platform.vehicle.common.RestResponse
;
...
...
@@ -60,6 +61,8 @@ public class VehicleLicenseController extends VehicleBaseController<VehicleLicen
return
RestResponse
.
suc
(
baseBiz
.
getOneById
(
id
));
}
@RequestMapping
(
value
=
"/license/company/getOne"
,
method
=
RequestMethod
.
GET
)
@IgnoreUserToken
@IgnoreClientToken
public
RestResponse
<
VehicleUserLicense
>
getOne
(
@RequestParam
(
value
=
"id"
,
defaultValue
=
"0"
)
Integer
id
)
throws
Exception
{
return
RestResponse
.
suc
(
baseBiz
.
getOneById
(
id
));
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/rest/VehicleModelController.java
View file @
e4409308
...
...
@@ -96,7 +96,7 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi
* @return
*/
@ApiOperation
(
"车型列表"
)
@PostMapping
(
value
=
"/app/unauthfind/VehicleModelPage"
)
@PostMapping
(
value
=
"/app/unauthfind/
find
VehicleModelPage"
)
public
ObjectRestResponse
<
VehicleModelVo
>
findVehicleModelPageUnauthfind
(
@RequestBody
@ApiParam
(
"查询条件"
)
VehicleModelQueryCondition
vmqc
,
HttpServletRequest
request
)
{
...
...
@@ -282,7 +282,7 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi
}
@ApiOperation
(
"
查询所有
"
)
@ApiOperation
(
"
优质车型
"
)
@GetMapping
(
value
=
"/goodList"
)
public
List
<
GoodDataVO
>
goodList
(
@RequestParam
(
"page"
)
Integer
page
,
@RequestParam
(
"limit"
)
Integer
limit
){
return
baseBiz
.
goodList
(
page
,
limit
);
...
...
@@ -296,9 +296,9 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi
* @return
*/
@ApiOperation
(
"车型列表"
)
@PostMapping
(
value
=
"/app/VehicleModelPage"
)
@PostMapping
(
value
=
"/app/
find
VehicleModelPage"
)
public
ObjectRestResponse
<
VehicleModelVo
>
findVehicleModelPage
(
@RequestBody
@ApiParam
(
"查询条件"
)
VehicleModelQueryCondition
vmqc
,
HttpServletRequest
request
)
{
@RequestBody
@ApiParam
(
"查询条件"
)
VehicleModelQueryCondition
vmqc
)
{
if
(
vmqc
.
getIsDel
()==
null
)
{
vmqc
.
setIsDel
(
0
);
...
...
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