Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-fb
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
王衍超
cloud-fb
Commits
c01db56e
Commit
c01db56e
authored
Jun 21, 2021
by
wukaiqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
针对预警修改 lookName/lookType的后台值
parent
080af68c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
34 deletions
+53
-34
BaseBusinessWarn.java
...c/main/java/com/xyst/dinas/biz/warn/BaseBusinessWarn.java
+53
-34
No files found.
backend/xyst.dinas.biz/src/main/java/com/xyst/dinas/biz/warn/BaseBusinessWarn.java
View file @
c01db56e
...
@@ -37,16 +37,16 @@ import com.xyst.dinas.biz.warn.service.WarningService;
...
@@ -37,16 +37,16 @@ import com.xyst.dinas.biz.warn.service.WarningService;
*/
*/
public
class
BaseBusinessWarn
{
public
class
BaseBusinessWarn
{
/** 业务类型*/
/** 业务类型
*/
protected
String
billType
;
protected
String
billType
;
/** 业务ID*/
/** 业务ID
*/
protected
UUID
billId
;
protected
UUID
billId
;
/** 指标*/
/** 指标
*/
protected
String
target
;
protected
String
target
;
/** 预警设置ID*/
/** 预警设置ID
*/
protected
UUID
warnSettingId
;
protected
UUID
warnSettingId
;
private
IWarningCalculator
warningCalculate
;
private
IWarningCalculator
warningCalculate
;
...
@@ -56,7 +56,6 @@ public class BaseBusinessWarn {
...
@@ -56,7 +56,6 @@ public class BaseBusinessWarn {
private
RemindService
remindService
;
private
RemindService
remindService
;
private
StaffService
staffService
;
private
StaffService
staffService
;
@Value
(
"${beecode.tenant.username:}"
)
@Value
(
"${beecode.tenant.username:}"
)
private
String
userName
;
private
String
userName
;
...
@@ -83,15 +82,15 @@ public class BaseBusinessWarn {
...
@@ -83,15 +82,15 @@ public class BaseBusinessWarn {
staffDAO
=
getStaffDAO
();
staffDAO
=
getStaffDAO
();
}
}
/** 预警设置*/
/** 预警设置
*/
public
WarnSetting
getWarnSetting
()
{
public
WarnSetting
getWarnSetting
()
{
if
(
warnSettingId
!=
null
)
{
if
(
warnSettingId
!=
null
)
{
return
warningSettingService
.
getWarnSetting
(
warnSettingId
);
return
warningSettingService
.
getWarnSetting
(
warnSettingId
);
}
}
return
warningSettingService
.
getWarnSetting
(
billType
,
billId
,
target
);
return
warningSettingService
.
getWarnSetting
(
billType
,
billId
,
target
);
}
}
/** 计算是否预警*/
/** 计算是否预警
*/
public
final
void
setWarningCalculate
(
IWarningCalculator
warningCalculate
)
{
public
final
void
setWarningCalculate
(
IWarningCalculator
warningCalculate
)
{
this
.
warningCalculate
=
warningCalculate
;
this
.
warningCalculate
=
warningCalculate
;
}
}
...
@@ -102,6 +101,7 @@ public class BaseBusinessWarn {
...
@@ -102,6 +101,7 @@ public class BaseBusinessWarn {
/**
/**
* 预警
* 预警
*
* @param isNotice 是否发送通知
* @param isNotice 是否发送通知
* @return
* @return
*/
*/
...
@@ -109,42 +109,46 @@ public class BaseBusinessWarn {
...
@@ -109,42 +109,46 @@ public class BaseBusinessWarn {
boolean
isWarning
=
false
;
boolean
isWarning
=
false
;
WarnSetting
warnSetting
=
getWarnSetting
();
WarnSetting
warnSetting
=
getWarnSetting
();
if
(
warnSetting
==
null
||
!
warnSetting
.
isOpen
())
return
false
;
//
if
(
warnSetting
==
null
||
!
warnSetting
.
isOpen
())
if
(
warningCalculate
==
null
&&
warnSetting
.
warnCalculator
()!=
null
)
{
return
false
;
//
warningCalculate
=
Amino
.
getApplicationMetadataContext
().
getBean
(
warnSetting
.
warnCalculator
(),
IWarningCalculator
.
class
);
if
(
warningCalculate
==
null
&&
warnSetting
.
warnCalculator
()
!=
null
)
{
warningCalculate
=
Amino
.
getApplicationMetadataContext
().
getBean
(
warnSetting
.
warnCalculator
(),
IWarningCalculator
.
class
);
}
}
Assert
.
notNull
(
warningCalculate
,
"The warningCalculate must not be null!"
);
Assert
.
notNull
(
warningCalculate
,
"The warningCalculate must not be null!"
);
isWarning
=
warningCalculate
.
isWarning
(
warnSetting
);
isWarning
=
warningCalculate
.
isWarning
(
warnSetting
);
//记录预警日志
//
记录预警日志
UUID
warnSettingId
=
warnSetting
.
getSettingId
();
UUID
warnSettingId
=
warnSetting
.
getSettingId
();
WarnExeRecord
warnExeRecord
=
warningSettingService
.
queryWarnExeRecord
(
warnSettingId
);
WarnExeRecord
warnExeRecord
=
warningSettingService
.
queryWarnExeRecord
(
warnSettingId
);
//1.当前没有执行中的预警记录
//
1.当前没有执行中的预警记录
if
(
warnExeRecord
==
null
)
{
if
(
warnExeRecord
==
null
)
{
if
(!
isWarning
)
return
false
;
//1.1 没有触发预警, 则不做任何操作;
if
(!
isWarning
)
//1.2 新增预警执行信息
return
false
;
// 1.1 没有触发预警,则不做任何操作;
// 1.2 新增预警执行信息
warnExeRecord
=
createWarnExeRecord
(
warnSetting
);
warnExeRecord
=
createWarnExeRecord
(
warnSetting
);
warnExeRecord
.
setActualValue
(
warningCalculate
.
getActualValue
());
warnExeRecord
.
setActualValue
(
warningCalculate
.
getActualValue
());
warnExeRecord
.
setMessage
(
warningCalculate
.
warnMessage
());
warnExeRecord
.
setMessage
(
warningCalculate
.
warnMessage
());
warningSettingService
.
insertWarnExe
(
warnExeRecord
);
warningSettingService
.
insertWarnExe
(
warnExeRecord
);
}
else
{
}
else
{
//2.当前存在执行中的预警记录,则修改预警执行信息
//
2.当前存在执行中的预警记录,则修改预警执行信息
Date
currentTime
=
new
Date
();
Date
currentTime
=
new
Date
();
warnExeRecord
.
setRecentlyTime
(
currentTime
);
warnExeRecord
.
setRecentlyTime
(
currentTime
);
warnExeRecord
.
setActualValue
(
warningCalculate
.
getActualValue
());
warnExeRecord
.
setActualValue
(
warningCalculate
.
getActualValue
());
if
(!
isWarning
)
{
//2.1 如果没有触发预警,则结束该预警记录
if
(!
isWarning
)
{
// 2.1 如果没有触发预警,则结束该预警记录
warnExeRecord
.
setEndTime
(
currentTime
);
warnExeRecord
.
setEndTime
(
currentTime
);
warnExeRecord
.
setMessage
(
warningCalculate
.
warnMessage
());
warnExeRecord
.
setMessage
(
warningCalculate
.
warnMessage
());
warnExeRecord
.
setWarnState
(
WarnStateEnum
.
OVER
.
getValue
());
warnExeRecord
.
setWarnState
(
WarnStateEnum
.
OVER
.
getValue
());
}
}
warningSettingService
.
updateWarnExe
(
warnExeRecord
);
warningSettingService
.
updateWarnExe
(
warnExeRecord
);
}
}
//通知人员
//
通知人员
String
[]
noticePerson
=
warnSetting
.
getPersonnel
();
String
[]
noticePerson
=
warnSetting
.
getPersonnel
();
String
message
=
warningCalculate
.
warnMessage
();
String
message
=
warningCalculate
.
warnMessage
();
try
{
try
{
if
(
isWarning
&&
isNotice
)
if
(
isWarning
&&
isNotice
)
notice
(
noticePerson
,
message
,
warnSetting
.
getBillId
());
notice
(
noticePerson
,
message
,
warnSetting
.
getBillId
()
,
warnSetting
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -169,13 +173,13 @@ public class BaseBusinessWarn {
...
@@ -169,13 +173,13 @@ public class BaseBusinessWarn {
/**
/**
* 通知所有人员
* 通知所有人员
*
* @param noticePerson
* @param noticePerson
* @param message
* @param message
* @param billId
* @param billId
* @throws Exception
* @throws Exception
*/
*/
private
void
notice
(
String
[]
noticePerson
,
String
message
,
UUID
billId
)
throws
Exception
{
private
void
notice
(
String
[]
noticePerson
,
String
message
,
UUID
billId
,
WarnSetting
warnSetting
)
throws
Exception
{
Date
currentTime
=
new
Date
();
Date
currentTime
=
new
Date
();
String
currentTimeStr
=
DateUtil
.
dateTime2String
(
currentTime
);
String
currentTimeStr
=
DateUtil
.
dateTime2String
(
currentTime
);
JSONObject
remObject
=
new
JSONObject
();
JSONObject
remObject
=
new
JSONObject
();
...
@@ -183,20 +187,32 @@ public class BaseBusinessWarn {
...
@@ -183,20 +187,32 @@ public class BaseBusinessWarn {
remObject
.
put
(
"id"
,
remindId
);
remObject
.
put
(
"id"
,
remindId
);
remObject
.
put
(
"createTime"
,
currentTimeStr
);
remObject
.
put
(
"createTime"
,
currentTimeStr
);
remObject
.
put
(
"remindTime"
,
currentTimeStr
);
remObject
.
put
(
"remindTime"
,
currentTimeStr
);
remObject
.
put
(
"remindContent"
,
message
);
//消息
remObject
.
put
(
"remindContent"
,
message
);
// 消息
remObject
.
put
(
"data"
,
billId
);
remObject
.
put
(
"data"
,
billId
);
// remObject.put("lookName", "");//标题
remObject
.
put
(
"lookName"
,
""
);
//标题
remObject
.
put
(
"lookName"
,
warnSetting
.
getTarget
());
// 标题
remObject
.
put
(
"lookType"
,
"Contract"
);
String
lookTypeName
=
warnSetting
.
getBillType
().
substring
(
0
,
2
);
String
lookType
=
"Contract"
;
if
(
lookTypeName
.
equals
(
"散客"
))
{
lookType
=
"RetailInfo"
;
}
else
if
(
lookTypeName
.
equals
(
"采区"
))
{
lookType
=
"SandMiningArea"
;
}
else
if
(
lookTypeName
.
equals
(
"库存"
))
{
lookType
=
"Inventory"
;
}
else
if
(
lookTypeName
.
equals
(
"合同"
))
{
lookType
=
"Contract"
;
}
// remObject.put("lookType", "Contract");
remObject
.
put
(
"lookType"
,
lookType
);
remObject
.
put
(
"_type"
,
CommonConstants
.
REMIND_ENTITY
);
remObject
.
put
(
"_type"
,
CommonConstants
.
REMIND_ENTITY
);
remObject
.
put
(
"isToCustomer"
,
false
);
remObject
.
put
(
"isToCustomer"
,
false
);
KObject
kobject
=
(
KObject
)
JSONObjectUtils
.
toObject
(
remObject
.
toString
());
KObject
kobject
=
(
KObject
)
JSONObjectUtils
.
toObject
(
remObject
.
toString
());
KObject
creater
=
null
;
KObject
creater
=
null
;
List
<
KObject
>
list
=
staffDAO
.
listStaffByUsername
(
"sysadmin"
);
List
<
KObject
>
list
=
staffDAO
.
listStaffByUsername
(
"sysadmin"
);
if
(
list
.
isEmpty
())
{
if
(
list
.
isEmpty
())
{
creater
=
MessageUtils
.
gerCurrentStaff
();
creater
=
MessageUtils
.
gerCurrentStaff
();
}
else
{
}
else
{
creater
=
list
.
get
(
0
);
creater
=
list
.
get
(
0
);
}
}
kobject
.
set
(
"sender"
,
creater
);
//
kobject
.
set
(
"sender"
,
creater
);
//
...
@@ -210,23 +226,23 @@ public class BaseBusinessWarn {
...
@@ -210,23 +226,23 @@ public class BaseBusinessWarn {
parts
.
put
(
part
);
parts
.
put
(
part
);
}
}
List
<
KObject
>
listRes
=
new
ArrayList
<
KObject
>();
List
<
KObject
>
listRes
=
new
ArrayList
<
KObject
>();
for
(
int
i
=
0
;
i
<
parts
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
parts
.
length
();
i
++)
{
JSONObject
item
=
parts
.
getJSONObject
(
i
);
JSONObject
item
=
parts
.
getJSONObject
(
i
);
item
.
put
(
"_type"
,
CommonConstants
.
REM_PART_RELATION_ENTITTY
);
item
.
put
(
"_type"
,
CommonConstants
.
REM_PART_RELATION_ENTITTY
);
item
.
put
(
"remindId"
,
remindId
);
item
.
put
(
"remindId"
,
remindId
);
item
.
put
(
"id"
,
UUID
.
randomUUID
());
item
.
put
(
"id"
,
UUID
.
randomUUID
());
String
partType
=
item
.
getString
(
RemPartRelationConstants
.
PARTICIPATE_TYPE
);
String
partType
=
item
.
getString
(
RemPartRelationConstants
.
PARTICIPATE_TYPE
);
if
(
ParterType
.
PERSON
.
getPartnerType
().
equals
(
partType
))
{
if
(
ParterType
.
PERSON
.
getPartnerType
().
equals
(
partType
))
{
//参与者id是员工的id
//
参与者id是员工的id
String
staffPartId
=
item
.
getString
(
RemPartRelationConstants
.
PARTICIPATE_ID
);
String
staffPartId
=
item
.
getString
(
RemPartRelationConstants
.
PARTICIPATE_ID
);
//根据员工的参与者id获得userId
//
根据员工的参与者id获得userId
KObject
staffKObject
=
staffService
.
getById
(
UUID
.
fromString
(
staffPartId
));
KObject
staffKObject
=
staffService
.
getById
(
UUID
.
fromString
(
staffPartId
));
KObject
userKObject
=
staffKObject
.
get
(
Staff
.
USER
);
KObject
userKObject
=
staffKObject
.
get
(
Staff
.
USER
);
String
userId
=
userKObject
.
getString
(
"id"
);
String
userId
=
userKObject
.
getString
(
"id"
);
item
.
put
(
RemPartRelationConstants
.
PARTICIPATE_ID
,
userId
);
item
.
put
(
RemPartRelationConstants
.
PARTICIPATE_ID
,
userId
);
}
}
KObject
entity
=(
KObject
)
JSONObjectUtils
.
toObject
(
item
.
toString
());
KObject
entity
=
(
KObject
)
JSONObjectUtils
.
toObject
(
item
.
toString
());
listRes
.
add
(
entity
);
listRes
.
add
(
entity
);
entity
.
validate
();
entity
.
validate
();
}
}
...
@@ -236,12 +252,15 @@ public class BaseBusinessWarn {
...
@@ -236,12 +252,15 @@ public class BaseBusinessWarn {
private
WarningService
getWarningSettingService
()
{
private
WarningService
getWarningSettingService
()
{
return
Amino
.
getApplicationMetadataContext
().
getBean
(
WarningService
.
class
);
return
Amino
.
getApplicationMetadataContext
().
getBean
(
WarningService
.
class
);
}
}
private
RemindService
getRemindService
()
{
private
RemindService
getRemindService
()
{
return
Amino
.
getApplicationMetadataContext
().
getBean
(
RemindService
.
class
);
return
Amino
.
getApplicationMetadataContext
().
getBean
(
RemindService
.
class
);
}
}
private
StaffService
getStaffService
()
{
private
StaffService
getStaffService
()
{
return
Amino
.
getApplicationMetadataContext
().
getBean
(
StaffService
.
class
);
return
Amino
.
getApplicationMetadataContext
().
getBean
(
StaffService
.
class
);
}
}
private
StaffDAO
getStaffDAO
()
{
private
StaffDAO
getStaffDAO
()
{
return
Amino
.
getApplicationMetadataContext
().
getBean
(
StaffDAO
.
class
);
return
Amino
.
getApplicationMetadataContext
().
getBean
(
StaffDAO
.
class
);
}
}
...
...
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