Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-cr20g
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
Administrator
dsk-cr20g
Commits
a42c0502
Commit
a42c0502
authored
May 25, 2023
by
lcl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
客户批量导入
parent
0828d84e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
36 deletions
+38
-36
CustomerController.java
...a/com/dsk/web/controller/customer/CustomerController.java
+35
-1
CustomerUser.java
...ain/java/com/dsk/system/domain/customer/CustomerUser.java
+1
-1
ICustomerService.java
...rc/main/java/com/dsk/system/service/ICustomerService.java
+0
-2
CustomerServiceImpl.java
...java/com/dsk/system/service/impl/CustomerServiceImpl.java
+2
-32
No files found.
dsk-admin/src/main/java/com/dsk/web/controller/customer/CustomerController.java
View file @
a42c0502
package
com
.
dsk
.
web
.
controller
.
customer
;
package
com
.
dsk
.
web
.
controller
.
customer
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.http.HttpException
;
import
com.dsk.common.annotation.Log
;
import
com.dsk.common.annotation.Log
;
import
com.dsk.common.annotation.RepeatSubmit
;
import
com.dsk.common.annotation.RepeatSubmit
;
import
com.dsk.common.core.controller.BaseController
;
import
com.dsk.common.core.controller.BaseController
;
...
@@ -12,13 +15,18 @@ import com.dsk.system.domain.customer.Customer;
...
@@ -12,13 +15,18 @@ import com.dsk.system.domain.customer.Customer;
import
com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto
;
import
com.dsk.system.domain.customer.dto.CustomerBusinessSearchDto
;
import
com.dsk.system.domain.customer.dto.CustomerSearchDto
;
import
com.dsk.system.domain.customer.dto.CustomerSearchDto
;
import
com.dsk.system.service.ICustomerService
;
import
com.dsk.system.service.ICustomerService
;
import
com.dsk.web.controller.search.service.BusinessOpportunityRadarService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 客户相关
* 客户相关
...
@@ -32,6 +40,8 @@ public class CustomerController extends BaseController {
...
@@ -32,6 +40,8 @@ public class CustomerController extends BaseController {
@Autowired
@Autowired
private
ICustomerService
baseService
;
private
ICustomerService
baseService
;
@Autowired
private
BusinessOpportunityRadarService
opportunityRadarService
;
/**
/**
* 查询客户列表
* 查询客户列表
...
@@ -94,6 +104,30 @@ public class CustomerController extends BaseController {
...
@@ -94,6 +104,30 @@ public class CustomerController extends BaseController {
//@PreAuthorize("@ss.hasPermi('customer:importData')")
//@PreAuthorize("@ss.hasPermi('customer:importData')")
@PostMapping
(
"/importData"
)
@PostMapping
(
"/importData"
)
public
AjaxResult
importData
(
@RequestPart
(
"file"
)
MultipartFile
file
)
throws
Exception
{
public
AjaxResult
importData
(
@RequestPart
(
"file"
)
MultipartFile
file
)
throws
Exception
{
return
AjaxResult
.
success
(
baseService
.
importData
(
new
ExcelUtil
<>(
Customer
.
class
).
importExcel
(
file
.
getInputStream
(),
3
)));
List
<
Customer
>
customerList
=
new
ExcelUtil
<>(
Customer
.
class
).
importExcel
(
file
.
getInputStream
(),
2
);
List
<
String
>
resultList
=
new
ArrayList
<>();
for
(
Customer
customer
:
customerList
)
{
if
(
ObjectUtils
.
isEmpty
(
customer
.
getCompanyName
()))
{
continue
;
}
try
{
Map
<
String
,
Object
>
map
=
opportunityRadarService
.
enterpriseByName
(
customer
.
getCompanyName
());
if
(
ObjectUtils
.
isEmpty
(
map
)){
throw
new
HttpException
(
"远程调用匹配接口失败!"
);
}
Map
<
String
,
Object
>
obj
=
BeanUtil
.
beanToMap
(
map
.
get
(
"data"
));
if
(!
ObjectUtils
.
isEmpty
(
obj
)){
customer
.
setCompanyId
(
MapUtil
.
getInt
(
obj
,
"jskEid"
));
customer
.
setLegalPerson
(
MapUtil
.
getStr
(
obj
,
"legalPerson"
));
customer
.
setRegisterCapital
(
MapUtil
.
getStr
(
obj
,
"registeredCapital"
));
customer
.
setRegisterAddress
(
MapUtil
.
getStr
(
obj
,
"domicile"
));
customer
.
setCreditCode
(
MapUtil
.
getStr
(
obj
,
"creditCode"
));
}
baseService
.
add
(
customer
);
}
catch
(
Exception
e
)
{
resultList
.
add
(
customer
.
getCompanyName
().
concat
(
":"
).
concat
(
e
.
getMessage
()));
}
}
return
AjaxResult
.
success
(
resultList
);
}
}
}
}
dsk-system/src/main/java/com/dsk/system/domain/customer/CustomerUser.java
View file @
a42c0502
...
@@ -38,7 +38,7 @@ public class CustomerUser implements Serializable {
...
@@ -38,7 +38,7 @@ public class CustomerUser implements Serializable {
* 创建时间
* 创建时间
*/
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
c
are
teTime
;
private
Date
c
rea
teTime
;
/**
/**
* 修改时间
* 修改时间
*/
*/
...
...
dsk-system/src/main/java/com/dsk/system/service/ICustomerService.java
View file @
a42c0502
...
@@ -29,6 +29,4 @@ public interface ICustomerService {
...
@@ -29,6 +29,4 @@ public interface ICustomerService {
List
<
CustomerBusinessListVo
>
selectBusinessList
(
CustomerBusinessSearchDto
dto
);
List
<
CustomerBusinessListVo
>
selectBusinessList
(
CustomerBusinessSearchDto
dto
);
List
<
String
>
importData
(
List
<
Customer
>
customerList
);
}
}
dsk-system/src/main/java/com/dsk/system/service/impl/CustomerServiceImpl.java
View file @
a42c0502
...
@@ -2,6 +2,7 @@ package com.dsk.system.service.impl;
...
@@ -2,6 +2,7 @@ package com.dsk.system.service.impl;
import
cn.hutool.core.bean.BeanException
;
import
cn.hutool.core.bean.BeanException
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.map.MapUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.dsk.common.core.domain.AjaxResult
;
import
com.dsk.common.core.domain.AjaxResult
;
import
com.dsk.common.exception.ServiceException
;
import
com.dsk.common.exception.ServiceException
;
...
@@ -19,6 +20,7 @@ import com.dsk.system.mapper.CustomerUserMapper;
...
@@ -19,6 +20,7 @@ import com.dsk.system.mapper.CustomerUserMapper;
import
com.dsk.system.service.IBusinessInfoService
;
import
com.dsk.system.service.IBusinessInfoService
;
import
com.dsk.system.service.ICustomerService
;
import
com.dsk.system.service.ICustomerService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.MapUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -46,8 +48,6 @@ public class CustomerServiceImpl implements ICustomerService {
...
@@ -46,8 +48,6 @@ public class CustomerServiceImpl implements ICustomerService {
private
CustomerUserMapper
customerUserMapper
;
private
CustomerUserMapper
customerUserMapper
;
@Autowired
@Autowired
private
IBusinessInfoService
businessInfoService
;
private
IBusinessInfoService
businessInfoService
;
@Autowired
private
DskOpenApiUtil
dskOpenApiUtil
;
@Override
@Override
public
List
<
CustomerListVo
>
selectList
(
CustomerSearchDto
dto
)
{
public
List
<
CustomerListVo
>
selectList
(
CustomerSearchDto
dto
)
{
...
@@ -117,34 +117,4 @@ public class CustomerServiceImpl implements ICustomerService {
...
@@ -117,34 +117,4 @@ public class CustomerServiceImpl implements ICustomerService {
dto
.
setUserId
(
SecurityUtils
.
getUserId
());
dto
.
setUserId
(
SecurityUtils
.
getUserId
());
return
businessInfoService
.
selectCustomerBusinessList
(
dto
);
return
businessInfoService
.
selectCustomerBusinessList
(
dto
);
}
}
@Override
public
List
<
String
>
importData
(
List
<
Customer
>
customerList
)
{
List
<
String
>
resultList
=
new
ArrayList
<>();
for
(
Customer
customer
:
customerList
)
{
if
(
ObjectUtils
.
isEmpty
(
customer
.
getCompanyName
()))
{
continue
;
}
try
{
//TODO 名称查询企业信息
this
.
add
(
customer
);
}
catch
(
Exception
e
)
{
resultList
.
add
(
customer
.
getCompanyName
().
concat
(
e
.
getMessage
()));
}
}
return
resultList
;
}
private
Map
<
String
,
Object
>
enterpriseByName
(
String
keyword
)
{
try
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"keyword"
,
keyword
);
Map
<
String
,
Object
>
map
=
dskOpenApiUtil
.
requestBody
(
"/nationzj/enterprice/findByName"
,
params
);
return
(
Map
<
String
,
Object
>)
map
.
get
(
"data"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"企业名称匹配企业信息失败:"
+
keyword
);
return
null
;
}
}
}
}
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