进度管理app
This commit is contained in:
@ -82,13 +82,13 @@ public class PgsProgressPlanController extends BaseController {
|
||||
/**
|
||||
* 删除进度计划
|
||||
*
|
||||
* @param id 主键
|
||||
* @param ids 主键
|
||||
*/
|
||||
@SaCheckPermission("progress:progressPlan:remove")
|
||||
@Log(title = "进度计划", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return toAjax(pgsProgressPlanService.deleteById(id));
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(pgsProgressPlanService.deleteByIds(List.of(ids)));
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -62,4 +63,15 @@ public class PgsProgressCategoryAppController {
|
||||
return R.ok(progressCategoryService.queryLastTimeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进度类别未完成数量
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@GetMapping("/unfinishNumber/{id}")
|
||||
public R<BigDecimal> getUnFinishNumber(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(progressCategoryService.getUnFinishNumber(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,11 +11,14 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanCreateReq;
|
||||
import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanQueryReq;
|
||||
import org.dromara.progress.domain.dto.progressplan.PgsProgressPlanRemoveReq;
|
||||
import org.dromara.progress.domain.vo.progressplan.PgsProgressPlanVo;
|
||||
import org.dromara.progress.service.IPgsProgressPlanService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 进度计划 app 接口
|
||||
*
|
||||
@ -59,4 +62,14 @@ public class PgsProgressPlanAppController extends BaseController {
|
||||
return R.ok(progressPlanService.insertByBo(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除进度计划
|
||||
*/
|
||||
@Log(title = "进度计划", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/remove")
|
||||
public R<Void> remove(@Validated @RequestBody PgsProgressPlanRemoveReq req) {
|
||||
List<Long> ids = req.getIds();
|
||||
return toAjax(progressPlanService.deleteByIds(ids));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package org.dromara.progress.domain.dto.progressplan;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
* @date 2025-09-10 17:28
|
||||
*/
|
||||
@Data
|
||||
public class PgsProgressPlanRemoveReq implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -4690448781757278592L;
|
||||
|
||||
/**
|
||||
* 主键串
|
||||
*/
|
||||
@NotNull(message = "主键不能为空")
|
||||
private List<Long> ids;
|
||||
}
|
@ -188,4 +188,12 @@ public interface IPgsProgressCategoryService extends IService<PgsProgressCategor
|
||||
* @return 项目进度百分比
|
||||
*/
|
||||
BigDecimal getCompletedPercentage(List<PgsProgressCategory> categoryList);
|
||||
|
||||
/**
|
||||
* 获取项目进度类别未完成数量
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 未完成数量
|
||||
*/
|
||||
BigDecimal getUnFinishNumber(Long id);
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ public interface IPgsProgressPlanService extends IService<PgsProgressPlan> {
|
||||
/**
|
||||
* 删除进度计划信息
|
||||
*
|
||||
* @param id 待删除的主键
|
||||
* @param ids 待删除的主键
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteById(Long id);
|
||||
Boolean deleteByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获取进度计划视图对象
|
||||
|
@ -1348,4 +1348,27 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
return BigDecimalUtil.toPercentage(completedTotal, allTotal);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目进度类别未完成数量
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 未完成数量
|
||||
*/
|
||||
@Override
|
||||
public BigDecimal getUnFinishNumber(Long id) {
|
||||
PgsProgressCategory category = this.getById(id);
|
||||
if (category == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal total = category.getTotal();
|
||||
BigDecimal completed = category.getCompleted();
|
||||
// 如果是百分比,需要转换为数值
|
||||
if (PgsProgressUnitTypeEnum.PERCENTAGE.getValue().equals(category.getUnitType())) {
|
||||
completed = completed
|
||||
.divide(BigDecimal.valueOf(100L), 2, RoundingMode.HALF_UP)
|
||||
.multiply(total);
|
||||
}
|
||||
return total.subtract(completed);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.facility.domain.FacMatrix;
|
||||
import org.dromara.facility.service.IFacMatrixService;
|
||||
import org.dromara.progress.domain.PgsProgressCategory;
|
||||
@ -190,41 +189,40 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl<PgsProgressPlanMappe
|
||||
/**
|
||||
* 删除进度计划信息
|
||||
*
|
||||
* @param id 待删除的主键
|
||||
* @param ids 待删除的主键
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteById(Long id) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
PgsProgressPlan progressPlan = this.getById(id);
|
||||
if (progressPlan == null) {
|
||||
throw new ServiceException("进度计划信息不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
Long projectId = progressPlan.getProjectId();
|
||||
projectService.validAuth(projectId, userId);
|
||||
if (progressPlan.getPlanNumber() != null && progressPlan.getPlanNumber().compareTo(BigDecimal.ZERO) != 0) {
|
||||
throw new ServiceException("已存在完成的设施,无法删除", HttpStatus.CONFLICT);
|
||||
}
|
||||
// 删除数据
|
||||
boolean result = this.removeById(id);
|
||||
if (!result) {
|
||||
throw new ServiceException("删除进度计划失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
// 关联删除分类中记录的计划值
|
||||
boolean update = progressCategoryService.lambdaUpdate()
|
||||
.eq(PgsProgressCategory::getId, progressPlan.getProgressCategoryId())
|
||||
.setSql("plan_total = plan_total - " + progressPlan.getPlanNumber())
|
||||
.update();
|
||||
if (!update) {
|
||||
throw new ServiceException("更新进度分类计划总数量失败,数据库操作失败", HttpStatus.ERROR);
|
||||
}
|
||||
// 关联删除计划详情数据
|
||||
LambdaQueryWrapper<PgsProgressPlanDetail> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(PgsProgressPlanDetail::getProgressPlanId, id);
|
||||
boolean remove = progressPlanDetailService.remove(lqw);
|
||||
if (!remove) {
|
||||
throw new ServiceException("删除进度计划详情失败,数据库异常", HttpStatus.ERROR);
|
||||
public Boolean deleteByIds(List<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
PgsProgressPlan progressPlan = this.getById(id);
|
||||
if (progressPlan == null) {
|
||||
throw new ServiceException("进度计划信息不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
if (progressPlan.getPlanNumber() != null && progressPlan.getPlanNumber().compareTo(BigDecimal.ZERO) != 0) {
|
||||
throw new ServiceException("已存在完成的设施,无法删除", HttpStatus.CONFLICT);
|
||||
}
|
||||
// 删除数据
|
||||
boolean result = this.removeById(id);
|
||||
if (!result) {
|
||||
throw new ServiceException("删除进度计划失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
// 关联删除分类中记录的计划值
|
||||
boolean update = progressCategoryService.lambdaUpdate()
|
||||
.eq(PgsProgressCategory::getId, progressPlan.getProgressCategoryId())
|
||||
.setSql("plan_total = plan_total - " + progressPlan.getPlanNumber())
|
||||
.update();
|
||||
if (!update) {
|
||||
throw new ServiceException("更新进度分类计划总数量失败,数据库操作失败", HttpStatus.ERROR);
|
||||
}
|
||||
// 关联删除计划详情数据
|
||||
LambdaQueryWrapper<PgsProgressPlanDetail> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(PgsProgressPlanDetail::getProgressPlanId, id);
|
||||
boolean remove = progressPlanDetailService.remove(lqw);
|
||||
if (!remove) {
|
||||
throw new ServiceException("删除进度计划详情失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user