diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpayment/vo/FinancialPaymentPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpayment/vo/FinancialPaymentPageReqVO.java index 4ca64098..228dba07 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpayment/vo/FinancialPaymentPageReqVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpayment/vo/FinancialPaymentPageReqVO.java @@ -9,6 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -53,4 +54,6 @@ public class FinancialPaymentPageReqVO extends PageParam { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] endTime; + @Schema(description = "部门ids") + private List deptIds; } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/financialpayment/FinancialPaymentServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/financialpayment/FinancialPaymentServiceImpl.java index ee05fc6c..c8b0ef55 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/financialpayment/FinancialPaymentServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/financialpayment/FinancialPaymentServiceImpl.java @@ -1,7 +1,9 @@ package cn.iocoder.yudao.module.bpm.service.financialpayment; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.Constants; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; @@ -26,6 +28,7 @@ import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAReimbursementMapper; import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmProcessInstanceExtMapper; import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.subscribe.SubscribeMessageSendApi; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; @@ -36,6 +39,8 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; @@ -68,6 +73,8 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService { private AdminUserApi userApi; @Resource private BpmProcessInstanceExtMapper processInstanceExtMapper; + @Resource + private DeptApi deptApi; @Override public Long createFinancialPayment(FinancialPaymentSaveVO vo) { @@ -152,6 +159,15 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService { @Override public PageResult getFinancialPaymentPage(FinancialPaymentPageReqVO pageReqVO) { pageReqVO.setReceiveUserId(getLoginUserId()); + List deptIds = new ArrayList<>(); + if (pageReqVO.getDeptId() != null) { + deptIds.add(pageReqVO.getDeptId()); + CommonResult> childDeptList = deptApi.getChildDeptList(pageReqVO.getDeptId()); + if (childDeptList.isSuccess()) { + deptIds.addAll(childDeptList.getData()); + } + pageReqVO.setDeptIds(deptIds); + } IPage vos = financialPaymentMapper.getFinancialPaymentPage(pageReqVO, MyBatisUtils.buildPage(pageReqVO)); return new PageResult<>(vos.getRecords(), vos.getTotal()); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/financialpayment/FinancialPaymentMapper.xml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/financialpayment/FinancialPaymentMapper.xml index 2e32b7a8..377d42ac 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/financialpayment/FinancialPaymentMapper.xml +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/financialpayment/FinancialPaymentMapper.xml @@ -22,8 +22,11 @@ left join system_users as d on a.receive_user_id = d.id a.deleted = 0 - - and c.id = #{vo.deptId} + + AND c.id IN + + #{deptId} + and b.nickname like concat('%', #{vo.nickname}, '%') diff --git a/yudao-module-report/yudao-module-report-biz/src/main/resources/application-local.yaml b/yudao-module-report/yudao-module-report-biz/src/main/resources/application-local.yaml index 134a0841..a510ea35 100644 --- a/yudao-module-report/yudao-module-report-biz/src/main/resources/application-local.yaml +++ b/yudao-module-report/yudao-module-report-biz/src/main/resources/application-local.yaml @@ -41,25 +41,25 @@ spring: primary: master datasource: master: - name: ruoyi-vue-pro - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + name: ruoyi-vue-pro-dev + url: jdbc:mysql://rm-bp1yloyj508qld78jno.mysql.rds.aliyuncs.com:3306/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 username: root - password: 123456 + password: Znalyrds2024 # username: sa # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W slave: # 模拟从库,可根据自己需要修改 - name: ruoyi-vue-pro - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + name: ruoyi-vue-pro-dev + url: jdbc:mysql://rm-bp1yloyj508qld78jno.mysql.rds.aliyuncs.com:3306/${spring.datasource.dynamic.datasource.master.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 username: root - password: 123456 + password: Znalyrds2024 # username: sa # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java index bd67fde3..7ddbabdd 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java @@ -42,7 +42,7 @@ public interface DeptApi { @GetMapping(PREFIX + "/getByLeaderId") @Operation(summary = "获取特定部门信息") @Parameter(name = "leaderUserId", description = "部门负责人", example = "12", required = true) - CommonResult> getDeptByLeaderId(@RequestParam("leaderUserId")Long leaderUserId); + CommonResult> getDeptByLeaderId(@RequestParam("leaderUserId") Long leaderUserId); @GetMapping(PREFIX + "/getList") @Operation(summary = "获取所有部门信息") @@ -81,4 +81,9 @@ public interface DeptApi { List list = getDeptList(ids).getCheckedData(); return CollectionUtils.convertMap(list, DeptRespDTO::getId); } + + @GetMapping(PREFIX + "/getChildDeptList") + @Operation(summary = "获得指定部门的所有子部门id") + @Parameter(name = "deptId", description = "用户id", example = "146", required = true) + CommonResult> getChildDeptList(@RequestParam("deptId") Long deptId); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java index 54ff40c6..92f4190a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.api.dept; +import cn.hutool.core.collection.CollectionUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; @@ -14,7 +15,9 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -108,4 +111,14 @@ public class DeptApiImpl implements DeptApi { List deptDOS = deptService.getDeptByLeaderId(userId); return success(BeanUtils.toBean(deptDOS, DeptRespDTO.class)); } + + @Override + public CommonResult> getChildDeptList(Long deptId) { + List deptDOS = deptService.getChildDeptList(deptId); + if (CollectionUtil.isEmpty(deptDOS)) { + return success(Collections.emptyList()); + } + List ids = deptDOS.stream().map(DeptDO::getId).collect(Collectors.toList()); + return success(ids); + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/worklog/dto/statistics/LogStatisticsDetailsListGroupByUserDTO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/worklog/dto/statistics/LogStatisticsDetailsListGroupByUserDTO.java index f18e1987..50bac305 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/worklog/dto/statistics/LogStatisticsDetailsListGroupByUserDTO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/worklog/dto/statistics/LogStatisticsDetailsListGroupByUserDTO.java @@ -28,4 +28,8 @@ public class LogStatisticsDetailsListGroupByUserDTO { */ private List dateList; + /** + * 部门ids + */ + private List deptIds; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/worklog/LogStatisticsServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/worklog/LogStatisticsServiceImpl.java index 4a9f4124..69388929 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/worklog/LogStatisticsServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/worklog/LogStatisticsServiceImpl.java @@ -17,16 +17,18 @@ import cn.iocoder.yudao.module.system.controller.admin.worklog.dto.statistics.My import cn.iocoder.yudao.module.system.controller.admin.worklog.dto.statistics.NeedWriteHistoryDTO; import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.statistics.*; import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.statisticsrecord.LogStatisticsDetailsListGroupByUserVO; -import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.statisticsrecord.LogStatisticsGroupByUserVO; +import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.worklog.*; import cn.iocoder.yudao.module.system.dal.mysql.worklog.LogFormMapper; import cn.iocoder.yudao.module.system.dal.mysql.worklog.LogStatisticsMapper; import cn.iocoder.yudao.module.system.dal.mysql.worklog.LogUseMapper; import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants; +import cn.iocoder.yudao.module.system.service.dept.DeptService; import cn.iocoder.yudao.module.system.service.worklog.dto.LogUseVO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -57,6 +59,9 @@ public class LogStatisticsServiceImpl implements LogStatisticsService { @Resource private LogStatisticsMapper logStatisticsMapper; + @Resource + @Lazy + private DeptService deptService; @Override public Long createLogStatistics(LogStatisticsSaveReqVO createReqVO) { @@ -406,6 +411,15 @@ public class LogStatisticsServiceImpl implements LogStatisticsService { throw exception(ErrorCodeConstants.PLEASE_SELECT_A_TIME_RANGE); } dto.setDateList(dateList); + List deptIds = new ArrayList<>(); + if (dto.getDeptId() != null) { + deptIds.add(dto.getDeptId()); + List deptList = deptService.getChildDeptList(dto.getDeptId()); + if (CollectionUtil.isNotEmpty(deptList)) { + deptIds.addAll(deptList.stream().map(DeptDO::getId).collect(Collectors.toList())); + } + dto.setDeptIds(deptIds); + } // 获取到所有数据 然后在java代码中分组 List vos = logStatisticsMapper.getStatisticsGroupByUser(dto); // 根据用户id/部门id分组 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/worklog/LogStatisticsMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/worklog/LogStatisticsMapper.xml index 61c68cec..016f370c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/worklog/LogStatisticsMapper.xml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/worklog/LogStatisticsMapper.xml @@ -175,10 +175,12 @@ and b.type = #{dto.type} - - and b.dept_id = #{dto.deptId} + + AND b.dept_id IN + + #{deptId} + -