Browse Source

衫泰项目

lfx 1 year ago
parent
commit
4f5eb3a664

+ 15 - 13
mjava-santai/pom.xml

@@ -4,22 +4,16 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.2.0.RELEASE</version> <!-- 使用最新的稳定版或其他适用版本 -->
+    </parent>
+
     <groupId>com.malk.santai</groupId>
     <artifactId>mjava-santai</artifactId>
     <version>1.0-SNAPSHOT</version>
 
-    <dependencyManagement>
-        <dependencies>
-            <!-- SpringBoot 依赖 -->
-            <dependency>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-dependencies</artifactId>
-                <version>2.2.13.RELEASE</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-        </dependencies>
-    </dependencyManagement>
     <dependencies>
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -43,7 +37,7 @@
     </dependencies>
 
     <build>
-        <finalName>santai</finalName>
+        <finalName>shantai</finalName>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
@@ -55,6 +49,14 @@
                     <encoding>UTF-8</encoding>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <executable>true</executable>
+                    <includeSystemScope>true</includeSystemScope>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 

+ 16 - 0
mjava-santai/src/main/java/com/malk/santai/config/StEkbConfig.java

@@ -0,0 +1,16 @@
+package com.malk.santai.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ConfigurationProperties(prefix = "ekb")
+@Data
+public class StEkbConfig {
+
+    private String preUrl;
+    private String appKey;
+    private String appSecurity;
+
+}

+ 7 - 0
mjava-santai/src/main/java/com/malk/santai/controller/TestController.java

@@ -0,0 +1,7 @@
+package com.malk.santai.controller;
+
+import com.malk.server.dingtalk.crypto.DingCallbackCrypto;
+
+public class TestController {
+
+}

+ 49 - 0
mjava-santai/src/main/java/com/malk/santai/event/StDingEventImpl.java

@@ -0,0 +1,49 @@
+package com.malk.santai.event;
+
+import com.malk.delegate.DDEvent;
+import com.malk.santai.service.StDingProcService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+@Primary
+public class StDingEventImpl implements DDEvent {
+
+    @Autowired
+    private StDingProcService stDingProcService;
+
+    // 付款单流程CODE
+    private static String DING_PROC_FKD_CODE="PROC-EF26A43D-1A5D-41A6-80F4-265FF373236D";
+
+    @Override
+    public void executeEvent_Task_Finish(String processInstanceId, String processCode, boolean isAgree, String remark) {
+        // 审批任务回调执行业务逻辑
+        log.info("衫泰审批任务完成回调,processInstanceId:{},processCode{}",processInstanceId,processCode);
+        if(DING_PROC_FKD_CODE.equals(processCode)&&isAgree){
+            stDingProcService.fkdSync(processInstanceId);
+        }
+    }
+
+    @Override
+    public void executeEvent_Task_Start(String processInstanceId, String processCode) {
+
+    }
+
+    @Override
+    public void executeEvent_Task_Redirect(String processInstanceId, String processCode) {
+
+    }
+
+    @Override
+    public void executeEvent_Instance_Finish(String processInstanceId, String processCode, boolean isAgree, boolean isTerminate, String staffId) {
+
+    }
+
+    @Override
+    public void executeEvent_Instance_Start(String processInstanceId, String processCode) {
+
+    }
+}

+ 7 - 0
mjava-santai/src/main/java/com/malk/santai/service/StDingProcService.java

@@ -0,0 +1,7 @@
+package com.malk.santai.service;
+
+public interface StDingProcService {
+
+    void fkdSync(String procInstId);
+
+}

+ 57 - 0
mjava-santai/src/main/java/com/malk/santai/service/impl/StDingProcServiceImpl.java

@@ -0,0 +1,57 @@
+package com.malk.santai.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.malk.santai.service.StDingProcService;
+import com.malk.service.dingtalk.DDClient;
+import com.malk.service.dingtalk.DDClient_Workflow;
+import com.malk.utils.UtilMap;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+@Slf4j
+public class StDingProcServiceImpl implements StDingProcService {
+
+    @Autowired
+    private DDClient_Workflow ddClient_workflow;
+    @Autowired
+    private DDClient ddClient;
+
+    @Override
+    public void fkdSync(String procInstId) {
+        Map map=ddClient_workflow.getProcessInstanceId(ddClient.getAccessToken(),procInstId);
+        log.info("map:{}",map);
+        Map rule=new HashMap();
+        rule.put("TextField-K11U6U5Q","付款事由");// 标题/付款摘要
+        rule.put("RecipientAccountField-K11U6U5P","收款信息");// 收款信息
+        rule.put("MoneyField_FMP7OAX3TZ40","付款金额");// 付款金额
+        Map data=getData(map,rule);
+        data.put("户名", UtilMap.getMap(data,"收款信息").get("name"));// 户名
+        data.put("银行",UtilMap.getMap(data,"收款信息").get("instName"));// 银行
+        data.put("支行信息",UtilMap.getMap(data,"收款信息").get("instBranchName"));// 支行信息
+        data.put("账号",UtilMap.getMap(data,"收款信息").get("cardNo"));// 账号
+        log.info("data:{}",JSONObject.toJSONString(data));
+    }
+
+
+    public Map getData(Map instance,Map rule){
+        Map resultMap=new HashMap();
+        List<Map> list=(List<Map>) instance.get("formComponentValues");
+        for (Map map:list) {
+            if(rule.containsKey(String.valueOf(map.get("id")))){
+                String componentType=String.valueOf(map.get("componentType"));
+                if(componentType.equals("RecipientAccountField")){
+                    resultMap.put(rule.get(String.valueOf(map.get("id"))),JSONObject.parseObject(String.valueOf(map.get("extValue"))));
+                }else{
+                    resultMap.put(rule.get(String.valueOf(map.get("id"))),map.get("value"));
+                }
+            }
+        }
+        return resultMap;
+    }
+}

