Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bailuntec-cost
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huluobin
bailuntec-cost
Commits
5159d402
Commit
5159d402
authored
Aug 26, 2021
by
liyanlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
企业微信通知
parent
0e776427
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
1 deletion
+75
-1
WxWebHook.java
.../java/com/blt/other/common/config/property/WxWebHook.java
+29
-0
FinalCheckState.java
...r/module/cost/service/impl/costcheck/FinalCheckState.java
+36
-0
application-prod.yml
cost-service/src/main/resources/application-prod.yml
+6
-1
application-test.yml
cost-service/src/main/resources/application-test.yml
+4
-0
No files found.
cost-service/src/main/java/com/blt/other/common/config/property/WxWebHook.java
0 → 100644
View file @
5159d402
package
com
.
blt
.
other
.
common
.
config
.
property
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
/**
* @Author: li.yanlin
* @Description: 企业微信通知
* @Date: Created in
* @Modified by:
*/
@Component
@Data
@ConfigurationProperties
(
"wx-hook"
)
public
class
WxWebHook
{
/**
* base URL
*/
private
String
url
;
/**
* 最终审核
*/
private
String
finalReview
;
private
String
test
;
}
cost-service/src/main/java/com/blt/other/module/cost/service/impl/costcheck/FinalCheckState.java
View file @
5159d402
package
com
.
blt
.
other
.
module
.
cost
.
service
.
impl
.
costcheck
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.blt.other.common.config.property.WxWebHook
;
import
com.blt.other.common.exception.BizRuntimeException
;
import
com.blt.other.database.model.CostCompanyDomain
;
import
com.blt.other.database.model.CostLogDomain
;
import
com.blt.other.database.model.UserDomain
;
import
com.blt.other.module.auth.dao.UserDao
;
import
com.blt.other.module.cost.dao.CostCurrentReviewerMapper
;
import
com.blt.other.module.cost.dao.CostLogDao
;
import
com.blt.other.module.cost.model.ApprovalHistoryDomain
;
...
...
@@ -14,12 +17,16 @@ import com.blt.other.module.cost.service.ApprovalHistoryService;
import
com.blt.other.module.sys.model.CostReviewer
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.lang.reflect.Array
;
import
java.nio.charset.StandardCharsets
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -62,6 +69,32 @@ public class FinalCheckState extends CostState {
costContext
.
costService
.
toFinancial
(
costDomain
);
}
@Resource
WxWebHook
webHook
;
@Resource
RestTemplate
restTemplate
;
@Resource
UserDao
userDao
;
private
void
sendWxMsg
(
CostDomain
costDomain
,
Integer
currentUserId
)
{
UserDomain
userDomain
=
userDao
.
selectByuserid
(
currentUserId
);
DateTimeFormatter
dtf
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
String
msg
=
String
.
format
(
"{\n"
+
" \"msgtype\": \"markdown\",\n"
+
" \"markdown\": {\n"
+
" \"content\": \"单号【<font color=\\\"info\\\">%s</font>】通过最终审核。\\n"
+
">金额: <font color=\\\"info\\\">%s</font>\\n"
+
">审核人: <font color=\\\"info\\\">%s</font>\\n"
+
">审核时间: <font color=\\\"info\\\">%s</font>\""
+
" }\n"
+
"}"
,
costDomain
.
getCostNo
(),
"CNY "
+
costDomain
.
getAmountRmb
(),
userDomain
==
null
?
currentUserId
:
userDomain
.
getUsername
(),
LocalDateTime
.
now
().
format
(
dtf
));
restTemplate
.
getMessageConverters
().
set
(
1
,
new
StringHttpMessageConverter
(
StandardCharsets
.
UTF_8
));
restTemplate
.
postForEntity
(
webHook
.
getUrl
()
+
webHook
.
getFinalReview
(),
msg
,
Object
.
class
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
handle
()
{
...
...
@@ -79,6 +112,7 @@ public class FinalCheckState extends CostState {
CostLogDomain
costLogDomain
=
costLogDao
.
selectDepartmentCheckLog
(
costDomain
.
getCostNo
());
List
<
CostCurrentReviewer
>
costCurrentReviewerList
=
costCurrentReviewerMapper
.
selectByCostNo
(
costDomain
.
getCostNo
());
if
(
costLogDomain
!=
null
&&
costCurrentReviewerList
.
stream
().
map
(
CostCurrentReviewer:
:
getOaUserId
).
collect
(
Collectors
.
toList
()).
contains
(
costLogDomain
.
getUpdateUserid
()))
{
log
.
info
(
"费用单:{}部门审核人和最终审核人是同一个人,最终审核人自动通过。"
,
costDomain
.
getCostNo
());
this
.
autoPass
();
return
;
...
...
@@ -119,6 +153,8 @@ public class FinalCheckState extends CostState {
costLogService
.
save
(
costDomain
.
getCostNo
(),
currentUserId
,
"最终审核通过"
,
CostLogDomain
.
FINAL_MANUAL_PASS
);
approvalHistoryService
.
save
(
approvalHistoryDomain
);
sendWxMsg
(
costDomain
,
currentUserId
);
//流转状态
nextState
(
unPayState
);
//通知财务系统
...
...
cost-service/src/main/resources/application-prod.yml
View file @
5159d402
...
...
@@ -20,7 +20,7 @@ spring:
publisher-returns
:
true
data
:
mongodb
:
uri
:
'
mongodb://admin:!%40#blt*mongo123@
10.0.12.3
:27018/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false'
uri
:
'
mongodb://admin:!%40#blt*mongo123@
42.193.191.242
:27018/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false'
database
:
bailuntec-cost
thymeleaf
:
...
...
@@ -107,3 +107,8 @@ net-suite:
realm
:
6916374
do-work
:
true
wx-hook
:
url
:
https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=
final-review
:
87e1dfa2-d54a-4126-afcf-95fbd68e74d8
test
:
8ecc859b-0548-4640-a47b-cd03d873b364
cost-service/src/main/resources/application-test.yml
View file @
5159d402
...
...
@@ -105,3 +105,7 @@ net-suite:
token-secret
:
d974ba497472b258a06175cc62a2edba6104f94c131afba38143e8c3a2f0e125
realm
:
6916374_SB1
do-work
:
false
wx-hook
:
url
:
https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=
final-review
:
87e1dfa2-d54a-4126-afcf-95fbd68e74d8
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