Forráskód Böngészése

NC定时任务测试及结构调整

fyz 1 hónapja%!(EXTRA string=óta)
szülő
commit
faa13b0060

+ 2 - 0
mjava-lanyun/src/main/java/com/malk/lanyun/controller/TimerController.java

@@ -86,11 +86,13 @@ public class TimerController {
     }
     @RequestMapping("testGetNcCollection")
     McR testGetNcCollection(@RequestBody Map data) {
+        log.info("开始手动执行NC部门成本");
         ncService.getNcCollection(data);
         return McR.success();
     }
     @RequestMapping("testGetNcCollectionOld")
     McR testGetNcCollectionOld(@RequestBody Map data) {
+        log.info("开始手动执行NC部门管理费用");
         ncService.getNcCollectionOld(data);
         return McR.success();
     }

+ 1 - 0
mjava-lanyun/src/main/java/com/malk/lanyun/service/impl/TimerServiceImpl.java

@@ -1941,6 +1941,7 @@ public class TimerServiceImpl implements TimerService {
                         Calendar calendar = Calendar.getInstance();
                         calendar.setTime(date);
                         // 设置日期为当月第一天
+                        // 设置日期为当月第一天
                         calendar.set(Calendar.DAY_OF_MONTH, 1);
                         // 调整为下月第一天
                         calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 1);

+ 3 - 1
mjava/src/main/java/com/malk/server/aliwork/YDConf.java

