修改进度计划判定逻辑
This commit is contained in:
@ -330,7 +330,11 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|||||||
}
|
}
|
||||||
BigDecimal completedTotal = progressCategory.getCompleted().add(new BigDecimal(size));
|
BigDecimal completedTotal = progressCategory.getCompleted().add(new BigDecimal(size));
|
||||||
progressCategory.setCompleted(completedTotal);
|
progressCategory.setCompleted(completedTotal);
|
||||||
|
// 判断是否完成计划
|
||||||
if (completedTotal.compareTo(progressCategory.getTotal()) == 0) {
|
if (completedTotal.compareTo(progressCategory.getTotal()) == 0) {
|
||||||
|
// 清空计划数量
|
||||||
|
progressCategory.setPlanTotal(BigDecimal.ZERO);
|
||||||
|
// 设置完成状态
|
||||||
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
||||||
}
|
}
|
||||||
boolean updateCategory = progressCategoryService.updateById(progressCategory);
|
boolean updateCategory = progressCategoryService.updateById(progressCategory);
|
||||||
@ -419,23 +423,29 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|||||||
}
|
}
|
||||||
progressCategory.setCompleted(completedTotal);
|
progressCategory.setCompleted(completedTotal);
|
||||||
|
|
||||||
// 完成判定
|
|
||||||
if (unitType.equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
|
|
||||||
if (completedTotal.compareTo(BigDecimal.valueOf(100)) == 0) {
|
|
||||||
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
|
||||||
}
|
|
||||||
} else { // NUMBER
|
|
||||||
if (completedTotal.compareTo(progressCategory.getTotal()) >= 0) {
|
|
||||||
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断是否跨过计划数量阈值
|
// 判断是否跨过计划数量阈值
|
||||||
if (oldPlanFinished.compareTo(progressPlan.getPlanNumber()) < 0
|
if (oldPlanFinished.compareTo(progressPlan.getPlanNumber()) < 0
|
||||||
&& newPlanFinished.compareTo(progressPlan.getPlanNumber()) >= 0) {
|
&& newPlanFinished.compareTo(progressPlan.getPlanNumber()) >= 0) {
|
||||||
progressCategory.setPlanTotal(progressCategory.getPlanTotal().subtract(progressPlan.getPlanNumber()));
|
progressCategory.setPlanTotal(progressCategory.getPlanTotal().subtract(progressPlan.getPlanNumber()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 完成判定
|
||||||
|
if (unitType.equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
|
||||||
|
if (completedTotal.compareTo(BigDecimal.valueOf(100)) == 0) {
|
||||||
|
// 清空计划数量
|
||||||
|
progressCategory.setPlanTotal(BigDecimal.ZERO);
|
||||||
|
// 设置完成状态
|
||||||
|
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
||||||
|
}
|
||||||
|
} else { // NUMBER
|
||||||
|
if (completedTotal.compareTo(progressCategory.getTotal()) >= 0) {
|
||||||
|
// 清空计划数量
|
||||||
|
progressCategory.setPlanTotal(BigDecimal.ZERO);
|
||||||
|
// 设置完成状态
|
||||||
|
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!progressCategoryService.updateById(progressCategory)) {
|
if (!progressCategoryService.updateById(progressCategory)) {
|
||||||
throw new ServiceException("更新进度分类异常", HttpStatus.ERROR);
|
throw new ServiceException("更新进度分类异常", HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user