Commit c4a6cc8d by 丁伟峰

fix

1 parent dacf01be
...@@ -28,7 +28,7 @@ public class CapacityController { ...@@ -28,7 +28,7 @@ public class CapacityController {
} }
@PostMapping("/capacity/adjust") @PostMapping("/capacity/adjust")
public Result<?> capacityAdjust(@Validated CapacityAdjustDTO.Request reqDTO) { public Result<?> capacityAdjust(@Validated @RequestBody CapacityAdjustDTO.Request reqDTO) {
Result<?> res = null; Result<?> res = null;
try { try {
res = orgCapacityService.adjustCapacity(reqDTO); res = orgCapacityService.adjustCapacity(reqDTO);
......
package com.dituhui.pea.order.dto; 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 lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -15,12 +20,14 @@ public class CapacityAdjustDTO { ...@@ -15,12 +20,14 @@ public class CapacityAdjustDTO {
@NotNull(message = "teamId不能为空") @NotNull(message = "teamId不能为空")
private String teamId; private String teamId;
@NotBlank(message = "日期字段不能为空") @JsonDeserialize(using = LocalDateDeserializer.class)
@Pattern(regexp = "\\d{4}-\\d{2}-\\d{2}", message = "日期字段格式必须为 yyyy-MM-dd") @JsonSerialize(using = LocalDateSerializer.class)
private LocalDate beginDate; @JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate startDate;
@NotBlank(message = "日期字段不能为空") @JsonDeserialize(using = LocalDateDeserializer.class)
@Pattern(regexp = "\\d{4}-\\d{2}-\\d{2}", message = "日期字段格式必须为 yyyy-MM-dd") @JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate endDate; private LocalDate endDate;
private Integer capAdjust; private Integer capAdjust;
......
...@@ -21,13 +21,14 @@ public class CapacityTeamAdjustEntity { ...@@ -21,13 +21,14 @@ public class CapacityTeamAdjustEntity {
private float capAdjust; 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 // Constructors, getters, setters, and other methods can be added as needed
......
...@@ -32,7 +32,7 @@ public class EngineerSkillGroupEntity { ...@@ -32,7 +32,7 @@ public class EngineerSkillGroupEntity {
@Column(length = 100, nullable = false) @Column(length = 100, nullable = false)
private String memo; 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; private LocalDateTime createTime;
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") @Column(name = "update_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
......
...@@ -14,6 +14,7 @@ import org.springframework.data.domain.Pageable; ...@@ -14,6 +14,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
...@@ -99,7 +100,7 @@ public class OrgCapacityServiceImpl implements OrgCapacityService { ...@@ -99,7 +100,7 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
.setCapTotal(e.getCapTotal()) .setCapTotal(e.getCapTotal())
.setCapUsed(e.getCapUsed()) .setCapUsed(e.getCapUsed())
.setCapLeft(e.getCapLeft()) .setCapLeft(e.getCapLeft())
.setCapAdjust(e.getCapAdjust()*100) .setCapAdjust(e.getCapAdjust())
.setEngineerNum(e.getEngineerCount()) .setEngineerNum(e.getEngineerCount())
.setUpdateTime(e.getUpdateTime()); .setUpdateTime(e.getUpdateTime());
} }
...@@ -114,11 +115,11 @@ public class OrgCapacityServiceImpl implements OrgCapacityService { ...@@ -114,11 +115,11 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
@Override @Override
public Result<?> adjustCapacity(CapacityAdjustDTO.Request reqDTO) { public Result<?> adjustCapacity(CapacityAdjustDTO.Request reqDTO) {
if (reqDTO.getBeginDate().isBefore(LocalDate.now())) { if (reqDTO.getStartDate().isBefore(LocalDate.now())) {
return Result.failed("日期不能小于当天"); return Result.failed("日期不能小于当天");
} }
// 遍历 startDate 到 endDate 之间的所有日期 // 遍历 startDate 到 endDate 之间的所有日期
LocalDate currentDate = reqDTO.getBeginDate(); LocalDate currentDate = reqDTO.getStartDate();
while (!currentDate.isAfter(reqDTO.getEndDate())) { while (!currentDate.isAfter(reqDTO.getEndDate())) {
float adjuest = (float) (reqDTO.getCapAdjust() / 100.0); float adjuest = (float) (reqDTO.getCapAdjust() / 100.0);
ajustCapacityByDate(reqDTO.getTeamId(), currentDate, adjuest); ajustCapacityByDate(reqDTO.getTeamId(), currentDate, adjuest);
...@@ -133,8 +134,12 @@ public class OrgCapacityServiceImpl implements OrgCapacityService { ...@@ -133,8 +134,12 @@ public class OrgCapacityServiceImpl implements OrgCapacityService {
entity = new CapacityTeamAdjustEntity(); entity = new CapacityTeamAdjustEntity();
entity.setTeamId(teamId); entity.setTeamId(teamId);
entity.setWorkday(date); entity.setWorkday(date);
entity.setMemo("");
entity.setCreateTime(LocalDateTime.now());
} }
entity.setCapAdjust(adjust); entity.setCapAdjust(adjust);
entity.setUpdateTime(LocalDateTime.now());
// todo 操作日志登记
capacityTeamAdjustDao.save(entity); capacityTeamAdjustDao.save(entity);
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!