Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
refined-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
refined-platform
Commits
b8f5d925
Commit
b8f5d925
authored
Apr 08, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加消息发送
parent
350a04f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
120 deletions
+124
-120
refined-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/SubEventStartedService.java
...xhx/daemon/applicationservice/SubEventStartedService.java
+3
-1
refined-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/SyncWorkmanStartedService.java
.../daemon/applicationservice/SyncWorkmanStartedService.java
+107
-107
refined-manager/src/main/java/com/mortals/xhx/daemon/task/SyncAppointWaitAndFinTaskImpl.java
...ortals/xhx/daemon/task/SyncAppointWaitAndFinTaskImpl.java
+14
-12
No files found.
refined-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/SubEventStartedService.java
View file @
b8f5d925
...
...
@@ -38,7 +38,9 @@ public class SubEventStartedService implements IApplicationStartedService {
public
void
start
()
{
ThreadPool
.
getInstance
().
init
(
10
);
new
AlarmSendMsgThread
().
start
();
AlarmSendMsgThread
alarmSendMsgThread
=
new
AlarmSendMsgThread
();
ThreadPool
.
getInstance
().
execute
(
alarmSendMsgThread
);
/* Constants.DEFAULT_TIMEOUT=12000;
...
...
refined-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/SyncWorkmanStartedService.java
View file @
b8f5d925
package
com.mortals.xhx.daemon.applicationservice
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.IdcardUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.springcloud.service.IApplicationStartedService
;
import
com.mortals.xhx.common.code.SourceEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.module.hik.person.model.req.person.PersonReq
;
import
com.mortals.xhx.module.hik.person.model.rsp.person.PersonDataInfo
;
import
com.mortals.xhx.module.hik.person.service.IHikPersonService
;
import
com.mortals.xhx.module.person.model.PersonEntity
;
import
com.mortals.xhx.module.person.service.PersonService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 同步工作人员到本地注册人员中
*
* @author:
* @date: 2023/4/24 10:50
*/
//@Component
@Slf4j
public
class
SyncWorkmanStartedService
implements
IApplicationStartedService
{
@Autowired
private
PersonService
personService
;
@Autowired
private
IHikPersonService
hikPersonService
;
@Override
public
void
start
()
{
log
.
info
(
"开始服务..[工作人员同步]"
);
PersonReq
personReq
=
new
PersonReq
();
personReq
.
setPageNo
(
1
);
personReq
.
setPageSize
(
3
);
Rest
<
PersonDataInfo
>
personListRest
=
hikPersonService
.
getPersonList
(
personReq
);
if
(
personListRest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
List
<
PersonEntity
>
collect
=
personListRest
.
getData
().
getList
().
parallelStream
().
map
(
work
->
{
//判断是否存在,存在更新,
if
(
work
.
getCertificateType
()
==
990
)
{
work
.
setCertificateNo
(
StrUtil
.
subSufByLength
(
work
.
getPersonId
(),
20
));
}
PersonEntity
personEntity
=
personService
.
getExtCache
(
work
.
getCertificateNo
());
if
(
ObjectUtils
.
isEmpty
(
personEntity
))
{
personEntity
=
new
PersonEntity
();
personEntity
.
initAttrValue
();
personEntity
.
setName
(
work
.
getPersonName
());
personEntity
.
setGender
(
work
.
getGender
()
==
1
?
0
:
1
);
personEntity
.
setIdCard
(
work
.
getCertificateNo
());
personEntity
.
setPhone
(
work
.
getPhoneNo
());
try
{
personEntity
.
setBirthday
(
DateUtil
.
parse
(
IdcardUtil
.
getBirth
(
work
.
getCertificateNo
()),
"yyyyMMdd"
));
}
catch
(
Exception
e
)
{
}
personEntity
.
setServerIndexCode
(
work
.
getPersonPhoto
().
getServerIndexCode
());
personEntity
.
setPicUrl
(
work
.
getPersonPhoto
().
getPicUri
());
personEntity
.
setSource
(
SourceEnum
.
海康系统
.
getValue
());
personEntity
.
setCreateTime
(
new
Date
());
personEntity
.
setCreateUserId
(
1L
);
personEntity
.
setCreateUserName
(
"system"
);
return
personEntity
;
}
return
personEntity
;
}).
collect
(
Collectors
.
toList
());
Map
<
Boolean
,
List
<
PersonEntity
>>
booleanListMap
=
collect
.
parallelStream
().
collect
(
Collectors
.
partitioningBy
(
x
->
x
.
getId
()
==
null
));
List
<
PersonEntity
>
savePersonList
=
booleanListMap
.
get
(
true
);
List
<
PersonEntity
>
updatePersonList
=
booleanListMap
.
get
(
false
);
if
(!
ObjectUtils
.
isEmpty
(
savePersonList
))
{
log
.
info
(
"新增人员数量:{}"
,
savePersonList
.
size
());
personService
.
save
(
savePersonList
);
}
if
(!
ObjectUtils
.
isEmpty
(
updatePersonList
))
{
log
.
info
(
"更新人员数量:{}"
,
updatePersonList
.
size
());
// personService.update(updatePersonList);
}
}
}
@Override
public
void
stop
()
{
log
.
info
(
"停止服务.."
);
}
@Override
public
int
getOrder
()
{
return
11
;
}
}
//
package com.mortals.xhx.daemon.applicationservice;
//
//
import cn.hutool.core.date.DateUtil;
//
import cn.hutool.core.util.IdcardUtil;
//
import cn.hutool.core.util.StrUtil;
//
import com.mortals.framework.common.Rest;
//
import com.mortals.framework.springcloud.service.IApplicationStartedService;
//
import com.mortals.xhx.common.code.SourceEnum;
//
import com.mortals.xhx.common.code.YesNoEnum;
//
import com.mortals.xhx.module.hik.person.model.req.person.PersonReq;
//
import com.mortals.xhx.module.hik.person.model.rsp.person.PersonDataInfo;
//
import com.mortals.xhx.module.hik.person.service.IHikPersonService;
//
import com.mortals.xhx.module.person.model.PersonEntity;
//
import com.mortals.xhx.module.person.service.PersonService;
//
import lombok.extern.slf4j.Slf4j;
//
import org.springframework.beans.factory.annotation.Autowired;
//
import org.springframework.util.ObjectUtils;
//
//
import java.util.Date;
//
import java.util.List;
//
import java.util.Map;
//
import java.util.stream.Collectors;
//
/
//
**
//
* 同步工作人员到本地注册人员中
//
*
//
* @author:
//
* @date: 2023/4/24 10:50
//
*/
//
//
@Component
//
@Slf4j
//
public class SyncWorkmanStartedService implements IApplicationStartedService {
///*
@Autowired
//
private PersonService personService;
//
@Autowired
// private IHikPersonService hikPersonService;*/
//
//
//
@Override
//
public void start() {
//
log.info("开始服务..[工作人员同步]");
//
//
PersonReq personReq = new PersonReq();
//
personReq.setPageNo(1);
//
personReq.setPageSize(3);
//
Rest<PersonDataInfo> personListRest = hikPersonService.getPersonList(personReq);
//
if (personListRest.getCode() == YesNoEnum.YES.getValue()) {
//
List<PersonEntity> collect = personListRest.getData().getList().parallelStream().map(work -> {
//
//判断是否存在,存在更新,
//
if (work.getCertificateType() == 990) {
//
work.setCertificateNo(StrUtil.subSufByLength(work.getPersonId(), 20));
//
}
//
PersonEntity personEntity = personService.getExtCache(work.getCertificateNo());
//
if (ObjectUtils.isEmpty(personEntity)) {
//
personEntity = new PersonEntity();
//
personEntity.initAttrValue();
//
personEntity.setName(work.getPersonName());
//
personEntity.setGender(work.getGender() == 1 ? 0 : 1);
//
personEntity.setIdCard(work.getCertificateNo());
//
personEntity.setPhone(work.getPhoneNo());
//
try {
//
personEntity.setBirthday(DateUtil.parse(IdcardUtil.getBirth(work.getCertificateNo()), "yyyyMMdd"));
//
} catch (Exception e) {
//
}
//
personEntity.setServerIndexCode(work.getPersonPhoto().getServerIndexCode());
//
personEntity.setPicUrl(work.getPersonPhoto().getPicUri());
//
personEntity.setSource(SourceEnum.海康系统.getValue());
//
personEntity.setCreateTime(new Date());
//
personEntity.setCreateUserId(1L);
//
personEntity.setCreateUserName("system");
//
return personEntity;
//
}
//
return personEntity;
//
}).collect(Collectors.toList());
//
//
Map<Boolean, List<PersonEntity>> booleanListMap = collect.parallelStream().collect(Collectors.partitioningBy(x -> x.getId() == null));
//
List<PersonEntity> savePersonList = booleanListMap.get(true);
//
List<PersonEntity> updatePersonList = booleanListMap.get(false);
//
//
if (!ObjectUtils.isEmpty(savePersonList)) {
//
log.info("新增人员数量:{}", savePersonList.size());
//
personService.save(savePersonList);
//
}
//
//
if (!ObjectUtils.isEmpty(updatePersonList)) {
//
log.info("更新人员数量:{}", updatePersonList.size());
//
// personService.update(updatePersonList);
//
}
//
//
//
}
//
//
//
}
//
//
@Override
//
public void stop() {
//
log.info("停止服务..");
//
}
//
//
@Override
//
public int getOrder() {
//
return 11;
//
}
//
//
//
}
refined-manager/src/main/java/com/mortals/xhx/daemon/task/SyncAppointWaitAndFinTaskImpl.java
View file @
b8f5d925
...
...
@@ -15,6 +15,7 @@ import com.mortals.framework.service.ITask;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.util.DataUtil
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.ThreadPool
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.busiz.rsp.register.AppointmentDataInfo
;
...
...
@@ -116,7 +117,7 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
private
void
syncWaitAndFinQueue
()
{
RedisTemplate
<
String
,
String
>
redisTemplate
=
cacheService
.
selectDbRedisTemplate
(
redisDb
);
// cacheService.select(redisDb);//
new
Thread
(()
->
{
Thread
thread
=
new
Thread
(()
->
{
List
<
WaitPersonInfo
>
waitPersonInfos
=
new
ArrayList
<>();
List
<
FinPersonInfo
>
finPersonInfos
=
new
ArrayList
<>();
List
<
EndPersonInfo
>
endPersonInfos
=
new
ArrayList
<>();
...
...
@@ -155,10 +156,10 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
List
<
CpPersonInfo
>
cpPersonInfos
=
new
ArrayList
<>();
while
(
true
)
{
String
value
=
redisTemplate
.
opsForList
().
leftPop
(
RedisKey
.
KEY_CP_LIST_CACHE
,
5
,
TimeUnit
.
SECONDS
);
log
.
info
(
"cp:{}"
,
value
);
String
value
=
redisTemplate
.
opsForList
().
leftPop
(
RedisKey
.
KEY_CP_LIST_CACHE
,
5
,
TimeUnit
.
SECONDS
);
log
.
info
(
"cp:{}"
,
value
);
CpPersonInfo
cpPersonInfo
=
JSON
.
parseObject
(
value
,
CpPersonInfo
.
class
);
log
.
info
(
"cp obj:{}"
,
JSON
.
toJSONString
(
cpPersonInfo
));
log
.
info
(
"cp obj:{}"
,
JSON
.
toJSONString
(
cpPersonInfo
));
if
(
ObjectUtils
.
isEmpty
(
cpPersonInfo
))
{
break
;
}
else
{
...
...
@@ -217,11 +218,11 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
//todo 构造发送消息。
AlarmRecordsEntity
recordsEntity
=
new
AlarmRecordsEntity
();
recordsEntity
.
initAttrValue
();
double
doTime
=
NumberUtil
.
div
(
Double
.
parseDouble
((
diff
)
+
""
),
60
,
1
);
// 保留1位小数,四舍五入
double
upTime
=
NumberUtil
.
div
(
Double
.
parseDouble
((
diff
-
avgWait
)+
""
),
60
,
1
);
// 保留1位小数,四舍五入
double
doTime
=
NumberUtil
.
div
(
Double
.
parseDouble
((
diff
)
+
""
),
60
,
1
);
// 保留1位小数,四舍五入
double
upTime
=
NumberUtil
.
div
(
Double
.
parseDouble
((
diff
-
avgWait
)
+
""
),
60
,
1
);
// 保留1位小数,四舍五入
String
alarmContent
=
String
.
format
(
"排队编号:%s:,%s业务叫号等待时间为%d分钟,超过了平均等待时长%d分钟!"
,
item
.
getQueueNo
(),
item
.
getBussinessName
(),
doTime
,
upTime
);
item
.
getQueueNo
(),
item
.
getBussinessName
(),
doTime
,
upTime
);
recordsEntity
.
setAlarmContent
(
alarmContent
);
recordsEntity
.
setAlarmTime
(
new
Date
());
recordsEntity
.
setCreateTime
(
new
Date
());
...
...
@@ -265,10 +266,10 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
AlarmRecordsEntity
recordsEntity
=
new
AlarmRecordsEntity
();
recordsEntity
.
initAttrValue
();
double
doTime
=
NumberUtil
.
div
(
Double
.
parseDouble
((
diff
)
+
""
),
60
,
1
);
// 保留1位小数,四舍五入
double
upTime
=
NumberUtil
.
div
(
Double
.
parseDouble
((
diff
-
avgWait
)+
""
),
60
,
1
);
// 保留1位小数,四舍五入
double
doTime
=
NumberUtil
.
div
(
Double
.
parseDouble
((
diff
)
+
""
),
60
,
1
);
// 保留1位小数,四舍五入
double
upTime
=
NumberUtil
.
div
(
Double
.
parseDouble
((
diff
-
avgWait
)
+
""
),
60
,
1
);
// 保留1位小数,四舍五入
String
alarmContent
=
String
.
format
(
"编号:%s:,%s业务办理时间为%d分钟,超过了平均办理时长%d分钟!"
,
item
.
getBussinessName
(),
doTime
,
upTime
);
String
alarmContent
=
String
.
format
(
"编号:%s:,%s业务办理时间为%d分钟,超过了平均办理时长%d分钟!"
,
item
.
getBussinessName
(),
doTime
,
upTime
);
recordsEntity
.
setAlarmContent
(
alarmContent
);
recordsEntity
.
setAlarmTime
(
new
Date
());
recordsEntity
.
setCreateTime
(
new
Date
());
...
...
@@ -316,7 +317,7 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
recordsEntity
.
initAttrValue
();
String
alarmContent
=
String
.
format
(
"客户对窗口:%s:,工作人员%s 发起评价:%s,评价内容:%s!"
,
careCpRecordsEntity
.
getWindowName
(),
cpPersonInfo
.
getWorkmanName
(),
cpPersonInfo
.
getOptionId
(),
cpPersonInfo
.
getContent
());
careCpRecordsEntity
.
getWindowName
(),
cpPersonInfo
.
getWorkmanName
(),
cpPersonInfo
.
getOptionId
(),
cpPersonInfo
.
getContent
());
recordsEntity
.
setAlarmContent
(
alarmContent
);
recordsEntity
.
setAlarmTime
(
new
Date
());
recordsEntity
.
setCreateTime
(
new
Date
());
...
...
@@ -324,7 +325,8 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
alarmRecordsService
.
save
(
recordsEntity
);
}
}
}).
start
();
});
ThreadPool
.
getInstance
().
execute
(
thread
);
}
...
...
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