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 c4a6cc8d
authored
Jul 31, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
1 parent
dacf01be
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
16 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/CapacityController.java
project-order/src/main/java/com/dituhui/pea/order/dto/CapacityAdjustDTO.java
project-order/src/main/java/com/dituhui/pea/order/entity/CapacityTeamAdjustEntity.java
project-order/src/main/java/com/dituhui/pea/order/entity/EngineerSkillGroupEntity.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrgCapacityServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/controller/CapacityController.java
View file @
c4a6cc8
...
...
@@ -28,7 +28,7 @@ public class CapacityController {
}
@PostMapping
(
"/capacity/adjust"
)
public
Result
<?>
capacityAdjust
(
@Validated
CapacityAdjustDTO
.
Request
reqDTO
)
{
public
Result
<?>
capacityAdjust
(
@Validated
@RequestBody
CapacityAdjustDTO
.
Request
reqDTO
)
{
Result
<?>
res
=
null
;
try
{
res
=
orgCapacityService
.
adjustCapacity
(
reqDTO
);
...
...
project-order/src/main/java/com/dituhui/pea/order/dto/CapacityAdjustDTO.java
View file @
c4a6cc8
package
com
.
dituhui
.
pea
.
order
.
dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.databind.annotation.JsonDeserialize
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer
;
import
com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer
;
import
com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer
;
import
com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Pattern
;
import
java.time.LocalDate
;
...
...
@@ -15,12 +20,14 @@ public class CapacityAdjustDTO {
@NotNull
(
message
=
"teamId不能为空"
)
private
String
teamId
;
@NotBlank
(
message
=
"日期字段不能为空"
)
@Pattern
(
regexp
=
"\\d{4}-\\d{2}-\\d{2}"
,
message
=
"日期字段格式必须为 yyyy-MM-dd"
)
private
LocalDate
beginDate
;
@JsonDeserialize
(
using
=
LocalDateDeserializer
.
class
)
@JsonSerialize
(
using
=
LocalDateSerializer
.
class
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
private
LocalDate
startDate
;
@NotBlank
(
message
=
"日期字段不能为空"
)
@Pattern
(
regexp
=
"\\d{4}-\\d{2}-\\d{2}"
,
message
=
"日期字段格式必须为 yyyy-MM-dd"
)
@JsonDeserialize
(
using
=
LocalDateDeserializer
.
class
)
@JsonSerialize
(
using
=
LocalDateSerializer
.
class
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
)
private
LocalDate
endDate
;
private
Integer
capAdjust
;
...
...
project-order/src/main/java/com/dituhui/pea/order/entity/CapacityTeamAdjustEntity.java
View file @
c4a6cc8
...
...
@@ -21,13 +21,14 @@ public class CapacityTeamAdjustEntity {
private
float
capAdjust
;
private
String
memo
;
private
String
memo
=
""
;
private
LocalDateTime
createTime
;
@Column
(
name
=
"create_time"
,
nullable
=
false
,
columnDefinition
=
"timestamp DEFAULT CURRENT_TIMESTAMP"
)
private
LocalDateTime
createTime
=
LocalDateTime
.
now
();
private
LocalDateTime
updateTime
;
@Column
(
name
=
"update_time"
,
nullable
=
false
,
columnDefinition
=
"timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
)
private
LocalDateTime
updateTime
=
LocalDateTime
.
now
();
private
String
layer
;
// Constructors, getters, setters, and other methods can be added as needed
...
...
project-order/src/main/java/com/dituhui/pea/order/entity/EngineerSkillGroupEntity.java
View file @
c4a6cc8
...
...
@@ -32,7 +32,7 @@ public class EngineerSkillGroupEntity {
@Column
(
length
=
100
,
nullable
=
false
)
private
String
memo
;
@Column
(
name
=
"create_time"
,
nullable
=
false
,
columnDefinition
=
"timestamp DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP
"
)
@Column
(
name
=
"create_time"
,
nullable
=
false
,
columnDefinition
=
"timestamp DEFAULT CURRENT_TIMESTAMP"
)
private
LocalDateTime
createTime
;
@Column
(
name
=
"update_time"
,
nullable
=
false
,
columnDefinition
=
"timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
)
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrgCapacityServiceImpl.java
View file @
c4a6cc8
...
...
@@ -14,6 +14,7 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
...
...
@@ -99,7 +100,7 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
.
setCapTotal
(
e
.
getCapTotal
())
.
setCapUsed
(
e
.
getCapUsed
())
.
setCapLeft
(
e
.
getCapLeft
())
.
setCapAdjust
(
e
.
getCapAdjust
()
*
100
)
.
setCapAdjust
(
e
.
getCapAdjust
())
.
setEngineerNum
(
e
.
getEngineerCount
())
.
setUpdateTime
(
e
.
getUpdateTime
());
}
...
...
@@ -114,11 +115,11 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
@Override
public
Result
<?>
adjustCapacity
(
CapacityAdjustDTO
.
Request
reqDTO
)
{
if
(
reqDTO
.
get
Begin
Date
().
isBefore
(
LocalDate
.
now
()))
{
if
(
reqDTO
.
get
Start
Date
().
isBefore
(
LocalDate
.
now
()))
{
return
Result
.
failed
(
"日期不能小于当天"
);
}
// 遍历 startDate 到 endDate 之间的所有日期
LocalDate
currentDate
=
reqDTO
.
get
Begin
Date
();
LocalDate
currentDate
=
reqDTO
.
get
Start
Date
();
while
(!
currentDate
.
isAfter
(
reqDTO
.
getEndDate
()))
{
float
adjuest
=
(
float
)
(
reqDTO
.
getCapAdjust
()
/
100.0
);
ajustCapacityByDate
(
reqDTO
.
getTeamId
(),
currentDate
,
adjuest
);
...
...
@@ -133,8 +134,12 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
entity
=
new
CapacityTeamAdjustEntity
();
entity
.
setTeamId
(
teamId
);
entity
.
setWorkday
(
date
);
entity
.
setMemo
(
""
);
entity
.
setCreateTime
(
LocalDateTime
.
now
());
}
entity
.
setCapAdjust
(
adjust
);
entity
.
setUpdateTime
(
LocalDateTime
.
now
());
// todo 操作日志登记
capacityTeamAdjustDao
.
save
(
entity
);
}
}
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