@@ -53,6 +53,7 @@ public class YDConf {
         multi_retrieve_id,
 
         retrieve_id,                // 单个ID查询 todo 若秘钥不匹配, 返回空, 添加报错说明
+        retrieve_id_new,                // 单个ID查询 todo 若秘钥不匹配, 返回空, 添加报错说明
 
         retrieve_search_process,            // 流程列表
         retrieve_search_form,               // 表单列表
@@ -65,7 +66,8 @@ public class YDConf {
         retrieve_changed,    // 变更记录
         retrieve_definition, // 表单定义,
         retrieve_approval_record,
-        getRunningTasks             //查询运行任务
+        getRunningTasks,             //查询运行任务
+        getFormFields  //获取组件列表
 
     }
 

+ 9 - 0
mjava/src/main/java/com/malk/server/dingtalk/DDR_New.java

@@ -97,6 +97,15 @@ public class DDR_New<T> extends VenR {
      */
     private Map dentry;
 
+    /**
+     * 文件链接
+     */
+    private String url;
+
+    /**
+     * 是否支持水印
+     */
+    private Boolean hasWaterMark;
     /**
      * 钉盘: 下一页的游标,为空字符串则表示分页结束
      */

+ 10 - 0
mjava/src/main/java/com/malk/service/aliwork/impl/YDClientImpl.java

@@ -51,6 +51,10 @@ public class YDClientImpl implements YDClient {
     private String getRequestUrl(String uri, String instanceId) {
         return getRequestUrl(uri) + "/" + instanceId;
     }
+    private String getRequestUrl_v2(String uri, String instanceId) {
+        return getRequestUrl_v2(uri) + "/" + instanceId;
+    }
+
 
     /**
      * 操作数据
@@ -121,6 +125,9 @@ public class YDClientImpl implements YDClient {
             case retrieve_id:
                 ddr_new = DDR_New.doGet(getRequestUrl("/forms/instances", ydParam.getFormInstanceId()), ddClient.initTokenHeader(), param);
                 break;
+            case retrieve_id_new:
+                ddr_new = DDR_New.doGet(getRequestUrl_v2("/forms/instances", ydParam.getFormInstanceId()), ddClient.initTokenHeader(), param);
+                break;
             case retrieve_search_process:
                 ddr_new = DDR_New.doPost(getRequestUrl("/processes/instances"), ddClient.initTokenHeader(), param, param);
                 break;
@@ -152,6 +159,9 @@ public class YDClientImpl implements YDClient {
             case retrieve_approval_record:
                 ddr_new = DDR_New.doGet(getRequestUrl("/processes/operationRecords"), this.ddClient.initTokenHeader(), param);
                 break;
+            case getFormFields:
+                ddr_new = DDR_New.doGet(getRequestUrl("/forms/formFields"), this.ddClient.initTokenHeader(), param);
+                break;
         }
         return ddr_new;
     }

+ 40 - 0
mjava/src/main/java/com/malk/service/dingtalk/DDClient_Storage.java

@@ -61,6 +61,14 @@ public interface DDClient_Storage {
      */
     boolean addSpacePermissions(String access_token, String spaceId, String dentryId, String unionId, String roleId, List<Map> members, Map option);
 
+    /**
+     * 添加权限《新》
+     *
+     * @param roleId   权限角色Id。 OWNER:拥有者, MANAGER:管理者, EDITOR:编辑者, DOWNLOADER:下载者, READER:查看者
+     * @param members  权限成员列表,最大值30。[配置详见文档]
+     */
+    boolean addSpacePermissionsNew(String access_token, String dentryUuid, String unionId, String roleId, List<Map> members, Map option);
+
     ///////////////////////// 通用上传逻辑 /////////////////////////
 
     /**
@@ -72,6 +80,24 @@ public interface DDClient_Storage {
      */
     DDR_New getUploadInfos(String access_token, String spaceId, String unionId, Map option);
 
+    /**
+     * 获取文件上传信息(新)
+     * @param access_token
+     * @param unionId
+     * @param option
+     * @return
+     */
+    DDR_New getUploadInfosNew(String access_token, String parentDentryUuid, String unionId, Map option);
+
+    /**
+     * 获取知识库文件上传信息
+     *
+     * @implNote protocol 通过指定上传协议返回不同协议上传所需要的信息。HEADER_SIGNATURE:Header加签
+     * @implNote multipart 是否需要分片上传。 true:需要; false:不需要. 说明: 5G以下文件,设为false,简化上传步骤。
+     * 5G以上文件,必须设为true,否则会上传失败。
+     */
+//    DDR_New getKnowledgeUploadInfos(String access_token, String spaceId, String unionId, Map option);
+
     /**
      * 文件上传
      *
@@ -86,4 +112,18 @@ public interface DDClient_Storage {
      * @param parentId 父目录Id。根目录时,该参数是0。
      */
     Map commitFiles(String access_token, String spaceId, String unionId, String uploadKey, String name, String parentId, Map option);
+
+    /**
+     * 提交文件(新)
+     *
+     * @param name     文件的名称,带后缀 [注意命名规范]
+     */
+    Map commitFilesNew(String access_token, String parentDentryUuid, String unionId, String uploadKey, String name, Map option);
+
+    /**
+     * 搜索文件
+     *
+     * @param dentryId 文件uuid。
+     */
+    Map searchFiles(String access_token, String spaceId, String unionId, String dentryId, Map option);
 }

+ 13 - 0
mjava/src/main/java/com/malk/service/dingtalk/DDService.java

@@ -48,6 +48,19 @@ public interface DDService {
      */
     Map uploadFileFormUrlForDingDrive(String accessToken, String unionId, String spaceId, String parentId, String urlFile, String fileNamePure);
 
+    /**
+     * 上传知识库文件
+     *
+     * @param urlFile      远程文件地址
+     * @param fileNamePure 氚云前端直接获取的附件ID,且免登后也无文件相关信息。若需要如文件名称,需要单独再查询SQL. 因此不能通过url截取文件名称
+     */
+    Map uploadFileFormUrlForKnowledge(String accessToken, String userId, String parentDentryUuid, String urlFile, String fileNamePure);
+
+    /**
+     * 获取钉盘文件下载信息 (可从上传钉盘信息里获取)
+     */
+    Map downloadInfos(String accessToken, String unionId, String spaceId, String dentryId, Map option);
+
     // todo 通讯录部门结构返回; 通讯录全量数据同步; 限流控制
 
     /**

+ 62 - 0
mjava/src/main/java/com/malk/service/dingtalk/impl/DDImplClient_Storage.java

@@ -16,6 +16,7 @@ import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -154,6 +155,18 @@ public class DDImplClient_Storage implements DDClient_Storage {
         return DDR_New.doPost(url, header, param, body).isSuccess();
     }
 
+    @Override
+    public boolean addSpacePermissionsNew(String access_token, String dentryUuid, String unionId, String roleId, List<Map> members, Map option) {
+        String url = "https://api.dingtalk.com/v2.0/storage/spaces/dentries/" + dentryUuid + "/permissions";
+        Map header = DDConf.initTokenHeader(access_token);
+        Map param = UtilMap.map("unionId", unionId);
+        Map body = UtilMap.map("roleId, members, option", roleId, members, option);
+//        if (ObjectUtil.isNotNull(option)) {
+//            body.putAll(option);
+//        }
+        return DDR_New.doPost(url, header, param, body).isSuccess();
+    }
+
     ///////////////////////// 通用上传逻辑 /////////////////////////
 
     /**
@@ -172,6 +185,24 @@ public class DDImplClient_Storage implements DDClient_Storage {
         }
         return DDR_New.doPost(path, header, param, body);
     }
+    /**
+     * 获取文件上传信息 (新)
+     *
+     * @apiNote https://open.dingtalk.com/document/development/upload-files-to-the-knowledge-base
+     */
+    @Override
+    public DDR_New getUploadInfosNew(String access_token, String parentDentryUuid, String unionId, Map option) {
+        String path = "https://api.dingtalk.com/v2.0/storage/spaces/files/" + parentDentryUuid + "/uploadInfos/query";
+        Map header = DDConf.initTokenHeader(access_token);
+        Map param = UtilMap.map("unionId", unionId);
+        Map body = new HashMap<>();
+        body.put("protocol","HEADER_SIGNATURE");
+        body.put("option",option);
+        if (ObjectUtil.isNotNull(option)) {
+            body.putAll(option);
+        }
+        return DDR_New.doPost(path, header, param, body);
+    }
 
     /**
      * 文件上传 [官方]
@@ -226,4 +257,35 @@ public class DDImplClient_Storage implements DDClient_Storage {
         DDR_New ddr = DDR_New.doPost(url, header, param, body);
         return ddr.getDentry();
     }
+
+    @Override
+    public Map commitFilesNew(String access_token, String parentDentryUuid, String unionId, String uploadKey, String name, Map option) {
+        String url = "https://api.dingtalk.com/v2.0/storage/spaces/files/" + parentDentryUuid + "/commit";
+        Map header = DDConf.initTokenHeader(access_token);
+        Map param = UtilMap.map("unionId", unionId);
+        Map body = UtilMap.map("uploadKey, name", uploadKey, name);
+        if (ObjectUtil.isNotNull(option)) {
+            body.putAll(option);
+        }
+        DDR_New ddr = DDR_New.doPost(url, header, param, body);
+        return ddr.getDentry();
+    }
+
+    /**
+     * 搜索文件  https://open.dingtalk.com/document/development/obtains-the-object-preview-or-editing-information
+     */
+    @Override
+    public Map searchFiles(String access_token, String spaceId, String unionId, String dentryId, Map option) {
+        String url = "https://api.dingtalk.com/v1.0/storage/spaces/" + spaceId + "/dentries/"+dentryId+"/openInfos/query";
+        Map header = DDConf.initTokenHeader(access_token);
+        Map param = UtilMap.map("unionId", unionId);
+//        Map body = UtilMap.map("uploadKey, name, parentId", uploadKey, name, parentId);
+        Map body = new HashMap<>();
+        if (ObjectUtil.isNotNull(option)) {
+            body.putAll(option);
+        }
+        DDR_New ddr = DDR_New.doPost(url, header, param, body);
+
+        return UtilMap.map("url, hasWaterMark",ddr.getUrl(),ddr.getHasWaterMark());
+    }
 }

+ 28 - 0
mjava/src/main/java/com/malk/service/dingtalk/impl/DDImplService.java

@@ -162,6 +162,34 @@ public class DDImplService implements DDService {
         return dentry;
     }
 
+    @Override
+    public Map uploadFileFormUrlForKnowledge(String accessToken, String userId, String parentDentryUuid, String urlFile, String fileNamePure) {
+        File file = UtilFile.mkdirIfNot(fileNamePure, filePath.getPath().getFile());
+        UtilHttp.doDownload(urlFile, file);
+        String unionId = String.valueOf(ddClient_contacts.getUserInfoById(accessToken, userId).get("unionid"));
+        // 获取空间上传信息
+        DDR_New ddr_new = ddClient_storage.getUploadInfosNew(accessToken, parentDentryUuid, unionId, null);
+//        DDR_New ddr_new = ddClient_storage.getUploadInfos(accessToken, spaceId, unionId, null);
+        // 执行文件上传
+        String resourceUrl = ((List<String>) ddr_new.getHeaderSignatureInfo().get("resourceUrls")).get(0);
+        ddClient_storage.uploadFiles(resourceUrl, (Map<String, String>) ddr_new.getHeaderSignatureInfo().get("headers"), file.getAbsolutePath());
+//        ddClient_storage.uploadFiles(resourceUrl, (Map<String, String>) ddr_new.getHeaderSignatureInfo().get("headers"), urlFile);
+        // 提交文件
+        Map dentry = ddClient_storage.commitFilesNew(accessToken, parentDentryUuid, unionId, ddr_new.getUploadKey(), fileNamePure, null);
+        // 删除本地临时文件
+        UtilFile.deleteFile(file.getAbsolutePath());
+        return dentry;
+    }
+
+    /**
+     *  获取钉盘文件下载信息 (可从上传钉盘信息里获取)
+     *  https://open.dingtalk.com/document/development/obtains-the-download-information-about-a-file
+     */
+    @Override
+    public Map downloadInfos(String accessToken, String unionId, String spaceId, String dentryId, Map option) {
+        return null;
+    }
+
     /**
      * 判断员工是否在指定部门
      */