From 7a72c1a4a23be34ee779aa4a1839b10cf3d34a84 Mon Sep 17 00:00:00 2001 From: lcj <2331845269@qq.com> Date: Thu, 31 Jul 2025 18:30:48 +0800 Subject: [PATCH] =?UTF-8?q?[add]=20=E5=8D=B7=E5=86=8C=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E3=80=81=E5=B7=A5=E7=A8=8B=E5=8D=95=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DesVolumeCatalogController.java | 11 ++++ .../controller/DesVolumeFileController.java | 4 +- .../service/IDesVolumeCatalogService.java | 8 +++ .../impl/DesVolumeCatalogServiceImpl.java | 63 ++++++++++++++++-- .../impl/DesVolumeFileServiceImpl.java | 66 +++++++++++-------- .../progress/domain/PgsProgressPlan.java | 7 +- .../domain/PgsProgressPlanDetail.java | 7 +- .../PgsProgressPlanCompletionQueryReq.java | 49 -------------- .../PgsProgressPlanCreateReq.java | 3 +- .../PgsProgressPlanDetailCreateDto.java | 3 +- ...ProgressPlanDetailPercentageCreateReq.java | 3 +- .../PgsProgressCategoryVo.java | 18 +++++ .../PgsProgressPlanCompletionVo.java | 37 ----------- .../vo/progressplan/PgsProgressPlanVo.java | 9 +-- .../PgsProgressPlanDetailNumVo.java | 7 +- .../PgsProgressPlanDetailVo.java | 8 +-- .../service/IPgsProgressPlanService.java | 14 +--- .../impl/PgsProgressCategoryServiceImpl.java | 2 +- .../PgsProgressPlanDetailServiceImpl.java | 26 ++++---- .../impl/PgsProgressPlanServiceImpl.java | 27 ++------ 20 files changed, 186 insertions(+), 186 deletions(-) delete mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/dto/progressplan/PgsProgressPlanCompletionQueryReq.java delete mode 100644 xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/domain/vo/progressplan/PgsProgressPlanCompletionVo.java diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/DesVolumeCatalogController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/DesVolumeCatalogController.java index a1180c09..2d08bbbf 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/DesVolumeCatalogController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/DesVolumeCatalogController.java @@ -75,6 +75,17 @@ public class DesVolumeCatalogController extends BaseController { return R.ok(volumeFileService.getVoList(volumeFiles)); } + /** + * 用户查看文件 + * + * @param id 主键 + */ + @GetMapping("/viewerFile/{id}") + public R viewerFile(@NotNull(message = "主键不能为空") + @PathVariable Long id) { + return toAjax(desVolumeCatalogService.viewerFile(id)); + } + /** * 新增卷册目录 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/DesVolumeFileController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/DesVolumeFileController.java index 95e72fb8..c710c159 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/DesVolumeFileController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/DesVolumeFileController.java @@ -5,7 +5,6 @@ import jakarta.annotation.Resource; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import org.dromara.common.core.domain.R; -import org.dromara.common.core.validate.AddGroup; import org.dromara.common.idempotent.annotation.RepeatSubmit; import org.dromara.common.log.annotation.Log; import org.dromara.common.log.enums.BusinessType; @@ -51,11 +50,10 @@ public class DesVolumeFileController extends BaseController { @Log(title = "卷册文件", businessType = BusinessType.INSERT) @RepeatSubmit() @PostMapping() - public R add(@Validated(AddGroup.class) @RequestBody DesVolumeFileCreateReq req) { + public R add(@Validated @RequestBody DesVolumeFileCreateReq req) { return toAjax(desVolumeFileService.insertByBo(req)); } - /** * 删除卷册文件 * diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/IDesVolumeCatalogService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/IDesVolumeCatalogService.java index 5a4efd8c..867254d2 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/IDesVolumeCatalogService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/IDesVolumeCatalogService.java @@ -103,4 +103,12 @@ public interface IDesVolumeCatalogService extends IService { * @return 卷册目录对象视图 */ Page getVoPage(Page volumeCatalogPage); + + /** + * 登录用户卷册目录文件查看 + * + * @param id 卷册目录id + * @return 是否成功 + */ + Boolean viewerFile(Long id); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeCatalogServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeCatalogServiceImpl.java index 5e521efc..ab953624 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeCatalogServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeCatalogServiceImpl.java @@ -11,6 +11,7 @@ import org.dromara.common.core.utils.ObjectUtils; import org.dromara.common.core.utils.StringUtils; 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.design.domain.DesVolumeCatalog; import org.dromara.design.domain.DesVolumeFile; import org.dromara.design.domain.DesVolumeFileViewer; @@ -23,13 +24,19 @@ import org.dromara.design.service.IDesVolumeCatalogService; import org.dromara.design.service.IDesVolumeFileService; import org.dromara.design.service.IDesVolumeFileViewerService; import org.dromara.project.service.IBusProjectService; +import org.dromara.system.domain.vo.SysUserVo; +import org.dromara.system.service.ISysUserService; import org.springframework.beans.BeanUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 卷册目录Service业务层处理 @@ -44,6 +51,9 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl queryFileListById(Long id) { return volumeFileService.lambdaQuery() .eq(DesVolumeFile::getVolumeCatalogId, id) + .orderByAsc(DesVolumeFile::getStatus) + .orderByDesc(DesVolumeFile::getCreateDept) .list(); } @@ -212,6 +224,24 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl volumeFiles = this.queryFileListById(volumeCatalog.getId()); vo.setFileVoList(volumeFileService.getVoList(volumeFiles)); + // 关联查阅人信息 + List allViewerList = volumeFileViewerService.lambdaQuery() + .eq(DesVolumeFileViewer::getVolumeCatalogId, volumeCatalog.getId()).list(); + List userIds = allViewerList.stream().map(DesVolumeFileViewer::getUserId).distinct().toList(); + List userVoList = userService.selectUserByIds(userIds, null); + Map userVoMap = userVoList.stream().collect(Collectors.toMap(SysUserVo::getUserId, Function.identity())); + List viewerList = new ArrayList<>(); + List noViewerList = new ArrayList<>(); + allViewerList.forEach(viewer -> { + SysUserVo userVo = userVoMap.get(viewer.getUserId()); + if (viewer.getStatus().equals("2")) { + viewerList.add(userVo); + } else { + noViewerList.add(userVo); + } + }); + vo.setViewerList(viewerList); + vo.setNoViewerList(noViewerList); return vo; } @@ -254,12 +284,35 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl volumeCatalogVoList = volumeCatalogList.stream().map(entity -> { - DesVolumeCatalogVo volumeCatalogVo = new DesVolumeCatalogVo(); - BeanUtils.copyProperties(entity, volumeCatalogVo); - return volumeCatalogVo; - }).toList(); + List volumeCatalogVoList = volumeCatalogList.stream().map(this::getVo).toList(); return volumeCatalogVoPage.setRecords(volumeCatalogVoList); } + /** + * 登录用户卷册目录文件查看 + * + * @param id 卷册目录id + * @return 是否成功 + */ + @Override + public Boolean viewerFile(Long id) { + Long userId = LoginHelper.getUserId(); + if (userId == null) { + return false; + } + DesVolumeFileViewer viewer = volumeFileViewerService.lambdaQuery() + .eq(DesVolumeFileViewer::getVolumeCatalogId, id) + .eq(DesVolumeFileViewer::getUserId, userId) + .eq(DesVolumeFileViewer::getStatus, "1") + .one(); + if (viewer != null) { + viewer.setStatus("2"); + boolean update = volumeFileViewerService.updateById(viewer); + if (!update) { + throw new ServiceException("卷册目录文件查看失败", HttpStatus.ERROR); + } + } + return true; + } + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeFileServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeFileServiceImpl.java index a7cb3884..c9344e50 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeFileServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/DesVolumeFileServiceImpl.java @@ -76,54 +76,67 @@ public class DesVolumeFileServiceImpl extends ServiceImpl cancellationIds = req.getCancellationIds(); if (CollUtil.isNotEmpty(cancellationIds)) { List list = this.listByIds(cancellationIds); list.forEach(item -> { + if (item.getStatus().equals("2")) { + return; + } String name = item.getFileName(); String modified = name.replaceAll("((\\d{8}))", "($1-已作废)"); item.setFileName(modified); item.setStatus("2"); }); - boolean update = this.updateBatchById(list); - if (!update) { - throw new ServiceException("更新卷册文件信息异常", HttpStatus.ERROR); + if (CollUtil.isNotEmpty(list)) { + boolean update = this.updateBatchById(list); + if (!update) { + throw new ServiceException("更新卷册文件信息异常", HttpStatus.ERROR); + } } } - DesVolumeFile file = new DesVolumeFile(); - BeanUtils.copyProperties(req, file); - String today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); - file.setFileName(ossVo.getFileName() + "(" + today + ")"); // 新增审阅人 List userIds = req.getUserIds(); - List viewerList = userIds.stream().map(userId -> { - DesVolumeFileViewer viewer = new DesVolumeFileViewer(); - viewer.setVolumeCatalogId(volumeCatalogId); - viewer.setUserId(userId); - return viewer; - }).toList(); - if (CollUtil.isNotEmpty(viewerList)) { + if (CollUtil.isNotEmpty(userIds)) { + List viewerList = userIds.stream().map(userId -> { + DesVolumeFileViewer viewer = new DesVolumeFileViewer(); + viewer.setVolumeCatalogId(volumeCatalogId); + viewer.setUserId(userId); + return viewer; + }).toList(); // 删除以前的审阅人 - boolean remove = volumeFileViewerService.remove(new LambdaQueryWrapper() - .eq(DesVolumeFileViewer::getVolumeCatalogId, volumeCatalogId)); - if (!remove) { - throw new ServiceException("修改审阅人失败", HttpStatus.ERROR); + Long count = volumeFileViewerService.lambdaQuery() + .eq(DesVolumeFileViewer::getVolumeCatalogId, volumeCatalogId) + .count(); + if (count > 0) { + boolean remove = volumeFileViewerService.remove(new LambdaQueryWrapper() + .eq(DesVolumeFileViewer::getVolumeCatalogId, volumeCatalogId)); + if (!remove) { + throw new ServiceException("修改审阅人失败", HttpStatus.ERROR); + } } boolean result = volumeFileViewerService.saveBatch(viewerList); if (!result) { throw new ServiceException("修改审阅人失败", HttpStatus.ERROR); } } - boolean save = this.save(file); - if (!save) { - throw new ServiceException("新增卷册文件信息异常", HttpStatus.ERROR); + // 查看文件是否存在 + if (req.getFileId() != null) { + SysOssVo ossVo = ossService.getById(req.getFileId()); + if (ossVo == null) { + throw new ServiceException("对应文件不存在", HttpStatus.NOT_FOUND); + } + DesVolumeFile file = new DesVolumeFile(); + BeanUtils.copyProperties(req, file); + String today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); + file.setFileName(ossVo.getOriginalName() + "(" + today + ")"); + boolean save = this.save(file); + if (!save) { + throw new ServiceException("新增卷册文件信息异常", HttpStatus.ERROR); + } } + return true; } @@ -156,7 +169,6 @@ public class DesVolumeFileServiceImpl extends ServiceImpl { */ TableDataInfo queryPageList(PgsProgressPlanQueryReq req, PageQuery pageQuery); - /** - * 分项工程完成明细列表 - * - * @param req 查询条件 - * @param pageQuery 分页参数 - * @return 分项工程完成明细列表 - */ - TableDataInfo queryPageCompletionDetailList(PgsProgressPlanCompletionQueryReq req, PageQuery pageQuery); - /** * 查询符合条件的进度计划列表 * @@ -103,7 +93,7 @@ public interface IPgsProgressPlanService extends IService { * @param planNumber 计划数量 * @param progressCategory 进度类别 */ - void validPlanNumber(Long planNumber, PgsProgressCategory progressCategory); + void validPlanNumber(BigDecimal planNumber, PgsProgressCategory progressCategory); /** * 校验计划是否延迟 diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java index 7bd27a54..4d3f765d 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressCategoryServiceImpl.java @@ -593,7 +593,7 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl finishedVoList = JSONUtil.toList(finishedDetail, PgsProgressPlanDetailFinishedVo.class); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanDetailServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanDetailServiceImpl.java index 37a0aebf..55ef3272 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanDetailServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/progress/service/impl/PgsProgressPlanDetailServiceImpl.java @@ -14,6 +14,7 @@ import org.dromara.common.core.constant.HttpStatus; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.utils.PageConvertUtil; import org.dromara.facility.domain.FacBoxTransformer; import org.dromara.facility.domain.FacInverter; import org.dromara.facility.domain.FacPhotovoltaicPanel; @@ -38,7 +39,6 @@ import org.dromara.progress.mapper.PgsProgressPlanDetailMapper; import org.dromara.progress.service.IPgsProgressCategoryService; import org.dromara.progress.service.IPgsProgressPlanDetailService; import org.dromara.progress.service.IPgsProgressPlanService; -import org.dromara.common.utils.PageConvertUtil; import org.springframework.beans.BeanUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -187,7 +187,7 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl 100) { + // 判断是否大于 100 + if (finishedNumber.compareTo(BigDecimal.valueOf(100)) > 0) { throw new ServiceException("完成百分比不能大于100", HttpStatus.BAD_REQUEST); } Long id = req.getId(); @@ -246,8 +248,8 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl progressPlan.getPlanNumber()) { throw new ServiceException("完成百分比不能大于计划进度", HttpStatus.BAD_REQUEST); @@ -258,13 +260,13 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl queryPageCompletionDetailList(PgsProgressPlanCompletionQueryReq req, PageQuery pageQuery) { - return null; - } - /** * 查询符合条件的进度计划列表 * @@ -211,7 +197,7 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl numDetailList = new ArrayList<>(); - long aiFill = 0L; + BigDecimal aiFill = new BigDecimal(0); if (detailMap.containsKey(id)) { numDetailList = progressPlanDetailService.getNumVoList(detailMap.get(id)); for (PgsProgressPlanDetailNumVo vo : numDetailList) { - aiFill += vo.getAiFill() != null ? vo.getAiFill() : 0L; + BigDecimal fill = vo.getAiFill() != null ? vo.getAiFill() : BigDecimal.ZERO; + aiFill = aiFill.add(fill); } } progressPlanVo.setDetailList(numDetailList); @@ -339,14 +326,14 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl 0) { + if (planNumber.compareTo(planTotal) > 0) { throw new ServiceException("计划数量不能大于剩余数量", HttpStatus.BAD_REQUEST); } } @@ -382,7 +369,7 @@ public class PgsProgressPlanServiceImpl extends ServiceImpl delayList = value.stream().map(progressPlan -> { PgsProgressPlan newProgressPlan = new PgsProgressPlan(); newProgressPlan.setId(progressPlan.getId()); - newProgressPlan.setDelayNumber(progressPlan.getPlanNumber() - progressPlan.getFinishedNumber()); + newProgressPlan.setDelayNumber(progressPlan.getPlanNumber().subtract(progressPlan.getFinishedNumber())); return newProgressPlan; }).toList(); progressPlanList.addAll(delayList);