From 4dfc6e5f07e20db7e9405d1a002acb2fa6daf4e9 Mon Sep 17 00:00:00 2001 From: chenqp <965586934@qq.com> Date: Sun, 30 Jul 2023 20:31:28 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=E5=8F=91=E7=A5=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=AA=8C=E7=9C=9F=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java index ffd2e5c6..e470891c 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java @@ -86,5 +86,8 @@ public class InvoiceDO extends BaseDO { @TableField(exist = false) private Boolean deleted; - + /** + * 验真状态 + */ + private String status; } From 1580d21d83dba89f9213e6f0f473ffaa642b3e42 Mon Sep 17 00:00:00 2001 From: chenqp <965586934@qq.com> Date: Sun, 30 Jul 2023 21:21:31 +0800 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=E7=94=B3=E8=AF=B7=E5=8D=95?= =?UTF-8?q?=E4=B8=BB=E5=8D=95=E4=BB=A3=E7=A0=81=E4=B8=B4=E6=97=B6=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/bs/enums/ErrorCodeConstants.java | 2 +- .../expenseapply/ExpenseApplyController.java | 99 +++++++ .../expenseapply/vo/ExpenseApplyBaseVO.java | 49 ++++ .../vo/ExpenseApplyCreateReqVO.java | 14 + .../expenseapply/vo/ExpenseApplyExcelVO.java | 70 +++++ .../vo/ExpenseApplyExportReqVO.java | 62 +++++ .../vo/ExpenseApplyPageReqVO.java | 67 +++++ .../expenseapply/vo/ExpenseApplyRespVO.java | 22 ++ .../vo/ExpenseApplyUpdateReqVO.java | 20 ++ .../expenseapply/ExpenseApplyConvert.java | 36 +++ .../expenseapply/ExpenseApplyDO.java | 84 ++++++ .../bs/dal/dataobject/invoice/InvoiceDO.java | 9 +- .../expenseapply/ExpenseApplyMapper.java | 57 ++++ .../bs/dal/mysql/invoice/InvoiceMapper.java | 4 - .../expenseapply/ExpenseApplyService.java | 75 +++++ .../expenseapply/ExpenseApplyServiceImpl.java | 85 ++++++ .../expenseapply/ExpenseApplyMapper.xml | 12 + .../ExpenseApplyServiceImplTest.java | 259 ++++++++++++++++++ 18 files changed, 1013 insertions(+), 13 deletions(-) create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/ExpenseApplyController.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyBaseVO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyCreateReqVO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExcelVO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExportReqVO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyPageReqVO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyRespVO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyUpdateReqVO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseapply/ExpenseApplyConvert.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapply/ExpenseApplyMapper.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/expenseapply/ExpenseApplyMapper.xml create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java diff --git a/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java b/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java index 65726454..69657919 100644 --- a/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java +++ b/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ErrorCodeConstants.java @@ -10,5 +10,5 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; public interface ErrorCodeConstants { ErrorCode INVOICE_NOT_EXISTS = new ErrorCode(200100, "我的发票不存在"); - + ErrorCode EXPENSE_APPLY_NOT_EXISTS = new ErrorCode(200200, "申请单不存在"); } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/ExpenseApplyController.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/ExpenseApplyController.java new file mode 100644 index 00000000..371b5d93 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/ExpenseApplyController.java @@ -0,0 +1,99 @@ +package cn.iocoder.yudao.module.bs.controller.admin.expenseapply; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.*; +import cn.iocoder.yudao.module.bs.convert.expenseapply.ExpenseApplyConvert; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; +import cn.iocoder.yudao.module.bs.service.expenseapply.ExpenseApplyService; +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.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +@Tag(name = "管理后台 - 申请单") +@RestController +@RequestMapping("/bs/expense-apply") +@Validated +public class ExpenseApplyController { + + @Resource + private ExpenseApplyService expenseApplyService; + + @PostMapping("/create") + @Operation(summary = "创建申请单") + @PreAuthorize("@ss.hasPermission('bs:expense-apply:create')") + public CommonResult createExpenseApply(@Valid @RequestBody ExpenseApplyCreateReqVO createReqVO) { + return success(expenseApplyService.createExpenseApply(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新申请单") + @PreAuthorize("@ss.hasPermission('bs:expense-apply:update')") + public CommonResult updateExpenseApply(@Valid @RequestBody ExpenseApplyUpdateReqVO updateReqVO) { + expenseApplyService.updateExpenseApply(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除申请单") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('bs:expense-apply:delete')") + public CommonResult deleteExpenseApply(@RequestParam("id") Long id) { + expenseApplyService.deleteExpenseApply(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得申请单") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('bs:expense-apply:query')") + public CommonResult getExpenseApply(@RequestParam("id") Long id) { + ExpenseApplyDO expenseApply = expenseApplyService.getExpenseApply(id); + return success(ExpenseApplyConvert.INSTANCE.convert(expenseApply)); + } + + @GetMapping("/list") + @Operation(summary = "获得申请单列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('bs:expense-apply:query')") + public CommonResult> getExpenseApplyList(@RequestParam("ids") Collection ids) { + List list = expenseApplyService.getExpenseApplyList(ids); + return success(ExpenseApplyConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得申请单分页") + @PreAuthorize("@ss.hasPermission('bs:expense-apply:query')") + public CommonResult> getExpenseApplyPage(@Valid ExpenseApplyPageReqVO pageVO) { + PageResult pageResult = expenseApplyService.getExpenseApplyPage(pageVO); + return success(ExpenseApplyConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出申请单 Excel") + @PreAuthorize("@ss.hasPermission('bs:expense-apply:export')") + @OperateLog(type = EXPORT) + public void exportExpenseApplyExcel(@Valid ExpenseApplyExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = expenseApplyService.getExpenseApplyList(exportReqVO); + // 导出 Excel + List datas = ExpenseApplyConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "申请单.xls", "数据", ExpenseApplyExcelVO.class, datas); + } + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyBaseVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyBaseVO.java new file mode 100644 index 00000000..12e60d1c --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyBaseVO.java @@ -0,0 +1,49 @@ +package cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 申请单 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ExpenseApplyBaseVO { + + @Schema(description = "申请类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @NotNull(message = "申请类型不能为空") + private String billType; + + @Schema(description = "申请者ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9227") + @NotNull(message = "申请者ID不能为空") + private Long userId; + + @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") + @NotNull(message = "用户昵称不能为空") + private String nickname; + + @Schema(description = "部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32343") + @NotNull(message = "部门ID不能为空") + private Long deptId; + + @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") + @NotNull(message = "部门名称不能为空") + private String deptName; + + @Schema(description = "项目名称", example = "芋艿") + private String projectName; + + @Schema(description = "申请事由", example = "不香") + private String reason; + + @Schema(description = "备注", example = "你猜") + private String remark; + + @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "附件不能为空") + private String files; + + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyCreateReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyCreateReqVO.java new file mode 100644 index 00000000..a26d6ffd --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 申请单创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ExpenseApplyCreateReqVO extends ExpenseApplyBaseVO { + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExcelVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExcelVO.java new file mode 100644 index 00000000..234e2131 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExcelVO.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + + +/** + * 申请单 Excel VO + * + * @author 芋道源码 + */ +@Data +public class ExpenseApplyExcelVO { + + @ExcelProperty("id") + private Long id; + + @ExcelProperty(value = "申请类型", converter = DictConvert.class) + @DictFormat("bs_bill_type") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private String billType; + + @ExcelProperty("申请单号") + private String applyNo; + + @ExcelProperty("申请者ID") + private Long userId; + + @ExcelProperty("用户昵称") + private String nickname; + + @ExcelProperty("部门ID") + private Long deptId; + + @ExcelProperty("部门名称") + private String deptName; + + @ExcelProperty("项目名称") + private String projectName; + + @ExcelProperty("申请事由") + private String reason; + + @ExcelProperty("申请金额") + private BigDecimal amount; + + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat("bs_expense_apply_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private String status; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("附件") + private String files; + + @ExcelProperty("创建者") + private String createBy; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("更新者") + private String updateBy; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExportReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExportReqVO.java new file mode 100644 index 00000000..50513519 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExportReqVO.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 申请单 Excel 导出 Request VO,参数和 ExpenseApplyPageReqVO 是一致的") +@Data +public class ExpenseApplyExportReqVO { + + @Schema(description = "申请类型", example = "2") + private String billType; + + @Schema(description = "申请单号") + private String applyNo; + + @Schema(description = "申请者ID", example = "9227") + private Long userId; + + @Schema(description = "用户昵称", example = "张三") + private String nickname; + + @Schema(description = "部门ID", example = "32343") + private Long deptId; + + @Schema(description = "部门名称", example = "王五") + private String deptName; + + @Schema(description = "项目名称", example = "芋艿") + private String projectName; + + @Schema(description = "申请事由", example = "不香") + private String reason; + + @Schema(description = "申请金额") + private BigDecimal amount; + + @Schema(description = "状态", example = "2") + private String status; + + @Schema(description = "备注", example = "你猜") + private String remark; + + @Schema(description = "附件") + private String files; + + @Schema(description = "创建者") + private String createBy; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "更新者") + private String updateBy; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyPageReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyPageReqVO.java new file mode 100644 index 00000000..b88f555e --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyPageReqVO.java @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +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 ExpenseApplyPageReqVO extends PageParam { + + @Schema(description = "申请类型", example = "2") + private String billType; + + @Schema(description = "申请单号") + private String applyNo; + + @Schema(description = "申请者ID", example = "9227") + private Long userId; + + @Schema(description = "用户昵称", example = "张三") + private String nickname; + + @Schema(description = "部门ID", example = "32343") + private Long deptId; + + @Schema(description = "部门名称", example = "王五") + private String deptName; + + @Schema(description = "项目名称", example = "芋艿") + private String projectName; + + @Schema(description = "申请事由", example = "不香") + private String reason; + + @Schema(description = "申请金额") + private BigDecimal amount; + + @Schema(description = "状态", example = "2") + private String status; + + @Schema(description = "备注", example = "你猜") + private String remark; + + @Schema(description = "附件") + private String files; + + @Schema(description = "创建者") + private String createBy; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "更新者") + private String updateBy; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyRespVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyRespVO.java new file mode 100644 index 00000000..03f65991 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyRespVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 申请单 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ExpenseApplyRespVO extends ExpenseApplyBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14225") + private Long id; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyUpdateReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyUpdateReqVO.java new file mode 100644 index 00000000..6619f3dc --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyUpdateReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 申请单更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ExpenseApplyUpdateReqVO extends ExpenseApplyBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14225") + @NotNull(message = "id不能为空") + private Long id; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseapply/ExpenseApplyConvert.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseapply/ExpenseApplyConvert.java new file mode 100644 index 00000000..4ad58b48 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseapply/ExpenseApplyConvert.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.bs.convert.expenseapply; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExcelVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyRespVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 申请单 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface ExpenseApplyConvert { + + ExpenseApplyConvert INSTANCE = Mappers.getMapper(ExpenseApplyConvert.class); + + ExpenseApplyDO convert(ExpenseApplyCreateReqVO bean); + + ExpenseApplyDO convert(ExpenseApplyUpdateReqVO bean); + + ExpenseApplyRespVO convert(ExpenseApplyDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java new file mode 100644 index 00000000..85fa6ce2 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java @@ -0,0 +1,84 @@ +package cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.math.BigDecimal; + +/** + * 申请单 DO + * + * @author 芋道源码 + */ +@TableName(value = "bs_expense_apply", autoResultMap = true) +@KeySequence("bs_expense_apply_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExpenseApplyDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 申请类型 + * + * 枚举 {@link TODO bs_bill_type 对应的类} + */ + private String billType; + /** + * 申请单号 + */ + private String applyNo; + /** + * 申请者ID + */ + private Long userId; + /** + * 用户昵称 + */ + private String nickname; + /** + * 部门ID + */ + private Long deptId; + /** + * 部门名称 + */ + private String deptName; + /** + * 项目名称 + */ + private String projectName; + /** + * 申请事由 + */ + private String reason; + /** + * 申请金额 + */ + private BigDecimal amount; + /** + * 状态 + * + * 枚举 {@link TODO bs_expense_apply_status 对应的类} + */ + private String status; + /** + * 备注 + */ + private String remark; + /** + * 附件 + */ + private String files; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java index e470891c..9ed1c5af 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java @@ -31,14 +31,7 @@ public class InvoiceDO extends BaseDO { * 附件 */ private String files; - /** - * 创建者 - */ - private String createBy; - /** - * 更新者 - */ - private String updateBy; + /** * 发票类型 */ diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapply/ExpenseApplyMapper.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapply/ExpenseApplyMapper.java new file mode 100644 index 00000000..7b1fa6ab --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapply/ExpenseApplyMapper.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.bs.dal.mysql.expenseapply; + +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.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyPageReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 申请单 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface ExpenseApplyMapper extends BaseMapperX { + + default PageResult selectPage(ExpenseApplyPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(ExpenseApplyDO::getBillType, reqVO.getBillType()) + .eqIfPresent(ExpenseApplyDO::getApplyNo, reqVO.getApplyNo()) + .eqIfPresent(ExpenseApplyDO::getUserId, reqVO.getUserId()) + .likeIfPresent(ExpenseApplyDO::getNickname, reqVO.getNickname()) + .eqIfPresent(ExpenseApplyDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(ExpenseApplyDO::getDeptName, reqVO.getDeptName()) + .likeIfPresent(ExpenseApplyDO::getProjectName, reqVO.getProjectName()) + .eqIfPresent(ExpenseApplyDO::getReason, reqVO.getReason()) + .eqIfPresent(ExpenseApplyDO::getAmount, reqVO.getAmount()) + .eqIfPresent(ExpenseApplyDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ExpenseApplyDO::getRemark, reqVO.getRemark()) + .eqIfPresent(ExpenseApplyDO::getFiles, reqVO.getFiles()) + .betweenIfPresent(ExpenseApplyDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ExpenseApplyDO::getId)); + } + + default List selectList(ExpenseApplyExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ExpenseApplyDO::getBillType, reqVO.getBillType()) + .eqIfPresent(ExpenseApplyDO::getApplyNo, reqVO.getApplyNo()) + .eqIfPresent(ExpenseApplyDO::getUserId, reqVO.getUserId()) + .likeIfPresent(ExpenseApplyDO::getNickname, reqVO.getNickname()) + .eqIfPresent(ExpenseApplyDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(ExpenseApplyDO::getDeptName, reqVO.getDeptName()) + .likeIfPresent(ExpenseApplyDO::getProjectName, reqVO.getProjectName()) + .eqIfPresent(ExpenseApplyDO::getReason, reqVO.getReason()) + .eqIfPresent(ExpenseApplyDO::getAmount, reqVO.getAmount()) + .eqIfPresent(ExpenseApplyDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ExpenseApplyDO::getRemark, reqVO.getRemark()) + .eqIfPresent(ExpenseApplyDO::getFiles, reqVO.getFiles()) + .betweenIfPresent(ExpenseApplyDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ExpenseApplyDO::getId)); + } + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/invoice/InvoiceMapper.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/invoice/InvoiceMapper.java index c4633ac7..26506c25 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/invoice/InvoiceMapper.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/invoice/InvoiceMapper.java @@ -21,9 +21,7 @@ public interface InvoiceMapper extends BaseMapperX { default PageResult selectPage(InvoicePageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(InvoiceDO::getFiles, reqVO.getFiles()) - .eqIfPresent(InvoiceDO::getCreateBy, reqVO.getCreateBy()) .betweenIfPresent(InvoiceDO::getCreateTime, reqVO.getCreateTime()) - .eqIfPresent(InvoiceDO::getUpdateBy, reqVO.getUpdateBy()) .eqIfPresent(InvoiceDO::getInvoiceType, reqVO.getInvoiceType()) .eqIfPresent(InvoiceDO::getInvoiceCode, reqVO.getInvoiceCode()) .eqIfPresent(InvoiceDO::getInvoiceNum, reqVO.getInvoiceNum()) @@ -41,9 +39,7 @@ public interface InvoiceMapper extends BaseMapperX { default List selectList(InvoiceExportReqVO reqVO) { return selectList(new LambdaQueryWrapperX() .eqIfPresent(InvoiceDO::getFiles, reqVO.getFiles()) - .eqIfPresent(InvoiceDO::getCreateBy, reqVO.getCreateBy()) .betweenIfPresent(InvoiceDO::getCreateTime, reqVO.getCreateTime()) - .eqIfPresent(InvoiceDO::getUpdateBy, reqVO.getUpdateBy()) .eqIfPresent(InvoiceDO::getInvoiceType, reqVO.getInvoiceType()) .eqIfPresent(InvoiceDO::getInvoiceCode, reqVO.getInvoiceCode()) .eqIfPresent(InvoiceDO::getInvoiceNum, reqVO.getInvoiceNum()) diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java new file mode 100644 index 00000000..1119b72e --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.module.bs.service.expenseapply; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyPageReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * 申请单 Service 接口 + * + * @author 芋道源码 + */ +public interface ExpenseApplyService { + + /** + * 创建申请单 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createExpenseApply(@Valid ExpenseApplyCreateReqVO createReqVO); + + /** + * 更新申请单 + * + * @param updateReqVO 更新信息 + */ + void updateExpenseApply(@Valid ExpenseApplyUpdateReqVO updateReqVO); + + /** + * 删除申请单 + * + * @param id 编号 + */ + void deleteExpenseApply(Long id); + + /** + * 获得申请单 + * + * @param id 编号 + * @return 申请单 + */ + ExpenseApplyDO getExpenseApply(Long id); + + /** + * 获得申请单列表 + * + * @param ids 编号 + * @return 申请单列表 + */ + List getExpenseApplyList(Collection ids); + + /** + * 获得申请单分页 + * + * @param pageReqVO 分页查询 + * @return 申请单分页 + */ + PageResult getExpenseApplyPage(ExpenseApplyPageReqVO pageReqVO); + + /** + * 获得申请单列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 申请单列表 + */ + List getExpenseApplyList(ExpenseApplyExportReqVO exportReqVO); + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java new file mode 100644 index 00000000..12ebc39e --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java @@ -0,0 +1,85 @@ +package cn.iocoder.yudao.module.bs.service.expenseapply; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyPageReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO; +import cn.iocoder.yudao.module.bs.convert.expenseapply.ExpenseApplyConvert; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; +import cn.iocoder.yudao.module.bs.dal.mysql.expenseapply.ExpenseApplyMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.EXPENSE_APPLY_NOT_EXISTS; + +/** + * 申请单 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ExpenseApplyServiceImpl implements ExpenseApplyService { + + @Resource + private ExpenseApplyMapper expenseApplyMapper; + + @Override + public Long createExpenseApply(ExpenseApplyCreateReqVO createReqVO) { + // 插入 + ExpenseApplyDO expenseApply = ExpenseApplyConvert.INSTANCE.convert(createReqVO); + expenseApplyMapper.insert(expenseApply); + // 返回 + return expenseApply.getId(); + } + + @Override + public void updateExpenseApply(ExpenseApplyUpdateReqVO updateReqVO) { + // 校验存在 + validateExpenseApplyExists(updateReqVO.getId()); + // 更新 + ExpenseApplyDO updateObj = ExpenseApplyConvert.INSTANCE.convert(updateReqVO); + expenseApplyMapper.updateById(updateObj); + } + + @Override + public void deleteExpenseApply(Long id) { + // 校验存在 + validateExpenseApplyExists(id); + // 删除 + expenseApplyMapper.deleteById(id); + } + + private void validateExpenseApplyExists(Long id) { + if (expenseApplyMapper.selectById(id) == null) { + throw exception(EXPENSE_APPLY_NOT_EXISTS); + } + } + + @Override + public ExpenseApplyDO getExpenseApply(Long id) { + return expenseApplyMapper.selectById(id); + } + + @Override + public List getExpenseApplyList(Collection ids) { + return expenseApplyMapper.selectBatchIds(ids); + } + + @Override + public PageResult getExpenseApplyPage(ExpenseApplyPageReqVO pageReqVO) { + return expenseApplyMapper.selectPage(pageReqVO); + } + + @Override + public List getExpenseApplyList(ExpenseApplyExportReqVO exportReqVO) { + return expenseApplyMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/expenseapply/ExpenseApplyMapper.xml b/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/expenseapply/ExpenseApplyMapper.xml new file mode 100644 index 00000000..6e4dcdc0 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/expenseapply/ExpenseApplyMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java b/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java new file mode 100644 index 00000000..96c5a1a1 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java @@ -0,0 +1,259 @@ +package cn.iocoder.yudao.module.bs.service.expenseapply; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyCreateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyPageReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; +import cn.iocoder.yudao.module.bs.dal.mysql.expenseapply.ExpenseApplyMapper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.EXPENSE_APPLY_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; + +/** + * {@link ExpenseApplyServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(ExpenseApplyServiceImpl.class) +public class ExpenseApplyServiceImplTest extends BaseDbUnitTest { + + @Resource + private ExpenseApplyServiceImpl expenseApplyService; + + @Resource + private ExpenseApplyMapper expenseApplyMapper; + + @Test + public void testCreateExpenseApply_success() { + // 准备参数 + ExpenseApplyCreateReqVO reqVO = randomPojo(ExpenseApplyCreateReqVO.class); + + // 调用 + Long expenseApplyId = expenseApplyService.createExpenseApply(reqVO); + // 断言 + assertNotNull(expenseApplyId); + // 校验记录的属性是否正确 + ExpenseApplyDO expenseApply = expenseApplyMapper.selectById(expenseApplyId); + assertPojoEquals(reqVO, expenseApply); + } + + @Test + public void testUpdateExpenseApply_success() { + // mock 数据 + ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class); + expenseApplyMapper.insert(dbExpenseApply);// @Sql: 先插入出一条存在的数据 + // 准备参数 + ExpenseApplyUpdateReqVO reqVO = randomPojo(ExpenseApplyUpdateReqVO.class, o -> { + o.setId(dbExpenseApply.getId()); // 设置更新的 ID + }); + + // 调用 + expenseApplyService.updateExpenseApply(reqVO); + // 校验是否更新正确 + ExpenseApplyDO expenseApply = expenseApplyMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, expenseApply); + } + + @Test + public void testUpdateExpenseApply_notExists() { + // 准备参数 + ExpenseApplyUpdateReqVO reqVO = randomPojo(ExpenseApplyUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> expenseApplyService.updateExpenseApply(reqVO), EXPENSE_APPLY_NOT_EXISTS); + } + + @Test + public void testDeleteExpenseApply_success() { + // mock 数据 + ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class); + expenseApplyMapper.insert(dbExpenseApply);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbExpenseApply.getId(); + + // 调用 + expenseApplyService.deleteExpenseApply(id); + // 校验数据不存在了 + assertNull(expenseApplyMapper.selectById(id)); + } + + @Test + public void testDeleteExpenseApply_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> expenseApplyService.deleteExpenseApply(id), EXPENSE_APPLY_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetExpenseApplyPage() { + // mock 数据 + ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class, o -> { // 等会查询到 + o.setBillType(null); + o.setApplyNo(null); + o.setUserId(null); + o.setNickname(null); + o.setDeptId(null); + o.setDeptName(null); + o.setProjectName(null); + o.setReason(null); + o.setAmount(null); + o.setStatus(null); + o.setRemark(null); + o.setFiles(null); + o.setCreateBy(null); + o.setCreateTime(null); + o.setUpdateBy(null); + }); + expenseApplyMapper.insert(dbExpenseApply); + // 测试 billType 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setBillType(null))); + // 测试 applyNo 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setApplyNo(null))); + // 测试 userId 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUserId(null))); + // 测试 nickname 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setNickname(null))); + // 测试 deptId 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptId(null))); + // 测试 deptName 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptName(null))); + // 测试 projectName 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setProjectName(null))); + // 测试 reason 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setReason(null))); + // 测试 amount 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setAmount(null))); + // 测试 status 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setStatus(null))); + // 测试 remark 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setRemark(null))); + // 测试 files 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setFiles(null))); + // 测试 createBy 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateBy(null))); + // 测试 createTime 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateTime(null))); + // 测试 updateBy 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUpdateBy(null))); + // 准备参数 + ExpenseApplyPageReqVO reqVO = new ExpenseApplyPageReqVO(); + reqVO.setBillType(null); + reqVO.setApplyNo(null); + reqVO.setUserId(null); + reqVO.setNickname(null); + reqVO.setDeptId(null); + reqVO.setDeptName(null); + reqVO.setProjectName(null); + reqVO.setReason(null); + reqVO.setAmount(null); + reqVO.setStatus(null); + reqVO.setRemark(null); + reqVO.setFiles(null); + reqVO.setCreateBy(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setUpdateBy(null); + + // 调用 + PageResult pageResult = expenseApplyService.getExpenseApplyPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbExpenseApply, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetExpenseApplyList() { + // mock 数据 + ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class, o -> { // 等会查询到 + o.setBillType(null); + o.setApplyNo(null); + o.setUserId(null); + o.setNickname(null); + o.setDeptId(null); + o.setDeptName(null); + o.setProjectName(null); + o.setReason(null); + o.setAmount(null); + o.setStatus(null); + o.setRemark(null); + o.setFiles(null); + o.setCreateBy(null); + o.setCreateTime(null); + o.setUpdateBy(null); + }); + expenseApplyMapper.insert(dbExpenseApply); + // 测试 billType 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setBillType(null))); + // 测试 applyNo 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setApplyNo(null))); + // 测试 userId 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUserId(null))); + // 测试 nickname 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setNickname(null))); + // 测试 deptId 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptId(null))); + // 测试 deptName 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptName(null))); + // 测试 projectName 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setProjectName(null))); + // 测试 reason 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setReason(null))); + // 测试 amount 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setAmount(null))); + // 测试 status 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setStatus(null))); + // 测试 remark 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setRemark(null))); + // 测试 files 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setFiles(null))); + // 测试 createBy 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateBy(null))); + // 测试 createTime 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateTime(null))); + // 测试 updateBy 不匹配 + expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUpdateBy(null))); + // 准备参数 + ExpenseApplyExportReqVO reqVO = new ExpenseApplyExportReqVO(); + reqVO.setBillType(null); + reqVO.setApplyNo(null); + reqVO.setUserId(null); + reqVO.setNickname(null); + reqVO.setDeptId(null); + reqVO.setDeptName(null); + reqVO.setProjectName(null); + reqVO.setReason(null); + reqVO.setAmount(null); + reqVO.setStatus(null); + reqVO.setRemark(null); + reqVO.setFiles(null); + reqVO.setCreateBy(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setUpdateBy(null); + + // 调用 + List list = expenseApplyService.getExpenseApplyList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbExpenseApply, list.get(0)); + } + +} From aa9cbeac880515faa57cb0c4856b404fb2eecd0b Mon Sep 17 00:00:00 2001 From: chenqp <965586934@qq.com> Date: Sun, 30 Jul 2023 22:12:23 +0800 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20=E8=8E=B7=E5=8F=96=E7=A7=9F?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E5=A2=9E=E5=8A=A0=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E5=90=8D=E7=A7=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/tenant/TenantController.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java index 0020c928..0d1f86f0 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.controller.admin.tenant; +import cn.hutool.core.map.MapUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; @@ -20,6 +21,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; import java.util.List; +import java.util.Map; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @@ -36,9 +38,13 @@ public class TenantController { @PermitAll @Operation(summary = "使用租户名,获得租户编号", description = "登录界面,根据用户的租户名,获得租户编号") @Parameter(name = "name", description = "租户名", required = true, example = "1024") - public CommonResult getTenantIdByName(@RequestParam("name") String name) { + public CommonResult getTenantIdByName(@RequestParam("name") String name) { TenantDO tenantDO = tenantService.getTenantByName(name); - return success(tenantDO != null ? tenantDO.getId() : null); + if (tenantDO == null) { + return success(null); + } + Map data = MapUtil.builder().put("id", tenantDO.getId()).put("name", tenantDO.getName()).build(); + return success(data); } @PostMapping("/create") From c4553a6dd4736b0352cccedb8ad1f59235de6026 Mon Sep 17 00:00:00 2001 From: chenqp <965586934@qq.com> Date: Sun, 30 Jul 2023 22:13:31 +0800 Subject: [PATCH 4/7] =?UTF-8?q?feat:=20bpm=E5=A2=9E=E5=8A=A0=E4=BE=9D?= =?UTF-8?q?=E8=B5=96bs=20biz=E6=A8=A1=E5=9D=97=EF=BC=8C=E6=96=B9=E4=BE=BF?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-module-bpm/yudao-module-bpm-biz/pom.xml | 6 +++++- .../admin/expenseapply/ExpenseApplyController.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) rename {yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs => yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm}/controller/admin/expenseapply/ExpenseApplyController.java (98%) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml b/yudao-module-bpm/yudao-module-bpm-biz/pom.xml index 12d5c5be..d4934c56 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml +++ b/yudao-module-bpm/yudao-module-bpm-biz/pom.xml @@ -26,7 +26,11 @@ yudao-module-system-api ${revision} - + + cn.iocoder.boot + yudao-module-bs-biz + ${revision} + cn.iocoder.boot diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/ExpenseApplyController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java similarity index 98% rename from yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/ExpenseApplyController.java rename to yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java index 371b5d93..07225b5c 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/ExpenseApplyController.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.bs.controller.admin.expenseapply; +package cn.iocoder.yudao.module.bpm.controller.admin.expenseapply; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; From 3fe5635b0841579161b94cf48526e08fbc1a6930 Mon Sep 17 00:00:00 2001 From: chenqp <965586934@qq.com> Date: Mon, 31 Jul 2023 00:48:07 +0800 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=E7=94=B3=E8=AF=B7=E5=8D=95?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9A=82=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/common/pojo/CommonResult.java | 15 ++- .../yudao/framework/common/pojo/ImageVo.java | 17 +++ .../expenseapply/ExpenseApplyController.java | 11 +- .../yudao/module/bs/enums/BillTypeEnum.java | 33 ++++++ .../bs/enums/ExpenseApplyStatusEnum.java | 30 ++++++ yudao-module-bs/yudao-module-bs-biz/pom.xml | 4 + .../expenseapply/vo/ExpenseApplyBaseVO.java | 41 +++---- .../vo/ExpenseApplyCreateReqVO.java | 15 ++- .../expenseapply/vo/ExpenseApplyExcelVO.java | 7 +- .../vo/ExpenseApplyTripBaseVO.java | 57 ++++++++++ .../vo/ExpenseApplyTripCreateReqVO.java | 12 +++ .../expenseapply/ExpenseApplyConvert.java | 4 + .../expenseapply/ExpenseApplyDO.java | 21 ++-- .../expenseapplytrip/ExpenseApplyTripDO.java | 92 ++++++++++++++++ .../bs/dal/dataobject/invoice/InvoiceDO.java | 3 +- .../expenseapply/ExpenseApplyMapper.java | 4 - .../ExpenseApplyTripMapper.java | 22 ++++ .../expenseapply/ExpenseApplyService.java | 14 ++- .../expenseapply/ExpenseApplyServiceImpl.java | 101 +++++++++++++++--- .../ExpenseApplyTripService.java | 19 ++++ .../ExpenseApplyTripServiceImpl.java | 19 ++++ .../ExpenseApplyTripMapper.xml | 12 +++ .../ExpenseApplyServiceImplTest.java | 12 +-- 23 files changed, 487 insertions(+), 78 deletions(-) create mode 100644 yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/ImageVo.java create mode 100644 yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/BillTypeEnum.java create mode 100644 yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ExpenseApplyStatusEnum.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripCreateReqVO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapplytrip/ExpenseApplyTripMapper.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapplytrip/ExpenseApplyTripService.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapplytrip/ExpenseApplyTripServiceImpl.java create mode 100644 yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/expenseapplytrip/ExpenseApplyTripMapper.xml diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/CommonResult.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/CommonResult.java index cb82d301..aa9fd118 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/CommonResult.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/CommonResult.java @@ -56,7 +56,12 @@ public class CommonResult implements Serializable { result.msg = message; return result; } - + public static CommonResult error(String message) { + CommonResult result = new CommonResult<>(); + result.code = 500; + result.msg = message; + return result; + } public static CommonResult error(ErrorCode errorCode) { return error(errorCode.getCode(), errorCode.getMsg()); } @@ -68,7 +73,13 @@ public class CommonResult implements Serializable { result.msg = ""; return result; } - + public static CommonResult success() { + CommonResult result = new CommonResult<>(); + result.code = GlobalErrorCodeConstants.SUCCESS.getCode(); + result.data = null; + result.msg = ""; + return result; + } public static boolean isSuccess(Integer code) { return Objects.equals(code, GlobalErrorCodeConstants.SUCCESS.getCode()); } diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/ImageVo.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/ImageVo.java new file mode 100644 index 00000000..5dff535a --- /dev/null +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/ImageVo.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.framework.common.pojo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 路由显示信息 + * + * @author ruoyi + */ +@Data +public class ImageVo implements Serializable { + private static final long serialVersionUID=1L; + String name; + String url; +} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java index 07225b5c..efe1dab8 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java @@ -37,17 +37,10 @@ public class ExpenseApplyController { @PostMapping("/create") @Operation(summary = "创建申请单") @PreAuthorize("@ss.hasPermission('bs:expense-apply:create')") - public CommonResult createExpenseApply(@Valid @RequestBody ExpenseApplyCreateReqVO createReqVO) { - return success(expenseApplyService.createExpenseApply(createReqVO)); + public CommonResult createExpenseApply(@Valid @RequestBody ExpenseApplyCreateReqVO createReqVO) { + return expenseApplyService.createExpenseApply(createReqVO); } - @PutMapping("/update") - @Operation(summary = "更新申请单") - @PreAuthorize("@ss.hasPermission('bs:expense-apply:update')") - public CommonResult updateExpenseApply(@Valid @RequestBody ExpenseApplyUpdateReqVO updateReqVO) { - expenseApplyService.updateExpenseApply(updateReqVO); - return success(true); - } @DeleteMapping("/delete") @Operation(summary = "删除申请单") diff --git a/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/BillTypeEnum.java b/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/BillTypeEnum.java new file mode 100644 index 00000000..f65fc578 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/BillTypeEnum.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.module.bs.enums; + +import cn.hutool.core.util.ArrayUtil; +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; +import java.util.stream.Collectors; + +/** + * 单据类型枚举 + */ +@AllArgsConstructor +@Getter +public enum BillTypeEnum { + + CLSQ("CLSQ", "差旅申请单"), + RCSQ("RCSQ", "日常申请单"); + + + /** + * 类型 + */ + private final String value; + /** + * 类型名 + */ + private final String name; + + +} diff --git a/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ExpenseApplyStatusEnum.java b/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ExpenseApplyStatusEnum.java new file mode 100644 index 00000000..20dbba8e --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-api/src/main/java/cn/iocoder/yudao/module/bs/enums/ExpenseApplyStatusEnum.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.bs.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 申请状态枚举 + */ +@AllArgsConstructor +@Getter +public enum ExpenseApplyStatusEnum { + + NOSUBMIT("0", "未提交"), + UNAUDIT("1", "待审核"), + NOPASS("2", "驳回"), + PASS("3", "通过"), + CANCEL("4", "取消"); + + + /** + * 类型 + */ + private final String value; + /** + * 类型名 + */ + private final String name; + + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/pom.xml b/yudao-module-bs/yudao-module-bs-biz/pom.xml index 808be241..2f3f197d 100644 --- a/yudao-module-bs/yudao-module-bs-biz/pom.xml +++ b/yudao-module-bs/yudao-module-bs-biz/pom.xml @@ -18,6 +18,10 @@ + + cn.iocoder.boot + yudao-spring-boot-starter-biz-tenant + cn.iocoder.boot yudao-module-bs-api diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyBaseVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyBaseVO.java index 12e60d1c..484b7fd3 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyBaseVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyBaseVO.java @@ -1,9 +1,12 @@ package cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo.ExpenseApplyTripCreateReqVO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import javax.validation.constraints.NotNull; +import java.util.List; /** * 申请单 Base VO,提供给添加、修改、详细的子 VO 使用 @@ -16,34 +19,36 @@ public class ExpenseApplyBaseVO { @NotNull(message = "申请类型不能为空") private String billType; - @Schema(description = "申请者ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9227") - @NotNull(message = "申请者ID不能为空") - private Long userId; - - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") - @NotNull(message = "用户昵称不能为空") - private String nickname; - - @Schema(description = "部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32343") - @NotNull(message = "部门ID不能为空") - private Long deptId; - - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") - @NotNull(message = "部门名称不能为空") - private String deptName; +// @Schema(description = "申请者ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9227") +// @NotNull(message = "申请者ID不能为空") +// private Long userId; +// +// @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") +// @NotNull(message = "用户昵称不能为空") +// private String nickname; +// +// @Schema(description = "部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32343") +// @NotNull(message = "部门ID不能为空") +// private Long deptId; +// +// @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") +// @NotNull(message = "部门名称不能为空") +// private String deptName; @Schema(description = "项目名称", example = "芋艿") private String projectName; @Schema(description = "申请事由", example = "不香") + @NotNull(message = "申请事由") private String reason; + private String status; @Schema(description = "备注", example = "你猜") private String remark; @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "附件不能为空") - private String files; - + private List files; + @Schema(description = "行程明细,仅为差旅申请单的时候需要传", example = "") + private List expenseApplyTrips; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyCreateReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyCreateReqVO.java index a26d6ffd..a52a47fa 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyCreateReqVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyCreateReqVO.java @@ -1,14 +1,27 @@ package cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.iocoder.yudao.module.bs.enums.ExpenseApplyStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +import javax.validation.constraints.AssertTrue; +import javax.validation.constraints.NotNull; +import java.util.Date; + @Schema(description = "管理后台 - 申请单创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class ExpenseApplyCreateReqVO extends ExpenseApplyBaseVO { - + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14225") + private Long id; + @AssertTrue(message = "换班日期只能是大于今日的日期") + public boolean isStatusValid() { + //只能传未提交和待审核 + return getStatus().equals(ExpenseApplyStatusEnum.NOSUBMIT.getValue()) || getStatus().equals(ExpenseApplyStatusEnum.UNAUDIT.getValue()); + } } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExcelVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExcelVO.java index 234e2131..adc287a3 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExcelVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyExcelVO.java @@ -55,16 +55,11 @@ public class ExpenseApplyExcelVO { @ExcelProperty("备注") private String remark; - @ExcelProperty("附件") - private String files; - @ExcelProperty("创建者") - private String createBy; + @ExcelProperty("创建时间") private LocalDateTime createTime; - @ExcelProperty("更新者") - private String updateBy; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java new file mode 100644 index 00000000..f4c8d309 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.math.BigDecimal; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 申请单行程明细 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ExpenseApplyTripBaseVO { + + + + @Schema(description = "出发地编码,二级市", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "出发地编码,二级市不能为空") + private String departureLocation; + + @Schema(description = "目的地编码,二级市", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "目的地编码,二级市不能为空") + private String destinationLocation; + + @Schema(description = "开始日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "开始日期不能为空") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime startTime; + + @Schema(description = "结束日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "结束日期不能为空") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime endTime; + + @Schema(description = "出差天数") + @NotNull(message = "出差天数不能为空") + private BigDecimal tripDay; + + @Schema(description = "出差类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + private String tripType; + + @Schema(description = "出差同行人", requiredMode = Schema.RequiredMode.REQUIRED) + private String tripPartners; + + @Schema(description = "预计费用") + private BigDecimal amount; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripCreateReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripCreateReqVO.java new file mode 100644 index 00000000..34ddc4c2 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripCreateReqVO.java @@ -0,0 +1,12 @@ +package cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo; + +import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "管理后台 - 申请单行程明细创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ExpenseApplyTripCreateReqVO extends ExpenseApplyTripBaseVO { + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseapply/ExpenseApplyConvert.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseapply/ExpenseApplyConvert.java index 4ad58b48..989710ea 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseapply/ExpenseApplyConvert.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/convert/expenseapply/ExpenseApplyConvert.java @@ -5,7 +5,9 @@ import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyC import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExcelVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyRespVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo.ExpenseApplyTripCreateReqVO; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -22,6 +24,8 @@ public interface ExpenseApplyConvert { ExpenseApplyConvert INSTANCE = Mappers.getMapper(ExpenseApplyConvert.class); ExpenseApplyDO convert(ExpenseApplyCreateReqVO bean); + ExpenseApplyTripDO convert(ExpenseApplyTripCreateReqVO bean); + List convert(List bean); ExpenseApplyDO convert(ExpenseApplyUpdateReqVO bean); diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java index 85fa6ce2..313ca8e7 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java @@ -1,12 +1,17 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; 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.math.BigDecimal; +import java.util.List; /** * 申请单 DO @@ -21,7 +26,7 @@ import java.math.BigDecimal; @Builder @NoArgsConstructor @AllArgsConstructor -public class ExpenseApplyDO extends BaseDO { +public class ExpenseApplyDO extends TenantBaseDO { /** * id @@ -42,18 +47,12 @@ public class ExpenseApplyDO extends BaseDO { * 申请者ID */ private Long userId; - /** - * 用户昵称 - */ - private String nickname; + /** * 部门ID */ private Long deptId; - /** - * 部门名称 - */ - private String deptName; + /** * 项目名称 */ @@ -79,6 +78,8 @@ public class ExpenseApplyDO extends BaseDO { /** * 附件 */ - private String files; + + @TableField(typeHandler = JacksonTypeHandler.class) + private List files; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java new file mode 100644 index 00000000..33b00ba8 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java @@ -0,0 +1,92 @@ +package cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip; + +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 申请单行程明细 DO + * + * @author 芋道源码 + */ +@TableName(value = "bs_expense_apply_trip", autoResultMap = true) +@KeySequence("bs_expense_apply_trip_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ExpenseApplyTripDO extends TenantBaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 备注 + */ + private String remark; + /** + * 附件 + */ + private String files; + /** + * 创建者 + */ + private String createBy; + /** + * 更新者 + */ + private String updateBy; + /** + * 申请单ID + */ + private Long applyId; + /** + * 出发地编码,二级市 + */ + private String departureLocation; + /** + * 目的地编码,二级市 + */ + private String destinationLocation; + /** + * 开始日期 + */ + private LocalDateTime startTime; + /** + * 结束日期 + */ + private LocalDateTime endTime; + /** + * 出差天数 + */ + private BigDecimal tripDay; + /** + * 出差类型 + * + * 枚举 {@link TODO bs_trip_type 对应的类} + */ + private String tripType; + /** + * 出差同行人 + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private String tripPartners; + /** + * 预计费用 + */ + private BigDecimal amount; + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java index 9ed1c5af..8541f69b 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.invoice; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import com.baomidou.mybatisplus.annotation.*; import lombok.*; @@ -20,7 +21,7 @@ import java.time.LocalDateTime; @Builder @NoArgsConstructor @AllArgsConstructor -public class InvoiceDO extends BaseDO { +public class InvoiceDO extends TenantBaseDO { /** * id diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapply/ExpenseApplyMapper.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapply/ExpenseApplyMapper.java index 7b1fa6ab..b16bb68d 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapply/ExpenseApplyMapper.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapply/ExpenseApplyMapper.java @@ -23,9 +23,7 @@ public interface ExpenseApplyMapper extends BaseMapperX { .eqIfPresent(ExpenseApplyDO::getBillType, reqVO.getBillType()) .eqIfPresent(ExpenseApplyDO::getApplyNo, reqVO.getApplyNo()) .eqIfPresent(ExpenseApplyDO::getUserId, reqVO.getUserId()) - .likeIfPresent(ExpenseApplyDO::getNickname, reqVO.getNickname()) .eqIfPresent(ExpenseApplyDO::getDeptId, reqVO.getDeptId()) - .likeIfPresent(ExpenseApplyDO::getDeptName, reqVO.getDeptName()) .likeIfPresent(ExpenseApplyDO::getProjectName, reqVO.getProjectName()) .eqIfPresent(ExpenseApplyDO::getReason, reqVO.getReason()) .eqIfPresent(ExpenseApplyDO::getAmount, reqVO.getAmount()) @@ -41,9 +39,7 @@ public interface ExpenseApplyMapper extends BaseMapperX { .eqIfPresent(ExpenseApplyDO::getBillType, reqVO.getBillType()) .eqIfPresent(ExpenseApplyDO::getApplyNo, reqVO.getApplyNo()) .eqIfPresent(ExpenseApplyDO::getUserId, reqVO.getUserId()) - .likeIfPresent(ExpenseApplyDO::getNickname, reqVO.getNickname()) .eqIfPresent(ExpenseApplyDO::getDeptId, reqVO.getDeptId()) - .likeIfPresent(ExpenseApplyDO::getDeptName, reqVO.getDeptName()) .likeIfPresent(ExpenseApplyDO::getProjectName, reqVO.getProjectName()) .eqIfPresent(ExpenseApplyDO::getReason, reqVO.getReason()) .eqIfPresent(ExpenseApplyDO::getAmount, reqVO.getAmount()) diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapplytrip/ExpenseApplyTripMapper.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapplytrip/ExpenseApplyTripMapper.java new file mode 100644 index 00000000..8d3dada5 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/mysql/expenseapplytrip/ExpenseApplyTripMapper.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.bs.dal.mysql.expenseapplytrip; + +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.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo.*; + +/** + * 申请单行程明细 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface ExpenseApplyTripMapper extends BaseMapperX { + + + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java index 1119b72e..87e6fe96 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.bs.service.expenseapply; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyCreateReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyPageReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; +import com.baomidou.mybatisplus.extension.service.IService; import javax.validation.Valid; import java.util.Collection; @@ -16,7 +18,7 @@ import java.util.List; * * @author 芋道源码 */ -public interface ExpenseApplyService { +public interface ExpenseApplyService extends IService { /** * 创建申请单 @@ -24,14 +26,10 @@ public interface ExpenseApplyService { * @param createReqVO 创建信息 * @return 编号 */ - Long createExpenseApply(@Valid ExpenseApplyCreateReqVO createReqVO); + CommonResult createExpenseApply(@Valid ExpenseApplyCreateReqVO createReqVO); + + - /** - * 更新申请单 - * - * @param updateReqVO 更新信息 - */ - void updateExpenseApply(@Valid ExpenseApplyUpdateReqVO updateReqVO); /** * 删除申请单 diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java index 12ebc39e..556ea8d2 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java @@ -1,21 +1,39 @@ package cn.iocoder.yudao.module.bs.service.expenseapply; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.RandomUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; +import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyCreateReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyPageReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo.ExpenseApplyTripCreateReqVO; import cn.iocoder.yudao.module.bs.convert.expenseapply.ExpenseApplyConvert; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; import cn.iocoder.yudao.module.bs.dal.mysql.expenseapply.ExpenseApplyMapper; +import cn.iocoder.yudao.module.bs.enums.BillTypeEnum; +import cn.iocoder.yudao.module.bs.enums.ExpenseApplyStatusEnum; +import cn.iocoder.yudao.module.bs.service.expenseapplytrip.ExpenseApplyTripService; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import javax.validation.Validator; +import java.math.BigDecimal; import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.EXPENSE_APPLY_NOT_EXISTS; /** @@ -25,27 +43,84 @@ import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.EXPENSE_APPLY_ */ @Service @Validated -public class ExpenseApplyServiceImpl implements ExpenseApplyService { +@Transactional(rollbackFor = Exception.class) +public class ExpenseApplyServiceImpl extends ServiceImpl implements ExpenseApplyService { + public static final String PROCESS_KEY = "expense_apply"; + @Resource + private Validator validator; @Resource private ExpenseApplyMapper expenseApplyMapper; - + @Resource + private AdminUserApi adminUserApi; + @Resource + private ExpenseApplyTripService expenseApplyTripService; +// @Resource +// private BpmProcessInstanceApi processInstanceApi; @Override - public Long createExpenseApply(ExpenseApplyCreateReqVO createReqVO) { - // 插入 + public CommonResult createExpenseApply(ExpenseApplyCreateReqVO createReqVO) { ExpenseApplyDO expenseApply = ExpenseApplyConvert.INSTANCE.convert(createReqVO); - expenseApplyMapper.insert(expenseApply); + CommonResult result = dataValidAndSetFileName(createReqVO, expenseApply); + if (result.isError()) { + return result; + } + + saveOrUpdate(expenseApply); + if (expenseApply.getBillType().equals(BillTypeEnum.CLSQ.getValue())) { + //插入或者更新差旅明细 + List trips = ExpenseApplyConvert.INSTANCE.convert(createReqVO.getExpenseApplyTrips()); + for (ExpenseApplyTripDO trip : trips) { + trip.setApplyId(expenseApply.getId()); + } + expenseApplyTripService.saveOrUpdateBatch(trips); + } + if (expenseApply.getStatus().equals(ExpenseApplyStatusEnum.UNAUDIT.getValue())) { + //cqptodo 提交单据,创建工作流 +// String processInstanceId = processInstanceApi.createProcessInstance(userId, +// new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) +// .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(leave.getId()))); + } // 返回 - return expenseApply.getId(); + return CommonResult.success(); } - @Override - public void updateExpenseApply(ExpenseApplyUpdateReqVO updateReqVO) { - // 校验存在 - validateExpenseApplyExists(updateReqVO.getId()); - // 更新 - ExpenseApplyDO updateObj = ExpenseApplyConvert.INSTANCE.convert(updateReqVO); - expenseApplyMapper.updateById(updateObj); + /** + * 新增和更新数据校验 + * @param createReqVO + * @param expenseApply + * @return + */ + private CommonResult dataValidAndSetFileName(ExpenseApplyCreateReqVO createReqVO, ExpenseApplyDO expenseApply) { + boolean isAdd = createReqVO.getId() == null; + + if (expenseApply.getBillType().equals(BillTypeEnum.CLSQ.getValue())) { + List expenseApplyTrips = createReqVO.getExpenseApplyTrips(); + if (CollUtil.isEmpty(expenseApplyTrips)) { + return CommonResult.error("差旅明细不能为空"); + } + // 参数校验 + ValidationUtils.validate(validator, expenseApplyTrips); + BigDecimal amount = BigDecimal.ZERO; + for (ExpenseApplyTripCreateReqVO trip : expenseApplyTrips) { + if (trip.getAmount()!=null) { + amount = amount.add(trip.getAmount()); + } + } + expenseApply.setAmount(amount); + } + if (isAdd) { + //新增 + //cqptodo 单号的规则需要重写 + expenseApply.setApplyNo(RandomUtil.randomString(6)); + }else { + validateExpenseApplyExists(expenseApply.getId()); + } + LoginUser loginUser = getLoginUser(); + expenseApply.setUserId(loginUser.getId()); + AdminUserRespDTO user = adminUserApi.getUser(loginUser.getId()); + expenseApply.setDeptId(user.getDeptId()); + + return CommonResult.success(); } @Override diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapplytrip/ExpenseApplyTripService.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapplytrip/ExpenseApplyTripService.java new file mode 100644 index 00000000..386f88c7 --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapplytrip/ExpenseApplyTripService.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.bs.service.expenseapplytrip; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo.*; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 申请单行程明细 Service 接口 + * + * @author 芋道源码 + */ +public interface ExpenseApplyTripService extends IService { + + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapplytrip/ExpenseApplyTripServiceImpl.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapplytrip/ExpenseApplyTripServiceImpl.java new file mode 100644 index 00000000..562a2fdd --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapplytrip/ExpenseApplyTripServiceImpl.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.bs.service.expenseapplytrip; + +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; +import cn.iocoder.yudao.module.bs.dal.mysql.expenseapplytrip.ExpenseApplyTripMapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +/** + * 申请单行程明细 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ExpenseApplyTripServiceImpl extends ServiceImpl implements ExpenseApplyTripService { + + +} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/expenseapplytrip/ExpenseApplyTripMapper.xml b/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/expenseapplytrip/ExpenseApplyTripMapper.xml new file mode 100644 index 00000000..cfc5952d --- /dev/null +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/resources/mapper/expenseapplytrip/ExpenseApplyTripMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java b/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java index 96c5a1a1..d2afffaf 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java @@ -44,12 +44,12 @@ public class ExpenseApplyServiceImplTest extends BaseDbUnitTest { ExpenseApplyCreateReqVO reqVO = randomPojo(ExpenseApplyCreateReqVO.class); // 调用 - Long expenseApplyId = expenseApplyService.createExpenseApply(reqVO); - // 断言 - assertNotNull(expenseApplyId); - // 校验记录的属性是否正确 - ExpenseApplyDO expenseApply = expenseApplyMapper.selectById(expenseApplyId); - assertPojoEquals(reqVO, expenseApply); +// Long expenseApplyId = expenseApplyService.createExpenseApply(reqVO); +// // 断言 +// assertNotNull(expenseApplyId); +// // 校验记录的属性是否正确 +// ExpenseApplyDO expenseApply = expenseApplyMapper.selectById(expenseApplyId); +// assertPojoEquals(reqVO, expenseApply); } @Test From f0250d96d976033f0b079517d6f66082d744e22b Mon Sep 17 00:00:00 2001 From: chenqp <965586934@qq.com> Date: Tue, 1 Aug 2023 00:01:13 +0800 Subject: [PATCH 6/7] =?UTF-8?q?feat:=20=E7=94=B3=E8=AF=B7=E5=8D=95?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/BpmProcessInstanceResultEnum.java | 4 +- .../expenseapply/ExpenseApplyController.java | 19 +- .../expenseapply/ExpenseApplyService.java | 3 +- .../expenseapply/ExpenseApplyServiceImpl.java | 58 +++- .../ExpenseApplyTripService.java | 2 +- .../ExpenseApplyTripServiceImpl.java | 2 +- .../listener/ExpenseApplyResultListener.java | 31 +++ .../bs/enums/ExpenseApplyStatusEnum.java | 6 +- .../vo/ExpenseApplyCreateReqVO.java | 8 +- .../vo/ExpenseApplyExportReqVO.java | 4 +- .../vo/ExpenseApplyPageReqVO.java | 4 +- .../vo/ExpenseApplyTripBaseVO.java | 6 +- .../admin/invoice/vo/InvoiceExcelVO.java | 4 +- .../admin/invoice/vo/InvoiceExportReqVO.java | 4 +- .../admin/invoice/vo/InvoicePageReqVO.java | 4 +- .../admin/invoice/vo/InvoiceRespVO.java | 4 +- .../admin/invoice/vo/InvoiceUpdateReqVO.java | 4 +- .../expenseapply/ExpenseApplyDO.java | 9 + .../expenseapplytrip/ExpenseApplyTripDO.java | 9 +- .../bs/dal/dataobject/invoice/InvoiceDO.java | 8 +- .../ExpenseApplyServiceImplTest.java | 259 ----------------- .../invoice/InvoiceServiceImplTest.java | 263 ------------------ .../src/main/resources/application-local.yaml | 1 + 23 files changed, 149 insertions(+), 567 deletions(-) rename {yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs => yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm}/service/expenseapply/ExpenseApplyService.java (94%) rename {yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs => yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm}/service/expenseapply/ExpenseApplyServiceImpl.java (70%) rename {yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs => yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm}/service/expenseapplytrip/ExpenseApplyTripService.java (90%) rename {yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs => yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm}/service/expenseapplytrip/ExpenseApplyTripServiceImpl.java (90%) create mode 100644 yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/ExpenseApplyResultListener.java delete mode 100644 yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java delete mode 100644 yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/invoice/InvoiceServiceImplTest.java diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java index 3b57554c..01c82999 100644 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java +++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java @@ -15,8 +15,8 @@ public enum BpmProcessInstanceResultEnum { PROCESS(1, "处理中"), APPROVE(2, "通过"), - REJECT(3, "不通过"), - CANCEL(4, "已取消"), + REJECT(3, "驳回"), + CANCEL(4, "取消"), // ========== 流程任务独有的状态 ========== diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java index efe1dab8..9a39031f 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java @@ -3,11 +3,15 @@ package cn.iocoder.yudao.module.bpm.controller.admin.expenseapply; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import cn.iocoder.yudao.module.bpm.service.expenseapplytrip.ExpenseApplyTripService; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.*; import cn.iocoder.yudao.module.bs.convert.expenseapply.ExpenseApplyConvert; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; -import cn.iocoder.yudao.module.bs.service.expenseapply.ExpenseApplyService; +import cn.iocoder.yudao.module.bpm.service.expenseapply.ExpenseApplyService; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; +import cn.iocoder.yudao.module.bs.enums.BillTypeEnum; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -33,7 +37,8 @@ public class ExpenseApplyController { @Resource private ExpenseApplyService expenseApplyService; - + @Resource + private ExpenseApplyTripService expenseApplyTripService; @PostMapping("/create") @Operation(summary = "创建申请单") @PreAuthorize("@ss.hasPermission('bs:expense-apply:create')") @@ -55,9 +60,15 @@ public class ExpenseApplyController { @Operation(summary = "获得申请单") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('bs:expense-apply:query')") - public CommonResult getExpenseApply(@RequestParam("id") Long id) { + public CommonResult getExpenseApply(@RequestParam("id") Long id) { ExpenseApplyDO expenseApply = expenseApplyService.getExpenseApply(id); - return success(ExpenseApplyConvert.INSTANCE.convert(expenseApply)); + if (expenseApply.getBillType().equals(BillTypeEnum.CLSQ.getValue())) { + LambdaQueryWrapperX queryWrapper = new LambdaQueryWrapperX<>(); + queryWrapper.eq(ExpenseApplyTripDO::getApplyId, expenseApply.getId()); + List list = expenseApplyTripService.list(queryWrapper); + expenseApply.setExpenseApplyTrips(list); + } + return success(expenseApply); } @GetMapping("/list") diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java similarity index 94% rename from yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java rename to yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java index 87e6fe96..93b16e24 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyService.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.bs.service.expenseapply; +package cn.iocoder.yudao.module.bpm.service.expenseapply; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -70,4 +70,5 @@ public interface ExpenseApplyService extends IService { */ List getExpenseApplyList(ExpenseApplyExportReqVO exportReqVO); + void processInstanceCallBack(long id, Integer result); } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java similarity index 70% rename from yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java rename to yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java index 556ea8d2..a4f3d574 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java @@ -1,15 +1,18 @@ -package cn.iocoder.yudao.module.bs.service.expenseapply; +package cn.iocoder.yudao.module.bpm.service.expenseapply; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.RandomUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; import cn.iocoder.yudao.framework.security.core.LoginUser; +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.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyCreateReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyPageReqVO; -import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO; import cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo.ExpenseApplyTripCreateReqVO; import cn.iocoder.yudao.module.bs.convert.expenseapply.ExpenseApplyConvert; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; @@ -17,7 +20,7 @@ import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTr import cn.iocoder.yudao.module.bs.dal.mysql.expenseapply.ExpenseApplyMapper; import cn.iocoder.yudao.module.bs.enums.BillTypeEnum; import cn.iocoder.yudao.module.bs.enums.ExpenseApplyStatusEnum; -import cn.iocoder.yudao.module.bs.service.expenseapplytrip.ExpenseApplyTripService; +import cn.iocoder.yudao.module.bpm.service.expenseapplytrip.ExpenseApplyTripService; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -30,10 +33,10 @@ import javax.validation.Validator; import java.math.BigDecimal; import java.util.Collection; import java.util.List; +import java.util.Map; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.EXPENSE_APPLY_NOT_EXISTS; /** @@ -56,7 +59,7 @@ public class ExpenseApplyServiceImpl extends ServiceImpl variables = BeanUtil.beanToMap(expenseApply); //cqptodo 提交单据,创建工作流 -// String processInstanceId = processInstanceApi.createProcessInstance(userId, -// new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) -// .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(leave.getId()))); + String processInstanceId = processInstanceApi.createProcessInstance(expenseApply.getUserId(), + new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) + .setVariables(variables).setBusinessKey(String.valueOf(expenseApply.getId()))); + //cqptodo 待测试是否会更新其它字段 将工作流的编号,更新到单据中 + updateById(new ExpenseApplyDO().setId(expenseApply.getId()).setProcessInstanceId(processInstanceId)); } // 返回 return CommonResult.success(); @@ -113,7 +119,11 @@ public class ExpenseApplyServiceImpl extends ServiceImpl files; @Schema(description = "创建者") private String createBy; diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyPageReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyPageReqVO.java index b88f555e..3e00921a 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyPageReqVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapply/vo/ExpenseApplyPageReqVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -9,6 +10,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; @@ -52,7 +54,7 @@ public class ExpenseApplyPageReqVO extends PageParam { private String remark; @Schema(description = "附件") - private String files; + private List files; @Schema(description = "创建者") private String createBy; diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java index f4c8d309..ba881b44 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java @@ -45,11 +45,11 @@ public class ExpenseApplyTripBaseVO { @NotNull(message = "出差天数不能为空") private BigDecimal tripDay; - @Schema(description = "出差类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @Schema(description = "出差类型") private String tripType; - @Schema(description = "出差同行人", requiredMode = Schema.RequiredMode.REQUIRED) - private String tripPartners; + @Schema(description = "出差同行人") + private Set tripPartners; @Schema(description = "预计费用") private BigDecimal amount; diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceExcelVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceExcelVO.java index 29a42281..ae2236ed 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceExcelVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceExcelVO.java @@ -1,10 +1,12 @@ package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.List; /** * 我的发票 Excel VO @@ -18,7 +20,7 @@ public class InvoiceExcelVO { private Long id; @ExcelProperty("附件") - private String files; + private List files; @ExcelProperty("创建者") private String createBy; diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceExportReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceExportReqVO.java index 3dca983f..ee833ceb 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceExportReqVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceExportReqVO.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; 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; @@ -14,7 +16,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ public class InvoiceExportReqVO { @Schema(description = "附件") - private String files; + private List files; @Schema(description = "创建者") private String createBy; diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoicePageReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoicePageReqVO.java index 0ed3dfdf..d3084c2b 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoicePageReqVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoicePageReqVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -9,6 +10,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; @@ -19,7 +21,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ public class InvoicePageReqVO extends PageParam { @Schema(description = "附件") - private String files; + private List files; @Schema(description = "创建者") private String createBy; diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceRespVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceRespVO.java index 1d975252..09c20542 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceRespVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceRespVO.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import java.time.LocalDateTime; +import java.util.List; @Schema(description = "管理后台 - 我的发票 Response VO") @Data @@ -17,7 +19,7 @@ public class InvoiceRespVO extends InvoiceBaseVO { private Long id; @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED) - private String files; + private List files; @Schema(description = "创建者") private String createBy; diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceUpdateReqVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceUpdateReqVO.java index 999922ee..0ab5ce1c 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceUpdateReqVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/invoice/vo/InvoiceUpdateReqVO.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import javax.validation.constraints.NotNull; +import java.util.List; @Schema(description = "管理后台 - 我的发票更新 Request VO") @Data @@ -19,6 +21,6 @@ public class InvoiceUpdateReqVO extends InvoiceBaseVO { @Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "附件不能为空") - private String files; + private List files; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java index 313ca8e7..d9b87f50 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply; import cn.iocoder.yudao.framework.common.pojo.ImageVo; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -81,5 +82,13 @@ public class ExpenseApplyDO extends TenantBaseDO { @TableField(typeHandler = JacksonTypeHandler.class) private List files; + /** + * 对应的流程编号 + * + * 关联 ProcessInstance 的 id 属性 + */ + private String processInstanceId; + @TableField(exist = false) + private List expenseApplyTrips; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java index 33b00ba8..969500de 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; +import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.*; @@ -40,7 +42,8 @@ public class ExpenseApplyTripDO extends TenantBaseDO { /** * 附件 */ - private String files; + @TableField(typeHandler = JacksonTypeHandler.class) + private List files; /** * 创建者 */ @@ -82,8 +85,8 @@ public class ExpenseApplyTripDO extends TenantBaseDO { /** * 出差同行人 */ - @TableField(typeHandler = JacksonTypeHandler.class) - private String tripPartners; + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set tripPartners; /** * 预计费用 */ diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java index 8541f69b..6ee973c0 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/invoice/InvoiceDO.java @@ -1,19 +1,22 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.invoice; +import cn.iocoder.yudao.framework.common.pojo.ImageVo; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.*; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.List; /** * 我的发票 DO * * @author chenqp */ -@TableName("bs_invoice") +@TableName(value = "bs_invoice", autoResultMap = true) @KeySequence("bs_invoice_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data @EqualsAndHashCode(callSuper = true) @@ -31,7 +34,8 @@ public class InvoiceDO extends TenantBaseDO { /** * 附件 */ - private String files; + @TableField(typeHandler = JacksonTypeHandler.class) + private List files; /** * 发票类型 diff --git a/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java b/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java deleted file mode 100644 index d2afffaf..00000000 --- a/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/expenseapply/ExpenseApplyServiceImplTest.java +++ /dev/null @@ -1,259 +0,0 @@ -package cn.iocoder.yudao.module.bs.service.expenseapply; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyCreateReqVO; -import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO; -import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyPageReqVO; -import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO; -import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; -import cn.iocoder.yudao.module.bs.dal.mysql.expenseapply.ExpenseApplyMapper; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.EXPENSE_APPLY_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link ExpenseApplyServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(ExpenseApplyServiceImpl.class) -public class ExpenseApplyServiceImplTest extends BaseDbUnitTest { - - @Resource - private ExpenseApplyServiceImpl expenseApplyService; - - @Resource - private ExpenseApplyMapper expenseApplyMapper; - - @Test - public void testCreateExpenseApply_success() { - // 准备参数 - ExpenseApplyCreateReqVO reqVO = randomPojo(ExpenseApplyCreateReqVO.class); - - // 调用 -// Long expenseApplyId = expenseApplyService.createExpenseApply(reqVO); -// // 断言 -// assertNotNull(expenseApplyId); -// // 校验记录的属性是否正确 -// ExpenseApplyDO expenseApply = expenseApplyMapper.selectById(expenseApplyId); -// assertPojoEquals(reqVO, expenseApply); - } - - @Test - public void testUpdateExpenseApply_success() { - // mock 数据 - ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class); - expenseApplyMapper.insert(dbExpenseApply);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ExpenseApplyUpdateReqVO reqVO = randomPojo(ExpenseApplyUpdateReqVO.class, o -> { - o.setId(dbExpenseApply.getId()); // 设置更新的 ID - }); - - // 调用 - expenseApplyService.updateExpenseApply(reqVO); - // 校验是否更新正确 - ExpenseApplyDO expenseApply = expenseApplyMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, expenseApply); - } - - @Test - public void testUpdateExpenseApply_notExists() { - // 准备参数 - ExpenseApplyUpdateReqVO reqVO = randomPojo(ExpenseApplyUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> expenseApplyService.updateExpenseApply(reqVO), EXPENSE_APPLY_NOT_EXISTS); - } - - @Test - public void testDeleteExpenseApply_success() { - // mock 数据 - ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class); - expenseApplyMapper.insert(dbExpenseApply);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbExpenseApply.getId(); - - // 调用 - expenseApplyService.deleteExpenseApply(id); - // 校验数据不存在了 - assertNull(expenseApplyMapper.selectById(id)); - } - - @Test - public void testDeleteExpenseApply_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> expenseApplyService.deleteExpenseApply(id), EXPENSE_APPLY_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetExpenseApplyPage() { - // mock 数据 - ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class, o -> { // 等会查询到 - o.setBillType(null); - o.setApplyNo(null); - o.setUserId(null); - o.setNickname(null); - o.setDeptId(null); - o.setDeptName(null); - o.setProjectName(null); - o.setReason(null); - o.setAmount(null); - o.setStatus(null); - o.setRemark(null); - o.setFiles(null); - o.setCreateBy(null); - o.setCreateTime(null); - o.setUpdateBy(null); - }); - expenseApplyMapper.insert(dbExpenseApply); - // 测试 billType 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setBillType(null))); - // 测试 applyNo 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setApplyNo(null))); - // 测试 userId 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUserId(null))); - // 测试 nickname 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setNickname(null))); - // 测试 deptId 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptId(null))); - // 测试 deptName 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptName(null))); - // 测试 projectName 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setProjectName(null))); - // 测试 reason 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setReason(null))); - // 测试 amount 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setAmount(null))); - // 测试 status 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setStatus(null))); - // 测试 remark 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setRemark(null))); - // 测试 files 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setFiles(null))); - // 测试 createBy 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateBy(null))); - // 测试 createTime 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateTime(null))); - // 测试 updateBy 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUpdateBy(null))); - // 准备参数 - ExpenseApplyPageReqVO reqVO = new ExpenseApplyPageReqVO(); - reqVO.setBillType(null); - reqVO.setApplyNo(null); - reqVO.setUserId(null); - reqVO.setNickname(null); - reqVO.setDeptId(null); - reqVO.setDeptName(null); - reqVO.setProjectName(null); - reqVO.setReason(null); - reqVO.setAmount(null); - reqVO.setStatus(null); - reqVO.setRemark(null); - reqVO.setFiles(null); - reqVO.setCreateBy(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setUpdateBy(null); - - // 调用 - PageResult pageResult = expenseApplyService.getExpenseApplyPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbExpenseApply, pageResult.getList().get(0)); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetExpenseApplyList() { - // mock 数据 - ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class, o -> { // 等会查询到 - o.setBillType(null); - o.setApplyNo(null); - o.setUserId(null); - o.setNickname(null); - o.setDeptId(null); - o.setDeptName(null); - o.setProjectName(null); - o.setReason(null); - o.setAmount(null); - o.setStatus(null); - o.setRemark(null); - o.setFiles(null); - o.setCreateBy(null); - o.setCreateTime(null); - o.setUpdateBy(null); - }); - expenseApplyMapper.insert(dbExpenseApply); - // 测试 billType 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setBillType(null))); - // 测试 applyNo 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setApplyNo(null))); - // 测试 userId 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUserId(null))); - // 测试 nickname 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setNickname(null))); - // 测试 deptId 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptId(null))); - // 测试 deptName 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptName(null))); - // 测试 projectName 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setProjectName(null))); - // 测试 reason 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setReason(null))); - // 测试 amount 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setAmount(null))); - // 测试 status 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setStatus(null))); - // 测试 remark 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setRemark(null))); - // 测试 files 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setFiles(null))); - // 测试 createBy 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateBy(null))); - // 测试 createTime 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateTime(null))); - // 测试 updateBy 不匹配 - expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUpdateBy(null))); - // 准备参数 - ExpenseApplyExportReqVO reqVO = new ExpenseApplyExportReqVO(); - reqVO.setBillType(null); - reqVO.setApplyNo(null); - reqVO.setUserId(null); - reqVO.setNickname(null); - reqVO.setDeptId(null); - reqVO.setDeptName(null); - reqVO.setProjectName(null); - reqVO.setReason(null); - reqVO.setAmount(null); - reqVO.setStatus(null); - reqVO.setRemark(null); - reqVO.setFiles(null); - reqVO.setCreateBy(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setUpdateBy(null); - - // 调用 - List list = expenseApplyService.getExpenseApplyList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbExpenseApply, list.get(0)); - } - -} diff --git a/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/invoice/InvoiceServiceImplTest.java b/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/invoice/InvoiceServiceImplTest.java deleted file mode 100644 index 71d5c516..00000000 --- a/yudao-module-bs/yudao-module-bs-biz/src/test/java/cn/iocoder/yudao/module/bs/service/invoice/InvoiceServiceImplTest.java +++ /dev/null @@ -1,263 +0,0 @@ -package cn.iocoder.yudao.module.bs.service.invoice; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.*; -import cn.iocoder.yudao.module.bs.dal.dataobject.invoice.InvoiceDO; -import cn.iocoder.yudao.module.bs.dal.mysql.invoice.InvoiceMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link InvoiceServiceImpl} 的单元测试类 - * - * @author chenqp - */ -@Import(InvoiceServiceImpl.class) -public class InvoiceServiceImplTest extends BaseDbUnitTest { - - @Resource - private InvoiceServiceImpl invoiceService; - - @Resource - private InvoiceMapper invoiceMapper; - - @Test - public void testCreateInvoice_success() { - // 准备参数 - InvoiceCreateReqVO reqVO = randomPojo(InvoiceCreateReqVO.class); - - // 调用 - Long invoiceId = invoiceService.createInvoice(reqVO); - // 断言 - assertNotNull(invoiceId); - // 校验记录的属性是否正确 - InvoiceDO invoice = invoiceMapper.selectById(invoiceId); - assertPojoEquals(reqVO, invoice); - } - - @Test - public void testUpdateInvoice_success() { - // mock 数据 - InvoiceDO dbInvoice = randomPojo(InvoiceDO.class); - invoiceMapper.insert(dbInvoice);// @Sql: 先插入出一条存在的数据 - // 准备参数 - InvoiceUpdateReqVO reqVO = randomPojo(InvoiceUpdateReqVO.class, o -> { - o.setId(dbInvoice.getId()); // 设置更新的 ID - }); - - // 调用 - invoiceService.updateInvoice(reqVO); - // 校验是否更新正确 - InvoiceDO invoice = invoiceMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, invoice); - } - - @Test - public void testUpdateInvoice_notExists() { - // 准备参数 - InvoiceUpdateReqVO reqVO = randomPojo(InvoiceUpdateReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> invoiceService.updateInvoice(reqVO), INVOICE_NOT_EXISTS); - } - - @Test - public void testDeleteInvoice_success() { - // mock 数据 - InvoiceDO dbInvoice = randomPojo(InvoiceDO.class); - invoiceMapper.insert(dbInvoice);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbInvoice.getId(); - - // 调用 - invoiceService.deleteInvoice(id); - // 校验数据不存在了 - assertNull(invoiceMapper.selectById(id)); - } - - @Test - public void testDeleteInvoice_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> invoiceService.deleteInvoice(id), INVOICE_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetInvoicePage() { - // mock 数据 - InvoiceDO dbInvoice = randomPojo(InvoiceDO.class, o -> { // 等会查询到 - o.setFiles(null); - o.setCreateBy(null); - o.setCreateTime(null); - o.setUpdateBy(null); - o.setInvoiceType(null); - o.setInvoiceCode(null); - o.setInvoiceNum(null); - o.setInvoiceDate(null); - o.setSeller(null); - o.setTaxAmount(null); - o.setExcludingTaxAmount(null); - o.setTotalAmount(null); - o.setDeptId(null); - o.setDeptName(null); - o.setRemark(null); - }); - invoiceMapper.insert(dbInvoice); - // 测试 files 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setFiles(null))); - // 测试 createBy 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateBy(null))); - // 测试 createTime 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateTime(null))); - // 测试 updateBy 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setUpdateBy(null))); - // 测试 invoiceType 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceType(null))); - // 测试 invoiceCode 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceCode(null))); - // 测试 invoiceNum 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceNum(null))); - // 测试 invoiceDate 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceDate(null))); - // 测试 seller 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setSeller(null))); - // 测试 taxAmount 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTaxAmount(null))); - // 测试 excludingTaxAmount 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setExcludingTaxAmount(null))); - // 测试 totalAmount 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTotalAmount(null))); - // 测试 deptId 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptId(null))); - // 测试 deptName 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptName(null))); - // 测试 remark 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setRemark(null))); - // 准备参数 - InvoicePageReqVO reqVO = new InvoicePageReqVO(); - reqVO.setFiles(null); - reqVO.setCreateBy(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setUpdateBy(null); - reqVO.setInvoiceType(null); - reqVO.setInvoiceCode(null); - reqVO.setInvoiceNum(null); - reqVO.setInvoiceDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setSeller(null); - reqVO.setTaxAmount(null); - reqVO.setExcludingTaxAmount(null); - reqVO.setTotalAmount(null); - reqVO.setDeptId(null); - reqVO.setDeptName(null); - reqVO.setRemark(null); - - // 调用 - PageResult pageResult = invoiceService.getInvoicePage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbInvoice, pageResult.getList().get(0)); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetInvoiceList() { - // mock 数据 - InvoiceDO dbInvoice = randomPojo(InvoiceDO.class, o -> { // 等会查询到 - o.setFiles(null); - o.setCreateBy(null); - o.setCreateTime(null); - o.setUpdateBy(null); - o.setInvoiceType(null); - o.setInvoiceCode(null); - o.setInvoiceNum(null); - o.setInvoiceDate(null); - o.setSeller(null); - o.setTaxAmount(null); - o.setExcludingTaxAmount(null); - o.setTotalAmount(null); - o.setDeptId(null); - o.setDeptName(null); - o.setRemark(null); - }); - invoiceMapper.insert(dbInvoice); - // 测试 files 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setFiles(null))); - // 测试 createBy 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateBy(null))); - // 测试 createTime 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateTime(null))); - // 测试 updateBy 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setUpdateBy(null))); - // 测试 invoiceType 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceType(null))); - // 测试 invoiceCode 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceCode(null))); - // 测试 invoiceNum 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceNum(null))); - // 测试 invoiceDate 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceDate(null))); - // 测试 seller 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setSeller(null))); - // 测试 taxAmount 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTaxAmount(null))); - // 测试 excludingTaxAmount 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setExcludingTaxAmount(null))); - // 测试 totalAmount 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTotalAmount(null))); - // 测试 deptId 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptId(null))); - // 测试 deptName 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptName(null))); - // 测试 remark 不匹配 - invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setRemark(null))); - // 准备参数 - InvoiceExportReqVO reqVO = new InvoiceExportReqVO(); - reqVO.setFiles(null); - reqVO.setCreateBy(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setUpdateBy(null); - reqVO.setInvoiceType(null); - reqVO.setInvoiceCode(null); - reqVO.setInvoiceNum(null); - reqVO.setInvoiceDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setSeller(null); - reqVO.setTaxAmount(null); - reqVO.setExcludingTaxAmount(null); - reqVO.setTotalAmount(null); - reqVO.setDeptId(null); - reqVO.setDeptName(null); - reqVO.setRemark(null); - - // 调用 - List list = invoiceService.getInvoiceList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbInvoice, list.get(0)); - } - -} diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 04fd67c7..9c506d42 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -150,6 +150,7 @@ logging: level: # 配置自己写的 MyBatis Mapper 打印日志 cn.iocoder.yudao.module.bpm.dal.mysql: debug + cn.iocoder.yudao.module.bs.dal.mysql: debug cn.iocoder.yudao.module.infra.dal.mysql: debug cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper: INFO # 配置 JobLogMapper 的日志级别为 info cn.iocoder.yudao.module.pay.dal.mysql: debug From 286fc5b74aacbcae86965204fb9f6cac68b1a8c2 Mon Sep 17 00:00:00 2001 From: chenqp <965586934@qq.com> Date: Wed, 2 Aug 2023 00:05:24 +0800 Subject: [PATCH 7/7] =?UTF-8?q?feat:=20=E7=94=B3=E8=AF=B7=E5=8D=95?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../expenseapply/ExpenseApplyController.java | 2 ++ .../expenseapply/ExpenseApplyService.java | 1 + .../expenseapply/ExpenseApplyServiceImpl.java | 28 +++++++++++---- .../message/BpmMessageServiceImpl.java | 36 +++++++++---------- .../vo/ExpenseApplyTripBaseVO.java | 15 ++++---- .../expenseapply/ExpenseApplyDO.java | 6 ++++ .../expenseapplytrip/ExpenseApplyTripDO.java | 19 +++++----- 7 files changed, 64 insertions(+), 43 deletions(-) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java index 9a39031f..0801a9a3 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/expenseapply/ExpenseApplyController.java @@ -67,6 +67,8 @@ public class ExpenseApplyController { queryWrapper.eq(ExpenseApplyTripDO::getApplyId, expenseApply.getId()); List list = expenseApplyTripService.list(queryWrapper); expenseApply.setExpenseApplyTrips(list); + //cqptodo 需要设置用户名,部门返回前端 +// expenseApplyService.setRepField(expenseApply); } return success(expenseApply); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java index 93b16e24..f252e6e5 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyService.java @@ -71,4 +71,5 @@ public interface ExpenseApplyService extends IService { List getExpenseApplyList(ExpenseApplyExportReqVO exportReqVO); void processInstanceCallBack(long id, Integer result); + } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java index a4f3d574..15f47cb2 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/expenseapply/ExpenseApplyServiceImpl.java @@ -3,9 +3,12 @@ package cn.iocoder.yudao.module.bpm.service.expenseapply; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.RandomUtil; +import cn.iocoder.yudao.framework.common.exception.ErrorCode; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; @@ -32,6 +35,7 @@ import javax.annotation.Resource; import javax.validation.Validator; import java.math.BigDecimal; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -58,7 +62,7 @@ public class ExpenseApplyServiceImpl extends ServiceImpl().eq(ExpenseApplyTripDO::getApplyId, expenseApply.getId())); + expenseApplyTripService.saveBatch(trips); } if (expenseApply.getStatus().equals(ExpenseApplyStatusEnum.PROCESS.getValue())) { - Map variables = BeanUtil.beanToMap(expenseApply); - //cqptodo 提交单据,创建工作流 + Map variables = new HashMap<>(); + variables.put("billType", expenseApply.getBillType()); + variables.put("amount", expenseApply.getAmount()); + variables.put("deptId", expenseApply.getDeptId()); String processInstanceId = processInstanceApi.createProcessInstance(expenseApply.getUserId(), new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) .setVariables(variables).setBusinessKey(String.valueOf(expenseApply.getId()))); - //cqptodo 待测试是否会更新其它字段 将工作流的编号,更新到单据中 updateById(new ExpenseApplyDO().setId(expenseApply.getId()).setProcessInstanceId(processInstanceId)); } // 返回 @@ -120,7 +128,7 @@ public class ExpenseApplyServiceImpl extends ServiceImpl().eq(ExpenseApplyTripDO::getApplyId, apply.getId())); } private ExpenseApplyDO validateExpenseApplyExists(Long id) { diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java index 03237015..90c47763 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java @@ -33,32 +33,32 @@ public class BpmMessageServiceImpl implements BpmMessageService { @Override public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams)); +// Map templateParams = new HashMap<>(); +// templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); +// templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); +// smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), +// BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams)); } @Override public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("reason", reqDTO.getReason()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams)); +// Map templateParams = new HashMap<>(); +// templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); +// templateParams.put("reason", reqDTO.getReason()); +// templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); +// smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), +// BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams)); } @Override public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("taskName", reqDTO.getTaskName()); - templateParams.put("startUserNickname", reqDTO.getStartUserNickname()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(), - BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)); +// Map templateParams = new HashMap<>(); +// templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); +// templateParams.put("taskName", reqDTO.getTaskName()); +// templateParams.put("startUserNickname", reqDTO.getStartUserNickname()); +// templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); +// smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(), +// BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)); } private String getProcessInstanceDetailUrl(String taskId) { diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java index ba881b44..2eb69273 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/controller/admin/expenseapplytrip/vo/ExpenseApplyTripBaseVO.java @@ -1,17 +1,14 @@ package cn.iocoder.yudao.module.bs.controller.admin.expenseapplytrip.vo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.math.BigDecimal; -import java.math.BigDecimal; -import javax.validation.constraints.*; +import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.Set; + import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; /** diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java index d9b87f50..a43bcfa3 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapply/ExpenseApplyDO.java @@ -91,4 +91,10 @@ public class ExpenseApplyDO extends TenantBaseDO { @TableField(exist = false) private List expenseApplyTrips; + @TableField(exist = false) + private Boolean deleted; + @TableField(exist = false) + private String nickname; + @TableField(exist = false) + private String detpName; } diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java index 969500de..bed5db48 100644 --- a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java +++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/dal/dataobject/expenseapplytrip/ExpenseApplyTripDO.java @@ -3,17 +3,17 @@ package cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip; import cn.iocoder.yudao.framework.common.pojo.ImageVo; import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +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.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.math.BigDecimal; + import java.math.BigDecimal; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Set; /** * 申请单行程明细 DO @@ -91,5 +91,6 @@ public class ExpenseApplyTripDO extends TenantBaseDO { * 预计费用 */ private BigDecimal amount; - + @TableField(exist = false) + private Boolean deleted; }