|
|
|
@ -26,8 +26,12 @@ import org.dromara.progress.constant.PgsProgressCategoryConstant;
|
|
|
|
|
import org.dromara.progress.domain.PgsProgressCategory;
|
|
|
|
|
import org.dromara.progress.domain.PgsProgressPlan;
|
|
|
|
|
import org.dromara.progress.domain.PgsProgressPlanDetail;
|
|
|
|
|
import org.dromara.progress.domain.dto.progressplandetail.*;
|
|
|
|
|
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailFinishedCreateReq;
|
|
|
|
|
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailPercentageCreateReq;
|
|
|
|
|
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailQueryReq;
|
|
|
|
|
import org.dromara.progress.domain.dto.progressplandetail.PgsProgressPlanDetailRemoveReq;
|
|
|
|
|
import org.dromara.progress.domain.enums.PgsFinishStatusEnum;
|
|
|
|
|
import org.dromara.progress.domain.enums.PgsProgressUnitTypeEnum;
|
|
|
|
|
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFinishedVo;
|
|
|
|
|
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo;
|
|
|
|
|
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo;
|
|
|
|
@ -129,11 +133,11 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|
|
|
|
throw new ServiceException("进度计划信息不存在", HttpStatus.NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal oldFinishedNumber = progressPlan.getFinishedNumber();
|
|
|
|
|
// todo 判断完成时间是否大于当前时间
|
|
|
|
|
// 判断完成时间是否大于当前时间
|
|
|
|
|
LocalDate planDate = progressPlanDetail.getDate();
|
|
|
|
|
/* if (planDate.after(new Date())) {
|
|
|
|
|
if (planDate.isAfter(LocalDate.now())) {
|
|
|
|
|
throw new ServiceException("完成时间不能大于当前时间", HttpStatus.BAD_REQUEST);
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
Long projectId = progressPlanDetail.getProjectId();
|
|
|
|
|
Long progressCategoryId = progressPlanDetail.getProgressCategoryId();
|
|
|
|
|
PgsProgressCategory progressCategory = progressCategoryService.getById(progressCategoryId);
|
|
|
|
@ -305,24 +309,21 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|
|
|
|
// 校验
|
|
|
|
|
BigDecimal finishedNumber = req.getFinishedNumber();
|
|
|
|
|
if (finishedNumber == null) {
|
|
|
|
|
throw new ServiceException("完成百分比不能为空", HttpStatus.BAD_REQUEST);
|
|
|
|
|
throw new ServiceException("完成值不能为空", HttpStatus.BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
// 判断是否小于 0
|
|
|
|
|
if (finishedNumber.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
|
throw new ServiceException("完成百分比不能小于0", HttpStatus.BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
// 判断是否大于 100
|
|
|
|
|
if (finishedNumber.compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
|
|
|
throw new ServiceException("完成百分比不能大于100", HttpStatus.BAD_REQUEST);
|
|
|
|
|
throw new ServiceException("完成值不能小于0", HttpStatus.BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
Long id = req.getId();
|
|
|
|
|
PgsProgressPlanDetail progressPlanDetail = this.getById(id);
|
|
|
|
|
if (progressPlanDetail == null) {
|
|
|
|
|
throw new ServiceException("进度计划详情信息不存在", HttpStatus.NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
// 判断总进度不能大于 100
|
|
|
|
|
if (progressPlanDetail.getFinishedNumber().add(finishedNumber).compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
|
|
|
throw new ServiceException("总进度不能大于100", HttpStatus.BAD_REQUEST);
|
|
|
|
|
// 判断完成时间是否大于当前时间
|
|
|
|
|
LocalDate date = progressPlanDetail.getDate();
|
|
|
|
|
if (date.isAfter(LocalDate.now())) {
|
|
|
|
|
throw new ServiceException("完成时间不能大于当前时间", HttpStatus.BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
Long progressPlanId = progressPlanDetail.getProgressPlanId();
|
|
|
|
|
PgsProgressPlan progressPlan = progressPlanService.getById(progressPlanId);
|
|
|
|
@ -334,35 +335,64 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|
|
|
|
if (progressCategory == null) {
|
|
|
|
|
throw new ServiceException("进度计划类别信息不存在", HttpStatus.NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal number = progressPlanDetail.getFinishedNumber();
|
|
|
|
|
BigDecimal oldFinishedNumberTotal = progressPlan.getFinishedNumber();
|
|
|
|
|
String unitType = progressCategory.getUnitType();
|
|
|
|
|
// ---------- 数据计算 ----------
|
|
|
|
|
BigDecimal oldDetailNumber = progressPlanDetail.getFinishedNumber();
|
|
|
|
|
BigDecimal oldPlanFinished = progressPlan.getFinishedNumber();
|
|
|
|
|
BigDecimal newPlanFinished = oldPlanFinished.subtract(oldDetailNumber).add(finishedNumber);
|
|
|
|
|
// 模式特定校验
|
|
|
|
|
if (unitType.equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue()) && newPlanFinished.compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
|
|
|
throw new ServiceException("总进度不能大于100", HttpStatus.BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
// 判断是否大于 100
|
|
|
|
|
if (unitType.equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue()) && finishedNumber.compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
|
|
|
throw new ServiceException("完成百分比不能大于100", HttpStatus.BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---------- 更新 detail ----------
|
|
|
|
|
progressPlanDetail.setFinishedNumber(finishedNumber);
|
|
|
|
|
// 更新
|
|
|
|
|
boolean update = this.updateById(progressPlanDetail);
|
|
|
|
|
if (!update) {
|
|
|
|
|
if (!this.updateById(progressPlanDetail)) {
|
|
|
|
|
throw new ServiceException("更新进度计划详情异常", HttpStatus.ERROR);
|
|
|
|
|
}
|
|
|
|
|
progressPlan.setFinishedNumber(oldFinishedNumberTotal.subtract(number).add(finishedNumber));
|
|
|
|
|
boolean result = progressPlanService.updateById(progressPlan);
|
|
|
|
|
if (!result) {
|
|
|
|
|
|
|
|
|
|
// ---------- 更新 plan ----------
|
|
|
|
|
progressPlan.setFinishedNumber(newPlanFinished);
|
|
|
|
|
if (!progressPlanService.updateById(progressPlan)) {
|
|
|
|
|
throw new ServiceException("更新进度计划异常", HttpStatus.ERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ---------- 更新 category ----------
|
|
|
|
|
BigDecimal completed = progressCategory.getCompleted();
|
|
|
|
|
BigDecimal completedTotal = completed.subtract(number).add(finishedNumber);
|
|
|
|
|
BigDecimal completedTotal = completed.subtract(oldDetailNumber).add(finishedNumber);
|
|
|
|
|
if (unitType.equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue()) && completedTotal.compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
|
|
|
throw new ServiceException("完成百分比不能大于100", HttpStatus.BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
if (unitType.equals(PgsProgressUnitTypeEnum.NUMBER.getValue()) && completedTotal.compareTo(progressCategory.getTotal()) > 0) {
|
|
|
|
|
throw new ServiceException("完成数量不能超过总数量", HttpStatus.BAD_REQUEST);
|
|
|
|
|
}
|
|
|
|
|
progressCategory.setCompleted(completedTotal);
|
|
|
|
|
|
|
|
|
|
// 完成判定
|
|
|
|
|
if (unitType.equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
|
|
|
|
|
if (completedTotal.compareTo(BigDecimal.valueOf(100)) == 0) {
|
|
|
|
|
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
|
|
|
|
}
|
|
|
|
|
// 判断当前是否已完成计划数量
|
|
|
|
|
BigDecimal nowFinishedNumber = progressPlan.getFinishedNumber();
|
|
|
|
|
if (oldFinishedNumberTotal.compareTo(progressPlan.getPlanNumber()) < 0
|
|
|
|
|
&& nowFinishedNumber.compareTo(progressPlan.getPlanNumber()) >= 0) {
|
|
|
|
|
} else { // NUMBER
|
|
|
|
|
if (completedTotal.compareTo(progressCategory.getTotal()) >= 0) {
|
|
|
|
|
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断是否跨过计划数量阈值
|
|
|
|
|
if (oldPlanFinished.compareTo(progressPlan.getPlanNumber()) < 0
|
|
|
|
|
&& newPlanFinished.compareTo(progressPlan.getPlanNumber()) >= 0) {
|
|
|
|
|
progressCategory.setPlanTotal(progressCategory.getPlanTotal().subtract(progressPlan.getPlanNumber()));
|
|
|
|
|
}
|
|
|
|
|
boolean updateCategory = progressCategoryService.updateById(progressCategory);
|
|
|
|
|
if (!updateCategory) {
|
|
|
|
|
|
|
|
|
|
if (!progressCategoryService.updateById(progressCategory)) {
|
|
|
|
|
throw new ServiceException("更新进度分类异常", HttpStatus.ERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -372,7 +402,7 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|
|
|
|
* @param req 插入进度计划详情设施参数
|
|
|
|
|
* @return 是否插入成功
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
/*@Override
|
|
|
|
|
public Boolean insertNumberDetail(PgsProgressPlanDetailNumberCreateReq req) {
|
|
|
|
|
// 校验
|
|
|
|
|
BigDecimal finishedNumber = req.getFinishedNumber();
|
|
|
|
@ -433,7 +463,7 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|
|
|
|
throw new ServiceException("更新进度分类异常", HttpStatus.ERROR);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页查询进度计划详情设施列表
|
|
|
|
|