Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c57988dc
authored
Nov 20, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(ID1004033):博西PEA_V1.0-消息预警:服务类和容量类消息没有推送
1 parent
6d7f4d37
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
2 deletions
project-order/src/main/java/com/dituhui/pea/order/scheduler/CalcOrgCapacityScheduler.java
project-order/src/main/java/com/dituhui/pea/order/scheduler/CalcOrgCapacityScheduler.java
View file @
c57988d
package
com
.
dituhui
.
pea
.
order
.
scheduler
;
import
com.dituhui.pea.order.common.DateUtils
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.common.jackson.DateTimeUtil
;
import
com.dituhui.pea.order.common.jackson.DateUtil
;
import
com.dituhui.pea.order.dao.CapacityOrgStatDao
;
import
com.dituhui.pea.order.dao.CapacityStatisticDao
;
import
com.dituhui.pea.order.dao.CapacityTeamStatDao
;
import
com.dituhui.pea.order.dao.OrgBranchDao
;
import
com.dituhui.pea.order.dao.OrgClusterDao
;
import
com.dituhui.pea.order.dao.OrgGroupDao
;
import
com.dituhui.pea.order.dao.OrgTeamDao
;
import
com.dituhui.pea.order.dto.CapacityOrgStatDTO
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.dto.MsgDTO
;
import
com.dituhui.pea.order.entity.CapacityOrgStatEntity
;
import
com.dituhui.pea.order.entity.CapacityTeamStatEntity
;
import
com.dituhui.pea.order.entity.OrgBranchEntity
;
import
com.dituhui.pea.order.entity.OrgClusterEntity
;
import
com.dituhui.pea.order.entity.OrgGroupEntity
;
import
com.dituhui.pea.order.entity.OrgTeamEntity
;
import
com.dituhui.pea.order.service.MsgService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
...
...
@@ -12,6 +28,7 @@ import org.springframework.stereotype.Component;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.text.MessageFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
...
...
@@ -35,6 +52,10 @@ public class CalcOrgCapacityScheduler {
private
CapacityOrgStatDao
capacityOrgStatDao
;
@Autowired
private
CapacityTeamStatDao
capacityTeamStatDao
;
@Autowired
private
MsgService
msgService
;
@Autowired
private
OrgClusterDao
orgClusterDao
;
@Value
(
"${scheduler.calc-org-capacity.day-offset-begin}"
)
private
int
dayOffsetBegin
;
...
...
@@ -127,6 +148,12 @@ public class CalcOrgCapacityScheduler {
entity
.
setUpdateTime
(
LocalDateTime
.
now
());
// todo entity.setOrderCount();
capacityOrgStatDao
.
save
(
entity
);
double
usedPercentage
=
(
double
)
dto
.
getCapUsed
()
/
dto
.
getCapTotal
();
log
.
info
(
"[calcOneBranch] {}小组容量已使用占比{}"
,
groupId
,
usedPercentage
);
if
(
BigDecimal
.
valueOf
(
usedPercentage
).
compareTo
(
new
BigDecimal
(
"0.8"
))
>=
0
)
{
addCapacityMsg
(
""
,
""
,
groupId
,
LocalDate
.
parse
(
date
,
DateUtil
.
DATE_FORMATTER
),
dto
.
getLayer
());
}
}
}
...
...
@@ -165,7 +192,43 @@ public class CalcOrgCapacityScheduler {
entity
.
setUpdateTime
(
LocalDateTime
.
now
());
// todo entity.setOrderCount();
capacityOrgStatDao
.
save
(
entity
);
double
usedPercentage
=
(
double
)
dto
.
getCapUsed
()
/
dto
.
getCapTotal
();
log
.
info
(
"[calcOneBranch] {}分部容量已使用占比{}"
,
branchId
,
usedPercentage
);
if
(
BigDecimal
.
valueOf
(
usedPercentage
).
compareTo
(
new
BigDecimal
(
"0.8"
))
>=
0
)
{
addCapacityMsg
(
""
,
branchId
,
""
,
LocalDate
.
parse
(
date
,
DateUtil
.
DATE_FORMATTER
),
dto
.
getLayer
());
}
}
}
private
void
addCapacityMsg
(
String
clusterId
,
String
branchId
,
String
groupId
,
LocalDate
targetDate
,
String
layer
)
{
MsgDTO
msgDTO
=
new
MsgDTO
();
msgDTO
.
setType
(
2
);
String
msg
=
"{0}{1}的容量在{2}已预约达80%"
;
String
msgBrand
=
""
;
if
(
StringUtils
.
isNotBlank
(
clusterId
))
{
OrgClusterEntity
cluster
=
orgClusterDao
.
getByClusterId
(
clusterId
);
msgBrand
=
cluster
.
getName
();
msgDTO
.
setClusterId
(
clusterId
);
}
if
(
StringUtils
.
isNotBlank
(
branchId
))
{
OrgBranchEntity
branch
=
orgBranchDao
.
getByBranchId
(
branchId
);
msgBrand
=
branch
.
getBranchName
();
msgDTO
.
setBranchId
(
branchId
);
}
if
(
StringUtils
.
isNotBlank
(
groupId
))
{
OrgGroupEntity
group
=
orgGroupDao
.
getByGroupId
(
groupId
);
msgBrand
=
group
.
getGroupName
();
msgDTO
.
setGroupId
(
groupId
);
}
msg
=
MessageFormat
.
format
(
msg
,
msgBrand
,
layer
,
DateTimeUtil
.
formatDate
(
targetDate
));
msgDTO
.
setContent
(
msg
);
msgDTO
.
setTag
(
1
);
msgService
.
add
(
msgDTO
);
}
private
void
calcAllTeamByDays
(
String
bdate
,
String
edate
)
{
...
...
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