采购清单流程
This commit is contained in:
parent
9476a9c243
commit
b2579d1688
@ -37,4 +37,6 @@ public interface GlobalErrorCodeConstants {
|
||||
|
||||
ErrorCode UNKNOWN = new ErrorCode(999, "未知错误");
|
||||
|
||||
|
||||
ErrorCode OA_PROCURE_NOT_EXISTS = new ErrorCode(10001, "OA 采购申请不存在");
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
### 请求 /bpm/oa/leave/create 接口 => 成功
|
||||
POST {{baseUrl}}/bpm/oa/leave/create
|
||||
Content-Type: application/json
|
||||
tenant-id: 1
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"startTime": "2022-03-01",
|
||||
"endTime": "2022-03-05",
|
||||
"type": 1,
|
||||
"reason": "我要请假啦啦啦!"
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure.BpmOAProcureRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure.BpmOAProcureSaveReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.convert.oa.BpmOAProcureConvert;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcureDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOaProcureService;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - OA 采购申请")
|
||||
@RestController
|
||||
@RequestMapping("/bpm/oa-procure")
|
||||
@Validated
|
||||
public class BpmOAProcureController {
|
||||
|
||||
@Resource
|
||||
private BpmOaProcureService bpmOaProcureService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建OA 采购申请")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:oa-procure:create')")
|
||||
public CommonResult<Long> createOaProcure(@Valid @RequestBody BpmOAProcureSaveReqVO createReqVO) {
|
||||
return success(bpmOaProcureService.createOaProcure(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新OA 采购申请")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:oa-procure:update')")
|
||||
public CommonResult<Boolean> updateOaProcure(@Valid @RequestBody BpmOAProcureSaveReqVO updateReqVO) {
|
||||
bpmOaProcureService.updateOaProcure(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除OA 采购申请")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('bpm:oa-procure:delete')")
|
||||
public CommonResult<Boolean> deleteOaProcure(@RequestParam("id") Long id) {
|
||||
bpmOaProcureService.deleteOaProcure(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得OA 采购申请")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:oa-procure:query')")
|
||||
public CommonResult<BpmOAProcureRespVO> getOaProcure(@RequestParam("id") Long id) {
|
||||
BpmOAProcureDO oaProcure = bpmOaProcureService.getOaProcure(id);
|
||||
return success(BpmOAProcureConvert.INSTANCE.convert(oaProcure));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.ProcureDetail;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.Reimbursement;
|
||||
import lombok.*;
|
||||
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 java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - OA 采购申请分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmOAProcurePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "申请人的用户编号", example = "26976")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "申请事由", example = "不喜欢")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "采购类型 (根据字典的来)", example = "2")
|
||||
private Integer procureType;
|
||||
|
||||
@Schema(description = "期望交付日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] expectedDeliveryDate;
|
||||
|
||||
@Schema(description = "采购明细数据JSON")
|
||||
private List<ProcureDetail> procureDetailJson;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remarks;
|
||||
|
||||
@Schema(description = "采购总金额")
|
||||
private String totalMoney;
|
||||
|
||||
@Schema(description = "采购总金额大写")
|
||||
private String totalMoneyChinese;
|
||||
|
||||
@Schema(description = "附件信息")
|
||||
private String fileItems;
|
||||
|
||||
@Schema(description = "报销结果")
|
||||
private Integer result;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "15852")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.ProcureDetail;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
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;
|
||||
|
||||
@Schema(description = "管理后台 - OA 采购申请 Response VO")
|
||||
@Data
|
||||
public class BpmOAProcureRespVO {
|
||||
|
||||
@Schema(description = "报销表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25971")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "申请人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26976")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "申请事由", example = "不喜欢")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "采购类型 (根据字典的来)", example = "2")
|
||||
private Integer procureType;
|
||||
|
||||
@Schema(description = "期望交付日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime expectedDeliveryDate;
|
||||
|
||||
@Schema(description = "采购明细数据JSON", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<ProcureDetail> procureDetailJson;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remarks;
|
||||
|
||||
@Schema(description = "采购总金额")
|
||||
private String totalMoney;
|
||||
|
||||
@Schema(description = "采购总金额大写")
|
||||
private String totalMoneyChinese;
|
||||
|
||||
@Schema(description = "附件信息")
|
||||
private List<UploadUserFile> fileItems;
|
||||
|
||||
@Schema(description = "报销结果", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer result;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "15852")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.ProcureDetail;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
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;
|
||||
|
||||
@Schema(description = "管理后台 - OA 采购申请新增/修改 Request VO")
|
||||
@Data
|
||||
public class BpmOAProcureSaveReqVO {
|
||||
|
||||
@Schema(description = "报销表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25971")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "申请人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26976")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "申请事由", example = "不喜欢")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "采购类型 (根据字典的来)", example = "2")
|
||||
private Integer procureType;
|
||||
|
||||
@Schema(description = "期望交付日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime expectedDeliveryDate;
|
||||
|
||||
@Schema(description = "采购明细数据JSON", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "采购明细数据JSON不能为空")
|
||||
private List<ProcureDetail> procureDetailJson;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remarks;
|
||||
|
||||
@Schema(description = "采购总金额")
|
||||
private String totalMoney;
|
||||
|
||||
@Schema(description = "采购总金额大写")
|
||||
private String totalMoneyChinese;
|
||||
|
||||
@Schema(description = "报销结果")
|
||||
private Integer result;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "15852")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "上传文件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<UploadUserFile> fileItems;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ProcureDetail {
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
@Schema(description = "规格")
|
||||
private String sku;
|
||||
@Schema(description = "数量")
|
||||
private String quantity;
|
||||
@Schema(description = "单位")
|
||||
private String unit;
|
||||
@Schema(description = "价格(单价)")
|
||||
private String amount;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.bpm.convert.oa;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure.BpmOAProcureRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure.BpmOAProcureSaveReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcureDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReimbursementDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 报销申请 Convert
|
||||
*
|
||||
* @author yj
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmOAProcureConvert {
|
||||
|
||||
BpmOAProcureConvert INSTANCE = Mappers.getMapper(BpmOAProcureConvert.class);
|
||||
|
||||
BpmOAProcureDO convert(BpmOAProcureSaveReqVO bean);
|
||||
|
||||
BpmOAProcureRespVO convert(BpmOAProcureDO bean);
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.ProcureDetail;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* OA 采购申请 DO
|
||||
*
|
||||
* @author 姚君
|
||||
*/
|
||||
@TableName(value ="bpm_oa_procure", autoResultMap = true)
|
||||
@KeySequence("bpm_oa_procure_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BpmOAProcureDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 报销表单主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 申请人的用户编号
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 申请事由
|
||||
*/
|
||||
private String reason;
|
||||
/**
|
||||
* 采购类型 (根据字典的来)
|
||||
*/
|
||||
private Integer procureType;
|
||||
/**
|
||||
* 期望交付日期
|
||||
*/
|
||||
private LocalDateTime expectedDeliveryDate;
|
||||
/**
|
||||
* 采购明细数据JSON
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<ProcureDetail> procureDetailJson;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
/**
|
||||
* 采购总金额
|
||||
*/
|
||||
private String totalMoney;
|
||||
/**
|
||||
* 采购总金额大写
|
||||
*/
|
||||
private String totalMoneyChinese;
|
||||
/**
|
||||
* 附件信息
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<UploadUserFile> fileItems;
|
||||
/**
|
||||
* 采购结果
|
||||
*/
|
||||
private Integer result;
|
||||
/**
|
||||
* 流程实例的编号
|
||||
*/
|
||||
private String processInstanceId;
|
||||
|
||||
}
|
@ -79,6 +79,6 @@ public class BpmOAReimbursementDO extends BaseDO {
|
||||
* 附件基本信息
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<UploadUserFile> fileItems ;
|
||||
private List<UploadUserFile> fileItems;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
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.module.bpm.controller.admin.oa.vo.procure.BpmOAProcurePageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcureDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* OA 采购申请 Mapper
|
||||
*
|
||||
* @author 姚君
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmOaProcureMapper extends BaseMapperX<BpmOAProcureDO> {
|
||||
|
||||
default PageResult<BpmOAProcureDO> selectPage(BpmOAProcurePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BpmOAProcureDO>()
|
||||
.eqIfPresent(BpmOAProcureDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(BpmOAProcureDO::getReason, reqVO.getReason())
|
||||
.eqIfPresent(BpmOAProcureDO::getProcureType, reqVO.getProcureType())
|
||||
.betweenIfPresent(BpmOAProcureDO::getExpectedDeliveryDate, reqVO.getExpectedDeliveryDate())
|
||||
.eqIfPresent(BpmOAProcureDO::getProcureDetailJson, reqVO.getProcureDetailJson())
|
||||
.eqIfPresent(BpmOAProcureDO::getRemarks, reqVO.getRemarks())
|
||||
.eqIfPresent(BpmOAProcureDO::getFileItems, reqVO.getFileItems())
|
||||
.eqIfPresent(BpmOAProcureDO::getResult, reqVO.getResult())
|
||||
.eqIfPresent(BpmOAProcureDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.betweenIfPresent(BpmOAProcureDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(BpmOAProcureDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure.BpmOAProcurePageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure.BpmOAProcureSaveReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcureDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* OA 采购申请 Service 接口
|
||||
*
|
||||
* @author 姚君
|
||||
*/
|
||||
public interface BpmOaProcureService {
|
||||
|
||||
/**
|
||||
* 创建OA 采购申请
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createOaProcure(@Valid BpmOAProcureSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新OA 采购申请
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateOaProcure(@Valid BpmOAProcureSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除OA 采购申请
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteOaProcure(Long id);
|
||||
|
||||
/**
|
||||
* 获得OA 采购申请
|
||||
*
|
||||
* @param id 编号
|
||||
* @return OA 采购申请
|
||||
*/
|
||||
BpmOAProcureDO getOaProcure(Long id);
|
||||
|
||||
/**
|
||||
* 获得OA 采购申请分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return OA 采购申请分页
|
||||
*/
|
||||
PageResult<BpmOAProcureDO> getOaProcurePage(BpmOAProcurePageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||
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.controller.admin.oa.vo.procure.BpmOAProcurePageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procure.BpmOAProcureSaveReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile;
|
||||
import cn.iocoder.yudao.module.bpm.convert.oa.BpmOAProcureConvert;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcureDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOaProcureMapper;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* OA 采购申请 Service 实现类
|
||||
*
|
||||
* @author 姚君
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class BpmOaProcureServiceImpl extends BpmOABaseService implements BpmOaProcureService {
|
||||
|
||||
@Resource
|
||||
private BpmOaProcureMapper bpmOaProcureMapper;
|
||||
@Resource
|
||||
private BpmProcessInstanceApi processInstanceApi;
|
||||
/**
|
||||
* OA 请假对应的流程定义 KEY
|
||||
*/
|
||||
public static final String PROCESS_KEY = "oa_procure";
|
||||
@Override
|
||||
public Long createOaProcure(BpmOAProcureSaveReqVO createReqVO) {
|
||||
Long userId = WebFrameworkUtils.getLoginUserId();
|
||||
// 插入
|
||||
BpmOAProcureDO oaProcure = BpmOAProcureConvert.INSTANCE.convert(createReqVO).setUserId(userId)
|
||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||
bpmOaProcureMapper.insert(oaProcure);
|
||||
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
String processInstanceId = processInstanceApi.createProcessInstance(userId,
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(oaProcure.getId()))).getCheckedData();
|
||||
|
||||
// 将工作流的编号,更新到 OA 采购单中
|
||||
bpmOaProcureMapper.updateById(new BpmOAProcureDO().setId(oaProcure.getId()).setProcessInstanceId(processInstanceId));
|
||||
|
||||
List<UploadUserFile> fileItems = createReqVO.getFileItems() ;
|
||||
//这里的逻辑,如果fileItems不为空,且有数据,那么说明是上传了附件的,则需要更工作流文件表对应的实例Id
|
||||
if (fileItems != null && !fileItems.isEmpty()) {
|
||||
uploadBpmFileProcessInstanceId(processInstanceId,fileItems) ;
|
||||
}
|
||||
return oaProcure.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOaProcure(BpmOAProcureSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateOaProcureExists(updateReqVO.getId());
|
||||
// 更新
|
||||
BpmOAProcureDO updateObj = BeanUtils.toBean(updateReqVO, BpmOAProcureDO.class);
|
||||
bpmOaProcureMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOaProcure(Long id) {
|
||||
// 校验存在
|
||||
validateOaProcureExists(id);
|
||||
// 删除
|
||||
bpmOaProcureMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateOaProcureExists(Long id) {
|
||||
if (bpmOaProcureMapper.selectById(id) == null) {
|
||||
throw exception(GlobalErrorCodeConstants.OA_PROCURE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmOAProcureDO getOaProcure(Long id) {
|
||||
return bpmOaProcureMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BpmOAProcureDO> getOaProcurePage(BpmOAProcurePageReqVO pageReqVO) {
|
||||
return bpmOaProcureMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?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.bpm.dal.mysql.oa.BpmOaProcureMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user