+ 20 - 16
mjava-santai/src/main/resources/application-dev.yml

@@ -1,31 +1,35 @@
 server:
-  port: 9020
+  port: 8112
   servlet:
-    context-path: /kkl
+    context-path: /tianhe
 
 enable:
   scheduling: false
 logging:
   config: classpath:logback-spring.xml
-  path: /home/server/connect/canrui/log/
+  path: /home/server/shantai/log/
   level:
-    com.zitoo.connect.*: debug
+    com.malk.*: debug
 
 # dingtalk
 dingtalk:
-  agentId: 2691784047
-  appKey: dinghbynhnd2dbgypmsa
-  appSecret: Kl5Xw8x0TlEIlvcJuUkYZD18UTTShJmfdKrAIpY8oX-Q_tazyUKA28nQh7dG5-mq
-  corpId: dingcc1b1ffad0d5ca1d
-  aesKey:
-  token:
+  agentId: 3088485347
+  appKey: dingryt7ulefpiziveoj
+  appSecret: qBdVqoK1UP9J3yN0ulaKuBmse4nrZPfNbVxjLGjaODGoRqbtws0__f3A5GpD5bLz
+  corpId: ding2c2e3f1dbf2b3ffebc961a6cb783455b
+  aesKey: uCSTfCFVU18QJjECfZTBWyC9mi10qqY1Spuqjl4ghct
+  token: Adib7WsRXHYrLGkOAUNcgl6gLY9nBIIaeprkhfmxGg6ca6atYWWKDkuE
 # teambition
 teambition:
-  AppID: 63589b8bb6803e162f9a57d8
-  AppSecret: 5mB3b73OFhSwo38xEVqahCLwQVhG1MW3
-  TenantId: 5ca44db8ca4fd40001b10559
-  OperatorId: 5e698cca21f5ad70dfba7d2b    # 公共账号, 需要有操作权限 [牧语]
+  AppID:
+  AppSecret:
+  TenantId:
+  OperatorId:    # 公共账号, 需要有操作权限 [牧语]
 # aliwork
 aliwork:
-  appType: APP_OHSG8KMIP9SGXV32XUQJ
-  systemToken: 9F766B81QHGDDLQ89X17X5GXVPYM20V729KLLPH
+  appType:
+  systemToken:
+ekb:
+  preUrl: https://dd2.hosecloud.com
+  appKey: dacdc1ce-ac95-40e5-b42e-9421e1315d7c
+  appSecurity: b679ebe4-aa1d-4638-936b-4f211fab28ed

+ 51 - 0
mjava-santai/src/test/java/com/malk/santai/DdTest.java

@@ -0,0 +1,51 @@
+package com.malk.santai;
+
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.malk.santai.config.StEkbConfig;
+import com.malk.santai.service.StDingProcService;
+import com.malk.utils.UtilMap;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class DdTest {
+
+    @Autowired
+    private StEkbConfig stEkbConfig;
+    @Autowired
+    private StDingProcService stDingProcService;
+
+    @Test
+    public void test(){
+        stDingProcService.fkdSync("JaFP7M4bTF-3qUnkZf5hyg06971714033972");
+    }
+
+    @Test
+    public void ekbTest(){
+        String id="ID01yVMv53gDSL";// "对外付款单"
+        Map map=new HashMap();
+        map.put("accessToken",getToken());
+        map.put("type","payment");
+        map.put("start",0);
+        map.put("count",10);
+        String result=HttpUtil.get(stEkbConfig.getPreUrl().concat("/api/openapi/v2/specifications/byIds/[").concat(id).concat("]"),map);
+        System.out.println(result);
+    }
+
+
+    private String getToken(){
+        String result= HttpUtil.post(stEkbConfig.getPreUrl().concat("/api/openapi/v1/auth/getAccessToken"),JSONObject.toJSONString(UtilMap.map("appKey, appSecurity",stEkbConfig.getAppKey(),stEkbConfig.getAppSecurity())));
+        return JSONObject.parseObject(result).getJSONObject("value").getString("accessToken");
+    }
+
+}