Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
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
8timerv2
8timerapiv200
Commits
93823108
Commit
93823108
authored
Jun 15, 2020
by
邓实川
Committed by
chenzg
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
excel读取方式改为直接从OSS读取
parent
7aa4a7ff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
27 deletions
+54
-27
src/main/java/cn/timer/api/controller/crm/CrmController.java
+54
-27
No files found.
src/main/java/cn/timer/api/controller/crm/CrmController.java
View file @
93823108
...
@@ -8,6 +8,8 @@
...
@@ -8,6 +8,8 @@
package
cn
.
timer
.
api
.
controller
.
crm
;
package
cn
.
timer
.
api
.
controller
.
crm
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Comparator
;
...
@@ -18,7 +20,6 @@ import java.util.Map;
...
@@ -18,7 +20,6 @@ import java.util.Map;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
@@ -34,7 +35,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
...
@@ -34,7 +35,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.resource.ResourceUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.poi.excel.ExcelReader
;
import
cn.hutool.poi.excel.ExcelReader
;
import
cn.hutool.poi.excel.ExcelUtil
;
import
cn.hutool.poi.excel.ExcelUtil
;
...
@@ -52,7 +52,6 @@ import cn.timer.api.bean.crm.CrmSeaRule;
...
@@ -52,7 +52,6 @@ import cn.timer.api.bean.crm.CrmSeaRule;
import
cn.timer.api.bean.yggl.YgglMainEmp
;
import
cn.timer.api.bean.yggl.YgglMainEmp
;
import
cn.timer.api.config.annotation.CurrentUser
;
import
cn.timer.api.config.annotation.CurrentUser
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.controller.dzht.cn.tign.hz.comm.FileHelper
;
import
cn.timer.api.dao.crm.CrmClientContactsMapper
;
import
cn.timer.api.dao.crm.CrmClientContactsMapper
;
import
cn.timer.api.dao.crm.CrmClientDataMapper
;
import
cn.timer.api.dao.crm.CrmClientDataMapper
;
import
cn.timer.api.dto.crm.CrmClientDataImportVo
;
import
cn.timer.api.dto.crm.CrmClientDataImportVo
;
...
@@ -77,8 +76,8 @@ import io.swagger.annotations.ApiOperation;
...
@@ -77,8 +76,8 @@ import io.swagger.annotations.ApiOperation;
@RequestMapping
(
value
=
"/crm"
,
produces
=
{
"application/json"
})
@RequestMapping
(
value
=
"/crm"
,
produces
=
{
"application/json"
})
public
class
CrmController
{
public
class
CrmController
{
@Value
(
value
=
"${config-8timer.crm-excel.realPath}"
)
//
@Value(value = "${config-8timer.crm-excel.realPath}")
private
String
realPath
;
//
private String realPath;
@Autowired
@Autowired
private
CrmClientDataMapper
crmClientDataMapper
;
private
CrmClientDataMapper
crmClientDataMapper
;
...
@@ -104,6 +103,13 @@ public class CrmController {
...
@@ -104,6 +103,13 @@ public class CrmController {
return
getYg
(
orgCode
,
empNum
).
getName
();
return
getYg
(
orgCode
,
empNum
).
getName
();
}
}
private
Integer
getQyzxManager
(
Integer
orgCode
,
Integer
empNum
)
{
return
YgglMainEmp
.
builder
().
build
()
.
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>().
lambda
().
eq
(
YgglMainEmp:
:
getOrgCode
,
orgCode
)
.
eq
(
YgglMainEmp:
:
getEmpNum
,
empNum
).
select
(
YgglMainEmp:
:
getIsManager
))
.
getIsManager
();
}
@GetMapping
(
"getIndustry"
)
@GetMapping
(
"getIndustry"
)
@ApiOperation
(
value
=
"获取行业列表"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
@ApiOperation
(
value
=
"获取行业列表"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
public
Result
<
List
<
IndustryClass
>>
getIndustry
(
@CurrentUser
UserBean
userBean
)
{
public
Result
<
List
<
IndustryClass
>>
getIndustry
(
@CurrentUser
UserBean
userBean
)
{
...
@@ -212,22 +218,30 @@ public class CrmController {
...
@@ -212,22 +218,30 @@ public class CrmController {
@GetMapping
(
"getBusinessGroup"
)
@GetMapping
(
"getBusinessGroup"
)
@ApiOperation
(
value
=
"获取业务组列表"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
@ApiOperation
(
value
=
"获取业务组列表"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
public
Result
<
Object
>
getBusinessGroup
(
@CurrentUser
UserBean
userBean
)
{
public
Result
<
Object
>
getBusinessGroup
(
@CurrentUser
UserBean
userBean
)
{
Integer
nowEmpNum
=
getEmpNum
(
userBean
);
Integer
orgCode
=
getOrgCode
(
userBean
);
Integer
isManager
=
getQyzxManager
(
orgCode
,
nowEmpNum
);
if
(
isManager
!=
null
&&
(
isManager
==
1
||
isManager
==
2
))
{
List
<
CrmBusinessGroup
>
list
=
CrmBusinessGroup
.
builder
().
build
()
List
<
CrmBusinessGroup
>
list
=
CrmBusinessGroup
.
builder
().
build
()
.
selectList
(
new
QueryWrapper
<
CrmBusinessGroup
>().
lambda
()
.
selectList
(
new
QueryWrapper
<
CrmBusinessGroup
>().
lambda
()
.
eq
(
CrmBusinessGroup:
:
getOrgCode
,
getOrgCode
(
userBean
)).
select
(
CrmBusinessGroup:
:
getId
,
.
eq
(
CrmBusinessGroup:
:
getOrgCode
,
getOrgCode
(
userBean
)).
select
(
CrmBusinessGroup:
:
getId
,
CrmBusinessGroup:
:
getSort
,
CrmBusinessGroup:
:
getName
,
CrmBusinessGroup:
:
getModifyTime
));
CrmBusinessGroup:
:
getSort
,
CrmBusinessGroup:
:
getName
,
CrmBusinessGroup:
:
getModifyTime
));
for
(
CrmBusinessGroup
crmBusinessGroup
:
list
)
{
for
(
CrmBusinessGroup
crmBusinessGroup
:
list
)
{
Integer
gid
=
crmBusinessGroup
.
getId
();
Integer
gid
=
crmBusinessGroup
.
getId
();
List
<
CrmBusinessGroupMember
>
crmBusinessGroupManagers
=
CrmBusinessGroupMember
.
builder
().
build
().
selectList
(
List
<
CrmBusinessGroupMember
>
crmBusinessGroupManagers
=
CrmBusinessGroupMember
.
builder
().
build
()
new
QueryWrapper
<
CrmBusinessGroupMember
>().
lambda
().
eq
(
CrmBusinessGroupMember:
:
getGid
,
gid
)
.
selectList
(
new
QueryWrapper
<
CrmBusinessGroupMember
>().
lambda
()
.
eq
(
CrmBusinessGroupMember:
:
getType
,
1
).
select
(
CrmBusinessGroupMember:
:
getEmpNum
));
.
eq
(
CrmBusinessGroupMember:
:
getGid
,
gid
).
eq
(
CrmBusinessGroupMember:
:
getType
,
1
)
List
<
CrmBusinessGroupMember
>
crmBusinessGroupMembers
=
CrmBusinessGroupMember
.
builder
().
build
().
selectList
(
.
select
(
CrmBusinessGroupMember:
:
getEmpNum
));
new
QueryWrapper
<
CrmBusinessGroupMember
>().
lambda
().
eq
(
CrmBusinessGroupMember:
:
getGid
,
gid
)
List
<
CrmBusinessGroupMember
>
crmBusinessGroupMembers
=
CrmBusinessGroupMember
.
builder
().
build
()
.
eq
(
CrmBusinessGroupMember:
:
getType
,
0
).
select
(
CrmBusinessGroupMember:
:
getEmpNum
));
.
selectList
(
new
QueryWrapper
<
CrmBusinessGroupMember
>().
lambda
()
.
eq
(
CrmBusinessGroupMember:
:
getGid
,
gid
).
eq
(
CrmBusinessGroupMember:
:
getType
,
0
)
.
select
(
CrmBusinessGroupMember:
:
getEmpNum
));
List
<
Map
<
String
,
Object
>>
managers
=
new
ArrayList
<
Map
<
String
,
Object
>>();
List
<
Map
<
String
,
Object
>>
managers
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
CrmBusinessGroupMember
crmBusinessGroupManager
:
crmBusinessGroupManagers
)
{
for
(
CrmBusinessGroupMember
crmBusinessGroupManager
:
crmBusinessGroupManagers
)
{
Integer
empNum
=
crmBusinessGroupManager
.
getEmpNum
();
Integer
empNum
=
crmBusinessGroupManager
.
getEmpNum
();
String
name
=
getEmpName
(
getOrgCode
(
userBean
)
,
empNum
);
String
name
=
getEmpName
(
orgCode
,
empNum
);
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"name"
,
name
);
map
.
put
(
"name"
,
name
);
map
.
put
(
"empNum"
,
empNum
);
map
.
put
(
"empNum"
,
empNum
);
...
@@ -238,7 +252,7 @@ public class CrmController {
...
@@ -238,7 +252,7 @@ public class CrmController {
List
<
Map
<
String
,
Object
>>
members
=
new
ArrayList
<
Map
<
String
,
Object
>>();
List
<
Map
<
String
,
Object
>>
members
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
CrmBusinessGroupMember
crmBusinessGroupManager
:
crmBusinessGroupMembers
)
{
for
(
CrmBusinessGroupMember
crmBusinessGroupManager
:
crmBusinessGroupMembers
)
{
Integer
empNum
=
crmBusinessGroupManager
.
getEmpNum
();
Integer
empNum
=
crmBusinessGroupManager
.
getEmpNum
();
String
name
=
getEmpName
(
getOrgCode
(
userBean
)
,
empNum
);
String
name
=
getEmpName
(
orgCode
,
empNum
);
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"name"
,
name
);
map
.
put
(
"name"
,
name
);
map
.
put
(
"empNum"
,
empNum
);
map
.
put
(
"empNum"
,
empNum
);
...
@@ -251,6 +265,10 @@ public class CrmController {
...
@@ -251,6 +265,10 @@ public class CrmController {
crmBusinessGroup
.
setCrmSeaRules
(
crmSeaRules
);
crmBusinessGroup
.
setCrmSeaRules
(
crmSeaRules
);
}
}
return
ResultUtil
.
data
(
list
,
"获取成功"
);
return
ResultUtil
.
data
(
list
,
"获取成功"
);
}
else
return
ResultUtil
.
error
(
"暂无查看权限"
);
}
}
@GetMapping
(
"getBusinessGroupId"
)
@GetMapping
(
"getBusinessGroupId"
)
...
@@ -264,7 +282,6 @@ public class CrmController {
...
@@ -264,7 +282,6 @@ public class CrmController {
.
distinct
().
collect
(
Collectors
.
toList
());
.
distinct
().
collect
(
Collectors
.
toList
());
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<
Map
<
String
,
Object
>>();
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
Integer
gid
:
gids
)
{
for
(
Integer
gid
:
gids
)
{
System
.
err
.
println
(
gid
);
String
name
=
CrmBusinessGroup
.
builder
().
build
().
selectOne
(
new
LambdaQueryWrapper
<
CrmBusinessGroup
>()
String
name
=
CrmBusinessGroup
.
builder
().
build
().
selectOne
(
new
LambdaQueryWrapper
<
CrmBusinessGroup
>()
.
eq
(
CrmBusinessGroup:
:
getId
,
gid
).
select
(
CrmBusinessGroup:
:
getName
)).
getName
();
.
eq
(
CrmBusinessGroup:
:
getId
,
gid
).
select
(
CrmBusinessGroup:
:
getName
)).
getName
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
...
@@ -1063,19 +1080,20 @@ public class CrmController {
...
@@ -1063,19 +1080,20 @@ public class CrmController {
Integer
empNum
=
getEmpNum
(
userBean
);
Integer
empNum
=
getEmpNum
(
userBean
);
Integer
orgCode
=
getOrgCode
(
userBean
);
Integer
orgCode
=
getOrgCode
(
userBean
);
String
filePath
=
null
;
// String filePath = null;
String
time
=
null
;
// String time = null;
try
{
// try {
time
=
DateUtil
.
format
(
new
Date
(),
"yyyyMMddHHmmssSSS"
);
// time = DateUtil.format(new Date(), "yyyyMMddHHmmssSSS");
filePath
=
FileHelper
.
downLoadFromUrl
(
url
,
time
+
".xls"
,
realPath
);
// filePath = FileHelper.downLoadFromUrl(url, time + ".xls", realPath);
System
.
err
.
println
(
filePath
);
// } catch (IOException e) {
}
catch
(
IOException
e
)
{
// e.printStackTrace();
e
.
printStackTrace
();
// }
}
// 从文件中读取Excel为ExcelReader
// 从文件中读取Excel为ExcelReader
ExcelReader
reader
;
ExcelReader
reader
;
// 从流中读取Excel为ExcelReader(比如从ClassPath中读取Excel文件)
// 从流中读取Excel为ExcelReader(比如从ClassPath中读取Excel文件)
reader
=
ExcelUtil
.
getReader
(
ResourceUtil
.
getStream
(
filePath
));
// reader = ExcelUtil.getReader(ResourceUtil.getStream(filePath));
// 从网络流OSS中读取excel资源
reader
=
getReaderByUrl
(
url
);
reader
.
addHeaderAlias
(
"*客户名称(必填)"
,
"clientName"
);
reader
.
addHeaderAlias
(
"*客户名称(必填)"
,
"clientName"
);
reader
.
addHeaderAlias
(
"*所属分组(必填)"
,
"belongGroupName"
);
reader
.
addHeaderAlias
(
"*所属分组(必填)"
,
"belongGroupName"
);
reader
.
addHeaderAlias
(
"行业"
,
"industryName"
);
reader
.
addHeaderAlias
(
"行业"
,
"industryName"
);
...
@@ -1095,7 +1113,6 @@ public class CrmController {
...
@@ -1095,7 +1113,6 @@ public class CrmController {
reader
.
addHeaderAlias
(
"个人地址"
,
"linkAddress"
);
reader
.
addHeaderAlias
(
"个人地址"
,
"linkAddress"
);
List
<
CrmClientDataImportVo
>
list
=
reader
.
read
(
0
,
1
,
CrmClientDataImportVo
.
class
);
List
<
CrmClientDataImportVo
>
list
=
reader
.
read
(
0
,
1
,
CrmClientDataImportVo
.
class
);
for
(
CrmClientDataImportVo
crmClientDataImportVo
:
list
)
{
for
(
CrmClientDataImportVo
crmClientDataImportVo
:
list
)
{
System
.
err
.
println
(
crmClientDataImportVo
);
String
clientName
=
crmClientDataImportVo
.
getClientName
();
// 客户名称(必填)
String
clientName
=
crmClientDataImportVo
.
getClientName
();
// 客户名称(必填)
String
belongGroupName
=
crmClientDataImportVo
.
getBelongGroupName
();
// 分组名(必填)
String
belongGroupName
=
crmClientDataImportVo
.
getBelongGroupName
();
// 分组名(必填)
...
@@ -1121,7 +1138,7 @@ public class CrmController {
...
@@ -1121,7 +1138,7 @@ public class CrmController {
// 业务组
// 业务组
CrmBusinessGroup
crmBusinessGroup
=
CrmBusinessGroup
.
builder
().
build
()
CrmBusinessGroup
crmBusinessGroup
=
CrmBusinessGroup
.
builder
().
build
()
.
selectOne
(
new
LambdaQueryWrapper
<
CrmBusinessGroup
>()
.
selectOne
(
new
LambdaQueryWrapper
<
CrmBusinessGroup
>()
.
eq
(
CrmBusinessGroup:
:
getOrgCode
,
userBean
.
getOrgCode
()
)
.
eq
(
CrmBusinessGroup:
:
getOrgCode
,
orgCode
)
.
eq
(
CrmBusinessGroup:
:
getName
,
belongGroupName
).
select
(
CrmBusinessGroup:
:
getId
));
.
eq
(
CrmBusinessGroup:
:
getName
,
belongGroupName
).
select
(
CrmBusinessGroup:
:
getId
));
if
(
crmBusinessGroup
==
null
)
if
(
crmBusinessGroup
==
null
)
return
ResultUtil
.
error
(
"没有匹配的业务组名称"
);
return
ResultUtil
.
error
(
"没有匹配的业务组名称"
);
...
@@ -1188,4 +1205,14 @@ public class CrmController {
...
@@ -1188,4 +1205,14 @@ public class CrmController {
}
}
return
ResultUtil
.
success
(
"导入成功"
);
return
ResultUtil
.
success
(
"导入成功"
);
}
}
private
ExcelReader
getReaderByUrl
(
String
url
)
{
InputStream
is
=
null
;
try
{
is
=
new
URL
(
url
).
openConnection
().
getInputStream
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
ExcelUtil
.
getReader
(
is
);
}
}
}
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