修改进度管理
This commit is contained in:
@ -62,12 +62,12 @@ public class PgsProgressPlanDetailController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 新增进度计划详情(数量设施)
|
* 新增进度计划详情(数量设施)
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("progress:progressPlanDetail:insertNumber")
|
/* @SaCheckPermission("progress:progressPlanDetail:insertNumber")
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PostMapping("/insert/number")
|
@PostMapping("/insert/number")
|
||||||
public R<Void> insertNumberDetail(@Validated @RequestBody PgsProgressPlanDetailNumberCreateReq req) {
|
public R<Void> insertNumberDetail(@Validated @RequestBody PgsProgressPlanDetailNumberCreateReq req) {
|
||||||
return toAjax(pgsProgressPlanDetailService.insertNumberDetail(req));
|
return toAjax(pgsProgressPlanDetailService.insertNumberDetail(req));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取进度计划详情已完成设施详细信息
|
* 获取进度计划详情已完成设施详细信息
|
||||||
|
@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.progress.domain.PgsProgressPlanDetail;
|
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.vo.progressplandetail.PgsProgressPlanDetailFinishedVo;
|
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFinishedVo;
|
||||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo;
|
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo;
|
||||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo;
|
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo;
|
||||||
@ -54,7 +57,7 @@ public interface IPgsProgressPlanDetailService extends IService<PgsProgressPlanD
|
|||||||
* @param req 插入进度计划详情设施参数
|
* @param req 插入进度计划详情设施参数
|
||||||
* @return 是否插入成功
|
* @return 是否插入成功
|
||||||
*/
|
*/
|
||||||
Boolean insertNumberDetail(PgsProgressPlanDetailNumberCreateReq req);
|
// Boolean insertNumberDetail(PgsProgressPlanDetailNumberCreateReq req);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询进度计划详情已完成设施列表
|
* 分页查询进度计划详情已完成设施列表
|
||||||
|
@ -451,8 +451,8 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
|||||||
}
|
}
|
||||||
BigDecimal ownerPrice = req.getOwnerPrice();
|
BigDecimal ownerPrice = req.getOwnerPrice();
|
||||||
BigDecimal constructionPrice = req.getConstructionPrice();
|
BigDecimal constructionPrice = req.getConstructionPrice();
|
||||||
BigDecimal ownerOutputValue = BigDecimal.ZERO;
|
BigDecimal ownerOutputValue;
|
||||||
BigDecimal constructionOutputValue = BigDecimal.ZERO;
|
BigDecimal constructionOutputValue;
|
||||||
if (unitType.equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue()) ||
|
if (unitType.equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue()) ||
|
||||||
progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
|
progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
|
||||||
progressCategory.setTotal(req.getTotal());
|
progressCategory.setTotal(req.getTotal());
|
||||||
@ -467,8 +467,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
|||||||
}
|
}
|
||||||
ownerOutputValue = total.multiply(ownerPrice);
|
ownerOutputValue = total.multiply(ownerPrice);
|
||||||
constructionOutputValue = total.multiply(constructionPrice);
|
constructionOutputValue = total.multiply(constructionPrice);
|
||||||
} else if (unitType.equals(PgsProgressUnitTypeEnum.NUMBER.getValue()) ||
|
} else {
|
||||||
progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.NUMBER.getValue())) {
|
|
||||||
BigDecimal total = req.getTotal();
|
BigDecimal total = req.getTotal();
|
||||||
if (total == null || total.compareTo(BigDecimal.ZERO) <= 0) {
|
if (total == null || total.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
total = progressCategory.getTotal();
|
total = progressCategory.getTotal();
|
||||||
@ -476,6 +475,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
|||||||
if (total == null || total.compareTo(BigDecimal.ZERO) <= 0) {
|
if (total == null || total.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
throw new ServiceException("请输入分项工程数量", HttpStatus.BAD_REQUEST);
|
throw new ServiceException("请输入分项工程数量", HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
progressCategory.setTotal(total);
|
||||||
ownerOutputValue = total.multiply(ownerPrice);
|
ownerOutputValue = total.multiply(ownerPrice);
|
||||||
constructionOutputValue = total.multiply(constructionPrice);
|
constructionOutputValue = total.multiply(constructionPrice);
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,12 @@ import org.dromara.progress.constant.PgsProgressCategoryConstant;
|
|||||||
import org.dromara.progress.domain.PgsProgressCategory;
|
import org.dromara.progress.domain.PgsProgressCategory;
|
||||||
import org.dromara.progress.domain.PgsProgressPlan;
|
import org.dromara.progress.domain.PgsProgressPlan;
|
||||||
import org.dromara.progress.domain.PgsProgressPlanDetail;
|
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.PgsFinishStatusEnum;
|
||||||
|
import org.dromara.progress.domain.enums.PgsProgressUnitTypeEnum;
|
||||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFinishedVo;
|
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailFinishedVo;
|
||||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo;
|
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailNumVo;
|
||||||
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo;
|
import org.dromara.progress.domain.vo.progressplandetail.PgsProgressPlanDetailUnFinishVo;
|
||||||
@ -129,11 +133,11 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|||||||
throw new ServiceException("进度计划信息不存在", HttpStatus.NOT_FOUND);
|
throw new ServiceException("进度计划信息不存在", HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
BigDecimal oldFinishedNumber = progressPlan.getFinishedNumber();
|
BigDecimal oldFinishedNumber = progressPlan.getFinishedNumber();
|
||||||
// todo 判断完成时间是否大于当前时间
|
// 判断完成时间是否大于当前时间
|
||||||
LocalDate planDate = progressPlanDetail.getDate();
|
LocalDate planDate = progressPlanDetail.getDate();
|
||||||
/* if (planDate.after(new Date())) {
|
if (planDate.isAfter(LocalDate.now())) {
|
||||||
throw new ServiceException("完成时间不能大于当前时间", HttpStatus.BAD_REQUEST);
|
throw new ServiceException("完成时间不能大于当前时间", HttpStatus.BAD_REQUEST);
|
||||||
}*/
|
}
|
||||||
Long projectId = progressPlanDetail.getProjectId();
|
Long projectId = progressPlanDetail.getProjectId();
|
||||||
Long progressCategoryId = progressPlanDetail.getProgressCategoryId();
|
Long progressCategoryId = progressPlanDetail.getProgressCategoryId();
|
||||||
PgsProgressCategory progressCategory = progressCategoryService.getById(progressCategoryId);
|
PgsProgressCategory progressCategory = progressCategoryService.getById(progressCategoryId);
|
||||||
@ -305,24 +309,21 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|||||||
// 校验
|
// 校验
|
||||||
BigDecimal finishedNumber = req.getFinishedNumber();
|
BigDecimal finishedNumber = req.getFinishedNumber();
|
||||||
if (finishedNumber == null) {
|
if (finishedNumber == null) {
|
||||||
throw new ServiceException("完成百分比不能为空", HttpStatus.BAD_REQUEST);
|
throw new ServiceException("完成值不能为空", HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
// 判断是否小于 0
|
// 判断是否小于 0
|
||||||
if (finishedNumber.compareTo(BigDecimal.ZERO) < 0) {
|
if (finishedNumber.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
throw new ServiceException("完成百分比不能小于0", HttpStatus.BAD_REQUEST);
|
throw new ServiceException("完成值不能小于0", HttpStatus.BAD_REQUEST);
|
||||||
}
|
|
||||||
// 判断是否大于 100
|
|
||||||
if (finishedNumber.compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
||||||
throw new ServiceException("完成百分比不能大于100", HttpStatus.BAD_REQUEST);
|
|
||||||
}
|
}
|
||||||
Long id = req.getId();
|
Long id = req.getId();
|
||||||
PgsProgressPlanDetail progressPlanDetail = this.getById(id);
|
PgsProgressPlanDetail progressPlanDetail = this.getById(id);
|
||||||
if (progressPlanDetail == null) {
|
if (progressPlanDetail == null) {
|
||||||
throw new ServiceException("进度计划详情信息不存在", HttpStatus.NOT_FOUND);
|
throw new ServiceException("进度计划详情信息不存在", HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
// 判断总进度不能大于 100
|
// 判断完成时间是否大于当前时间
|
||||||
if (progressPlanDetail.getFinishedNumber().add(finishedNumber).compareTo(BigDecimal.valueOf(100)) > 0) {
|
LocalDate date = progressPlanDetail.getDate();
|
||||||
throw new ServiceException("总进度不能大于100", HttpStatus.BAD_REQUEST);
|
if (date.isAfter(LocalDate.now())) {
|
||||||
|
throw new ServiceException("完成时间不能大于当前时间", HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
Long progressPlanId = progressPlanDetail.getProgressPlanId();
|
Long progressPlanId = progressPlanDetail.getProgressPlanId();
|
||||||
PgsProgressPlan progressPlan = progressPlanService.getById(progressPlanId);
|
PgsProgressPlan progressPlan = progressPlanService.getById(progressPlanId);
|
||||||
@ -334,35 +335,64 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|||||||
if (progressCategory == null) {
|
if (progressCategory == null) {
|
||||||
throw new ServiceException("进度计划类别信息不存在", HttpStatus.NOT_FOUND);
|
throw new ServiceException("进度计划类别信息不存在", HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
BigDecimal number = progressPlanDetail.getFinishedNumber();
|
String unitType = progressCategory.getUnitType();
|
||||||
BigDecimal oldFinishedNumberTotal = progressPlan.getFinishedNumber();
|
// ---------- 数据计算 ----------
|
||||||
|
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);
|
progressPlanDetail.setFinishedNumber(finishedNumber);
|
||||||
// 更新
|
if (!this.updateById(progressPlanDetail)) {
|
||||||
boolean update = this.updateById(progressPlanDetail);
|
|
||||||
if (!update) {
|
|
||||||
throw new ServiceException("更新进度计划详情异常", HttpStatus.ERROR);
|
throw new ServiceException("更新进度计划详情异常", HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
progressPlan.setFinishedNumber(oldFinishedNumberTotal.subtract(number).add(finishedNumber));
|
|
||||||
boolean result = progressPlanService.updateById(progressPlan);
|
// ---------- 更新 plan ----------
|
||||||
if (!result) {
|
progressPlan.setFinishedNumber(newPlanFinished);
|
||||||
|
if (!progressPlanService.updateById(progressPlan)) {
|
||||||
throw new ServiceException("更新进度计划异常", HttpStatus.ERROR);
|
throw new ServiceException("更新进度计划异常", HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------- 更新 category ----------
|
||||||
BigDecimal completed = progressCategory.getCompleted();
|
BigDecimal completed = progressCategory.getCompleted();
|
||||||
BigDecimal completedTotal = completed.subtract(number).add(finishedNumber);
|
BigDecimal completedTotal = completed.subtract(oldDetailNumber).add(finishedNumber);
|
||||||
progressCategory.setCompleted(completedTotal);
|
if (unitType.equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue()) && completedTotal.compareTo(BigDecimal.valueOf(100)) > 0) {
|
||||||
if (completedTotal.compareTo(BigDecimal.valueOf(100)) == 0) {
|
throw new ServiceException("完成百分比不能大于100", HttpStatus.BAD_REQUEST);
|
||||||
progressCategory.setStatus(PgsFinishStatusEnum.FINISH.getValue());
|
|
||||||
}
|
}
|
||||||
// 判断当前是否已完成计划数量
|
if (unitType.equals(PgsProgressUnitTypeEnum.NUMBER.getValue()) && completedTotal.compareTo(progressCategory.getTotal()) > 0) {
|
||||||
BigDecimal nowFinishedNumber = progressPlan.getFinishedNumber();
|
throw new ServiceException("完成数量不能超过总数量", HttpStatus.BAD_REQUEST);
|
||||||
if (oldFinishedNumberTotal.compareTo(progressPlan.getPlanNumber()) < 0
|
}
|
||||||
&& nowFinishedNumber.compareTo(progressPlan.getPlanNumber()) >= 0) {
|
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
|
||||||
|
&& newPlanFinished.compareTo(progressPlan.getPlanNumber()) >= 0) {
|
||||||
progressCategory.setPlanTotal(progressCategory.getPlanTotal().subtract(progressPlan.getPlanNumber()));
|
progressCategory.setPlanTotal(progressCategory.getPlanTotal().subtract(progressPlan.getPlanNumber()));
|
||||||
}
|
}
|
||||||
boolean updateCategory = progressCategoryService.updateById(progressCategory);
|
|
||||||
if (!updateCategory) {
|
if (!progressCategoryService.updateById(progressCategory)) {
|
||||||
throw new ServiceException("更新进度分类异常", HttpStatus.ERROR);
|
throw new ServiceException("更新进度分类异常", HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +402,7 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|||||||
* @param req 插入进度计划详情设施参数
|
* @param req 插入进度计划详情设施参数
|
||||||
* @return 是否插入成功
|
* @return 是否插入成功
|
||||||
*/
|
*/
|
||||||
@Override
|
/*@Override
|
||||||
public Boolean insertNumberDetail(PgsProgressPlanDetailNumberCreateReq req) {
|
public Boolean insertNumberDetail(PgsProgressPlanDetailNumberCreateReq req) {
|
||||||
// 校验
|
// 校验
|
||||||
BigDecimal finishedNumber = req.getFinishedNumber();
|
BigDecimal finishedNumber = req.getFinishedNumber();
|
||||||
@ -433,7 +463,7 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
|
|||||||
throw new ServiceException("更新进度分类异常", HttpStatus.ERROR);
|
throw new ServiceException("更新进度分类异常", HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询进度计划详情设施列表
|
* 分页查询进度计划详情设施列表
|
||||||
|
Reference in New Issue
Block a user