Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
李苗
/
Vion-DevOps
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 819a2bea
authored
Mar 13, 2024
by
HlQ
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[add] 使用 Redisson 替换 SpringBoot 自带的 Redis 客户端
[chg] 修改整个项目的文件换行符
1 parent
828b8914
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
107 additions
and
104 deletions
pom.xml
src/main/java/vion/config/FaultTypeConverter.java
src/main/java/vion/config/RedisConfig.java
src/main/java/vion/config/UserNameConverter.java
src/main/java/vion/cron/ContractRunner.java
src/main/java/vion/service/impl/DictionaryServiceImpl.java
src/main/java/vion/service/impl/TaskServiceImpl.java
src/main/java/vion/third/DingMod.java
src/main/java/vion/vo/TaskVO.java
src/main/resources/application-dev.properties
pom.xml
View file @
819a2be
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
<sqlserver.version>
12.2.0.jre8
</sqlserver.version>
<sqlserver.version>
12.2.0.jre8
</sqlserver.version>
<lombok.version>
1.18.30
</lombok.version>
<lombok.version>
1.18.30
</lombok.version>
<hutool.version>
6.0.0-M11
</hutool.version>
<hutool.version>
6.0.0-M11
</hutool.version>
<redisson.verion>
3.27.1
</redisson.verion>
<mapstruct-plus.version>
1.3.5
</mapstruct-plus.version>
<mapstruct-plus.version>
1.3.5
</mapstruct-plus.version>
<mp.version>
3.5.5
</mp.version>
<mp.version>
3.5.5
</mp.version>
<mp-join.version>
1.4.7.2
</mp-join.version>
<mp-join.version>
1.4.7.2
</mp-join.version>
...
@@ -82,8 +83,9 @@
...
@@ -82,8 +83,9 @@
<version>
${wx-mp.version}
</version>
<version>
${wx-mp.version}
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.redisson
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
<artifactId>
redisson-spring-boot-starter
</artifactId>
<version>
${redisson.verion}
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
cn.dev33
</groupId>
<groupId>
cn.dev33
</groupId>
...
...
src/main/java/vion/config/FaultTypeConverter.java
View file @
819a2be
...
@@ -3,12 +3,11 @@ package vion.config;
...
@@ -3,12 +3,11 @@ package vion.config;
import
com.github.liaochong.myexcel.core.converter.CustomWriteContext
;
import
com.github.liaochong.myexcel.core.converter.CustomWriteContext
;
import
com.github.liaochong.myexcel.core.converter.CustomWriteConverter
;
import
com.github.liaochong.myexcel.core.converter.CustomWriteConverter
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.redisson.api.RMap
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
vion.constant.RedisKeyEnum
;
import
vion.constant.RedisKeyEnum
;
import
java.util.Map
;
/**
/**
* @author HlQ
* @author HlQ
* @date 2024/2/2
* @date 2024/2/2
...
@@ -17,11 +16,11 @@ import java.util.Map;
...
@@ -17,11 +16,11 @@ import java.util.Map;
@RequiredArgsConstructor
@RequiredArgsConstructor
public
class
FaultTypeConverter
implements
CustomWriteConverter
<
Integer
,
Object
>
{
public
class
FaultTypeConverter
implements
CustomWriteConverter
<
Integer
,
Object
>
{
private
final
Redis
Template
redisTemplate
;
private
final
Redis
sonClient
redissonClient
;
@Override
@Override
public
Object
convert
(
Integer
originalData
,
CustomWriteContext
customWriteContext
)
{
public
Object
convert
(
Integer
originalData
,
CustomWriteContext
customWriteContext
)
{
Map
<
String
,
String
>
faultTypeMap
=
redisTemplate
.
opsForHash
().
entries
(
RedisKeyEnum
.
DICT_PREFIX
.
getVal
()
+
RedisKeyEnum
.
FAULT_TYPE
.
getVal
());
RMap
<
String
,
String
>
faultTypeMap
=
redissonClient
.
getMap
(
RedisKeyEnum
.
DICT_PREFIX
.
getVal
()
+
RedisKeyEnum
.
FAULT_TYPE
.
getVal
());
return
faultTypeMap
.
getOrDefault
(
originalData
.
toString
(),
"故障类型不存在"
);
return
faultTypeMap
.
getOrDefault
(
originalData
.
toString
(),
"故障类型不存在"
);
}
}
}
}
src/main/java/vion/config/RedisConfig.java
View file @
819a2be
package
vion
.
config
;
package
vion
.
config
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
org.redisson.Redisson
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
org.redisson.api.RedissonClient
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.redisson.codec.JsonJacksonCodec
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
org.redisson.config.Config
;
import
org.redisson.config.SingleServerConfig
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
java.text.SimpleDateFormat
;
/**
/**
* @author HlQ
* @author HlQ
...
@@ -20,32 +16,23 @@ import java.text.SimpleDateFormat;
...
@@ -20,32 +16,23 @@ import java.text.SimpleDateFormat;
@Configuration
@Configuration
public
class
RedisConfig
{
public
class
RedisConfig
{
@Bean
@Value
(
"${spring.data.redis.host}"
)
public
RedisTemplate
<
String
,
Object
>
redisTemplate
(
RedisConnectionFactory
factory
)
{
private
String
host
;
//我们为了自己开发方便,一般使用String , Object
@Value
(
"${spring.data.redis.port}"
)
RedisTemplate
<
String
,
Object
>
template
=
new
RedisTemplate
<>();
private
Integer
port
;
template
.
setConnectionFactory
(
factory
);
@Value
(
"${spring.data.redis.password}"
)
//序列化配置
private
String
password
;
//jackson的序列化
@Value
(
"${spring.data.redis.database}"
)
ObjectMapper
om
=
new
ObjectMapper
();
private
Integer
database
;
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
activateDefaultTyping
(
om
.
getPolymorphicTypeValidator
(),
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
// Date序列化 yyyy-MM-dd HH:mm:ss/yyyy-MM-dd hh:mm:ss:SSS
om
.
setDateFormat
(
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm:ss:SSS"
));
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
Jackson2JsonRedisSerializer
<
Object
>
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
<>(
om
,
Object
.
class
);
@Bean
(
destroyMethod
=
"shutdown"
)
//String 的序列化
public
RedissonClient
redissonClient
()
{
StringRedisSerializer
stringRedisSerializer
=
new
StringRedisSerializer
();
Config
config
=
new
Config
();
//key采用String的序列化方式
config
.
setCodec
(
JsonJacksonCodec
.
INSTANCE
);
template
.
setKeySerializer
(
stringRedisSerializer
);
SingleServerConfig
singleServerConfig
=
config
.
useSingleServer
();
//hash的key也采用String的序列化方式
singleServerConfig
.
setAddress
(
"redis://"
+
host
+
":"
+
port
)
template
.
setHashKeySerializer
(
stringRedisSerializer
);
.
setPassword
(
password
)
//value的序列化方式采用jackson
.
setDatabase
(
database
);
template
.
setValueSerializer
(
jackson2JsonRedisSerializer
);
return
Redisson
.
create
(
config
);
//hash的value也采用jackson的序列化方式
template
.
setHashValueSerializer
(
jackson2JsonRedisSerializer
);
template
.
afterPropertiesSet
();
return
template
;
}
}
}
}
src/main/java/vion/config/UserNameConverter.java
View file @
819a2be
package
vion
.
config
;
package
vion
.
config
;
import
org.dromara.hutool.core.lang.Opt
;
import
com.github.liaochong.myexcel.core.converter.CustomWriteContext
;
import
com.github.liaochong.myexcel.core.converter.CustomWriteContext
;
import
com.github.liaochong.myexcel.core.converter.CustomWriteConverter
;
import
com.github.liaochong.myexcel.core.converter.CustomWriteConverter
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.dromara.hutool.core.lang.Opt
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
vion.constant.RedisKeyEnum
;
import
vion.constant.RedisKeyEnum
;
import
vion.model.User
;
import
vion.model.User
;
...
@@ -17,13 +17,14 @@ import vion.model.User;
...
@@ -17,13 +17,14 @@ import vion.model.User;
@RequiredArgsConstructor
@RequiredArgsConstructor
public
class
UserNameConverter
implements
CustomWriteConverter
<
Long
,
String
>
{
public
class
UserNameConverter
implements
CustomWriteConverter
<
Long
,
String
>
{
private
final
Redis
Template
redisTemplate
;
private
final
Redis
sonClient
redissonClient
;
@Override
@Override
public
String
convert
(
Long
originalData
,
CustomWriteContext
customWriteContext
)
{
public
String
convert
(
Long
originalData
,
CustomWriteContext
customWriteContext
)
{
return
Opt
.
ofNullable
(((
User
)
redisTemplate
.
opsForValue
().
get
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_ID
.
getVal
()
+
originalData
)))
return
Opt
.
ofNullable
(
redissonClient
.
getBucket
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_ID
.
getVal
()
+
originalData
).
get
())
.
map
(
u
->
(
User
)
u
)
.
map
(
User:
:
getUsername
)
.
map
(
User:
:
getUsername
)
.
orElse
(
"未知"
);
.
orElse
(
"未知"
);
}
}
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/vion/cron/ContractRunner.java
View file @
819a2be
package
vion
.
cron
;
package
vion
.
cron
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.dromara.hutool.core.collection.CollUtil
;
import
org.dromara.hutool.core.collection.CollUtil
;
import
org.dromara.hutool.core.collection.ListUtil
;
import
org.dromara.hutool.core.collection.ListUtil
;
import
org.dromara.hutool.core.date.DateUtil
;
import
org.dromara.hutool.core.date.DateUtil
;
import
org.dromara.hutool.core.lang.Opt
;
import
org.dromara.hutool.core.lang.Opt
;
import
org.dromara.hutool.core.util.ObjUtil
;
import
org.dromara.hutool.core.text.StrUtil
;
import
org.dromara.hutool.core.text.StrUtil
;
import
lombok.RequiredArgsConstructor
;
import
org.dromara.hutool.core.util.ObjUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
vion.constant.RedisKeyEnum
;
import
vion.constant.RedisKeyEnum
;
import
vion.model.*
;
import
vion.model.Dictionary
;
import
vion.model.Dictionary
;
import
vion.model.*
;
import
vion.service.*
;
import
vion.service.*
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
...
@@ -37,7 +37,7 @@ public class ContractRunner {
...
@@ -37,7 +37,7 @@ public class ContractRunner {
private
final
IRContractStoreService
contractStoreService
;
private
final
IRContractStoreService
contractStoreService
;
private
final
IStoreService
storeService
;
private
final
IStoreService
storeService
;
private
final
IPaymentService
paymentService
;
private
final
IPaymentService
paymentService
;
private
final
Redis
Template
redisTemplate
;
private
final
Redis
sonClient
redissonClient
;
@Scheduled
(
cron
=
"0 0 * * * *"
)
@Scheduled
(
cron
=
"0 0 * * * *"
)
public
void
contractSync
()
{
public
void
contractSync
()
{
...
@@ -47,7 +47,7 @@ public class ContractRunner {
...
@@ -47,7 +47,7 @@ public class ContractRunner {
.
stream
().
collect
(
Collectors
.
toMap
(
Dictionary:
:
getValue
,
Dictionary:
:
getKey
));
.
stream
().
collect
(
Collectors
.
toMap
(
Dictionary:
:
getValue
,
Dictionary:
:
getKey
));
List
<
Contract
>
insOrUpdContractList
=
new
ArrayList
<>();
List
<
Contract
>
insOrUpdContractList
=
new
ArrayList
<>();
String
modifyTime
=
Opt
.
ofNullable
((
String
)
redis
Template
.
opsForValue
().
get
(
RedisKeyEnum
.
CONTRACT_SYNC_TIME
.
getVal
()
))
String
modifyTime
=
Opt
.
ofNullable
((
String
)
redis
sonClient
.
getBucket
(
RedisKeyEnum
.
CONTRACT_SYNC_TIME
.
getVal
()).
get
(
))
.
orElse
(
"1970-01-01 00:00:00"
);
.
orElse
(
"1970-01-01 00:00:00"
);
String
url
=
"jdbc:sqlserver://47.92.144.255:1433;databaseName=UFDATA_001_2020;encrypt=false"
;
String
url
=
"jdbc:sqlserver://47.92.144.255:1433;databaseName=UFDATA_001_2020;encrypt=false"
;
String
username
=
"vion-reader"
;
String
username
=
"vion-reader"
;
...
@@ -138,7 +138,7 @@ public class ContractRunner {
...
@@ -138,7 +138,7 @@ public class ContractRunner {
// 合同状态不为空,代表此条记录为新增,需要同步销售人信息到 r_contract_user 表中
// 合同状态不为空,代表此条记录为新增,需要同步销售人信息到 r_contract_user 表中
if
(
ObjUtil
.
isNotNull
(
v
.
getStatus
()))
{
if
(
ObjUtil
.
isNotNull
(
v
.
getStatus
()))
{
RContractUser
contractUser
=
new
RContractUser
();
RContractUser
contractUser
=
new
RContractUser
();
String
userId
=
Opt
.
ofNullable
(
redis
Template
.
opsForValue
().
get
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_NAME
.
getVal
()
+
v
.
getSaleName
()
))
String
userId
=
Opt
.
ofNullable
(
redis
sonClient
.
getBucket
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_NAME
.
getVal
()
+
v
.
getSaleName
()).
get
(
))
.
map
(
u
->
(
User
)
u
)
.
map
(
u
->
(
User
)
u
)
.
map
(
User:
:
getUserid
)
.
map
(
User:
:
getUserid
)
.
orElse
(
null
);
.
orElse
(
null
);
...
@@ -246,7 +246,7 @@ public class ContractRunner {
...
@@ -246,7 +246,7 @@ public class ContractRunner {
});
});
log
.
info
(
"【结束】从crm系统同步合同信息"
);
log
.
info
(
"【结束】从crm系统同步合同信息"
);
redis
Template
.
opsForValue
().
set
(
RedisKeyEnum
.
CONTRACT_SYNC_TIME
.
getVal
(),
DateUtil
.
formatDateTime
(
insOrUpdContractList
.
get
(
0
).
getOriginalModTime
()));
redis
sonClient
.
getBucket
(
RedisKeyEnum
.
CONTRACT_SYNC_TIME
.
getVal
()).
set
(
DateUtil
.
formatDateTime
(
insOrUpdContractList
.
get
(
0
).
getOriginalModTime
()));
}
}
@Scheduled
(
cron
=
"0 0 1 * * ?"
)
@Scheduled
(
cron
=
"0 0 1 * * ?"
)
...
...
src/main/java/vion/service/impl/DictionaryServiceImpl.java
View file @
819a2be
package
vion
.
service
.
impl
;
package
vion
.
service
.
impl
;
import
org.dromara.hutool.core.lang.Opt
;
import
com.github.yulichang.base.MPJBaseServiceImpl
;
import
com.github.yulichang.base.MPJBaseServiceImpl
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.dromara.hutool.core.lang.Opt
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
vion.constant.RedisKeyEnum
;
import
vion.constant.RedisKeyEnum
;
import
vion.mapper.DictionaryMapper
;
import
vion.mapper.DictionaryMapper
;
...
@@ -16,12 +16,12 @@ import java.util.stream.Collectors;
...
@@ -16,12 +16,12 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
@RequiredArgsConstructor
public
class
DictionaryServiceImpl
extends
MPJBaseServiceImpl
<
DictionaryMapper
,
Dictionary
>
implements
IDictionaryService
{
public
class
DictionaryServiceImpl
extends
MPJBaseServiceImpl
<
DictionaryMapper
,
Dictionary
>
implements
IDictionaryService
{
private
final
Redis
Template
redisTemplate
;
private
final
Redis
sonClient
redissonClient
;
@Override
@Override
public
void
syncDict
()
{
public
void
syncDict
()
{
Opt
.
ofEmptyAble
(
this
.
list
())
Opt
.
ofEmptyAble
(
this
.
list
())
.
map
(
l
->
l
.
stream
().
collect
(
Collectors
.
groupingBy
(
Dictionary:
:
getType
,
Collectors
.
toMap
(
d
->
d
.
getKey
().
toString
(),
Dictionary:
:
getValue
))))
.
map
(
l
->
l
.
stream
().
collect
(
Collectors
.
groupingBy
(
Dictionary:
:
getType
,
Collectors
.
toMap
(
d
->
d
.
getKey
().
toString
(),
Dictionary:
:
getValue
))))
.
ifPresent
(
m
->
m
.
forEach
((
type
,
map
)
->
redis
Template
.
opsForHash
().
putAll
(
RedisKeyEnum
.
DICT_PREFIX
.
getVal
()
+
RedisKeyEnum
.
getValByKey
(
type
),
map
)));
.
ifPresent
(
m
->
m
.
forEach
((
type
,
map
)
->
redis
sonClient
.
getMap
(
RedisKeyEnum
.
DICT_PREFIX
.
getVal
()
+
RedisKeyEnum
.
getValByKey
(
type
)).
putAll
(
map
)));
}
}
}
}
src/main/java/vion/service/impl/TaskServiceImpl.java
View file @
819a2be
...
@@ -24,8 +24,9 @@ import org.dromara.hutool.core.util.ObjUtil;
...
@@ -24,8 +24,9 @@ import org.dromara.hutool.core.util.ObjUtil;
import
org.dromara.hutool.crypto.SecureUtil
;
import
org.dromara.hutool.crypto.SecureUtil
;
import
org.dromara.hutool.json.JSONArray
;
import
org.dromara.hutool.json.JSONArray
;
import
org.dromara.hutool.json.JSONObject
;
import
org.dromara.hutool.json.JSONObject
;
import
org.redisson.api.RMap
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
vion.constant.RedisKeyEnum
;
import
vion.constant.RedisKeyEnum
;
...
@@ -57,7 +58,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -57,7 +58,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
private
final
DingMod
dingMod
;
private
final
DingMod
dingMod
;
private
final
WechatMod
wechatMod
;
private
final
WechatMod
wechatMod
;
private
final
Converter
converter
;
private
final
Converter
converter
;
private
final
Redis
Template
redisTemplate
;
private
final
Redis
sonClient
redissonClient
;
@Value
(
"${fileUrl:}"
)
@Value
(
"${fileUrl:}"
)
private
String
fileUrl
;
private
String
fileUrl
;
...
@@ -133,6 +134,8 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -133,6 +134,8 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
var
wrapper
=
new
MPJLambdaWrapper
<
Task
>()
var
wrapper
=
new
MPJLambdaWrapper
<
Task
>()
.
selectAll
(
Task
.
class
)
.
selectAll
(
Task
.
class
)
.
selectAs
(
Store:
:
getName
,
TaskVO:
:
getStoreName
)
.
selectAs
(
Store:
:
getName
,
TaskVO:
:
getStoreName
)
.
selectAs
(
Store:
:
getSalesperson
,
TaskVO:
:
getSalesperson
)
.
selectAs
(
Store:
:
getMaintainStatus
,
TaskVO:
:
getMaintainStatus
)
.
selectCollection
(
FileInfo
.
class
,
TaskTempVO:
:
getFileList
)
.
selectCollection
(
FileInfo
.
class
,
TaskTempVO:
:
getFileList
)
.
leftJoin
(
Store
.
class
,
Store:
:
getId
,
Task:
:
getStoreId
)
.
leftJoin
(
Store
.
class
,
Store:
:
getId
,
Task:
:
getStoreId
)
.
leftJoin
(
FileInfo
.
class
,
on
->
on
.
leftJoin
(
FileInfo
.
class
,
on
->
on
...
@@ -194,7 +197,8 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -194,7 +197,8 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
task
.
setUuid
(
IdUtil
.
nanoId
());
task
.
setUuid
(
IdUtil
.
nanoId
());
this
.
save
(
task
);
this
.
save
(
task
);
Opt
.
ofNullable
((
User
)
redisTemplate
.
opsForValue
().
get
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_ID
.
getVal
()
+
store
.
getSalesperson
()))
Opt
.
ofNullable
(
redissonClient
.
getBucket
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_ID
.
getVal
()
+
store
.
getSalesperson
()).
get
())
.
map
(
u
->
(
User
)
u
)
.
map
(
User:
:
getUserid
)
.
map
(
User:
:
getUserid
)
.
ifPresent
(
userid
->
dingMod
.
workMsg
(
buildMsg2
(
userid
,
store
.
getName
(),
task
)));
.
ifPresent
(
userid
->
dingMod
.
workMsg
(
buildMsg2
(
userid
,
store
.
getName
(),
task
)));
...
@@ -209,7 +213,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -209,7 +213,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
.
filter
(
CollUtil:
:
isNotEmpty
)
.
filter
(
CollUtil:
:
isNotEmpty
)
.
ifPresent
(
fileInfoList
->
fileInfoList
.
forEach
(
fileInfo
->
{
.
ifPresent
(
fileInfoList
->
fileInfoList
.
forEach
(
fileInfo
->
{
String
path
=
fileUrl
+
FileUtil
.
FILE_SEPARATOR
+
task
.
getStoreId
()
+
FileUtil
.
FILE_SEPARATOR
+
task
.
getId
()
+
FileUtil
.
FILE_SEPARATOR
+
fileInfo
.
getName
();
String
path
=
fileUrl
+
FileUtil
.
FILE_SEPARATOR
+
task
.
getStoreId
()
+
FileUtil
.
FILE_SEPARATOR
+
task
.
getId
()
+
FileUtil
.
FILE_SEPARATOR
+
fileInfo
.
getName
();
File
tarFile
=
File
Util
.
copy
(
fileInfo
.
getUrl
(),
path
,
true
);
FileUtil
.
copy
(
fileInfo
.
getUrl
(),
path
,
true
);
FileInfo
newFileInfo
=
new
FileInfo
();
FileInfo
newFileInfo
=
new
FileInfo
();
newFileInfo
.
setStoreId
(
task
.
getStoreId
());
newFileInfo
.
setStoreId
(
task
.
getStoreId
());
...
@@ -288,9 +292,11 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -288,9 +292,11 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
private
void
sendNotifications
(
Task
task
,
UserVO
user
,
Store
store
)
{
private
void
sendNotifications
(
Task
task
,
UserVO
user
,
Store
store
)
{
Task
existTask
=
this
.
getById
(
task
.
getId
());
Task
existTask
=
this
.
getById
(
task
.
getId
());
Long
activeUserId
=
task
.
getActiveUser
();
Long
activeUserId
=
task
.
getActiveUser
();
User
activeUser
=
(
User
)
redisTemplate
.
opsForValue
().
get
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_ID
.
getVal
()
+
activeUserId
);
Set
<
String
>
useridList
=
new
HashSet
<>();
Set
<
String
>
useridList
=
new
HashSet
<>();
useridList
.
add
(
activeUser
.
getUserid
());
Opt
.
ofNullable
(
redissonClient
.
getBucket
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_ID
.
getVal
()
+
activeUserId
).
get
())
.
map
(
u
->
(
User
)
u
)
.
map
(
User:
:
getUserid
)
.
ifPresent
(
useridList:
:
add
);
if
(
task
.
getStatus
()
==
3
)
{
if
(
task
.
getStatus
()
==
3
)
{
// 工单完成时,推送钉钉消息到预工单的确认人
// 工单完成时,推送钉钉消息到预工单的确认人
Opt
.
ofNullable
(
existTask
.
getTaskTempId
())
Opt
.
ofNullable
(
existTask
.
getTaskTempId
())
...
@@ -370,6 +376,8 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -370,6 +376,8 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
MPJLambdaWrapper
<
Task
>
wrapper
=
new
MPJLambdaWrapper
<
Task
>()
MPJLambdaWrapper
<
Task
>
wrapper
=
new
MPJLambdaWrapper
<
Task
>()
.
selectAll
(
Task
.
class
)
.
selectAll
(
Task
.
class
)
.
selectAs
(
Store:
:
getName
,
TaskVO:
:
getStoreName
)
.
selectAs
(
Store:
:
getName
,
TaskVO:
:
getStoreName
)
.
selectAs
(
Store:
:
getSalesperson
,
TaskVO:
:
getSalesperson
)
.
selectAs
(
Store:
:
getMaintainStatus
,
TaskVO:
:
getMaintainStatus
)
.
selectCollection
(
FaultLog
.
class
,
TaskVO:
:
getFaultLogList
)
.
selectCollection
(
FaultLog
.
class
,
TaskVO:
:
getFaultLogList
)
.
leftJoin
(
Store
.
class
,
Store:
:
getId
,
Task:
:
getStoreId
)
.
leftJoin
(
Store
.
class
,
Store:
:
getId
,
Task:
:
getStoreId
)
.
leftJoin
(
FaultLog
.
class
,
FaultLog:
:
getTaskId
,
Task:
:
getId
)
.
leftJoin
(
FaultLog
.
class
,
FaultLog:
:
getTaskId
,
Task:
:
getId
)
...
@@ -404,10 +412,13 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -404,10 +412,13 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
public
String
urgeTask
(
Long
taskId
,
String
remark
)
{
public
String
urgeTask
(
Long
taskId
,
String
remark
)
{
Task
task
=
this
.
getById
(
taskId
);
Task
task
=
this
.
getById
(
taskId
);
Long
activeUserId
=
task
.
getActiveUser
();
Long
activeUserId
=
task
.
getActiveUser
();
User
activeUser
=
(
User
)
redisTemplate
.
opsForValue
().
get
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_ID
.
getVal
()
+
activeUserId
);
String
userid
=
Opt
.
ofNullable
(
redissonClient
.
getBucket
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_ID
.
getVal
()
+
activeUserId
).
get
())
.
map
(
u
->
(
User
)
u
)
.
map
(
User:
:
getUserid
)
.
orElse
(
null
);
Store
store
=
storeService
.
getById
(
task
.
getStoreId
());
Store
store
=
storeService
.
getById
(
task
.
getStoreId
());
JSONObject
msg
=
buildMsg4
(
activeUser
.
getUserid
()
,
store
.
getName
(),
task
,
remark
);
JSONObject
msg
=
buildMsg4
(
userid
,
store
.
getName
(),
task
,
remark
);
String
pushRes
=
dingMod
.
workMsg
(
msg
);
String
pushRes
=
dingMod
.
workMsg
(
msg
);
if
(
StrUtil
.
contains
(
pushRes
,
"ok"
))
{
if
(
StrUtil
.
contains
(
pushRes
,
"ok"
))
{
return
"成功"
;
return
"成功"
;
...
@@ -511,7 +522,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -511,7 +522,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
}
}
JSONObject
buildMsg
(
String
userid
,
String
storeName
,
Task
task
)
{
JSONObject
buildMsg
(
String
userid
,
String
storeName
,
Task
task
)
{
Map
<
String
,
String
>
orderStatusMap
=
redisTemplate
.
opsForHash
().
entries
(
RedisKeyEnum
.
DICT_PREFIX
.
getVal
()
+
RedisKeyEnum
.
ORDER_STATUS
.
getVal
());
RMap
<
Integer
,
String
>
orderStatusMap
=
redissonClient
.
getMap
(
RedisKeyEnum
.
DICT_PREFIX
.
getVal
()
+
RedisKeyEnum
.
ORDER_STATUS
.
getVal
());
JSONObject
jsonObj
=
new
JSONObject
();
JSONObject
jsonObj
=
new
JSONObject
();
jsonObj
.
set
(
"agent_id"
,
2358374016L
);
jsonObj
.
set
(
"agent_id"
,
2358374016L
);
...
@@ -530,7 +541,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -530,7 +541,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
####
发送时间:
{}
####
发送时间:
{}
""";
""";
String markdown = StrUtil.format(template,
String markdown = StrUtil.format(template,
storeName, task.getUuid(), task.getRepairPeople(), task.getRepairPhone(), orderStatusMap.get(task.getStatus()
.toString()
), task.getFaultDescription(), DateUtil.now());
storeName, task.getUuid(), task.getRepairPeople(), task.getRepairPhone(), orderStatusMap.get(task.getStatus()), task.getFaultDescription(), DateUtil.now());
content.set("
markdown
", markdown);
content.set("
markdown
", markdown);
content.set("
btn_orientation
", "
1
");
content.set("
btn_orientation
", "
1
");
...
@@ -575,7 +586,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -575,7 +586,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
}
}
JSONObject
buildMsg3
(
String
userid
,
String
storeName
,
Task
task
)
{
JSONObject
buildMsg3
(
String
userid
,
String
storeName
,
Task
task
)
{
Map
<
String
,
String
>
orderStatusMap
=
redisTemplate
.
opsForHash
().
entries
(
RedisKeyEnum
.
DICT_PREFIX
.
getVal
()
+
RedisKeyEnum
.
ORDER_STATUS
.
getVal
());
RMap
<
Integer
,
String
>
orderStatusMap
=
redissonClient
.
getMap
(
RedisKeyEnum
.
DICT_PREFIX
.
getVal
()
+
RedisKeyEnum
.
ORDER_STATUS
.
getVal
());
JSONObject
jsonObj
=
new
JSONObject
();
JSONObject
jsonObj
=
new
JSONObject
();
jsonObj
.
set
(
"agent_id"
,
2358374016L
);
jsonObj
.
set
(
"agent_id"
,
2358374016L
);
...
@@ -594,7 +605,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -594,7 +605,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
#### 发送时间:{}
#### 发送时间:{}
"""
;
"""
;
String
markdown
=
StrUtil
.
format
(
template
,
String
markdown
=
StrUtil
.
format
(
template
,
storeName
,
task
.
getUuid
(),
task
.
getRepairPeople
(),
task
.
getRepairPhone
(),
orderStatusMap
.
get
(
task
.
getStatus
()
.
toString
()
),
task
.
getFaultDescription
(),
DateUtil
.
now
());
storeName
,
task
.
getUuid
(),
task
.
getRepairPeople
(),
task
.
getRepairPhone
(),
orderStatusMap
.
get
(
task
.
getStatus
()),
task
.
getFaultDescription
(),
DateUtil
.
now
());
content
.
set
(
"markdown"
,
markdown
);
content
.
set
(
"markdown"
,
markdown
);
content
.
set
(
"btn_orientation"
,
"1"
);
content
.
set
(
"btn_orientation"
,
"1"
);
...
@@ -609,7 +620,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -609,7 +620,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
}
}
JSONObject
buildMsg4
(
String
userid
,
String
storeName
,
Task
task
,
String
remark
)
{
JSONObject
buildMsg4
(
String
userid
,
String
storeName
,
Task
task
,
String
remark
)
{
Map
<
String
,
String
>
orderStatusMap
=
redisTemplate
.
opsForHash
().
entries
(
RedisKeyEnum
.
DICT_PREFIX
.
getVal
()
+
RedisKeyEnum
.
ORDER_STATUS
.
getVal
());
RMap
<
Integer
,
String
>
orderStatusMap
=
redissonClient
.
getMap
(
RedisKeyEnum
.
DICT_PREFIX
.
getVal
()
+
RedisKeyEnum
.
ORDER_STATUS
.
getVal
());
JSONObject
jsonObj
=
new
JSONObject
();
JSONObject
jsonObj
=
new
JSONObject
();
jsonObj
.
set
(
"agent_id"
,
2358374016L
);
jsonObj
.
set
(
"agent_id"
,
2358374016L
);
...
@@ -628,7 +639,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
...
@@ -628,7 +639,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
#### 发送时间:{}
#### 发送时间:{}
"""
;
"""
;
String
markdown
=
StrUtil
.
format
(
template
,
String
markdown
=
StrUtil
.
format
(
template
,
storeName
,
task
.
getUuid
(),
task
.
getRepairPeople
(),
task
.
getRepairPhone
(),
orderStatusMap
.
get
(
task
.
getStatus
()
.
toString
()
),
remark
,
DateUtil
.
now
());
storeName
,
task
.
getUuid
(),
task
.
getRepairPeople
(),
task
.
getRepairPhone
(),
orderStatusMap
.
get
(
task
.
getStatus
()),
remark
,
DateUtil
.
now
());
content
.
set
(
"markdown"
,
markdown
);
content
.
set
(
"markdown"
,
markdown
);
content
.
set
(
"btn_orientation"
,
"1"
);
content
.
set
(
"btn_orientation"
,
"1"
);
...
...
src/main/java/vion/third/DingMod.java
View file @
819a2be
package
vion
.
third
;
package
vion
.
third
;
import
cn.dev33.satoken.stp.StpUtil
;
import
cn.dev33.satoken.stp.StpUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
io.github.linpeilie.Converter
;
import
jakarta.servlet.http.HttpServletResponse
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.dromara.hutool.core.array.ArrayUtil
;
import
org.dromara.hutool.core.array.ArrayUtil
;
import
org.dromara.hutool.core.codec.binary.Base64
;
import
org.dromara.hutool.core.codec.binary.Base64
;
import
org.dromara.hutool.core.collection.CollUtil
;
import
org.dromara.hutool.core.collection.CollUtil
;
import
org.dromara.hutool.core.collection.ListUtil
;
import
org.dromara.hutool.core.collection.ListUtil
;
import
org.dromara.hutool.core.lang.Opt
;
import
org.dromara.hutool.core.lang.Opt
;
import
org.dromara.hutool.core.util.ObjUtil
;
import
org.dromara.hutool.core.text.StrUtil
;
import
org.dromara.hutool.core.text.StrUtil
;
import
org.dromara.hutool.core.util.ObjUtil
;
import
org.dromara.hutool.crypto.SecureUtil
;
import
org.dromara.hutool.crypto.SecureUtil
;
import
org.dromara.hutool.crypto.digest.mac.HMac
;
import
org.dromara.hutool.crypto.digest.mac.HMac
;
import
org.dromara.hutool.http.HttpUtil
;
import
org.dromara.hutool.http.HttpUtil
;
...
@@ -16,12 +21,8 @@ import org.dromara.hutool.http.client.Response;
...
@@ -16,12 +21,8 @@ import org.dromara.hutool.http.client.Response;
import
org.dromara.hutool.json.JSONArray
;
import
org.dromara.hutool.json.JSONArray
;
import
org.dromara.hutool.json.JSONObject
;
import
org.dromara.hutool.json.JSONObject
;
import
org.dromara.hutool.json.JSONUtil
;
import
org.dromara.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
org.redisson.api.RedissonClient
;
import
io.github.linpeilie.Converter
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
vion.constant.RedisKeyEnum
;
import
vion.constant.RedisKeyEnum
;
import
vion.dto.DingDTO
;
import
vion.dto.DingDTO
;
...
@@ -30,14 +31,12 @@ import vion.service.*;
...
@@ -30,14 +31,12 @@ import vion.service.*;
import
vion.vo.RoleVO
;
import
vion.vo.RoleVO
;
import
vion.vo.UserVO
;
import
vion.vo.UserVO
;
import
jakarta.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.time.Duration
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -61,7 +60,7 @@ public class DingMod {
...
@@ -61,7 +60,7 @@ public class DingMod {
private
final
IRRoleResourceService
roleResourceService
;
private
final
IRRoleResourceService
roleResourceService
;
private
final
IDeptService
deptService
;
private
final
IDeptService
deptService
;
private
final
Converter
converter
;
private
final
Converter
converter
;
private
final
Redis
Template
redisTemplate
;
private
final
Redis
sonClient
redissonClient
;
/**
/**
* 获取钉钉token
* 获取钉钉token
...
@@ -69,13 +68,13 @@ public class DingMod {
...
@@ -69,13 +68,13 @@ public class DingMod {
* @return java.lang.String
* @return java.lang.String
*/
*/
public
String
getToken
()
{
public
String
getToken
()
{
return
(
String
)
Opt
.
ofNullable
(
redis
Template
.
opsForValue
().
get
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
ACCESS_TOKEN
.
getVal
()
))
return
(
String
)
Opt
.
ofNullable
(
redis
sonClient
.
getBucket
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
ACCESS_TOKEN
.
getVal
()).
get
(
))
.
orElseGet
(()
->
{
.
orElseGet
(()
->
{
String
res
=
HttpUtil
.
get
(
"https://oapi.dingtalk.com/gettoken?appkey="
+
appKey
+
"&appsecret="
+
appSecret
);
String
res
=
HttpUtil
.
get
(
"https://oapi.dingtalk.com/gettoken?appkey="
+
appKey
+
"&appsecret="
+
appSecret
);
JSONObject
jsonObj
=
JSONUtil
.
parseObj
(
res
);
JSONObject
jsonObj
=
JSONUtil
.
parseObj
(
res
);
if
(
jsonObj
.
containsKey
(
"access_token"
))
{
if
(
jsonObj
.
containsKey
(
"access_token"
))
{
String
accessToken
=
jsonObj
.
getStr
(
"access_token"
);
String
accessToken
=
jsonObj
.
getStr
(
"access_token"
);
redis
Template
.
opsForValue
().
set
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
ACCESS_TOKEN
.
getVal
(),
accessToken
,
7000
,
TimeUnit
.
SECONDS
);
redis
sonClient
.
getBucket
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
ACCESS_TOKEN
.
getVal
()).
set
(
accessToken
,
Duration
.
ofSeconds
(
7000
)
);
return
accessToken
;
return
accessToken
;
}
}
return
""
;
return
""
;
...
@@ -92,11 +91,11 @@ public class DingMod {
...
@@ -92,11 +91,11 @@ public class DingMod {
Long
offset
=
0L
;
Long
offset
=
0L
;
boolean
flag
=
true
;
boolean
flag
=
true
;
while
(
flag
)
{
while
(
flag
)
{
JSONObject
paramJson
=
new
JSONObject
();
// 2:试用期 3:正式 5:待离职 -1:无状态
// 2:试用期 3:正式 5:待离职 -1:无状态
paramJson
.
set
(
"status_list"
,
"2,3,5,-1"
);
JSONObject
paramJson
=
JSONUtil
.
ofObj
()
paramJson
.
set
(
"size"
,
50
);
.
set
(
"status_list"
,
"2,3,5,-1"
)
paramJson
.
set
(
"offset"
,
offset
);
.
set
(
"size"
,
50
)
.
set
(
"offset"
,
offset
);
String
res
=
HttpUtil
.
post
(
"https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/queryonjob?access_token="
+
accessToken
,
paramJson
.
toString
());
String
res
=
HttpUtil
.
post
(
"https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/queryonjob?access_token="
+
accessToken
,
paramJson
.
toString
());
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
res
);
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
res
);
if
(
jsonObject
.
getBool
(
"success"
,
false
))
{
if
(
jsonObject
.
getBool
(
"success"
,
false
))
{
...
@@ -120,10 +119,10 @@ public class DingMod {
...
@@ -120,10 +119,10 @@ public class DingMod {
List
<
List
<
String
>>
userIdListSplit
=
ListUtil
.
partition
(
userIdList
,
90
);
List
<
List
<
String
>>
userIdListSplit
=
ListUtil
.
partition
(
userIdList
,
90
);
userIdListSplit
.
forEach
(
tmpList
->
{
userIdListSplit
.
forEach
(
tmpList
->
{
JSONObject
paramJson
=
new
JSONObject
();
JSONObject
paramJson
=
JSONUtil
.
ofObj
()
paramJson
.
set
(
"agentid"
,
2358374016L
);
.
set
(
"agentid"
,
2358374016L
)
paramJson
.
set
(
"userid_list"
,
String
.
join
(
","
,
tmpList
));
.
set
(
"userid_list"
,
String
.
join
(
","
,
tmpList
))
paramJson
.
set
(
"field_filter_list"
,
"sys00-name,sys00-mobile,sys00-mainDeptId,sys00-mainDept,sys01-employeeStatus"
);
.
set
(
"field_filter_list"
,
"sys00-name,sys00-mobile,sys00-mainDeptId,sys00-mainDept,sys01-employeeStatus"
);
String
res
=
HttpUtil
.
post
(
"https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/list?access_token="
+
accessToken
,
paramJson
.
toString
());
String
res
=
HttpUtil
.
post
(
"https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/list?access_token="
+
accessToken
,
paramJson
.
toString
());
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
res
);
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
res
);
...
@@ -150,8 +149,8 @@ public class DingMod {
...
@@ -150,8 +149,8 @@ public class DingMod {
}
}
userService
.
saveOrUpdate
(
user
,
Wrappers
.<
User
>
lambdaUpdate
().
eq
(
User:
:
getUserid
,
userid
));
userService
.
saveOrUpdate
(
user
,
Wrappers
.<
User
>
lambdaUpdate
().
eq
(
User:
:
getUserid
,
userid
));
User
one
=
userService
.
lambdaQuery
().
eq
(
User:
:
getUserid
,
userid
).
one
();
User
one
=
userService
.
lambdaQuery
().
eq
(
User:
:
getUserid
,
userid
).
one
();
redis
Template
.
opsForValue
().
set
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_ID
.
getVal
()
+
one
.
getId
(),
user
);
redis
sonClient
.
getBucket
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_ID
.
getVal
()
+
one
.
getId
()).
set
(
user
);
redis
Template
.
opsForValue
().
set
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_NAME
.
getVal
()
+
one
.
getUsername
(),
user
);
redis
sonClient
.
getBucket
(
RedisKeyEnum
.
DING_PREFIX
.
getVal
()
+
RedisKeyEnum
.
USER_NAME
.
getVal
()
+
one
.
getUsername
()).
set
(
user
);
}
}
}
}
});
});
...
@@ -208,11 +207,11 @@ public class DingMod {
...
@@ -208,11 +207,11 @@ public class DingMod {
*/
*/
public
Object
dingCallback
(
String
target
,
DingDTO
dto
,
HttpServletResponse
res
)
{
public
Object
dingCallback
(
String
target
,
DingDTO
dto
,
HttpServletResponse
res
)
{
if
(
StrUtil
.
equals
(
target
,
"login"
))
{
if
(
StrUtil
.
equals
(
target
,
"login"
))
{
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
JSONUtil
.
ofObj
()
jsonObject
.
set
(
"clientId"
,
appKey
);
.
set
(
"clientId"
,
appKey
)
jsonObject
.
set
(
"clientSecret"
,
appSecret
);
.
set
(
"clientSecret"
,
appSecret
)
jsonObject
.
set
(
"code"
,
dto
.
getAuthCode
());
.
set
(
"code"
,
dto
.
getAuthCode
())
jsonObject
.
set
(
"grantType"
,
"authorization_code"
);
.
set
(
"grantType"
,
"authorization_code"
);
String
tokenRes
=
HttpUtil
.
post
(
"https://api.dingtalk.com/v1.0/oauth2/userAccessToken"
,
jsonObject
.
toString
());
String
tokenRes
=
HttpUtil
.
post
(
"https://api.dingtalk.com/v1.0/oauth2/userAccessToken"
,
jsonObject
.
toString
());
JSONObject
tokenObj
=
JSONUtil
.
parseObj
(
tokenRes
);
JSONObject
tokenObj
=
JSONUtil
.
parseObj
(
tokenRes
);
if
(!
tokenObj
.
containsKey
(
"accessToken"
))
{
if
(!
tokenObj
.
containsKey
(
"accessToken"
))
{
...
...
src/main/java/vion/vo/TaskVO.java
View file @
819a2be
...
@@ -24,8 +24,12 @@ public class TaskVO {
...
@@ -24,8 +24,12 @@ public class TaskVO {
/**
/**
* 门店名称
* 门店名称
*/
*/
@ExcelColumn
(
order
=
0
,
title
=
"项目名称"
)
@ExcelColumn
(
title
=
"项目名称"
)
private
String
storeName
;
private
String
storeName
;
private
Integer
salesperson
;
private
String
maintainStatus
;
/**
/**
* 预处理工单id
* 预处理工单id
*/
*/
...
...
src/main/resources/application-dev.properties
View file @
819a2be
...
@@ -10,7 +10,7 @@ spring.data.redis.password=RtOTnx2V
...
@@ -10,7 +10,7 @@ spring.data.redis.password=RtOTnx2V
spring.data.redis.port
=
6379
spring.data.redis.port
=
6379
spring.data.redis.database
=
8
spring.data.redis.database
=
8
wx.mp.config-
storage.type
=
Redis
Template
wx.mp.config-
storage.type
=
Redis
son
wx.mp.config-storage.key-
prefix
=
wa
wx.mp.config-storage.key-
prefix
=
wa
wx.mp.config-
storage.redis.host
=
r-2zejlb88mng3q50aw7pd.redis.rds.aliyuncs.com
wx.mp.config-
storage.redis.host
=
r-2zejlb88mng3q50aw7pd.redis.rds.aliyuncs.com
wx.mp.config-
storage.redis.password
=
=RtOTnx2V
wx.mp.config-
storage.redis.password
=
=RtOTnx2V
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment