fix (farm): 生产计划
- 计算逾期天数
This commit is contained in:
@@ -92,6 +92,7 @@ public class CropFarmingCenterController {
|
|||||||
cropFarmingCenterService.restartProductionPlan(updateReqVO);
|
cropFarmingCenterService.restartProductionPlan(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "生产计划-开始按钮")
|
@Operation(summary = "生产计划-开始按钮")
|
||||||
@PutMapping("/production-plan/start")
|
@PutMapping("/production-plan/start")
|
||||||
public CommonResult<Boolean> startPlanning(@RequestBody ProductionPlanUpdateReqVO updateReqVO) {
|
public CommonResult<Boolean> startPlanning(@RequestBody ProductionPlanUpdateReqVO updateReqVO) {
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ public class ProductionPlanUpdateReqVO {
|
|||||||
|
|
||||||
@Schema(description = "计划执行状态 (1:未开始;2:进行中;3:已完成;4:逾期)")
|
@Schema(description = "计划执行状态 (1:未开始;2:进行中;3:已完成;4:逾期)")
|
||||||
private Integer planStatus;
|
private Integer planStatus;
|
||||||
|
@Schema(description = "计划执行状态 (5: 逾期未开始; 6:逾期未结束)")
|
||||||
private Integer planSubStatus;
|
private Integer planSubStatus;
|
||||||
|
@Schema(description = "逾期天数")
|
||||||
|
private Integer overdueDays;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "租户ID")
|
@Schema(description = "租户ID")
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.Period;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -226,7 +227,8 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
|||||||
PageResult<ProductionPlanRespVO> resultData = BeanUtils.toBean(productionPlanDOPageResult, ProductionPlanRespVO.class);
|
PageResult<ProductionPlanRespVO> resultData = BeanUtils.toBean(productionPlanDOPageResult, ProductionPlanRespVO.class);
|
||||||
resultData.getList().forEach(e -> {
|
resultData.getList().forEach(e -> {
|
||||||
// 逾期天数
|
// 逾期天数
|
||||||
|
int overdueDays = this.countOverdueDays(e);
|
||||||
|
e.setOverdueDays(overdueDays);
|
||||||
// 计划状态-名称
|
// 计划状态-名称
|
||||||
e.setPlanStatusName(PLAN_MAP.get(e.getPlanStatus()));
|
e.setPlanStatusName(PLAN_MAP.get(e.getPlanStatus()));
|
||||||
// 模型
|
// 模型
|
||||||
@@ -258,6 +260,26 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int countOverdueDays(ProductionPlanRespVO vo) {
|
||||||
|
Integer planStatus = vo.getPlanStatus();
|
||||||
|
Integer planSubStatus = vo.getPlanSubStatus();
|
||||||
|
|
||||||
|
if (!ObjectUtils.notEqual(planStatus, PLAN_STATUS_4)) {
|
||||||
|
LocalDate today = LocalDate.now(ZoneId.of("Asia/Shanghai"));
|
||||||
|
if (!ObjectUtils.notEqual(planSubStatus, PLAN_STATUS_5)) {
|
||||||
|
LocalDate productionStartDate = vo.getProductionStartDate();
|
||||||
|
Period period = Period.between(today, productionStartDate);
|
||||||
|
return period.getDays();
|
||||||
|
}
|
||||||
|
if (!ObjectUtils.notEqual(planSubStatus, PLAN_STATUS_5)) {
|
||||||
|
LocalDate productionEndDate = vo.getProductionEndDate();
|
||||||
|
Period period = Period.between(today, productionEndDate);
|
||||||
|
return period.getDays();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCropCount(Long tenantId) {
|
public int getCropCount(Long tenantId) {
|
||||||
return productionPlanMapper.getCropCount(tenantId);
|
return productionPlanMapper.getCropCount(tenantId);
|
||||||
|
|||||||
Reference in New Issue
Block a user