Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
crm_java_search
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_server
crm_java_search
Commits
b2f9a0d5
Commit
b2f9a0d5
authored
6 years ago
by
liangyuzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add custom_field_template to import
parent
50e6fd68
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
2 deletions
+79
-2
lib/crm_java_search/checkers/base_checker.rb
+79
-2
No files found.
lib/crm_java_search/checkers/base_checker.rb
View file @
b2f9a0d5
...
...
@@ -4,6 +4,7 @@ module CrmJavaSearch
def
initialize
(
user
:,
entity
:,
params
:)
params
=
params
.
with_indifferent_access
Log
.
logger
.
info
(
"crm_java_search es initialize params
#{
params
.
to_json
}
"
)
@user
=
user
@entity
=
entity
...
...
@@ -13,6 +14,8 @@ module CrmJavaSearch
@exclude_ids
=
params
[
"exclude_ids"
].
compact
||
[]
@exclude_ids
.
push
(
@entity
.
id
)
if
@entity
&&
@entity
.
id
@id_source
=
params
[
"id_source"
]
||
''
@custom_field_template_id
=
params
[
"custom_field_template_id"
]
@no_custom_field_template
=
-
1
end
def
es_check
(
klass
)
...
...
@@ -46,14 +49,64 @@ module CrmJavaSearch
if
@res
[
"data"
][
'repeat'
]
&&
@res
[
"data"
][
'entities'
].
present?
@res
[
"data"
][
'entities'
].
select
{
|
entity_hash
|
return
duplicate_in_owns
(
entity_hash
[
'cross_fields'
])
if
entity_hash
[
'user_id'
].
to_i
==
@user
.
id
duplicate_in_org
(
entity_hash
[
'cross_fields'
])
Log
.
logger
.
info
(
"crm_java_search es entity_hash is
#{
entity_hash
.
to_json
}
"
)
if
klass
.
name
==
'Customer'
&&
@custom_field_template_id
.
present?
&&
@organization
.
customers
.
find
(
entity_hash
[
'id'
].
to_i
).
custom_field_template_id
==
@custom_field_template_id
.
to_i
&&
check_by_custom_field_template
Log
.
logger
.
info
(
"crm_java_search es 客户业务模板内查重"
)
#TODO 客户业务模板内查重
check_in_custom_field_template
elsif
klass
.
name
==
'Customer'
&&
@organization
.
customers
.
find
(
entity_hash
[
'id'
].
to_i
).
custom_field_template_id
.
blank?
&&
check_by_custom_field_template
Log
.
logger
.
info
(
"crm_java_search es 客户无业务模板,查重以前数据"
)
#TODO 客户无业务模板,查重以前数据
check_in_no_custom_field_template
elsif
klass
.
name
==
'Contact'
&&
@custom_field_template_id
.
present?
&&
@organization
.
contacts
.
find
(
entity_hash
[
'id'
].
to_i
).
customer
.
custom_field_template_id
==
@custom_field_template_id
.
to_i
&&
check_by_custom_field_template
Log
.
logger
.
info
(
"crm_java_search es 联系人业务模板内查重"
)
#TODO 联系人业务模板内查重
check_in_custom_field_template
elsif
klass
.
name
==
'Contact'
&&
@organization
.
contacts
.
find
(
entity_hash
[
'id'
].
to_i
).
customer
.
custom_field_template_id
.
blank?
&&
check_by_custom_field_template
Log
.
logger
.
info
(
"crm_java_search es 联系人无业务模板,查重以前数据"
)
#TODO 联系人无业务模板,查重以前数据
check_in_no_custom_field_template
elsif
(
@organization
.
settings
(
:customer_duplicate_scope_config
).
type
==
'all'
)
||
(
%w(Contact Customer)
.
exclude?
klass
.
name
)
duplicate_in_owns_or_org
(
entity_hash
)
else
no_duplicates
end
}
else
no_duplicates
end
end
def
check_in_custom_field_template
if
@organization
.
settings
(
:customer_duplicate_scope_config
).
custom_template_scopes
.
include?
@custom_field_template_id
.
to_s
return
duplicate_in_custom_template
else
return
no_duplicate_in_custom_template
end
end
def
check_in_no_custom_field_template
if
@organization
.
settings
(
:customer_duplicate_scope_config
).
custom_template_scopes
.
include?
@no_custom_field_template
.
to_s
return
duplicate_in_no_custom_template
else
return
no_duplicate_in_no_custom_template
end
end
def
check_by_custom_field_template
!!
(
@organization
.
settings
(
:customer_duplicate_scope_config
).
type
==
'by_custom_template'
)
end
def
duplicate_in_owns_or_org
(
entity_hash
)
return
duplicate_in_owns
(
entity_hash
[
'cross_fields'
])
if
entity_hash
[
'user_id'
].
to_i
==
@user
.
id
duplicate_in_org
(
entity_hash
[
'cross_fields'
])
end
def
cross_field_from_setting
RelationDuplicate
::
RelationService
.
new
(
@organization
).
send
(
"
#{
@entity
.
class
.
name
.
underscore
}
_cross"
)[
@custom_field
.
name
]
end
...
...
@@ -82,6 +135,30 @@ module CrmJavaSearch
@remark
=
"未发现相同
#{
@field_label
}
的
#{
@model_human_name
}
"
end
def
duplicate_in_no_custom_template
@code
=
"1"
@remark
=
"你已经有相同
#{
@field_label
}
的
#{
@model_human_name
}
在无业务模板里面"
@duplicated
=
true
end
def
no_duplicate_in_no_custom_template
@code
=
"0"
@remark
=
"未发现相同
#{
@field_label
}
的
#{
@model_human_name
}
在无业务模板里面"
@duplicated
=
false
end
def
no_duplicate_in_custom_template
@code
=
"0"
@remark
=
"未发现相同
#{
@field_label
}
的
#{
@model_human_name
}
在业务模板里面"
@duplicated
=
false
end
def
duplicate_in_custom_template
@code
=
"1"
@remark
=
"你已经有相同
#{
@field_label
}
的
#{
@model_human_name
}
在业务模板里面"
@duplicated
=
true
end
def
duplicate_in_owns
(
cross_field
=
nil
)
@code
=
"1"
if
cross_field
.
present?
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment