Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
relation
Commits
2a6dc0ca
Commit
2a6dc0ca
authored
Aug 10, 2025
by
wujipeng
Browse files
模板去重逻辑修改
parent
14bc3c42
Changes
4
Show whitespace changes
Inline
Side-by-side
src/main/java/com/platform/annotation/NumericValue.java
deleted
100644 → 0
View file @
14bc3c42
package
com.platform.annotation
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Target
(
ElementType
.
FIELD
)
// 表示该注解只能用于成员变量
@Retention
(
RetentionPolicy
.
RUNTIME
)
// 表示该注解在运行时可用
public
@interface
NumericValue
{
double
value
();
// 唯一的数值参数
}
\ No newline at end of file
src/main/java/com/platform/model/entity/ExcelDataEntity.java
View file @
2a6dc0ca
...
...
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableId;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.platform.annotation.NumericValue
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -34,81 +33,64 @@ public class ExcelDataEntity {
@ApiModelProperty
(
"目录id"
)
private
String
directoryId
;
@NumericValue
(
0
)
@ApiModelProperty
(
"交易类型"
)
private
String
type
;
@NumericValue
(
1
)
@ApiModelProperty
(
"交易主体的出入"
)
private
String
direction
;
@NumericValue
(
2
)
@ApiModelProperty
(
"交易时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
time
;
@NumericValue
(
3
)
@ApiModelProperty
(
"交易金额"
)
private
double
amount
;
@NumericValue
(
4
)
@ApiModelProperty
(
"交易流水号"
)
private
String
serial
;
@NumericValue
(
5
)
@ApiModelProperty
(
"收款方银行卡所属银行卡号"
)
@TableField
(
"payee_bank_card"
)
private
String
payeeBankCard
;
@NumericValue
(
6
)
@ApiModelProperty
(
"收款方支付账号"
)
@TableField
(
"payee_account"
)
private
String
payeeAccount
;
@NumericValue
(
7
)
@ApiModelProperty
(
"收款方商户号"
)
@TableField
(
"payee_merchant"
)
private
String
payeeMerchant
;
@NumericValue
(
8
)
@ApiModelProperty
(
"收款方商户名称"
)
@TableField
(
"payee_name"
)
private
String
payeeName
;
@NumericValue
(
9
)
@ApiModelProperty
(
"付款方银行卡所属银行名称"
)
@TableField
(
"payment_bank_name"
)
private
String
paymentBankName
;
@NumericValue
(
10
)
@ApiModelProperty
(
"付款方银行卡所属银行卡号"
)
@TableField
(
"payment_bank_card"
)
private
String
paymentBankCard
;
@NumericValue
(
11
)
@ApiModelProperty
(
"付款方支付账号"
)
@TableField
(
"payment_account"
)
private
String
paymentAccount
;
@NumericValue
(
12
)
@ApiModelProperty
(
"交易支付设备ip"
)
private
String
ip
;
@NumericValue
(
13
)
@ApiModelProperty
(
"mac地址"
)
private
String
mac
;
@NumericValue
(
14
)
@ApiModelProperty
(
"银行外部渠道交易流水号"
)
@TableField
(
"external_channel"
)
private
String
externalChannel
;
@NumericValue
(
15
)
@ApiModelProperty
(
"支付账号"
)
@TableField
(
"pay_account"
)
private
String
payAccount
;
@NumericValue
(
16
)
@ApiModelProperty
(
"备注"
)
private
String
remark
;
...
...
src/main/java/com/platform/service/impl/AnalysisServiceImpl.java
View file @
2a6dc0ca
...
...
@@ -12,7 +12,6 @@ import com.platform.model.vo.AnalysisVO;
import
com.platform.model.vo.FileUploadVO
;
import
com.platform.model.vo.TableHeaderVO
;
import
com.platform.service.*
;
import
com.platform.utils.AnnotationUtils
;
import
com.platform.utils.DateUtils
;
import
com.platform.utils.IdCardUtils
;
import
com.platform.utils.StringUtils
;
...
...
@@ -29,10 +28,8 @@ import javax.annotation.Resource;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
...
...
@@ -134,31 +131,17 @@ public class AnalysisServiceImpl implements AnalysisService {
filterIndex
.
add
(
tableHeaderVO
.
getIndex
());
}
}
for
(
int
i
=
0
;
i
<
tableHeaderList
.
size
();
i
++)
{
if
(!
ObjectUtils
.
isEmpty
(
tableHeaderList
.
get
(
i
))
&&
!
ObjectUtils
.
isEmpty
(
tableHeaderList
.
get
(
i
))
&&
tableHeaderList
.
get
(
i
).
getFilter
())
{
filterIndex
.
add
(
i
);
}
}
Map
<
String
,
ExcelDataEntity
>
excelDataMap
=
Maps
.
newHashMap
();
List
<
UserEntity
>
userList
=
Lists
.
newArrayList
();
//保存excel数据,判断是否使用默认模板
if
(!
ObjectUtils
.
isEmpty
(
ExcelTemplate
))
{
if
(!
ObjectUtils
.
isEmpty
(
ExcelTemplate
)
&&
!
filterIndex
.
isEmpty
()
)
{
List
<
ExcelDataEntity
>
afterDeduplication
=
Lists
.
newArrayList
();
for
(
ExcelDataEntity
excelDatum
:
excelData
)
{
StringBuilder
key
=
new
StringBuilder
();
for
(
Integer
index
:
filterIndex
)
{
Field
field
=
AnnotationUtils
.
findFieldByNumericValue
(
excelDatum
,
index
);
if
(
field
!=
null
)
{
Method
getter
=
AnnotationUtils
.
findGetterMethod
(
field
,
excelDatum
.
getClass
());
if
(
getter
!=
null
)
{
try
{
Object
value
=
getter
.
invoke
(
excelDatum
);
if
(
value
!=
null
)
{
key
.
append
(
value
);
}
}
catch
(
IllegalAccessException
|
InvocationTargetException
ignored
)
{
// 异常处理(建议至少记录日志)
}
}
}
}
excelDataMap
.
put
(
key
.
toString
(),
excelDatum
);
}
deduplicationData
(
excelDataMap
,
excelData
,
filterIndex
);
//excelDataMap中的value传给afterDeduplication
excelDataMap
.
forEach
(
(
key
,
excelDatum
)
->
afterDeduplication
.
add
(
excelDatum
)
...
...
@@ -214,6 +197,66 @@ public class AnalysisServiceImpl implements AnalysisService {
}
}
private
void
deduplicationData
(
Map
<
String
,
ExcelDataEntity
>
excelDataMap
,
List
<
ExcelDataEntity
>
excelData
,
List
<
Integer
>
filterIndex
)
{
for
(
ExcelDataEntity
excelDatum
:
excelData
)
{
StringBuilder
key
=
new
StringBuilder
();
if
(
filterIndex
.
contains
(
0
))
{
key
.
append
(
excelDatum
.
getType
());
}
if
(
filterIndex
.
contains
(
1
))
{
key
.
append
(
excelDatum
.
getDirection
());
}
if
(
filterIndex
.
contains
(
2
))
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
formattedDate
=
sdf
.
format
(
excelDatum
.
getTime
());
key
.
append
(
formattedDate
);
}
if
(
filterIndex
.
contains
(
3
))
{
key
.
append
(
excelDatum
.
getAmount
());
}
if
(
filterIndex
.
contains
(
4
))
{
key
.
append
(
excelDatum
.
getSerial
());
}
if
(
filterIndex
.
contains
(
5
))
{
key
.
append
(
excelDatum
.
getPayeeBankCard
());
}
if
(
filterIndex
.
contains
(
6
))
{
key
.
append
(
excelDatum
.
getPayeeAccount
());
}
if
(
filterIndex
.
contains
(
7
))
{
key
.
append
(
excelDatum
.
getPayeeMerchant
());
}
if
(
filterIndex
.
contains
(
8
))
{
key
.
append
(
excelDatum
.
getPayeeName
());
}
if
(
filterIndex
.
contains
(
9
))
{
key
.
append
(
excelDatum
.
getPaymentBankName
());
}
if
(
filterIndex
.
contains
(
10
))
{
key
.
append
(
excelDatum
.
getPaymentBankCard
());
}
if
(
filterIndex
.
contains
(
11
))
{
key
.
append
(
excelDatum
.
getPaymentAccount
());
}
if
(
filterIndex
.
contains
(
12
))
{
key
.
append
(
excelDatum
.
getIp
());
}
if
(
filterIndex
.
contains
(
13
))
{
key
.
append
(
excelDatum
.
getMac
());
}
if
(
filterIndex
.
contains
(
14
))
{
key
.
append
(
excelDatum
.
getExternalChannel
());
}
if
(
filterIndex
.
contains
(
15
))
{
key
.
append
(
excelDatum
.
getPayAccount
());
}
if
(
filterIndex
.
contains
(
16
))
{
key
.
append
(
excelDatum
.
getRemark
());
}
excelDataMap
.
put
(
key
.
toString
(),
excelDatum
);
}
}
private
ExcelDataEntity
handleExcelData
(
List
<
TableHeaderVO
>
tableHeaderList
,
Row
row
,
String
folderName
,
String
fileId
,
int
caseId
)
{
ExcelDataEntity
excelDataEntity
=
new
ExcelDataEntity
();
...
...
src/main/java/com/platform/utils/AnnotationUtils.java
deleted
100644 → 0
View file @
14bc3c42
package
com.platform.utils
;
import
com.platform.annotation.NumericValue
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
public
class
AnnotationUtils
{
/**
* 获取带有指定NumericValue值的字段
* @param target 目标对象
* @param value 要查找的注解值
* @return 匹配的字段,如果没有找到返回null
*/
public
static
Field
findFieldByNumericValue
(
Object
target
,
int
value
)
{
for
(
Field
field
:
target
.
getClass
().
getDeclaredFields
())
{
NumericValue
annotation
=
field
.
getAnnotation
(
NumericValue
.
class
);
if
(
annotation
!=
null
&&
annotation
.
value
()
==
value
)
{
return
field
;
}
}
return
null
;
}
/**
* 获取字段的getter方法
* @param field 目标字段
* @param clazz 目标类
* @return getter方法,如果没有找到返回null
*/
public
static
Method
findGetterMethod
(
Field
field
,
Class
<?>
clazz
)
{
String
fieldName
=
field
.
getName
();
String
getterName
=
"get"
+
fieldName
.
substring
(
0
,
1
).
toUpperCase
()
+
fieldName
.
substring
(
1
);
try
{
return
clazz
.
getMethod
(
getterName
);
}
catch
(
NoSuchMethodException
e
)
{
// 尝试boolean类型的is前缀
if
(
field
.
getType
()
==
boolean
.
class
||
field
.
getType
()
==
Boolean
.
class
)
{
getterName
=
"is"
+
fieldName
.
substring
(
0
,
1
).
toUpperCase
()
+
fieldName
.
substring
(
1
);
try
{
return
clazz
.
getMethod
(
getterName
);
}
catch
(
NoSuchMethodException
ex
)
{
return
null
;
}
}
return
null
;
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment