Pārlūkot izejas kodu

添加编码生成功能

ljy121 1 gadu atpakaļ
vecāks
revīzija
326ab20970

+ 8 - 4
zjugis-business/src/main/java/com/zjugis/business/controller/CommonController.java

@@ -2,13 +2,13 @@ package com.zjugis.business.controller;
 
 import com.zjugis.business.service.CommonService;
 import com.zjugis.framework.common.pojo.CommonResult;
+import com.zjugis.framework.workflow.model.SerialNumberDto;
 import com.zjugis.framework.workflow.rpc.remote.WorkflowClient;
 import com.zjugis.framework.workflow.utils.zTree;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.List;
 
 /**
@@ -46,9 +46,13 @@ public class CommonController {
         return CommonResult.success(commonService.getProjectTypeZTree());
     }
 
-
     @GetMapping("/area-tree")
     public CommonResult<List<zTree>> areaTree() {
         return CommonResult.success(commonService.getAreaTree());
     }
+
+    @PostMapping("/generate-serial-number")
+    public CommonResult<String> serialNumber(@Valid @RequestBody SerialNumberDto serialNumberDto) {
+        return CommonResult.success(commonService.serialNumber(serialNumberDto));
+    }
 }

+ 3 - 0
zjugis-business/src/main/java/com/zjugis/business/service/CommonService.java

@@ -1,5 +1,6 @@
 package com.zjugis.business.service;
 
+import com.zjugis.framework.workflow.model.SerialNumberDto;
 import com.zjugis.framework.workflow.utils.zTree;
 
 import java.util.List;
@@ -19,4 +20,6 @@ public interface CommonService {
     String getUserTree();
 
     String getAssigneeTree(String deptId);
+
+    String serialNumber(SerialNumberDto serialNumberDto);
 }

+ 10 - 0
zjugis-business/src/main/java/com/zjugis/business/service/impl/CommonServiceImpl.java

@@ -6,6 +6,7 @@ import com.zjugis.business.service.CommonService;
 import com.zjugis.business.service.ProjectTypeService;
 import com.zjugis.framework.common.exception.ServiceException;
 import com.zjugis.framework.common.pojo.CommonResult;
+import com.zjugis.framework.workflow.model.SerialNumberDto;
 import com.zjugis.framework.workflow.rpc.remote.WorkflowClient;
 import com.zjugis.framework.workflow.utils.zTree;
 import com.zjugis.module.system.api.area.dto.AreaNodeRespVO;
@@ -73,6 +74,15 @@ public class CommonServiceImpl implements CommonService {
         return workflowClient.getDepartmentTree(deptId);
     }
 
+    /**
+     * @param serialNumberDto
+     * @return
+     */
+    @Override
+    public String serialNumber(SerialNumberDto serialNumberDto) {
+        return workflowClient.getFlowNumByName(serialNumberDto);
+    }
+
     private void convertProjectType2Ztree(List<ProjectTypeNode> tree, String pid,List<zTree>  zTrees){
         for (ProjectTypeNode projectTypeNode : tree) {
             zTree node = new zTree();

+ 3 - 1
zjugis-business/src/main/resources/templates/FlowContract/apply.ftl

@@ -38,7 +38,9 @@
                             <div class="form-item">
                                 <div class="z-comp-input" name="contract$contractNumber">
                                     <input type="text" value="${formEntity.contractNumber!}">
-                                    <button name="numberBtn">生成</button>
+                                </div>
+                                <div id="generateSerial" style="width: 50px; float: right;">
+                                    <div class="btn btn-sm btn-primary">生成</div>
                                 </div>
                             </div>
                         </div>

+ 22 - 0
zjugis-framework/zjugis-spring-boot-starter-workflow/src/main/java/com/zjugis/framework/workflow/model/SerialNumberDto.java

@@ -0,0 +1,22 @@
+package com.zjugis.framework.workflow.model;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.util.Map;
+
+/**
+ * @author ljy
+ * @version 1.0
+ * @date 2023/12/6 18:08
+ */
+@Data
+public class SerialNumberDto {
+
+    @NotBlank
+    private String name;
+
+    private Map<String,String> params;
+
+    private Integer iPreview;
+}

+ 5 - 0
zjugis-framework/zjugis-spring-boot-starter-workflow/src/main/java/com/zjugis/framework/workflow/rpc/remote/WorkflowClient.java

@@ -2,9 +2,11 @@ package com.zjugis.framework.workflow.rpc.remote;
 
 import com.zjugis.framework.common.pojo.CommonResult;
 import com.zjugis.framework.workflow.model.IFlowInstance;
+import com.zjugis.framework.workflow.model.SerialNumberDto;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
 /**
@@ -37,4 +39,7 @@ public interface WorkflowClient {
     @PostMapping("/ProcessEngineApi/saveFlowDescribe")
     String saveFlowDescribe(@RequestParam("flowInstanceId") String flowInstanceId,@RequestParam("describe") String describe);
 
+    @PostMapping("/CodeTemplateServiceApi/getFlowNumByName")
+    String getFlowNumByName(@RequestBody SerialNumberDto serialNumberDto);
+
 }

+ 51 - 0
zjugis-workflow/src/main/java/com/zjugis/z_workflow/serviceApi/CodeTemplateServiceApiController.java

@@ -0,0 +1,51 @@
+package com.zjugis.z_workflow.serviceApi;
+
+import com.alibaba.fastjson2.JSON;
+import com.zjugis.framework.workflow.model.BaseController;
+import com.zjugis.framework.workflow.model.SerialNumberDto;
+import com.zjugis.z_workflow.service.CodeTemplateService;
+import com.zjugis.z_workflow.service.ObsoleteNumRecyclingService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+
+
+@RestController
+public class CodeTemplateServiceApiController extends BaseController {
+
+    @Autowired
+    private CodeTemplateService codeTemplateService;
+    @Autowired
+    private ObsoleteNumRecyclingService obsoleteNumRecyclingService;
+
+    /**
+     * 根据编码模板名称和编码参数生成编码
+     */
+    //            "    /**\n" +
+//                    "     * 业务编码生成调用示例\n" +
+//                    "     */\n" +
+//                    "    private void callExample() {\n" +
+//                    "       //编码模板:\"测试模板1_\"+{systemName}+\"_\"+FlowNum(1,4,'0',\"林业审批{districtCode}\",0)\n" +
+//                    "       //编码参数\n" +
+//                    "       Map<String, String> mapParam = new HashMap<>();\n" +
+//                    "       mapParam.put(\"id\", \"id\");//编码模板ID\n" +
+//                    "       //动态参数(没有动态参数,可不传)\n" +
+//                    "       Map<String, String> dynamicParam = new HashMap<>();\n" +
+//                    "       dynamicParam.put(\"systemName\", \"测试系统\");//对应编码模板系统变量{systemName}\n" +
+//                    "       dynamicParam.put(\"districtCode\", \"320201\");//对应编码模板系统变量{districtCode}\n" +
+//                    "       mapParam.put(\"codeParam\", JSON.toJSONString(dynamicParam));\n" +
+//                    "       //是否预览模式(1:预览模式 0或不传:非预览模式)\n" +
+//                    "       mapParam.put(\"iPreview\", \"0\");\n" +
+//                    "       //接口Url\n" +
+//                    "       String apiUrl = YamlConfig.getValue(\"application-project.yml\",\"serviceUrl.z_bussiness_commom\") + \"CodeTemplateServiceApi/getFlowNumByName\";\n" +
+//                    "       //调用接口获取数据\n" +
+//                    "       String result = ServiceApiUtils.getDataFromServiceApi(apiUrl, mapParam);\n" +
+//                    "    }"
+    @PostMapping
+    public String getFlowNumByName(@Valid @RequestBody  SerialNumberDto serialNumberDto) throws Exception {
+        return codeTemplateService.getFlowNumByName(serialNumberDto.getName(), JSON.toJSONString(serialNumberDto.getParams()), serialNumberDto.getIPreview());
+    }
+}