feat(system): 新增部门类型枚举和项目管理相关功能
- 新增全局部门类型枚举 DeptTypeEnum - 在 DeptRespDTO 中添加部门类型字段 - 新增 ProjectApi 接口和 ProjectDTO 类,用于项目管理功能
This commit is contained in:
parent
ce26b95c08
commit
de45686361
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.framework.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 全局部门类型枚举
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum DeptTypeEnum {
|
||||
|
||||
COMPANY("COMPANY", "公司"),
|
||||
SALE_DEPT("SALE_DEPT", "销售部门"),
|
||||
DEVELOPMENT_DEPT("DEVELOPMENT_DEPT", "开发部门"),
|
||||
PRODUCTION_DEPT("TECHNICAL_DEPT", "生产部门"),
|
||||
MARKETING_DEPT("MARKETING_DEPT", "市场部门"),
|
||||
FINANCE_DEPT("FINANCE_DEPT", "财务部门"),
|
||||
HR_DEPT("HR_DEPT", "人力部门"),
|
||||
PURCHASING_DEPT("PURCHASING_DEPT", "采购部门"),
|
||||
OTHER("OTHER", "其他部门");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String value;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private final String name;
|
||||
}
|
@ -6,6 +6,10 @@ import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.project.BpmOAProjectCr
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.project.BpmOAProjectRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProjectDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAProjectService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -15,7 +19,14 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
/**
|
||||
@ -32,6 +43,12 @@ public class BpmOAProjectController {
|
||||
@Resource
|
||||
private BpmOAProjectService projectService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi userApi;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建请求申请")
|
||||
public CommonResult<Long> createProject(@Valid @RequestBody BpmOAProjectCreateReqVO createReqVO) {
|
||||
@ -45,8 +62,36 @@ public class BpmOAProjectController {
|
||||
public CommonResult<BpmOAProjectRespVO> getProject(@RequestParam("id") Long id) {
|
||||
|
||||
BpmOAProjectDO project = projectService.getProject(id);
|
||||
BpmOAProjectRespVO respVO = BeanUtils.toBean(project, BpmOAProjectRespVO.class);
|
||||
|
||||
return success(BeanUtils.toBean(project, BpmOAProjectRespVO.class));
|
||||
if (respVO != null) {
|
||||
|
||||
// 获取项目中所有部门编号列表
|
||||
Set<Long> deptIds = respVO.getParticipationDept() == null ? new HashSet<>() : respVO.getParticipationDept();
|
||||
deptIds.add(respVO.getResponsibleDept());
|
||||
|
||||
// 获取所有用户信息
|
||||
AdminUserRespDTO userRespDTO = userApi.getUser(respVO.getDirectorUserId()).getCheckedData();
|
||||
// 获取所有部门信息
|
||||
List<DeptRespDTO> deptDOS = deptApi.getDeptList(deptIds).getCheckedData();
|
||||
Map<Long, DeptRespDTO> deptMap = convertMap(deptDOS, DeptRespDTO::getId);
|
||||
|
||||
// 设置责任人名称
|
||||
respVO.setDirectorUserName(userRespDTO.getNickname());
|
||||
|
||||
// 筛选出不是责任人部门的部门信息
|
||||
List<DeptRespDTO> deptVOs = deptDOS.stream()
|
||||
.filter(dept -> !dept.getId().equals(respVO.getResponsibleDept()))
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 设置责任部门名称
|
||||
respVO.setResponsibleDeptName(deptMap.get(respVO.getResponsibleDept()).getName());
|
||||
// 拼接参与部门名称
|
||||
respVO.setParticipationDeptName(deptVOs.stream().map(DeptRespDTO::getName).collect(Collectors.joining("、")));
|
||||
}
|
||||
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
@GetMapping("/getByProcessInstanceId")
|
||||
@ -55,7 +100,35 @@ public class BpmOAProjectController {
|
||||
public CommonResult<BpmOAProjectRespVO> getByProcessInstanceId(@RequestParam("processInstanceId") String processInstanceId) {
|
||||
|
||||
BpmOAProjectDO project = projectService.getByProcessInstanceId(processInstanceId);
|
||||
BpmOAProjectRespVO respVO = BeanUtils.toBean(project, BpmOAProjectRespVO.class);
|
||||
|
||||
return success(BeanUtils.toBean(project, BpmOAProjectRespVO.class));
|
||||
if (respVO != null) {
|
||||
|
||||
// 获取项目中所有部门编号列表
|
||||
Set<Long> deptIds = respVO.getParticipationDept() == null ? new HashSet<>() : respVO.getParticipationDept();
|
||||
deptIds.add(respVO.getResponsibleDept());
|
||||
|
||||
// 获取所有用户信息
|
||||
AdminUserRespDTO userRespDTO = userApi.getUser(respVO.getDirectorUserId()).getCheckedData();
|
||||
// 获取所有部门信息
|
||||
List<DeptRespDTO> deptDOS = deptApi.getDeptList(deptIds).getCheckedData();
|
||||
Map<Long, DeptRespDTO> deptMap = convertMap(deptDOS, DeptRespDTO::getId);
|
||||
|
||||
// 设置责任人名称
|
||||
respVO.setDirectorUserName(userRespDTO.getNickname());
|
||||
|
||||
// 筛选出不是责任人部门的部门信息
|
||||
List<DeptRespDTO> deptVOs = deptDOS.stream()
|
||||
.filter(dept -> !dept.getId().equals(respVO.getResponsibleDept()))
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 设置责任部门名称
|
||||
respVO.setResponsibleDeptName(deptMap.get(respVO.getResponsibleDept()).getName());
|
||||
// 拼接参与部门名称
|
||||
respVO.setParticipationDeptName(deptVOs.stream().map(DeptRespDTO::getName).collect(Collectors.joining("、")));
|
||||
}
|
||||
|
||||
return success(respVO);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ public class BpmOAProjectCreateReqVO {
|
||||
private LocalDate startDate;
|
||||
|
||||
@Schema(description = "项目结束日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "项目结束日期不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate endDate;
|
||||
|
||||
|
@ -28,31 +28,34 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
public class BpmOAProjectRespVO extends BpmOABaseRespVO {
|
||||
|
||||
@Schema(description = "项目类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "项目类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "项目名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "责任部门", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "责任部门不能为空")
|
||||
private Long responsibleDept;
|
||||
|
||||
@Schema(description = "责任部门名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String responsibleDeptName;
|
||||
|
||||
@Schema(description = "参与部门集合")
|
||||
private Set<Long> participationDept;
|
||||
|
||||
@Schema(description = "参与部门名称集合")
|
||||
private String participationDeptName;
|
||||
|
||||
@Schema(description = "责任人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "责任人不能为空")
|
||||
private Long directorUserId;
|
||||
|
||||
@Schema(description = "责任人名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String directorUserName;
|
||||
|
||||
@Schema(description = "项目开始日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "项目开始日期不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate startDate;
|
||||
|
||||
@Schema(description = "项目结束日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "项目结束日期不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate endDate;
|
||||
|
||||
@ -60,7 +63,6 @@ public class BpmOAProjectRespVO extends BpmOABaseRespVO {
|
||||
private Integer isLongTerm;
|
||||
|
||||
@Schema(description = "项目预算", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "项目预算不能为空")
|
||||
private BigDecimal projectBudget;
|
||||
|
||||
@Schema(description = "项目内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
@ -11,5 +11,5 @@ public class BpmOARefundItems {
|
||||
private Integer rentalItemsType;
|
||||
|
||||
@Schema(description = "归还数量")
|
||||
private Integer number;
|
||||
private Integer rentalNumber;
|
||||
}
|
||||
|
@ -3,9 +3,13 @@ package cn.iocoder.yudao.module.bpm.dal.mysql.oa;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure.BpmOAProcurePageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcureDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* OA 采购申请 Mapper
|
||||
@ -30,4 +34,5 @@ public interface BpmOAProcureMapper extends BaseMapperX<BpmOAProcureDO> {
|
||||
.orderByDesc(BpmOAProcureDO::getId));
|
||||
}
|
||||
|
||||
List<BpmOAProcureDO> selectListByDeptId(@Param("companyDeptId") Long companyDeptId);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.system.api.holiday.HolidayApi;
|
||||
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
||||
import cn.iocoder.yudao.module.system.api.position.PositionApi;
|
||||
import cn.iocoder.yudao.module.system.api.project.ProjectApi;
|
||||
import cn.iocoder.yudao.module.system.api.rental.RentalDepositRecordApi;
|
||||
import cn.iocoder.yudao.module.system.api.rental.RentalOrderApi;
|
||||
import cn.iocoder.yudao.module.system.api.sms.SmsSendApi;
|
||||
@ -31,7 +32,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@EnableFeignClients(clients = {FileApi.class, RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class, NotifyMessageSendApi.class,
|
||||
SubscribeMessageSendApi.class, SocialClientApi.class, UsersExtApi.class, AttendanceApi.class, BankApi.class, ConfigApi.class, PositionApi.class, SupplierApi.class, AssetsApi.class,
|
||||
AssetsTypeApi.class, AssetReceiveApi.class, AttendanceApi.class, AttendanceGroupApi.class, WorkOvertimeApi.class, HolidayApi.class,
|
||||
RentalOrderApi.class, RentalDepositRecordApi.class
|
||||
RentalOrderApi.class, RentalDepositRecordApi.class, ProjectApi.class
|
||||
})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.DeptTypeEnum;
|
||||
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;
|
||||
@ -28,6 +29,8 @@ import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
|
||||
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -38,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -77,6 +81,9 @@ public class BpmOAProcurePayServiceImpl extends BpmOABaseService implements BpmO
|
||||
@Resource
|
||||
private AdminUserApi userApi;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
|
||||
@Resource
|
||||
private BpmHistoryProcessInstanceService historyProcessInstanceService;
|
||||
|
||||
@ -154,15 +161,31 @@ public class BpmOAProcurePayServiceImpl extends BpmOABaseService implements BpmO
|
||||
public List<BpmOAProcureDO> getAvailablePurchaseOrders() {
|
||||
//获取当前登录用户id
|
||||
Long userId = WebFrameworkUtils.getLoginUserId();
|
||||
//查询当前登录用户所在部门所有用户id
|
||||
CommonResult<List<Long>> userIdsResult = adminUserApi.getUserIdsByUserIdGroupByDept(userId);
|
||||
List<Long> userIds = userIdsResult.getData();
|
||||
//根据用户ids 获取所有可用采购单
|
||||
return oaProcureMapper.selectList(new LambdaQueryWrapperX<BpmOAProcureDO>()
|
||||
.in(BpmOAProcureDO::getUserId, userIds)
|
||||
.eq(BpmOAProcureDO::getResult, BpmProcessInstanceResultEnum.APPROVE.getResult())
|
||||
.eq(BpmOAProcureDO::getPayFlag, BpmOAProcureDO.FLAG_FALSE)
|
||||
);
|
||||
// 获取当前登录用的部门信息
|
||||
DeptRespDTO dto = deptApi.getDept(adminUserApi.getUser(userId).getCheckedData().getDeptId()).getCheckedData();
|
||||
|
||||
// 用户属于采购部时
|
||||
if (dto.getType().equals(DeptTypeEnum.PURCHASING_DEPT.getValue())) {
|
||||
|
||||
// 获取用户所在公司信息
|
||||
DeptRespDTO company = deptApi.getUserCompanyDept(userId).getCheckedData();
|
||||
|
||||
// 查询当前用户所在公司下,所有部门可用的采购单
|
||||
return oaProcureMapper.selectListByDeptId(company.getId());
|
||||
|
||||
}else {
|
||||
|
||||
//查询当前登录用户所在部门下所有用户的信息
|
||||
CommonResult<List<Long>> userIdsResult = adminUserApi.getUserIdsByUserIdGroupByDept(userId);
|
||||
List<Long> userIds; userIds = userIdsResult.getData();
|
||||
|
||||
//根据用户ids 获取所有可用采购单
|
||||
return oaProcureMapper.selectList(new LambdaQueryWrapperX<BpmOAProcureDO>()
|
||||
.in(BpmOAProcureDO::getUserId, userIds)
|
||||
.eq(BpmOAProcureDO::getResult, BpmProcessInstanceResultEnum.APPROVE.getResult())
|
||||
.eq(BpmOAProcureDO::getPayFlag, BpmOAProcureDO.FLAG_FALSE)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,8 @@ import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAProjectMapper;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.system.api.project.ProjectApi;
|
||||
import cn.iocoder.yudao.module.system.api.project.dto.ProjectDTO;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -49,6 +51,9 @@ public class BpmOAProjectServiceImpl extends BpmOABaseService implements BpmOAPr
|
||||
@Resource
|
||||
private BpmProcessInstanceService bpmProcessInstanceService;
|
||||
|
||||
@Resource
|
||||
private ProjectApi projectApi;
|
||||
|
||||
@Override
|
||||
public Long createProject(Long userId, BpmOAProjectCreateReqVO createReqVO) {
|
||||
|
||||
@ -84,7 +89,7 @@ public class BpmOAProjectServiceImpl extends BpmOABaseService implements BpmOAPr
|
||||
@Override
|
||||
public void updateProjectResult(String processInstanceId, Long id, Integer result) {
|
||||
|
||||
validateLeaveExists(id);
|
||||
BpmOAProjectDO project = validateLeaveExists(id);
|
||||
//审核通过 (最后节点)
|
||||
if (BpmProcessInstanceResultEnum.APPROVE.getResult().equals(result)) {
|
||||
|
||||
@ -92,16 +97,20 @@ public class BpmOAProjectServiceImpl extends BpmOABaseService implements BpmOAPr
|
||||
|
||||
if (instance.isEnded()) {
|
||||
|
||||
// 同步创建 项目
|
||||
projectApi.create(BeanUtils.toBean(project, ProjectDTO.class).setStatus(1));
|
||||
}
|
||||
}
|
||||
|
||||
projectMapper.updateById(new BpmOAProjectDO().setId(id).setResult(result));
|
||||
}
|
||||
|
||||
private void validateLeaveExists(Long id) {
|
||||
if (projectMapper.selectById(id) == null) {
|
||||
private BpmOAProjectDO validateLeaveExists(Long id) {
|
||||
BpmOAProjectDO project = projectMapper.selectById(id);
|
||||
if (project == null) {
|
||||
throw exception(OA_PROJECT_NOT_EXISTS);
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,7 +93,7 @@ public class BpmOARefundServiceImpl extends BpmOABaseService implements BpmOARef
|
||||
uploadBpmFileProcessInstanceId(processInstanceId,fileItems) ;
|
||||
}
|
||||
|
||||
// 退款申请发起后,变更租赁订单状态为 退款中
|
||||
// 退款申请发起后,变更租赁订单状态为 退款申请中
|
||||
rentalOrderApi.updateOrder(new RentalOrderDTO()
|
||||
.setOrderNo(refund.getOrderNo())
|
||||
.setStatus(2));
|
||||
@ -131,6 +131,18 @@ public class BpmOARefundServiceImpl extends BpmOABaseService implements BpmOARef
|
||||
}
|
||||
}
|
||||
|
||||
// -- 自己取消
|
||||
// -- 审核拒绝
|
||||
if (BpmProcessInstanceResultEnum.REJECT.getResult().equals(result)
|
||||
|| BpmProcessInstanceResultEnum.CANCEL.getResult().equals(result)
|
||||
|| BpmProcessInstanceResultEnum.BACK.getResult().equals(result)) {
|
||||
|
||||
// 变更租赁订单状态 为租借中
|
||||
rentalOrderApi.updateOrder(new RentalOrderDTO()
|
||||
.setOrderNo(refundDO.getOrderNo())
|
||||
.setStatus(1));
|
||||
}
|
||||
|
||||
refundMapper.updateById(new BpmOARefundDO().setId(id).setResult(result));
|
||||
}
|
||||
|
||||
|
@ -9,4 +9,25 @@
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
<select id="selectListByDeptId" resultType="cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcureDO">
|
||||
SELECT
|
||||
a.*
|
||||
FROM
|
||||
bpm_oa_procure a
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
u.id AS id
|
||||
FROM
|
||||
system_users u, system_dept d
|
||||
WHERE
|
||||
d.id = u.dept_id
|
||||
AND d.flag LIKE CONCAT('%', #{companyDeptId}, '%')
|
||||
AND u.deleted = 0
|
||||
AND d.deleted = 0
|
||||
) uu ON a.user_id = uu.id
|
||||
WHERE
|
||||
a.result = 2
|
||||
AND a.pay_flag = 0
|
||||
AND a.deleted = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -19,6 +19,9 @@ public class DeptRespDTO {
|
||||
@Schema(description = "父部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "部门类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "部门层级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer level;
|
||||
|
||||
|
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.system.api.project;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.system.api.position.dto.PositionDTO;
|
||||
import cn.iocoder.yudao.module.system.api.project.dto.ProjectDTO;
|
||||
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 项目")
|
||||
public interface ProjectApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/project";
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "创建项目")
|
||||
CommonResult<Long> create(@RequestBody ProjectDTO createReqVO);
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package cn.iocoder.yudao.module.system.api.project.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 项目管理新增/修改 Request VO")
|
||||
@Data
|
||||
public class ProjectDTO {
|
||||
|
||||
@Schema(description = "项目管理表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "项目编号")
|
||||
private String projectNo;
|
||||
|
||||
@Schema(description = "项目类型 | 字典值参考system_project_type", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "项目类型 | 字典值参考system_project_type不能为空")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "项目名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "责任部门", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "责任部门不能为空")
|
||||
private Long responsibleDept;
|
||||
|
||||
@Schema(description = "参与部门集合", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "参与部门集合不能为空")
|
||||
private Set<Long> participationDept;
|
||||
|
||||
@Schema(description = "责任人用户编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "责任人用户编号不能为空")
|
||||
private Long directorUserId;
|
||||
|
||||
@Schema(description = "项目开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "项目开始时间不能为空")
|
||||
private LocalDate startDate;
|
||||
|
||||
@Schema(description = "项目结束时间")
|
||||
private LocalDate endDate;
|
||||
|
||||
@Schema(description = "是否长期 | 0否 1是")
|
||||
private Integer isLongTerm;
|
||||
|
||||
@Schema(description = "项目预算")
|
||||
private Integer projectBudget;
|
||||
|
||||
@Schema(description = "项目内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "项目内容不能为空")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "项目人员用户编号集合")
|
||||
private Set<Long> staff;
|
||||
|
||||
@Schema(description = "项目额外属性")
|
||||
private Map<String, Object> dynamicAttribute;
|
||||
|
||||
@Schema(description = "项目状态 | 1 进行中 2已完成", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "项目状态 | 1 进行中 2已完成不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.system.api.project;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.api.project.dto.ProjectDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.project.vo.ProjectSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.service.project.ProjectService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class ProjectApiImpl implements ProjectApi {
|
||||
|
||||
@Resource
|
||||
private ProjectService projectService;
|
||||
|
||||
@Override
|
||||
public CommonResult<Long> create(ProjectDTO createReqVO) {
|
||||
return success(projectService.createProject(BeanUtils.toBean(createReqVO, ProjectSaveReqVO.class)));
|
||||
}
|
||||
}
|
@ -21,8 +21,8 @@ public class DeptRespVO {
|
||||
@Schema(description = "父部门 ID", example = "1024")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "机构类型 | 0公司 1部门", example = "0")
|
||||
private Integer type;
|
||||
@Schema(description = "机构类型 | 字典值参考 system_dept_type", example = "0")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer sort;
|
||||
|
@ -28,8 +28,8 @@ public class DeptSaveReqVO {
|
||||
@Schema(description = "父部门 ID", example = "1024")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "机构类型 | 0公司 1部门", example = "0")
|
||||
private Integer type;
|
||||
@Schema(description = "机构类型 | 字典值参考 system_dept_type", example = "0")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
|
@ -157,7 +157,13 @@ public class ProjectController {
|
||||
// 设置责任人名称
|
||||
item.setDirectorUserName(userMap.get(item.getDirectorUserId()).getNickname());
|
||||
// 拼接项目人员名称
|
||||
item.setStaffName(userVOs.stream().map(AdminUserDO::getNickname).collect(Collectors.joining("、")));
|
||||
if (item.getStaff() != null) {
|
||||
item.setStaffName(userVOs.stream()
|
||||
.filter(user -> item.getStaff().contains(user.getId()))
|
||||
.map(AdminUserDO::getNickname)
|
||||
.collect(Collectors.joining("、")));
|
||||
|
||||
}
|
||||
|
||||
// 筛选出不是责任人部门的部门信息
|
||||
List<DeptDO> deptVOs = deptDOS.stream()
|
||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.customer.RentalCustomerPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.customer.RentalCustomerRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.customer.RentalCustomerSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.itemsrecord.RentalItemsCountReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.itemsrecord.RentalItemsRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.itemsrecord.RentalItemsRecordRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.itemsrecord.RentalItemsRecordSaveReqVO;
|
||||
@ -66,6 +67,15 @@ public class RentalItemsRecordController {
|
||||
return success(BeanUtils.toBean(rentalItemsRecordService.getRentalItemsRecord(id), RentalItemsRecordRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get-count")
|
||||
@Operation(summary = "获取指定订单剩余租赁物品数量")
|
||||
@Parameter(name = "orderNo", description = "订单编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('system:rental-items:query')")
|
||||
public CommonResult<List<RentalItemsCountReqVO>> getRentalItemsRecord(@RequestParam("orderNo") String orderNo) {
|
||||
|
||||
return success(rentalItemsRecordService.getRentalItemsCount(orderNo, false));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得租赁物品记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:rental-items:query')")
|
||||
|
@ -42,9 +42,9 @@ public class DeptDO extends TenantBaseDO {
|
||||
*/
|
||||
private Long parentId;
|
||||
/**
|
||||
* 机构类型 | 0公司 1部门
|
||||
* 机构类型 | 字典值参考 system_dept_type
|
||||
*/
|
||||
private Integer type;
|
||||
private String type;
|
||||
/**
|
||||
* 部门层级
|
||||
*/
|
||||
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqV
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -60,4 +61,7 @@ public interface DeptMapper extends BaseMapperX<DeptDO> {
|
||||
|
||||
return selectJoinOne(DeptDO.class, query);
|
||||
}
|
||||
|
||||
List<DeptDO> selectCompany(@Param("flag") String flag,
|
||||
@Param("type") String type);
|
||||
}
|
||||
|
@ -25,5 +25,6 @@ public interface RentalItemsRecordMapper extends BaseMapperX<RentalItemsRecordDO
|
||||
.orderByDesc(RentalItemsRecordDO::getCreateTime));
|
||||
}
|
||||
|
||||
List<RentalItemsCountReqVO> selectRentalItemsCount(@Param("orderNo") String orderNo);
|
||||
List<RentalItemsCountReqVO> selectRentalItemsCount(@Param("orderNo") String orderNo,
|
||||
@Param("isUpdate") Boolean isUpdate);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.DeptTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
@ -325,7 +326,7 @@ public class DeptServiceImpl implements DeptService {
|
||||
public List<DeptDO> getCompanyDept() {
|
||||
|
||||
return deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>()
|
||||
.eq(DeptDO::getType, 0)
|
||||
.eq(DeptDO::getType, DeptTypeEnum.COMPANY.getValue())
|
||||
.eq(DeptDO::getVirtuallyStatus, 0)
|
||||
.eq(DeptDO::getStatus, CommonStatusEnum.ENABLE.getStatus()));
|
||||
}
|
||||
@ -361,9 +362,7 @@ public class DeptServiceImpl implements DeptService {
|
||||
}
|
||||
|
||||
// 根据所在部门信息获取 所在公司信息
|
||||
List<DeptDO> companyDeptList = deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>()
|
||||
.likeIfPresent(DeptDO::getFlag, deptDo.getFlag())
|
||||
.eq(DeptDO::getType, 0));
|
||||
List<DeptDO> companyDeptList = deptMapper.selectCompany(deptDo.getFlag(), DeptTypeEnum.COMPANY.getValue());
|
||||
|
||||
if (CollectionUtil.isEmpty(companyDeptList)) {
|
||||
return new DeptDO();
|
||||
|
@ -56,5 +56,5 @@ public interface RentalItemsRecordService {
|
||||
* @param orderNo 订单编号
|
||||
* @return 剩余数量
|
||||
*/
|
||||
List<RentalItemsCountReqVO> getRentalItemsCount(String orderNo);
|
||||
List<RentalItemsCountReqVO> getRentalItemsCount(String orderNo, Boolean isUpdate);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class RentalItemsRecordServiceImpl implements RentalItemsRecordService{
|
||||
public Long createRentalItemsRecord(RentalItemsRecordSaveReqVO createReqVO) {
|
||||
|
||||
// 获取订单剩余租借数量 使用悲观锁
|
||||
List<RentalItemsCountReqVO> reqVOS = getRentalItemsCount(createReqVO.getOrderNo());
|
||||
List<RentalItemsCountReqVO> reqVOS = getRentalItemsCount(createReqVO.getOrderNo(), true);
|
||||
Map<Integer, RentalItemsCountReqVO> countMap = convertMap(reqVOS, RentalItemsCountReqVO::getRentalItemsType);
|
||||
|
||||
// 判断租借类型为归还时,检验归还数量是否大于剩余数量
|
||||
@ -58,7 +58,7 @@ public class RentalItemsRecordServiceImpl implements RentalItemsRecordService{
|
||||
public void createRentalItemsRecordBath(List<RentalItemsRecordSaveReqVO> createReqVO) {
|
||||
|
||||
// 获取订单剩余租借数量 使用悲观锁
|
||||
List<RentalItemsCountReqVO> reqVOS = getRentalItemsCount(createReqVO.get(0).getOrderNo());
|
||||
List<RentalItemsCountReqVO> reqVOS = getRentalItemsCount(createReqVO.get(0).getOrderNo(), true);
|
||||
Map<Integer, RentalItemsCountReqVO> countMap = convertMap(reqVOS, RentalItemsCountReqVO::getRentalItemsType);
|
||||
|
||||
for (RentalItemsRecordSaveReqVO vo : createReqVO) {
|
||||
@ -98,9 +98,9 @@ public class RentalItemsRecordServiceImpl implements RentalItemsRecordService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RentalItemsCountReqVO> getRentalItemsCount(String orderNo) {
|
||||
public List<RentalItemsCountReqVO> getRentalItemsCount(String orderNo, Boolean isUpdate) {
|
||||
|
||||
return rentalItemsRecordMapper.selectRentalItemsCount(orderNo);
|
||||
return rentalItemsRecordMapper.selectRentalItemsCount(orderNo, isUpdate);
|
||||
}
|
||||
|
||||
private void validateRentalItemsRecordExists(Long id) {
|
||||
|
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
<select id="selectCompany" resultType="cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
system_dept
|
||||
WHERE
|
||||
#{flag} LIKE CONCAT('%', flag, '%')
|
||||
AND type = #{type}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
</mapper>
|
@ -19,6 +19,8 @@
|
||||
WHERE
|
||||
order_no = #{orderNo}
|
||||
AND deleted = 0
|
||||
FOR UPDATE
|
||||
<if test="isUpdate">
|
||||
FOR UPDATE
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user