办公用品
This commit is contained in:
parent
dcad4cd75f
commit
de690b7cea
@ -0,0 +1,96 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.controller.admin.bgyp;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.home.controller.admin.bgyp.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.home.dal.dataobject.bgyp.BgypDO;
|
||||||
|
import cn.iocoder.yudao.module.home.service.bgyp.BgypService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 办公用品管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/home/bgyp")
|
||||||
|
@Validated
|
||||||
|
public class BgypController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BgypService bgypService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建办公用品管理")
|
||||||
|
@PreAuthorize("@ss.hasPermission('home:bgyp:create')")
|
||||||
|
public CommonResult<Long> createBgyp(@Valid @RequestBody BgypSaveReqVO createReqVO) {
|
||||||
|
return success(bgypService.createBgyp(getLoginUserId(), createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新办公用品管理")
|
||||||
|
@PreAuthorize("@ss.hasPermission('home:bgyp:update')")
|
||||||
|
public CommonResult<Boolean> updateBgyp(@Valid @RequestBody BgypSaveReqVO updateReqVO) {
|
||||||
|
bgypService.updateBgyp(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除办公用品管理")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('home:bgyp:delete')")
|
||||||
|
public CommonResult<Boolean> deleteBgyp(@RequestParam("id") Long id) {
|
||||||
|
bgypService.deleteBgyp(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得办公用品管理")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('home:bgyp:query')")
|
||||||
|
public CommonResult<BgypRespVO> getBgyp(@RequestParam("id") Long id) {
|
||||||
|
BgypDO bgyp = bgypService.getBgyp(id);
|
||||||
|
return success(BeanUtils.toBean(bgyp, BgypRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得办公用品管理分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('home:bgyp:query')")
|
||||||
|
public CommonResult<PageResult<BgypRespVO>> getBgypPage(@Valid BgypPageReqVO pageReqVO) {
|
||||||
|
PageResult<BgypDO> pageResult = bgypService.getBgypPage(getLoginUserId(), pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, BgypRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出办公用品管理 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('home:bgyp:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportBgypExcel(@Valid BgypPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<BgypDO> list = bgypService.getBgypPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "办公用品管理.xls", "数据", BgypRespVO.class,
|
||||||
|
BeanUtils.toBean(list, BgypRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.controller.admin.bgyp.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 办公用品管理分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class BgypPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "审批状态", example = "2")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "申请人的用户编号", example = "12591")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "申请标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "申请用户名称", example = "王五")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "申请部门名称", example = "李四")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
@Schema(description = "申请部门id", example = "31022")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品名字", example = "张三")
|
||||||
|
private String usageName;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品id", example = "11372")
|
||||||
|
private Integer usageId;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品数量")
|
||||||
|
private Integer usageQuantity;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品分类")
|
||||||
|
private Integer unit;
|
||||||
|
|
||||||
|
@Schema(description = "申请用途")
|
||||||
|
private String usagePurpose;
|
||||||
|
|
||||||
|
@Schema(description = "申请时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] usageDate;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.controller.admin.bgyp.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 办公用品管理 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class BgypRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "审批状态", example = "2")
|
||||||
|
@ExcelProperty("审批状态")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "申请人的用户编号", example = "12591")
|
||||||
|
@ExcelProperty("申请人的用户编号")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "流程实例的编号", example = "13849")
|
||||||
|
@ExcelProperty("流程实例的编号")
|
||||||
|
private String processInstanceId;
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12104")
|
||||||
|
@ExcelProperty("id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "申请标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("申请标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "申请用户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||||
|
@ExcelProperty("申请用户名称")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "申请部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||||
|
@ExcelProperty("申请部门名称")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
@Schema(description = "申请部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31022")
|
||||||
|
@ExcelProperty("申请部门id")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品名字", example = "张三")
|
||||||
|
@ExcelProperty("申请物品名字")
|
||||||
|
private String usageName;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11372")
|
||||||
|
@ExcelProperty(value = "申请物品id", converter = DictConvert.class)
|
||||||
|
@DictFormat("bgyp_usage_name") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||||
|
private Integer usageId;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("申请物品数量")
|
||||||
|
private Integer usageQuantity;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品分类")
|
||||||
|
@ExcelProperty(value = "申请物品分类", converter = DictConvert.class)
|
||||||
|
@DictFormat("bgyp_unit") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||||
|
private Integer unit;
|
||||||
|
|
||||||
|
@Schema(description = "申请用途")
|
||||||
|
@ExcelProperty("申请用途")
|
||||||
|
private String usagePurpose;
|
||||||
|
|
||||||
|
@Schema(description = "申请时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("申请时间")
|
||||||
|
private LocalDateTime usageDate;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.controller.admin.bgyp.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 办公用品管理新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class BgypSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}")
|
||||||
|
private Map<String, List<Long>> startUserSelectAssignees;
|
||||||
|
|
||||||
|
@Schema(description = "审批状态", example = "2")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "申请人的用户编号", example = "12591")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "流程实例的编号", example = "13849")
|
||||||
|
private String processInstanceId;
|
||||||
|
|
||||||
|
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12104")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "申请标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "申请标题不能为空")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "申请用户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||||
|
@NotEmpty(message = "申请用户名称不能为空")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "申请部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||||
|
@NotEmpty(message = "申请部门名称不能为空")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
@Schema(description = "申请部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31022")
|
||||||
|
@NotNull(message = "申请部门id不能为空")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品名字", example = "张三")
|
||||||
|
private String usageName;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11372")
|
||||||
|
@NotNull(message = "申请物品id不能为空")
|
||||||
|
private Integer usageId;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "申请物品数量不能为空")
|
||||||
|
private Integer usageQuantity;
|
||||||
|
|
||||||
|
@Schema(description = "申请物品分类")
|
||||||
|
private Integer unit;
|
||||||
|
|
||||||
|
@Schema(description = "申请用途")
|
||||||
|
private String usagePurpose;
|
||||||
|
|
||||||
|
@Schema(description = "申请时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "申请时间不能为空")
|
||||||
|
private LocalDateTime usageDate;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.dal.dataobject.bgyp;
|
||||||
|
|
||||||
|
import com.sun.xml.bind.v2.TODO;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 办公用品管理 DO
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
@TableName("oa_bgyp")
|
||||||
|
@KeySequence("oa_bgyp_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BgypDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 审批状态
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 申请人的用户编号
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 流程实例的编号
|
||||||
|
*/
|
||||||
|
private String processInstanceId;
|
||||||
|
/**
|
||||||
|
* 申请标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
/**
|
||||||
|
* 申请用户名称
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
/**
|
||||||
|
* 申请部门名称
|
||||||
|
*/
|
||||||
|
private String deptName;
|
||||||
|
/**
|
||||||
|
* 申请部门id
|
||||||
|
*/
|
||||||
|
private Long deptId;
|
||||||
|
/**
|
||||||
|
* 申请物品名字
|
||||||
|
*/
|
||||||
|
private String usageName;
|
||||||
|
/**
|
||||||
|
* 申请物品id
|
||||||
|
*
|
||||||
|
* 枚举 {@link TODO bgyp_usage_name 对应的类}
|
||||||
|
*/
|
||||||
|
private Integer usageId;
|
||||||
|
/**
|
||||||
|
* 申请物品数量
|
||||||
|
*/
|
||||||
|
private Integer usageQuantity;
|
||||||
|
/**
|
||||||
|
* 申请物品分类
|
||||||
|
*
|
||||||
|
* 枚举 {@link TODO bgyp_unit 对应的类}
|
||||||
|
*/
|
||||||
|
private Integer unit;
|
||||||
|
/**
|
||||||
|
* 申请用途
|
||||||
|
*/
|
||||||
|
private String usagePurpose;
|
||||||
|
/**
|
||||||
|
* 申请时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime usageDate;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.dal.mysql.bgyp;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.home.dal.dataobject.bgyp.BgypDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.home.controller.admin.bgyp.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 办公用品管理 Mapper
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface BgypMapper extends BaseMapperX<BgypDO> {
|
||||||
|
|
||||||
|
default PageResult<BgypDO> selectPage(Long userId, BgypPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<BgypDO>()
|
||||||
|
.eqIfPresent(BgypDO::getTitle, reqVO.getTitle())
|
||||||
|
.likeIfPresent(BgypDO::getUserName, reqVO.getUserName())
|
||||||
|
.likeIfPresent(BgypDO::getDeptName, reqVO.getDeptName())
|
||||||
|
.eqIfPresent(BgypDO::getDeptId, reqVO.getDeptId())
|
||||||
|
.likeIfPresent(BgypDO::getUsageName, reqVO.getUsageName())
|
||||||
|
.eqIfPresent(BgypDO::getUsageId, reqVO.getUsageId())
|
||||||
|
.eqIfPresent(BgypDO::getUsageQuantity, reqVO.getUsageQuantity())
|
||||||
|
.eqIfPresent(BgypDO::getUnit, reqVO.getUnit())
|
||||||
|
.eqIfPresent(BgypDO::getUsagePurpose, reqVO.getUsagePurpose())
|
||||||
|
.betweenIfPresent(BgypDO::getUsageDate, reqVO.getUsageDate())
|
||||||
|
.eqIfPresent(BgypDO::getStatus, reqVO.getStatus())
|
||||||
|
.eqIfPresent(BgypDO::getUserId, userId)
|
||||||
|
.betweenIfPresent(BgypDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(BgypDO::getId));
|
||||||
|
}
|
||||||
|
default PageResult<BgypDO> selectPage(BgypPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<BgypDO>()
|
||||||
|
.eqIfPresent(BgypDO::getTitle, reqVO.getTitle())
|
||||||
|
.likeIfPresent(BgypDO::getUserName, reqVO.getUserName())
|
||||||
|
.likeIfPresent(BgypDO::getDeptName, reqVO.getDeptName())
|
||||||
|
.eqIfPresent(BgypDO::getDeptId, reqVO.getDeptId())
|
||||||
|
.likeIfPresent(BgypDO::getUsageName, reqVO.getUsageName())
|
||||||
|
.eqIfPresent(BgypDO::getUsageId, reqVO.getUsageId())
|
||||||
|
.eqIfPresent(BgypDO::getUsageQuantity, reqVO.getUsageQuantity())
|
||||||
|
.eqIfPresent(BgypDO::getUnit, reqVO.getUnit())
|
||||||
|
.eqIfPresent(BgypDO::getUsagePurpose, reqVO.getUsagePurpose())
|
||||||
|
.betweenIfPresent(BgypDO::getUsageDate, reqVO.getUsageDate())
|
||||||
|
.eqIfPresent(BgypDO::getStatus, reqVO.getStatus())
|
||||||
|
.eqIfPresent(BgypDO::getUserId, reqVO.getUserId())
|
||||||
|
.betweenIfPresent(BgypDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(BgypDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.service.bgyp;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.home.controller.admin.bgyp.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.home.dal.dataobject.bgyp.BgypDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 办公用品管理 Service 接口
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
public interface BgypService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建办公用品管理
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createBgyp(@Valid BgypSaveReqVO createReqVO);
|
||||||
|
Long createBgyp(Long userId, @Valid BgypSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新办公用品管理
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateBgyp(@Valid BgypSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除办公用品管理
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteBgyp(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得办公用品管理
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 办公用品管理
|
||||||
|
*/
|
||||||
|
BgypDO getBgyp(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得办公用品管理分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 办公用品管理分页
|
||||||
|
*/
|
||||||
|
PageResult<BgypDO> getBgypPage(BgypPageReqVO pageReqVO);
|
||||||
|
PageResult<BgypDO> getBgypPage(Long userid, BgypPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新请假申请的状态
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @param status 结果
|
||||||
|
*/
|
||||||
|
void updateBgypStatus(Long id, Integer status);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,116 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.service.bgyp;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
|
||||||
|
import cn.iocoder.yudao.module.home.dal.dataobject.clgl.ClglDO;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.home.controller.admin.bgyp.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.home.dal.dataobject.bgyp.BgypDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.home.dal.mysql.bgyp.BgypMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.KNOWLEDGE_NOT_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 办公用品管理 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class BgypServiceImpl implements BgypService {
|
||||||
|
public static final String PROCESS_KEY = "bgyp-001";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BgypMapper bgypMapper;
|
||||||
|
@Resource
|
||||||
|
private BpmProcessInstanceApi processInstanceApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createBgyp(BgypSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
BgypDO bgyp = BeanUtils.toBean(createReqVO, BgypDO.class);
|
||||||
|
bgypMapper.insert(bgyp);
|
||||||
|
// 返回
|
||||||
|
return bgyp.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createBgyp(Long userId, BgypSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
BgypDO bgyp = BeanUtils.toBean(createReqVO, BgypDO.class)
|
||||||
|
.setUserId(userId).setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||||
|
bgypMapper.insert(bgyp);
|
||||||
|
// 发起 BPM 流程
|
||||||
|
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||||
|
String processInstanceId = processInstanceApi.createProcessInstance(userId,
|
||||||
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||||
|
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(bgyp.getId()))
|
||||||
|
.setStartUserSelectAssignees(createReqVO.getStartUserSelectAssignees()));
|
||||||
|
bgypMapper.updateById(new BgypDO().setId(bgyp.getId()).setProcessInstanceId(processInstanceId));
|
||||||
|
// 返回
|
||||||
|
return bgyp.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateBgyp(BgypSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateBgypExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
BgypDO updateObj = BeanUtils.toBean(updateReqVO, BgypDO.class);
|
||||||
|
bgypMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteBgyp(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateBgypExists(id);
|
||||||
|
// 删除
|
||||||
|
bgypMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateBgypExists(Long id) {
|
||||||
|
if (bgypMapper.selectById(id) == null) {
|
||||||
|
throw exception(BGYP_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BgypDO getBgyp(Long id) {
|
||||||
|
return bgypMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<BgypDO> getBgypPage(BgypPageReqVO pageReqVO) {
|
||||||
|
return bgypMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<BgypDO> getBgypPage(Long userId, BgypPageReqVO pageReqVO) {
|
||||||
|
return bgypMapper.selectPage(userId,pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateBgypStatus(Long id, Integer status) {
|
||||||
|
validateLeaveExists(id);
|
||||||
|
bgypMapper.updateById(new BgypDO().setId(id).setStatus(status));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateLeaveExists(Long id) {
|
||||||
|
if (bgypMapper.selectById(id) == null) {
|
||||||
|
throw exception(KNOWLEDGE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.service.bgyp.listener;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent;
|
||||||
|
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener;
|
||||||
|
import cn.iocoder.yudao.module.home.service.bgyp.BgypService;
|
||||||
|
import cn.iocoder.yudao.module.home.service.bgyp.BgypServiceImpl;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class BpmBygpStatusListener extends BpmProcessInstanceStatusEventListener {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BgypService bgypService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getProcessDefinitionKey() {
|
||||||
|
return BgypServiceImpl.PROCESS_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
||||||
|
bgypService.updateBgypStatus(Long.parseLong(event.getBusinessKey()), event.getStatus());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user