Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
POC
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBizPOC_20003
POC
提交
65e95160
提交
65e95160
编写于
4月 07, 2020
作者:
MoneyQ
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加新文件
上级
6fe4bd4c
变更
1
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
277 行增加
和
0 行删除
+277
-0
UsrIMServiceImpl.java
.../java/com/ibiz/core/ht/service/impl/UsrIMServiceImpl.java
+277
-0
未找到文件。
im-usr/src/main/java/com/ibiz/core/ht/service/impl/UsrIMServiceImpl.java
0 → 100644
浏览文件 @
65e95160
package
com
.
ibiz
.
core
.
ht
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ibiz.core.ht.domain.IM
;
import
com.ibiz.core.ht.filter.IMSearchContext
;
import
com.ibiz.core.ht.service.IIMService
;
import
com.ibiz.core.r7rt_org.domain.OrgDeptUser
;
import
com.ibiz.core.r7rt_org.filter.OrgDeptUserSearchContext
;
import
com.ibiz.core.r7rt_org.filter.OrgUserSearchContext
;
import
com.ibiz.core.r7rt_org.service.IOrgDeptUserService
;
import
com.ibiz.core.r7rt_org.service.IOrgUserService
;
import
com.ibiz.util.config.UniWFClientProperties
;
import
com.ibiz.util.feign.FeignRequestInterceptor
;
import
com.ibiz.util.feign.UniWFFeignClient
;
import
com.ibiz.util.feign.suport.SearchContextFeignEncode
;
import
com.ibiz.util.helper.SpringContextHolder
;
import
com.ibiz.util.security.userdetail.LoginUser
;
import
feign.Client
;
import
feign.Contract
;
import
feign.Feign
;
import
feign.codec.Decoder
;
import
feign.codec.Encoder
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* 实体[重要事项] 服务对象接口实现
*/
@Service
@Primary
@Slf4j
public
class
UsrIMServiceImpl
extends
IMServiceImpl
{
@Autowired
IOrgUserService
iOrgUserService
;
@Autowired
IOrgDeptUserService
iOrgDeptUserService
;
UniWFClientProperties
uniWFClientProperties
;
UniWFFeignClient
uniWFFeignClient
;
@Autowired
public
UsrIMServiceImpl
(
Decoder
decoder
,
Encoder
encoder
,
Client
client
,
Contract
contract
,
FeignRequestInterceptor
feignRequestInterceptor
,
UniWFClientProperties
uniWFClientProperties
)
{
this
.
uniWFClientProperties
=
uniWFClientProperties
;
if
(
uniWFClientProperties
.
getServiceId
()!=
null
)
{
Feign
.
Builder
nameBuilder
=
Feign
.
builder
()
.
client
(
client
)
.
encoder
(
encoder
)
.
decoder
(
decoder
)
.
contract
(
contract
)
.
requestInterceptor
(
feignRequestInterceptor
)
;
this
.
uniWFFeignClient
=
nameBuilder
.
target
(
UniWFFeignClient
.
class
,
"http://"
+
uniWFClientProperties
.
getServiceId
()
+
"/"
)
;
}
else
if
(
uniWFClientProperties
.
getServiceUrl
()!=
null
)
{
if
(
client
instanceof
LoadBalancerFeignClient
)
{
client
=
((
LoadBalancerFeignClient
)
client
).
getDelegate
();
}
Feign
.
Builder
nameBuilder
=
Feign
.
builder
()
.
client
(
client
)
.
encoder
(
encoder
)
.
decoder
(
decoder
)
.
contract
(
contract
)
.
requestInterceptor
(
feignRequestInterceptor
)
;
this
.
uniWFFeignClient
=
nameBuilder
.
target
(
UniWFFeignClient
.
class
,
"http://"
+
uniWFClientProperties
.
getServiceUrl
()
+
"/"
)
;
}
}
@Override
@Transactional
public
IM
getMP
(
IM
im
)
{
if
(
im
==
null
)
{
return
im
;
}
// 部门领导
im
.
setBmldids
(
analysisPickupData3
(
im
.
getBmld
()));
// 领导
im
.
setLdids
(
analysisPickupData3
(
im
.
getLd
()));
// 跨公司部门领导
im
.
setKgsldids
(
analysisPickupData3
(
im
.
getKgsld
()));
// 内部审核
im
.
setNgshids
(
analysisPickupData3
(
im
.
getNgsh
()));
// 会签部门
im
.
setHqbmids
(
getOrgUserByDept2
(
analysisPickupData2
(
im
.
getHqbm
())));
// 跨公司部门
im
.
setKgsbmids
(
getOrgUserByDept2
(
analysisPickupData2
(
im
.
getKgsbm
())));
return
im
;
}
@Override
public
IM
createAndStart
(
IM
im
)
{
if
(
im
==
null
)
{
return
null
;
}
// 创建im数据
this
.
create
(
im
);
String
orgUserId
=
im
.
getCreateMan
();
JSONObject
loginUser
=
new
JSONObject
();
loginUser
.
put
(
"personId"
,
"062a3530-ea68-b7b8-6781-c977cd295995"
);
loginUser
.
put
(
"orgUserName"
,
"MoneyQ"
);
loginUser
.
put
(
"orgId"
,
"7feb41d6ba62a0a2a816cd5c76ce18e7"
);
loginUser
.
put
(
"orgName"
,
"华泰证券股份有限公司"
);
loginUser
.
put
(
"orgDeptId"
,
"857e21e5-6df8-f12f-d07b-f1ce95573c4d"
);
loginUser
.
put
(
"orgDeptName"
,
"综合管理部"
);
// 流程启动
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"proxymoduleid"
,
"IM"
);
data
.
put
(
"proxydataid"
,
im
.
getIMId
());
data
.
put
(
"loginuser"
,
loginUser
);
StartWFThread
startWFThread
=
new
StartWFThread
(
"e3300d30bd7a736b2df727f2c5945348"
,
data
);
startWFThread
.
start
();
return
im
;
}
/**
* 根据部门标识获取人员清单(String) 方法1<br>
* 目标数据格式<br>
* key1,key2,key3,key4
*
* @param deptids 部门标识列表
* @return 人员清单(String);没有数据则返回null
*/
private
String
getOrgUserByDept1
(
List
<
String
>
deptids
)
{
if
(
deptids
==
null
)
{
return
null
;
}
List
<
String
>
rstList
=
new
ArrayList
<>();
for
(
String
deptid
:
deptids
)
{
OrgDeptUserSearchContext
hqbmCond
=
new
OrgDeptUserSearchContext
();
hqbmCond
.
setN_orgdeptid_eq
(
deptid
);
hqbmCond
.
setPageable
(
PageRequest
.
of
(
0
,
1000
));
Page
<
OrgDeptUser
>
users
=
iOrgDeptUserService
.
searchDefault
(
hqbmCond
);
if
(
users
==
null
||
users
.
getContent
().
size
()
==
0
)
{
return
null
;
}
for
(
OrgDeptUser
user
:
users
)
{
rstList
.
add
(
user
.
getOrgUserId
());
}
}
return
String
.
join
(
","
,
rstList
);
}
/**
* 根据部门标识获取人员清单(String) 方法2<br>
* 目标数据格式<br>
* [{"srfmajortext":"majortext1","srfkey":"key1"},{"srfmajortext":"majortext2","srfkey":"key2"},{"srfmajortext":"majortext3","srfkey":"key3"},{"srfmajortext":"majortext4","srfkey":"key4"}]
*
* @param deptids 部门标识列表
* @return 人员清单(String);没有数据则返回null
*/
private
String
getOrgUserByDept2
(
List
<
String
>
deptids
)
{
if
(
deptids
==
null
)
{
return
null
;
}
List
<
PickupData
>
rstList
=
new
ArrayList
<>();
for
(
String
deptid
:
deptids
)
{
OrgDeptUserSearchContext
hqbmCond
=
new
OrgDeptUserSearchContext
();
hqbmCond
.
setN_orgdeptid_eq
(
deptid
);
hqbmCond
.
setPageable
(
PageRequest
.
of
(
0
,
1000
));
Page
<
OrgDeptUser
>
users
=
iOrgDeptUserService
.
searchDefault
(
hqbmCond
);
if
(
users
==
null
||
users
.
getContent
().
size
()
==
0
)
{
return
null
;
}
for
(
OrgDeptUser
user
:
users
)
{
PickupData
pickupData
=
new
PickupData
();
pickupData
.
setSrfkey
(
user
.
getOrgUserId
());
pickupData
.
setSrfmajortext
(
user
.
getOrgUserName
());
rstList
.
add
(
pickupData
);
}
}
return
JSONArray
.
toJSONString
(
rstList
);
}
/**
* 解析地址选择栏数据 方法1<br>
* 源数据<br>
* [{"srfmajortext":"majortext1","srfkey":"key1"},{"srfmajortext":"majortext2","srfkey":"key2"},{"srfmajortext":"majortext3","srfkey":"key3"},{"srfmajortext":"majortext4","srfkey":"key4"}]<br>
* 目标数据(String)<br>
* key1,key2,key3,key4
*
* @param oriStr 带解析数据
* @return 解析之后的数据;不符合规则的则返回null
*/
private
String
analysisPickupData1
(
String
oriStr
)
{
List
<
String
>
rstList
=
analysisPickupData2
(
oriStr
);
if
(
rstList
==
null
)
{
return
null
;
}
return
String
.
join
(
","
,
rstList
);
}
/**
* 解析地址选择栏数据 方法2<br>
* 源数据<br>
* [{"srfmajortext":"majortext1","srfkey":"key1"},{"srfmajortext":"majortext2","srfkey":"key2"},{"srfmajortext":"majortext3","srfkey":"key3"},{"srfmajortext":"majortext4","srfkey":"key4"}]<br>
* 目标数据(List)<br>
* [key1,key2,key3,key4]
*
* @param oriStr 带解析数据
* @return 解析之后的数据;不符合规则的则返回null
*/
private
List
<
String
>
analysisPickupData2
(
String
oriStr
)
{
if
(
oriStr
==
null
||
oriStr
.
isEmpty
())
{
return
null
;
}
log
.
debug
(
"analysisPickupData2 ("
+
oriStr
+
")"
);
JSONArray
array
=
JSONArray
.
parseArray
(
oriStr
);
if
(
array
==
null
||
array
.
size
()
==
0
)
{
return
null
;
}
List
<
String
>
rstList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++)
{
JSONObject
jo
=
array
.
getJSONObject
(
i
);
rstList
.
add
(
jo
.
getString
(
"srfkey"
));
}
return
rstList
;
}
/**
* 解析地址选择栏数据 方法3(无变动)<br>
* 源数据<br>
* [{"srfmajortext":"majortext1","srfkey":"key1"},{"srfmajortext":"majortext2","srfkey":"key2"},{"srfmajortext":"majortext3","srfkey":"key3"},{"srfmajortext":"majortext4","srfkey":"key4"}]<br>
* 目标数据(String)<br>
* [{"srfmajortext":"majortext1","srfkey":"key1"},{"srfmajortext":"majortext2","srfkey":"key2"},{"srfmajortext":"majortext3","srfkey":"key3"},{"srfmajortext":"majortext4","srfkey":"key4"}]
*
* @param oriStr 带解析数据
* @return 解析之后的数据;不符合规则的则返回null
*/
private
String
analysisPickupData3
(
String
oriStr
)
{
return
oriStr
;
}
@Data
private
class
PickupData
{
private
String
srfmajortext
;
private
String
srfkey
;
}
private
class
StartWFThread
extends
Thread
{
private
String
pswfversion_id
;
private
JSONObject
data
;
StartWFThread
(
String
pswfversion_id
,
JSONObject
data
)
{
this
.
pswfversion_id
=
pswfversion_id
;
this
.
data
=
data
;
}
@Override
public
void
run
(){
uniWFFeignClient
.
apiWfStart
(
pswfversion_id
,
data
);
}
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录