diff --git a/xinnengyuan/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/UserService.java b/xinnengyuan/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/UserService.java index 631cb8e0..3185cd86 100644 --- a/xinnengyuan/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/UserService.java +++ b/xinnengyuan/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/service/UserService.java @@ -124,4 +124,10 @@ public interface UserService { */ Map selectPostNamesByIds(List postIds); + + /** + * 通过用户id查询头像 + */ + String selectAvatarById(Long userId); + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/controller/SubConstructionUserController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/controller/SubConstructionUserController.java index b04ca1b1..a0e7d7af 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/controller/SubConstructionUserController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/controller/SubConstructionUserController.java @@ -90,6 +90,27 @@ public class SubConstructionUserController extends BaseController { return constructionUserService.queryPageList(req, pageQuery); } + /** + * 新人池 + */ + @SaCheckPermission("contractor:constructionUser:newUserList") + @GetMapping("/newUserList") + public TableDataInfo newUserList(SubConstructionUserQueryReq req, PageQuery pageQuery) { + return constructionUserService.queryNewUserPageList(req, pageQuery); + } + + /** + * 分配 + */ + @SaCheckPermission("contractor:constructionUser:allocate") + @PutMapping("/allocate") + @RepeatSubmit() + public R allocate(@RequestBody @Validated AllocateDto dto) { + return R.ok(constructionUserService.allocate(dto)); + } + + + /** * 查询每个施工人员总的考勤列表 */ diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/domain/dto/constructionuser/AllocateDto.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/domain/dto/constructionuser/AllocateDto.java new file mode 100644 index 00000000..92f1156b --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/domain/dto/constructionuser/AllocateDto.java @@ -0,0 +1,60 @@ +package org.dromara.contractor.domain.dto.constructionuser; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +/** + * @author lilemy + * @date 2025/3/5 14:31 + */ + +@Data +public class AllocateDto implements Serializable { + + @Serial + private static final long serialVersionUID = 3252651952758479341L; + + + @NotNull(message = "数据Id") + private Long id; + + /** + * 项目id + */ + @NotNull(message = "项目不能为空") + private Long projectId; + + /** + * 分包公司id + */ + @NotNull(message = "分包不能为空") + private Long contractorId; + + /** + * 班组id + */ + @NotNull(message = "班组不能为空") + private Long teamId; + + /** + * 部门id + */ + @NotNull(message = "部门不能为空") + private Long deptId; + + /** + * 工种(字典type_of_work) + */ + @NotNull(message = "工种不能为空") + private String typeOfWork; + + /** + * 岗位(默认为0普通员工,1组长) + */ + @NotNull(message = "岗位不能为空") + private String postId; + +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/service/ISubConstructionUserService.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/service/ISubConstructionUserService.java index e4e7b5b9..532a0d30 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/service/ISubConstructionUserService.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/service/ISubConstructionUserService.java @@ -41,6 +41,9 @@ public interface ISubConstructionUserService extends IService queryPageList(SubConstructionUserQueryReq req, PageQuery pageQuery); + TableDataInfo queryNewUserPageList(SubConstructionUserQueryReq req, PageQuery pageQuery); + + Boolean allocate(AllocateDto dto); /** * 分页查询施工人员考勤列表 * diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/service/impl/SubConstructionUserServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/service/impl/SubConstructionUserServiceImpl.java index a5e116cf..31d75ebc 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/service/impl/SubConstructionUserServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/contractor/service/impl/SubConstructionUserServiceImpl.java @@ -45,20 +45,20 @@ import org.dromara.contractor.mapper.SubConstructionUserMapper; import org.dromara.contractor.service.ISubConstructionUserFileService; import org.dromara.contractor.service.ISubConstructionUserService; import org.dromara.contractor.service.ISubContractorService; -import org.dromara.project.domain.BusAttendance; -import org.dromara.project.domain.BusProject; -import org.dromara.project.domain.BusProjectTeamMember; -import org.dromara.project.domain.BusWorkWage; +import org.dromara.project.domain.*; import org.dromara.project.domain.enums.BusAttendanceClockStatusEnum; import org.dromara.project.domain.enums.BusAttendanceCommuterEnum; import org.dromara.project.domain.enums.BusConstructionUserAttendanceStatusEnum; import org.dromara.project.service.*; import org.dromara.system.domain.SysUser; +import org.dromara.system.domain.SysUserRole; import org.dromara.system.domain.bo.SysUserBo; import org.dromara.system.domain.vo.SysOssVo; import org.dromara.system.domain.vo.SysUserVo; +import org.dromara.system.mapper.SysUserRoleMapper; import org.dromara.system.service.ISysDictTypeService; import org.dromara.system.service.ISysOssService; +import org.dromara.system.service.ISysRoleService; import org.dromara.system.service.ISysUserService; import org.jetbrains.annotations.NotNull; import org.springframework.beans.BeanUtils; @@ -92,6 +92,10 @@ public class SubConstructionUserServiceImpl extends ServiceImpl queryNewUserPageList(SubConstructionUserQueryReq req, PageQuery pageQuery) { + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + // 从对象中取值 + String userName = req.getUserName(); + + // 模糊查询 + lqw.like(StringUtils.isNotBlank(userName), SubConstructionUser::getUserName, userName); + lqw.isNull(SubConstructionUser::getProjectId); + lqw.isNull(SubConstructionUser::getTeamId); + // 添加关联查询条件:sys_user的dept_id为null + // 另一种写法,使用表别名 + lqw.apply("exists (select 1 from sys_user where user_id = sys_user_id and dept_id is null)"); + + Page result = this.page(pageQuery.build(), lqw); + List list = result.getRecords().stream().map(vo -> { + SubConstructionUserVo subConstructionUserVo = new SubConstructionUserVo(); + BeanUtils.copyProperties(vo, subConstructionUserVo); + // 解密身份证号码 + String decrypt = vo.getSfzNumber(); + try { + decrypt = idCardEncryptorUtil.decrypt(decrypt); + } catch (Exception e) { + log.warn("身份证解密失败"); + } + subConstructionUserVo.setSfzNumber(decrypt); + return subConstructionUserVo; + }).collect(Collectors.toList()); + return new TableDataInfo<>(list, result.getTotal()); + } + + @Override + public Boolean allocate(AllocateDto dto) { + SubConstructionUser constructionUser = baseMapper.selectById(dto.getId()); + if(constructionUser == null){ + throw new ServiceException("施工人员信息不存在", HttpStatus.ERROR); + } + constructionUser.setProjectId(dto.getProjectId()); + constructionUser.setContractorId(dto.getContractorId()); + + BusProjectTeam team = projectTeamService.getById(dto.getTeamId()); + if(team == null){ + throw new ServiceException("班组信息不存在", HttpStatus.ERROR); + } + constructionUser.setTeamId(dto.getTeamId()); + constructionUser.setTeamName(team.getTeamName()); + constructionUser.setTypeOfWork(dto.getTypeOfWork()); + constructionUser.setEntryDate(new Date()); + constructionUser.setFirstDate(LocalDate.now()); + + int i = baseMapper.updateById(constructionUser); + + //人员与班组关联表 + BusProjectTeamMember projectTeamMember = new BusProjectTeamMember(); + projectTeamMember.setMemberId(constructionUser.getSysUserId()); + projectTeamMember.setTeamId(dto.getTeamId()); + projectTeamMember.setProjectId(dto.getProjectId()); + projectTeamMember.setPostId(dto.getPostId()); + projectTeamMemberService.save(projectTeamMember); + + //人员与项目关联表 + BusUserProjectRelevancy relevancy = new BusUserProjectRelevancy(); + relevancy.setUserId(constructionUser.getSysUserId()); + relevancy.setProjectId(dto.getProjectId()); + userProjectRelevancyService.save(relevancy); + + //设置基础角色 先清空已有角色 + userRoleMapper.delete(Wrappers.lambdaQuery() + .eq(SysUserRole::getUserId, constructionUser.getSysUserId()) + .eq(SysUserRole::getProjectId, dto.getProjectId()) + .in(SysUserRole::getRoleId, Arrays.asList(2L, 3L)) + ); + //再添加分配角色 + Long roleId = "0".equals(dto.getPostId()) ? 2L : 3L; + SysUserRole sysUserRole = new SysUserRole(); + sysUserRole.setUserId(constructionUser.getSysUserId()); + sysUserRole.setRoleId(roleId); + sysUserRole.setProjectId(dto.getProjectId()); + userRoleMapper.insert(sysUserRole); + + //强退 + roleService.cleanOnlineUser(Collections.singletonList(constructionUser.getSysUserId())); + + return i>0; + } + /** * 分页查询施工人员考勤列表 * @@ -1356,9 +1458,10 @@ public class SubConstructionUserServiceImpl extends ServiceImpl wrapper.isNull(SubConstructionUser::getProjectId) + .or().eq(SubConstructionUser::getProjectId, req.getProjectId()) + ); Page result = this.page(pageQuery.build(), lqw); ArrayList list = new ArrayList<>(); diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cory/controller/app/BusContactnoticeAppController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cory/controller/app/BusContactnoticeAppController.java index b1365c5c..4d14c2eb 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cory/controller/app/BusContactnoticeAppController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/cory/controller/app/BusContactnoticeAppController.java @@ -67,4 +67,15 @@ public class BusContactnoticeAppController extends BaseController { return R.ok(busContactnoticeService.insertByBo(bo)); } + /** + * 修改联系单 + */ + @Log(title = "联系单", businessType = BusinessType.UPDATE) + @RepeatSubmit() + @PutMapping() + public R edit(@Validated(EditGroup.class) @RequestBody BusContactnoticeBo bo) { + return R.ok(busContactnoticeService.updateByBo(bo)); + } + + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/app/BusBillofquantitiesVersionsAppController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/app/BusBillofquantitiesVersionsAppController.java new file mode 100644 index 00000000..ca0be62f --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/app/BusBillofquantitiesVersionsAppController.java @@ -0,0 +1,81 @@ +package org.dromara.design.controller.app; + +import cn.dev33.satoken.annotation.SaCheckPermission; +import jakarta.validation.constraints.NotNull; +import lombok.RequiredArgsConstructor; +import org.dromara.common.core.domain.R; +import org.dromara.common.core.enums.BusinessStatusEnum; +import org.dromara.common.idempotent.annotation.RepeatSubmit; +import org.dromara.common.log.annotation.Log; +import org.dromara.common.log.enums.BusinessType; +import org.dromara.common.mybatis.core.page.PageQuery; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.web.core.BaseController; +import org.dromara.design.domain.bo.*; +import org.dromara.design.domain.vo.*; +import org.dromara.design.service.IBusBillofquantitiesVersionsService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +/** + * 工程量清单版本 + * + * @author Lion Li + * @date 2025-08-11 + */ +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/app/design/billofquantitiesVersions") +public class BusBillofquantitiesVersionsAppController extends BaseController { + + private final IBusBillofquantitiesVersionsService busBillofquantitiesVersionsService; + + + + /** + * 获取所有版本号 + */ + @GetMapping("/obtainAllVersionNumbers") + public TableDataInfo obtainAllVersionNumbers(ObtainAllVersionNumbersReq bo, PageQuery pageQuery) { + bo.setStatus(BusinessStatusEnum.FINISH.getStatus()); + return busBillofquantitiesVersionsService.obtainAllVersionNumbers(bo, pageQuery); + } + + /** + * 获取物资设备清单总数据 + */ + @GetMapping("/materialTotal/{projectId}") + public R> queryMaterialTotalListByProject(@NotNull(message = "项目主键不能为空") + @PathVariable Long projectId) { + return R.ok(busBillofquantitiesVersionsService.queryMaterialTotalListByProject(projectId)); + } + + /** + * 获取指定版本的sheet + */ + @GetMapping("/sheetList") + public R> sheetList(SheetListReq bo) { + return R.ok(busBillofquantitiesVersionsService.sheetList(bo)); + } + + /** + * 获取工程量清单列表 + */ + @GetMapping("/obtainTheList") + public R> obtainTheList(CoryObtainTheListReq bo, PageQuery pageQuery) { + return R.ok(busBillofquantitiesVersionsService.obtainTheList(bo)); + } + + + /** + * 查询工程量清单版本列表 + */ + @GetMapping("/list") + public TableDataInfo list(PageQuery pageQuery) { + return busBillofquantitiesVersionsService.queryPageList(new BusBillofquantitiesVersionsBo(), pageQuery); + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/app/DesDesignChangeAppController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/app/DesDesignChangeAppController.java index 0e95ea3d..0436c5d9 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/app/DesDesignChangeAppController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/controller/app/DesDesignChangeAppController.java @@ -53,29 +53,17 @@ public class DesDesignChangeAppController extends BaseController { /** * 查询设计变更管理列表 */ - @SaCheckPermission("design:designChange:list") @GetMapping("/list") public TableDataInfo list(DesDesignChangeQueryReq req, PageQuery pageQuery) { return desDesignChangeService.queryPageList(req, pageQuery); } - /** - * 根据主键导出设计变更单 - */ - @SaCheckPermission("design:designChange:exportWord") - @Log(title = "设计变更管理", businessType = BusinessType.EXPORT) - @PostMapping("/export/word") - public void exportWordById(@NotNull(message = "主键不能为空") Long id, - HttpServletResponse response) { - desDesignChangeService.exportWordById(id, response); - } /** * 获取设计变更管理详细信息 * * @param id 主键 */ - @SaCheckPermission("design:designChange:query") @GetMapping("/{id}") public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) { @@ -85,7 +73,6 @@ public class DesDesignChangeAppController extends BaseController { /** * 新增设计变更管理 */ - @SaCheckPermission("design:designChange:add") @Log(title = "设计变更管理", businessType = BusinessType.INSERT) @RepeatSubmit() @PostMapping() @@ -96,7 +83,6 @@ public class DesDesignChangeAppController extends BaseController { /** * 修改设计变更管理 */ - @SaCheckPermission("design:designChange:edit") @Log(title = "设计变更管理", businessType = BusinessType.UPDATE) @RepeatSubmit() @PutMapping() @@ -104,40 +90,15 @@ public class DesDesignChangeAppController extends BaseController { return R.ok(desDesignChangeService.updateByBo(req)); } - /** - * 删除设计变更管理 - * - * @param ids 主键串 - */ - @SaCheckPermission("design:designChange:remove") - @Log(title = "设计变更管理", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public R remove(@NotEmpty(message = "主键不能为空") - @PathVariable Long[] ids) { - return toAjax(desDesignChangeService.deleteByIds(List.of(ids))); - } - /** * 查询选择卷册目录 */ - @SaCheckPermission("design:designChange:catalogList") @GetMapping("/catalogList/{projectId}") public R> catalogList(@PathVariable("projectId") Long projectId) { return R.ok(desVolumeCatalogService.catalogList(projectId)); } - /** - * 查询选择目录下的蓝图 - */ - @SaCheckPermission("design:designChange:blueprint") - @GetMapping("/blueprint/{volumeCatalogId}") - public R> blueprint(@PathVariable("volumeCatalogId") Long volumeCatalogId) { - List list = desVolumeFileService.list(Wrappers.lambdaQuery(DesVolumeFile.class) - .eq(DesVolumeFile::getVolumeCatalogId, volumeCatalogId) - .eq(DesVolumeFile::getType, DesVolumeFile.BLUEPRINT) - .eq(DesVolumeFile::getAuditStatus, BusinessStatusEnum.FINISH.getStatus())); - return R.ok(list); - } + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/bo/ObtainAllVersionNumbersReq.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/bo/ObtainAllVersionNumbersReq.java index 5e22dc92..4f2826d7 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/bo/ObtainAllVersionNumbersReq.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/bo/ObtainAllVersionNumbersReq.java @@ -1,5 +1,6 @@ package org.dromara.design.domain.bo; +import io.swagger.v3.oas.annotations.Hidden; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Data; @@ -28,4 +29,7 @@ public class ObtainAllVersionNumbersReq implements Serializable { @NotNull(message = "项目ID不能为空") private Long projectId; + @Hidden() + private String status; + } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/BusBillofquantitiesVersionsVo.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/BusBillofquantitiesVersionsVo.java index 4ae7b63f..f9221e09 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/BusBillofquantitiesVersionsVo.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/domain/vo/BusBillofquantitiesVersionsVo.java @@ -1,5 +1,7 @@ package org.dromara.design.domain.vo; +import org.dromara.common.translation.annotation.Translation; +import org.dromara.common.translation.constant.TransConstant; import org.dromara.design.domain.BusBillofquantitiesVersions; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; @@ -67,4 +69,16 @@ public class BusBillofquantitiesVersionsVo implements Serializable { @ExcelProperty(value = "审核状态") private String status; + + /** + * 项目ID + */ + private Long projectId; + + + /** + * 项目名称 + */ + @Translation(type = TransConstant.PROJECT_ID_TO_NAME, mapper = "projectId") + private String projectName; } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/BusBillofquantitiesVersionsServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/BusBillofquantitiesVersionsServiceImpl.java index 62294839..10bb90ba 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/BusBillofquantitiesVersionsServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/design/service/impl/BusBillofquantitiesVersionsServiceImpl.java @@ -495,10 +495,11 @@ public class BusBillofquantitiesVersionsServiceImpl extends ServiceImpl result = baseMapper.selectVoPage(pageQuery.build(), lqw); - result.getRecords().forEach(item -> { - System.out.println("1 " + item.getStatus()); - }); +// result.getRecords().forEach(item -> { +// System.out.println("1 " + item.getStatus()); +// }); return TableDataInfo.build(result); } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java index 729e06be..31468183 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java @@ -11,6 +11,7 @@ import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.model.LoginUser; +import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.encrypt.annotation.ApiEncrypt; @@ -167,7 +168,11 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping public R add(@Validated @RequestBody SysUserBo user) { + if(user.getDeptId() == null){ + throw new ServiceException("请选择部门!"); + } deptService.checkDeptDataScope(user.getDeptId()); + // 去重后的所有 roleId List roleList = user.getProjectRoles().stream() .filter(dto -> dto.getRoleIds() != null) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java index 061af597..a0acc5e9 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java @@ -35,6 +35,7 @@ import org.dromara.system.domain.vo.SysRoleVo; import org.dromara.system.domain.vo.SysUserExportVo; import org.dromara.system.domain.vo.SysUserVo; import org.dromara.system.mapper.*; +import org.dromara.system.service.ISysOssService; import org.dromara.system.service.ISysUserFileService; import org.dromara.system.service.ISysUserService; import org.springframework.cache.annotation.CacheEvict; @@ -65,6 +66,8 @@ public class SysUserServiceImpl implements ISysUserService, UserService { private final SysUserPostMapper userPostMapper; private final IBusUserProjectRelevancyService userProjectRelevancyService; + private final SysOssMapper ossMapper; + private final ISubConstructionUserService constructionUserService; @Lazy @@ -110,6 +113,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService { private Wrapper buildQueryWrapper(SysUserBo user) { Map params = user.getParams(); QueryWrapper wrapper = Wrappers.query(); + wrapper.isNotNull("u.dept_id"); wrapper.eq("u.del_flag", SystemConstants.NORMAL) .eq(StringUtils.isNotBlank(user.getUserType()),"u.user_type",user.getUserType()) .eq(ObjectUtil.isNotNull(user.getUserId()), "u.user_id", user.getUserId()) @@ -1074,4 +1078,16 @@ public class SysUserServiceImpl implements ISysUserService, UserService { .collect(Collectors.toMap(SysPost::getPostId, SysPost::getPostName)); } + @Override + public String selectAvatarById(Long userId) { + SysUser sysUsers = baseMapper.selectById(userId); + if(sysUsers == null || sysUsers.getAvatar() == null){ + return null; + } + SysOss sysOss = ossMapper.selectById(sysUsers.getAvatar()); + if(sysOss == null){ + return null; + } + return sysOss.getUrl(); + } } diff --git a/xinnengyuan/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/app/FlowAppController.java b/xinnengyuan/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/app/FlowAppController.java new file mode 100644 index 00000000..b19721fa --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/controller/app/FlowAppController.java @@ -0,0 +1,182 @@ +package org.dromara.workflow.controller.app; + +import cn.hutool.core.util.StrUtil; +import lombok.RequiredArgsConstructor; +import org.dromara.common.core.domain.R; +import org.dromara.common.core.domain.dto.UserDTO; +import org.dromara.common.core.enums.BusinessStatusEnum; +import org.dromara.common.core.service.UserService; +import org.dromara.warm.flow.core.FlowEngine; +import org.dromara.warm.flow.core.dto.DefJson; +import org.dromara.warm.flow.core.dto.NodeJson; +import org.dromara.warm.flow.core.entity.Instance; +import org.dromara.warm.flow.core.invoker.FrameInvoker; +import org.dromara.warm.flow.ui.service.ChartExtService; +import org.dromara.workflow.common.ConditionalOnEnable; +import org.dromara.workflow.domain.bo.FlowCategoryBo; +import org.dromara.workflow.domain.vo.FlowAppVo; +import org.dromara.workflow.domain.vo.FlowCategoryVo; +import org.dromara.workflow.domain.vo.FlowHisTaskVo; +import org.dromara.workflow.service.IFlwInstanceService; +import org.dromara.workflow.service.IFlwTaskAssigneeService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import java.util.stream.Collectors; + +@ConditionalOnEnable +@Validated +@RequiredArgsConstructor +@RestController +@RequestMapping("/app/workflow/") +public class FlowAppController { + + private final IFlwInstanceService flwInstanceService; + + private final UserService userService; + + private final IFlwTaskAssigneeService flwTaskAssigneeService; + + @GetMapping("/{businessId}") + public R> list(@PathVariable("businessId") String businessId,Long projectId) { + Map stringObjectMap; + try { + stringObjectMap = flwInstanceService.flowHisTaskList(businessId); + } catch (Exception e) { + return R.ok(null,null); + } + + List list= (List) stringObjectMap.get("list"); + Map map = list.stream().collect(Collectors.toMap(FlowHisTaskVo::getNodeCode, vo -> vo)); + + + String instanceId = (String) stringObjectMap.get("instanceId"); + String defJsonStr = ((Instance) FlowEngine.insService().getById(instanceId)).getDefJson(); + DefJson defJson = (DefJson)FlowEngine.jsonConvert.strToBean(defJsonStr, DefJson.class); + ChartExtService chartExtService = (ChartExtService) FrameInvoker.getBean(ChartExtService.class); + if (chartExtService != null) { + chartExtService.initPromptContent(defJson); + chartExtService.execute(defJson); + } + + List nodeList = defJson.getNodeList(); + List nodeJsons = sortNodeList(nodeList); + List appVoList = new ArrayList<>(); + for (NodeJson nodeJson : nodeJsons ){ + FlowAppVo appVo = new FlowAppVo(); + + appVo.setNodeName(nodeJson.getNodeName()); + appVo.setStatus(nodeJson.getStatus()); + appVo.setNodeType(nodeJson.getNodeType()); + String nodeCode = nodeJson.getNodeCode(); + FlowHisTaskVo flowHisTaskVo = map.get(nodeCode); + if(flowHisTaskVo != null){ + appVo.setFlowStatus(flowHisTaskVo.getFlowStatus()); + if(BusinessStatusEnum.WAITING.getStatus().equals(flowHisTaskVo.getFlowStatus())){ + appVo.setAuditName(flowHisTaskVo.getApproveName()); + }else { + appVo.setApproveName(flowHisTaskVo.getApproveName()); + if(StrUtil.isNotBlank(flowHisTaskVo.getApprover())){ + appVo.setApproveAvatar(userService.selectAvatarById(Long.valueOf(flowHisTaskVo.getApprover()))); + } + } + }else { + appVo.setFlowStatus(BusinessStatusEnum.WAITING.getStatus()); + if(nodeJson.getNodeType()==1){ + String permissionFlag = nodeJson.getPermissionFlag(); + List userDTOS = flwTaskAssigneeService.fetchUsersByStorageIds(permissionFlag, projectId); + String auditName = userDTOS.stream().map(UserDTO::getNickName).collect(Collectors.joining(",")); + appVo.setAuditName(auditName); + } + } + } + + return R.ok(appVoList); + } + + + public List sortNodeList(List nodeList) { + // 1. 分离不同类型的节点 + NodeJson startNode = null; // nodeType=0 + NodeJson endNode = null; // nodeType=2 + List approvalNodes = new ArrayList<>(); // nodeType=1 + + for (NodeJson node : nodeList) { + if (node.getNodeType() == 0) { + startNode = node; + } else if (node.getNodeType() == 2) { + endNode = node; + } else if (node.getNodeType() == 1) { + approvalNodes.add(node); + } + } + + // 2. 对审批节点(nodeType=1)按流程顺序排序 + List sortedApprovalNodes = sortApprovalNodes(approvalNodes, startNode); + + // 3. 组合最终排序结果:开始节点 → 排序后的审批节点 → 结束节点 + List result = new ArrayList<>(); + if (startNode != null) { + result.add(startNode); + } + result.addAll(sortedApprovalNodes); + if (endNode != null) { + result.add(endNode); + } + + return result; + } + + /** + * 对审批节点按流程流转顺序排序 + */ + private List sortApprovalNodes(List approvalNodes, NodeJson startNode) { + // 创建节点编码到节点对象的映射,方便快速查找 + Map nodeMap = approvalNodes.stream() + .collect(Collectors.toMap(NodeJson::getNodeCode, node -> node)); + + List sortedList = new ArrayList<>(); + + // 从开始节点的下一个节点开始 + String currentNodeCode = getFirstApprovalNodeCode(startNode); + if (currentNodeCode == null) { + return sortedList; // 没有找到起始审批节点,返回空列表 + } + + // 循环查找下一个节点,直到找不到或形成闭环 + Set visited = new HashSet<>(); + while (currentNodeCode != null && nodeMap.containsKey(currentNodeCode) && !visited.contains(currentNodeCode)) { + visited.add(currentNodeCode); + NodeJson currentNode = nodeMap.get(currentNodeCode); + sortedList.add(currentNode); + + // 获取下一个节点编码 + currentNodeCode = getNextNodeCode(currentNode); + } + + return sortedList; + } + + /** + * 获取开始节点指向的第一个审批节点编码 + */ + private String getFirstApprovalNodeCode(NodeJson startNode) { + if (startNode == null || startNode.getSkipList() == null || startNode.getSkipList().isEmpty()) { + return null; + } + // 取第一个流转关系的下一个节点编码 + return startNode.getSkipList().getFirst().getNextNodeCode(); + } + + /** + * 获取当前节点指向的下一个节点编码 + */ + private String getNextNodeCode(NodeJson currentNode) { + if (currentNode == null || currentNode.getSkipList() == null || currentNode.getSkipList().isEmpty()) { + return null; + } + // 取第一个流转关系的下一个节点编码 + return currentNode.getSkipList().getFirst().getNextNodeCode(); + } +} diff --git a/xinnengyuan/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/FlowAppVo.java b/xinnengyuan/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/FlowAppVo.java new file mode 100644 index 00000000..7e6b00dd --- /dev/null +++ b/xinnengyuan/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/domain/vo/FlowAppVo.java @@ -0,0 +1,50 @@ +package org.dromara.workflow.domain.vo; + + +import lombok.Data; +import org.dromara.common.core.domain.dto.UserDTO; + +import java.security.PrivilegedAction; +import java.util.List; +import java.util.Map; + +@Data +public class FlowAppVo { + + /** + * 节点类型 0-开始 1-中间 2-结束 + */ + private Integer nodeType; + + /** + * 节点名称 + */ + private String nodeName; + + /** + * 审核状态 + */ + private String flowStatus; + + + /** + * 审核人 + */ + private String auditName; + + /** + * 审批操作人 + */ + private String approveName; + + /** + * 审批操作人头像 + */ + private String approveAvatar; + + /** + * 节点状态 0-未开始 1-进行中 2-已完成 + */ + private Integer status; + +}