From 66fc2a190769a74c9f8e6b16a465ecac80e5a6ef Mon Sep 17 00:00:00 2001 From: "LAPTOP-0SF788NU\\admin" <3306174053@qq.com> Date: Mon, 9 Oct 2023 13:39:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=89=B9=E6=B5=81=E7=A8=8B=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0,=E5=85=83?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/flow/FlowController.java | 65 ++++++++++++++++++- .../controller/admin/flow/vo/FlowBaseVO.java | 3 + .../admin/flow/vo/FlowPageReqVO.java | 3 + .../archives/dal/dataobject/flow/FlowDO.java | 8 +++ 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/FlowController.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/FlowController.java index 99de09bd..ea53687f 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/FlowController.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/FlowController.java @@ -1,5 +1,9 @@ package cn.iocoder.yudao.module.archives.controller.admin.flow; +import cn.iocoder.yudao.module.infra.service.file.FileService; +import cn.iocoder.yudao.module.setting.service.passwords.PasswordsService; +import com.alibaba.druid.util.StringUtils; +import com.alibaba.fastjson.JSONObject; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -8,9 +12,10 @@ import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Operation; -import javax.validation.constraints.*; import javax.validation.*; import javax.servlet.http.*; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.io.IOException; @@ -27,6 +32,8 @@ import cn.iocoder.yudao.module.archives.controller.admin.flow.vo.*; import cn.iocoder.yudao.module.archives.dal.dataobject.flow.FlowDO; import cn.iocoder.yudao.module.archives.convert.flow.FlowConvert; import cn.iocoder.yudao.module.archives.service.flow.FlowService; +import org.springframework.web.multipart.MultipartFile; +import sun.security.util.Password; @Tag(name = "管理后台 - 审批流程") @RestController @@ -37,6 +44,13 @@ public class FlowController { @Resource private FlowService flowService; + @Resource + private FileService fileService; + + @Resource + private PasswordsService passwordsService; + + @PostMapping("/create") @Operation(summary = "创建审批流程") @PreAuthorize("@ss.hasPermission('archives:flow:create')") @@ -44,6 +58,55 @@ public class FlowController { return success(flowService.createFlow(createReqVO)); } + + /** + * 账簿上传 + */ + @PostMapping("/upload") + @Operation(summary = "上传审批流程图") + @PreAuthorize("@ss.hasPermission('archives:flow:create')") + public Long uploadAccountingBook(@RequestPart("multipartFile") MultipartFile multipartFile) { + FlowCreateReqVO vo = new FlowCreateReqVO(); + try { + String uri = fileService.createFile(multipartFile.getName(), multipartFile.getOriginalFilename(), multipartFile.getBytes()); + vo.setSuffix(multipartFile.getOriginalFilename()) + .setFileUrl(uri) + .setFileAp(uri) + .setFlowCode(execute()); + }catch (Exception e){ + e.printStackTrace(); + } + return flowService.createFlow(vo); + } + + /** + * 填值规则Demo:生成订单号 + * 【测试示例】 + */ + public String execute(){ + String prefix = "LC"; + //订单前缀默认为CN 如果规则参数不为空,则取自定义前缀 + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); + String formatDateTime = now.format(formatter); + String value = prefix + formatDateTime; + // 根据formData的值的不同,生成不同的订单号 + if (!StringUtils.isEmpty(formatDateTime)) { + value += formatDateTime; + } + return value; + } + + @GetMapping("/downloadXml") + @Operation(summary = "获得审批流程分页") + @PreAuthorize("@ss.hasPermission('archives:accounting-report:query')") + public void getAccountingReportPage(@Valid FlowPageReqVO pageVO, HttpServletResponse response) throws IOException { + PageResult pageResult = flowService.getFlowPage(pageVO); + PageResult voPageResult = FlowConvert.INSTANCE.convertPage(pageResult); + String jsonString = JSONObject.toJSONString(voPageResult); + passwordsService.jsonToXmlConverter(response,pageVO.getInputPassword(),jsonString); + } + @PutMapping("/update") @Operation(summary = "更新审批流程") @PreAuthorize("@ss.hasPermission('archives:flow:update')") diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/vo/FlowBaseVO.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/vo/FlowBaseVO.java index f75e68f6..d5b4d2ba 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/vo/FlowBaseVO.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/vo/FlowBaseVO.java @@ -66,4 +66,7 @@ public class FlowBaseVO { @Schema(description = "归档状态") private String archiveState; + @Schema(description = "密码") + String inputPassword; + } diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/vo/FlowPageReqVO.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/vo/FlowPageReqVO.java index db349231..2f2c1e46 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/vo/FlowPageReqVO.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/controller/admin/flow/vo/FlowPageReqVO.java @@ -70,4 +70,7 @@ public class FlowPageReqVO extends PageParam { @Schema(description = "归档状态") private String archiveState; + @Schema(description = "密码") + String inputPassword; + } diff --git a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/flow/FlowDO.java b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/flow/FlowDO.java index 15e3b711..6508ef5f 100644 --- a/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/flow/FlowDO.java +++ b/yudao-module-archives/yudao-module-archives-biz/src/main/java/cn/iocoder/yudao/module/archives/dal/dataobject/flow/FlowDO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.archives.dal.dataobject.flow; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; import java.time.LocalDateTime; @@ -7,6 +8,7 @@ import java.time.LocalDateTime; import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.*; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import lombok.experimental.Accessors; /** * 审批流程 DO @@ -16,6 +18,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; @TableName("archives_flow") @KeySequence("archives_flow_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data +@Accessors(chain = true) @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @Builder @@ -97,4 +100,9 @@ public class FlowDO extends BaseDO { */ private String archiveState; + /** + * 密码 + */ + String password; + }