Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
157f5583
Commit
157f5583
authored
May 29, 2025
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(大编辑):bug修复
1.json字段比较优化
parent
be15dbb6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
3 deletions
+48
-3
pom.xml
...m-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/pom.xml
+5
-0
CommonEquipDataProcessService.java
...biz/edit/process/equip/CommonEquipDataProcessService.java
+43
-3
No files found.
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/pom.xml
View file @
157f5583
...
@@ -72,6 +72,11 @@
...
@@ -72,6 +72,11 @@
<version>
0.10.2
</version>
<version>
0.10.2
</version>
<scope>
compile
</scope>
<scope>
compile
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.skyscreamer
</groupId>
<artifactId>
jsonassert
</artifactId>
<version>
1.5.3
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/edit/process/equip/CommonEquipDataProcessService.java
View file @
157f5583
...
@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.edit.process.equip;
...
@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.edit.process.equip;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.text.CharSequenceUtil
;
import
cn.hutool.core.text.CharSequenceUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
...
@@ -46,6 +47,9 @@ import org.elasticsearch.index.query.QueryBuilders;
...
@@ -46,6 +47,9 @@ import org.elasticsearch.index.query.QueryBuilders;
import
org.elasticsearch.search.SearchHit
;
import
org.elasticsearch.search.SearchHit
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.builder.SearchSourceBuilder
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.elasticsearch.search.sort.SortOrder
;
import
org.json.JSONException
;
import
org.skyscreamer.jsonassert.JSONAssert
;
import
org.skyscreamer.jsonassert.JSONCompareMode
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
...
@@ -127,6 +131,9 @@ public class CommonEquipDataProcessService {
...
@@ -127,6 +131,9 @@ public class CommonEquipDataProcessService {
public
static
final
String
BASE_COLUMN_REC_DATE
=
"\"REC_DATE\""
;
public
static
final
String
BASE_COLUMN_REC_DATE
=
"\"REC_DATE\""
;
public
static
final
String
BASE_COLUMN_REC_USERID
=
"\"REC_USER_ID\""
;
public
static
final
String
BASE_COLUMN_REC_USERID
=
"\"REC_USER_ID\""
;
private
static
final
CopyOptions
options
=
CopyOptions
.
create
()
.
setIgnoreNullValue
(
false
).
ignoreCase
();
@PostConstruct
@PostConstruct
public
void
init
()
{
public
void
init
()
{
Set
<
Class
<?
extends
IBaseChangeData
>>
subClasses
=
getAllSubClasses
();
Set
<
Class
<?
extends
IBaseChangeData
>>
subClasses
=
getAllSubClasses
();
...
@@ -153,7 +160,7 @@ public class CommonEquipDataProcessService {
...
@@ -153,7 +160,7 @@ public class CommonEquipDataProcessService {
}
}
public
static
<
T
extends
IBaseChangeData
>
void
castMap2Bean
(
Map
<
String
,
Object
>
map
,
T
target
)
{
public
static
<
T
extends
IBaseChangeData
>
void
castMap2Bean
(
Map
<
String
,
Object
>
map
,
T
target
)
{
BeanUtil
.
copyProperties
(
JSON
.
parse
(
JSONObject
.
toJSONString
(
map
)),
target
,
true
);
BeanUtil
.
copyProperties
(
JSON
.
parse
(
JSONObject
.
toJSONString
(
map
)),
target
,
options
);
}
}
...
@@ -685,8 +692,31 @@ public class CommonEquipDataProcessService {
...
@@ -685,8 +692,31 @@ public class CommonEquipDataProcessService {
FieldDisplayDefine
displayDefine
=
field
.
getAnnotation
(
FieldDisplayDefine
.
class
);
FieldDisplayDefine
displayDefine
=
field
.
getAnnotation
(
FieldDisplayDefine
.
class
);
TableField
tableField
=
field
.
getAnnotation
(
TableField
.
class
);
TableField
tableField
=
field
.
getAnnotation
(
TableField
.
class
);
// 业务字段对比处理逻辑
// 业务字段对比处理逻辑
if
(!
Objects
.
equals
(
oldVal
,
newVal
))
{
if
(
displayDefine
!=
null
&&
displayDefine
.
isExist
())
{
if
(
displayDefine
!=
null
&&
displayDefine
.
isExist
())
{
// json 比较逻辑
if
(
displayDefine
.
type
().
equals
(
JSON
.
class
))
{
if
(!
isJsonEqualLoose
((
String
)
oldVal
,
(
String
)
newVal
))
{
String
columnName
=
tableField
.
value
();
wrapper
.
set
(
columnName
,
newVal
);
String
fieldName
=
displayDefine
.
value
();
FieldChangeMeta
fieldChangeMeta
=
new
FieldChangeMeta
();
fieldChangeMeta
.
setColumnKey
(
field
.
getName
());
fieldChangeMeta
.
setColumnFamily
(
group
.
value
());
fieldChangeMeta
.
setColumnLabel
(
fieldName
);
fieldChangeMeta
.
setChangeId
(
changeId
);
fieldChangeMeta
.
setIsRepeatColumn
(
displayDefine
.
isRepeatColumn
());
// 字段类型前端渲染时使用
fieldChangeMeta
.
setColumnType
(
displayDefine
.
type
().
getSimpleName
());
fieldChangeMeta
.
setColumnOldValue
(
Objects
.
toString
(
oldVal
,
""
));
fieldChangeMeta
.
setColumnNewValue
(
Objects
.
toString
(
newVal
,
""
));
fieldChangeMeta
.
setDisplayOldValue
(
formatService
.
format
(
displayDefine
,
fieldChangeMeta
.
getColumnOldValue
()));
fieldChangeMeta
.
setDisplayNewValue
(
formatService
.
format
(
displayDefine
,
fieldChangeMeta
.
getColumnNewValue
()));
changeData
.
add
(
fieldChangeMeta
);
}
continue
;
}
// 其他比较逻辑
if
(!
Objects
.
equals
(
oldVal
,
newVal
))
{
String
columnName
=
tableField
.
value
();
String
columnName
=
tableField
.
value
();
wrapper
.
set
(
columnName
,
newVal
);
wrapper
.
set
(
columnName
,
newVal
);
String
fieldName
=
displayDefine
.
value
();
String
fieldName
=
displayDefine
.
value
();
...
@@ -717,6 +747,7 @@ public class CommonEquipDataProcessService {
...
@@ -717,6 +747,7 @@ public class CommonEquipDataProcessService {
}
}
}
}
}
catch
(
IllegalAccessException
e
)
{
}
catch
(
IllegalAccessException
e
)
{
System
.
err
.
println
(
"字段访问失败: "
+
field
.
getName
());
System
.
err
.
println
(
"字段访问失败: "
+
field
.
getName
());
}
}
...
@@ -734,6 +765,15 @@ public class CommonEquipDataProcessService {
...
@@ -734,6 +765,15 @@ public class CommonEquipDataProcessService {
return
changeData
;
return
changeData
;
}
}
public
static
boolean
isJsonEqualLoose
(
String
expectedJson
,
String
actualJson
)
{
try
{
JSONAssert
.
assertEquals
(
expectedJson
,
actualJson
,
JSONCompareMode
.
LENIENT
);
return
true
;
}
catch
(
Error
|
JSONException
e
)
{
return
false
;
}
}
public
Map
<
String
,
Object
>
getEquipDetailByRecord
(
String
record
)
{
public
Map
<
String
,
Object
>
getEquipDetailByRecord
(
String
record
)
{
Map
<
String
,
Object
>
re
=
new
HashMap
<>();
Map
<
String
,
Object
>
re
=
new
HashMap
<>();
...
...
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